[CODE][NEWBIE]weapon holding

From: anthony benjamin (benjamin@powerweb.net)
Date: 02/14/99


I looked through the archives already, and the site...but could find no
help...

what I am trying to do is make it so that if you are holding a weapon,
you attack with it. I wanted to make sure i got the right weapon type
message, etc, so I tried to write my own seperate hit function for
it...I know it isn't right...and being a novice C programmer I have no
idea, what I have wrong... Here is my code:

void holdhit(struct char_data * ch, struct char_data * victim, int type)

{
  struct obj_data *held = GET_EQ(ch, WEAR_HOLD);
  int w_typer, victim_ac, calc_thaco, dam, diceroll;

if (GET_EQ(ch, WEAR_HOLD) == ITEM_WEAPON){
   w_typer = GET_OBJ_VAL(held, 3) + TYPE_HIT;


  /* roll the die and take your chances... */
  diceroll = number(1, 20);

  damage(ch, victim, 0, w_typer);
    /* okay, we know the guy has been hit.  now calculate damage. */

    /* Start with the damage bonuses: the damroll and strength apply */
    dam = str_app[STRENGTH_APPLY_INDEX(ch)].todam;
    dam += GET_DAMROLL(ch);

    if (held) {
      /* Add weapon-based damage if a weapon is being wielded */
      dam += dice(GET_OBJ_VAL(held, 1), GET_OBJ_VAL(held, 2));
    }


}else{
 //nothing
}
}

basically for that function I just copied the regular hit function and
cut out what I thought I didn't need...and for the actual call of the
function I used..

if (GET_OBJ_TYPE(holding) == ITEM_WEAPON){
 holdhit(ch, FIGHTING(ch), TYPE_UNDEFINED);
}

none of this works...and within 3 seconds of logging on a character,
obviously when control violence is called, the mud crashes, I imagine I
am referencing some non-existing variable ; ) Any help would be
appreciated, as always...

anthony "this time I searched the archives!"


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