Missile weapons patch

From: Dan Argent (mbax7dja@FS1.CS.MAN.AC.UK)
Date: 05/28/98


To all who have the ranged weapons patch on their mud.

A quick question to answer a headache I have.
The function fire_missile needs a (missile) as one of it's values
(eg.. WEAR_HOLD), otherwise you crash.

I can load an instance of the object when there is <2 arg ..ie when
you just type "shoot" and it responds "who, where?!"

But if you try and actually shoot someone, if wont work.
code is attached, I apologise for the hackishness.

Also, this code DID work,  before the addition of the unequip char in
the "whom do you wish to shoot " case.

ACMD(do_shoot)
{
 struct obj_data *missile = GET_EQ(ch, WEAR_HOLD);
struct obj_data *anum;
struct obj_data *weapon = GET_EQ(ch, WEAR_WIELD);
  char arg2[MAX_INPUT_LENGTH];
  char arg1[MAX_INPUT_LENGTH];
  int dir, range;
int ammo_num;

  if (!GET_EQ(ch, WEAR_WIELD)) {
    send_to_char("You aren't wielding a shooting weapon!\r\n", ch);
    return;
  }

  if (( (GET_OBJ_TYPE(weapon) != ITEM_FIREWEAPON)
&&       (GET_OBJ_TYPE(weapon) != ITEM_PISTOL)
&&       (GET_OBJ_TYPE(weapon) != ITEM_SMG)
&&       (GET_OBJ_TYPE(weapon) != ITEM_RIFLE)
&&       (GET_OBJ_TYPE(weapon) != ITEM_SHOTGUN)
&&       (GET_OBJ_TYPE(weapon) != ITEM_LMG)
&&       (GET_OBJ_TYPE(weapon) != ITEM_LASER)
&&       (GET_OBJ_TYPE(weapon) != ITEM_HEAVY))

&&  (!GET_EQ(ch, WEAR_HOLD))) {
    send_to_char("You need to be holding a missile!\r\n", ch);
    return;
  }


if (GET_OBJ_TYPE(weapon) == ITEM_PISTOL )
             {     range = GET_EQ(ch, WEAR_WIELD)->obj_flags.value[0];
ammo_num =   GET_EQ(ch, WEAR_WIELD)->obj_flags.value[1]; anum =
read_object(ammo_num, VIRTUAL);
 sprintf (buf, "ammo number %d   anum %d   \r\n", ammo_num, anum);
equip_char(ch, anum, WEAR_HOLD);
    printf ("okay... ");
   send_to_char (buf,ch);
        }
else
 if ((GET_OBJ_TYPE(GET_EQ(ch, WEAR_WIELD)) == ITEM_SLING) &&
      (GET_OBJ_TYPE(missile) == ITEM_ROCK))
       range = GET_EQ(ch, WEAR_WIELD)->obj_flags.value[0];
  else
    if ((GET_OBJ_TYPE(missile) == ITEM_ARROW) &&
        (GET_OBJ_TYPE(GET_EQ(ch, WEAR_WIELD)) == ITEM_BOW))
         range = GET_EQ(ch, WEAR_WIELD)->obj_flags.value[0];
  else
    if ((GET_OBJ_TYPE(missile) == ITEM_BOLT) &&
        (GET_OBJ_TYPE(GET_EQ(ch, WEAR_WIELD)) == ITEM_CROSSBOW))
         range = GET_EQ(ch, WEAR_WIELD)->obj_flags.value[0];

  else {
    send_to_char("You should wield a missile weapon and hold a
    missile!\r\n", ch
);
    return;
  }

/* itt was here */

  two_arguments(argument, arg1, arg2);
 if (!*arg1 || !*arg2) {
    send_to_char("You should try: shoot <someone> <direction>\r\n",
    ch);
      extract_obj(unequip_char(ch, WEAR_HOLD));
          return;
}


/*  if (IS_DARK(ch->in_room)) {
    send_to_char("You can't see that far.\r\n", ch);
    return;
  } */

  if ((dir = search_block(arg2, dirs, FALSE)) < 0) {
    send_to_char("What direction?\r\n", ch);
    return;
  }

  if (!CAN_GO(ch, dir)) {
    send_to_char("Something blocks the way!\r\n", ch);
    return;

 if (range > 3)
    range = 3;
  if (range < 1)
    range = 1;

  fire_missile(ch, arg1, missile, WEAR_HOLD, range, dir);



Cheers

Dan...


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST