I had a vague recollection that in some cases the original xp value was restored, but it looks lile that uses vars 753 instead (in the jaroo spell permanency fix). Maybe it's just for debug. It would be best to search the files to be sure (including dlg files).
I guess I haven't checked outside Temple+ stuff, but the only stuff there that mentions global 752 are resurrection spell scripts and the (unrelated) moat house thing. I see how the Jaroo thing works; it stores your XP in the dialogue, then resets it after raising to result in no XP lost. I don't really understand why, though, because by the book Reincarnate has the same penalty as Raise Dead.
As far as I can tell, no other script refers to global 752. Just the spell scripts for raising and the one that would not be expecting the global to be set to the number of XP half way from one arbitrary level to the next.
When I tidied up some of the spell code in Paladin's Cove, I removed that global 752, just to prevent confusion whenever I saw it in there. It didn't seem to be used anywhere else, except for the gnoll skeleton respawning, which was module specific. Anyways, while I was there digging around the code, I was able to shorten up that large grouping of if/then statements, making a little formula out of it. Since the XP's needed to gain a level have a specific mathematical progression. The XP's needed to gain a new level are equal to the XP's needed to gain the current level + (1000 times the current level). Code: xp_current_level, xp_previous_level = 0, 0 for L in range (1, target_item.obj.stat_level_get(stat_level)+1): xp_previous_level = xp_current_level xp_current_level += (L-1)*1000 xp_new = xp_current_level - ((xp_current_level - xp_previous_level) / 2) target_item.obj.stat_base_set(stat_experience, xp_new) target_item.obj.object_script_execute( target_item.obj, 18 ) To be honest, the if/then statements are clearer to anyone casually reading the code. But I like solving little puzzles like this.
I think this is only needed for the spell permanency fix dialogue option which resets character state by killing and resurrecting. In this case storing current XP makes sense. Jaroo's Reincarnate actually works as expected, XP is lost as expected. At least with Temple+.
Oh, okay. That makes sense. I didn't really look at the context. I guess I'll have to keep that in mind if I ever implement the version of Reincarnation that turns you into a random humanoid race. Maybe I can figure out how to make it use the St. Cuthbert resurrection in that case in Temple+, since that will automatically have no XP penalty. Okay. Good to know you came to the same conclusion. And yeah, there are more compact ways to calculate the right XP value. I think what that code was working around was that the vanilla code has a pre-calculated array of the cumulative XP numbers (I guess doing like 20 adds for this was too expensive in 2003 ), and then it erroneously sets XP to Code: cumulative[i]/2 So, half the total XP needed to get back to the right level, not half way between the two levels.