PDA

View Full Version : Question about Modding Spell Effect Death


MattCaspermeyer
11-26-2010, 12:08 AM
Hi, I've actually been working on a mod for King's Bounty the Legend, but I'm pretty sure the mechanics work the same for Armored Princess and Crossworlds, so I'm posting here hoping somebody will know the answer to the problem I'm having with spell effects.

For certain effects, (i.e. burn, poison) there is a function in SPELL_EFFECTS.LUA (like effect_burn_attack) that sets the effect on the afflicted unit and then next time called the damage of the effect is applied.

The first time the effect is applied, typically it is called from a function in UNIT_FEATURES.LUA (for example), however, one of my questions is: what calls it for the subsequent application of the damage caused by the affliction (i.e. when the burn or poison effect is causing damage on the unit)? For other effects, like Sleem's Poison Spit, there seems to be no function where the affliction damage is being applied (like for burn and poison in SPELL_EFFECTS.LUA), but nonetheless it is applied. I'm wondering what applies the damage in this situation (i.e. is it in an LUA file somewhere or simply one of the Library functions (like Attack or AU)).

Lastly, what has driven me to ask these questions is that if an effect causes stack death and the next unit to move is another AI unit with an affliction, the affliction damage is skipped (but the affliction duration decreases by 1 and the unit moves normally). This only happens if the unit stack dies, if the unit stack is not killed then the affliction damage proceeds normally.

Here is an example:

Cannoneers are afflicted with "effect_burn" caused by Flaming Arrow and the unit that moves next, Giants, are also afflicted with the same effect. If the Cannoneers suffer enough damage to die, then the Giant's "effect_burn" will not be executed and the Giants will move normally as well as 1 round subtracted from the "effect_burn" duration. Where is the duration being changed and why did effect_burn_attack not get called?

Hopefully someone here knows why as it seems like (at least for The Legend and Armored Princess it seems that the affliction damage is attenuated so that stack death does not occur or is very infrequent - I can't say anything for Crossworlds because I don't have it yet). I'm thinking that it might be a limitation in the game code as the opposed to the LUA scripts, but hopefully not.

P.S. I use the LUA Debugger in Development Mode to walk through scripts and so I've tracked script execution the best I can, but I can't step into Library Functions like Attack, AU, etc. so what happens in those is somewhat of a mystery except what is described here: http://kingsbounty.ru/docs/scripting/index.htm and returns from effect_burn_attack, for example, go to a gen_tab in TEXTGEN.LUA (and stepping further from there goes nowhere since it keeps looping between it and gen_space for longer than my patience held out).