Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
Yandex, Sogou, AhrefsBot

Members: 0
Guests: 23
Stats
Files
Topics
Posts
Members
Newest Member
489
3,791
19,644
596
Elwood

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Codebases » SmaugFUSS » Bug in one_hit( )
Forum Rules | Mark all | Recent Posts

Bug in one_hit( )
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Oct 7, 2017 4:50 pm   
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts413
JoinedMar 7, 2005

 
Noticed some odd behavior during play testing, finally tracked it back to this bit.

So if you're in the one_hit( ) function and you attempt to damage someone, say 30 points of blunt damage, you eventually land here:

   if( ( retcode = damage( ch, victim, dam, dt ) ) != rNONE )
      return retcode;
      
   if( char_died( ch ) )
      return rCHAR_DIED;
      
   if( char_died( victim ) )
      return rVICT_DIED;

   retcode = rNONE;
   
   if( dam == 0 )
      return retcode;

   /*
    * Weapon spell support            -Thoric
    * Each successful hit casts a spell
    */
   if( wield && !IS_SET( victim->immune, RIS_MAGIC ) && !xIS_SET( victim->in_room->room_flags, ROOM_NO_MAGIC ) )
   {
    
   }



And so on. The problem is that damage( ) might not actually inflict any damage, seeing as how one might be immune to, in this case, blunt damage. However, one_hit( ) still has a positive 'dam' value, so you won't bail out with the dam == 0 check above, and hence you'll end up with weaponspells still firing on what I think most would consider an unsuccessful hit.

A simple fix might be to check the HP of the victim before and after the damage call. No change would be a sign of a unsuccessful hit, so you could do something like this:

    previous_hp = victim->hit;
    
    if ( (retcode = damage( ch, victim, dam, dt )) != rNONE )
    	return retcode;
    	
    if ( char_died(ch) )
    	return rCHAR_DIED;
    	
    if ( char_died(victim) )
    	return rVICT_DIED;

    retcode = rNONE;

    if ( dam == 0 )
	    return retcode;

   /*
    * Weapon spell support            -Thoric
    * Each successful hit casts a spell
    */
   if( wield && !IS_SET( victim->immune, RIS_MAGIC ) && !xIS_SET( victim->in_room->room_flags, ROOM_NO_MAGIC ) && victim->hit < previous_hp )
   {
    
   }


This works for me, and preserves the functionality of the retaliatory shields, which makes intuitive sense (e.g. still close enough to get burned by a fire shield, even if your hit didn't do any damage). Obviously don't forget to declare the variable somewhere, up top in one_hit( ) or whatever suits you.

Perhaps this is one of those items open to some measure of debate, but given the way the code was written, I don't see why immunity to PLUSx, NONMAGIC and MAGIC (checked in one_hit( ) ) should be any different from immunity to everything else, i.e. BLUNT (checked in damage( ) ), in that all should be considered unsuccessful hits if damage = 0.

Thoughts?

Pages:<< prev 1 next >>