Re: Wait states and Perform Violence

From: John (
Date: 12/28/01

Zizazat said: -

> The problem comes in when I get into fight.c, specifically
> I don't think I understand what this function is supposed to be doing.
> 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
> 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
> hit() below.
> This really isn't right, because PCs can perform a kick every 3 rounds
> 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) {
>         continue;  <-----   goes to the next ch in the combat_list
>       }
>       GET_WAIT_STATE(ch) = 0;   <------- only reached because
>       ^^^^^^^^^^^^^^^^^^^^^^^ The wait state is reset to 0 each

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) {
-     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: |
   | Archives: |
   | Newbie List:   |

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