Traumaturgy bug? (4.4.8b) (in mon_take_hit())

Bug reports and discussion about bugs.
Post Reply
Argle
Posts: 30
Joined: Sat Jan 28, 2012 7:29 am

Traumaturgy bug? (4.4.8b) (in mon_take_hit())

Post by Argle »

Using 4.4.8b source
[edit] This is all in the mon_take_hit fn in xtra2.c

Issue 1: Referenced Traumaturgy skill value results in 0 or 1 gain, 100% of the time.

src\server\xtra2.c:7348:
s16b skill_trauma = get_skill(p_ptr, SKILL_TRAUMATURGY);

Should be raw value, like so:
u16b skill_trauma = get_skill(p_ptr, SKILL_TRAUMATURGY) * SKILL_STEP; //[edit] see second post

Because later we're comparing it to MAX_SKILL, which is 50000, here:

src\server\xtra2.c:7373:
scale_trauma = (((skill_trauma) * 20) / SKILL_MAX);

and 50*20/50000 = 0, in integer terms. And since later we're taking the lower of scale_trauma, damage/20, and monster HP, it will always be 0.

Issue 2: scale_trauma is never set if you don't have tim_trauma!

So even if we fix the above, it still won't matter to the average user who doesn't have a temp traumaturgy buff.

C:\Users\Foster\Desktop\src\server\xtra2.c:7370:

Code: Select all

/* Trauma boost spell */
if (p_ptr->tim_trauma) {
	skill_trauma += (skill_trauma < (SKILL_MAX - (p_ptr->tim_trauma_pow * 1000)) ? (p_ptr->tim_trauma_pow * 1000) : SKILL_MAX - skill_trauma);
	scale_trauma = (((skill_trauma) * 20) / SKILL_MAX);
}

/*snip*/

long gain = scale_trauma;
Thus if tim_trauma is 0, scale_trauma is 0, and gain is 0. If we just move that second line outside of the conditional

Code: Select all

/* Trauma boost spell */
if (p_ptr->tim_trauma) {
	skill_trauma += (skill_trauma < (SKILL_MAX - (p_ptr->tim_trauma_pow * 1000)) ? (p_ptr->tim_trauma_pow * 1000) : SKILL_MAX - skill_trauma);
}
scale_trauma = (((skill_trauma) * 20) / SKILL_MAX);
/*snip*/

long gain = scale_trauma;
It will be set according to the formula.

Both of these issues result in Traumaturgy gains being 0 or 1, every time, regardless of skill, damage, or monster HP. I don't know what the functional gains are intended to be, but tests after applying both of these fixes results in hits over 200 returning 10 mana with 25 trauma skill. I don't know if that's the intended gain (capped at 40% of skill), but I'm positive that 0 or 1 was not ;)
Last edited by Argle on Thu Feb 09, 2012 8:42 am, edited 1 time in total.
Argle
Posts: 30
Joined: Sat Jan 28, 2012 7:29 am

Re: Traumaturgy bug? (4.4.8b) (in mon_take_hit())

Post by Argle »

One more fix:

change:
s16b skill_trauma = get_skill(p_ptr, SKILL_TRAUMATURGY) * SKILL_STEP;
to
u16b skill_trauma = get_skill(p_ptr, SKILL_TRAUMATURGY) * SKILL_STEP;

Otherwise it wraps if your modified skill gets over 32k, and each monster you injure starts draining mana from you. Testing Trauma skill 30, casting nether/cold/self for temp trauma, bumped it to 33, and resulted in -13 gain per hit.
mikaelh
Developer
Posts: 217
Joined: Sun Dec 13, 2009 3:18 pm

Re: Traumaturgy bug? (4.4.8b) (in mon_take_hit())

Post by mikaelh »

Your fixes have been applied. Thanks for investigating the issue in such detail.
Argle
Posts: 30
Joined: Sat Jan 28, 2012 7:29 am

Re: Traumaturgy bug? (4.4.8b) (in mon_take_hit())

Post by Argle »

No problem, I enjoy this sort of thing.

Thanks, for applying so quickly (for the 3 rune bug too)!
Post Reply