It seems it is impossible to override (or overwrite as I wrote in my previous post even if it is not correct) scripts with "_h" because they are resources. The only way is to do as TimelordDC said, create a new RewardXP function and override all scripts using the original one ... that is a lot of work. Moreover, if I create another mods with the same principle I will have problems of compatibility (plus the problems of compatibility with third party mods).
So I found an easier solution. I used local variables to store the party members level.
Here is what I did:
- Created a var_mymod.gda to declare my variables (
link to wiki)
- Place the .gda into the override folder of my mod
- Open my toolset and update the Properties of my mod by selecting var_mymod in "Variable 2da" field
- Add some lines in my mod script to "track" the level up (the code below it's not very clean and not optimized, it is what I used for my tests). If the current level is different from what we have stored, there was a level up. The update will be near instantaneous that a corresponding event existed.
#include "utility_h"
void BonusUpdate(object oPartyMember)
{
[...]
}
void main()
{
object oHero = GetHero();
object oModule = GetModule(); // the local variables are attached to the module
if (GetLevel(oHero) != GetLocalInt(oModule, "HERO_LEVEL"))
{
if ( HasAbility(oHero, MYABILITY) ) BonusUpdate(oHero);
SetLocalInt(oModule, "HERO_LEVEL", GetLevel(oHero)); // storage of the hero level
}
}
Here is what I put in var_mymod.gda file:
ID Label Type Default IsPlot
int string string string int
0 HERO_LEVEL int 0 0
Modifié par Herw81, 12 avril 2010 - 04:56 .