Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Majestic-12, Yandex, DotBot, Yahoo!

Members: 0
Guests: 12
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » 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, 2:50 pm
Go to the top of the page
Go to the bottom of the page

GatewaySysop
Conjurer
GroupMembers
Posts367
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 ) )
   {
    <snip>
   }



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 )
   {
    <snip>
   }


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 >>