simply remove your old do_get, do_put, do_drop and do_give! replace with these in act_obj.c /*************************************************************************** * (c) 2000 TAKA and the GHOST DANCER MUD PROJECT TEAM * * You may use this code provided you accept it's usage agreements * * Usage agreement * 1) Is that you do not remove or modify this comment block. * 2) You must give due credit in the help files * 3) You email me at a_ghost_dancer@excite.com * this helps me judge what snippets are popular and i welcome * any ideas and if i find them worthy i may decide to code them * for GHOST and distribute them on our page. * 4) You must abid by all other ROM and MERC licences * 5) Finally any improvements/bugs you find or make please share them * so we can continue to put out quality snippets. * * Last thank you to all the ROM amd MERC folks for this wounderful code * base know as ROM. * * The Ghost Dancer MUD Project Team and me TAKA thank you * for your interest. * * You can email me at: * TAKA * a_ghost_dancer@excite.com * * The following code adds the ability to get x*item, put x*item * drop x*item, and give x*item. The old functionality to get, put * drop, and give an item and/or all items and/or all.items is still * available. * * so get cigar, get 2*cigar, get all, get all.cigar * get cigar humidor, get all.cigar humidor, get all humidor, get 2*cigar humidor * same type of functionality is now in put, give, and drop. * * This idea is from a few of the Ghost Dancer MUD staff PYROX and AZASH * drop on in and pay us a visit if you like * 209.84.132.85 port 3333 * ***************************************************************************/ void do_get( CHAR_DATA *ch, char *argument ) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char rest[MAX_INPUT_LENGTH];/**/ OBJ_DATA *obj; OBJ_DATA *obj_next; OBJ_DATA *container; bool found; int number, i = 0;/**/ number = mult_argument(argument,rest);/**/ strcpy(argument, rest); argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if (!str_cmp(arg2,"from")) argument = one_argument(rest,arg2); /* Get type. */ if ( arg1[0] == '\0' ) { send_to_char( "Get what?\n\r", ch ); return; } if ((number < 1) || (number > 64 )) { send_to_char( "Number must be between 1 and 64.\n\r", ch ); return; } if ( arg2[0] == '\0' ) { if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) && (number == 1) ) { /* 'get obj' */ obj = get_obj_list( ch, arg1, ch->in_room->contents ); if ( obj == NULL ) { act( "I see no $T here.", ch, NULL, arg1, TO_CHAR ); return; } get_obj( ch, obj, NULL ); } else if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) && (number >= 2) ) { found = FALSE; for ( obj = ch->in_room->contents; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; if ( is_name( &arg1[0], obj->name ) && can_see_obj( ch, obj ) ) { found = TRUE; get_obj( ch, obj, NULL ); i++; if (i >= number) return; } } if ( !found ) { if ( arg1[3] == '\0' ) send_to_char( "I see nothing here.\n\r", ch ); else act( "I see no $T here.", ch, NULL, &arg1[0], TO_CHAR ); } } else { /* 'get all' or 'get all.obj' */ found = FALSE; 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->name ) ) && can_see_obj( ch, obj ) ) { found = TRUE; get_obj( ch, obj, NULL ); } } if ( !found ) { if ( arg1[3] == '\0' ) send_to_char( "I see nothing here.\n\r", ch ); else act( "I see no $T here.", ch, NULL, &arg1[4], TO_CHAR ); } } } else { /* 'get ... container' */ 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 ) ) == NULL ) { act( "I see no $T here.", ch, NULL, arg2, TO_CHAR ); return; } switch ( container->item_type ) { default: send_to_char( "That's not a container.\n\r", ch ); return; case ITEM_CONTAINER: case ITEM_CORPSE_NPC: break; case ITEM_CORPSE_PC: { if (!can_loot(ch,container)) { send_to_char( "You can't do that.\n\r", ch ); return; } } } if ( IS_SET(container->value[1], CONT_CLOSED) ) { act( "The $d is closed.", ch, NULL, container->name, TO_CHAR ); return; } if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) && (number == 1) ) { /* 'get obj container' */ obj = get_obj_list( ch, arg1, container->contains ); if ( obj == NULL ) { act( "I see nothing like that in the $T.", ch, NULL, arg2, TO_CHAR ); return; } get_obj( ch, obj, container ); } else if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) && (number >= 2) ) { found = FALSE; for ( obj = container->contains; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; if ( is_name( &arg1[0], obj->name ) && can_see_obj( ch, obj ) ) { found = TRUE; get_obj( ch, obj, container ); i++; if (i >= number) return; } } if ( !found ) { if ( arg1[3] == '\0' ) act( "I see nothing in the $T.", ch, NULL, arg2, TO_CHAR ); else act( "I see nothing like that in the $T.", ch, NULL, arg2, TO_CHAR ); } } else { /* 'get all container' or 'get all.obj container' */ found = FALSE; for ( obj = container->contains; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; if ( ( arg1[3] == '\0' || is_name( &arg1[4], obj->name ) ) && can_see_obj( ch, obj ) ) { found = TRUE; if (container->pIndexData->vnum == OBJ_VNUM_PIT && !IS_IMMORTAL(ch)) { send_to_char("Don't be so greedy!\n\r",ch); return; } get_obj( ch, obj, container ); } } if ( !found ) { if ( arg1[3] == '\0' ) act( "I see nothing in the $T.", ch, NULL, arg2, TO_CHAR ); else act( "I see nothing like that in the $T.", ch, NULL, arg2, TO_CHAR ); } } } return; } void do_put( CHAR_DATA *ch, char *argument ) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char rest[MAX_INPUT_LENGTH]; OBJ_DATA *container; OBJ_DATA *obj; OBJ_DATA *obj_next; int number, i = 0;/**/ number = mult_argument(argument,rest);/**/ strcpy(argument, rest); argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if (!str_cmp(arg2,"in") || !str_cmp(arg2,"on")) argument = one_argument(argument,arg2); if ( arg1[0] == '\0' || arg2[0] == '\0' ) { send_to_char( "Put what in what?\n\r", ch ); 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 ) ) == NULL ) { act( "I see no $T here.", ch, NULL, arg2, TO_CHAR ); return; } if ( container->item_type != ITEM_CONTAINER ) { send_to_char( "That's not a container.\n\r", ch ); return; } if ( IS_SET(container->value[1], CONT_CLOSED) ) { act( "The $d is closed.", ch, NULL, container->name, TO_CHAR ); return; } if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) && (number == 1) ) { /* 'put obj container' */ if ( ( obj = get_obj_carry( ch, arg1, ch ) ) == NULL ) { send_to_char( "You do not have that item.\n\r", ch ); return; } if ( obj == container ) { send_to_char( "You can't fold it into itself.\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 (WEIGHT_MULT(obj) != 100) { send_to_char("You have a feeling that would be a bad idea.\n\r",ch); return; } if (get_obj_weight( obj ) + get_true_weight( container ) > (container->value[0] * 10) || get_obj_weight(obj) > (container->value[3] * 10)) { send_to_char( "It won't fit.\n\r", ch ); return; } if (container->pIndexData->vnum == OBJ_VNUM_PIT && !CAN_WEAR(container,ITEM_TAKE)) { if (obj->timer) SET_BIT(obj->extra_flags,ITEM_HAD_TIMER); else obj->timer = number_range(100,200); } obj_from_char( obj ); obj_to_obj( obj, container ); if (IS_SET(container->value[1],CONT_PUT_ON)) { act("$n puts $p on $P.",ch,obj,container, TO_ROOM); act("You put $p on $P.",ch,obj,container, TO_CHAR); } else { act( "$n puts $p in $P.", ch, obj, container, TO_ROOM ); act( "You put $p in $P.", ch, obj, container, TO_CHAR ); } } else if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) && (number >= 2) ) { /* 'put all container' or 'put all.obj container' */ for ( obj = ch->carrying; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; if ( ( is_name( &arg1[0], obj->name ) ) && can_see_obj( ch, obj ) && WEIGHT_MULT(obj) == 100 && obj->wear_loc == WEAR_NONE && obj != container && can_drop_obj( ch, obj ) && get_obj_weight( obj ) + get_true_weight( container ) <= (container->value[0] * 10) && get_obj_weight(obj) < (container->value[3] * 10)) { if (container->pIndexData->vnum == OBJ_VNUM_PIT && !CAN_WEAR(obj, ITEM_TAKE) ) { if (obj->timer) SET_BIT(obj->extra_flags,ITEM_HAD_TIMER); else obj->timer = number_range(100,200); } obj_from_char( obj ); obj_to_obj( obj, container ); i++; if (IS_SET(container->value[1],CONT_PUT_ON)) { act("$n puts $p on $P.",ch,obj,container, TO_ROOM); act("You put $p on $P.",ch,obj,container, TO_CHAR); } else { act( "$n puts $p in $P.", ch, obj, container, TO_ROOM ); act( "You put $p in $P.", ch, obj, container, TO_CHAR ); } if (i >= number) return; } } return; } else { /* 'put all container' or 'put all.obj container' */ for ( obj = ch->carrying; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; if ( ( arg1[3] == '\0' || is_name( &arg1[4], obj->name ) ) && can_see_obj( ch, obj ) && WEIGHT_MULT(obj) == 100 && obj->wear_loc == WEAR_NONE && obj != container && can_drop_obj( ch, obj ) && get_obj_weight( obj ) + get_true_weight( container ) <= (container->value[0] * 10) && get_obj_weight(obj) < (container->value[3] * 10)) { if (container->pIndexData->vnum == OBJ_VNUM_PIT && !CAN_WEAR(obj, ITEM_TAKE) ) { if (obj->timer) SET_BIT(obj->extra_flags,ITEM_HAD_TIMER); else obj->timer = number_range(100,200); } obj_from_char( obj ); obj_to_obj( obj, container ); if (IS_SET(container->value[1],CONT_PUT_ON)) { act("$n puts $p on $P.",ch,obj,container, TO_ROOM); act("You put $p on $P.",ch,obj,container, TO_CHAR); } else { act( "$n puts $p in $P.", ch, obj, container, TO_ROOM ); act( "You put $p in $P.", ch, obj, container, TO_CHAR ); } } } } return; } void do_drop( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; char rest[MAX_INPUT_LENGTH]; OBJ_DATA *obj; OBJ_DATA *obj_next; bool found; int number, i = 0;/**/ number = mult_argument(argument,rest);/**/ strcpy(argument, rest); argument = one_argument( argument, arg ); if ( arg[0] == '\0' ) { send_to_char( "Drop what?\n\r", ch ); return; } if ( is_number( arg ) ) { /* 'drop NNNN coins' */ int amount, gold = 0, silver = 0; amount = atoi(arg); argument = one_argument( argument, arg ); if ( amount <= 0 || ( str_cmp( arg, "coins" ) && str_cmp( arg, "coin" ) && str_cmp( arg, "gold" ) && str_cmp( arg, "silver") ) ) { send_to_char( "Sorry, you can't do that.\n\r", ch ); return; } if ( !str_cmp( arg, "coins") || !str_cmp(arg,"coin") || !str_cmp( arg, "silver")) { if (ch->silver < amount) { send_to_char("You don't have that much silver.\n\r",ch); return; } ch->silver -= amount; silver = amount; } else { if (ch->gold < amount) { send_to_char("You don't have that much gold.\n\r",ch); return; } ch->gold -= amount; gold = amount; } for ( obj = ch->in_room->contents; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; switch ( obj->pIndexData->vnum ) { case OBJ_VNUM_SILVER_ONE: silver += 1; extract_obj(obj); break; case OBJ_VNUM_GOLD_ONE: gold += 1; extract_obj( obj ); break; case OBJ_VNUM_SILVER_SOME: silver += obj->value[0]; extract_obj(obj); break; case OBJ_VNUM_GOLD_SOME: gold += obj->value[1]; extract_obj( obj ); break; case OBJ_VNUM_COINS: silver += obj->value[0]; gold += obj->value[1]; extract_obj(obj); break; } } obj_to_room( create_money( gold, silver ), ch->in_room ); act( "$n drops some coins.", ch, NULL, NULL, TO_ROOM ); send_to_char( "OK.\n\r", ch ); return; } if ( str_cmp( arg, "all" ) && str_prefix( "all.", arg ) && (number == 1) ) { /* 'drop obj' */ if ( ( obj = get_obj_carry( ch, arg, ch ) ) == NULL ) { send_to_char( "You do not have that item.\n\r", ch ); return; } if ( !can_drop_obj( ch, obj ) ) { send_to_char( "You can't let go of it.\n\r", ch ); return; } obj_from_char( obj ); obj_to_room( obj, ch->in_room ); act( "$n drops $p.", ch, obj, NULL, TO_ROOM ); act( "You drop $p.", ch, obj, NULL, TO_CHAR ); if (IS_OBJ_STAT(obj,ITEM_MELT_DROP)) { act("$p dissolves into smoke.",ch,obj,NULL,TO_ROOM); act("$p dissolves into smoke.",ch,obj,NULL,TO_CHAR); extract_obj(obj); } } else if ( str_cmp( arg, "all" ) && str_prefix( "all.", arg ) && (number >= 2) ) { /* 'drop all' or 'drop all.obj' */ found = FALSE; for ( obj = ch->carrying; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; if ( ( is_name( &arg[0], obj->name ) ) && can_see_obj( ch, obj ) && obj->wear_loc == WEAR_NONE && can_drop_obj( ch, obj ) ) { found = TRUE; obj_from_char( obj ); obj_to_room( obj, ch->in_room ); act( "$n drops $p.", ch, obj, NULL, TO_ROOM ); act( "You drop $p.", ch, obj, NULL, TO_CHAR ); if (IS_OBJ_STAT(obj,ITEM_MELT_DROP)) { act("$p dissolves into smoke.",ch,obj,NULL,TO_ROOM); act("$p dissolves into smoke.",ch,obj,NULL,TO_CHAR); extract_obj(obj); } i++; if (i >= number) return; } } if ( !found ) { if ( arg[3] == '\0' ) act( "You are not carrying anything.",ch, NULL, arg, TO_CHAR ); else act( "You are not carrying any $T.",ch, NULL, &arg[4], TO_CHAR ); } } else { /* 'drop all' or 'drop all.obj' */ found = FALSE; for ( obj = ch->carrying; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; if ( ( arg[3] == '\0' || is_name( &arg[4], obj->name ) ) && can_see_obj( ch, obj ) && obj->wear_loc == WEAR_NONE && can_drop_obj( ch, obj ) ) { found = TRUE; obj_from_char( obj ); obj_to_room( obj, ch->in_room ); act( "$n drops $p.", ch, obj, NULL, TO_ROOM ); act( "You drop $p.", ch, obj, NULL, TO_CHAR ); if (IS_OBJ_STAT(obj,ITEM_MELT_DROP)) { act("$p dissolves into smoke.",ch,obj,NULL,TO_ROOM); act("$p dissolves into smoke.",ch,obj,NULL,TO_CHAR); extract_obj(obj); } } } if ( !found ) { if ( arg[3] == '\0' ) act( "You are not carrying anything.", ch, NULL, arg, TO_CHAR ); else act( "You are not carrying any $T.", ch, NULL, &arg[4], TO_CHAR ); } } return; } void do_give( CHAR_DATA *ch, char *argument ) { char arg1 [MAX_INPUT_LENGTH]; char arg2 [MAX_INPUT_LENGTH]; char rest[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; CHAR_DATA *victim; OBJ_DATA *obj; int number, i = 0;/**/ number = mult_argument(argument,rest);/**/ strcpy(argument, rest); argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if ( arg1[0] == '\0' || arg2[0] == '\0' ) { send_to_char( "Give what to whom?\n\r", ch ); return; } if ( is_number( arg1 ) ) { /* 'give NNNN coins victim' */ int amount; bool silver; amount = atoi(arg1); if ( amount <= 0 || ( str_cmp( arg2, "coins" ) && str_cmp( arg2, "coin" ) && str_cmp( arg2, "gold" ) && str_cmp( arg2, "silver")) ) { send_to_char( "Sorry, you can't do that.\n\r", ch ); return; } silver = str_cmp(arg2,"gold"); argument = one_argument( argument, arg2 ); if ( arg2[0] == '\0' ) { send_to_char( "Give what to whom?\n\r", ch ); return; } if ( ( victim = get_char_room( ch, arg2 ) ) == NULL ) { send_to_char( "They aren't here.\n\r", ch ); return; } if ( (!silver && ch->gold < amount) || (silver && ch->silver < amount) ) { send_to_char( "You haven't got that much.\n\r", ch ); return; } if (silver) { ch->silver -= amount; victim->silver += amount; } else { ch->gold -= amount; victim->gold += amount; } sprintf(buf,"$n gives you %d %s.",amount, silver ? "silver" : "gold"); act( buf, ch, NULL, victim, TO_VICT ); act( "$n gives $N some coins.", ch, NULL, victim, TO_NOTVICT ); sprintf(buf,"You give $N %d %s.",amount, silver ? "silver" : "gold"); act( buf, ch, NULL, victim, TO_CHAR ); if (IS_NPC(victim) && IS_SET(victim->act,ACT_IS_CHANGER)) { int change; change = (silver ? 95 * amount / 100 / 100 : 95 * amount); if (!silver && change > victim->silver) victim->silver += change; if (silver && change > victim->gold) victim->gold += change; if (change < 1 && can_see(victim,ch)) { act("$n tells you 'I'm sorry, you did not give me enough to change.'" ,victim,NULL,ch,TO_VICT); ch->reply = victim; sprintf(buf,"%d %s %s", amount, silver ? "silver" : "gold",ch->name); do_give(victim,buf); } else if (can_see(victim,ch)) { sprintf(buf,"%d %s %s", change, silver ? "gold" : "silver",ch->name); do_give(victim,buf); if (silver) { sprintf(buf,"%d silver %s", (95 * amount / 100 - change * 100),ch->name); do_give(victim,buf); } act("$n tells you 'Thank you, come again.'", victim,NULL,ch,TO_VICT); ch->reply = victim; } } /* * Bribe trigger -------REMOVED TAKA to compile once----------- */ if ( IS_NPC(victim) && HAS_TRIGGER( victim, TRIG_BRIBE ) ) mp_bribe_trigger( victim, ch, silver ? amount : amount * 100 ); return; } if ( ( obj = get_obj_carry( ch, arg1, ch ) ) == NULL ) { send_to_char( "You do not have that item.\n\r", ch ); return; } /* * Bribe trigger -------REMOVED TAKA to compile once----------- */ if ( obj->wear_loc != WEAR_NONE ) { 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 (IS_NPC(victim) && victim->pIndexData->pShop != NULL) { act("$N tells you 'Sorry, you'll have to sell that.'", ch,NULL,victim,TO_CHAR); ch->reply = victim; return; } if ( !can_drop_obj( ch, obj ) ) { send_to_char( "You can't let go of it.\n\r", ch ); return; } if ( victim->carry_number + get_obj_number( obj ) > can_carry_n( victim ) ) { act( "$N has $S hands full.", ch, NULL, victim, TO_CHAR ); return; } if (get_carry_weight(victim) + get_obj_weight(obj) > can_carry_w( victim ) ) { act( "$N can't carry that much weight.", ch, NULL, victim, TO_CHAR ); return; } if ( !can_see_obj( victim, obj ) ) { act( "$N can't see it.", ch, NULL, victim, TO_CHAR ); return; } if (number == 1) { obj_from_char( obj ); obj_to_char( obj, victim ); MOBtrigger = FALSE; act( "$n gives $p to $N.", ch, obj, victim, TO_NOTVICT ); act( "$n gives you $p.", ch, obj, victim, TO_VICT ); act( "You give $p to $N.", ch, obj, victim, TO_CHAR ); MOBtrigger = TRUE; } else { for (;;) { obj_from_char( obj ); obj_to_char( obj, victim ); i++; if (i >= number) { MOBtrigger = FALSE; act( "$n gives some $p to $N.", ch, obj, victim, TO_NOTVICT ); act( "$n gives you some $p.", ch, obj, victim, TO_VICT ); act( "You give some $p to $N.", ch, obj, victim, TO_CHAR ); MOBtrigger = TRUE; return; } if ( ( obj = get_obj_carry( ch, arg1, ch ) ) == NULL ) { send_to_char( "You do not have that item.\n\r", ch ); MOBtrigger = FALSE; act( "$n gives somr $p to $N.", ch, obj, victim, TO_NOTVICT ); act( "$n gives you some $p.", ch, obj, victim, TO_VICT ); act( "You give some $p to $N.", ch, obj, victim, TO_CHAR ); MOBtrigger = TRUE; return; } } } /* * Give trigger */ if ( IS_NPC(victim) && HAS_TRIGGER( victim, TRIG_GIVE ) ) mp_give_trigger( victim, ch, obj ); return; } /* * end of TAKA mods */