Aller au contenu

Photo

[Question] Death Event Handling


1 réponse à ce sujet

#1
Challseus

Challseus
  • Members
  • 1 032 messages
I am attemping to run some custom functionality when PC's/party members die. Among other things, I need to see if the dying creature has an effect on them. I am properly overriding player_core.nss with my own custom script with no issues. The problem arises when I catch the event, EVENT_TYPE_DEATH.

As soon as I catch the event, I check the creature for the effect, using the function, GetEffectsByAbilityId(). This returns an empty array of effects. In hindsight, this probably makes sense, as effects should be removed from creatures upon death... Fair enough.

The next thing I tried was to run this functionality in my event handling for EVENT_TYPE_DAMAGED. My thinking was, I could just use GetCurrentHealth() and if it was <= 0 (not sure why someone would have negative health, but can't be too safe!) after taking damage, I could remove the effects there. I put lots of DEBUG in this event handler, and as a creature kept losing health from each time they were damaged, the correct number of HP's was printed properly. However, whenever the killing blow was landed, the event never fired. Okay, fine, system designers, I have more cards up my sleeve!

I then started to take a look at EVENT_TYPE_ATTACK_IMPACT, which I use for other things in my module. I currently catch this event in my overrided version of creature_core.nss. My thought process was to catch the event when the enemy's attack impacted the PC/party member, check the damage (and of course if said attack was successful), and check the target's health. If the health minus the damage is <= 0, then remove the effects before Effects_ApplyInstantEffectDamage is eventually called, which in turn calls EffectDeath at some point.

Obviously this does not work. Here is a code snippet of how I get the damage:

object oAttacker = GetEventObject(ev, 0);
int nEffectId = GetEventInteger(ev,1);   
    
effect eImpactEffect = GetAttackImpactDamageEffect(oAttacker, nEffectId);

float fDamage = GetEffectFloat(eImpactEffect,0);

Now, bear in mind I am calling this in my own custom script, before passing things off to creature_core.nss which in turn passes things off to rules_core.nss. Anyway, when I run this, no damage is ever applied to the target. Once I remove it, things go back to normal. After trying various things, I narrowed it down the calling the function, GetAttackImpactDamageEffect. It's almost as if this can only be called one time per attack. And for the record, I am getting the damage correctly.

At any rate, I am well aware of other ways to make this work, such as modifying core scripts and whatnot, but before going that route (if at all), does anyone else have any ideas on how to check effects on creatures as they die?

#2
BryanDerksen

BryanDerksen
  • BioWare Employees
  • 273 messages
Have you tried overriding the event via the events 2DA? I've never used it myself, but based on the information at http://social.biowar.../Event_override it looks like it may be able to intercept the death event for you before any of the core scripts get a chance to deal with it.

Edit: Oops, just saw the thread you started about events.xls right after posting. So yeah, I guess you thought of that approach too. :)

Modifié par BryanDerksen, 04 décembre 2009 - 06:58 .