Aller au contenu

Photo

Events - How To properly Override them


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

#1
AND04

AND04
  • Members
  • 154 messages
Refer to this Wiki Article for How to do this:

Overriding Events

Please note though that the articel atm just captures the override of an event that doesn't have any actions attached to it.
And be careful to send any event that you aren't covering completly to the Default Eventhandler attached to it by calling HandleEvent() with the current event and without a ressource!

#2
DonTalone

DonTalone
  • Members
  • 4 messages
Nice tutorial for understanding the basics in extending the games' scripts.
I'm not much into wiki editing, so maybe you could extend a link to this section so everyone knows how to extend the M2DA's also.

Modifié par DonTalone, 20 novembre 2009 - 08:58 .


#3
AND04

AND04
  • Members
  • 154 messages

DonTalone wrote...

Nice tutorial for understanding the basics in extending the games' scripts.
I'm not much into wiki editing, so maybe you could extend a link to this section so everyone knows how to extend the M2DA's also.


Done.

#4
eiham

eiham
  • Members
  • 38 messages
It appears only one module can override a given event though, unless I am mistaken. as in, if I were to also override EVENT_TYPE_INVENTORY_ADDED, my script would fire, but yours never would (even if I call HandleEvent(ev)).



We might need to create some community module that will allow us to register event handlers on the code side or something. Unless I'm totally wrong here.

#5
Craig Graff

Craig Graff
  • Members
  • 608 messages
You're only right if you are talking about overriding the script called by particular events as determined by event.xls which are routed to rules_core by default.

Edit: After actually following the link, I see that is exactly what you are talking about. And yes, you are right.

Modifié par Craig Graff, 22 novembre 2009 - 08:04 .


#6
Cador

Cador
  • Members
  • 52 messages
hmm, i don´t understand the purpose of overriding an event.



the example in the wiki is just a script that uses EVENT_TYPE_INVENTORY_ADDED.

i can use this event type without changing a 2da.



was it just a simple example?



is the purpose to create new events?


#7
Craig Graff

Craig Graff
  • Members
  • 608 messages
The purpose is to access a particular event without editing a core script. There are definite gotchas to be had with this, and keep in mind that for the ones already routing through to rules_core, you could easily experience performance issues on some systems (which is why they were routed to rules_core directly in the first place).

#8
Cador

Cador
  • Members
  • 52 messages
ok thats to high for me.
i thought, if you want to script something, you create a new script which looks like this

