Aller au contenu

Photo

SOLVED: override events (engineevents.gda) without impacting other modules


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

#1
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
Which overrride folder will load this only for my standalone module? Seems it only works in core override, in which case it loads even when I am not actually 'playing' my stand-alone mod...

I figured I would ask before attempting to script around this (check for module or area name, else pass event to default handler)....I only want to override certain events when playing my specific module...the overrides break combat in single player.

Modifié par RecklezzRogue, 08 mai 2010 - 09:28 .


#2
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
see below....

Modifié par RecklezzRogue, 06 mai 2010 - 03:40 .


#3
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
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 .


#4
Proleric

Proleric
  • Members
  • 2 362 messages
Bearing in mind your original question, why are you using core>override rather than module>override?

#5
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
If your mod is standalone why would <your module)/core/override load when not playing your module? From what I read on the wiki it should only load that when you're playing the module if its a standalone one, no?

#6
Proleric

Proleric
  • Members
  • 2 362 messages
Where did you read that? The compatibility article in the wiki says that resources in the core folder of an active add-in can affect all campaigns, which is my understanding of forum discussions to date.

If that's incorrect, let's fix it.

Modifié par Proleric1, 06 mai 2010 - 03:24 .


#7
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
Pro - while all the 'normal stuff' works in the module/override folder, engineevents.gda does not - I originally posted this trying to figure how to intercept events without impacting anything else...trial and error got me to using the core/override folder. The conditional mechanism I put in works (so as not to interfere with other modules), but if this is just me putting engineevents in the wrong place, I'd love to know it...doubt it though - I dorked around with this for days. ;-)

Kil - specifically to your point - addin/mymodule/core/override definately affects everything based on my testing.

Modifié par RecklezzRogue, 06 mai 2010 - 03:33 .