Author Topic: Help! Monsters follow through transitions  (Read 924 times)

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Help! Monsters follow through transitions
« on: March 02, 2011, 10:53:21 pm »


                How do I keep monsters in the area they spawn in ? For example I have 2 areas connected by a standard transition and the monsters follow over to the next transition, I want to stop this from happening. Also I had a major problem on my server where a person would die port back to town and a few moments later all the monsters he was fighting would show up in town. 

So I guess I need a way for monsters to drop "aggro" once no PC's are in the area. I already have a area cleanup script that runs in my OnExit for each area. So they will despawn in time if I can simply get them to not go through transitions, and even worse somehow teleport across my world into town to continue fighting someoen who died. Thanks to anyone who helps me '<img'>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #1 on: March 02, 2011, 11:01:19 pm »


               standard script nw_g0_transition

add this under line     object oClicker=GetClickingObject();

if(!GetIsPC(oClicker))
{
return;
}

Then monsters stop before the transition so its a good idea to clean them otherwise they ambush other PC comming in...
               
               

               
            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #2 on: March 02, 2011, 11:16:28 pm »


               Thank you ShaDoOoW !
               
               

               
            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #3 on: March 02, 2011, 11:34:31 pm »


               Well that kind of worked. Now they wont follow through transitions ( thanks ) but when a player dies and returns to town they somehow port to him no matter how far away he is. This is exactly what happens if it will help.

Player spams AoE spells
Player dies to mobs
player returns to town and rests
about 15 seconds later all the monsters show up in town that he was fighting.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #4 on: March 03, 2011, 12:25:05 am »


               Your problem here does not sound like it is happening because of the standard unmodified NWN scripts.  More information is needed to try and figure out what is going wrong.
When did this start happening?
Have you installed any new content that could have caused it to start happening?  
Have you modified any af the default henchman scripts?
What AoE spells are being spammed.
               
               

               
            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #5 on: March 03, 2011, 04:45:17 am »


               I think it was a modified OnHeartbeat script I just put in. I noticed it was only happening after combat was over and my script told the monsters/npc's to return to there original spawn point. But somehow they were jumping to my players in town. Thanks to everyone for your help !
               
               

               
            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #6 on: March 03, 2011, 07:13:36 am »


               Sounds like you have one of the on module load switches turned on.

from "x2_inc_switches"

// * AI: Activating the switch below will make the creaures using the WalkWaypoint function
  // * able to walk across areas
  // SetModuleSwitch (MODULE_SWITCH_ENABLE_CROSSAREA_WALKWAYPOINTS, TRUE);


Make sure it is false if you do not want monsters to follow players through transitions.
As despite what the function says, it is not limited to just waypoints, but allows hostiles to transition in pursuit.
This is likely if you are using X2_mod_def_load.

Edit*
Another thing to check would be to make sure your Onheartbeat is not using the command: GetNearestEnemy, always make sure you use NearestPercievedEnemy (or its variants: seen or heard.)
               
               

               


                     Modifié par Xovian, 03 mars 2011 - 07:20 .
                     
                  


            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #7 on: March 03, 2011, 12:39:29 pm »


               Thanks for all the information. It helps a lot.
               
               

               
            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #8 on: March 04, 2011, 05:46:45 am »


               in x2_inc_switches i found this

//------------------------------------------------------------------------------
// * Setting this switch to TRUE will enable the allow NPCs running between waypoints using the WalkWaypoints
// * function to cross areas, like they did in the original NWN. This was changed in 1.30 to use only
// * waypoints in one area.
//------------------------------------------------------------------------------
const string MODULE_SWITCH_ENABLE_CROSSAREA_WALKWAYPOINTS = "X2_SWITCH_CROSSAREA_WALKWAYPOINTS";

but it dosent say true of false anywhere for me to edit. I'm confused do i make a mod varible  with the string FALSE ?
               
               

               
            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #9 on: March 04, 2011, 06:55:36 am »


               The switch will be turned on/off in X2_mod_def_load, or whatever script you are using for your OnModuleLoad event. the include statement  x2_inc_switches is just the source from where the event pulls the data from.
               
               

               
            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #10 on: March 04, 2011, 03:53:38 pm »


               Did all that , they still follow my players back to town. How about an OnExit script that either puts monsters in limbo ( no loot left behind is why limbo and not death ) , or if a hostile trys to leave the script sends them to a specific location in an empty area with an OnEnter kill script. Would that fix my problem ?

P.S. This is my current OnExit script if anyone could show me how and where to put in the effect i'm looking for that would be handy.


// Area OnExit script to clean up the area.
//:://///////////////////////////////////////

// Function to determine if any PCs are in an area.
int GetIsPCInArea( object oArea = OBJECT_SELF)
{ if( !GetIsObjectValid( oArea) || (GetArea( oArea) != oArea)) return FALSE;

 object oInArea = GetFirstObjectInArea( oArea);
 if( !GetIsObjectValid( oInArea)) return FALSE;
 if( GetIsPC( oInArea)) return TRUE;
 return GetIsObjectValid( GetNearestCreature( CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oInArea));
}


