/***************************************************************** * pickup.c * Automated Multiple-Object Retriever (with 3 search options) * Evangelion <jeremyhill@cox.net> * * Last updated: Nov 02 2003 ******************************************************************/ /* PICKUP goes through all objects in the game that are on the ground and picks an object up if it matches your criteria. "pickup evatoken" would cause all objects on the ground named 'evatoken' to be picked up and placed in your inventory. There are three additional options to pickup: pickup <argument> aggressive: Gets all objects in the game matching argument, regardless of if it's in another object or being used by someone. pickup <argument> mobs: Same thing as aggressive except only mobiles will be checked in addition to the ground. Useful if you don't want to take things from people accidently. pickup <argument> vnum: argument will be a vnum to be picked up. Example: "pickup 26 vnum". Hint: To pickup by multiple names, such as 250 and token, and aggressively, do: "pickup '250 token' agg", for example. Notes: - You can pickup by vnum and aggressive both at the same time, etc. - Pickup Mobs will automatically pickup aggressively, so you don't need to type in both. - If you cannot see the object or the room an object is in, you will not pick it up. - Objects with no wear flags will not be picked up, even with aggressive. - Most of the time you'd want to pick up aggressively or with mobs. Some mobs pick up anything on the ground. */ /*Functions in this file: ****************************************************************** void do_pickup (CHAR_DATA * ch, char *argument) ****************************************************************** */ void do_pickup (CHAR_DATA * ch, char *argument) { char search_name[MIL]; char arg[MIL]; char buf[MSL]; int vnum = 0, number = 0; OBJ_DATA *obj; CHAR_DATA *gch; CHAR_DATA *tch; bool is_aggressive = FALSE; bool is_vnum = FALSE; bool is_mobs = FALSE; /*Invalid usage?*/ if (argument[0] == '\0') { do_help (ch, "pickup"); return; } argument = one_argument(argument, search_name); sprintf(buf, "Argument: %s\n\r", search_name); send_to_char(buf, ch); while (argument[0] != '\0') { argument = one_argument(argument, arg); if (!str_prefix(arg, "aggressive")) { send_to_char("Picking up aggressively.\n\r", ch); is_aggressive = TRUE; } if (!str_prefix(arg, "mobile") || !str_prefix(arg, "mobs") ) { send_to_char("Picking up aggressively (only from mobs and not players).\n\r", ch); is_aggressive = TRUE; is_mobs = TRUE; } if (!str_prefix(arg, "vnum")) { send_to_char("Argument is a vnum.\n\r", ch); is_vnum = TRUE; } } if (is_vnum) { if (!is_number(search_name)) { send_to_char("If you search by vnum, the argument must be a number.\n\r", ch); return; } vnum = atoi(search_name); } /*Let's find some objects.*/ for (obj = object_list; obj != NULL; obj = obj->next) { //obj_next = obj->next; /*Can see object?*/ if (!can_see_obj (ch, obj)) continue; /*Check vnum/name for match.*/ if (is_vnum) { if (obj->pIndexData->vnum != vnum) continue; } else { if (!is_name (search_name, obj->name)) continue; } /*Aggressive pickup style?*/ if (!is_aggressive) { if (obj->in_obj != NULL || obj->in_room == NULL || obj->carried_by != NULL || obj->wear_flags == 0) continue; if (obj->in_room != NULL && !can_see_room (ch, obj->in_room)) continue; /*Check furniture.*/ if (obj->in_room != NULL) { for (gch = obj->in_room->people; gch != NULL; gch = gch->next_in_room) { if (gch->on == obj) /*Not picking it up, people are on it. (Use aggressive to pick it up)*/ continue; } } /*here we CAN check for money to just extract, but won't.*/ /*if (obj->item_type == ITEM_MONEY)...*/ obj_from_room (obj); obj_to_char(obj, ch); number++; continue; } else { /*Aggressive is trickier.*/ if (obj->wear_flags == 0) continue; /*Check furniture.*/ if (obj->in_room != NULL) { for (gch = obj->in_room->people; gch != NULL; gch = gch->next_in_room) { /*Get off!*/ if (gch->on == obj) { gch->position = POS_STANDING; gch->on = NULL; } } } /*If the object is in a container, we have to extract it from the container.*/ /*Note that this object "should" be picked up by the next IF, or dropped onto the floor.*/ if (obj->in_obj != NULL) { if (obj->in_obj->carried_by != NULL) { tch = obj->in_obj->carried_by; if (!can_see (ch, tch) || tch->in_room == NULL || tch == ch) continue; /*Mobs only?*/ if (is_mobs) if (!IS_NPC(tch)) continue; /*Can't take objects from higher-level immortals.*/ if (IS_IMMORTAL(tch) && tch->level >= ch->level) continue; } obj_from_obj (obj); if (obj->carried_by == NULL && obj->in_room == NULL) obj_to_room (obj, get_room_index(ROOM_VNUM_LIMBO)); } /*Is the object carried by someone?*/ if (obj->carried_by != NULL && can_see (ch, obj->carried_by) && obj->carried_by->in_room != NULL && obj->carried_by != ch) { tch = obj->carried_by; /*Mobs only?*/ if (is_mobs) if (!IS_NPC(tch)) continue; /*Can't take objects from higher-level immortals.*/ if (IS_IMMORTAL(tch) && tch->level >= ch->level) continue; /*Obj_from_char checks character usage (wielded, etc), yay.*/ obj_from_char(obj); obj_to_char(obj, ch); number++; continue; } /*here we CAN check for money to just extract, but won't.*/ /*if (obj->item_type == ITEM_MONEY)...*/ /*Item's in a room.*/ if (obj->in_room) { obj_from_room (obj); obj_to_char(obj, ch); number++; continue; } /*We should have picked up all valid objects by now.*/ }/*Ends else (pickup is aggressive)*/ }/*Ends for loop through objects*/ if (number == 0) send_to_char("No matching objects found.\n\r", ch); else { sprintf(buf, "%d matching objects were found and added to your inventory.\n\r", number); send_to_char(buf, ch); } return; }