#include "......_h"
void main()
{
event ev = GetCurrentEvent();
int nEvent = GetEventType(ev);

switch (nEvent)
{

case the event you want

your code

}

and at the end you call the core script if the event wasn´t handled above.

so i don´t change the core_script.
i just check my event and script what i want

i don´t see the difference to the script in the wiki-link


edit: or does this just tell the game to fire a specific script when the event is called?

Modifié par Cador, 22 novembre 2009 - 08:31 .


#9
Gralamin

Gralamin
  • Members
  • 45 messages

Cador wrote...

ok thats to high for me.
i thought, if you want to script something, you create a new script which looks like this

#include "......_h"
void main()
{
event ev = GetCurrentEvent();
int nEvent = GetEventType(ev);

switch (nEvent)
{

case the event you want

your code

}

and at the end you call the core script if the event wasn´t handled above.

so i don´t change the core_script.
i just check my event and script what i want

i don´t see the difference to the script in the wiki-link


edit: or does this just tell the game to fire a specific script when the event is called?

In that case, you would have to have that be the core script of an addin module. Overriding the event allows you to use ANY script on a certain event.

#10
AND04

AND04
  • Members
  • 154 messages

Gralamin wrote...
In that case, you would have to have that be the core script of an addin module. Overriding the event allows you to use ANY script on a certain event.


+ some events just don't fire into your script.

#11
Gralamin

Gralamin
  • Members
  • 45 messages

AND04 wrote...

Gralamin wrote...
In that case, you would have to have that be the core script of an addin module. Overriding the event allows you to use ANY script on a certain event.


+ some events just don't fire into your script.

I'm guessing this include INVENTORY_ADDED? I know I've tried everything to get it to fire on my Display Item Set Bonuses mod.

Modifié par Gralamin, 22 novembre 2009 - 10:06 .


#12
Craig Graff

Craig Graff
  • Members
  • 608 messages
INVENTORY_ADDED is not a module event. It is an event which fires for each container, be it a placeable or a creature. In the case of the player, the assigned script is player_core.

There is a CAMPAIGN_ITEM_ACQUIRED event, but it is designed to only fire for items that have the appropriate local variable set.

INVENTORY_ADDED can be directed to a specific script, but you would need to be careful how you handled it, since it would potentially be firing for every object in the game.

Modifié par Craig Graff, 22 novembre 2009 - 10:27 .


#13
AND04

AND04
  • Members
  • 154 messages

Craig Graff wrote...

INVENTORY_ADDED is not a module event. It is an event which fires for each container, be it a placeable or a creature. In the case of the player, the assigned script is player_core.

There is a CAMPAIGN_ITEM_ACQUIRED event, but it is designed to only fire for items that have the appropriate local variable set.

INVENTORY_ADDED can be directed to a specific script, but you would need to be careful how you handled it, since it would potentially be firing for every object in the game.


on another note is it possible to determine wich script is the default event-handler for an object?

In my Case i am overrideing the Event EVENT_TYPE_USE if it has the PlaceableAction PLACEABLE_ACTION_OPEN_INVENTORY - now if its just a Standard-Container/BodyBag i am Auto Looting it - if it has a Plot-Falg (IsPlot) i use HandleEvent(ev); to run the Default-Handler

Now the propblem is, that not all containers with a unique-event script have that plot-flag set.
The Warden Cache triggering the Appearance of Morrigan has it for example - The "Song-Chest" in the Dalish Camp however hasn't.

Now i somehow need to not loot it when a special event script is attached and no plot flag is set to the container - special meaning a none Core-Script.

Modifié par AND04, 22 novembre 2009 - 03:21 .


#14
Craig Graff

Craig Graff
  • Members
  • 608 messages
Sadly, I know of no way to determine that. A GetEventScript function would certainly be handy though.



I think I'll put in a request for one.

#15
AND04

AND04
  • Members
  • 154 messages

Craig Graff wrote...

Sadly, I know of no way to determine that. A GetEventScript function would certainly be handy though.

I think I'll put in a request for one.


that would be great :)

#16
georage

georage
  • Members
  • 247 messages
 I am trying to follow the directions (http://social.biowar..._game_via_M2DAs) for making my own 2da, but the paths suggested on the wiki confuse me.

I found the folder with ExcelProcessor.exe, but I am unsure what the path in bold should be.

D:\\Dragon Age\\tools\\main\\ResourceBuild\\Processors\\ExcelProcessor.exe "%l" -outdir=D:\\DA\\tag\\main\\build\\packages\\core\\override

#17
Craig Graff

Craig Graff
  • Members
  • 608 messages
\\My Documents\\BioWare\\Dragon Age\\modules\\Single Player\\override will work (though you need to have the path to your documents folder).

#18
georage

georage
  • Members
  • 247 messages
Thanks!

#19
Joshua Raven

Joshua Raven
  • Members
  • 182 messages
I am trying to override the EVENT_TYPE_COMBAT_END event.

- I set the engineevent_mymod m2da EVENT_TYPE_COMBAT_END override to my_events
- Created a new script my_events
- I also tried setting the script as the core module script

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_MODULE_LOAD:
        {

            PrintToLog("******************************************");            
            PrintToLog("******************************************");            
            PrintToLog("******************************************");            
            PrintToLog("***** MODULE LOAD EVENT TRIGGERED ********");            
            PrintToLog("******************************************");            
            PrintToLog("******************************************");            
            PrintToLog("******************************************");            
            
            break;
        }


        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, 07 décembre 2009 - 12:47 .


#20
anakin5

anakin5
  • Members
  • 258 messages
The script that manage the event EVENT_TYPE_MODULE_LOAD is your core module script if you want one (you don't have to have one if you don't need it)

The script that manage EVENT_TYPE_COMBAT_END is an other script, that you referred in the engineevent M2DA file.



The event EVENT_TYPE_COMBAT_END is fired in creature script. So it will fired each time a creature get out of combat.

But be aware that I figured that HandleEvent doesn't call custom creature scripts. Once you have succed to make it work, test it on Spider Queen in Thaig to be sure you are not doing something wrong.

#21
Craig Graff

Craig Graff
  • Members
  • 608 messages
EVENT_TYPE_GAMEMODE_CHANGE is likely to let you do what you want if you don't want to mess with core scripts. Intercepting it can be dangerous/tricky if you are doing this in a stand-alone or base module, so tread carefully.

#22
georage

georage
  • Members
  • 247 messages
Event overrides do not seem to fire reliably ... EVENT_TYPE_ENTER does NOT seem to work at all when entering an area, for example.

And when entering triggers, they fire more than once.

Has anyone gotten EVENT_TYPE_ENTER to work FOR AN AREA with an override?

Modifié par georage, 08 décembre 2009 - 12:26 .


#23
Craig Graff

Craig Graff
  • Members
  • 608 messages
EVENT_TYPE_ENTER should never really be used with areas. Much better to use
EVENT_TYPE_AREALOAD_POSTLOADEXIT
EVENT_TYPE_AREALOAD_PRELOADEXIT
EVENT_TYPE_AREALOAD_SPECIAL

or if you are trying to do something when a savegame is loaded in an area

EVENT_TYPE_AREALOADSAVE_POSTLOADEXIT
EVENT_TYPE_AREALOADSAVE_PRELOADEXIT
EVENT_TYPE_AREALOADSAVE_SPECIAL

Modifié par Craig Graff, 08 décembre 2009 - 12:55 .


#24
Sunjammer

Sunjammer
  • Members
  • 925 messages
Are the above in the order they fire, i.e. Post > Pre > Special?

#25
stuntpope

stuntpope
  • Members
  • 112 messages
Check out the comments in the area_core script which handles these events.



PRELOADEXIT happens while the load screen is up.

POSTLOADEXIT happens as the load screen is going away.

SPECIAL is for running a cutscene or movie once the area has loaded.



I would suppose the order is pre > special > post. Though I'm not certain about those last two.