Aller au contenu

Photo

Overriding events that fire on creatures, still confused


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

#1
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
So, I found a BioWare post somewhere stating that EVENT_TYPE_COMBAT_END is a script that fires on each creature in the game, not on an area (obviously). Now my question is, if this is the case, how would I go about adding a custom script that fires on top of the original actions that take place when this event fires?

I figured it would be possible to add HandleEvent(R"yourscript.ncs"); at the end of the original event script, but that would mean I'd have to use custom *_core files which would make the mod incompatible with a lot of other mods.

Could anyone help me out here? I've been overriding area events with the engineevents_ m2da, but it just doesn't seem to work for creature triggered events.

Thanks in advance, been going at this for days now!:o

#2
Inarai

Inarai
  • Members
  • 1 078 messages
Sorry, I haven't poked around in the toolset much, but, something occurs to me: This would indicate that there is already some sort of event that gets passed or announced that declares an end of combat. If this is true, and you find how this script finds that the event has occurred... You should be able to simply add an additional script to trigger on the same event. Much easier for after patches and the like.

#3
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Well, creature_core calls the COMBAT_END that I'm sure of:

void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);

    switch (nEventType)
    {

        case EVENT_TYPE_COMBAT_END:
        {
                ...
        }
    }
}

However, I tried doing the same but the event never fires (nothing is written to the log and no floaty appears):


- I set the engineevent_mymod m2da EVENT_TYPE_COMBAT_END override to my_events
- Created a new script my_events

When using the engineevent_ m2da override, nothing happens at all, no log write after combat.

I have no clue what I'm doing wrong here, it seems like everything is correct yet the script never fires. Anyone any ideas, I'm at a loss here.

- The following is contained inside the event, the module load event fires correctly, the combat_end doesn't:

#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"

void main()
{
   event ev = GetCurrentEvent();
   int nEventType = GetEventType(ev);
   object oOwner = GetEventCreator(ev);
   object oItem = GetEventObject(ev, 0);

   switch ( nEventType )
   {
       case EVENT_TYPE_COMBAT_END:
       {
           
           PrintToLog("******************************************");            
           PrintToLog("******************************************");            
           PrintToLog("******************************************");            
           PrintToLog("***** EVENT COMBAT_END FIRED *************");            
           PrintToLog("******************************************");            
           PrintToLog("******************************************");            
           PrintToLog("******************************************");            

          
          DisplayFloatyMessage(OBJECT_SELF, "EVENT FIRED");

          HandleEvent(ev);           
          break;
       }
    
       default:
           break;         
   }      
}

Modifié par Joshua Raven, 09 décembre 2009 - 10:00 .


#4
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
double post

Modifié par Joshua Raven, 09 décembre 2009 - 09:59 .


#5
Inarai

Inarai
  • Members
  • 1 078 messages
Hm... Again, I'm not familiar with this toolset specifically, so this advice is coming from a different perspective, BUT:



Is it possible that the creature script is importing some method set, or has a parent set of code that yours does not?

