battle/skill damage in Smaugfuss 1.7

Posted by Kilos on Fri 19 May 2006 03:14 PM — 9 posts, 29,582 views.

#0

I've been trying to get battle damage (You hit X for 10 damage) and also skill damage (Your lightning bolt hits X for 10 damage) to work in Smaugfuss 1.7

Here's my code:

---------------------

if ( dt >=0 && dt < top_sn )
skill = skill_table[dt];

dt = TYPE_HIT;
attack = attack_table[0];

if (dt == TYPE_HIT && dam == 0)
{
sprintf(buf1, "$n's %s %s $N badly%c", attack, vp, punct );
sprintf(buf2, "Your %s %s $N badly%c", attack, vp, punct );
sprintf(buf3, "$n's %s %s you badly%c", attack, vp, punct );
}
else
if ( dt == TYPE_HIT ) //damage number & text
{
sprintf( buf1, "$n %s $N%c", vp, punct );
sprintf( buf2, "You %s $N for %i damage%c", vs, dam, punct );
sprintf( buf3, "$n %s you for %i damage%c", vp, dam, punct );
}
else if( dt > TYPE_HIT && is_wielding_poisoned( ch ) )
{
if( dt < TYPE_HIT + sizeof( attack_table ) / sizeof( attack_table[0] ) )
attack = attack_table[dt - TYPE_HIT];
else
{
bug( "Dam_message: bad dt %d from %s in %d.", dt, ch->name, ch->in_room->vnum );
dt = TYPE_HIT;
attack = attack_table[0];
}

snprintf( buf1, 256, "$n's poisoned %s %s $N%c", attack, vp, punct );
snprintf( buf2, 256, "Your poisoned %s %s $N%c", attack, vp, punct );
snprintf( buf3, 256, "$n's poisoned %s %s you%c", attack, vp, punct );
}
else
{
if( skill )
{
attack = skill->noun_damage;
if( dam == 0 )
{
bool found = FALSE;

if( skill->miss_char && skill->miss_char[0] != '\0' )
{
act( AT_HIT, skill->miss_char, ch, NULL, victim, TO_CHAR );
found = TRUE;
}
if( skill->miss_vict && skill->miss_vict[0] != '\0' )
{
act( AT_HITME, skill->miss_vict, ch, NULL, victim, TO_VICT );
found = TRUE;
}
if( skill->miss_room && skill->miss_room[0] != '\0' )
{
if( str_cmp( skill->miss_room, "supress" ) )
act( AT_ACTION, skill->miss_room, ch, NULL, victim, TO_NOTVICT );
found = TRUE;
}
if( found ) /* miss message already sent */
{
if( was_in_room )
{
char_from_room( ch );
char_to_room( ch, was_in_room );
}
return;
}
}
else
{
if( skill->hit_char && skill->hit_char[0] != '\0' )
act( AT_HIT, skill->hit_char, ch, NULL, victim, TO_CHAR );
if( skill->hit_vict && skill->hit_vict[0] != '\0' )
act( AT_HITME, skill->hit_vict, ch, NULL, victim, TO_VICT );
if( skill->hit_room && skill->hit_room[0] != '\0' )
act( AT_ACTION, skill->hit_room, ch, NULL, victim, TO_NOTVICT );
}
}
else if( dt >= TYPE_HIT && dt < TYPE_HIT + sizeof( attack_table ) / sizeof( attack_table[0] ) )
{
if( obj )
attack = obj->short_descr;
else
attack = attack_table[dt - TYPE_HIT];
}
else
{
bug( "Dam_message: bad dt %d from %s in %d.", dt, ch->name, ch->in_room->vnum );
dt = TYPE_HIT;
attack = attack_table[0];
}

sprintf( buf1, "$n's %s %s $N%c", attack, vp, punct );
sprintf( buf2, "Your %s %s $N for %i damage%c", attack, vp, dam, punct );
sprintf( buf3, "$n %s you for %i damage%c", vp, dam, punct );
}


-------------------

Note: I intentionally didn't want observers in the room seeing the damage amount. What I get from this code is:

You hit X for # damage.
X hits you for # damage.

But, when using spells I get the exact same thing.


So my question is, How can get it to show this:

Your lightning bolt smites X for # damage.
X's lightning bolt smites you for # damage.

I appreciate any help you can offer me!
USA #1
Remember you can use the code tag.

Spells are handled quite differently compared to skills. I'm not sure offhand, but do spells even call that function you're editing?
#2
Ah sorry about that, didn't notice that checkbox.

Hmm, not sure but I believe so. I could be wrong. Also I should mention that using a skill such as punch gives me the same problem.
USA #3
What exactly is the problem again?

Skills are handled in the function you're in, look for something like "$n's %s %s"
#4
I think this is the section dealing with it:



