Here's the final solution:
UPDATE --
In order to control when the following script actually intercepts events, I have done the following (thanks to some help form David Sims in another thread)
RecklezzRogue said..
David - thank you - you got me there - I can now do event intercepts, without impacting (in any noticeable way) other modules...here's what I did in the end:
1 - created a 2da override for var_module wherein the variable DMO001_EVENT_INTERCEPT is defined as an int with a default value of '0'
2 - used Manage Modules/Properties/Variables to set DMO001_EVENT_INTERCEPT to '1'
3 - check for value of DMO001_EVENT_INTERCEPT in my events override script as follows:
case EVENT_TYPE_PERCEPTION_DISAPPEAR:
{
// If this isn't Dark Alliances, bail to default handler
//
object oModule = GetModule();
if (GetLocalInt(oModule, "DMO001_EVENT_INTERCEPT") == 0)
{
HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
}
4 - Placed my engineevents.gda, my var_module.gda, dmo001_event_intercept.nss & ncs in ../addin/core/override
And everything works...now I'll post this where someone trying to solve this will find it - clearly the wrong thread now that I found the root cause...
THANK YOU!
Following is the latest, and fully functional, event override script:
// Event Intercept Script to solve NPC behaviour problems
//
// File: dmo001_event_intercept.nss
// Module: Dark Alliances
// Sources: code from Magic (Bioware Social) & DA Builder Wiki
// Sources: David Sims forum assistance with module variables vs. constants ;-)
// Author: RecklezzRogue
// Date: 5-5-2010
// Revision 0.11
#include "utility_h"
#include "wrappers_h"
#include "events_h"
#include "sys_ambient_h"
#include "ai_main_h_2"
void main()
{
event ev = GetCurrentEvent();
int nEvent = GetEventType(ev);
object oOwner = GetEventObject(ev,0);
object oHero = GetHero();
int bEventHandled = FALSE;
// DisplayFloatyMessage(GetHero(), "Event Intercept Called", FLOATY_MESSAGE, 16777215,5.0); //Debug
switch (nEvent)
{
// If a hostile creature disappeared, update the threat table with the
// remaining perceived enemies.
//
// This code solves the problem of NPC's standing and taunting in combat
// mode, but not attacking visible combatant hostiles unless they are
// directly attacked
//
case EVENT_TYPE_PERCEPTION_DISAPPEAR:
{
// If this isn't Dark Alliances, bail to default handler
//
object oModule = GetModule();
if (GetLocalInt(oModule, "DMO001_EVENT_INTERCEPT") == 0)
{
// DisplayFloatyMessage(GetHero(), "Event Int Exit - Line 42", FLOATY_MESSAGE, 16777215,5.0); //Debug
HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
}
//Perception Fix Follows
//
if ((IsObjectHostile(OBJECT_SELF,GetEventObject(ev,0)))
&& OBJECT_SELF != GetMainControlled()
&& !IsPartyMember(OBJECT_SELF))
{
// DisplayFloatyMessage(GetHero(), "Event Int - Perception", FLOATY_MESSAGE, 16777215,5.0); //Debug
int i;
object[] oEnemies = GetNearestObjectByGroup(OBJECT_SELF,TRUE,OBJECT_TYPE_CREATURE,AI_THREAT_SIZE,TRUE,TRUE);
int nEnemyCount = GetArraySize(oEnemies);
if (GetThreatTableSize(OBJECT_SELF)<nEnemyCount)
{
for (i = 0; i<nEnemyCount; i++)
{
if (GetThreatValueByObjectID(OBJECT_SELF,oEnemies[i])==0.0)
{
AI_Threat_UpdateEnemyAppeared(OBJECT_SELF,oEnemies[i]);
}
}
int bEventHandled = FALSE;
}
else
HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
}
break;
}
// NPC's Re-engage after an AOE effect (fireball, freeze, etc)
//
// This solves the problem of NPC's disengaging from combat
// after recoveing from an AOE attack, especially Fireballs.
//
case EVENT_TYPE_COMMAND_COMPLETE:
{
// If this isn't Dark Alliances, bail to default handler
//
object oModule = GetModule();
if (GetLocalInt(oModule, "DMO001_EVENT_INTERCEPT") == 0)
{
HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
}
// Creature finished the ExecuteEffect command
//
if ((GetEventInteger(ev,0)==32) && (bEventHandled == FALSE)
&& !IsPartyMember(OBJECT_SELF)
&& OBJECT_SELF != GetMainControlled())
{
// DisplayFloatyMessage(GetHero(), "Event Int - EV = 32", FLOATY_MESSAGE, 16777215,5.0); //Debug
WR_ClearAllCommands(OBJECT_SELF,TRUE);
AI_DetermineCombatRound();
int bEventHandled = TRUE;
}
// The following code makes sure that NPC's go home after the battle
// Using this means that you will need to use commands that
// Rubber_SetHome (like UT_Quickmove) to keep NPC's at waypoints.
// This code also accomodates Ambient move patterns, but those with
// active move patterns still risk being stuck after battle...
//
else if (GetCommandType(GetCurrentCommand(OBJECT_SELF))==COMMAND_TYPE_INVALID
&& GetCommandQueueSize(OBJECT_SELF)==0
&& !IsPartyMember(OBJECT_SELF)
&& OBJECT_SELF != GetMainControlled())
{
DisplayFloatyMessage(GetHero(), "Event Int - EV = RGH", FLOATY_MESSAGE, 16777215,5.0); //Debug
// Issue Rubber_GoHome and Ambient_Start if not fighting, not at
// home wp, event not handled, and there is no ambient move
// pattern variable set (other than 0 or FALSE), and the Ambient
// system is enabled (the creature associated with the event)
//
// Adding conditional for PartyMembers...(must be false)
//
if (!GetCombatState(OBJECT_SELF)
&& GetDistanceBetweenLocations(GetLocation(OBJECT_SELF),Rubber_GetHome())>1.0
&& bEventHandled == FALSE
&& !GetLocalInt(OBJECT_SELF, AMBIENT_MOVE_PATTERN)
&& !IsPartyMember(OBJECT_SELF)
&& OBJECT_SELF != GetMainControlled())
{
Rubber_GoHome();
int bEventHandled = FALSE;
}
else
HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
if (GetLocalInt(OBJECT_SELF,AMBIENT_SYSTEM_STATE) & AMBIENT_SYSTEM_ENABLED
&& bEventHandled == FALSE
&& !GetCombatState(OBJECT_SELF)
&& !GetLocalInt(OBJECT_SELF, AMBIENT_MOVE_PATTERN)
&& !IsPartyMember(OBJECT_SELF)
&& OBJECT_SELF != GetMainControlled())
{
Ambient_Start();
int bEventHandled = TRUE;
}
else
HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
}
break;
}
}
if (!bEventHandled
&& nEvent == EVENT_TYPE_PERCEPTION_DISAPPEAR)
{
HandleEvent(ev,RESOURCE_SCRIPT_CREATURE_CORE);
}
else if (!bEventHandled
&& nEvent == EVENT_TYPE_COMMAND_COMPLETE)
{
HandleEvent(ev,RESOURCE_SCRIPT_RULES_CORE);
}
else
// DisplayFloatyMessage(GetHero(), "Event Int Exit - Line 161", FLOATY_MESSAGE, 16777215,5.0); //Debug
HandleEvent(ev); // pass to the event to the default handler for Event
}
// --- script end ---
Modifié par RecklezzRogue, 06 mai 2010 - 01:39 .