#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "mud.h" extern char *const dir_rev[]; void do_drag (CHAR_DATA * ch, char *argy) { char arg1[SML_LENGTH]; char buf[500]; SINGLE_OBJECT *obj = NULL; CHAR_DATA *rch; char arg2[SML_LENGTH]; int dir; ROOM_DATA *oldroom; DEFINE_COMMAND ("drag", do_drag, POSITION_STANDING, 0, LOG_NORMAL, "This command allows you to drag a corpse.") arg1[0] = '\0'; arg2[0] = '\0'; if (strlen (argy) >= 50) return; argy = one_argy (argy, arg1); argy = one_argy (argy, arg2); if (arg1[0] == '\0') { send_to_char ("Drag what?\n\r", ch); return; } if (arg2[0] == '\0' || ((dir = get_direction_number (arg2)) == MAX_DIR)) { send_to_char ("In which direction?\n\r", ch); return; } if ((obj = get_obj_here (ch, arg1, SEARCH_ROOM_FIRST)) == NULL || obj->carried_by != NULL || obj->in_room == NULL) { send_to_char ("I don't see that object here....\n\r", ch); return; } if (obj->pIndexData->item_type != ITEM_CORPSE_PC && obj->pIndexData->item_type != ITEM_CORPSE_NPC && obj->pIndexData->item_type != ITEM_SIEGE && !CAN_WEAR (obj, ITEM_TAKE)) { send_to_char ("You can't drag that object...\n\r", ch); return; } if (ch->move < 10) { send_to_char ("You are too exhausted to drag anything...\n\r", ch); return; } dir = -1; if (arg2[0] == 'n' || arg2[0] == 'N') dir = DIR_NORTH; if (arg2[0] == 'w' || arg2[0] == 'W') dir = DIR_WEST; if (arg2[0] == 'e' || arg2[0] == 'E') dir = DIR_EAST; if (arg2[0] == 's' || arg2[0] == 'S') dir = DIR_SOUTH; if (arg2[0] == 'u' || arg2[0] == 'U') dir = DIR_UP; if (arg2[0] == 'd' || arg2[0] == 'D') dir = DIR_DOWN; if (dir == -1) { send_to_char ("Which direction?\n\r", ch); return; } oldroom = ch->in_room; if (!move_char (ch, dir)) { send_to_char ("How can you drag something to someplace you can't even go!\n\r", ch); return; } sprintf (buf, "%s drags %s %s.\n\r", NAME (ch), (obj->short_descr ? obj->short_descr : obj->pIndexData->short_descr), dir_name[dir]); for (rch = oldroom->people; rch != NULL; rch = rch->next_in_room) { if (rch == ch) continue; if (!IS_AWAKE (rch)) continue; send_to_char (buf, rch); } obj_from (obj); obj_to (obj, ch->in_room); sprintf (buf, "You drag %s into the room.\n\r", (obj->short_descr ? obj->short_descr : obj->pIndexData->short_descr)); send_to_char (buf, ch); sprintf (buf, "%s drags %s in from %s.\n\r", NAME (ch), (obj->short_descr ? obj->short_descr : obj->pIndexData->short_descr), dir_rev[rev_dir[dir]]); for (rch = ch->in_room->people; rch != NULL; rch = rch->next_in_room) { if (rch == ch) continue; if (!IS_AWAKE (rch)) continue; send_to_char (buf, rch); } SUBMOVE(ch, number_range (8, 10)); return; } void do_meditate (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("meditate", do_meditate, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to meditate, and focus on magical energy regeneration.") if (RIDING (ch) != NULL) { send_to_char ("If you wanted to sit and meditate, you would not be riding!\n\r", ch); return; } if (ch->fgt && ch->fgt->ears > 9) { send_to_char ("You are bashed; you can't meditate...\n\r", ch); return; } if (FIGHTING(ch)) { if (FIGHTING(ch)->in_room != ch->in_room) { ch->fgt->fighting = NULL; NEW_POSITION(ch, POSITION_STANDING); } else { act ("You must start meditation from a standing or resting position.", ch, NULL, NULL, TO_CHAR); return; } } if (ch->position != POSITION_STANDING && ch->position != POSITION_RESTING && ch->position != POSITION_MEDITATING) { act ("You must start meditation from a standing or resting position.", ch, NULL, NULL, TO_CHAR); return; } if (ch->position == POSITION_MEDITATING) { NEW_POSITION(ch, POSITION_STANDING); act ("You stop meditating, and clamber to your feet.", ch, NULL, NULL, TO_CHAR); act ("$N stops meditating, and clambers to $s feet.", ch, NULL, ch, TO_ROOM); return; } NEW_POSITION(ch, POSITION_MEDITATING); act ("You sit down cross-legged and begin meditating.", ch, NULL, NULL, TO_CHAR); act ("$N sits down, clears $s mind, and begins meditating.", ch, NULL, ch, TO_ROOM); return; } void get_obj (CHAR_DATA * ch, SINGLE_OBJECT * obj, SINGLE_OBJECT * container, bool opp_align) { CHAR_DATA *fch; CHAR_DATA *fch_next; if (!CAN_WEAR (obj, ITEM_TAKE)) { send_to_char ("You can't take that.\n\r", ch); return; } for (fch = ch->in_room->people; fch != NULL; fch = fch_next) { fch_next = fch->next_in_room; if (IS_MOB (fch) && fch->pIndexData->guard && can_see(fch, ch) && obj->pIndexData->vnum == fch->pIndexData->guard->guarding_object) { do_say (fch, "Don't touch that!"); multi_hit (fch, ch, TYPE_UNDEFINED); return; } } if (!opp_align) { if (container != NULL) { act ("You get $p\x1B[37;0m from $P\x1B[0m.", ch, obj, container, TO_CHAR); act ("$n gets $p\x1B[37;0m from $P\x1B[0m.", ch, obj, container, TO_ROOM); } else { act ("You get $p\x1B[37;0m.", ch, obj, container, TO_CHAR); act ("$n gets $p\x1B[37;0m.", ch, obj, container, TO_ROOM); } } obj_from (obj); obj->wear_loc = -1; obj_to (obj, ch); if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(ch)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) SET_BIT(ch->act, PLR_HAS_BOAT); } return; } void do_take (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("take", do_get, POSITION_RESTING, 0, LOG_NORMAL, "This command allows you to get an object from an object, or from the ground.") return; } void do_get (CHAR_DATA * ch, char *argy) { char arg1[SML_LENGTH]; char arg2[SML_LENGTH]; char buffy[SML_LENGTH]; char buf[200]; SINGLE_OBJECT *obj; SINGLE_OBJECT *obj_next; SINGLE_OBJECT *container; CHAR_DATA *fch; I_CONTAINER *cnt; bool found = FALSE; bool gonnasave = FALSE; bool opp_align = FALSE; DEFINE_COMMAND ("get", do_get, POSITION_RESTING, 0, LOG_NORMAL, "This command allows you to get an object from an object, or from the ground.") if(IS_PLAYER(ch)) { for(fch = ch->in_room->people; fch != NULL; fch = fch->next_in_room) { if (IS_PLAYER(fch) && DIFF_ALIGN(ch, fch)) { opp_align = TRUE; break; } } } if (!str_cmp (argy, "all corpse")) { argy = one_argy (argy, arg1); argy = one_argy (argy, arg2); } else { argy = one_argy (argy, arg1); while (str_prefix ("from", argy) && argy != "" && argy[0] != '\0') argy = one_argy (argy, arg1); argy = one_argy (argy, arg2); while (argy != "" && argy[0] != '\0') argy = one_argy (argy, arg2); } if (arg1[0] == '\0') { send_to_char ("Get what?\n\r", ch); return; } for (fch = ch->in_room->people; fch != NULL; fch = fch->next_in_room) { if (can_see (ch, fch) && is_name (arg1, RNAME (fch)) && fch->position == POSITION_STANDING && IS_MOB (fch) && IS_SET (fch->pIndexData->act3, ACT3_MIMIC)) { act ("$n attacks as you try to pick it up!", fch, NULL, ch, TO_VICT); act ("$n attacks as $N tries to pick it up!", fch, NULL, ch, TO_NOTVICT); multi_hit (fch, ch, TYPE_UNDEFINED); return; } } if (arg2[0] == '\0') { if (str_cmp (arg1, "all") && str_prefix ("all.", arg1)) { if (!str_cmp (arg1, "coins") || !str_cmp (arg1, "coin")) { int i; int cointypes = 0; found = FALSE; for (i = 0; i < MAX_COINS; i++) if(ch->in_room->coins[i] > 0) cointypes++; if (cointypes == 0) { send_to_char("There are no coins here to pick up.\n\r", ch); return; } else { if (cointypes == 1) { for (i = 0; i < MAX_COINS; i++) if (ch->in_room->coins[i] > 0) break; sprintf(buf, "You pick up %d %s.", ch->in_room->coins[i],coin_color[i]); send_to_char(buf, ch); ch->coins[i] += ch->in_room->coins[i]; ch->in_room->coins[i] = 0; return; } else { int coins_used = 0; char buf2[100]; sprintf(buf, "You pick up "); for (i = 0; i < MAX_COINS; i++) { if (ch->in_room->coins[i] > 0) { coins_used++; if (coins_used < cointypes) { sprintf(buf2, "%d %s, ", ch->in_room->coins[i], coin_color[i]); strcat(buf, buf2); } else { sprintf(buf2, "and %d %s.\n\r", ch->in_room->coins[i], coin_color[i]); strcat(buf, buf2); } ch->coins[i] += ch->in_room->coins[i]; ch->in_room->coins[i] = 0; } } send_to_char(buf, ch); return; } } } obj = get_obj_list (ch, arg1, ch->in_room->contents); if (obj == NULL || IS_SET (obj->extra_flags, ITEM_UNSEEN)) { act ("It isn't here.", ch, NULL, NULL, TO_CHAR); return; } get_obj (ch, obj, NULL, opp_align); if (opp_align) { act("You pick up $p.", ch, obj,NULL , TO_CHAR); act("$n picks up $p.", ch, obj, NULL, TO_ROOM); } } else { int i; found = FALSE; for (i = 0; i < MAX_COINS; i++) { if (ch->in_room->coins[i] > 0) { found = TRUE; sprintf(buf, "You pick up %d %s.\n\r", ch->in_room->coins[i], coin_color[i]); send_to_char(buf, ch); ch->coins[i] += ch->in_room->coins[i]; ch->in_room->coins[i] = 0; } } for (obj = ch->in_room->contents; obj != NULL; obj = obj_next) { obj_next = obj->next_content; if ((arg1[3] == '\0' || is_name (&arg1[4], obj->pIndexData->name)) && can_see_obj (ch, obj) && !IS_SET (obj->extra_flags, ITEM_UNSEEN)) { found = TRUE; get_obj (ch, obj, NULL, opp_align); } } if (!found) { if (arg1[3] == '\0') send_to_char ("I see nothing here.\n\r", ch); else act ("I don't see that here.", ch, NULL, NULL, TO_CHAR); } else if (opp_align) { act("You pick up several items.", ch, NULL,NULL , TO_CHAR); act("$n gathers up several things off the ground.", ch, NULL, NULL, TO_ROOM); } } } else { if (!str_cmp (arg2, "all") || !str_prefix ("all.", arg2)) { send_to_char ("You can't do that.\n\r", ch); return; } if ((container = (!str_prefix ("cor", arg2) ? get_obj_here (ch, arg2, SEARCH_ROOM_FIRST) : get_obj_here (ch, arg2, SEARCH_INV_FIRST))) == NULL) { send_to_char("That does not appear to be here.\n\r", ch); return; } switch (container->pIndexData->item_type) { default: send_to_char ("You can't look inside that...\n\r", ch); return; case ITEM_CONTAINER: case ITEM_CORPSE_NPC: { cnt = (I_CONTAINER *) container->more; if ((cnt->money > 0 || container->contains) && strlen (NAME (ch)) < 30) { if (cnt->looted_by[0] == '\0') { strcpy (cnt->looted_by, NAME (ch)); } else if (cnt->looted_by_two[0] == '\0' && str_cmp (NAME (ch), cnt->looted_by)) { strcpy (cnt->looted_by_two, NAME (ch)); } } } break; case ITEM_CORPSE_PC: { char name[SML_LENGTH]; char *pd; if (!pow.get_from_corpse_while_in_combat && FIGHTING (ch)) { send_to_char ("You don't have time to loot the corpse while you are fighting!\n\r", ch); return; } cnt = (I_CONTAINER *) container->more; pd = OOSTR (container, short_descr); pd = one_argy (pd, name); pd = one_argy (pd, name); pd = one_argy (pd, name); pd = one_argy (pd, name); /*name now equals the name of the person */ if (IS_PLAYER(ch) && LEVEL(ch)<=pow.loot_level && str_cmp(name,NAME(ch))) { send_to_char("You cannot loot another person's corpse at that low level.\n\r",ch); return; } if ((container->contains || cnt->money > 0) && str_cmp (NAME (ch), capitalize (name))) { if (strlen (NAME (ch)) < 30) { if (cnt->looted_by[0] == '\0') { strcpy (cnt->looted_by, NAME (ch)); } else if (cnt->looted_by_two[0] == '\0' && str_cmp (NAME (ch), cnt->looted_by)) { strcpy (cnt->looted_by_two, NAME (ch)); } } fprintf (stderr, "%s just took something from %s's corpse.\n", NAME (ch), capitalize (name)); } if (container->contains || cnt->money > 0) { sprintf (buffy, "%s%s.cor", PLAYER_DIR_2, capitalize (name)); unlink (buffy); } gonnasave = TRUE; if (IS_PLAYER (ch) && str_cmp (NAME (ch), capitalize (name))) { if (ch->pcdata->no_quit_pk < 4); ch->pcdata->no_quit_pk = 4;/*JRAJRA*/ } /* JRAJRA -noquit stuff */ } } cnt = (I_CONTAINER *) container->more; if (IS_SET (cnt->flags, CONT_CLOSED)) { act ("The $d is closed.", ch, NULL, container->pIndexData->name, TO_CHAR); return; } if (str_cmp (arg1, "all") && str_prefix ("all.", arg1)) { cnt = (I_CONTAINER *) container->more; if (!str_cmp (arg1, "coins")) { int i; int amount = cnt->money; if (cnt->money < 1) { send_to_char ("I see no coins in there.\n\r", ch); return; } sprintf (buf, "You get %s from %s\x1B[0;37m.\n\r", name_amount (cnt->money), OOSTR (container, short_descr)); for (i = MAX_COINS-1; i >= 0; i--) { if (amount >= coin_mult[i]) { ch->coins[i] += amount/coin_mult[i]; amount %= coin_mult[i]; } } cnt->money = 0; send_to_char (buf, ch); return; } obj = get_obj_list (ch, arg1, container->contains); if (obj == NULL) { act ("There is nothing like that in the $T\x1B[0m.", ch, NULL, arg2, TO_CHAR); return; } get_obj (ch, obj, container, opp_align); if (opp_align) { act("You get $p from $P.", ch, obj, container, TO_CHAR); act("$n reaches in and gets $p out of $P.", ch, obj, container, TO_ROOM); } } else { cnt = (I_CONTAINER *) container->more; found = FALSE; if (cnt->money > 0) { int i; int amount = cnt->money; sprintf (buf, "You get %s from %s.\x1B[0;37m\n\r", name_amount (cnt->money), OOSTR (container, short_descr)); for (i = MAX_COINS-1; i >= 0; i--) { if (amount >= coin_mult[i]) { ch->coins[i] += amount/coin_mult[i]; amount %= coin_mult[i]; } } cnt->money = 0; send_to_char (buf, ch); found = TRUE; } for (obj = container->contains; obj != NULL; obj = obj_next) { obj_next = obj->next_content; if ((arg1[3] == '\0' || is_name (&arg1[4], obj->pIndexData->name)) && can_see_obj (ch, obj)) { found = TRUE; get_obj (ch, obj, container, opp_align); } } if (!found) { if (arg1[3] == '\0') act ("I see nothing in $T\x1B[0m.", ch, NULL, arg2, TO_CHAR); else act ("I see nothing like that in $T\x1B[0m.", ch, NULL, arg2, TO_CHAR); } else { if (opp_align) { if (arg1[3] == '\0') { act ("You get some things from $P\x1B[0m.", ch, NULL,container,TO_CHAR); act ("$n gets some things from $P\x1b[0;37m.", ch, NULL,container,TO_ROOM); } else { act ("You get some things from $P\x1B[0m.", ch,NULL,container,TO_CHAR); act ("$n gets some stuff from $P\x1b[0;37m.", ch, NULL,container, TO_ROOM); } } } } } if (IS_PLAYER (ch)) update_weight_num (ch); return; } void do_put (CHAR_DATA * ch, char *argy) { char arg1[SML_LENGTH]; char arg2[SML_LENGTH]; SINGLE_OBJECT *container; SINGLE_OBJECT *obj; SINGLE_OBJECT *obj_next; I_CONTAINER *cnt; DEFINE_COMMAND ("put", do_put, POSITION_RESTING, 0, LOG_NORMAL, "This command allows you to put an object in something.") argy = one_argy (argy, arg1); while (str_prefix ("in", argy) && argy != "" && argy[0] != '\0') argy = one_argy (argy, arg1); argy = one_argy (argy, arg2); while (argy != "" && argy[0] != '\0') argy = one_argy (argy, arg2); if (arg1[0] == '\0' || arg2[0] == '\0') { send_to_char ("Put what in what?\n\r", ch); return; } if (!str_cmp (arg1, "all.coin") || !str_cmp (arg1, "coin") || !str_cmp (arg1, "all.coins") || !str_cmp (arg1, "coins")) { char buffu[500]; if ((container = get_obj_here (ch, arg2, SEARCH_INV_FIRST)) == NULL) { act ("I see no $T here.", ch, NULL, arg2, TO_CHAR); return; } if (container->pIndexData->item_type != ITEM_CONTAINER) { send_to_char ("You can't put anything inside of that.\n\r", ch); return; } cnt = (I_CONTAINER *) container->more; cnt->money += ch->coins[COPPER]; sprintf (buffu, "You put your copper in %s. (Gold pieces can't go inside containers).\n\r", OOSTR (container, short_descr)); act (buffu, ch, NULL, ch, TO_CHAR); ch->coins[COPPER] = 0; return; } if (!str_cmp (arg2, "all") || !str_prefix ("all.", arg2)) { send_to_char ("You can't do that.\n\r", ch); return; } if ((container = get_obj_here (ch, arg2, SEARCH_INV_FIRST)) == NULL) { act ("I see no $T here.", ch, NULL, arg2, TO_CHAR); return; } if (container->pIndexData->item_type != ITEM_CONTAINER) { send_to_char ("That's not a container.\n\r", ch); return; } cnt = (I_CONTAINER *) container->more; if (IS_SET (cnt->flags, CONT_CLOSED)) { act ("The $d is closed.", ch, NULL, container->pIndexData->name, TO_CHAR); return; } if (str_cmp (arg1, "all") && str_prefix ("all.", arg1)) { if ((obj = get_obj_inv (ch, arg1)) == NULL) { send_to_char ("You do not have that item.\n\r", ch); return; } if (obj->wear_loc!=WEAR_NONE && IS_SET (obj->extra_flags, ITEM_NOREMOVE)) { send_to_char("You can't remove that item!\n\r",ch); return; } if (obj == container) { send_to_char ("Now that would be a trick, eh?\n\r", ch); return; } if (!can_drop_obj (ch, obj)) { send_to_char ("You can't let go of it.\n\r", ch); return; } if ((cnt->max_weight + container->pIndexData->weight) < (get_obj_weight (obj) + get_obj_weight (container))) { send_to_char ("It won't fit.\n\r", ch); return; } obj_from (obj); obj_to (obj, container); if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(ch)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) REMOVE_BIT(ch->act, PLR_HAS_BOAT); } act ("$n puts $p\x1B[0m in $P\x1B[0m.", ch, obj, container, TO_ROOM); act ("You put $p\x1B[0m in $P\x1B[0m.", ch, obj, container, TO_CHAR); } else { cnt = (I_CONTAINER *) container->more; for (obj = ch->carrying; obj != NULL; obj = obj_next) { obj_next = obj->next_content; if ((arg1[3] == '\0' || is_name (&arg1[4], obj->pIndexData->name)) && can_see_obj (ch, obj) && obj->wear_loc == WEAR_NONE && obj != container && can_drop_obj (ch, obj) && get_obj_weight (obj) + get_obj_weight (container) <= cnt->max_weight) { obj_from (obj); obj_to (obj, container); if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(ch)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) REMOVE_BIT(ch->act, PLR_HAS_BOAT); } act ("$n puts $p\x1B[0m in $P\x1B[0m.", ch, obj, container, TO_ROOM); act ("You put $p\x1B[0m in $P\x1B[0m.", ch, obj, container, TO_CHAR); } } } return; } void do_drop (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; char buf[SML_LENGTH]; CHAR_DATA *fch; bool opp_align = FALSE; int amount; SINGLE_OBJECT *obj_next; bool found = FALSE; char arg2[SML_LENGTH]; DEFINE_COMMAND ("drop", do_drop, POSITION_RESTING, 0, LOG_NORMAL, "This command allows you to drop an object.") argy = one_argy (argy, arg); if (!is_number (arg)) { while (argy != "" && argy[0] != '\0') argy = one_argy (argy, arg); } argy = one_argy (argy, arg2); if (!ch->in_room) return; CAN_DROP_ITEMS_IN_BGROUND (no) CAN_DROP_ITEMS_IN_ARENA (no) if (IS_PLAYER(ch)) for (fch = ch->in_room->people; fch != NULL; fch = fch->next_in_room) { if (IS_PLAYER(fch) && DIFF_ALIGN(ch, fch)) { opp_align = TRUE; break; } } if (arg[0] == '\0') { send_to_char ("Drop what?\n\r", ch); return; } if (!str_cmp (arg, "coin") || !str_cmp (arg, "coins") || !str_cmp (arg, "all.coin") || !str_cmp (arg, "all.coins")) { char bufff[500]; if (tally_coins (ch) < 0) { send_to_char ("You have no coins in your inventory!\n\r", ch); return; } { int i; for (i = 0; i < MAX_COINS; i++) { ch->in_room->coins[i] += ch->coins[i]; ch->coins[i] = 0; } } sprintf (bufff, "You drop your coins.\n\r"); act("$n drops some coins.", ch, NULL,NULL, TO_ROOM); send_to_char (bufff, ch); return; } if (IS_PLAYER (ch)) { update_weight_num (ch); /*save_char_obj(ch); */ } if (is_number(arg) && atoi(arg) > 0) { int i; for (i = 0; i < MAX_COINS; i++) { if (!str_cmp(arg2, coin_name[i])) { amount = atoi(arg); if (ch->coins[i] < amount) { sprintf(buf, "You don't have that many %s coins!\n\r", coin_color[i]); send_to_char(buf, ch); return; } ch->coins[i] -= amount; if (ch->in_room->sector_type != SECT_WATER_SWIM && ch->in_room->sector_type != SECT_WATER_NOSWIM) ch->in_room->coins[i]+= amount; sprintf(buf, "You drop %d %s coins.\n\r", amount, coin_color[i]); send_to_char(buf, ch); sprintf(buf, "$n drops some %s coins.\n\r", coin_color[i]); act( buf, ch, NULL, NULL, TO_ROOM); return; } } } if ((str_cmp (arg, "all") && str_prefix ("all.", arg)) || (ch->fgt && ch->fgt->combat_delay_count == 9)) { if ((obj = get_obj_inv (ch, arg)) == NULL) { send_to_char ("You do not have that item.\n\r", ch); return; } else if ((!NOT_WORN (obj)) ) { send_to_char ("You will have to remove it first.\n\r", ch); return; } if (!can_drop_obj (ch, obj)) { send_to_char ("You can't let go of it.\n\r", ch); return; } if (obj->wear_loc == -1 && !IS_SET (obj->extra_flags, ITEM_UNSEEN) && (ch->fgt && ch->fgt->combat_delay_count == 9)) { act ("You hide $p\x1B[0m in the room.", ch, obj, NULL, TO_CHAR); ch->fgt->combat_delay_count = 0; obj->extra_flags ^= ITEM_UNSEEN; obj_from (obj); if (ch->in_room->sector_type == SECT_WATER_SWIM || ch->in_room->sector_type == SECT_WATER_NOSWIM) { act ("The waters cause $p to sink beneath them; lost forever.", ch, obj, NULL, TO_CHAR); free_it (obj); return; } obj_to (obj, ch->in_room); if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(ch)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) REMOVE_BIT(ch->act, PLR_HAS_BOAT); } if (check_skill(ch, gsn_hide)) act ("$n hides $p\x1B[0m.", ch, obj, NULL, TO_ROOM); return; } act ("You drop $p\x1B[37;0m.", ch, obj, NULL, TO_CHAR); act ("$n drops $p\x1B[37;0m.", ch, obj, NULL, TO_ROOM); obj_from (obj); if (ch->in_room->sector_type == SECT_WATER_SWIM || ch->in_room->sector_type == SECT_WATER_NOSWIM) { act ("The waters cause $p to sink beneath them; lost forever.", ch, obj, NULL, TO_CHAR); free_it (obj); } else { obj_to (obj, ch->in_room); if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(ch)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) REMOVE_BIT(ch->act, PLR_HAS_BOAT); } if (IS_OBJ_STAT(obj, ITEM_DROPSCRIPT)) { again_8: /* Dropped item, check for triggers on object! */ { SINGLE_TRIGGER *tr; SCRIPT_INFO *s; for (tr = trigger_list[TDROPPED]; tr != NULL; tr = tr->next) { if (obj->pIndexData->vnum == tr->attached_to_obj) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_8; } { char tmp[500]; sprintf(tmp,"%d",ch->in_room->vnum); if (tr->keywords[0] != '\0' && !one_is_in_list_two (tmp, tr->keywords)) continue; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->obj = obj; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ } } } } /* End trigger check! */ if (IS_SET(ch->in_room->room_flags, ROOM_DROPSCRIPT)) { again_9: /* Dropped item, check for triggers on room! */ { SINGLE_TRIGGER *tr; SCRIPT_INFO *s; for (tr = trigger_list[TDROPPED]; tr != NULL; tr = tr->next) { if (ch->in_room->vnum == tr->attached_to_room) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_9; } { char tmp[50]; sprintf(tmp,"%d",obj->pIndexData->vnum); if (tr->keywords[0] != '\0' && !one_is_in_list_two (tmp, tr->keywords)) continue; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->room = ch->in_room; s->obj = obj; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ } } } } /* End trigger check! */ } } else { if (!str_cmp (arg, "all")) { found = FALSE; if (tally_coins (ch) > 0) { char bunl[500]; int i; if (ch->in_room->sector_type != SECT_WATER_SWIM && ch->in_room->sector_type != SECT_WATER_NOSWIM) { for (i = 0; i < MAX_COINS; i++) { ch->in_room->coins[i] += ch->coins[i]; ch->coins[i] = 0; } } sprintf (bunl, "You drop your coins.\n\r"); send_to_char (bunl, ch); found = TRUE; } } for (obj = ch->carrying; obj != NULL; obj = obj_next) { if (!obj->next_content) obj_next = NULL; else obj_next = obj->next_content; if ((arg[3] == '\0' || is_name (&arg[4], obj->pIndexData->name)) && can_see_obj (ch, obj) && (obj->wear_loc == WEAR_NONE) && can_drop_obj (ch, obj)) { found = TRUE; if (IS_PLAYER(ch) && !opp_align) { act ("$n drops $p\x1B[37;0m.", ch, obj, NULL, TO_ROOM); act ("You drop $p\x1B[37;0m.", ch, obj, NULL, TO_CHAR); } obj_from (obj); if (ch->in_room->sector_type == SECT_WATER_SWIM || ch->in_room->sector_type == SECT_WATER_NOSWIM) { act ("The waters cause $p to sink beneath them; lost forever.", ch, obj, NULL, TO_CHAR); free_it (obj); } else { if (IS_OBJ_STAT(obj, ITEM_DROPSCRIPT)) { again_10: /* Dropped item, check for triggers on object! */ { SINGLE_TRIGGER *tr; SCRIPT_INFO *s; for (tr = trigger_list[TDROPPED]; tr != NULL; tr = tr->next) { if (obj->pIndexData->vnum == tr->attached_to_obj) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_10; } { char tmp[50]; sprintf(tmp,"%d",ch->in_room->vnum); if (tr->keywords[0] != '\0' && !one_is_in_list_two (tmp, tr->keywords)) continue; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->obj = obj; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ } } } } /* End trigger check! */ if (IS_SET(ch->in_room->room_flags, ROOM_DROPSCRIPT)) { again_11: /* Dropped item, check for triggers on room! */ { SINGLE_TRIGGER *tr; SCRIPT_INFO *s; for (tr = trigger_list[TDROPPED]; tr != NULL; tr = tr->next) { if (ch->in_room->vnum == tr->attached_to_room) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_11; } { char tmp[50]; sprintf(tmp,"%d",obj->pIndexData->vnum); if (tr->keywords[0] != '\0' && !one_is_in_list_two (tmp, tr->keywords)) continue; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->room = ch->in_room; s->obj = obj; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ } } } } /* End trigger check! */ obj_to (obj, ch->in_room); if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(ch)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) REMOVE_BIT(ch->act, PLR_HAS_BOAT); } } } } if (!found) { if (arg[3] == '\0') act ("You are not carrying anything.", ch, NULL, arg, TO_CHAR); else act ("You are not carrying $T.", ch, NULL, &arg[4], TO_CHAR); } else if (IS_PLAYER(ch) && opp_align) { act("$n drops some stuff.", ch, NULL, NULL, TO_ROOM); act("You drop some stuff.", ch, NULL, NULL, TO_CHAR); } } return; } void do_give (CHAR_DATA * ch, char *argy) { char arg1[SML_LENGTH]; char arg2[SML_LENGTH]; char arg3[SML_LENGTH]; CHAR_DATA *victim; SINGLE_OBJECT *obj; int amount; char buf[STD_LENGTH]; DEFINE_COMMAND ("give", do_give, POSITION_RESTING, 0, LOG_NORMAL, "This command allows you to give something to someone.") if (FIGHTING (ch) && !pow.give_while_fighting) { send_to_char ("You may not give objects while fighting!\n\r", ch); return; } CAN_GIVE_ITEMS_IN_ARENA (no) CAN_GIVE_ITEMS_IN_BGROUND (no) argy = one_argy (argy, arg1); argy = one_argy (argy, arg2); argy = one_argy (argy, arg3); if (arg1[0] == '\0' || arg2[0] == '\0') { send_to_char ("Give what to whom?\n\r", ch); return; } if (is_number(arg1) && atoi(arg1) > 0) { int i; for (i = 0; i < MAX_COINS; i++) { if (!str_cmp(arg2, coin_name[i])) { amount = atoi(arg1); if (ch->coins[i] < amount) { sprintf(buf, "You don't have that many %s coins.\n\r", coin_color[i]); send_to_char(buf, ch); return; } if ((victim = get_char_room (ch, arg3)) == NULL) { send_to_char ("You don't see them here.\n\r", ch); return; } if (victim == ch) return; ch->coins[i] -= amount; victim->coins[i] += amount; sprintf (buf, "You give %d %s %s to %s.\n\r", amount, coin_color[i], (amount > 1 ? "coins" : "coin"), NAME (victim)); send_to_char (buf, ch); sprintf(buf, "$n gives %s %s %s to $N.", (amount > 1 ? "some" : "one"), coin_color[i], (amount > 1 ? "coins" : "coin")); act (buf, ch, NULL, victim, TO_NOTVICT); sprintf (buf, "%s gives you %d %s %s.\n\r", NAME (ch), amount, coin_color[i], (amount > 1 ? "coins" : "coin")); send_to_char (buf, victim); return; } } } if ((victim = get_char_room (ch, arg2)) == NULL) { send_to_char ("They aren't here.\n\r", ch); return; } if ((obj = get_obj_inv (ch, arg1)) == NULL) { send_to_char ("You do not have that item.\n\r", ch); return; } if (!NOT_WORN (obj)) { send_to_char ("You must remove it first.\n\r", ch); return; } if ((victim = get_char_room (ch, arg2)) == NULL) { send_to_char ("They aren't here.\n\r", ch); return; } if (!can_drop_obj (ch, obj)) { send_to_char ("You can't let go of it.\n\r", ch); return; } if (!can_see_obj (victim, obj)) { act ("$N can't see it.", ch, NULL, victim, TO_CHAR); return; } obj_from (obj); obj_to (obj, victim); if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(ch)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) REMOVE_BIT(ch->act, PLR_HAS_BOAT); } if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(victim)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) REMOVE_BIT(victim->act, PLR_HAS_BOAT); } obj->wear_loc = -1; if (IS_SET (obj->extra_flags, ITEM_INVENTORY)) obj->extra_flags ^= ITEM_INVENTORY; act ("$n gives $p\x1B[0m to $N.", ch, obj, victim, TO_NOTVICT); act ("$n gives you $p\x1B[0m.", ch, obj, victim, TO_VICT); act ("You give $p\x1B[0m to $N.", ch, obj, victim, TO_CHAR); if (IS_OBJ_STAT(obj, ITEM_GIVESCRIPT)) { again_12: /* Given item, check for triggers on mobbie! */ if (IS_MOB (victim)) { SINGLE_TRIGGER *tr; SCRIPT_INFO *s; for (tr = trigger_list[TGIVEN]; tr != NULL; tr = tr->next) { if (victim->pIndexData->vnum == tr->attached_to_mob) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_12; } {char tmp[50]; sprintf(tmp,"%d",obj->pIndexData->vnum); if (tr->keywords[0] != '\0' && !one_is_in_list_two (tmp, tr->keywords)) continue; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->mob = victim; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ } } /* End trigger check! */ again_13: { SINGLE_TRIGGER *tr; SCRIPT_INFO *s; for (tr = trigger_list[TGIVEN]; tr != NULL; tr = tr->next) { if (obj->pIndexData->vnum == tr->attached_to_obj) { if (tr->running_info && !tr->interrupted) continue; /* Already running, interrupted, but script says not to allow interruptions. */ if (tr->running_info && tr->interrupted != 2) { end_script (tr->running_info); goto again_13; } {char tmp[50]; sprintf(tmp,"%d",victim->pIndexData->vnum); if (tr->keywords[0] != '\0' && !one_is_in_list_two (tmp , tr->keywords)) continue; } /* ----------------- */ /* Start the script! */ /* ----------------- */ tr->running_info = mem_alloc (sizeof (*tr->running_info)); s = tr->running_info; bzero (s, sizeof (*s)); s->current = ch; s->obj = obj; s->mob = victim; strcpy (s->code_seg, tr->code_label); s->current_line = 0; s->called_by = tr; s->next = info_list; info_list = s; execute_code (s); /* ----------------- */ } } } } } /* End trigger check! */ return; } void do_fill (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; SINGLE_OBJECT *fountain; I_DRINK *dr; bool found; DEFINE_COMMAND ("fill", do_fill, POSITION_STANDING, 0, LOG_NORMAL, "This command allows you to fill a container or lamp.") argy = one_argy (argy, arg); if (arg[0] == '\0') { send_to_char ("Fill what?\n\r", ch); return; } /*held */ if ((obj = get_obj_inv (ch, arg)) == NULL) { send_to_char ("You do not have that item.\n\r", ch); return; } if (obj->pIndexData->item_type == ITEM_DRINK_CON) { found = FALSE; dr = (I_DRINK *) obj->more; for (fountain = ch->in_room->contents; fountain != NULL; fountain = fountain->next_content) { if (fountain->pIndexData->item_type == ITEM_FOUNTAIN) { found = TRUE; break; } } if (!found) { send_to_char ("There is no fountain here!\n\r", ch); return; } if (dr->liquid_now != 0 && dr->liquid_type != 0) { send_to_char ("It already has some other liquid in it.\n\r", ch); return; } if (IS_SET(dr->not_poison, 1)) { send_to_char("That container cannot be refilled.\n\r", ch); return; } if (dr->liquid_now >= dr->max_liquid) { send_to_char ("The container is full.\n\r", ch); return; } act ("You fill $p\x1B[0m.", ch, obj, NULL, TO_CHAR); dr->liquid_type = 0; dr->liquid_now = dr->max_liquid; } else if (obj->pIndexData->item_type == ITEM_LIGHT) { SINGLE_OBJECT *obj2; I_LIGHT *lg = (I_LIGHT *) obj->more; I_DRINK *dr; /*get_ITEM_WIELD */ if ((obj2 = get_item_held (ch, ITEM_DRINK_CON)) == NULL) { send_to_char ("You don't have anything in your hand to fill it with.\n\r", ch); return; } dr = (I_DRINK *) obj2->more; if (!IS_SET (lg->light_lit, LIGHT_FILLABLE) && !IS_SET (lg->light_fillable, LIGHT_FILLABLE)) { send_to_char ("It can't be refueled.\n\r", ch); return; } if (dr->liquid_type != -1) { send_to_char ("There's no oil in that container.\n\r", ch); return; } if (lg->light_now != 0) { send_to_char ("There is already some oil in it.\n\r", ch); return; } CAN_FILL_LIGHT_WHILE_LIT (yes); if (dr->liquid_now < 1) { send_to_char ("There is no liquid left to fill it with.\n\r", ch); return; } if (dr->liquid_now >= lg->max_light) { act ("You fill $p\x1B[0m with $P\x1B[0m.", ch, obj, obj2, TO_CHAR); lg->light_now = lg->max_light; dr->liquid_now += -(lg->max_light); } else { act ("You empty $P\x1B[0m into $p\x1B[0m.", ch, obj, obj2, TO_CHAR); lg->light_now = lg->max_light; dr->liquid_now = 0; } } else { send_to_char ("You can't fill that.\n\r", ch); return; } return; } void do_empty (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; DEFINE_COMMAND ("empty", do_empty, POSITION_RESTING, 0, LOG_NORMAL, "This command allows you to empty a container of liquid.") argy = one_argy (argy, arg); if (arg[0] == '\0') { send_to_char ("Empty what?\n\r", ch); return; } /*held */ if ((obj = get_obj_inv (ch, arg)) == NULL) { send_to_char ("You do not have that item.\n\r", ch); return; } if (obj->pIndexData->item_type == ITEM_DRINK_CON) { I_DRINK *dr = (I_DRINK *) obj->more; if (dr->liquid_now < 1) { send_to_char ("Your container is empty.\n\r", ch); return; } act ("You empty $p\x1B[0m.", ch, obj, NULL, TO_CHAR); dr->liquid_type = 0; dr->liquid_now = 0; } return; } void do_drink (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; int amount; bool thirsty; int liquid; DEFINE_COMMAND ("drink", do_drink, POSITION_RESTING, 0, LOG_NORMAL, "This command allows you to drink from something.") while (argy != "" && argy[0] != '\0') argy = one_argy (argy, arg); if (arg[0] == '\0') { for (obj = ch->in_room->contents; obj; obj = obj->next_content) { if (obj->pIndexData->item_type == ITEM_FOUNTAIN) break; } if (obj == NULL) { send_to_char ("Drink what?\n\r", ch); return; } } else { if ((obj = get_obj_here (ch, arg, SEARCH_ROOM_FIRST)) == NULL) { send_to_char ("You can't find it.\n\r", ch); return; } } if (IS_PLAYER (ch) && ch->pcdata->condition[COND_DRUNK] > 10) { send_to_char ("You are too drunk, dazed, and confused to drink any more.\n\r", ch); return; } if (IS_PLAYER (ch) && ch->pcdata->condition[COND_THIRST] < 7) thirsty = TRUE; else thirsty = FALSE; if (IS_PLAYER (ch) && ch->pcdata->condition[COND_THIRST] > 40) { send_to_char ("If you drank any more, your bladder would explode.\n\r", ch); return; } switch (obj->pIndexData->item_type) { default: send_to_char ("You can't drink from that.\n\r", ch); break; case ITEM_FOUNTAIN: { I_FOUNTAIN *fn = (I_FOUNTAIN *) obj->more; if (IS_PLAYER (ch)) ch->pcdata->condition[COND_THIRST] = 48; act ("$n drinks from $p\x1B[0m.", ch, obj, NULL, TO_ROOM); act ("You drink from $p\x1B[0m.", ch, obj, NULL, TO_CHAR); if (fn->spells[0] > 0) obj_cast_spell (fn->spells[0], fn->liquid, ch, ch, NULL); if (fn->spells[1] > 0) obj_cast_spell (fn->spells[1], fn->liquid, ch, ch, NULL); if (fn->spells[2] > 0) obj_cast_spell (fn->spells[2], fn->liquid, ch, ch, NULL); break; } case ITEM_DRINK_CON: { I_DRINK *dr = (I_DRINK *) obj->more; if (dr->liquid_now <= 0) { send_to_char ("It is empty.\n\r", ch); return; } if ((liquid = dr->liquid_type) >= LIQ_MAX) { bug ("Bad liquid number %d.", liquid); liquid = dr->liquid_type = 0; } if (liquid == -1) { act ("$n drinks lamp oil from $p\x1B[0m, and grimaces in pain.", ch, obj, NULL, TO_ROOM); act ("You drink oil from $p\x1B[0m. Ugh!", ch, obj, NULL, TO_CHAR); amount = 0; } else { act ("$n drinks $T\x1B[0m from $p\x1B[0m.", ch, obj, liq_table[liquid].liq_name, TO_ROOM); act ("You drink $T\x1B[0m from $p\x1B[0m.", ch, obj, liq_table[liquid].liq_name, TO_CHAR); amount = number_range (3, 10); amount = UMIN (amount, dr->liquid_now); gain_condition (ch, COND_DRUNK, amount * liq_table[liquid].liq_affect[COND_DRUNK]); gain_condition (ch, COND_FULL, amount * liq_table[liquid].liq_affect[COND_FULL]); gain_condition (ch, COND_THIRST, amount * liq_table[liquid].liq_affect[COND_THIRST]); if (IS_PLAYER (ch) && ch->pcdata->condition[COND_DRUNK] > 10) send_to_char ("You feel drunk.\n\r", ch); if (IS_PLAYER (ch) && ch->pcdata->condition[COND_FULL] > 40) send_to_char ("You are full.\n\r", ch); if (IS_PLAYER (ch) && ch->pcdata->condition[COND_THIRST] > 40) send_to_char ("You are no longer thirsty.\n\r", ch); if (dr->not_poison >= 2) { AFFECT_DATA af; bzero (&af, sizeof (af)); act ("$n's face pales.", ch, NULL, NULL, TO_ROOM); send_to_char ("Your intestines feel like they are on fire!\n\r", ch); af.type = gsn_poison; af.duration = 3 * amount; af.location = APPLY_NONE; af.modifier = 0; af.aff[HURT] = POISON; affect_join (ch, &af); } } dr->liquid_now -= amount; if (dr->liquid_now <= 0) { dr->not_poison = 0; dr->liquid_type = 0; } break; } } return; } void do_eat (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; DEFINE_COMMAND ("eat", do_eat, POSITION_RESTING, 0, LOG_NORMAL, "This command allows you to eat something.") argy = one_argy (argy, arg); if (!str_cmp (arg, "the") || !str_cmp (arg, "some")) argy = one_argy (argy, arg); if (arg[0] == '\0') { send_to_char ("Eat what?\n\r", ch); return; } if ((obj = get_obj_inv (ch, arg)) == NULL) { send_to_char ("You do not have that item.\n\r", ch); return; } if (!IS_IMMORTAL (ch)) { if (obj->pIndexData->item_type != ITEM_FOOD && obj->pIndexData->item_type != ITEM_PILL) { send_to_char ("That's not edible.\n\r", ch); return; } if (IS_PLAYER (ch) && ch->pcdata->condition[COND_FULL] > 40) { send_to_char ("You are too full to eat more.\n\r", ch); return; } } else { if (obj->pIndexData->item_type == ITEM_LIGHT && IS_LIT (obj)) --ch->in_room->light; if (obj->wear_loc != -1) remove_obj(ch, obj); } act ("$n eats $p\x1B[0m.", ch, obj, NULL, TO_ROOM); act ("You eat $p\x1B[0m.", ch, obj, NULL, TO_CHAR); switch (obj->pIndexData->item_type) { case ITEM_FOOD: { I_FOOD *fd = (I_FOOD *) obj->more; if (IS_PLAYER (ch)) { int conditiona; conditiona = ch->pcdata->condition[COND_FULL]; gain_condition (ch, COND_FULL, fd->hours); if (conditiona < 4 && ch->pcdata->condition[COND_FULL] > 4) send_to_char ("You feel a bit less hungry.\n\r", ch); else if (ch->pcdata->condition[COND_FULL] > 40) send_to_char ("You are full.\n\r", ch); } if (fd->not_poison != 0) { /* The shit was poisoned! */ AFFECT_DATA af; bzero (&af, sizeof (af)); act ("$n's face pales, and $e clutches $s stomach.", ch, 0, 0, TO_ROOM); send_to_char ("Ouch! You feel very sick!\n\r", ch); af.type = gsn_poison; af.duration = fd->hours / 2; af.location = APPLY_NONE; af.modifier = 0; af.aff[HURT] = POISON; affect_join (ch, &af); } break; } case ITEM_PILL: { I_POTION *pl = (I_POTION *) obj->more; if (pl->spells[0] > 0) obj_cast_spell (pl->spells[0], pl->spell_level, ch, ch, NULL); if (pl->spells[1] > 0) obj_cast_spell (pl->spells[1], pl->spell_level, ch, ch, NULL); if (pl->spells[2] > 0) obj_cast_spell (pl->spells[2], pl->spell_level, ch, ch, NULL); break; } } obj_from (obj); free_it (obj); return; } bool draw_obj (CHAR_DATA * ch, SINGLE_OBJECT * obj) { if (worn_flags[obj->wear_loc].flagname != ITEM_WEAR_BELT) return FALSE; if (hand_empty(ch) == WEAR_NONE) return FALSE; obj->wear_loc = -1; /* Yes, using 18 is bad but I dont feel like looking it up each time. */ equip_char (ch, obj, 19, hand_empty (ch)); act ("$n draws $p\x1B[0m from $s belt.", ch, obj, NULL, TO_ROOM); act ("You draw $p\x1B[0m from your belt.", ch, obj, NULL, TO_CHAR); return TRUE; } bool sheath_obj (CHAR_DATA * ch, SINGLE_OBJECT * obj) { /* We make code for only one belt and 2 items sheathed..if you want more you are insane... */ bool belt; SINGLE_OBJECT *objt; bool worn_in_belt[10]; int i; int slot = WEAR_NONE; for (i = 0; i < 10; i++) worn_in_belt[i] = FALSE; if (obj == NULL) return FALSE; if (!IS_SET (obj->pIndexData->wear_flags, ITEM_WEAR_BELT)) return FALSE; if (worn_flags[obj->wear_loc].flagname != ITEM_WIELD) { send_to_char("You must be wielding a weapon to sheath it.\n\r", ch); return FALSE; } if (IS_OBJ_STAT(obj, ITEM_POLEARM)) { send_to_char("You cannot sheath polearms.\n\r", ch); return FALSE; } for (objt = ch->carrying; objt != NULL; objt = objt->next_content) { if (worn_flags[objt->wear_loc].flagname == ITEM_WEAR_WAIST) belt = TRUE; if(worn_flags[obj->wear_loc].flagname == ITEM_WEAR_BELT) worn_in_belt[objt->wear_num] = TRUE; } if (!belt) { send_to_char("You must be wearing a belt to sheath stuff in.\n\r", ch); return FALSE; } slot = (!worn_in_belt[0] ? 0 : (!worn_in_belt[1] ? 1 : WEAR_NONE)); if (slot == -1) { send_to_char ("Remove something from your belt first.\n\r", ch); return FALSE; } unequip_char(ch, obj); obj->wear_loc = 19; obj->wear_num = slot; act ("$n sheaths $p\x1B[0m in $s belt.", ch, obj, NULL, TO_ROOM); act ("You sheath $p\x1B[0m in your belt.", ch, obj, NULL, TO_CHAR); return TRUE; } bool remove_obj (CHAR_DATA * ch, SINGLE_OBJECT *obj) { if (obj == NULL) return FALSE; if (obj->wear_loc == WEAR_NONE) return FALSE; if (IS_SET (obj->extra_flags, ITEM_NOREMOVE) && !IS_IMMORTAL (ch) && obj->pIndexData->item_type != ITEM_FOOD) { act ("You can't remove $p\x1B[0m.", ch, obj, NULL, TO_CHAR); return FALSE; } if (worn_flags[obj->wear_loc].flagname == ITEM_WEAR_WAIST) { SINGLE_OBJECT *obj2; for (obj2 = ch->carrying; obj2 != NULL; obj2 = obj2->next_content) { if (worn_flags[obj2->wear_loc].flagname == ITEM_WEAR_BELT) unequip_char(ch, obj2); } } if (unequip_char (ch, obj)) { act ("$n stops using $p\x1B[0m.", ch, obj, NULL, TO_ROOM); act ("You stop using $p\x1B[0m.", ch, obj, NULL, TO_CHAR); } else { send_to_char ("You've got your hands full.\n\r", ch); return FALSE; } return TRUE; } void wear_obj (CHAR_DATA * ch, SINGLE_OBJECT * obj, bool fReplace) { SINGLE_OBJECT *objt = NULL; bool worn_already[20]; /* This should be enough for num_worn..if not just up it. Easier than allocating in the middle... would require an extra { } to do it. */ int loc; int wear_spot; int i; int num_worn; int slot; char buf[200]; int polerange = 0; int shields = 0; int num_weapons = 0; int num_held = 0; if (IS_MOB (ch) && ch->pIndexData->pShop != NULL) return; for (i = 0; i < 20; i++) worn_already[i] = FALSE; /* We first get the location we are going to try to put the item on. */ for (i = 1; worn_flags[i].part_of_body >= 0; i++) { if (IS_SET(obj->pIndexData->wear_flags, worn_flags[i].flagname)) { loc = i; wear_spot = i; break; } } if (worn_flags[i].part_of_body < 0) return; /* Get the number of possible slots we have to look at. */ num_worn = (IS_MOB(ch) ? 1 : race_info[ch->pcdata->race].parts[worn_flags[i].part_of_body]) * worn_flags[i].num_slots; if (num_worn == 0) return; /* Now we go down the character list and see if those slots are all taken up or not. */ for (objt = ch->carrying; objt != NULL; objt = objt->next_content) { if (objt->wear_loc == loc) { if (objt->wear_num < 20) worn_already[objt->wear_num] = TRUE; } if (loc < 0 || loc >= MAX_WEAR) loc = 0; if (worn_flags[loc].flagname ==ITEM_WIELD) { if (worn_flags[objt->wear_loc].flagname == ITEM_WEAR_SHIELD) shields++; } } /* Then we look for an empty slot... */ slot = WEAR_NONE; for (i = 0; i < num_worn; i++) { if (!worn_already[i] && slot == WEAR_NONE) { slot = i; break; } } /* If there is an empty slot, slot > WEAR_NONE and we skip all this trying to remove stuff. If we are not supposed to replace the item, we just return (like in "wear all"). Otherwise, we go down the list of item the character has and see if any of them are of the correct wear_loc. If it is, we attempt to remove it. If we can remove it, we then put the new item in that place. */ if (loc < 0 || loc >= MAX_WEAR) loc = 0; if (slot == WEAR_NONE) { if (!fReplace) return; else { for (objt = ch->carrying; objt != NULL; objt = objt->next_content) { if (objt->wear_loc == loc && objt->wear_num < num_worn) { if (IS_SET(objt->extra_flags, ITEM_NOREMOVE) && LEVEL(ch) < IMM_LEVEL) continue; if (worn_flags[loc].flagname == ITEM_WEAR_WAIST) /* If we remove the belt, all sheathed items fall out of it. */ { SINGLE_OBJECT *sheathed; for (sheathed = ch->carrying; sheathed != NULL; sheathed = sheathed->next_content) { if (worn_flags[sheathed->wear_loc].flagname == ITEM_WEAR_BELT) { obj_from (sheathed); if (ch->in_room) obj_to(sheathed, ch->in_room); } } } slot = objt->wear_num; unequip_char(ch, objt); act ("$n stops using $p\x1B[0m.", ch, objt, NULL, TO_ROOM); act ("You stop using $p\x1B[0m.", ch, objt, NULL, TO_CHAR); break; } } } /* If we have no open slots and cannot remove anything to make room, we say sowwie and just return giving a message that too much is being worn. */ if (slot == -1) { sprintf(buf, "You already have too many things %s.\n\r", worn_flags[wear_spot].how_it_appears); send_to_char(buf, ch); return; } } if (loc < 0 || loc >= MAX_WEAR) loc = 0; if (worn_flags[loc].flagname ==ITEM_WIELD) { for (i = 0; i < num_worn; i++) { if (ch->hold[i]) { num_held++; if(ch->hold[i]->pIndexData->item_type == ITEM_WEAPON) { num_weapons++; if (IS_OBJ_STAT(ch->hold[i], ITEM_POLEARM)) polerange++; } if (ch->hold[i]->pIndexData->item_type == ITEM_MISSILE) { num_weapons++; polerange++; } } } /* Now we make each polearm or ranged wpn cost two wpn and held slots... */ num_weapons += polerange; num_held += polerange; /* If the new wpn is a polearm we make it need another slot by making a prev slot filled. */ if (IS_OBJ_STAT(obj, ITEM_POLEARM) || obj->pIndexData->item_type == ITEM_MISSILE) { num_weapons++; num_held ++; } if(obj->pIndexData->item_type == ITEM_WEAPON) { if (shields + num_weapons >= num_worn) { /* You have a shield in each pair of arms and a wpn in each pair of arms...at most. */ send_to_char("You are limited to your number of arms in shields and weapons.\n\r", ch); return; } /* We now add the extra wpn and held slot the new wpn takes up. */ num_weapons++; num_held++; if (num_held > num_worn || num_weapons > num_worn) { send_to_char("You cannot wield so much stuff. Each polearm or ranged weapon takes up two slots, and each shield worn means you can only wear one weapon on that pair of arms.\n\r", ch); return; } } } /* Now at this point we have a wear_loc, we have a number slot which will be wear_num and then we put the item on and give a message. */ sprintf(buf, "You wear $p\x1b[0;37m %s.", worn_flags[wear_spot].how_it_appears); act (buf, ch, obj, NULL, TO_CHAR); if (loc < 0 || loc >= MAX_WEAR) loc = 0; if (worn_flags[loc].flagname == ITEM_WIELD) act ("$n wields $p\x1b[0;37m.", ch, obj, NULL, TO_ROOM); else if (worn_flags[loc].flagname == ITEM_FLOATING) act ("$p\x1b[0;37m starts floating about $n's head.", ch, obj, NULL, TO_ROOM); else if (worn_flags[loc].flagname == ITEM_WEAR_ABOUT) { act("$n wears $p\x1b[0;37m about $s body.", ch, obj, NULL, TO_ROOM); } else { sprintf(buf, "$n wears $p\x1B[0;37m on $s %s.",worn_flags[loc].what_you_type); act (buf, ch, obj, NULL, TO_ROOM); } equip_char(ch, obj, loc, slot); return; } void do_swap (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("swap", do_exchange, POSITION_RESTING, 0, LOG_NORMAL, "This command exchanges what you have in your primary and secondary hand.") return; } void do_exchange (CHAR_DATA * ch, char *argy) { SINGLE_OBJECT *objh1; SINGLE_OBJECT *objh2; char arg1[SML_LENGTH]; int hand; bool hone; bool htwo; DEFINE_COMMAND ("exchange", do_exchange, POSITION_FIGHTING, 0, LOG_NORMAL, "This command exchanges what you have in your primary and secondary hand.") one_argy(argy, arg1); hand = atoi(arg1); hand--; if (hand < 0 || hand > (IS_MOB(ch) ? 1 : race_info[ch->pcdata->race].parts[3])) hand = 0; hone = FALSE; htwo = FALSE; if ((objh1 = ch->hold[2*(hand)]) != NULL) hone = TRUE; if ((objh2 = ch->hold[2*hand+1]) != NULL) htwo = TRUE; if ((!hone) && (!htwo)) { act ("You aren't holding anything in your hands!", ch, NULL, NULL, TO_CHAR); return; } if ((!hone) && (htwo)) { objh2->wear_num = 2*hand; act ("The object in your secondary hand is now in your primary hand.", ch, NULL, NULL, TO_CHAR); ch->hold[2*hand+1] = NULL; ch->hold[2*hand] = objh2; return; } if ((hone) && (!htwo)) { objh1->wear_num = 2*hand+1; act ("The object in your primary hand is now in your secondary hand.", ch, NULL, NULL, TO_CHAR); ch->hold[2*hand] = NULL; ch->hold[2*hand+1] = objh1; return; } if ((hone) && (htwo)) { objh1->wear_num = 2*hand+1; objh2->wear_num = 2*hand; act ("You now hold $p\x1B[0m in your primary hand.", ch, objh2, NULL, TO_CHAR); act ("You now hold $p\x1B[0m in your secondary hand.", ch, objh1, NULL, TO_CHAR); ch->hold[2*hand] = objh2; ch->hold[2*hand+1] = objh1; return; } return; } void do_wield (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("wield", do_wear, POSITION_STANDING, 0, LOG_NORMAL, "Allows you to wear/wield or hold an object.") return; } void do_hold (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("hold", do_wear, POSITION_STANDING, 0, LOG_NORMAL, "Allows you to wear/wield or hold an object.") return; } void do_wear (CHAR_DATA * ch, char *argy) { char arg1[SML_LENGTH]; char arg2[SML_LENGTH]; SINGLE_OBJECT *obj; DEFINE_COMMAND ("wear", do_wear, POSITION_FIGHTING, 0, LOG_NORMAL, "Allows you to wear/wield or hold an object.") argy = one_argy (argy, arg1); one_argy (argy, arg2); if (arg1[0] == '\0') { send_to_char ("Please specify what you want to wear/wield/hold.\n\r", ch); return; } if (!str_cmp (arg1, "all")) { SINGLE_OBJECT *obj_next; if (FIGHTING (ch) != NULL && !pow.equip_in_combat) { send_to_char ("Not while you're fighting; you'd get creamed!\n\r", ch); return; } for (obj = ch->carrying; obj != NULL; obj = obj_next) { obj_next = obj->next_content; if ((CAN_WEAR (obj, ITEM_WIELD))) if (hand_empty (ch) == WEAR_NONE) continue; if (obj->wear_loc == WEAR_NONE && can_see_obj (ch, obj)) wear_obj (ch, obj, FALSE); } return; } else { if ((obj = get_obj_inv (ch, arg1)) == NULL) { send_to_char ("You do not have that item.\n\r", ch); return; } if ((CAN_WEAR (obj, ITEM_WIELD))) if (hand_empty (ch) == WEAR_NONE) { send_to_char ("Your hands are already full!\n\r", ch); return; } if (FIGHTING (ch) != NULL && !pow.equip_in_combat && !CAN_WEAR (obj, ITEM_WIELD)) { send_to_char ("Not while you're fighting; you'd get creamed!\n\r", ch); return; } if (obj->wear_loc == -1) { wear_obj (ch, obj, TRUE); } } return; } void do_sheath (CHAR_DATA * ch, char *argy) { char arg1[STD_LENGTH]; SINGLE_OBJECT *obj; DEFINE_COMMAND ("sheath", do_sheath, POSITION_STANDING, 0, LOG_NORMAL, "Allows you to sheath a weapon in your belt.") argy = one_argy (argy, arg1); if ((obj = get_obj_inv (ch, arg1)) == NULL) { if ((obj = get_item_held (ch, ITEM_WEAPON)) != NULL) sheath_obj (ch, obj); return; } if (!sheath_obj(ch, obj)) send_to_char("You can't sheath that!\n\r", ch); return; } void do_draw (CHAR_DATA * ch, char *argy) { char arg1[STD_LENGTH]; SINGLE_OBJECT *obj; SINGLE_OBJECT *obj1; int i; bool hand_free = FALSE; int wields = 0; int shields = 0; int polearms = 0; /* Get the numbers of pairs of arms. */ int num_arms; DEFINE_COMMAND ("draw", do_draw, POSITION_FIGHTING, 0, LOG_NORMAL, "Allows you to draw a weapon from your belt.") num_arms = (IS_MOB(ch) ? 1 : race_info[ch->pcdata->race].parts[3]); if (num_arms == 0) return; if ((obj = get_obj_wear (ch, arg1)) == NULL) { send_to_char ("You do not have that item in your belt.\n\r", ch); return; } for (i = 0; i < 2*num_arms; i++) { if (ch->hold[i] == FALSE) { hand_free = TRUE; break; } } if (!hand_free) { send_to_char("You don't have any hands free.\n\r", ch); return; } for (obj1 = ch->carrying; obj1 != NULL; obj1 = obj1->next_content) { if (worn_flags[obj1->wear_loc].flagname == ITEM_WEAR_SHIELD) shields++; if (worn_flags[obj1->wear_loc].flagname == ITEM_WIELD) { if (obj->pIndexData->item_type == ITEM_WEAPON) { wields++; if(IS_OBJ_STAT(obj, ITEM_POLEARM)) polearms++; } if (obj->pIndexData->item_type == ITEM_MISSILE) { wields++; polearms++; } } } if (polearms >= num_arms) { send_to_char("You cannot draw a weapon while wielding a polearm or ranged weapon.\n\r", ch); return; } if (wields >= 2*num_arms) { send_to_char("Your hands are full!\n\r", ch); return; } if (shields >= num_arms && wields > (2*num_arms -2)) { send_to_char("You cannot while you are using a shield with so many weapons.\n\r", ch); return; } if (!draw_obj (ch, obj)) send_to_char ("You can't do that!\n\r", ch); return; } void do_remove (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; DEFINE_COMMAND ("remove", do_remove, POSITION_FIGHTING, 0, LOG_NORMAL, "This command allows you to remove a weapon/armor/etc... that is worn.") one_argy (argy, arg); if (arg[0] == '\0') { send_to_char ("Remove what?\n\r", ch); return; } if (!str_cmp (argy, "all")) { SINGLE_OBJECT *obj_next; if (!pow.remove_while_fighting && FIGHTING (ch)) { send_to_char ("No way; you'd get creamed!\n\r", ch); return; } for (obj = ch->carrying; obj != NULL; obj = obj_next) { obj_next = obj->next_content; if (obj->wear_loc != WEAR_NONE) remove_obj (ch, obj); } if (ch->move > ch->max_move) ch->move = ch->max_move; return; } if ((obj = get_obj_wear (ch, arg)) == NULL) { send_to_char ("You do not have that item.\n\r", ch); return; } if (!pow.remove_while_fighting && worn_flags[obj->wear_loc].flagname != ITEM_WIELD && FIGHTING (ch)) { send_to_char ("No way; you'd get creamed!\n\r", ch); return; } if (obj->wear_loc != -1) { remove_obj (ch, obj); } if (ch->move > ch->max_move) MAXMOVE(ch); if (ch->hit > ch->max_hit) ch->hit = ch->max_hit; return; } void do_bury (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("bury", do_sacrifice, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to sacrifice something to the gods... helps clean up the game.") return; } void do_sacrifice (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; const char *god; int n_god; char buf[STD_LENGTH]; DEFINE_COMMAND ("sacrifice", do_sacrifice, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to sacrifice something to the gods... helps clean up the game.") if (argy == "" || argy[0] == '\0') return; one_argy (argy, arg); if (arg[0] == '\0' || !str_cmp (arg, NAME (ch))) { act ("$n offers $mself to the gods, who decline.", ch, NULL, NULL, TO_ROOM); send_to_char ( "The gods appreciate your self-sacrifice, but refuse.\n\r", ch); return; } obj = get_obj_list (ch, arg, ch->in_room->contents); if (obj == NULL) { if (get_obj_inv (ch, arg) != NULL) { send_to_char ("The object must be lying on the ground in order to sacrifice it.\n\r", ch); return; } send_to_char ("You don't see that object here to sacrifice.\n\r", ch); return; } if (!CAN_WEAR (obj, ITEM_TAKE)) { act ("$p\x1B[0m is not a sacrificable object.", ch, obj, 0, TO_CHAR); return; } n_god = number_range (0, 4); god = pow.god_names[n_god]; sprintf (buf, "$n sacrifices $p\x1B[0m to \x1B[1m%s\x1B[0m.", god); act (buf, ch, obj, NULL, TO_ROOM); sprintf (buf, "You sacrifice $p\x1B[0m to \x1B[1m%s\x1B[0m.", god); act (buf, ch, obj, NULL, TO_CHAR); if (LEVEL (ch) < 9 && obj->pIndexData->item_type == ITEM_CORPSE_NPC) { send_to_char ("You recieve a copper coin as a gift from the gods for this sacrifice!\n\r", ch); ch->coins[0]++; } if (obj->carried_by != NULL) obj_from (obj); free_it (obj); return; } void do_quaff (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; I_POTION *pt; DEFINE_COMMAND ("quaff", do_quaff, POSITION_FIGHTING, 0, LOG_NORMAL, "Allows you to quaff a potion.") one_argy (argy, arg); if (arg[0] == '\0') { send_to_char ("Quaff what?\n\r", ch); return; } if ((obj = get_obj_inv (ch, arg)) == NULL) { send_to_char ("You do not have that potion.\n\r", ch); return; } if (obj->pIndexData->item_type != ITEM_POTION) { send_to_char ("You can quaff only potions.\n\r", ch); return; } pt = (I_POTION *) obj->more; act ("$n quaffs $p\x1B[0m.", ch, obj, NULL, TO_ROOM); act ("You quaff $p\x1B[0m.", ch, obj, NULL, TO_CHAR); if (pt->spells[0] > 0) obj_cast_spell (pt->spells[0], pt->spell_level, ch, ch, NULL); if (pt->spells[1] > 0) obj_cast_spell (pt->spells[1], pt->spell_level, ch, ch, NULL); if (pt->spells[2] > 0) obj_cast_spell (pt->spells[2], pt->spell_level, ch, ch, NULL); obj_from (obj); free_it (obj); return; } void do_read (CHAR_DATA * ch, char *argy) { DEFINE_COMMAND ("read", do_look, POSITION_RESTING, 0, LOG_NORMAL, "Same as look.") return; } void do_recite (CHAR_DATA * ch, char *argy) { char arg1[SML_LENGTH]; char arg2[SML_LENGTH]; CHAR_DATA *victim; I_POTION *sc; SINGLE_OBJECT *scroll; SINGLE_OBJECT *obj; DEFINE_COMMAND ("recite", do_recite, POSITION_FIGHTING, 0, LOG_NORMAL, "Allows you to recite a scroll.") argy = one_argy (argy, arg1); argy = one_argy (argy, arg2); if ((scroll = get_obj_inv (ch, arg1)) == NULL) { send_to_char ("You do not have that scroll.\n\r", ch); return; } if (scroll->pIndexData->item_type != ITEM_SCROLL) { send_to_char ("You can recite only scrolls.\n\r", ch); return; } sc = (I_POTION *) scroll->more; obj = NULL; if (arg2[0] == '\0') { victim = ch; } else { if ((victim = get_char_room (ch, arg2)) == NULL && (obj = get_obj_here (ch, arg2, SEARCH_INV_FIRST)) == NULL) { send_to_char ("You can't find it.\n\r", ch); return; } } act ("$n recites $p\x1B[0m.", ch, scroll, NULL, TO_ROOM); act ("You recite $p\x1B[0m.", ch, scroll, NULL, TO_CHAR); if (sc->spells[0] > 0) obj_cast_spell (sc->spells[0], sc->spell_level, ch, victim, obj); if (sc->spells[1] > 0) obj_cast_spell (sc->spells[1], sc->spell_level, ch, victim, obj); if (sc->spells[2] > 0) obj_cast_spell (sc->spells[2], sc->spell_level, ch, victim, obj); free_it (scroll); return; } void do_brandish (CHAR_DATA * ch, char *argy) { CHAR_DATA *vch; CHAR_DATA *vch_next; SINGLE_OBJECT *staff; SPELL_DATA *spell; I_WAND *stf; DEFINE_COMMAND ("brandish", do_brandish, POSITION_FIGHTING, 0, LOG_NORMAL, "Allows you to brandish a staff.") if ((staff = get_item_held (ch, ITEM_STAFF)) == NULL) { send_to_char ("You don't have the staff in your hand.\n\r", ch); return; } stf = (I_WAND *) staff->more; if ((spell = skill_lookup (NULL, stf->spells[0])) == NULL) { bug ("Do_brandish: bad sn %d.", 9999); return; } WAIT_STATE (ch, 2 * PULSE_VIOLENCE); if (stf->current_charges > 0) { act ("$n raises $p\x1B[0m into the air and utters some mystical words under $s breath.", ch, staff, NULL, TO_ROOM); act ("You brandish $p\x1B[0m.", ch, staff, NULL, TO_CHAR); for (vch = ch->in_room->people; vch; vch = vch_next) { vch_next = vch->next_in_room; switch (spell->spell_type) { default: bug ("Do_brandish: bad target for sn %d.", spell->gsn); return; case TAR_IGNORE: if (vch != ch) continue; break; case TAR_CHAR_OFFENSIVE: if (IS_MOB (ch) ? IS_MOB (vch) : IS_PLAYER (vch)) continue; break; case TAR_CHAR_DEFENSIVE: if (IS_MOB (ch) ? IS_PLAYER (vch) : IS_MOB (vch)) continue; break; case TAR_CHAR_SELF: if (vch != ch) continue; break; } if (stf->spells[0] > 0) obj_cast_spell (stf->spells[0], stf->spell_level, ch, vch, NULL); } } if (--stf->current_charges <= 0) { act ("$n's $p\x1B[0m blazes bright and is gone.", ch, staff, NULL, TO_ROOM); act ("Your $p\x1B[0m blazes bright and is gone.", ch, staff, NULL, TO_CHAR); free_it (staff); } return; } void do_zap (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; CHAR_DATA *victim; SINGLE_OBJECT *wand; SINGLE_OBJECT *obj; SPELL_DATA *spell; I_WAND *wnd; DEFINE_COMMAND ("zap", do_zap, POSITION_FIGHTING, 0, LOG_NORMAL, "Allows you to zap a wand.") one_argy (argy, arg); if (arg[0] == '\0' && FIGHTING (ch) == NULL) { send_to_char ("Zap whom or what?\n\r", ch); return; } if ((wand = get_item_held (ch, ITEM_WAND)) == NULL) { send_to_char ("You don't have a wand in your hand.\n\r", ch); return; } wnd = (I_WAND *) wand->more; if ((spell = skill_lookup (NULL, wnd->spells[0])) == NULL) { bug ("Do_zap: bad sn %d.", 0); return; } obj = NULL; if (arg[0] == '\0') { if (FIGHTING (ch) != NULL) { victim = FIGHTING (ch); } else { send_to_char ("Zap whom or what?\n\r", ch); return; } } else { if ((victim = get_char_room (ch, arg)) == NULL && (obj = get_obj_here (ch, arg, SEARCH_INV_FIRST)) == NULL) { send_to_char ("You can't find it.\n\r", ch); return; } } WAIT_STATE (ch, 2 * PULSE_VIOLENCE); if (wnd->current_charges > 0) { if (victim != NULL) { act ("$n zaps $N with $p\x1B[0m.", ch, wand, victim, TO_ROOM); act ("You zap $N with $p\x1B[0m.", ch, wand, victim, TO_CHAR); } else { act ("$n zaps $P with $p\x1B[0m.", ch, wand, obj, TO_ROOM); act ("You zap $P with $p\x1B[0m.", ch, wand, obj, TO_CHAR); } if (wnd->spells[0] > 0) obj_cast_spell (wnd->spells[0], wnd->spell_level, ch, victim, obj); } if (--wnd->current_charges <= 0) { act ("$n's $p\x1B[0m explodes into fragments.", ch, wand, NULL, TO_ROOM); act ("Your $p\x1B[0m explodes into fragments.", ch, wand, NULL, TO_CHAR); free_it (wand); } return; } void do_study (CHAR_DATA * ch, char *argy) { SINGLE_OBJECT *obj; SPELL_DATA *spell; I_BOOK *bk; DEFINE_COMMAND ("study", do_study, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to study a book.") if ((obj = get_obj_inv (ch, argy)) == NULL) { send_to_char ("You don't have that to study.\n\r", ch); return; } if (obj->pIndexData->item_type != ITEM_BOOK) { send_to_char ("That's not a book.. wouldn't want it to BURST into FLAMES! heh.\n\r", ch); return; } bk = (I_BOOK *) obj->more; if (bk->teaches == 0) { send_to_char ("You begin to read... Blah blah blah...\n\rYou soon discover that there is nothing you can learn from this book.\n\r", ch); return; } spell = skill_lookup (NULL, bk->teaches); if (spell == NULL) { send_to_char ("Some LAME builder created this book wrong - it doesn't do SHIT!\n\rHAHAHAHAHA!", ch); return; } /*past this point the book FRIES.. */ if (ch->pcdata->learned[(bk->teaches)] > 25) { send_to_char ("You read the book and a knowledge and understanding begins to\n\rmeld into your open mind... Unfortunately the book doesn't seem to\n\rteach you anything you don't already know! DOH!\n\r", ch); } else { char buf[STD_LENGTH]; send_to_char ("You read the book and a knowledge and understanding begins to\n\rmeld into your open mind...\n\r", ch); sprintf (buf, "You now understand the very basics of %s!!\n\r", spell->spell_name); send_to_char (buf, ch); ch->pcdata->learned[(bk->teaches)] = 26; } act ("$n reads $p\x1B[0m, and it bursts into flames!", ch, obj, NULL, TO_ROOM); act ("After you read $p\x1B[0m, it bursts into flames!", ch, obj, NULL, TO_CHAR); free_it (obj); return; } void do_steal (CHAR_DATA * ch, char *argy) { char buf[STD_LENGTH]; char arg1[SML_LENGTH]; char arg2[SML_LENGTH]; CHAR_DATA *victim; SINGLE_OBJECT *obj; DEFINE_COMMAND ("steal", do_steal, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to steal things from others.") argy = one_argy (argy, arg1); argy = one_argy (argy, arg2); if (arg1[0] == '\0' || arg2[0] == '\0') { send_to_char ("Steal what from whom?\n\r", ch); return; } if (IS_PLAYER (ch) && (IN_BATTLE(ch) || CHALLENGE (ch) == ARENA_FIGHTING)) { send_to_char ("Not in the battleground or arena!\n\r", ch); return; } if ((victim = get_char_room (ch, arg2)) == NULL) { send_to_char ("They aren't here.\n\r", ch); return; } if (LEVEL(victim) >= IMM_LEVEL) { send_to_char ("Forget it.\n\r", ch); return; } if (victim == ch) { send_to_char ("Like a dull sword, that's pointless.\n\r", ch); return; } WAIT_STATE (ch, 24); if (is_safe (ch, victim)) { if (IS_PLAYER (ch)) { act ("\x1B[1;37mYou feel as if the gods are watching, and a hot pain spreads", ch, NULL, NULL, TO_CHAR); act ("through your hand. OUCH! Perhaps you should not steal here...\x1B[0m", ch, NULL, NULL, TO_CHAR); } return; } else { if (victim->position == POSITION_FIGHTING || get_curr_dex(ch) < 26 || number_range(1,4) == 4 || !check_skill(ch, gsn_steal) || (IS_MOB (ch) && (number_range (1, 20) < 19)) || (IS_MOB (victim) && victim->pIndexData->pShop != NULL)) { send_to_char ("Oops.\n\r", ch); act ("$n tried to steal from you.\n\r", ch, NULL, victim, TO_VICT); act ("$n tried to steal from $N.\n\r", ch, NULL, victim, TO_NOTVICT); sprintf (buf, "%s is a bloody thief!", NAME (ch)); send_to_char (buf, victim); if (IS_PLAYER (ch)) { if (IS_MOB (victim)) { multi_hit (victim, ch, TYPE_UNDEFINED); } } return; } else { if ((obj = get_obj_inv (victim, arg1)) == NULL) { send_to_char ("You can't find it.\n\r", ch); return; } if (obj->wear_loc != -1) { send_to_char ("You can't steal things people are WEARING or HOLDING!!!\n\r", ch); return; } if (!can_drop_obj (ch, obj) || IS_SET (obj->extra_flags, ITEM_INVENTORY)) { send_to_char ("You can't pry it away.\n\r", ch); return; } if (number_range (1, 5) == 2) { act ("$N's suddenly looks your way, and you whistle innocently.", ch, NULL, victim, TO_CHAR); return; } obj_from (obj); obj_to (obj, ch); if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(ch)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) SET_BIT(ch->act, PLR_HAS_BOAT); } if (obj->pIndexData->item_type == ITEM_VEHICLE && IS_PLAYER(victim)) { I_VEHICLE *veh = (I_VEHICLE *) obj->more; if (veh->sector_use == SECT_WATER_SWIM || veh->sector_use == SECT_WATER_NOSWIM) REMOVE_BIT(victim->act, PLR_HAS_BOAT); } obj->wear_loc = -1; send_to_char ("Stolen.\n\r", ch); } return; } return; } void do_light (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; SINGLE_OBJECT *obj2; I_LIGHT *lt; I_TOOL *tb; DEFINE_COMMAND ("light", do_light, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to light a light source.") argy = one_argy (argy, arg); if (arg[0] == '\0') obj = get_item_held (ch, ITEM_LIGHT); else obj = get_obj_inv (ch, arg); obj2 = get_obj_inv (ch, "tinderbox"); if (obj == NULL) { send_to_char ("You don't have the light.\n\r", ch); return; } if (obj->pIndexData->item_type != ITEM_LIGHT) { send_to_char ("You can't light that!\n\r", ch); return; } lt = (I_LIGHT *) obj->more; if (IS_LIT (obj)) { send_to_char ("It's lit already!\n\r", ch); return; } if (lt->light_now <= 0) { send_to_char ("It's out of fuel.\n\r", ch); return; } if (obj2 == NULL) { send_to_char ("You don't have anything to light it with!\n\r", ch); return; } tb = (I_TOOL *) obj2->more; if (use_tool (obj2, TOOL_TINDERBOX) && !IS_SET(lt->light_lit, LIGHT_LIT)) { SET_BIT (lt->light_lit, LIGHT_LIT); act ("$n lights $p with $P.", ch, obj, obj2, TO_ROOM); act ("You light $p with $P.", ch, obj, obj2, TO_CHAR); if (obj->wear_loc != -1) { ch->in_room->light++; if (IS_PLAYER(ch)) ch->pcdata->light++; } if (tb->uses == 1) { send_to_char ("Your tinderbox is almost out of tinder, and the flint is starting to chip.\n\r", ch); } if (tb->uses == 0) { send_to_char ("Your tinderbox is out of tinder and the flint is chipped...\n\rTime to buy a new one!\n\r", ch); obj_from (obj2); free_it (obj2); } return; } else { send_to_char ("You can't light it with that.\n\r", ch); return; } return; } void do_extinguish (CHAR_DATA * ch, char *argy) { char arg[SML_LENGTH]; SINGLE_OBJECT *obj; I_LIGHT *lt; DEFINE_COMMAND ("extinguish", do_extinguish, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to extinguish a light source.") argy = one_argy (argy, arg); if (arg[0] == '\0') obj = get_item_held (ch, ITEM_LIGHT); /*held */ else obj = get_obj_inv (ch, arg); if (obj == NULL) { send_to_char ("You don't have the light in your hands.\n\r", ch); return; } if (obj->pIndexData->item_type != ITEM_LIGHT) { send_to_char ("That's not a light source.\n\r", ch); return; } lt = (I_LIGHT *) obj->more; if (!IS_LIT (obj)) { send_to_char ("It's extinguished already!\n\r", ch); return; } REMOVE_BIT (lt->light_lit, LIGHT_LIT); act ("$n extinguishes $p.", ch, obj, NULL, TO_ROOM); act ("You extinguish $p.", ch, obj, NULL, TO_CHAR); if (obj->wear_loc != -1) { ch->in_room->light--; if (IS_PLAYER(ch)) { ch->pcdata->light--; } } return; } void do_butcher (CHAR_DATA * ch, char *argy) /*By Arcane */ { SINGLE_OBJECT *obj, *weap, *steak; int count, x; char buf[80]; DEFINE_COMMAND ("butcher", do_butcher, POSITION_STANDING, 0, LOG_NORMAL, "Allows you to butcher a corpse into steaks. Based on your butcher skill.") if (argy[0] == '\0') { send_to_char ("What do you want to butcher?\n\r", ch); return; } if ((obj = get_obj_here (ch, argy, SEARCH_ROOM_FIRST)) == NULL) { send_to_char ("That's not here.\n\r", ch); return; } if (obj->pIndexData->item_type != ITEM_CORPSE_NPC) { send_to_char ("You can't butcher that!\n\r", ch); return; } if ((weap = get_item_held (ch, ITEM_WEAPON)) == NULL) { send_to_char ("You need something to cut with!\n\r", ch); return; } if (!IS_SET (weap->extra_flags, ITEM_SLASHING | ITEM_HEAVY_SLASH | ITEM_LIGHT_SLASH | ITEM_PIERCE)) { send_to_char ("You need something sharp to cut with!\n\r", ch); return; } if (!check_skill(ch, gsn_butcher)) { send_to_char ("Your clumsy hands destroy the corpse.\n\r", ch); free_it (obj); return; } count = dice (1, 3); sprintf (buf, "You slice and dice the corpse into %d steak%s.\n\r", count, (count > 1 ? "s" : "")); send_to_char (buf, ch); for (x = 0; x < count; x++) { steak = create_object (get_obj_index (20), 0); steak->timer = number_range (13, 20); if (dice (1, 100) == 13) { ((I_FOOD *) steak->more)->not_poison = 1; } obj_to (steak, ch->in_room); } free_it (obj); return; }