Author Topic: Best way to block a PC from entering a trigger region  (Read 675 times)

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« on: November 25, 2015, 09:50:38 pm »


               

Okay, I want to create a region in my city map that cannot be accessed in the beginning.


 


I'm want the character to move away from there onEnter but I just can't do it right.


 


I've tried with the following:



void main()
{
    location lTrigger = GetLocation(OBJECT_SELF);
    object oPC = GetEnteringObject();

    if (!GetIsPC(oPC)) return;

    AssignCommand(oPC, ClearAllActions());
    AssignCommand(oPC, ActionDoCommand(SetCutsceneMode(oPC, TRUE)));
    FloatingTextStringOnCreature("Better not go there...", oPC);
    AssignCommand(oPC, ActionMoveAwayFromLocation(lTrigger));
    AssignCommand(oPC, ActionDoCommand(SetCutsceneMode(oPC, FALSE)));

}

It kind of works but after 2-3 fast clicks the PC can enter the region...


 


I would really really appreciate some ideas! Is there some better way of doing something like this?



               
               

               
            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #1 on: November 25, 2015, 10:18:40 pm »


               

Another way to address the objective is to assign a local variable to the PCs who have permission to enter that part of the city.  Then, use the trigger to check for the variable.  If the variable exists, then JumpAssociates.  If not, do nothing.


 


For example, if PCs need to speak to an NPC in order to gain permission to enter that part of the city, then during the conversation with the NPC, apply the variable onto the PC or an item in the PC's inventory (for persistence).  When the PC subsequently enters the trigger, the OnEnter script checks for the variable and decides what to do based on whether or not it is found.


 


I've tried various 'bounce-back' scripts and have found, like you, that there are ways to defeat them.



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #2 on: November 26, 2015, 01:47:52 am »


               

Option B


 


Place an "Invisible Wall (blocks movement)" placeable (in the toolset under "Miscellaneous"), blocking access to the transition you don't want the PC to access.  When the conditions are met for the PC to proceed to the next area, destroy the blocker placeable, allowing them access to the transition. You may have to place more than one blocker depending on how the transition is positioned.


 


Option C


 


If the transition is a door, lock it, and tag it as having a key, but do not assign a key tag. When the PC can use the transition, use the command SetLockKeyRequired(oDoor, FALSE); in a script to remove the lock requirement followed by the SetLocked(oDoor, FALSE); command to unlock the door.



               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #3 on: November 26, 2015, 02:19:33 am »


               

Option C is the best bet.  The message about not wanting to go that way can go into the OnFailToOpen script slot to provide your feedback message on it, and there's no way around it without DM or script unlocking of the door.



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #4 on: November 26, 2015, 02:22:57 am »


               


Option C is the best bet.  The message about not wanting to go that way can go into the OnFailToOpen script slot to provide your feedback message on it, and there's no way around it without DM or script unlocking of the door.




 


Yes option C is always my preferred method. I only use option 2 when the "door" is one of those non-rendering area transition doors - like the ones used for cave entrances and the like.



               
               

               
            

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #5 on: November 26, 2015, 03:30:17 pm »


               

I'll take a look at this "Invisible Wall (blocks movement)" placeable.


 


The thing is I can't use a door as the situation doesn't allow it.


 


Here it is:


The PC is near a Merchant's house and talk to his Henchman on how to proceed with the stealing of an item inside. The Henchman knocks on the door and starts talking to the merchant's wife. Meanwhile the PC has to go through the back window of the house while he is not seen of a nearby patrolling guard.


And here is the problem:


I want to somehow stop the player from going to the door near the henchman and the merchant's wife as it will ruin the immersion of the whole situation.



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #6 on: November 26, 2015, 05:14:13 pm »


               Perhaps a trigger around the door could break the conversation and close the door? e.g. "there are two of you! I don't loke the look of this!" [slam]
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #7 on: November 26, 2015, 05:17:23 pm »


               I think your best bet is to edit a copy of the nw_g0_transition script and use that. Then you can stop the PC easily enough. I don't recall if it's easy to point a transition to a different script or if they all default to that. If so and you don't want to edit that globally I think you can put an on clicked handler that does a ClearAllActions if the clicker is a PC. Sorry for the vagueness. I'm remote with only a phone...
               
               

               
            

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #8 on: November 26, 2015, 07:47:01 pm »


               


Perhaps a trigger around the door could break the conversation and close the door? e.g. "there are two of you! I don't loke the look of this!" [slam]




 


Yes, I was thinking of something like this but then another problem appears. When The henchman and the merchant wife are "pushed" from the PC they amove aside.


