Re: [CODING] Fight System Crash, in act.offensive

From: John (
Date: 12/12/01

Sorry Chi, I didnt read your message clearly - damn, you put this in
do_hit. Here goes a second try:-

Chi Blahs:-
if (GET_OBJ_VAL(GET_EQ(ch, WEAR_WIELD), 3) == 15)
 }// If wielding a gun, works fine
// If not, CRASH
 if ((GET_POS(ch) == POS_STANDING) && (vict != FIGHTING(ch))) {

---> this IF checks isnt needed. Why? Because interpreter.c will make
sure the command doesnt work if GET_POS is at the right minimum.
Secondly, if FIGHTING(ch) exists, then GET_POS(ch) == POS_FIGHTING,
hence again, the command wouldnt go through. So, you dont need this.

// Num attackign is a switch set earlier in do_hit
  while (num_attacking > 0)
    hit(ch, vict, TYPE_UNDEFINED);
   num_attacking -= 1;
   }//end while

----> This loop is definitely where it crashes. Your summary of your
code may miss some vital commands ie. return calls, which takes you out
of the loop for your gun code. But, I can only work with what I am
given. Anyways, you definitely do not need the WAIT_STATE in the LOOP!
You can put it at the end of the command if you like, but not in the

Now, let me put a scenario to you. Att1, Att2 and Att3 hits the victim
three times. Victim then dies and victim is a mob. NOW, I know you think
that all of fight.c does checks etc etc, but the checks assume you are
passing valid parameters. In this instance, you are still in your while
loop. Att4 tries to call hit(ch, vict, TYPE_UNDEFINED) BUT BUT vict
doesnt exist anymore! Forget all the checks at fight.c, your hit() calls
are passing an invalid vict pointer.

I am assuming you did a similar thing with your gun scenario by calling
hit() without the appropriate checks.

So, my re-write would be:-
// assuming you already checked if (GET_EQ(ch, WEAR_WIELD))
if (GET_OBJ_VAL(GET_EQ(ch, WEAR_WIELD), 3) == 15) {
blah blah
return;  // so as to not continue along the function
// now we are not using a gun attack
while (num_attack-- >0 && !vict) {
hit(ch, vict, TYPE_UNDEFINED);
WAIT_STATE(ch, PULSE_VIOLENCE +2);  // note outside of loop
 // end of function

PS: I really dont think players will appreciate having a wait state of
ten rounds if they have five attacks per round.

If you are still having problems, email me with your complete do_hit bit
and I will try to help.

   | FAQ: |
   | Archives: |
   | Newbie List:   |

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