Retreat Skill [by S.Mead]
Snippet Posted Wednesday, August 12th @ 11:35:55 PM, by George Greer in the Skills dept.
Added Apr 27, 1998. Click the link below to read it or download it.

From: "S. Mead" <meadsh@ECE.ORST.EDU>
With Additions From: Andy Hubbard <hub@LEICESTER.AC.UK> and
                     George Greer <greerga@circlemud.org>
Subject: SKILL_RETREAT

    This retreat skill allows a character to flee from battle in a
direction of his choosing and without loss of exp.  The main
disadvantage this skill has over FLEE is that it has a WAIT_STATE, so
you can't go ape with it like you can flee.
    One of the things I would like some help on is getting from the
direction argument to the interger direction... the way I do it
here(with a switch) is pure slop... is there a more efficent way?  Also,
if anyone has some helpful suggestions for cleaning this code up, please
teach me.

-Shaw-
<Sometimes my toilet has floating errors too...>


ACMD(do_retreat)
{
 int prob, percent, dir = 0;
 int retreat_type;

 one_argument(argument, arg);

 if (!FIGHTING(ch))
   {
   send_to_char("You are not fighting!", ch);
   return;
   }
 if (!*arg)
   {
   send_to_char("Retreat where?!?", ch);
   return;
   }

 retreat_type = search_block(argument + 1, dirs, FALSE);

 if (retreat_type < 0 || !EXIT(ch, retreat_type) ||
   EXIT(ch, retreat_type)->to_room == NOWHERE)
   {
   send_to_char("Retreat where?\r\n", ch);
   return;
   }

 percent = GET_SKILL(ch, SKILL_RETREAT);
 prob = number(0, 101);

 if (prob <= percent){
    if (CAN_GO(ch, dir) && !IS_SET(ROOM_FLAGS(EXIT(ch,dir)->to_room),
ROOM_DEATH))
  {
       act("$n skillfully retreats from combat.", TRUE, ch, 0, 0,
TO_ROOM);
  send_to_char("You skillfully retreat from combat.\r\n", ch);
  WAIT_STATE(ch, PULSE_VIOLENCE);
  improve_skill(ch, SKILL_RETREAT, 2);
  do_simple_move(ch, dir, TRUE);
  if (FIGHTING(FIGHTING(ch)) == ch)
   stop_fighting(FIGHTING(ch));
  stop_fighting(ch);
  } else {
  act("$n tries to retreat from combat but has no where to go!", TRUE,
ch,
     0, 0, TO_ROOM);
  send_to_char("You cannot retreat in that direction!", ch);
       return;
  }
 } else {
    send_to_char("You fail your attempt to retreat!\r\n", ch);
    WAIT_STATE(ch, PULSE_VIOLENCE);
    return;
  }
}



<< Restricting access to rooms [by Billy H. Chan] | Reply | View as text | Flattened | Room Affection patch [by The Arrow] >>

 


Related Links
  CircleMUD
George Greer
download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.