How can an NPC be changed to stay at it's position and to not react on a PC pushing it.


 



I think your best bet is to edit a copy of the nw_g0_transition script and use that. Then you can stop the PC easily enough. I don't recall if it's easy to point a transition to a different script or if they all default to that. If so and you don't want to edit that globally I think you can put an on clicked handler that does a ClearAllActions if the clicker is a PC. Sorry for the vagueness. I'm remote with only a phone...




I suppose this is best done if there is a TriggerIn inside a TriggerOut trigger region and when TriggerIn is clicked , it only reacts OnClick if the PC is staying in TriggerOut.


Isn't nw_g0_transition  only for area transitions?



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #9 on: November 26, 2015, 09:48:49 pm »


               Sorry. I assumed from your description of the problem you were talking about the inside and outside of a house and so had an area transition...
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #10 on: November 26, 2015, 11:35:42 pm »


               Re pushing aside - I think PC always has bump priority over henchmen, but NPCs in custom factions seem to block PCs. You can tweak perspace in appearance.2da to make a creature block more effectively.


If the trigger is quite big, it should be possible to close and lock the door before the PC has time to use it.


Probably academic here, but if you need a version of nw_g0_transition with a user exit, you can rip it from my Travel Builder suite (it works stand-alone).
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #11 on: November 27, 2015, 12:16:36 am »


               

What you are describing might be better handled as a cutscene. During a cutscene the Builder has the ability to take full control of the PC, forcing them to do something - in this case moving to the window and going through it. The dialog between the henchman and NPC will still be visible - at least until the PC transitions into the house.


 


Start cutscene mode, have the henchman talk to the NPC, and move the PC to the window, end the cutscene, and transition the PC inside the house.


 


At some point, you'll have to fire the henchman, so that they keep the NPC busy, and then rehire them when the PC completes the task. If you don't fire the henchman, they'll jump inside the house with the PC, breaking immersion and leaving players asking themselves "wasn't he/she supposed to keep the merchant's wife busy?"


 


Cutscenes are more work, but I think in this case, the end results will pay off.



               
               

               
            

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #12 on: November 27, 2015, 09:58:42 am »


               


Re pushing aside - I think PC always has bump priority over henchmen, but NPCs in custom factions seem to block PCs. You can tweak perspace in appearance.2da to make a creature block more effectively.




 


As the henchman is already fired, then I suppose making him custom faction will deal with the blocking problem.


 





Probably academic here, but if you need a version of nw_g0_transition with a user exit, you can rip it from my Travel Builder suite (it works stand-alone).





Thanks! I'm bookmarking this.


 




Start cutscene mode, have the henchman talk to the NPC, and move the PC to the window, end the cutscene, and transition the PC inside the house.




Yeah, that's how I was thinking to go with the scene but I wanted the player to wait for a nearby guard and go through the window while he is not seen. I suppose I will just remove this idea (thinking of it, it's not a lot of fun to wait for a guard to pass by).



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #13 on: November 27, 2015, 10:23:10 am »


               

Sorry- haven't read all the replies here, but the issue with ActionMoveAway and onEnter is:


The onEnter only triggers once per entry, so if someone does manage to click rapidly enough, they can manage to 'stay' within the trigger indefinitely without further triggering.


 


I solved this issue on my server by doing JumpToObject on an invisible object / waypoint that is far enough away from the trigger that it is impossible to rapidly click back into it.


Doesnt have to be miles away, just maybe 3-5 ft away, your character will look like they are gliding /sliding into position - but it will bounce them out of the locations they are not meant to be in.


I do this in barrier scripts 


But it could be adapted for large areas.


You would just need to modify the script to find the nearest tp location around the circumference of the area.


So it retains the slide/glide effect on the JumpToObject


 


Otherwise if someone enters the trigger from the north, and the tp location is on the south, then it will teleport them, instead of bouncing them.



               
               

               
            

Legacy_Zeke

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
Best way to block a PC from entering a trigger region
« Reply #14 on: November 27, 2015, 11:44:54 am »


               


You would just need to modify the script to find the nearest tp location around the circumference of the area.


So it retains the slide/glide effect on the JumpToObject


 


Otherwise if someone enters the trigger from the north, and the tp location is on the south, then it will teleport them, instead of bouncing them.




I guess the best way would be to surround the area with a couple of such objects and the JumpTo the nearest one?


 


So while the character is sliding, it's impossible to click rapidly and stop it?


 


 


 


(I love this forum, a lot of helpful people here. Thank you!)