fireweapons

From: Nick Stout (cyberman_64@HOTMAIL.COM)
Date: 08/26/98


Okay... I am trying to add guns to our mud, but i want to do a little
twist.
I want to make it so it has clips, and it uses 1 round every pulse of
violence. I got everything except the round subtraction.
Could you tell me what to add?

act.info.c:
in look_in_obj:

 } else if ((GET_OBJ_TYPE(obj) != ITEM_DRINKCON) &&
             (GET_OBJ_TYPE(obj) != ITEM_FOUNTAIN) &&
             (GET_OBJ_TYPE(obj) != ITEM_CONTAINER))
+ {
+              if ( (GET_OBJ_TYPE(obj) == ITEM_FIREWEAPON) ||
+                    (GET_OBJ_TYPE(obj) == ITEM_MISSILE) ) {
+                           sprintf(buf, "It contains %d units of
ammunition.\r\n", GET_OBJ_VAL(obj,3));
+                           send_to_char(buf,ch);
+                  } else {
+                       send_to_char("There's nothing inside that!\r\n",
ch);
+          }

  } else {
    if (GET_OBJ_TYPE(obj) == ITEM_CONTAINER) {
      if (IS_SET(GET_OBJ_VAL(obj, 1), CONT_CLOSED))

act.offensive.c:
add:
ACMD(do_load_weapon)
{
  /* arg1 = fire weapon arg2 = missiles */

 char arg1[MAX_INPUT_LENGTH];
 char arg2[MAX_INPUT_LENGTH];

 struct obj_data *missile;
 struct obj_data *weapon = GET_EQ(ch, WEAR_WIELD);

 int num_needed = 0;
 int num_left = 0;
 int num_ammo = 0;
 two_arguments(argument, arg1, arg2);

 if (!*arg1 || !*arg2) {
      send_to_char("Usage LOAD|RELOAD <weapon> <ammo>",ch);
      return;
 }
 if (!weapon) {
      send_to_char("You must hold the weapon to load it.",ch);
      return;
 }
 if (GET_OBJ_TYPE(weapon) != ITEM_FIREWEAPON) {
      send_to_char("That item doesn't use ammunition!",ch);
      return;
 }

 missile = get_obj_in_list_vis(ch, arg2, ch->carrying);
 if (!missile) {
     send_to_char("What are you trying to use as ammunition?",ch);
     return;
 }
 if (GET_OBJ_TYPE(missile) != ITEM_MISSILE) {
     send_to_char("That isn't ammunition!",ch);
     return;
 }
 if (GET_OBJ_VAL(missile,0) != GET_OBJ_VAL(weapon,0)) {
     send_to_char("The ammunition won't fit in the weapon!",ch);
     return;
 }
 num_needed = GET_OBJ_VAL(weapon,2) - GET_OBJ_VAL(weapon,3);
 if (!num_needed) {
     send_to_char("It's already fully loaded.",ch);
     return;
 }
 num_ammo = GET_OBJ_VAL(missile,3);
 if (!num_ammo) {
     /* shouldn't really get here.. this one's for Murphy :) */
     send_to_char("It's empty!",ch);
     extract_obj(missile);
     return;
 }
 if (num_ammo <= num_needed) {
     GET_OBJ_VAL(weapon,3) += num_ammo;
     extract_obj(missile);
 } else {
     GET_OBJ_VAL(weapon,3) += num_needed;
     GET_OBJ_VAL(missile,3) -= num_needed;
 }
 act("You load $p", FALSE, ch, weapon, 0, TO_CHAR);
 act("$n loads $p", FALSE, ch, weapon, 0, TO_ROOM);
}


Now to subtract ammo, i have to include this in somewhere. (hit?)

 if ( (GET_OBJ_TYPE(weapon) == ITEM_FIREWEAPON) ) {
 GET_OBJ_VAL(weapon, 3) -= 1;

Would anyone tell me how to format that so that it works? Thanks.
-CyberMan


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


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