Aller au contenu

Photo

linked doors


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
kamal_

kamal_
  • Members
  • 5 260 messages
I'm trying to link doors together. This code works fine as long as the two doors are in the same area, but when one is in another area, the game locks up. ? I'm sure I've missed something trivial.

//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 .


#2
Dann-J

Dann-J
  • Members
  • 3 161 messages
If you use direct door-to-door transitions (rather than to waypoints), then the second door opens automatically when you get where you're going. The downside is that your party tends to be jammed together on the other side, which makes instant fights (like the Luskan outpost in SoZ) very difficult. I prefer waypoint transitions though.

Perhaps it would be better to set a local variable on the player, then have an OnEnter script that checks for the variable and opens the nearest door (then deletes the local variable again)?

#3
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
It might be this door action:
DelayCommand(7.5,ActionCloseDoor(oLinkedDoor));

The game locks up when one door tries to pathfind its way to the linked door to do the action. You had it right above, with assigning the locked door to open itself. You can create a wrapper function to perform the AssignCommand and return VOID, and then use the wrapper function in your DelayCommand.

#4
Morbane

Morbane
  • Members
  • 1 883 messages
AssignCommand(oPC, ActionJumpToLocation(GetLocation(GetObjectByTag("DoorTag"))));

#5
kamal_

kamal_
  • Members
  • 5 260 messages
I hate the door to door transitions for the party bunching as Dannj said, as well as the tendency for camera issues where the camera has a bad angle in the new area. So i try to always transition to waypoints so i can better space things.

I'll look at Lugaid's suggestion first, that seems promising.