Re: [Newbie] [CODE] Was: Im a newbie, plz help

From: Derek L. Karnes (dkarnes@mystech.com)
Date: 12/23/96


Daniel Durnin wrote:
<snip>
> 
> 1> Probably very simple to most of you, a Mob spec that makes it switch.
> You know, a mob is fighting three people, and it chooses a person different
> from the present one to start fighting.

What a pleasant fellow. And a merry christmas to you, too, good sir.

UNTESTED code follows:

SPECIAL(switcheronius)
{
  int fighters = 0, found = FALSE;
  struct char_data *vict;

  if (cmd || GET_POS(ch) != POS_FIGHTING)
    return FALSE;

  /* make sure at least 2 people are fighting me */
  for (vict = world[ch->in_room].people; vict; vict = vict->next_in_room)
    if (FIGHTING(vict) == ch)
      count++;
  if (count < 2)
    return (FALSE);
  
  /*
   * pick someone who's fighting me that I'm not already fighting, and
   * make it a litle random
   */
  do {
    for (vict = world[ch->in_room].people; vict; vict = vict->next_in_room)
      if (FIGHTING(vict) == ch && FIGHTING(ch) != vict && !number(0, 4) )
	{
	  found = TRUE;
	  break;
	}
  } while (!found);

  act("$n turns on $N!",  TRUE, ch, 0, vict, TO_NOTVICT);
  act("$n turns on you!", TRUE, ch, 0, vict, TO_VICT);

  stop_fighting(vict);
  stop_fighting(ch);
  
  set_fighting(ch, vict);

  return(TRUE);
}

--

--    dkarnes@mystech.com
--    Serapis, Imp of Dark Pawns
--    www.augusta.net 4000
--    Open for Beta testing
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST