Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CF: bug/feature with saving throw?



There is something strange with the "saving throw" code in attack.c.
If a weapon has several attack types and one of them allows saving
throws, then the whole attack can fail because of that, even if the
other attack types could have done some damage.  I think this is a
bug rather than a feature.

I discovered this when I prayed on an altar and I was lucky enough
to get a God intervention which added the attack types "weaponmagic"
and "fear" to my current weapon (a Frostbrand).  The result was
disastrous: instead of improving the weapon, it ruined it because
AT_FEAR allows a saving throw which can cancel the whole attack.

Here is a proposed patch to server/attack.c.  Instead of returning
immediately when the saving throw succeeds, it clears the affected
attack types and returns only if there is no attack left.  I don't
think there are any side effects, but I might have overlooked
something.  Comments are welcome...

---------- cut here ----------
*** attack.c.orig	Sun Apr 21 07:07:37 1996
--- attack.c	Wed Jul  3 14:11:53 1996
***************
*** 511,517 ****
         /*  the following includes a secret saving throw for magic:
	   you get TWO saving throws for magical attacks! */
         (RANDOM()%20+((op->protected&type)?5:1) >= savethrow[op->level]))
!       return 0;
  
    CLEAR_FLAG(op,FLAG_SCARED); /* Or the monster won't hit back */
    if(get_owner(hitter))
--- 511,523 ----
         /*  the following includes a secret saving throw for magic:
	   you get TWO saving throws for magical attacks! */
         (RANDOM()%20+((op->protected&type)?5:1) >= savethrow[op->level]))
!       {
!	/* do not bail out immediately if other attack types can succeed */
!	type &= ~(AT_PARALYZE|AT_FEAR|AT_POISON|AT_CONFUSION|AT_SLOW|
!		  AT_CANCELLATION|AT_DEPLETE);
!	if (!type)
!	  return 0;
!       }
  
    CLEAR_FLAG(op,FLAG_SCARED); /* Or the monster won't hit back */
    if(get_owner(hitter))
---------- cut here ----------

-Raphael