Aller au contenu

Photo

Help! Monsters follow through transitions


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

#1
0pie

0pie
  • Members
  • 37 messages
 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 :)

#2
Shadooow

Shadooow
  • Members
  • 4 470 messages
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...

#3
0pie

0pie
  • Members
  • 37 messages
Thank you ShaDoOoW !

#4
0pie

0pie
  • Members
  • 37 messages
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.

#5
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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.

#6
0pie

0pie
  • Members
  • 37 messages
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 !

#7
Xovian

Xovian
  • Members
  • 87 messages
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 .


#8
0pie

0pie
  • Members
  • 37 messages
Thanks for all the information. It helps a lot.

#9
0pie

0pie
  • Members
  • 37 messages
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 ?

#10
Xovian

Xovian
  • Members
  • 87 messages
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.

#11
0pie

0pie
  • Members
  • 37 messages
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());
}

#12
Xovian

Xovian
  • Members
  • 87 messages

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.

#13
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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.

#14
Xovian

Xovian
  • Members
  • 87 messages
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.

#15
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

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.  

#16
0pie

0pie
  • Members
  • 37 messages

Lightfoot8 wrote...

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.


- Only noticed it recently ( a week perhaps )
- Grease & Cloud of Bewildermint
- yes only when AoE's are around and player dies.
- not sure what a spell hook is
- yes "x2_def_spawn"
- no no Haks
- no, at least I didnt notice it or it didnt happen until recently.

Here is my alterd OnSpawn script


//:://///////////////////////////////////////////////:: Name x2_def_spawn//:: Copyright © 2001 Bioware Corp.//::///////////////////////////////////////////////*    Default On Spawn script

    2003-07-28: Georg Zoeller:
    If you set a ninteger on the creature named    "X2_USERDEFINED_ONSPAWN_EVENTS"    The creature will fire a pre and a post-spawn    event on itself, depending on the value of that    variable    1 - Fire Userdefined Event 1510 (pre spawn)    2 - Fire Userdefined Event 1511 (post spawn)    3 - Fire both events
    2007-12-31: Deva Winblood    Modified to look for X3_HORSE_OWNER_TAG and if    it is defined look for an NPC with that tag    nearby or in the module (checks near first).    It will make that NPC this horse's master.
*///::////////////////////////////////////////////////:: Created By: Keith Warner, Georg Zoeller//:: Created On: June 11/03//:://////////////////////////////////////////////
const int EVENT_USER_DEFINED_PRESPAWN = 1510;const int EVENT_USER_DEFINED_POSTSPAWN = 1511;

#include "x2_inc_switches"void main(){    string sTag;    object oNPC;    // User defined OnSpawn event requested?    int nSpecEvent = GetLocalInt(OBJECT_SELF,"X2_USERDEFINED_ONSPAWN_EVENTS");

    // Pre Spawn Event requested    if (nSpecEvent == 1  || nSpecEvent == 3  )    {    SignalEvent(OBJECT_SELF,EventUserDefined(EVENT_USER_DEFINED_PRESPAWN ));    }
    sTag=GetLocalString(OBJECT_SELF,"X3_HORSE_OWNER_TAG");    if (GetStringLength(sTag)>0)    { // look for master        oNPC=GetNearestObjectByTag(sTag);        if (GetIsObjectValid(oNPC)&&GetObjectType(oNPC)==OBJECT_TYPE_CREATURE)        { // master found            AddHenchman(oNPC);        } // master found        else        { // look in module            oNPC=GetObjectByTag(sTag);            if (GetIsObjectValid(oNPC)&&GetObjectType(oNPC)==OBJECT_TYPE_CREATURE)            { // master found                AddHenchman(oNPC);            } // master found            else            { // master does not exist - remove X3_HORSE_OWNER_TAG                DeleteLocalString(OBJECT_SELF,"X3_HORSE_OWNER_TAG");            } // master does not exist - remove X3_HORSE_OWNER_TAG        } // look in module    } // look for master
    /*  Fix for the new golems to reduce their number of attacks */
    int nNumber = GetLocalInt(OBJECT_SELF,CREATURE_VAR_NUMBER_OF_ATTACKS);    if (nNumber >0 )    {        SetBaseAttackBonus(nNumber);    }
    // Execute default OnSpawn script.    ExecuteScript("nw_c2_default9", OBJECT_SELF);

    //Post Spawn event requeste    if (nSpecEvent == 2 || nSpecEvent == 3)    {    SignalEvent(OBJECT_SELF,EventUserDefined(EVENT_USER_DEFINED_POSTSPAWN));    } // Set Locals to support Wolfie's Return Home Scriptlet in HeartbeatSetLocalLocation(OBJECT_SELF, "WHERE_I_SPAWNED", GetLocation(OBJECT_SELF));SetLocalInt(OBJECT_SELF, "NPC_FUNCTIONSTATE",0);}


Thanks for all the help guys 8)

#17
Knight_Shield

Knight_Shield
  • Members
  • 444 messages
Have you done a module build after changing scripts? Never know might show an uncompiled script or something useful.Just a thought .

#18
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Have any of the following scripts been modified.

NW_S0_GreaseA
NW_S0_GreaseB
NW_S0_GreaseC
X2_S0_CldBewldA
****
X2_S0_CldBewldC