Re: Calling set_fighting() inside a manual spell

From: Zeavon (zeavon@kilnar.com)
Date: 09/23/99


On Thu, 23 Sep 1999, Chuck Carson wrote:

> I never though about calling hit()...
>
> I have actually gotten this manual spell to work as I want it too but your
> suggestion seems a bit cleaner.
>

I've found that calling hit() as a work-around to set_fighting() is a bad
idea. If you have a nasty mob fighting a warrior and the warrior's nearby
friendly mage decides to cast his spell on the mob. The mob will hit the
mage even though it is in the middle of fighting the warrior.

Of course, you may LIKE that side effect of using hit(). Personally, I
don't.

Try this code instead:
call set_fighting() just like you normally would, but change
set_fighting() to be:

// start one char fighting another (yes, it is horrible, I know... )
void set_fighting(struct char_data *ch, struct char_data *vict)
{
  // Here we check to make sure that ch doesn't start kicking his own
  // ass. We also abort the set_fighting() if the person is already
  // fighting someone.
  if (ch == vict || FIGHTING(ch))
    return;

  ch->next_fighting = combat_list;
  combat_list = ch;

  if (AFF_FLAGGED(ch, AFF_SLEEP))
    affect_from_char(ch, SPELL_SLEEP);

  FIGHTING(ch) = vict;
  GET_POS(ch) = POS_FIGHTING;
  check_killer(ch, vict);
}

That will replace your work-around of using hit() with a better call of
set_fighting() where set_fighting() does all of the error checking
internally for you.

--
Zeavon Calatin, Spear of Insanity
http://spear.kilnar.com/    telnet://spear.kilnar.com:1066
GCS d- s+: a- C+++ U++++ P++ L++ E---- W+++ N+ o-- K w--
O M- V PS+ PE Y+ PGP- t-- 5-- X+ R+++ tv+ b++ DI++ D++
G e h--- r+++ z+++


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



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