Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ battle/skill damage in Smaugfuss 1.7

battle/skill damage in Smaugfuss 1.7

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Kilos   (9 posts)  Bio
Date Fri 19 May 2006 03:14 PM (UTC)
Message

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

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #1 on Fri 19 May 2006 03:30 PM (UTC)
Message
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?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Kilos   (9 posts)  Bio
Date Reply #2 on Fri 19 May 2006 03:48 PM (UTC)
Message
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.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #3 on Fri 19 May 2006 07:46 PM (UTC)
Message
What exactly is the problem again?

Skills are handled in the function you're in, look for something like "$n's %s %s"

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Kilos   (9 posts)  Bio
Date Reply #4 on Fri 19 May 2006 09:06 PM (UTC)
Message
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.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #5 on Fri 19 May 2006 09:18 PM (UTC)
Message
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.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Kilos   (9 posts)  Bio
Date Reply #6 on Fri 19 May 2006 10:06 PM (UTC)
Message
Hmm, yeah probably something else I messed with. Ah well, I'll get it eventually. Thanks.
Top

Posted by Dace K   Canada  (169 posts)  Bio
Date Reply #7 on Sat 20 May 2006 01:43 AM (UTC)
Message
Looks like your spells have been set to TYPE_HIT for some reason.

ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com

Drop by the area archives and find something for your mud. http://areaarchives.servegame.com
Top

Posted by Kilos   (9 posts)  Bio
Date Reply #8 on Sat 20 May 2006 12:22 PM (UTC)
Message
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 );
   }
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


21,130 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.