Author Topic: Prevent creatures from leaving an area (following the PC outside)  (Read 558 times)

Legacy_FlowerGolem

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0


               Hi,

I have designed a house full of rats, and I would like that those rats do not leave the house by following the PC when (s)he is fleeing.

How can I do that?

Thanks in advance. '<img'>
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Prevent creatures from leaving an area (following the PC outside)
« Reply #1 on: March 23, 2011, 11:24:29 pm »


               You can make a trigger in front of the door that jumps any rats that enter it back to some waypoint.

-420
               
               

               
            

Legacy_FlowerGolem

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
Prevent creatures from leaving an area (following the PC outside)
« Reply #2 on: March 26, 2011, 06:49:03 pm »


               I tried what you suggested, but it didn't work correctly. I could teleport some rats around, but not all of them, and especially not when I was leaving the house ; they were all following me, ignoring the teleport trigger.

But never mind, I got another idea to make this area more manageable.
               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Prevent creatures from leaving an area (following the PC outside)
« Reply #3 on: April 06, 2011, 05:41:22 pm »


               Check monsters leaving through an area transition in NW_G0_Transition.nss and run a function like this on all transition-ers that aren't a PC, henchmen, summon etc..

object oCritter = GetEnteringObject();
object oTarget = GetTransitionTarget(OBJECT_SELF);
effect eDamage;

if( *REQUIREMENTS HERE* ){
{
eDamage = EffectDamage(GetCurrentHitPoints(oCritter)+15 , DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_TWENTY);
eDamage = SupernaturalEffect(eDamage);
ApplyEffectToObject (DURATION_TYPE_INSTANT, eDamage,oCritter);
}
else
{
AssignCommand(oCritter,JumpToObject(oTarget));
}

If you don't put requirements, this will kill anyone who tries to make a transition anywhere in the game. If you only want this idea applying to certain exits, apply them to triggers instead of adding them to NW_G0_Transition.nss

Alternatively, you could set a localvariable on spawning enemies, and use that local variable as the check in the IF statement. That way it would only apply to monsters with this variable (in which case make sure NPCs dont get this variable too)
               
               

               


                     Modifié par EzRemake, 06 avril 2011 - 04:45 .
                     
                  


            

Legacy_datamaster

  • Jr. Member
  • **
  • Posts: 94
  • Karma: +0/-0
Prevent creatures from leaving an area (following the PC outside)
« Reply #4 on: May 08, 2011, 07:40:20 pm »


               I will have to check on one of my modules, but I have a script I place in the door/area trigger OnUsed or is it AreaTransitionClick script that says if the creature is not a PC do nothing.  This keeps them from following.  When I am back on the computer with this I will check and post it, if no one else has by then.
               
               

               
            

Legacy_datamaster

  • Jr. Member
  • **
  • Posts: 94
  • Karma: +0/-0
Prevent creatures from leaving an area (following the PC outside)
« Reply #5 on: May 08, 2011, 08:18:25 pm »


               Ok this is the script I have that keeps NPCs/creatures from following a PC through an area transition.

//place in OnClick for Trigger or OnAreaTransitionClick for door
void main()
{
  object oClicker = GetClickingObject();
  object oTarget = GetTransitionTarget(OBJECT_SELF);
  if(GetIsPC(oClicker))
    {
        SetAreaTransitionBMP(AREA_TRANSITION_RANDOM);
        AssignCommand(oClicker,JumpToObject(oTarget));
    }
  else
        ClearAllActions();
}

Since I started using that script, I have had no problems with monsters following PCs
through doors in modules I make.  Unless I want them too, of course.