[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  mp_damage all and mp_restore all

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: mp_damage all and mp_restore all
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by MagisterXero   (11 posts)  [Biography] bio
Date Mon 15 Mar 2010 07:42 PM (UTC)  quote  ]
Message
Scratch this, I just realized the problem. -_-

Ordering of code makes a big difference! haha
[Go to top] top

Posted by MagisterXero   (11 posts)  [Biography] bio
Date Mon 15 Mar 2010 07:37 PM (UTC)  quote  ]
Message
Okay, so basically, I'm trying to get a working mp_damage all and mp_restore all on my mud, but I've not yet been able to get this loop to work. Wondering if anyone here can possibly tell me which pieces of my code need to be changed.

mpdamage:

void do_mp_damage( CHAR_DATA * ch, const char *argument )
{
   CHAR_DATA *vch_next;
   char buf[MAX_INPUT_LENGTH];
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   CHAR_DATA *victim;
   int dam;

   /*if( IS_AFFECTED( ch, AFF_CHARM ) )
      return; */

   if( !IS_NPC( ch ) || ( ch->desc && get_trust( ch ) < LEVEL_IMMORTAL ) )
   {
      send_to_char( "Huh?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );

   if( arg1[0] == '\0' )
   {
      send_to_char( "mpdamage whom?\r\n", ch );
      progbug( "Mpdamage: invalid argument1", ch );
      return;
   }

   if( arg2[0] == '\0' )
   {
      send_to_char( "mpdamage inflict how many hps?\r\n", ch );
      progbug( "Mpdamage: invalid argument2", ch );
      return;
   }
   if( ( victim = get_char_room_mp( ch, arg1 ) ) == NULL )
   {
      send_to_char( "Victim must be in room.\r\n", ch );
      //progbug( "Mpdamage: victim not in room", ch );
      return;
   }

   if( victim == ch )
   {
      send_to_char( "You can't mpdamage yourself.\r\n", ch );
      progbug( "Mpdamage: trying to damage self", ch );
      return;
   }

        dam = atoi( arg2 );

   if( ( dam < 0 ) || ( dam > 1000000 ) )
   {
      send_to_char( "Mpdamage how much?\r\n", ch );
      progbug( "Mpdamage: invalid (nonexistent?) argument", ch );
      return;
   }

   /*
    * this is kinda begging for trouble
    */
   /*
    * Note from Thoric to whoever put this in...
    * Wouldn't it be better to call damage(ch, ch, dam, dt)?
    * I hate redundant code
    */

if ( !str_cmp( arg1, "all" ) )
    {
        for ( victim = ch->in_room->first_person; victim; victim = vch_next )
        {
            vch_next = victim->next_in_room;
            if ( victim != ch
            &&   can_see( ch, victim ) ) /* Could go either way */
            {
                sprintf( buf, "'%s' %s", victim->name, arg2 );
                do_mp_damage( ch, buf );
            }
        }
        return;
    }

   if( simple_damage( ch, victim, dam, TYPE_UNDEFINED ) == rVICT_DIED )
   {
      stop_fighting( ch, FALSE );
      stop_hating( ch );
      stop_fearing( ch );
      stop_hunting( ch );
   }

   return;
}


mprestore:


/*
 * syntax: mprestore (character) (#hps)                Gorog
 */
void do_mp_restore( CHAR_DATA * ch, const char *argument )
{
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   CHAR_DATA *victim;
   int hp;

   /*if( IS_AFFECTED( ch, AFF_CHARM ) )
      return;*/

   if( !IS_NPC( ch ) || ( ch->desc && get_trust( ch ) < LEVEL_IMMORTAL ) )
   {
      send_to_char( "Huh?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );

   if( arg1[0] == '\0' )
   {
      send_to_char( "mprestore whom?\r\n", ch );
      progbug( "Mprestore: invalid argument1", ch );
      return;
   }

   if( arg2[0] == '\0' )
   {
      send_to_char( "mprestore how many hps?\r\n", ch );
      progbug( "Mprestore: invalid argument2", ch );
      return;
   }

   if( ( victim = get_char_room_mp( ch, arg1 ) ) == NULL )
   {
      send_to_char( "Victim must be in room.\r\n", ch );
      progbug( "Mprestore: victim not in room", ch );
      return;
   }

   hp = atoi( arg2 );

   if( ( hp < 0 ) || ( hp > 32000 ) )
   {
      send_to_char( "Mprestore how much?\r\n", ch );
      progbug( "Mprestore: invalid (nonexistent?) argument", ch );
      return;
   }
   hp += victim->hit;
   victim->hit = ( hp > 32000 || hp < 0 || hp > victim->max_hit ) ? victim->max_hit : hp;
}


For lack of being unable to make mp_damage work for an "all" command, I haven't touched mp_restore yet. I figured if I was able to make one work, the other would follow suit after.
[Go to top] 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.


811 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]