Re: Wait states and Perform Violence

From: John (witpens@optushome.com.au)
Date: 12/28/01


Zizazat said: -

>
> The problem comes in when I get into fight.c, specifically
perform_violence.
>
> I don't think I understand what this function is supposed to be doing.
It
> looks like it loops through the combat_list and checks some things for
> sanity (no longer fighting for example) also, if the GET_MOB_WAIT > 0
it
> drops out of the loop and misses the hit at the bottom.

All offensive moves are resolved through the callup of ACMD and then the
PCs are put on the combat_list (this is done through damage() and
hit() ).
Every combat round, perform_violence goes through the entire combat_list
(mobs are also put on the list if they
start a fight) and does all the check and then calls up the hit().

WAIT_STATE for PCs is used for interpreter.c where any commands will be
queued until WAIT_STATE == 0. So, that means no extra offensive
commands, but hit() still gets called through combat_list.

>
> So what is happening is when I try to call a small function check
> mob_warrior(ch) the mob ONLY kicks every 3 rounds but never gets to
the
> hit() below.
>
> This really isn't right, because PCs can perform a kick every 3 rounds
AND
> keep hitting all the while.
>

The answer is in the loop below. For MOBs, WAIT_STATE is checked in
perform_violence (unlike PCs, where it is checked in interpreter.c).
Remember, perform_violence is going through the combat_list, so if
WAIT_STATE > 0, then continue (ie. go to the next ch in combat_list)

> What further confuses me is right below the check:
> if (IS_NPC(ch)) {
>       if (GET_WAIT_STATE(ch) > 0) {
>         GET_WAIT_STATE(ch) -= PULSE_VIOLENCE;
>         continue;  <-----   goes to the next ch in the combat_list
>       }
>
>       GET_WAIT_STATE(ch) = 0;   <------- only reached because
GET_WAIT_STATE(ch) <= 0
>       ^^^^^^^^^^^^^^^^^^^^^^^ The wait state is reset to 0 each
time?!?
>

The WAIT_STATE is set to 0 just in case it goes negative. NOTE: This
statement will only be reached BECAUSE
if (GET_WAIT_STATE(ch) > 0) isnt true <---- remember, it has a continue
command for this if statement.

So, if I were you, this is what I would do:-

if (IS_NPC(ch)) {
   if (GET_MOB_WAIT(ch) > 0) {
      GET_MOB_WAIT(ch) -= PULSE_VIOLENCE;
-     continue;
      }
+  else {
    GET_MOB_WAIT(ch) = 0;
    if (GET_POS(ch) < POS_FIGHTING) {
       GET_POS(ch) = POS_FIGHTING;
       act("$n scrambles to $s feet!", TRUE, ch, 0, 0, TO_ROOM);
       }
+    else {
+          mob_warrior(ch);
+          /* any other checks you want to happen here */
+         }
    }
+ }


Hope this helps.

PS: I am assuming you got rid of mob spec_procs altogether, because now,
mobs can hit even during wait_states BUT they can also
cast spells more than once per round if you allow characters to order
charmed spellcasters. Thats about the only reason I can see the
use of mob wait_states, otherwise, it isnt even called or assigned
anywhere else in stock code *shrug*

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/24/03 PDT