// Function to destroy BodyBags, Encounter creatures, and Items left laying around. Plot items will be left alone.
// Also closes all open doors in the area and locks ones that have a lock on them.
// Only does all this if the area has no PCs in it.
void CleanArea( object oArea = OBJECT_SELF)
{ if( !GetIsObjectValid( oArea) || (GetArea( oArea) != oArea) || GetIsPCInArea( oArea)) return;

 object oObject = GetFirstObjectInArea( oArea);
 while( GetIsObjectValid( oObject))
 { switch( GetObjectType( oObject))
   { case OBJECT_TYPE_CREATURE:
       if( GetIsEncounterCreature( oObject) && !GetPlotFlag( oObject)) DestroyObject( oObject, 0.1f);
       break;

     case OBJECT_TYPE_PLACEABLE:
       if( GetTag( oObject) == "BodyBag")
       { int bPlotFound = FALSE;
         object oObjectInside = GetFirstItemInInventory( oObject);
         while( GetIsObjectValid( oObjectInside))
         { if( GetPlotFlag( oObjectInside)) bPlotFound = TRUE;
           else DestroyObject( oObjectInside, 0.1f);
           oObjectInside = GetNextItemInInventory( oObject);
         }
         if( !bPlotFound) DestroyObject( oObject, 0.2f);
       }
       break;

     case OBJECT_TYPE_ITEM:
       { int bPlotFound = GetPlotFlag( oObject);
         if( !bPlotFound && GetHasInventory( oObject))
         { object oObjectInside = GetFirstItemInInventory( oObject);
           while( GetIsObjectValid( oObjectInside))
           { if( GetPlotFlag( oObjectInside)) bPlotFound = TRUE;
             else DestroyObject( oObjectInside, 0.1f);
             oObjectInside = GetNextItemInInventory( oObject);
           }
         }
         if( !bPlotFound) DestroyObject( oObject, 0.2f);
       }
       break;

     case OBJECT_TYPE_AREA_OF_EFFECT:
       DestroyObject( oObject, 0.1f);
       break;

     case OBJECT_TYPE_DOOR:
       if( GetIsOpen( oObject)) AssignCommand( oObject, ActionCloseDoor( oObject));
       if( !GetLocked( oObject) && GetLockLockable( oObject)) AssignCommand( oObject, ActionDoCommand( SetLocked( oObject, TRUE)));
       break;

     case OBJECT_TYPE_ENCOUNTER:
       // Nothing to clean up with these.
       break;

     case OBJECT_TYPE_STORE:
       // Nothing to clean up with these.
       break;

     case OBJECT_TYPE_TRIGGER:
       // Nothing to clean up with these.
       break;

     case OBJECT_TYPE_WAYPOINT:
       // Nothing to clean up with these.
       break;
   }
   oObject = GetNextObjectInArea( oArea);
 }
}


// Area OnExit main function.
void main()
{ object oExiting = GetExitingObject();
 if( !GetIsPC( oExiting)) return;

 DelayCommand( 300.0f, CleanArea());
}
               
               

               
            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #11 on: March 04, 2011, 04:53:02 pm »


               

0pie wrote...

How about an OnExit script that either puts monsters in limbo ( no loot left behind is why limbo and not death )


This script doesnt put a monster anywhere, it simply destroys them Irrevocably, and entierly.
The script also only destroys encounter creatures, that are not plot, so those that were not done from an encounter are not destroyed.

However, this is not the script causing your problem.
It has to be coming from somewhere else.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #12 on: March 04, 2011, 05:15:19 pm »


               We still do not have enough information to solve you problem.   To help us find an answer for you, We need more information:

When did it start hapening?
What AoE spells where the PC spamming?
Does it only happen when the PC was Spaming the  AoE spell?
If It only Happens when the AoE spells are used. Do you have a spell Hook in place?
Have any of the Default NPC scripts been modified?

AreYou useing any Haks.
Did it start happening after installing any Haks or ERF's

Without answers to at least some of the questions. The places to look for the solution to your problem are just way to many.
               
               

               
            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #13 on: March 04, 2011, 05:29:33 pm »


               I agree Lightfoot, but there is a simply way to remedy this.

Use this for the OnEnter script to the town, or at least add it to the top of your script:

void main()
{
object oPC = GetEnteringObject();
     if (GetIsPC(oPC) || GetIsPossessedFamiliar(oPC) || GetIsDM(oPC) || GetIsDMPossessed(oPC))
       {
        //If it is a Player, DM, or DM with a possessed creature, or possessed familiar do nothing
        return;
       }
else if(GetIsObjectValid(oPC))
{
DestroyObject(oPC, 0.1);
}


The above script is very simple, it destroys anything that is not a player, dm, or possessed familiar coming through the transition. Since only creatures can use transitions, defining the type (object =creature) is not needed.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help! Monsters follow through transitions
« Reply #14 on: March 04, 2011, 07:08:03 pm »


               

Xovian wrote...

I agree Lightfoot, but there is a simply way to remedy this.

Use this for the OnEnter script to the town, or at least add it to the top of your script:


void main()
{
object oPC = GetEnteringObject();
if (GetIsPC(oPC) || GetIsPossessedFamiliar(oPC) || GetIsDM(oPC) || GetIsDMPossessed(oPC))
{
//If it is a Player, DM, or DM with a possessed creature, or possessed familiar do nothing
return;
}
else if(GetIsObjectValid(oPC))
{
DestroyObject(oPC, 0.1);
}


The above script is very simple, it destroys anything that is not a player, dm, or possessed familiar coming through the transition. Since only creatures can use transitions, defining the type (object =creature) is not needed.

 Ok, so we place this on enter of the area?
Problem solved there are no monsters to folow the PC in the first place.     Every single creature will fire the onEnter event.