Re: Multiple Attacks

From: Admin of The Keep (dkoepke@california.com)
Date: 10/08/96


On Tue, 8 Oct 1996 the.count@kirk.geog.sc.edu wrote:

> what worked for me was to use an idea posted here a while back
> which added to the heartbeat function in comm.c:
> if (!(pulse % PULSE_VIOLENCE))
> 	perform_violence(1);
> 	perform_violence(2);
> 	perform_violence(3);
> 
> and then change perform_violence, in fight.c, to take an int as an
> argument (does it in the stock?  i don't remember) and set up a case
> structure to handle each additional attack.

  Gag, why?  Write a macro like:

    #define ATTACKS_PER_ROUND(ch)  \
	    ((number(1, 101) <= GET_SKILL(ch, SKILL_HIT_TWO)) + \
	     (number(1, 101) <= GET_SKILL(ch, SKILL_HIT_THREE)) + \
	     (number(1, 101) <= GET_SKILL(ch, SKILL_HIT_FOUR)))

  This should return a number 0-3.  Now, in perform_violence() just do
  a quick for loop:

    int x; /* put this in perform_violence() at the top */

    for (x = 0; x <= ATTACKS_PER_ROUND(ch) && FIGHTING(ch); x++)
      hit(ch, FIGHTING(ch), TYPE_UNDEFINED);

  Remove the call to 'hit' before that because these two lines now take
  care of all hitting.  Note that they do a check for FIGHTING(ch) in
  the for() loop to prevent crashes if the opponent is killed on the
  hit().  All you have to do to add more hits, then, is just add on to
  the ATTACKS_PER_ROUND macro and add the skill in spells.h.  You should
  probably place ATTACKS_PER_ROUND in spells.h, actually, so you don't
  have to go from file to file to add the skill (eg., you'll only have to
  do spells.h, spell_parser.c, and class.c instead of four or more files).

  NOTE: This code was written in my e-mail program without thought or
  reference to the CircleMUD code.  I just wrote what I think would work;
  although, it _probably_ will work... maybe...


  <*=-+Daniel+-=*>
  "Forgive me father, for I am sin."


+-----------------------------------------------------------+
| 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