//put in the onUsed of the door.
/*
links two doors together, so they are in the same open state, ie, you don't enter through a door you opened, and transition to a new area, to find the door you ostensibly entered through in the closed state.
door automatically closes a short time after being opened, unless it's outside of the doors "open" hours.
*/
void main()
{
int nOpenHour =GetLocalInt(OBJECT_SELF, "open_hour");
int nCloseHour =GetLocalInt(OBJECT_SELF, "close_hour");
int nCurrentTime =GetTimeHour();
object oLinkedDoor = GetObjectByTag(GetLocalString(OBJECT_SELF, "linked_door"));
// object oLinkedArea = GetObjectByTag(GetLocalString(OBJECT_SELF, "linked_area"));
//set the linked door to same open/closed/destroyed state
SetLocked(oLinkedDoor,FALSE); //this side was opened, so unlock the other side if it was locked.
if (GetLocalInt(OBJECT_SELF, "called_from_linked")==1)
{
SetLocalInt(oLinkedDoor, "called_from_linked", 0);
SetLocalInt(OBJECT_SELF, "called_from_linked", 0);
AssignCommand(oLinkedDoor , ActionOpenDoor(oLinkedDoor));
//"shop hours" code
if ((nOpenHour<nCurrentTime)&&(nCurrentTime<nCloseHour))
{
SendMessageToPC(GetFirstPC(),"Debug: delayed door close.");
DelayCommand(7.5,ActionCloseDoor(oLinkedDoor));
}
else //do nothing, building is not open, leave in state player left it.
{
}
}
else
{
SetLocalInt(OBJECT_SELF,"called_from_linked",1);
SetLocalInt(oLinkedDoor,"called_from_linked",1);
if ((nOpenHour<nCurrentTime)&&(nCurrentTime<nCloseHour))
{
SendMessageToPC(GetFirstPC(),"Debug: delayed door close.");
DelayCommand(7.5,ActionCloseDoor(oLinkedDoor));
}
else //do nothing, building is not open, leave in state player left it.
{
}
//make sure first time open opens linked
int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
if (DoOnce==TRUE) return;
SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
AssignCommand(oLinkedDoor , ActionOpenDoor(oLinkedDoor));
}
}
Modifié par kamal_, 31 mai 2012 - 10:58 .





Retour en haut