if( skill )
{
attack = skill->noun_damage;
if( dam == 0 )
{
bool found = FALSE;

if( skill->miss_char && skill->miss_char[0] != '\0' )
{
act( AT_HIT, skill->miss_char, ch, NULL, victim, TO_CHAR );
found = TRUE;
}
if( skill->miss_vict && skill->miss_vict[0] != '\0' )
{
act( AT_HITME, skill->miss_vict, ch, NULL, victim, TO_VICT );
found = TRUE;
}
if( skill->miss_room && skill->miss_room[0] != '\0' )
{
if( str_cmp( skill->miss_room, "supress" ) )
act( AT_ACTION, skill->miss_room, ch, NULL, victim, TO_NOTVICT );
found = TRUE;
}
if( found ) /* miss message already sent */
{
if( was_in_room )
{
char_from_room( ch );
char_to_room( ch, was_in_room );
}
return;
}
}
else
{
if( skill->hit_char && skill->hit_char[0] != '\0' )
act( AT_HIT, skill->hit_char, ch, NULL, victim, TO_CHAR );
if( skill->hit_vict && skill->hit_vict[0] != '\0' )
act( AT_HITME, skill->hit_vict, ch, NULL, victim, TO_VICT );
if( skill->hit_room && skill->hit_room[0] != '\0' )
act( AT_ACTION, skill->hit_room, ch, NULL, victim, TO_NOTVICT );
}
}
else if( dt >= TYPE_HIT && dt < TYPE_HIT + sizeof( attack_table ) / sizeof( attack_table[0] ) )
{
if( obj )
attack = obj->short_descr;
else
attack = attack_table[dt - TYPE_HIT];
}
else
{
bug( "Dam_message: bad dt %d from %s in %d.", dt, ch->name, ch->in_room->vnum );
dt = TYPE_HIT;
attack = attack_table[0];
}

sprintf( buf1, "$n's %s %s $N%c", attack, vp, punct );
sprintf( buf2, "Your %s %s $N for %i damage%c", attack, vp, dam, punct );
sprintf( buf3, "$n %s you for %i damage%c", vp, dam, punct );
}




Everything seems correct to me, but I know something's not right. The problem is the battle messages come out wrong, let me give you an example.

"cast lightning"
You smite Monster for 10 damage.

"kick"
You hit Monster for 4 damage.

But what I'm trying to accomplish is:
Your lightning bolt (or punch etc) hits Monster for X damage.
USA #5
Well you must have removed something then. Stock Smaug includes the attack name.
Quote:
Your lightning bolt jolts Test Goblin!

All you need to do is add the damage. Check back and see what you removed.
#6
Hmm, yeah probably something else I messed with. Ah well, I'll get it eventually. Thanks.
Canada #7
Looks like your spells have been set to TYPE_HIT for some reason.
#8
I've located my mistakes and fixed them. To help those that search on this topic in the future, here's the correct code to get it to work in fight.c:



if( dt >= 0 && dt < ( unsigned int )top_sn )
      skill = skill_table[dt];
   if( dt == TYPE_HIT )
   {
      snprintf( buf1, 256, "$n %s $N%c", vp, punct );
      snprintf( buf2, 256, "You %s $N for %i damage%c", vs, dam, punct );
      snprintf( buf3, 256, "$n %s you for %i damage%c", vp, dam, punct );
   }
   else if( dt > TYPE_HIT && is_wielding_poisoned( ch ) )
   {
      if( dt < TYPE_HIT + sizeof( attack_table ) / sizeof( attack_table[0] ) )
         attack = attack_table[dt - TYPE_HIT];
      else
      {
         bug( "Dam_message: bad dt %d from %s in %d.", dt, ch->name, ch->in_room->vnum );
         dt = TYPE_HIT;
         attack = attack_table[0];
      }

      snprintf( buf1, 256, "$n's poisoned %s %s $N%c", attack, vp, punct );
      snprintf( buf2, 256, "Your poisoned %s %s $N for %i damage%c", attack, vp, dam, punct );
      snprintf( buf3, 256, "$n's poisoned %s %s you%c", attack, vp, punct );
   }
   else
   {
      if( skill )
      {
         attack = skill->noun_damage;
         if( dam == 0 )
         {
            bool found = FALSE;

            if( skill->miss_char && skill->miss_char[0] != '\0' )
            {
               act( AT_HIT, skill->miss_char, ch, NULL, victim, TO_CHAR );
               found = TRUE;
            }
            if( skill->miss_vict && skill->miss_vict[0] != '\0' )
            {
               act( AT_HITME, skill->miss_vict, ch, NULL, victim, TO_VICT );
               found = TRUE;
            }
            if( skill->miss_room && skill->miss_room[0] != '\0' )
            {
               if( str_cmp( skill->miss_room, "supress" ) )
                  act( AT_ACTION, skill->miss_room, ch, NULL, victim, TO_NOTVICT );
               found = TRUE;
            }
            if( found ) /* miss message already sent */
            {
               if( was_in_room )
               {
                  char_from_room( ch );
                  char_to_room( ch, was_in_room );
               }
               return;
            }
         }
         else
         {
            if( skill->hit_char && skill->hit_char[0] != '\0' )
               act( AT_HIT, skill->hit_char, ch, NULL, victim, TO_CHAR );
            if( skill->hit_vict && skill->hit_vict[0] != '\0' )
               act( AT_HITME, skill->hit_vict, ch, NULL, victim, TO_VICT );
            if( skill->hit_room && skill->hit_room[0] != '\0' )
               act( AT_ACTION, skill->hit_room, ch, NULL, victim, TO_NOTVICT );
         }
      }
      else if( dt >= TYPE_HIT && dt < TYPE_HIT + sizeof( attack_table ) / sizeof( attack_table[0] ) )
      {
         if( obj )
            attack = obj->short_descr;
         else
            attack = attack_table[dt - TYPE_HIT];
      }
      else
      {
         bug( "Dam_message: bad dt %d from %s in %d.", dt, ch->name, ch->in_room->vnum );
         dt = TYPE_HIT;
         attack = attack_table[0];
      }

      snprintf( buf1, 256, "$n's %s %s $N%c", attack, vp, punct );
      snprintf( buf2, 256, "Your %s %s $N for %i damage%c ", attack, vp, dam, punct );
      snprintf( buf3, 256, "$n's %s %s you for %i damage%c", attack, vp, dam, punct );
   }