#6
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Not that I'm aware of. My script compiled correctly so it has all the required includes. And to my knowledge (and the way it is documented here) all that is required is for a custom eventoverride_ m2da to point the game to a custom script when a certain event is triggered, yet it doesn't execute my custom script (or at least doesn't get to the point where a logwrite is executed).

#7
Inarai

Inarai
  • Members
  • 1 078 messages
Are those spaces actually in your switch statement? Whitespace like that usually isn't relevant, but I wonder if it's somehow altering the way the scripter parses the varialble.

#8
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Good catch but no, it isn't the cause of the problem because another event in that script actually DOES work (MODULE_LOAD). So the script works and the event switch works, it just never triggers the COMBAT_END event.

#9
AND04

AND04
  • Members
  • 154 messages

Joshua Raven wrote...

Good catch but no, it isn't the cause of the problem because another event in that script actually DOES work (MODULE_LOAD). So the script works and the event switch works, it just never triggers the COMBAT_END event.


hmm, you could try to use EnableEvent - as this type might be diasabled for some reason - or just try to not use the module-script but a new one.

havn't had that problem yet but i didn't try overriding that speciifc event yet.

#10
anakin5

anakin5
  • Members
  • 258 messages
As I said in an other post, I you make a module that patch the orignal game, you can't override an event that fire in creature script because you will not be able to call HandleEvent at the end of your script.

If you call HandleEvent at the end of your script, creature_core will immediatly handle the event, and creature_core IS NOT always the fist script of the chain (custom creature script is the fist). So you beak all creatures of the game that were handling this event in their custom script.


#11
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
Thanks for that anakin5. So is there _any_ way to alter these changes in the original game then? Should I go about and edit the core files themselves (in this case I only want the script to fire on party members) which will mean less compatibility (which I'll accept in this case)? Or is there another way you'd implement these changes to the original game?

#12
anakin5

anakin5
  • Members
  • 258 messages
First, we don't have any feedback of Bioware's team to know why HandleEvent doesn't call custom creature script while it does for placeable, or even if what I said is true or not. It is the results of my tests but it can be the result of something i am not aware.

I am trying to figure out what are the event thats are used in at least one custom creature script in the game to provide a list of event that cannot be override (without breaking at least 1 creature in the campaign), but it takes a long time.
EVENT_TYPE_COMBAT_END is really sensible, I didn't test it but there is 90% chance that it is used in some custom creature scripts.
After the release of campaign script in the toolset, we will be able to know this list of events, but not before.

The best solution is to wait for the toolset release. The temporary solution is to override core files when you want to make change in a event that is fired in creature script.

To use your script only with followers, I suggest writing the following things at the start of the event management in the core scripts (creature_core, player_core or rules_core) :

...
case EVENT_TYPE_COMBAT_END:
{
        if(IsFollower(OBJECT_SELF))
        {
                my_custom_function();
                return;
        }
        ....
}
....

Modifié par anakin5, 10 décembre 2009 - 02:17 .


#13
Craig Graff

Craig Graff
  • Members
  • 608 messages
It really depends on what you want to do. The best way to handle creature events for certain creatures is typically to have a custom script assigned to the creatures you want to handle, then pass the event on to creature_core with HandleEvent.



If you are just looking to check when combat is over for the player, look at EVENT_TYPE_GAMEMODE_CHANGE on the module script.



EVENT_TYPE_COMBAT_END is not an engine function and probably can't be overriden in events.xls. It is sent from within combat_h.

#14
Magic

Magic
  • Members
  • 187 messages
Hey. I just saw your thread and want to add that hiring followers have a call

SetEventScript(oCreature, RESOURCE_SCRIPT_PLAYER_CORE);

in WR_SetFollowerState() of wrappers_h.nss,

called by UT_HireFollower() of utility_h.nss.



If your creature is a follower, it's probably not using your custom script anymore. In this case you'll need to remedy it after the hiring.

#15
Guest_Leopard73_*

Guest_Leopard73_*
  • Guests
you could try adding your custom script to the creature/s object inspector scripts under AI then pass back to the original creature core



#include "utility_h"

#include "wrappers_h"

#include "events_h"



void main()

{

event ev = GetCurrentEvent();

int nEventType = GetEventType(ev);

int nEventHandled = FALSE;



switch ( nEventType )

{

case EVENT_TYPE_COMBAT_END:

{



PrintToLog("******************************************");

PrintToLog("******************************************");

PrintToLog("******************************************");

PrintToLog("***** EVENT COMBAT_END FIRED *************");

PrintToLog("******************************************");

PrintToLog("******************************************");

PrintToLog("******************************************");





DisplayFloatyMessage(OBJECT_SELF, "EVENT FIRED", FLOATY_MESSAGE, 65535);



nEventHandled = FALSE;

break;

}

}

if (!nEventHandled) //If this event wasn't handled by this script, let the core script try

{

HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);

}

}