act_obj.cpp
act_obj.cpp · 229.0 KB
From the archive wotl-src.zip
Download the archive « Back to the archive contents
/**************************************************************************/
// act_obj.cpp - players performing actions relating to objects
/***************************************************************************
* The Dawn of Time v1.69r (c)1997-2004 Michael Garratt *
* >> A number of people have contributed to the Dawn codebase, with the *
* majority of code written by Michael Garratt - www.dawnoftime.org *
* >> To use this source code, you must fully comply with all the licenses *
* in licenses.txt... In particular, you may not remove this copyright *
* notice. *
***************************************************************************
* >> Original Diku Mud copyright (c)1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, & Katja Nyboe. *
* >> Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* >> ROM 2.4 is copyright 1993-1995 Russ Taylor and has been brought to *
* you by the ROM consortium: Russ Taylor(rtaylor@pacinfo.com), *
* Gabrielle Taylor(gtaylor@pacinfo.com) & Brian Moore(rom@rom.efn.org) *
* >> Oblivion 1.2 is copyright 1996 Wes Wagner *
**************************************************************************/
#include "include.h" // dawn standard includes
#include "msp.h"
#include "lockers.h"
#include "lookup.h"
#include "altform.h"
#include "shop.h"
/* command procedures needed */
DECLARE_DO_FUN(do_split );
DECLARE_DO_FUN(do_yell );
DECLARE_DO_FUN(do_say );
DECLARE_DO_FUN(do_stand );
DECLARE_DO_FUN(do_look );
void do_gecho( char_data *ch, char *argument );
int find_door args( ( char_data *ch, char *arg, char *action) );
char *get_weapontype(OBJ_DATA *obj); /* prototype - handler.c */
bool trapcheck_get(char_data *ch, OBJ_DATA *obj);
bool race_can_wear (char_data *ch, OBJ_DATA *obj);
SPRESULT spell_fear_magic( int sn, int level, char_data *ch, void *vo,int ); /* magic.cpp */
// Local functions.
#define CD char_data
#define OD OBJ_DATA
bool remove_obj args( (char_data *ch, int iWear, bool fReplace ) );
CD * find_keeper args( (char_data *ch ) );
int get_cost args( (char_data *keeper, OBJ_DATA *obj, bool fBuy ) );
void obj_to_keeper args( (OBJ_DATA *obj, char_data *ch ) );
OD * get_obj_keeper args( (char_data *ch,char_data *keeper,char *argument));
DECLARE_OSPEC_FUN( ospec_thought_sharer);
DECLARE_OSPEC_FUN( ospec_blessed_chalice);
DECLARE_OSPEC_FUN( ospec_gnomish_lockpick);
#undef OD
#undef CD
bool can_loot(char_data *, OBJ_DATA *)
{
return true;
}
/**************************************************************************/
void get_obj( char_data *ch, OBJ_DATA *obj, OBJ_DATA *container)
{
// variables for AUTOSPLIT
char_data *gch;
int members;
char buffer[100];
if ( !CAN_WEAR(obj, OBJWEAR_TAKE) )
{
ch->println("You can't take that.");
return;
}
if ( trapcheck_get( ch, obj ))
return;
// Clan Gear Items - Ixliam
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && (obj->pIndexData->clan != NULL))
{
if (obj->pIndexData->clan != ch->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
}
}
if (IS_SET(obj->extra2_flags, OBJEXTRA2_RUNIC) && obj->level > ch->level)
{
act( "$n is struck with lightning as they try to get $p.", ch, obj, NULL, TO_ROOM );
ch->printf( "You are struck by lightning when you touch %s.\r\n", obj->short_descr );
ch->printf( "%s is to powerful for you to handle.\r\n", obj->short_descr );
return;
}
//ospec_blessed_chalice
if (obj->ospec_fun == ospec_lookup("ospec_blessed_chalice")
&& ((!IS_SET(obj->extra_flags, OBJEXTRA_ANTI_EVIL)
&& IS_SET(obj->extra_flags, OBJEXTRA_ANTI_GOOD)
&& IS_GOOD(ch))
||(IS_SET(obj->extra_flags, OBJEXTRA_ANTI_EVIL)
&& !IS_SET(obj->extra_flags, OBJEXTRA_ANTI_GOOD)
&& IS_EVIL(ch))
||(!IS_SET(obj->extra_flags, OBJEXTRA_ANTI_EVIL)
&& !IS_SET(obj->extra_flags, OBJEXTRA_ANTI_GOOD)
&& IS_NEUTRAL(ch))))
{
act( "$n is struck with lightning as they try to get $p.", ch, obj, NULL, TO_ROOM );
ch->printf( "You are struck by lightning when you touch %s.\r\n", obj->short_descr );
ch->hit = UMIN( ch->hit - game_settings->max_hp_from_heal_spell, ch->max_hit );
update_pos( ch );
return;
}
if ( obj->item_type == ITEM_MONEY)
{
// check silver first
if ((get_carry_weight( ch ) +
get_silver_weight(obj->value[0])) > can_carry_w( ch ) )
{
ch->println("You cannot carry that much weight.");
return;
}
// now lets check if the player can carry that much gold
if ((get_carry_weight( ch ) +
get_gold_weight(obj->value[1])) > can_carry_w( ch ) )
{
ch->println("You cannot carry that much weight.");
return;
}
}
if ( !IS_SWITCHED (ch) && (ch->carry_number + get_obj_number( obj ) > can_carry_n( ch )))
{
act( "$d: you can't carry that many items.",
ch, NULL, obj->name, TO_CHAR );
return;
}
if ( !IS_SWITCHED (ch) && get_carry_weight(ch) + get_obj_weight( obj ) > can_carry_w( ch ) )
{
act( "$d: you can't carry that much weight.",
ch, NULL, obj->name, TO_CHAR );
return;
}
if (obj->in_room != NULL)
{
for (gch = obj->in_room->people; gch != NULL; gch = gch->next_in_room)
if (gch->on == obj)
{
act("$N appears to be using $p.",
ch,obj,gch,TO_CHAR);
return;
}
}
if ( container != NULL ){
if(container->pIndexData->vnum == OBJ_VNUM_PIT
&& !CAN_WEAR(container, OBJWEAR_TAKE)
&& !IS_OBJ_STAT(obj,OBJEXTRA_HAD_TIMER))
obj->timer = 0;
if(IS_SET(ch->dyn2, DYN2_CHICANERY) && get_skill(ch, gsn_chicanery) > number_percent())
{
act( "You secretly get $p from $P.", ch, obj, container, TO_CHAR );
// hide them to mortals
int old_invis_level = ch->invis_level;
ch->invis_level = UMAX(ch->invis_level, LEVEL_IMMORTAL);
act( "$n gets $p from $P.[CHICANERY]", ch, obj, container, TO_ROOM );
ch->invis_level=old_invis_level;
check_improve(ch,gsn_chicanery,true,10);
}
else
{
act( "You get $p from $P.", ch, obj, container, TO_CHAR );
act( "$n gets $p from $P.", ch, obj, container, TO_ROOM );
}
REMOVE_BIT(obj->extra_flags,OBJEXTRA_HAD_TIMER);
obj_from_obj( obj );
}else
{
if(IS_SET(ch->dyn2, DYN2_CHICANERY) && get_skill(ch, gsn_chicanery) > number_percent())
{
act( "You secretly get $p.", ch, obj, container, TO_CHAR );
// hide them to mortals
int old_invis_level = ch->invis_level;
ch->invis_level = UMAX(ch->invis_level, LEVEL_IMMORTAL);
act( "$n gets $p.[CHICANERY]", ch, obj, container, TO_ROOM );
ch->invis_level=old_invis_level;
check_improve(ch,gsn_chicanery,true,10);
}
else
{
act( "You get $p.", ch, obj, container, TO_CHAR );
act( "$n gets $p.", ch, obj, container, TO_ROOM );
}
obj_from_room( obj );
}
if ( obj->item_type == ITEM_MONEY)
{
ch->silver += obj->value[0];
ch->gold += obj->value[1];
if (IS_SET(ch->act,PLR_AUTOSPLIT))
{ // AUTOSPLIT code
members = 0;
for (gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
{
if (!IS_AFFECTED(gch,AFF_CHARM) && is_same_group( gch, ch ) )
members++;
}
if ( members > 1 && (obj->value[0] > 1 || obj->value[1]))
{
sprintf(buffer,"%d %d",obj->value[0],obj->value[1]);
do_split(ch,buffer);
}
}
if(!IS_NPC(ch)){
if(obj->lastdrop_id!=ch->id
&& !strcmp(obj->lastdrop_remote_ip,ch->remote_ip_copy))
{
multilog_alertf(ch, "`Y%s<%d>`x getting `Y%d gold `xand `S%d silver `xfrom somewhere "
"(prob the ground), `M(room %d)`x, this was put there by someone `B(id=%d)`x other than %s but from the same "
"ip address as `Y%s!`x",
ch->name,
ch->level,
obj->value[1],
obj->value[0],
ch->in_room_vnum(),
(int)obj->lastdrop_id,
ch->name,
ch->name);
ch->printlnf("#`YExchanging money between your PC's or someone from your site is illegal!!!`^");
ch->printlnf("#`RAll your money is forfeit!!!`^");
ch->gold = 0;
ch->silver = 0;
ch->bank = 0;
extract_obj( obj );
return;
}
}
extract_obj( obj );
}else{
// multilog abuse checks
if(!IS_NPC(ch)){
if(obj->lastdrop_id!=ch->id &&
!strcmp(obj->lastdrop_remote_ip,ch->remote_ip_copy))
{
multilog_alertf(ch,
"`Y%s<%d>`x getting `Gobject `x'%s'<%d>(%d)`x which was originally put where it is being 'got from' (room %d)"
"by `Bsomeone (id=%d)`x different than `Y%s`x, but from the same ip address as `Y%s!`x",
ch->name,
ch->level,
obj->short_descr,
obj->level,
obj->pIndexData?obj->pIndexData->vnum:0,
ch->in_room_vnum(),
(int)obj->lastdrop_id,
ch->name,
ch->name);
char mbuf [MSL];
sprintf(mbuf, "`#`Y%s has been removed for being a multilog item. `RDO NOT MULTI ITEMS!!!`^", obj->short_descr);
ch->printlnf(mbuf);
extract_obj( obj );
return;
}
}
obj_to_char( obj, ch );
}
return;
}
/************************************************************************/
// get a random object from the characters inventory
OBJ_DATA *get_random_obj( char_data* mob )
{
OBJ_DATA *obj_next, *obj, *target=NULL;
int now = 0, highest = 0;
for ( obj = mob->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
if ( obj->wear_loc != WEAR_NONE
|| !can_drop_obj( mob, obj ) )
continue;
if ( ( now = number_percent() ) > highest )
{
target = obj;
highest = now;
}
}
return target;
}
/************************************************************************/
void donate(char_data *ch, OBJ_DATA *obj)
{
if(!CAN_WEAR( obj, OBJWEAR_TAKE) || obj->item_type == ITEM_CORPSE_PC){
act("You can't donate $p.", ch, obj,NULL, TO_CHAR);
return;
}
int room_vnum=0;
// confirm the room they are going to donate to exists
if (obj->level < 11){
if (obj->item_type == ITEM_WEAPON){
room_vnum=ROOM_VNUM_NEWBIEWEAPON_DONATE;
}else if (obj->item_type == ITEM_ARMOR){
room_vnum=ROOM_VNUM_NEWBIEARMOR_DONATE;
}else{
room_vnum=ROOM_VNUM_NEWBIEMISC_DONATE;
}
}else{
if (obj->pIndexData->vnum == OBJ_VNUM_RANDOM_OBJ){
room_vnum=3064;
}else if (obj->item_type == ITEM_ARMOR){
room_vnum=ROOM_VNUM_ARMOR_DONATE;
}else if (obj->item_type == ITEM_WEAPON){
room_vnum=ROOM_VNUM_WEAPON_DONATE;
}else{
room_vnum=ROOM_VNUM_MISC_DONATE;
}
}
room_index_data *room=get_room_index(room_vnum);
if(!room){
act(FORMATF("Bug: couldn't find room %d to donate object %d ($p) "
"- please inform the admin.",
room_vnum, obj->pIndexData?obj->pIndexData->vnum:-1), ch, obj,NULL, TO_CHAR);
return;
}
// Clan Gear Items - Ixliam
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && (obj->pIndexData->clan != NULL))
{
if (obj->pIndexData->clan != ch->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
}
}
if(obj->item_type == ITEM_KEY)
{
extract_obj(obj);
ch->println("Your donation is greatly appreciated");
ch->printlnf("%s disappears in a puff of smoke.", obj->short_descr);
act( "$n donates $p.", ch, obj, NULL, TO_ROOM);
return;
}
ch->println("Your donation is greatly appreciated");
ch->printlnf("%s disappears in a puff of smoke.", obj->short_descr);
act( "$n donates $p.", ch, obj, NULL, TO_ROOM);
obj_from_room(obj);
room_index_data *oldroom=ch->in_room;
ch->in_room=room;
SET_BIT(obj->extra2_flags,OBJEXTRA2_NOSELL);
// find the pit in the room
OBJ_DATA *pit;
for( pit= room->contents; pit; pit= pit->next_content )
{
if(pit->pIndexData && pit->pIndexData->vnum==OBJ_VNUM_PIT){
break;
}
}
if(pit){
act( "$p appears in $P.", ch, obj, pit, TO_ROOM);
obj->timer=200; // objects donated last around 3 hours irl time
obj_to_obj(obj,pit);
}else{
act( "$p appears in the room by your feet.", ch, obj, NULL, TO_ROOM);
obj_to_room(obj,room);
}
ch->in_room=oldroom;
}
/************************************************************************/
// multiroom donation system - by Balo and Kal
void do_donate( char_data *ch, char *argument)
{
OBJ_DATA *obj;
char arg[MIL];
OBJ_DATA *obj_next;
bool found;
sh_int max_don;
one_argument( argument, arg);
if(IS_NULLSTR(arg)){
ch->println("Donate What?!");
return;
}
// handle donating a specific item
if( str_cmp( arg, "all" ) && str_prefix( "all.", arg ) )
{
obj = get_obj_list( ch, arg, ch->in_room->contents );
if (!obj){
ch->printlnf("I don't see any '%s' on the ground here to donate!", arg);
return;
}
SET_BIT(obj->extra2_flags,OBJEXTRA2_NOSELL);
donate(ch, obj);
return;
}
// handle donating all
{
found = false;
max_don = 0;
for ( obj = ch->in_room->contents; obj; obj = obj_next )
{
obj_next = obj->next_content;
if(!CAN_WEAR(obj, OBJWEAR_TAKE)){
continue;
}
if ( ( arg[3] == '\0' || is_name( &arg[4], obj->name ) )
&& can_see_obj( ch, obj ) )
{
found = true;
max_don++;
if (max_don > 100)
{
ch->wrapln("That's a lot of stuff!! Hold up a sec! "
"The pipelines in the sky are a little full.. "
"give it a sec and try again!");
return;
}
donate(ch, obj);
}
}
if ( !found ){
ch->println( "I don't see that here.");
}
}
}
/************************************************************************/
void do_get( char_data *ch, char *argument)
{
char arg1[MIL];
char arg2[MIL];
OBJ_DATA *obj;
OBJ_DATA *obj_next;
OBJ_DATA *container;
bool found;
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if(!str_cmp(arg2,"from")){
argument = one_argument(argument,arg2);
}
// Get type.
if ( IS_NULLSTR(arg1) )
{
ch->println( "Get what?" );
return;
}
// ooc rooms
if(!IS_IMMORTAL(ch) && IS_SET(ch->in_room->room_flags,ROOM_OOC)){
ch->println("Not in an OOC room.");
return;
}
if( IS_NULLSTR(arg2) )
{
if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) )
{
// '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(!IS_IMMORTAL(ch))
{
if(ch->in_room->vnum==ROOM_VNUM_NEWBIEWEAPON_DONATE || ch->in_room->vnum==ROOM_VNUM_NEWBIEARMOR_DONATE ||
ch->in_room->vnum==ROOM_VNUM_NEWBIEMISC_DONATE || ch->in_room->vnum==ROOM_VNUM_WEAPON_DONATE ||
ch->in_room->vnum==ROOM_VNUM_ARMOR_DONATE || ch->in_room->vnum==ROOM_VNUM_MISC_DONATE)
{
ch->println("Don't be so greedy. You cannot use 'get all' here.");
return;
}
}
// '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 ) )
{
// allow creation of objects with hidden name
if(IS_SET( obj->extra_flags, OBJEXTRA_NO_GET_ALL )){
continue;
}
found = true;
get_obj( ch, obj, NULL);
}
}
if ( !found )
{
if ( arg1[3] == '\0' ){
ch->println("I see nothing here.");
}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 ) )
{
ch->println("You can't do that.");
ch->println("syntax: get <object> <containing_object>");
return;
}
if ( ( container = get_obj_here( ch, arg2 ) ) == NULL )
{
act( "I see no $T here.", ch, NULL, arg2, TO_CHAR );
return;
}
// allow creation of objects with hidden name
if(IS_SET( container->extra_flags, OBJEXTRA_NO_GET_ALL )){
act( "I see no $T here.", ch, NULL, arg2, TO_CHAR );
return;
}
switch ( container->item_type )
{
default:
{
ch->printlnf( "%s is not a container.", container->short_descr);
if(IS_NEWBIE(ch)){
ch->println( "`Wsyntax:`=C get <what> <container>`x");
}
return;
}
case ITEM_CAULDRON:
case ITEM_QUIVER:
case ITEM_CONTAINER:
case ITEM_FLASK:
case ITEM_MORTAR:
case ITEM_CORPSE_NPC:
break;
case ITEM_CORPSE_PC:
{
if (!can_loot(ch,container))
{
ch->println("You can't do that.");
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 ) )
{
// '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
{
// '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))
{
ch->println("Don't be so greedy!");
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[MIL];
char arg2[MIL];
obj_data *container;
obj_data *obj;
obj_data *obj_next;
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' )
{
ch->println("Put what in what?");
return;
}
// ooc rooms
if(!IS_IMMORTAL(ch) && IS_SET(ch->in_room->room_flags,ROOM_OOC)){
ch->println("Not in an OOC room.");
return;
}
if ( !str_cmp( arg2, "all" ) || !str_prefix( "all.", arg2 ) )
{
ch->println("You can't do that.");
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:
ch->printlnf( "%s is not a container.", container->short_descr);
if(IS_NEWBIE(ch)){
ch->println( "`Whint?:`=C put <what> <container>`x");
}
return;
case ITEM_FOUNTAIN:
if ( !str_cmp( arg1, "coin" ) )
{
if(ch->gold == 0)
{
ch->println("You do not have a gold coin to flip into anything.");
return;
}
ch->gold -=1;
act( "$n tosses a `#`Ygold coin`^ into $P.", ch, NULL, container, TO_ROOM );
act( "You make a wish and toss a `#`Ygold coin`^ into $P.", ch, NULL, container, TO_CHAR );
} else {
ch->printlnf( "%s is not a container.", container->short_descr);
if(IS_NEWBIE(ch))
{
ch->println( "`Whint?:`=C put <what> <container>`x");
}
}
return;
case ITEM_CAULDRON:
case ITEM_QUIVER:
case ITEM_CONTAINER:
case ITEM_FLASK:
case ITEM_MORTAR:
break;
}
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 ) )
{
// 'put obj container'
if ( ( obj = get_obj_carry( ch, arg1 ) ) == NULL )
{
ch->println("You do not have that item.");
return;
}
if ( obj == container )
{
ch->println("You can't fold it into itself.");
return;
}
if ( !can_drop_obj( ch, obj ) )
{
ch->println("You can't let go of it.");
return;
}
if (WEIGHT_MULT(obj) != 100)
{
ch->println("You have a feeling that would be a bad idea.");
return;
}
if (get_obj_weight(obj) > (container->value[3] * 10))
{
ch->printlnf( "%s appears to be too big to ever be put into %s.",
obj->short_descr, container->short_descr);
return;
}
if (get_obj_weight( obj ) + get_true_weight( container ) - container->weight
> (container->value[0] * 10))
{
ch->printlnf( "There doesn't appears to be enough room inside %s to fit %s.`1",
container->short_descr, obj->short_descr);
return;
}
if (container->pIndexData->vnum == OBJ_VNUM_PIT
&& !CAN_WEAR(container,OBJWEAR_TAKE))
{
if (obj->timer){
SET_BIT(obj->extra_flags,OBJEXTRA_HAD_TIMER);
}else{
obj->timer = number_range(100,200);
}
}
// Clan Gear Items - Ixliam
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && (obj->pIndexData->clan != NULL))
{
if (obj->pIndexData->clan != ch->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
}
}
if (IS_SET(obj->extra2_flags, OBJEXTRA2_RUNIC) && obj->level > ch->level)
{
act( "$n is shocked as they try to put $p away.", ch, obj, NULL, TO_ROOM );
ch->printf( "%s is to powerful for you to handle.\r\n", obj->short_descr );
return;
}
obj_from_char( obj );
obj_to_obj( obj, container );
if (IS_SET(container->value[1],CONT_PUT_ON))
{
if(IS_SET(ch->dyn2, DYN2_CHICANERY) && get_skill(ch, gsn_chicanery) > number_percent())
{
act( "You secretly put $p on $P.", ch, obj, container, TO_CHAR );
// hide them to mortals
int old_invis_level = ch->invis_level;
ch->invis_level = UMAX(ch->invis_level, LEVEL_IMMORTAL);
act( "$n puts $p on $P.[CHICANERY]", ch, obj, container, TO_ROOM );
ch->invis_level=old_invis_level;
check_improve(ch,gsn_chicanery,true,10);
}
else
{
act("$n puts $p on $P.",ch,obj,container, TO_ROOM);
act("You put $p on $P.",ch,obj,container, TO_CHAR);
}
}
else
{
if(IS_SET(ch->dyn2, DYN2_CHICANERY) && get_skill(ch, gsn_chicanery) > number_percent())
{
act( "You secretly put $p in $P.", ch, obj, container, TO_CHAR );
// hide them to mortals
int old_invis_level = ch->invis_level;
ch->invis_level = UMAX(ch->invis_level, LEVEL_IMMORTAL);
act( "$n puts $p on $P.[CHICANERY]", ch, obj, container, TO_ROOM );
ch->invis_level=old_invis_level;
check_improve(ch,gsn_chicanery,true,10);
}
else
{
act("$n puts $p in $P.",ch,obj,container, TO_ROOM);
act("You put $p in $P.",ch,obj,container, TO_CHAR);
}
}
}
else
{
// PC being ordered to do this
if ( !IS_NPC(ch) && IS_SET( ch->dyn, DYN_IS_BEING_ORDERED ))
{
if ( ch->master )
ch->master->println("Not going to happen.");
return;
}
// '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, OBJWEAR_TAKE) )
if (obj->timer)
SET_BIT(obj->extra_flags,OBJEXTRA_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[MIL];
OBJ_DATA *obj;
OBJ_DATA *obj_next;
bool found;
argument = one_argument( argument, arg );
if ( arg[0] == '\0' )
{
ch->println("Drop what?");
return;
}
// ooc rooms
if(!IS_IMMORTAL(ch) && IS_SET(ch->in_room->room_flags,ROOM_OOC)){
ch->println("Not in an OOC room.");
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") ) )
{
ch->println("Sorry, you can't do that.");
return;
}
if ( !str_cmp( arg, "coins") || !str_cmp(arg,"coin")
|| !str_cmp( arg, "silver"))
{
if (ch->silver < amount)
{
ch->println("You don't have that much silver.");
return;
}
ch->silver -= amount;
silver = amount;
}
else
{
if (ch->gold < amount)
{
ch->println("You don't have that much gold.");
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=create_money( gold, silver );
// record details for multilogging detection
if(!IS_NPC(ch)){
obj->lastdrop_id=ch->id;
replace_string(obj->lastdrop_remote_ip,ch->remote_ip_copy);
}
obj_to_room( obj, ch->in_room );
if(IS_SET(ch->dyn2, DYN2_CHICANERY) && get_skill(ch, gsn_chicanery) > number_percent())
{
act( "You secretly drop some coins.", ch, NULL, NULL, TO_CHAR );
// hide them to mortals
int old_invis_level = ch->invis_level;
ch->invis_level = UMAX(ch->invis_level, LEVEL_IMMORTAL);
act( "$n drops some coins.[CHICANERY]", ch, NULL, NULL, TO_ROOM );
ch->invis_level=old_invis_level;
check_improve(ch,gsn_chicanery,true,10);
}
else
{
ch->println( "OK." );
act( "$n drops some coins.", ch, NULL, NULL, TO_ROOM );
}
ch->println( "OK." );
return;
}
if ( str_cmp( arg, "all" ) && str_prefix( "all.", arg ) )
{
// 'drop obj'
if ( ( obj = get_obj_carry( ch, arg ) ) == NULL ){
ch->println( "You do not have that item." );
return;
}
if ( !can_drop_obj( ch, obj ) ){
ch->println( "You can't let go of it." );
return;
}
if ( IS_SET(ch->in_room->room2_flags, ROOM2_PC_SHOP_STORAGE) &&
!IS_SET(obj->extra2_flags, OBJEXTRA2_PC_CRAFTED))
{
ch->println( "You cannot place that item here to sell." );
return;
}
obj_from_char( obj );
// record details for multilogging detection
if(!IS_NPC(ch)){
obj->lastdrop_id=ch->id;
replace_string(obj->lastdrop_remote_ip, ch->remote_ip_copy);
}
obj_to_room( obj, ch->in_room );
if(IS_SET(ch->dyn2, DYN2_CHICANERY) && get_skill(ch, gsn_chicanery) > number_percent())
{
act( "You secretly drop $p.", ch, obj, NULL, TO_CHAR );
// hide them to mortals
int old_invis_level = ch->invis_level;
ch->invis_level = UMAX(ch->invis_level, LEVEL_IMMORTAL);
act( "$n drops $p.[CHICANERY]", ch, obj, NULL, TO_ROOM );
ch->invis_level=old_invis_level;
check_improve(ch,gsn_chicanery,true,10);
}
else
{
act( "$n drops $p.", ch, obj, NULL, TO_ROOM );
act( "You drop $p.", ch, obj, NULL, TO_CHAR );
}
if (IS_OBJ_STAT(obj,OBJEXTRA_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
{
// PC being ordered to do this
if ( !IS_NPC(ch) && IS_SET( ch->dyn, DYN_IS_BEING_ORDERED ))
{
if ( ch->master )
ch->master->println("Not going to happen.");
return;
}
// 'drop all' or 'drop all.obj'
found = false;
if ( IS_SET(ch->in_room->room2_flags, ROOM2_PC_SHOP_STORAGE))
{
ch->println( "You must drop them individually." );
return;
}
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 );
// record details for multilogging detection
if(!IS_NPC(ch)){
obj->lastdrop_id=ch->id;
replace_string(obj->lastdrop_remote_ip, ch->remote_ip_copy);
}
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,OBJEXTRA_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_new( char_data *ch, char *argument, int silent)
{
char arg1 [MIL];
char arg2 [MIL];
char buf[MSL];
char_data *victim;
OBJ_DATA *obj;
argument = one_argument( argument, arg1 ); // what
argument = one_argument( argument, arg2 ); // whom
// display the help if they don't give enough arguments
if ( IS_NULLSTR(arg1) || IS_NULLSTR(arg2) )
{
ch->println("");
if(!IS_NULLSTR(arg1) && IS_NULLSTR(arg2)){
ch->printlnf("Give '%s' to who?", arg1);
}else{
ch->println( "Give what to whom?");
}
ch->println("");
ch->titlebar( "Giving Objects");
ch->println( "Syntax: give <object/what> [to] <person/creature>");
ch->println( "e.g. typing 'give sword guard'");
ch->println( " - will give a sword to a guard, (assuming you are carrying one).");
ch->println( "note: the word 'to' is optional in the give command.");
ch->titlebar( "Giving Currency");
// 'give NNNN coins [to] victim'
ch->println( "Syntax: give <amount> gold [to] <person/creature>");
ch->println( "e.g. typing 'give 15 silver guard'");
ch->println( " - will give 15 of your silver coins to a guard.");
ch->println( "e.g. typing 'give 2 gold guard'");
ch->println( " - will give 2 of your gold coins to a guard.");
ch->println( "note: 1 gold is worth 10 silver.");
ch->titlebar( "");
return;
}
// ooc rooms
if(!IS_IMMORTAL(ch) && IS_SET(ch->in_room->room_flags,ROOM_OOC)){
ch->println("Not in an OOC room, you can only give objects within the main game realm.");
return;
}
if ( is_number( arg1 ) )
{
// 'give NNNN coins [to] 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")) )
{
ch->println("Sorry, you can't do that.");
return;
}
silver = str_cmp(arg2,"gold");
argument = one_argument( argument, arg2 );
if ( IS_NULLSTR(arg2))
{
ch->printlnf( "Give %d %s to whom?", amount, silver?"silver":"gold" );
return;
}
// using optional 'to' in give command
if(!str_cmp("to", arg2)){
argument = one_argument( argument, arg2 );
}
// find they person they are giving to
if ( ( victim = get_char_room( ch, arg2 ) ) == NULL )
{
ch->printlnf( "You can't seem to find any '%s' here to give %d %s to.",
arg2, amount, silver?"silver":"gold");
return;
}
if(victim==ch){
ch->printlnf("What would be the purpose of giving %d %s to yourself when you already have it?",
amount, silver?"silver":"gold");
return;
}
if (IS_NPC(victim) && IS_SET(victim->act,ACT_IS_CHANGER))
{
// check that the money changer can see them
if(!can_see(victim,ch)){
ch->println("They can't see you to give you your change.");
return;
}
// check that the money changer isn't subdued
if (victim->subdued){
ch->println("They don't appear to be in a state to exchange your money.");
return;
}
// sleeping
if (!IS_AWAKE(victim)){
ch->printlnf( "%s is sleeping and can not change your money right now.", PERS(victim, ch));
return;
}
}
if ( (!silver && ch->gold < amount) || (silver && ch->silver < amount) )
{
ch->printlnf( "You haven't got %d %s to give!", amount, silver?"silver":"gold");
return;
}
// make sure victim can carry that much money
if (get_carry_weight(victim) +
(silver ? get_silver_weight(amount) : get_gold_weight(amount))
> can_carry_w( victim ) )
{
act( "$N can't carry that much weight.",
ch, NULL, victim, TO_CHAR );
return;
}
// record details for multilogging detection
if( !IS_NPC(ch)
&& !HAS_CONFIG(ch, CONFIG_IGNORE_MULTILOGINS)
&& !IS_NPC(victim)
&& !HAS_CONFIG(victim, CONFIG_IGNORE_MULTILOGINS)
)
{
if(!strcmp(ch->remote_ip_copy,victim->remote_ip_copy)){
multilog_alertf(victim, "`C%s<%d>`B(id=%d) `xgiving %s%d %s`x to `Y%s<%d>`x (room %d), both from same IP!",
ch->name,
ch->level,
(int)ch->id,
silver?"`S":"`Y",
amount,
silver?"silver":"gold",
victim->name,
victim->level,
ch->in_room_vnum());
ch->printlnf("#`YExchanging money between your PC's or someone from your site is illegal!!!`^");
ch->printlnf("#`RAll your money is forfeit!!!`^");
ch->gold = 0;
ch->silver = 0;
ch->bank = 0;
victim->gold = 0;
victim->silver = 0;
victim->bank = 0;
return;
}
}
// exchange the money
if (silver){
ch->silver -= amount;
victim->silver += amount;
}else{
ch->gold -= amount;
victim->gold += amount;
}
if (silent){
sprintf(buf, "SILENTGIVE: %s gives %s %d %s.", ch->name , victim->name, amount, silver ? "silver" : "gold");
wiznet(buf,ch,NULL,WIZ_SECURE,0,get_trust(ch));
sprintf(buf,"You SILENTLY give $N %d %s.",amount, silver ? "silver" : "gold");
act( buf, ch, NULL, victim, TO_CHAR );
}else{
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 );
// Bribe trigger
if ( IS_NPC(victim) && HAS_TRIGGER( victim, TRIG_BRIBE ) ){
mp_bribe_trigger( victim, ch, silver ? amount : amount * 100 );
limit_mobile_wealth(victim);
}
}
// handle money changers giving money back
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);
sprintf(buf,"%d %s %s",
amount, silver ? "silver" : "gold",ch->name);
do_give_new(victim,buf, silent);
}
else if (can_see(victim,ch))
{
sprintf(buf,"%d %s %s",
change, silver ? "gold" : "silver",ch->name);
do_give_new(victim,buf, silent);
if (silver)
{
sprintf(buf,"%d silver %s",
(95 * amount / 100 - change * 100),ch->name);
do_give_new(victim,buf, silent);
}
act("$n tells you 'Thank you, come again.'", victim,NULL,ch,TO_VICT);
limit_mobile_wealth(victim);
}
}
return;
} // end of code which deals with giving money
// === GIVING OBJECTS CODE
// give <object> [to] <victim>
// using optional 'to' in give command
if(!str_cmp("to", arg2)){
argument = one_argument( argument, arg2 );
}
// find the object
if ( ( obj = get_obj_carry( ch, arg1 ) ) == NULL )
{
ch->printlnf( "You are not carrying any '%s' to give to '%s'.", arg1, arg2 );
return;
}
if ( obj->wear_loc != WEAR_NONE )
{
ch->printlnf( "You are currently using '%s', you must remove it before giving it to '%s'.", obj->short_descr, arg2 );
return;
}
// find the victim to receive the item
if ( ( victim = get_char_room( ch, arg2 ) ) == NULL ) {
ch->printlnf( "You can't seem to find any '%s' here to give '%s' to.", arg2, obj->short_descr);
return;
}
if(victim==ch){
ch->printlnf("What would be the purpose of giving %s to yourself?", obj->short_descr);
return;
}
if (IS_NPC(victim) && victim->pIndexData->pShop != NULL)
{
// if they are a shop keeper without a give trigger which
// would catch the object, don't accept the item
if(!mp_would_run_give_trigger(victim, ch, obj )){
act("$N tells you 'Sorry, you'll have to sell that.'", ch,NULL,victim,TO_CHAR);
return;
}
}
if ( !can_drop_obj( ch, obj ) )
{
ch->printlnf( "You can't let go of %s.", obj->short_descr );
return;
}
// Clan Gear Items - Ixliam
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && (obj->pIndexData->clan != NULL))
{
if (obj->pIndexData->clan != ch->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
} else
if (obj->pIndexData->clan != victim->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
}
}
if (IS_SET(obj->extra2_flags, OBJEXTRA2_RUNIC) && obj->level > ch->level)
{
act( "$n is struck with lightning as they try to get $p.", ch, obj, NULL, TO_ROOM );
ch->printf( "You are struck by lightning when you touch %s.\r\n", obj->short_descr );
ch->printf( "%s is to powerful for you to handle.\r\n", obj->short_descr );
obj_from_char( obj );
obj_to_room(obj,ch->in_room);
return;
}
if ( !IS_CONTROLLED(victim) && victim->carry_number + get_obj_number( obj ) > can_carry_n( victim ) )
{
act( "$N has $S hands full.", ch, NULL, victim, TO_CHAR );
return;
}
if (!IS_CONTROLLED(victim) && 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( FORMATF("$N can't seem to see %s.", obj->short_descr), ch, NULL, victim, TO_CHAR );
return;
}
if (IS_SET(obj->extra2_flags, OBJEXTRA2_RUNIC) && obj->level > victim->level)
{
act( "$n is struck with lightning as they try to get $p.", victim, obj, NULL, TO_ROOM );
victim->printf( "You are struck by lightning when you touch %s.\r\n", obj->short_descr );
victim->printf( "%s is to powerful for you to handle.\r\n", obj->short_descr );
obj_from_char( obj );
obj_to_room(obj,ch->in_room);
return;
}
obj_from_char( obj );
// check lastgive details for multilogging detection
if(!IS_NPC(victim)
&& !HAS_CONFIG(ch, CONFIG_IGNORE_MULTILOGINS)
&& !HAS_CONFIG(victim, CONFIG_IGNORE_MULTILOGINS)){
// player giving objects to itself via another player or mob
if( obj->lastdrop_id!=victim->id
&& !strcmp(obj->lastdrop_remote_ip, victim->remote_ip_copy))
{
multilog_alertf(victim, "`M%s<%d>`x giving `Gobject '%s' (%d)`x to `Y%s<%d>`x (room %d), which was recently given to "
"`M%s`x by `Bsomeone (id=%d)`x other than `Y%s`x from the same ip as `Y%s!`x",
ch->name,
ch->level,
obj->short_descr,
obj->pIndexData?obj->pIndexData->vnum:0,
victim->name,
victim->level,
ch->in_room_vnum(),
ch->name,
(int)obj->lastdrop_id,
victim->name,
victim->name);
char mbuf [MSL];
sprintf(mbuf, "`#`Y%s has been removed for being a multilog item. `RDO NOT MULTI ITEMS!!!`^", obj->short_descr);
ch->printlnf(mbuf);
extract_obj( obj );
return;
// player giving directly to another of their players
}else if(!strcmp(ch->remote_ip_copy, victim->remote_ip_copy)){
multilog_alertf(ch, "`C%s<%d>`B(id=%d) `xgiving `Gobject '%s' (%d) `xto `Y%s<%d>`x (room%d) - object exchange between players from the same IP!",
ch->name,
ch->level,
(int)ch->id,
obj->short_descr,
obj->pIndexData?obj->pIndexData->vnum:0,
victim->name,
victim->level,
ch->in_room_vnum());
char mbuf [MSL];
sprintf(mbuf, "`#`Y%s has been removed for being a multilog item. `RDO NOT MULTI ITEMS!!!`^", obj->short_descr);
ch->printlnf(mbuf);
extract_obj( obj );
return;
}
}
// record host of giver on object if not a mob
if(!IS_NPC(ch)){
obj->lastdrop_id=ch->id;
replace_string(obj->lastdrop_remote_ip, ch->remote_ip_copy);
}
obj_to_char( obj, victim );
if (silent)
{
sprintf(buf, "SILENTGIVE: %s gives %s to %s.", ch->name, obj->short_descr, victim->name);
wiznet(buf,ch,NULL,WIZ_SECURE,0,get_trust(ch));
act( "You SILENTLY give $p to $N.", ch, obj, victim, TO_CHAR );
}
else
{
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;
if(obj->ospec_fun == ospec_lookup("ospec_thought_sharer")
&& !IS_NPC(ch)
&& !IS_NPC(victim))
{
act("$p glows as it is passed from $n to $N", ch, obj, victim, TO_NOTVICT);
act( "As $n gives you $p it glows for a moment.", ch, obj, victim, TO_VICT );
act( "As you give $p to $N it glows for a moment.", ch, obj, victim, TO_CHAR );
ospec_thought_sharer(obj, ch);
}
}
// Give mobprog trigger
if ( IS_NPC(victim) && HAS_TRIGGER( victim, TRIG_GIVE ) ){
mp_give_trigger( victim, ch, obj );
}
}
// normal give
void do_give( char_data *ch, char *argument )
{
do_give_new(ch, argument, false);
}
// silent give
void do_sgive( char_data *ch, char *argument )
{
do_give_new(ch, argument, true);
}
/************************************************************************/
/*
* Take stuff and money from subdued or sleeping characters
* Written by Quenralther and Kalahn - Dec 97
*/
void do_grab( char_data *ch, char *argument )
{
char arg1 [MIL];
char arg2 [MIL];
char buf[MSL];
char_data *victim;
OBJ_DATA *obj;
int random;
if( IS_OOC(ch) )
{ ch->println("You may not use grab in an ooc area."); return; }
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if ( arg1[0] == '\0' || arg2[0] == '\0' )
{
ch->println("Take what from whom?");
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")) )
{
ch->println("Sorry, you can't do that.");
return;
}
silver = str_cmp(arg2,"gold");
argument = one_argument( argument, arg2 );
if ( arg2[0] == '\0' )
{
ch->println("Take what from whom?");
return;
}
if ( ( victim = get_char_room( ch, arg2 ) ) == NULL )
{
ch->println("They aren't here.");
return;
}
if IS_AWAKE(victim)
{
ch->println("You can't grab stuff from someone who's awake.");
return;
}
if (IS_IMMORTAL(victim))
{
ch->println("You failed.");
return;
}
if (is_safe(ch,victim))
{
return;
}
#ifdef unix
if (!IS_IMMORTAL(ch))
{
WAIT_STATE( ch, PULSE_VIOLENCE );
}
#endif
if ((victim->position == POS_SLEEPING
&& !IS_IMMORTAL(ch)
&& (!IS_AFFECTED(victim, AFF_SLEEP)
|| (!is_same_group(ch, victim) && number_range(1,5)==1)
|| number_range(1,15)==1)
)
|| (victim->position<=POS_SLEEPING && IS_KEEPER(victim) && !IS_IMMORTAL(ch))
)
{
random = dice(1,100);
if (IS_KEEPER(victim)
|| ( random < 70 + victim->level-ch->level-ch->modifiers[STAT_QU]/5
+ victim->modifiers[STAT_IN]/5) )
{
// remove sleep spell if necessary
if ( IS_AFFECTED(ch, AFF_SLEEP) ){
affect_strip( ch, gsn_sleep );
}
victim->position = POS_RESTING;
act("$n tried to take some coins from $N, who wakes up.",ch,NULL,victim,TO_NOTVICT );
act("You are awakened by $N trying to take some coins from you.",victim,NULL,ch,TO_CHAR);
act("Your attempts have woken $N!",ch,NULL,victim,TO_CHAR);
// wiznet thefts messages
sprintf(buf,"$N <%d> tried to grab %d coins from %s <%d> and woke them up!",
ch->level, amount, victim->name, victim->level);
wiznet(buf,ch,NULL,WIZ_THEFTS,0,0);
return;
}
random = dice(1,100);
if ( random < 75-ch->level+victim->level )
{
act("$n couldn't manage to pry any coins away from $N.",ch,NULL,victim,TO_NOTVICT );
act("You couldn't manage to pry any coins away from $N.",ch,NULL,victim,TO_CHAR);
// wiznet thefts message
sprintf(buf,"$N tried to grab %d coins from %s <%d> and failed.",
amount, victim->name, victim->level);
wiznet(buf,ch,NULL,WIZ_THEFTS,0,0);
return;
}
} // endif they are in the sleeping position... if they are below that you can
// always take everything
if (!silver && victim->gold < amount)
{
amount = victim->gold;
// wiznet thefts messages
sprintf(buf,"$N <%d> took using grab %d gold coins from %s <%d>.",
ch->level, amount, victim->name, victim->level);
wiznet(buf,ch,NULL,WIZ_THEFTS,0,0);
}
if (silver && victim->silver < amount)
{
amount = victim->silver;
// wiznet thefts messages
sprintf(buf,"$N <%d> took using grab %d silver coins from %s <%d>.",
ch->level, amount, victim->name, victim->level);
wiznet(buf,ch,NULL,WIZ_THEFTS,0,0);
return;
}
if (silver)
{
victim->silver -= amount;
ch->silver += amount;
}
else
{
victim->gold -= amount;
ch->gold += amount;
}
if (victim->position > POS_SLEEPING)
{
act( "$n took some coins from you.", ch, NULL, victim, TO_VICT);
}
act( "$n takes some coins from $N.", ch, NULL, victim, TO_NOTVICT );
sprintf(buf,"You take %d %s from $N.",amount, silver ? "silver" : "gold");
act( buf, ch, NULL, victim, TO_CHAR );
return;
} // end of coins
if ( ( victim = get_char_room( ch, arg2 ) ) == NULL )
{
ch->println("They aren't here.");
return;
}
if (IS_AWAKE(victim))
{
ch->println("You can't grab stuff from someone who's awake.");
return;
}
if (IS_IMMORTAL(victim))
{
ch->println("You failed.");
return;
}
obj = get_obj_carry_for_looker( victim, arg1, ch ); // find the object in victims inventory
if ( !obj) // not in their inventory check if they are wearing it
{
if ((obj = get_obj_wear(victim, arg1)) != NULL)
{
if ( IS_SET(obj->extra_flags, OBJEXTRA_NOREMOVE ))
{
ch->println("You can't wrench it away...it's stuck somehow.");
return;
}
}
}
if (!obj) // check if nothing was found
{
ch->println("You can't find that item on their person.");
return;
}
#ifdef unix
if (!IS_IMMORTAL(ch))
{
WAIT_STATE( ch, PULSE_VIOLENCE );
}
#endif
if ((victim->position == POS_SLEEPING
&& !IS_IMMORTAL(ch)
&& (!IS_AFFECTED(victim, AFF_SLEEP)
|| (!is_same_group(ch, victim) && number_range(1,5)==1)
|| number_range(1,15)==1)
)
|| (victim->position<=POS_SLEEPING && IS_KEEPER(victim) && !IS_IMMORTAL(ch))
)
{
random = dice(1,100);
if (IS_KEEPER(victim)
||( random < 90 + victim->level - ch->level
- ch->modifiers[STAT_AG]/10+victim->modifiers[STAT_IN]/5 )
)
{
/*
if ( victim->position == POS_SLEEPING
&& (!IS_AFFECTED(victim, AFF_SLEEP)
|| (!is_same_group(ch, victim) && number_range(1,5)==1)
|| number_range(1,15)==1
)
)
{
random = dice(1,100);
if ( random < 90 + victim->level - ch->level
- ch->modifiers[STAT_AG]/10+victim->modifiers[STAT_IN]/5 )
{
*/
victim->position = POS_RESTING;
act("$n tried to take something from $N, who wakes up.",ch,NULL,victim,TO_NOTVICT );
act("You are awakened by $N trying to take something from you.",victim,NULL,ch,TO_CHAR);
act("Your attempts have woken $N!",ch,NULL,victim,TO_CHAR);
// wiznet thefts messages
sprintf(buf,"$N <%d> tried to grab $p from %s <%d> and woke them up!",
ch->level, victim->name, victim->level);
wiznet(buf,ch, obj,WIZ_THEFTS,0,0);
return;
}
random = dice(1,100);
if ( random < 100-ch->level+victim->level-ch->modifiers[STAT_ST]/5+victim->modifiers[STAT_ST]/5 )
{
act("$n couldn't manage to pry anything away from $N.",ch,NULL,victim,TO_NOTVICT );
act("You couldn't manage to pry anything away from $N.",ch,NULL,victim,TO_CHAR);
// wiznet thefts messages
sprintf(buf,"$N <%d> tried to grab $p from %s <%d> but failed to get it!",
ch->level, victim->name, victim->level);
wiznet(buf,ch, obj,WIZ_THEFTS,0,0);
return;
}
}
if (is_safe(ch,victim))
{
return;
}
if ( !can_drop_obj( victim, obj ) )
{
ch->println("You can't wrench it away...it's stuck somehow.");
// wiznet thefts messages
sprintf(buf,"$N <%d> tried to grab $p from %s <%d> but couldn't wrench it away.",
ch->level, victim->name, victim->level);
wiznet(buf,ch, obj,WIZ_THEFTS,0,0);
return;
}
if ( ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) )
{
ch->println("You have your hands full.");
return;
}
if ( ch->carry_weight + get_obj_weight( obj ) > can_carry_w( ch ) )
{
ch->println("You can't carry that much weight.");
return;
}
// Clan Gear Items - Ixliam
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && (obj->pIndexData->clan != NULL))
{
if (obj->pIndexData->clan != ch->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
} else
if (obj->pIndexData->clan != victim->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
}
}
if (IS_SET(obj->extra2_flags, OBJEXTRA2_RUNIC) && obj->level > ch->level)
{
act( "$n is struck with lightning as they try to grab $p.", ch, obj, NULL, TO_ROOM );
ch->printf( "You are struck by lightning when you touch %s.\r\n", obj->short_descr );
ch->printf( "%s is to powerful for you to handle.\r\n", obj->short_descr );
return;
}
// object exchanges hands now
obj_from_char( obj );
obj_to_char( obj, ch );
act( "$n takes $p from $N.", ch, obj, victim, TO_NOTVICT );
if ( victim->position > POS_SLEEPING )
{
act( "$n takes $p from you.", ch, obj, victim, TO_VICT );
}
act( "You take $p from $N.", ch, obj, victim, TO_CHAR );
// wiznet thefts messages
sprintf(buf,"$N <%d> grabbed $p from %s <%d> successfully.",
ch->level, victim->name, victim->level);
wiznet(buf,ch, obj,WIZ_THEFTS,0,0);
return;
}
/************************************************************************/
/* for poisoning weapons and food/drink */
void do_envenom(char_data *ch, char *argument)
{
OBJ_DATA *obj;
AFFECT_DATA af;
int percent,skill;
/* find out what */
if (IS_NULLSTR(argument))
{
ch->println("Envenom what item?");
return;
}
obj = get_obj_list(ch,argument,ch->carrying);
if (obj== NULL)
{
ch->println("You don't have that item.");
return;
}
if ((skill = get_skill(ch,gsn_envenom)) < 1)
{
ch->println("Are you crazy? You'd poison yourself!");
return;
}
if (obj->item_type == ITEM_FOOD || obj->item_type == ITEM_DRINK_CON)
{
if (number_percent() < skill) // success!
{
act("$n treats $p with deadly poison.",ch,obj,NULL,TO_ROOM);
act("You treat $p with deadly poison.",ch,obj,NULL,TO_CHAR);
if ((obj->item_type == ITEM_FOOD || obj->item_type == ITEM_DRINK_CON)
&& obj->value[3] == 0)
{
SET_BIT(obj->value[3], FOOD_POISONED);
check_improve(ch,gsn_envenom,true,4);
}
WAIT_STATE(ch,skill_table[gsn_envenom].beats);
return;
}
act("You fail to poison $p.",ch,obj,NULL,TO_CHAR);
if (!obj->value[3])
{
check_improve(ch,gsn_envenom,false,4);
}
WAIT_STATE(ch,skill_table[gsn_envenom].beats);
return;
}
if ( obj->item_type == ITEM_WEAPON )
{
if (IS_WEAPON_STAT( obj,WEAPON_FLAMING )
|| IS_WEAPON_STAT( obj,WEAPON_FROST )
|| IS_WEAPON_STAT( obj,WEAPON_VAMPIRIC )
|| IS_WEAPON_STAT( obj,WEAPON_SHOCKING )
|| IS_WEAPON_STAT( obj,WEAPON_HOLY ))
{
act("You can't seem to envenom $p.",ch,obj,NULL,TO_CHAR);
return;
}
if (obj->value[3] < 0
|| attack_table[obj->value[3]].damage == DAM_BASH)
{
ch->println("You can only envenom edged weapons.");
return;
}
if (IS_WEAPON_STAT(obj,WEAPON_POISON))
{
act("$p is already envenomed.",ch,obj,NULL,TO_CHAR);
return;
}
percent = number_percent();
if (percent < skill)
{
af.where = WHERE_WEAPON;
af.type = gsn_poison;
af.level = ch->level;
af.duration = ch->level / 4;
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = WEAPON_POISON;
affect_to_obj(obj,&af);
act("$n coats $p with deadly venom.",ch,obj,NULL,TO_ROOM);
act("You coat $p with venom.",ch,obj,NULL,TO_CHAR);
check_improve(ch,gsn_envenom,true,3);
WAIT_STATE(ch,skill_table[gsn_envenom].beats);
return;
}
else
{
act("You fail to envenom $p.",ch,obj,NULL,TO_CHAR);
check_improve(ch,gsn_envenom,false,3);
WAIT_STATE(ch,skill_table[gsn_envenom].beats);
return;
}
}
act("You can't poison $p.",ch,obj,NULL,TO_CHAR);
return;
}
/**************************************************************************/
void do_fill( char_data *ch, char *argument )
{
char arg[MIL];
char buf[MSL];
OBJ_DATA *obj;
OBJ_DATA *fountain;
bool found;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
ch->println("Fill what?");
return;
}
if ( ( obj = get_obj_carry( ch, arg ) ) == NULL )
{
ch->println("You do not have that item.");
return;
}
found = false;
for ( fountain = ch->in_room->contents; fountain != NULL;
fountain = fountain->next_content )
{
if ( fountain->item_type == ITEM_FOUNTAIN )
{
found = true;
break;
}
}
if ( !found )
{
ch->println("There is no fountain here!");
return;
}
// if the fountain is empty you shouldn't be able to fill a drinkcontainer
if ( fountain->value[1] == 0 )
{
act( "$p is empty.", ch, fountain, NULL, TO_CHAR );
return;
}
if ( obj->item_type != ITEM_DRINK_CON )
{
ch->println("You can't fill that.");
return;
}
if ( obj->value[1] != 0 && obj->value[2] != fountain->value[2] )
{
ch->println("There is already another liquid in it.");
return;
}
if ( obj->value[1] >= obj->value[0] )
{
ch->println("Your container is full.");
return;
}
// decrement the fountain by the fill amount
// if it isn't an infinite fountain
if(fountain->value[1]>=0){
fountain->value[1] -= (obj->value[0] - obj->value[1]);
// in case -1 is unlimited etc
if ( fountain->value[1] < 0 ){
fountain->value[1] = 0;
}
}
sprintf(buf,"You fill $p with %s from $P.",
liq_table[fountain->value[2]].liq_name);
act( buf, ch, obj,fountain, TO_CHAR );
sprintf(buf,"$n fills $p with %s from $P.",
liq_table[fountain->value[2]].liq_name);
act(buf,ch,obj,fountain,TO_ROOM);
obj->value[2] = fountain->value[2];
obj->value[1] = obj->value[0];
return;
}
/**************************************************************************/
void do_pour (char_data *ch, char *argument)
{
char arg[MSL],buf[MSL], outbuf[MSL];
OBJ_DATA *out, *in;
char_data *vch = NULL;
int amount;
argument = one_argument(argument,arg);
if (IS_NULLSTR(arg)|| IS_NULLSTR(argument))
{
ch->println("Pour what into what?");
ch->println("Note: to empty a liquid container type `=Cempty <container_name>`x");
return;
}
if ((out = get_obj_carry(ch,arg)) == NULL)
{
ch->println("You don't have that item." );
return;
}
if (out->item_type != ITEM_DRINK_CON)
{
ch->println("That's not a drink container." );
return;
}
sprintf(outbuf,argument);
one_argument(outbuf,outbuf);
if (!str_cmp(outbuf,"out"))
{
if (out->value[1] == 0)
{
ch->println("It's already empty." );
return;
}
out->value[1] = 0;
out->value[3] = 0;
sprintf(buf,"You invert $p, spilling %s all over the ground.",
liq_table[out->value[2]].liq_name);
act(buf,ch,out,NULL,TO_CHAR);
sprintf(buf,"$n inverts $p, spilling %s all over the ground.",
liq_table[out->value[2]].liq_name);
act(buf,ch,out,NULL,TO_ROOM);
return;
}
if ((in = get_obj_here(ch,argument)) == NULL)
{
vch = get_char_room(ch,argument);
if (vch == NULL)
{
ch->println("Pour into what?" );
return;
}
in = get_eq_char(vch,WEAR_HOLD);
if (in == NULL)
{
ch->println("They aren't holding anything." );
return;
}
}
if (in->item_type != ITEM_DRINK_CON)
{
ch->println("You can only pour into other drink containers." );
return;
}
if (in == out)
{
ch->println("You cannot change the laws of physics!");
return;
}
if (in->value[1] != 0 && in->value[2] != out->value[2])
{
ch->println("They don't hold the same liquid.");
return;
}
if (out->value[1] == 0)
{
act("There's nothing in $p to pour.",ch,out,NULL,TO_CHAR);
return;
}
if (in->value[1] >= in->value[0])
{
act("$p is already filled to the top.",ch,in,NULL,TO_CHAR);
return;
}
amount = UMIN(out->value[1],in->value[0] - in->value[1]);
in->value[1] += amount;
out->value[1] -= amount;
in->value[2] = out->value[2];
if (vch == NULL)
{
sprintf(buf,"You pour %s from $p into $P.",
liq_table[out->value[2]].liq_name);
act(buf,ch,out,in,TO_CHAR);
sprintf(buf,"$n pours %s from $p into $P.",
liq_table[out->value[2]].liq_name);
act(buf,ch,out,in,TO_ROOM);
}
else
{
sprintf(buf,"You pour some %s for $N.",
liq_table[out->value[2]].liq_name);
act(buf,ch,NULL,vch,TO_CHAR);
sprintf(buf,"$n pours you some %s.",
liq_table[out->value[2]].liq_name);
act(buf,ch,NULL,vch,TO_VICT);
sprintf(buf,"$n pours some %s for $N.",
liq_table[out->value[2]].liq_name);
act(buf,ch,NULL,vch,TO_NOTVICT);
}
}
/**************************************************************************/
void do_drink( char_data *ch, char *argument )
{
char arg[MIL];
OBJ_DATA *obj;
int amount;
int liquid;
int max_liq;
for(max_liq=0; !IS_NULLSTR(liq_table[max_liq].liq_name); max_liq++){
}
max_liq--;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
for ( obj = ch->in_room->contents; obj; obj = obj->next_content )
{
if ( obj->item_type == ITEM_FOUNTAIN )
break;
}
if ( obj == NULL )
{
ch->println( "Drink what?" );
return;
}
}
else
{
if ( ( obj = get_obj_here( ch, arg ) ) == NULL )
{
ch->println( "You can't find it." );
return;
}
}
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_DRUNK] > 10 )
{
ch->println( "You fail to reach your mouth. *Hic*" );
return;
}
switch ( obj->item_type )
{
default:
ch->println( "You can't drink from that." );
return;
case ITEM_FOUNTAIN:
case ITEM_DRINK_CON:
if ( obj->value[1]== 0 ){
ch->println( "It is already empty." );
return;
}
liquid = obj->value[2];
if ( liquid < 0 || liquid>max_liq)
{
bugf( "Do_drink: bad liquid number %d.", liquid );
autonote(NOTE_SNOTE, "do_drink()", "bad liquid number", "imm",
FORMATF("Do_drink: bad liquid number %d, on object %d (%s), value reset to 0..",
liquid, obj->pIndexData?obj->pIndexData->vnum:0, obj->short_descr ), true);
liquid = obj->value[2] = 0;
}
amount = liq_table[liquid].liq_affect[4];
if(obj->item_type==ITEM_FOUNTAIN){ // naturally drink more from a fountain
amount*=3;
}
amount = UMIN(amount, (obj->value[1] < 0 ? amount : obj->value[1]));
break;
}
if ( (strstr(liq_table[liquid].liq_name, "blood")) && IS_VAMPIRE(ch))
{
if(ch->vampgen == 13 && ch->bloodpool >= 20)
{
ch->bloodpool = 20;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 12 && ch->bloodpool >= 30)
{
ch->bloodpool = 30;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 11 && ch->bloodpool >= 40)
{
ch->bloodpool = 40;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 10 && ch->bloodpool >= 50)
{
ch->bloodpool = 50;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 9 && ch->bloodpool >= 60)
{
ch->bloodpool = 60;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 8 && ch->bloodpool >= 70)
{
ch->bloodpool = 70;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 7 && ch->bloodpool >= 80)
{
ch->bloodpool = 80;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 6 && ch->bloodpool >= 90)
{
ch->bloodpool = 90;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 5 && ch->bloodpool >= 100)
{
ch->bloodpool = 100;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 4 && ch->bloodpool >= 125)
{
ch->bloodpool = 125;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 3 && ch->bloodpool >= 150)
{
ch->bloodpool = 150;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 2 && ch->bloodpool >= 175)
{
ch->bloodpool = 175;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
} else
if(ch->vampgen == 1 && ch->bloodpool >= 200)
{
ch->bloodpool = 200;
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
{
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
}
ch->bloodpool += 1;
gain_condition( ch, COND_THIRST, 10 );
ch->println( "The blood feels like liquid fire going down your throat." );
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
ch->printlnf( "Your thirst for blood is quenched." );
if(obj->value[1]>0)
obj->value[1] -= amount;
return;
}
else if( IS_VAMPIRE(ch))
{
ch->println( "You can only drink blood." );
return;
}
if (!IS_NPC(ch) && !IS_IMMORTAL(ch)
&& ch->pcdata->condition[COND_FULL] > 45)
{
ch->println( "You're too full to drink more." );
return;
}
act( "$n drinks $T from $p.",
ch, obj, liq_table[liquid].liq_name, TO_ROOM );
act( "You drink $T from $p.",
ch, obj, liq_table[liquid].liq_name, TO_CHAR );
// Kalahn Drink Fix
if(obj->value[1]>=0){
amount = UMIN(amount, obj->value[1]);
}
gain_condition( ch, COND_DRUNK,
amount * liq_table[liquid].liq_affect[COND_DRUNK] / 36 );
gain_condition( ch, COND_FULL,
amount * liq_table[liquid].liq_affect[COND_FULL] / 7 );
gain_condition( ch, COND_THIRST,
amount * liq_table[liquid].liq_affect[COND_THIRST] / 10 );
gain_condition(ch, COND_HUNGER,
amount * liq_table[liquid].liq_affect[COND_HUNGER] / 2 );
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_DRUNK] > 10 )
ch->println("You feel drunk.");
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_FULL] > 40 )
ch->println("You are full.");
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_THIRST] > 40 )
ch->println("Your thirst is quenched.");
//ospec_blessed_chalice
if(obj->ospec_fun == ospec_lookup("ospec_blessed_chalice"))
ospec_blessed_chalice(obj, ch);
if ( IS_SET(obj->value[3], FOOD_POISONED)
&& !HAS_CLASSFLAG(ch, CLASSFLAG_POISON_IMMUNITY)
)
{
// The drink was poisoned!
AFFECT_DATA af;
act( "$n chokes and gags.", ch, NULL, NULL, TO_ROOM );
ch->println("You choke and gag.");
af.where = WHERE_AFFECTS;
af.type = gsn_poison;
af.level = number_fuzzy(amount);
af.duration = 3 * amount;
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = AFF_POISON;
affect_join( ch, &af );
}
// containers with -1 are infinite, so don't remove the amount.
if(obj->value[1]>0){
obj->value[1] -= amount;
// remove the poison if it is emptied
if(obj->value[1]<=0){
obj->value[3]=0;
obj->value[1]=0;
}
}
}
/**************************************************************************/
void do_eat( char_data *ch, char *argument )
{
char arg[MIL];
OBJ_DATA *obj;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
ch->println("Eat what?");
return;
}
if ( ( obj = get_obj_carry( ch, arg ) ) == NULL )
{
ch->println("You do not have that item.");
return;
}
if ( ch->level<LEVEL_IMMORTAL )
{
if ( (ch->race == race_lookup("thri-kreen") ||
ch->race == race_lookup("dragon") ||
ch->race == race_lookup("beholder") ||
IS_SET(ch->wish, WISH_EATALL) ||
ch->race == race_lookup("illithid")) &&
obj->item_type != ITEM_FOOD &&
obj->item_type != ITEM_CORPSE_NPC &&
obj->item_type != ITEM_PILL )
{
ch->printlnf( "That's not edible." );
return;
}
if ( ch->race != race_lookup("thri-kreen") &&
ch->race != race_lookup("dragon") &&
ch->race != race_lookup("beholder") &&
ch->race != race_lookup("illithid") &&
!IS_SET(ch->wish, WISH_EATALL) &&
obj->item_type != ITEM_FOOD && obj->item_type != ITEM_PILL )
{
ch->println("That's not edible.");
return;
}
if ( !IS_NPC(ch) && ch->pcdata->condition[COND_FULL] > 40
&& obj->value[0]!=0 && obj->value[1]!=0 )
{
ch->println("You are too full to eat more.");
return;
}
}
if (ch->race == race_lookup("illithid") && obj->item_type == ITEM_CORPSE_NPC)
{
act( "$n tentacles reach down and suck the brain from $p.", ch, obj, NULL, TO_ROOM );
act( "You suck the brain from $p.", ch, obj, NULL, TO_CHAR );
}
else
{
act( "$n eats $p.", ch, obj, NULL, TO_ROOM );
act( "You eat $p.", ch, obj, NULL, TO_CHAR );
}
switch ( obj->item_type )
{
case ITEM_CORPSE_NPC:
if ( !IS_NPC(ch) &&
(ch->race == race_lookup("thri-kreen") ||
ch->race == race_lookup("dragon") ||
ch->race == race_lookup("beholder") ||
ch->race == race_lookup("illithid") ))
{
int condition;
condition = ch->pcdata->condition[COND_HUNGER];
gain_condition( ch, COND_HUNGER, 20 );
gain_condition( ch, COND_FULL, 30);
if ( condition == 0 && ch->pcdata->condition[COND_HUNGER] > 0 )
ch->printlnf( "You are no longer hungry." );
else if ( ch->pcdata->condition[COND_FULL] > 40 )
ch->printlnf( "You are full." );
}
break;
case ITEM_FOOD:
if ( !IS_NPC(ch) )
{
int condition;
condition = ch->pcdata->condition[COND_HUNGER];
if ( IS_SET(obj->value[3], FOOD_CONSECRATED))
{
gain_condition(ch, COND_HUNGER, (obj->value[0] / 2));
gain_condition(ch, COND_HUNGER, (obj->value[1] / 2));
ch->pcdata->tired=UMAX(ch->pcdata->tired - number_range(1, 3), 0);
ch->move+=number_range(1, obj->level/2);
}
if ( IS_SET(obj->value[3], FOOD_JUICY))
{
gain_condition(ch, COND_HUNGER, obj->value[0]);
gain_condition( ch, COND_THIRST, obj->value[0]);
gain_condition( ch, COND_FULL, obj->value[1]);
}
gain_condition( ch, COND_HUNGER, obj->value[0] );
gain_condition( ch, COND_FULL, obj->value[1]);
if ( condition == 0 && ch->pcdata->condition[COND_HUNGER] > 0 )
ch->println("You are no longer hungry.");
else if ( ch->pcdata->condition[COND_FULL] > 40 )
ch->println("You are full.");
}
if ( IS_SET(obj->value[3], FOOD_POISONED)
&& !HAS_CLASSFLAG(ch, CLASSFLAG_POISON_IMMUNITY))
{
// The food was poisoned!- do a saving throw
if ( saves_spell( number_fuzzy(obj->value[0])*2, ch, DAM_POISON))
{
act( "$n turns pale for a moment.", ch, 0, 0, TO_ROOM );
ch->println("You feel a little sick for a moment but it passes.");
}else{
AFFECT_DATA af;
act( "$n chokes and gags.", ch, 0, 0, TO_ROOM );
ch->println("You choke and gag.");
af.where = WHERE_AFFECTS;
af.type = gsn_poison;
af.level = number_fuzzy(obj->value[0]);
af.duration = 2 * obj->value[0];
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = AFF_POISON;
affect_join( ch, &af );
}
}
break;
case ITEM_PILL:
if ( IS_SET( ch->in_room->room_flags, ROOM_ANTIMAGIC )) {
ch->println("Nothing seemed to happen.");
extract_obj( obj );
return;
}
obj_cast_spell( obj->value[1], obj->value[0], ch, ch, NULL );
obj_cast_spell( obj->value[2], obj->value[0], ch, ch, NULL );
obj_cast_spell( obj->value[3], obj->value[0], ch, ch, NULL );
obj_cast_spell( obj->value[4], obj->value[0], ch, ch, NULL );
if (ch->fighting){
WAIT_STATE( ch, 2*PULSE_VIOLENCE );
}else{
WAIT_STATE( ch, 3*PULSE_VIOLENCE/2 );
}
break;
}
extract_obj( obj );
return;
}
/**************************************************************************/
// Remove an object, return true if object in wear location has been removed
bool remove_obj( char_data *ch, int iWear, bool fReplace )
{
OBJ_DATA *obj;
if ( ( obj = get_eq_char( ch, iWear ) ) == NULL )
return true;
if ( !fReplace )
return false;
if ( !IS_IMMORTAL(ch) && IS_SET(obj->extra_flags, OBJEXTRA_NOREMOVE) )
{
act( "You can't remove $p.", ch, obj, NULL, TO_CHAR );
return false;
}
if (obj->wear_loc==WEAR_SECONDARY){
act( "You stop using $p as your offhand weapon.", ch, obj, NULL, TO_CHAR );
}else if (!IS_SET(obj->extra_flags,OBJEXTRA_LODGED)){
act( "You stop using $p.", ch, obj, NULL, TO_CHAR );
}
// Clan Gear Items - Ixliam
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && (obj->pIndexData->clan != NULL))
{
if (obj->pIndexData->clan != ch->clan)
{
ch->println("That belongs to another clan! Item removed.");
obj->wear_loc = -1;
extract_obj(obj);
return true;
}
}
if (IS_SET(obj->extra2_flags, OBJEXTRA2_RUNIC) && obj->level > ch->level)
{
ch->printf( "%s is too powerful for you to handle.\r\n", obj->short_descr );
obj_from_char( obj );
obj_to_char(obj, ch);
return true;
}
if ( IS_SET( obj->extra_flags, OBJEXTRA_LODGED ))
{
REMOVE_BIT( obj->extra_flags, OBJEXTRA_LODGED );
if (iWear == WEAR_LODGED_ARM )
{
act( "With a tug you dislodge $p from your arm.", ch, obj, NULL, TO_CHAR );
act( "With a tug, $n dislodges $p from $s arm.", ch, obj, NULL, TO_ROOM );
ch->hit -= obj->level / 4;
obj->wear_loc = -1;
return true;
}
else if (iWear == WEAR_LODGED_LEG )
{
act( "With a good yank you dislodge $p from your leg.", ch, obj, NULL, TO_CHAR );
act( "With a good yank, $n dislodges $p from $s leg.", ch, obj, NULL, TO_ROOM );
ch->hit -= obj->level / 5;
ch->move -= obj->level / 2;
obj->wear_loc = -1;
return true;
}
else if (iWear == WEAR_LODGED_RIB )
{
act( "With a wrenching pull you dislodge $p from your chest.", ch, obj, NULL, TO_CHAR );
act( "With a wrenching pull, $n dislodges $p from $s chest.", ch, obj, NULL, TO_ROOM );
ch->hit -= obj->level / 2;
obj->wear_loc = -1;
return true;
}
}
else {
act( "$n stops using $p.", ch, obj, NULL, TO_ROOM );
}
unequip_char( ch, obj );
return true;
}
/**************************************************************************/
/*
* Wear one object.
* Optional replacement of existing objects.
* Big repetitive code, ick.
*/
void wear_obj( char_data *ch, OBJ_DATA *obj, bool fReplace, bool hold )
{
obj_data *existing_primary_position; // used for object wearing preference system
// --- object wearing preference system works as follows:
// if 'ch' is wearing 2 items in a particular wear location
// (e.g. WEAR_FINGER_L, WEAR_FINGER_R), and try to wear an object
// into that wear location, the code will favour replacing the item
// which doesn't have the same vnum as the object about to be put on.
// The effect of this, is you can type 'wear golden', 'wear golden'...
// and you would replace both of your rings with golden rings...
// instead of the second 'wear golden' replacing what you just
// wore using the first 'wear golden'.
// - Kal, Sept 03
// do check if objects level is LEVEL_IMMORTAL or higher, and it is a
// mortal trying to wear the object, remove it from them.
if (( obj->level>LEVEL_HERO)&&(ch->level < LEVEL_IMMORTAL))
{
char buf[MSL];
sprintf( buf, "`x%s (%s) lvl %d`1tried to wear `1%s [%d] lvl %d`1It was removed since it was out of level.",
ch->name, ch->short_descr, ch->level,
obj->short_descr, obj->pIndexData->vnum, obj->level);
autonote(NOTE_SNOTE, "p_anote()","`Yoverlevel object!`x", "imm", buf, true);
ch->printlnf( "You try to use %s and it crumbles to dust.", obj->short_descr );
act( "$n tries to use $p, but it crumbles to dust.",
ch, obj, NULL, TO_ROOM );
extract_obj(obj);
return;
}
if ( IS_SET( obj->attune_flags, ATTUNE_NEED_TO_USE ))
{
if ( ch->id != obj->attune_id )
{
act( "You cannot use $p until you have attuned yourself to it.", ch, obj, NULL, TO_CHAR );
return;
}
}
if(IS_SET(obj->extra_flags, OBJEXTRA_MAGIC)
&& HAS_CLASSFLAG(ch, CLASSFLAG_MAGIC_ANTIPATHY))
{
act("You have great antipathy towards $p.",ch,obj,NULL,TO_CHAR);
return;
}
if ( !IS_ADMIN( ch )) // Immortal requested not to have this but I wanted it :)
{
if(!IS_NPC(ch) && obj->pIndexData->relative_size<
race_table[ch->race]->low_size &&
obj->item_type != ITEM_LIGHT &&
!CAN_WEAR( obj, OBJWEAR_HOLD) &&
!CAN_WEAR( obj, OBJWEAR_FLOAT) )
{
act("$p is too small for you.",ch,obj,NULL,TO_CHAR);
return;
}
// Clan Gear Items - Ixliam
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && (obj->pIndexData->clan != NULL))
{
if (obj->pIndexData->clan != ch->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
}
}
if (IS_SET(obj->extra2_flags, OBJEXTRA2_RUNIC) && obj->level > ch->level)
{
ch->printf( "%s is too powerful for you to handle.\r\n", obj->short_descr );
return;
}
if(!IS_NPC(ch) && obj->pIndexData->relative_size>
race_table[ch->race]->high_size &&
obj->item_type != ITEM_LIGHT &&
!CAN_WEAR( obj, OBJWEAR_FLOAT) )
{
act("$p is too large for you.", ch, obj, NULL, TO_CHAR);
return;
}
}
if ( !IS_IMMORTAL( ch ))
{
if(DISALLOWED_OBJECT_FOR_CHAR(obj, ch))
{
act("$p cannot be used by your class.",ch,obj,NULL,TO_CHAR);
return;
}
}
if(race_can_wear(ch, obj) == false)
{
act("$p cannot be worn on your body.",ch,obj,NULL,TO_CHAR);
return;
}
if ( obj->item_type == ITEM_LIGHT )
{
if ( !remove_obj( ch, WEAR_LIGHT, fReplace ) )
return;
act( "$n lights $p and holds it.", ch, obj, NULL, TO_ROOM );
act( "You light $p and hold it.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_LIGHT );
return;
}
if ( obj->item_type == ITEM_PROJECTILE )
{
if ( !remove_obj( ch, WEAR_HOLD, fReplace ) )
return;
act( "$n holds $p in $s hand.", ch, obj, NULL, TO_ROOM );
act( "You hold $p in your hand.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_HOLD );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_FINGER ) )
{
// remove something from the fingers to make way for the item about to go on if necessary
existing_primary_position=get_eq_char( ch, WEAR_FINGER_L );
if ( existing_primary_position && get_eq_char( ch, WEAR_FINGER_R ))
{
if(existing_primary_position->pIndexData
&& obj->pIndexData
&& existing_primary_position->pIndexData->vnum==obj->pIndexData->vnum)
{
// favour replacing the secondary position item over doing an exact swap
if( !remove_obj( ch, WEAR_FINGER_R, fReplace )
&&!remove_obj( ch, WEAR_FINGER_L, fReplace ) ){
return;
}
}else{
if( !remove_obj( ch, WEAR_FINGER_L, fReplace )
&&!remove_obj( ch, WEAR_FINGER_R, fReplace ) ){
return;
}
}
}
if ( get_eq_char( ch, WEAR_FINGER_L ) == NULL )
{
act( "$n wears $p on $s left finger.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your left finger.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_FINGER_L );
return;
}
if ( get_eq_char( ch, WEAR_FINGER_R ) == NULL )
{
act( "$n wears $p on $s right finger.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your right finger.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_FINGER_R );
return;
}
bug( "Wear_obj: no free finger.");
ch->println("You already wear two rings.");
return;
}
if ( CAN_WEAR( obj, OBJWEAR_NECK ) )
{
// remove something from the neck to make way for the item about to go on if necessary
existing_primary_position=get_eq_char( ch, WEAR_NECK_1 );
if ( existing_primary_position && get_eq_char( ch, WEAR_NECK_2 ))
{
if(existing_primary_position->pIndexData
&& obj->pIndexData
&& existing_primary_position->pIndexData->vnum==obj->pIndexData->vnum)
{
// favour replacing the secondary position item over doing an exact swap
if( !remove_obj( ch, WEAR_NECK_2, fReplace )
&&!remove_obj( ch, WEAR_NECK_1, fReplace ) ){
return;
}
}else{
if( !remove_obj( ch, WEAR_NECK_1, fReplace )
&&!remove_obj( ch, WEAR_NECK_2, fReplace ) ){
return;
}
}
}
// put the item onto the free wear position
if ( get_eq_char( ch, WEAR_NECK_1 ) == NULL )
{
act( "$n wears $p around $s neck.", ch, obj, NULL, TO_ROOM );
act( "You wear $p around your neck.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_NECK_1 );
return;
}
if ( get_eq_char( ch, WEAR_NECK_2 ) == NULL )
{
act( "$n wears $p around $s neck.", ch, obj, NULL, TO_ROOM );
act( "You wear $p around your neck.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_NECK_2 );
return;
}
bug("Wear_obj: no free neck.");
ch->println("You already wear two neck items.");
return;
}
if ( CAN_WEAR( obj, OBJWEAR_TORSO ) )
{
if ( !remove_obj( ch, WEAR_TORSO, fReplace ) )
return;
act( "$n wears $p on $s torso.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your torso.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_TORSO );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_HEAD ) )
{
if ( !remove_obj( ch, WEAR_HEAD, fReplace ) )
return;
act( "$n wears $p on $s head.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your head.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_HEAD );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_LEGS ) )
{
if ( !remove_obj( ch, WEAR_LEGS, fReplace ) )
return;
act( "$n wears $p on $s legs.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your legs.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_LEGS );
return;
}
//////////////
if (CAN_WEAR(obj, OBJWEAR_EYES))
{
if (!remove_obj (ch, WEAR_EYES, fReplace)){
return;
}
act( "$n wears $p on $s eyes.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your eyes.", ch, obj, NULL, TO_CHAR );
equip_char (ch, obj, WEAR_EYES);
return;
}
if (CAN_WEAR(obj, OBJWEAR_EAR))
{
// remove something from the ears to make way for the item about to go on if necessary
existing_primary_position=get_eq_char( ch, WEAR_EAR_L );
if ( existing_primary_position && get_eq_char( ch, WEAR_EAR_R ))
{
if(existing_primary_position->pIndexData
&& obj->pIndexData
&& existing_primary_position->pIndexData->vnum==obj->pIndexData->vnum)
{
// favour replacing the secondary position item over doing an exact swap
if( !remove_obj( ch, WEAR_EAR_R, fReplace )
&&!remove_obj( ch, WEAR_EAR_L, fReplace ) ){
return;
}
}else{
if( !remove_obj( ch, WEAR_EAR_L, fReplace )
&&!remove_obj( ch, WEAR_EAR_R, fReplace ) ){
return;
}
}
}
if (get_eq_char (ch, WEAR_EAR_L) == NULL)
{
act( "$n wears $p on $s left ear.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your left ear.", ch, obj, NULL, TO_CHAR );
equip_char (ch, obj, WEAR_EAR_L);
return;
}
if (get_eq_char (ch, WEAR_EAR_R) == NULL)
{
act( "$n wears $p on $s right ear.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your right ear.", ch, obj, NULL, TO_CHAR );
equip_char (ch, obj, WEAR_EAR_R);
return;
}
bug("Wear_obj: no free ear.");
ch->println("You already wear two ear rings.");
return;
}
if (CAN_WEAR(obj, OBJWEAR_FACE))
{
if (!remove_obj (ch, WEAR_FACE, fReplace))
return;
act( "$n wears $p on $s face.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your face.", ch, obj, NULL, TO_CHAR );
equip_char (ch, obj, WEAR_FACE);
return;
}
if ( CAN_WEAR( obj, OBJWEAR_BACK ) )
{
if ( !remove_obj( ch, WEAR_BACK, fReplace ) )
return;
act( "$n wears $p on $s back.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your back.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_BACK );
return;
}
if (CAN_WEAR(obj, OBJWEAR_ANKLE))
{
// remove something from the ankles to make way for the item about to go on if necessary
existing_primary_position=get_eq_char( ch, WEAR_ANKLE_L );
if ( existing_primary_position && get_eq_char( ch, WEAR_ANKLE_R ))
{
if(existing_primary_position->pIndexData
&& obj->pIndexData
&& existing_primary_position->pIndexData->vnum==obj->pIndexData->vnum)
{
// favour replacing the secondary position item over doing an exact swap
if( !remove_obj( ch, WEAR_ANKLE_R, fReplace )
&&!remove_obj( ch, WEAR_ANKLE_L, fReplace ) ){
return;
}
}else{
if( !remove_obj( ch, WEAR_ANKLE_L, fReplace )
&&!remove_obj( ch, WEAR_ANKLE_R, fReplace ) ){
return;
}
}
}
if (get_eq_char (ch, WEAR_ANKLE_L) == NULL)
{
act( "$n wears $p on $s left ankle.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your left ankle.", ch, obj, NULL, TO_CHAR );
equip_char (ch, obj, WEAR_ANKLE_L);
return;
}
if (get_eq_char (ch, WEAR_ANKLE_R) == NULL)
{
act( "$n wears $p on $s right ankle.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your right ankle.", ch, obj, NULL, TO_CHAR );
equip_char (ch, obj, WEAR_ANKLE_R);
return;
}
bug("Wear_obj: no free ankle.");
ch->println("You already wear items on both your ankles.");
return;
}
//////////////
if ( CAN_WEAR( obj, OBJWEAR_FEET ) )
{
if ( !remove_obj( ch, WEAR_FEET, fReplace ) )
return;
act( "$n wears $p on $s feet.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your feet.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_FEET );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_HANDS ) )
{
if ( !remove_obj( ch, WEAR_HANDS, fReplace ) )
return;
act( "$n wears $p on $s hands.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your hands.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_HANDS );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_ARMS ) )
{
if ( !remove_obj( ch, WEAR_ARMS, fReplace ) )
return;
act( "$n wears $p on $s arms.", ch, obj, NULL, TO_ROOM );
act( "You wear $p on your arms.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_ARMS );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_ABOUT ) )
{
if ( !remove_obj( ch, WEAR_ABOUT, fReplace ) )
return;
act( "$n wears $p about $s torso.", ch, obj, NULL, TO_ROOM );
act( "You wear $p about your torso.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_ABOUT );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_WAIST ) )
{
if ( !remove_obj( ch, WEAR_WAIST, fReplace ) )
return;
act( "$n wears $p about $s waist.", ch, obj, NULL, TO_ROOM );
act( "You wear $p about your waist.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_WAIST );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_WRIST ) )
{
// remove something from the wrists to make way for the item about to go on if necessary
existing_primary_position=get_eq_char( ch, WEAR_WRIST_L );
if ( existing_primary_position && get_eq_char( ch, WEAR_WRIST_R ))
{
if(existing_primary_position->pIndexData
&& obj->pIndexData
&& existing_primary_position->pIndexData->vnum==obj->pIndexData->vnum)
{
// favour replacing the secondary position item over doing an exact swap
if( !remove_obj( ch, WEAR_WRIST_R, fReplace )
&&!remove_obj( ch, WEAR_WRIST_L, fReplace ) ){
return;
}
}else{
if( !remove_obj( ch, WEAR_WRIST_L, fReplace )
&&!remove_obj( ch, WEAR_WRIST_R, fReplace ) ){
return;
}
}
}
if ( get_eq_char( ch, WEAR_WRIST_L ) == NULL )
{
act( "$n wears $p around $s left wrist.",
ch, obj, NULL, TO_ROOM );
act( "You wear $p around your left wrist.",
ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_WRIST_L );
return;
}
if ( get_eq_char( ch, WEAR_WRIST_R ) == NULL )
{
act( "$n wears $p around $s right wrist.",
ch, obj, NULL, TO_ROOM );
act( "You wear $p around your right wrist.",
ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_WRIST_R );
return;
}
bug("Wear_obj: no free wrist.");
ch->println("You already wear two wrist items.");
return;
}
if ( CAN_WEAR( obj, OBJWEAR_SHIELD ) )
{
OBJ_DATA *weapon;
if ( !remove_obj( ch, WEAR_SHIELD, fReplace ) )
return;
weapon = get_eq_char(ch,WEAR_WIELD);
if (weapon != NULL && ch->size < SIZE_LARGE
&& IS_WEAPON_STAT(weapon,WEAPON_TWO_HANDS))
{
ch->println("Your hands are tied up with your two-handed weapon!");
return;
}
if (get_eq_char (ch, WEAR_SECONDARY) != NULL)
{
if (hold){
if ( !remove_obj( ch, WEAR_SECONDARY, true) ){
return;
}
}else{
ch->println("You cannot use a shield while using 2 weapons.");
ch->println("(Try using hold instead of wear to automatically remove your offhand weapon.)");
return;
}
}
act( "$n wears $p as a shield.", ch, obj, NULL, TO_ROOM );
act( "You wear $p as a shield.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_SHIELD );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_WIELD ) )
{
int sn,skill;
if ( !remove_obj( ch, WEAR_WIELD, fReplace ) )
return;
if ( !IS_NPC(ch)
&& get_obj_weight(obj) > ((ch->modifiers[STAT_ST] + 20) * 10 ))
{
ch->println("It is too heavy for you to wield.");
return;
}
if (!IS_NPC(ch) && ch->size < SIZE_LARGE
&& IS_WEAPON_STAT(obj,WEAPON_TWO_HANDS)
&& ((get_eq_char(ch,WEAR_SHIELD) != NULL)
|| (get_eq_char(ch,WEAR_SECONDARY) != NULL)))
{
ch->println("You need two hands free for that weapon.");
return;
}
if ( IS_SET( obj->extra2_flags, OBJEXTRA2_NOPRIMARY )) {
act( "$p is designed to be wielded in your offhand.", ch, obj, NULL, TO_CHAR );
return;
}
act( "$n wields $p.", ch, obj, NULL, TO_ROOM );
act( "You wield $p.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_WIELD );
sn = get_weapon_sn(ch);
if (sn == gsn_hand_to_hand)
return;
skill = get_weapon_skill(ch,sn);
if (skill >= 100)
act("$p feels like a part of you!",ch,obj,NULL,TO_CHAR);
else if (skill > 85)
act("You feel quite confident with $p.",ch,obj,NULL,TO_CHAR);
else if (skill > 70)
act("You are skilled with $p.",ch,obj,NULL,TO_CHAR);
else if (skill > 50)
act("Your skill with $p is adequate.",ch,obj,NULL,TO_CHAR);
else if (skill > 25)
act("$p feels a little clumsy in your hands.",ch,obj,NULL,TO_CHAR);
else if (skill > 1)
act("You fumble and almost drop $p.",ch,obj,NULL,TO_CHAR);
else
act("You don't even know which end is up on $p.",
ch,obj,NULL,TO_CHAR);
return;
}
if ( CAN_WEAR( obj, OBJWEAR_HOLD ) )
{
if (get_eq_char (ch, WEAR_SECONDARY) != NULL)
{
if (hold){
if ( !remove_obj( ch, WEAR_SECONDARY, true) ){
return;
}
}else{
ch->println("You cannot hold an item while using 2 weapons.");
ch->println("(Try using hold instead of wear to automatically remove your offhand weapon.)");
return;
}
}
if ( !remove_obj( ch, WEAR_HOLD, fReplace ) ){
return;
}
act( "$n holds $p in $s hand.", ch, obj, NULL, TO_ROOM );
act( "You hold $p in your hand.", ch, obj, NULL, TO_CHAR );
equip_char( ch, obj, WEAR_HOLD );
return;
}
if ( CAN_WEAR(obj,OBJWEAR_FLOAT) )
{
if (!remove_obj(ch,WEAR_FLOAT, fReplace) )
return;
act("$n releases $p to float next to $m.",ch,obj,NULL,TO_ROOM);
act("You release $p and it floats next to you.",ch,obj,NULL,TO_CHAR);
equip_char(ch,obj,WEAR_FLOAT);
return;
}
if ( CAN_WEAR( obj, OBJWEAR_LODGED_ARM ) )
{
if ( !remove_obj( ch, WEAR_LODGED_ARM, fReplace ) )
return;
equip_char( ch, obj, WEAR_LODGED_ARM );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_LODGED_LEG ) )
{
if ( !remove_obj( ch, WEAR_LODGED_LEG, fReplace ) )
return;
equip_char( ch, obj, WEAR_LODGED_LEG );
return;
}
if ( CAN_WEAR( obj, OBJWEAR_LODGED_RIB ) )
{
if ( !remove_obj( ch, WEAR_LODGED_RIB, fReplace ) )
return;
equip_char( ch, obj, WEAR_LODGED_RIB );
return;
}
if ( fReplace )
ch->println("You can't wear, wield, or hold that.");
return;
}
/**************************************************************************/
void do_wear( char_data *ch, char *argument )
{
char arg[MIL];
OBJ_DATA *obj;
one_argument( argument, arg );
if ( IS_NULLSTR(arg) )
{
ch->println( "Wear, wield what?" );
return;
}
if ( !str_cmp( arg, "all" ) )
{
OBJ_DATA *obj_next;
for ( obj = ch->carrying; obj != NULL; obj = obj_next )
{
obj_next = obj->next_content;
if ( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) ){
wear_obj ( ch, obj, false, false );
}
}
return;
}
if ( ( obj = get_obj_carry( ch, arg ) ) == NULL ){
ch->println( "You do not have that item." );
return;
}
wear_obj( ch, obj, true, false );
return;
}
/**************************************************************************/
void do_hold( char_data *ch, char *argument )
{
char arg[MIL];
OBJ_DATA *obj;
one_argument( argument, arg );
if ( IS_NULLSTR(arg)){
ch->println( "Hold what?" );
return;
}
if ( ( obj = get_obj_carry( ch, arg ) ) == NULL ){
ch->println( "You do not have that item." );
return;
}
wear_obj( ch, obj, true, true );
return;
}
/**************************************************************************/
void do_remove( char_data *ch, char *argument )
{
char arg[MIL];
OBJ_DATA *obj;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
ch->println("Remove what?");
return;
}
if (!str_cmp(arg, "all"))
{
// PC being ordered to do this
if ( !IS_NPC(ch) && IS_SET( ch->dyn, DYN_IS_BEING_ORDERED ))
{
if ( ch->master )
ch->println("Not going to happen.");
return;
}
bool found =false;
for ( obj = ch->carrying; obj != NULL; obj = obj->next_content )
{
if ( obj->wear_loc != WEAR_NONE
&& can_see_obj( ch, obj ) )
{
if (!found)
found = true;
if ( obj->wear_loc == WEAR_SHEATHED
|| obj->wear_loc == WEAR_CONCEALED )
{
if ( obj->wear_loc == WEAR_SHEATHED)
REMOVE_CONFIG2(ch, CONFIG2_SHEATHED);
if ( obj->wear_loc == WEAR_CONCEALED)
REMOVE_CONFIG2(ch, CONFIG2_CONCEALED);
if ( obj->item_type == ITEM_POLE)
{ REMOVE_CONFIG2(ch, CONFIG2_FISHING);
REMOVE_CONFIG2(ch, CONFIG2_FISH_ON); }
obj->wear_loc = -1;
act( "$n stops using $p.", ch, obj, NULL, TO_ROOM );
act( "You stop using $p.", ch, obj, NULL, TO_CHAR );
// Clan Gear Items - Ixliam
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && (obj->pIndexData->clan != NULL))
{
if (obj->pIndexData->clan != ch->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
}
}
}
else
{
if ( get_eq_char(ch, WEAR_SHEATHED) != NULL && obj->wear_loc == WEAR_WIELD)
{ SET_CONFIG2(ch, CONFIG2_SHEATHED); }
remove_obj( ch, obj->wear_loc, true );
if ( obj->wear_loc == WEAR_ABOUT)
REMOVE_CONFIG2(ch, CONFIG2_CLOAKED);
}
WAIT_STATE(ch, 1);
if (ch->fighting)
WAIT_STATE(ch, 5);
}
}
if (!found)
{
ch->println("You are not wearing anything.");
}
return;
}
if ( ( obj = get_obj_wear( ch, arg ) ) == NULL )
{
ch->println("You do not have that item.");
return;
}
if ( obj->wear_loc == WEAR_ABOUT)
REMOVE_CONFIG2(ch, CONFIG2_CLOAKED);
if ( obj->wear_loc == WEAR_SHEATHED
|| obj->wear_loc == WEAR_CONCEALED )
{
if ( obj->wear_loc == WEAR_SHEATHED)
REMOVE_CONFIG2(ch, CONFIG2_SHEATHED);
if ( obj->wear_loc == WEAR_CONCEALED)
REMOVE_CONFIG2(ch, CONFIG2_CONCEALED);
if ( obj->item_type == ITEM_POLE)
REMOVE_CONFIG2(ch, CONFIG2_FISHING);
obj->wear_loc = -1;
act( "$n stops using $p.", ch, obj, NULL, TO_ROOM );
act( "You stop using $p.", ch, obj, NULL, TO_CHAR );
// Clan Gear Items - Ixliam
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && (obj->pIndexData->clan != NULL))
{
if (obj->pIndexData->clan != ch->clan)
{
ch->println("That belongs to another clan! Item removed.");
extract_obj(obj);
return;
}
}
}
else {
if ( get_eq_char(ch, WEAR_SHEATHED) != NULL && obj->wear_loc == WEAR_WIELD)
{ SET_CONFIG2(ch, CONFIG2_SHEATHED); }
remove_obj( ch, obj->wear_loc, true );
if ( obj->wear_loc == WEAR_ABOUT)
REMOVE_CONFIG2(ch, CONFIG2_CLOAKED);
}
return;
}
/**************************************************************************/
void do_quaff( char_data *ch, char *argument )
{
char arg[MIL];
OBJ_DATA *obj;
one_argument( argument, arg );
if ( IS_OOC( ch )) {
ch->println("Not in an OOC room.");
return;
}
if ( arg[0] == '\0' )
{
ch->println("Quaff what?");
return;
}
if ( ( obj = get_obj_carry( ch, arg ) ) == NULL )
{
ch->println("You do not have that potion.");
return;
}
if ( obj->item_type != ITEM_POTION )
{
ch->println("You can quaff only potions.");
return;
}
if ( IS_SET( ch->in_room->room_flags, ROOM_ANTIMAGIC ))
{
act( "$n quaffs $p.", ch, obj, NULL, TO_ROOM );
act( "You quaff $p but nothing seems to happen.", ch, obj, NULL ,TO_CHAR );
extract_obj( obj );
return;
}
if( IS_SET(ch->in_room->room2_flags,ROOM2_ARENA))
{
act( "$n quaffs $p and tries to `#`YCHEAT`^ in the `RARENA`^.", ch, obj, NULL, TO_ROOM );
act( "You quaff $p and try to `#`YCHEAT`^ in the `RARENA`^.", ch, obj, NULL ,TO_CHAR );
info_broadcast(ch, "%s tried to use Potions in the Arena.", ch->name);
ch->hit = 1;
extract_obj( obj );
return;
}
// Added so that barbarians have a good chance of 'fearing magic'. - Tib
if(IS_SET(obj->extra_flags, OBJEXTRA_MAGIC)
&& HAS_CLASSFLAG(ch, CLASSFLAG_MAGIC_ANTIPATHY) && number_range(1,3)==1)
{
if ( IS_AFFECTED( ch, AFF_FEAR ) || IS_AFFECTED2( ch, AFF2_FEAR_MAGIC) )
{
ch->println("The potion shatters on the ground, falling from your shaking hands.");
extract_obj( obj );
return;
}
act( "$n quaffs $p and screams in terror!", ch, obj, NULL, TO_ROOM );
act( "You quaff $p and scream as you realize the potion was magic.",
ch, obj, NUShowing the first 100 KB of 229.0 KB. Download the archive for the full file.