act_obj.cpp
dawn/src/act_obj.cpp · 155.2 KB
From the archive dawn1.69r.tgz
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 "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 );
char *get_weapontype(OBJ_DATA *obj); /* prototype - handler.c */
bool trapcheck_get(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));
#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;
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;
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{
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);
}
}
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);
}
}
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->item_type == ITEM_WEAPON){
room_vnum=ROOM_VNUM_WEAPON_DONATE;
}else if (obj->item_type == ITEM_ARMOR){
room_vnum=ROOM_VNUM_ARMOR_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;
}
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;
}
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
{
// '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_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_CAULDRON:
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);
}
}
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
{
// 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 );
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;
}
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);
}
}
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;
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());
}
}
// 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;
}
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;
}
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);
// 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());
}
}
// 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;
}
// 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;
}
// 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->value[3])
{
obj->value[3] = 1;
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]);
break;
}
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 );
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.");
if ( obj->value[3] != 0
&& !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 ( 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;
}
}
act( "$n eats $p.", ch, obj, NULL, TO_ROOM );
act( "You eat $p.", ch, obj, NULL, TO_CHAR );
switch ( obj->item_type )
{
case ITEM_FOOD:
if ( !IS_NPC(ch) )
{
int condition;
condition = ch->pcdata->condition[COND_HUNGER];
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 ( obj->value[3] != 0
&& !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 );
}
if ( IS_SET( obj->extra_flags, OBJEXTRA_LODGED ))
{
REMOVE_BIT( obj->extra_flags, OBJEXTRA_LODGED );
if ( get_eq_char( ch, 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 ( get_eq_char( ch, 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 ( get_eq_char( ch, 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;
}
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 ( 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 ( 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 )
{
obj->wear_loc = -1;
act( "$n stops using $p.", ch, obj, NULL, TO_ROOM );
act( "You stop using $p.", ch, obj, NULL, TO_CHAR );
}
else
{
remove_obj( ch, obj->wear_loc, true );
}
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_SHEATHED
|| obj->wear_loc == WEAR_CONCEALED )
{
obj->wear_loc = -1;
act( "$n stops using $p.", ch, obj, NULL, TO_ROOM );
act( "You stop using $p.", ch, obj, NULL, TO_CHAR );
}
else
remove_obj( ch, obj->wear_loc, true );
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;
}
// 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, NULL ,TO_CHAR );
msp_to_room(MSPT_ACTION, MSP_SOUND_QUAFF, 0, ch, false, true);
spell_fear_magic( gsn_fear_magic, UMIN(250, (obj->level*5)), ch, ch, 0);
extract_obj( obj );
return;
}
if ((ch->level < obj->level)&&(obj->level>10))
{
ch->println("This liquid is too powerful for you to drink.");
return;
}
act( "$n quaffs $p.", ch, obj, NULL, TO_ROOM );
act( "You quaff $p.", ch, obj, NULL ,TO_CHAR );
msp_to_room(MSPT_ACTION, MSP_SOUND_QUAFF,
0,
ch,
false,
true);
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 );
}
extract_obj( obj );
return;
}
/**************************************************************************/
void do_recite( char_data *ch, char *argument )
{
char arg1[MIL];
char arg2[MIL];
char_data *victim;
OBJ_DATA *scroll;
OBJ_DATA *obj;
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if ( ( scroll = get_obj_carry( ch, arg1 ) ) == NULL )
{
ch->println( "You do not have that scroll." );
return;
}
if(IS_AFFECTED( ch, AFF_BLIND ) ){
ch->println( "You can't recite scrolls while blind." );
return;
}
if ( scroll->item_type != ITEM_SCROLL )
{
ch->println( "You can recite only scrolls." );
return;
}
if (( ch->level < scroll->level)&&(scroll->level>10))
{
ch->println( "This scroll is too complex for you to comprehend." );
return;
}
obj = NULL;
if ( arg2[0] == '\0' )
{
victim = ch;
}
else
{
if ( ( victim = get_char_room ( ch, arg2 ) ) == NULL
&& ( obj = get_obj_here ( ch, arg2 ) ) == NULL )
{
ch->println("You can't find it.");
return;
}
}
act( "$n recites $p.", ch, scroll, NULL, TO_ROOM );
act( "You recite $p.", ch, scroll, NULL, TO_CHAR );
if (number_percent() >= 20 + get_skill(ch,gsn_scrolls) * 4/5)
{
ch->println("You mispronounce a syllable.");
check_improve(ch,gsn_scrolls,false,2);
}
else
{
obj_cast_spell( scroll->value[1], scroll->value[0], ch, victim, obj );
obj_cast_spell( scroll->value[2], scroll->value[0], ch, victim, obj );
obj_cast_spell( scroll->value[3], scroll->value[0], ch, victim, obj );
obj_cast_spell( scroll->value[4], scroll->value[0], ch, victim, obj );
check_improve(ch,gsn_scrolls,true,2);
}
extract_obj( scroll );
return;
}
/**************************************************************************/
void do_brandish( char_data *ch, char *argument )
{
OBJ_DATA *staff;
int sn;
// new stuff here
char arg2[MIL];
char_data *victim;
OBJ_DATA *obj;
void *vo;
int target;
strcpy(arg2, argument);
if ( ( staff = get_eq_char( ch, WEAR_HOLD ) ) == NULL )
{
ch->println("You hold nothing in your hands to brandish.");
return;
}
if ( staff->item_type != ITEM_STAFF )
{
ch->println("You can brandish only with a staff.");
return;
}
if ( IS_SET( ch->in_room->room_flags, ROOM_ANTIMAGIC )) {
act( "Your $p doesn't seem to have any power.", ch, staff, NULL, TO_CHAR );
return;
}
if (( sn = staff->value[3] ) < 0
|| sn >= MAX_SKILL
|| skill_table[sn].spell_fun == 0 )
{
bugf( "do_brandish(): bad sn %d.", sn );
return;
}
WAIT_STATE( ch, 2 * PULSE_VIOLENCE );
if (staff->value[2] < -1)
{
staff->value[2] = -1;
}
if (( staff->value[2] > 0 ) || (staff->value[2] = -1))
{
act( "$n brandishes $p.", ch, staff, NULL, TO_ROOM );
act( "You brandish $p.", ch, staff, NULL, TO_CHAR );
if ( ch->level < staff->level
|| (get_skill(ch,gsn_staves)==0)
|| number_percent() >= 20 + get_skill(ch,gsn_staves) * 4/5)
{
act ("You fail to invoke $p.",ch,staff,NULL,TO_CHAR);
act ("...and nothing happens.",ch,NULL,NULL,TO_ROOM);
check_improve(ch,gsn_staves,false,2);
}
else // cast the spell
{
// Locate targets.
victim = NULL;
obj = NULL;
vo = NULL;
target = TARGET_NONE;
switch ( skill_table[sn].target )
{
default:
bugf( "do_cast(): bad target for sn %d.", sn );
return;
case TAR_IGNORE:
break;
case TAR_MOB_OFFENSIVE:
case TAR_CHAR_OFFENSIVE:
if ( arg2[0] == '\0' )
{
if ( ( victim = ch->fighting ) == NULL )
{
ch->println("Brandish the object while aiming it towards whom?");
return;
}
}
else
{
if ( ( victim = get_char_room( ch, arg2 ) ) == NULL )
{
ch->println("They aren't here.");
return;
}
}
if ( !IS_NPC(ch) )
{
if (is_safe(ch,victim) && victim != ch)
{
ch->println("Not on that target.");
return;
}
}
if ( IS_AFFECTED(ch, AFF_CHARM) && ch->master == victim )
{
ch->println("You can't do that on your own follower.");
return;
}
vo = (void *) victim;
target = TARGET_CHAR;
break;
case TAR_CHAR_DEFENSIVE:
if ( arg2[0] == '\0' )
{
victim = ch;
}
else
{
if ( ( victim = get_char_room( ch, arg2 ) ) == NULL )
{
ch->println("They aren't here.");
return;
}
}
vo = (void *) victim;
target = TARGET_CHAR;
break;
case TAR_CHAR_SELF:
if ( arg2[0] != '\0' && !is_name( arg2, ch->name ) )
{
ch->println("You can't brandish this object while aiming it at another.");
return;
}
vo = (void *) ch;
target = TARGET_CHAR;
break;
case TAR_OBJ_INV:
if ( arg2[0] == '\0' )
{
ch->println("You must brandish the object towards another object?");
return;
}
if ( ( obj = get_obj_carry( ch, arg2 ) ) == NULL )
{
ch->println("You are not carrying that.");
return;
}
vo = (void *) obj;
target = TARGET_OBJ;
break;
case TAR_OBJ_MOB_OFF:
case TAR_OBJ_CHAR_OFF:
if (arg2[0] == '\0')
{
if ((victim = ch->fighting) == NULL)
{
ch->println("Brandish the object on whom or what?");
return;
}
target = TARGET_CHAR;
}
else if ((victim = get_char_room(ch,arg2)) != NULL)
{
target = TARGET_CHAR;
}
if (target == TARGET_CHAR) // check the sanity of the attack
{
if(is_safe_spell(ch,victim,false) && victim != ch)
{
ch->println("Not on that target.");
return;
}
if ( IS_AFFECTED(ch, AFF_CHARM) && ch->master == victim )
{
ch->println("You can't do that on your own follower.");
return;
}
vo = (void *) victim;
}
else if ((obj = get_obj_here(ch,arg2)) != NULL)
{
vo = (void *) obj;
target = TARGET_OBJ;
}
else
{
ch->println("You don't see that here.");
return;
}
break;
case TAR_OBJ_CHAR_DEF:
if (arg2[0] == '\0')
{
vo = (void *) ch;
target = TARGET_CHAR;
}
else if ((victim = get_char_room(ch,arg2)) != NULL)
{
vo = (void *) victim;
target = TARGET_CHAR;
}
else if ((obj = get_obj_carry(ch,arg2)) != NULL)
{
vo = (void *) obj;
target = TARGET_OBJ;
}
else
{
ch->println("You don't see that here.");
return;
}
break;
} // end of spell type switch
if (IS_NPC(ch) || class_table[ch->clss].fMana)
// clss has spells
(*skill_table[sn].spell_fun) ( sn, staff->value[0], ch, vo,target);
else
(*skill_table[sn].spell_fun) (sn, staff->value[0], ch, vo,target);
check_improve(ch,gsn_staves,true,2);
}
}
// get rid of the staff if required
if ( staff->value[2] == -1)
{
return;
}
staff->value[2]--;
if (staff->value[2] < 1)
{
act( "$n's $p blazes bright and is gone.", ch, staff, NULL, TO_ROOM );
act( "Your $p blazes bright and is gone.", ch, staff, NULL, TO_CHAR );
extract_obj( staff );
}
return;
}
/**************************************************************************/
void do_apply( char_data *ch, char *argument )
{
char arg[MIL];
char_data *victim;
OBJ_DATA *poultice;
if ( IS_OOC( ch )) {
ch->println( "Not in an OOC room." );
return;
}
if ( get_skill( ch, gsn_apply ) == 0 )
{
ch->println( "You are not educated in the herbal arts." );
return;
}
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
ch->println( "Apply what to whom?" );
return;
}
if (( poultice = get_eq_char( ch, WEAR_HOLD )) == NULL )
{
ch->println( "You hold nothing in your hand." );
return;
}
if ( poultice->item_type != ITEM_POULTICE )
{
ch->println( "You are not holding a suitable medicinal component." );
return;
}
if (( victim = get_char_room ( ch, arg ) ) == NULL )
{
ch->println( "They are not here." );
return;
}
WAIT_STATE( ch, 2 * PULSE_VIOLENCE );
if ( poultice->value[2] != 0 )
{
act( "$n applies $p to $N.", ch, poultice, victim, TO_ROOM );
act( "You apply $p to $N.", ch, poultice, victim, TO_CHAR );
}
if ( ch->level < poultice->level
|| number_percent() >= 20 + get_skill( ch, gsn_apply ) * 4/5 )
{
act( "Your efforts to apply $p didn't produce any noticeable effects.",
ch, poultice, NULL, TO_CHAR );
act( "$n's efforts to apply $p had no noticeable effects.",
ch, poultice, NULL, TO_ROOM );
check_improve( ch, gsn_apply, false, 2 );
}
else
{
obj_cast_spell( poultice->value[3], poultice->value[0], ch, victim, NULL );
check_improve( ch, gsn_apply, true, 2 );
}
if ( --poultice->value[2] == 0 )
{
act( "$n has used up $p.", ch, poultice, NULL, TO_ROOM );
act( "You have used up $p.", ch, poultice, NULL, TO_CHAR );
extract_obj( poultice );
}
if ( poultice->value[2] < 0 )
poultice->value[2] = -1; // set it back to infinite
return;
}
/**************************************************************************/
void duel_unprotect_victim(char_data *victim);
/**************************************************************************/
void do_steal( char_data *ch, char *argument )
{
char buf [MSL];
char arg1 [MIL];
char arg2 [MIL];
char_data *victim;
OBJ_DATA *obj;
int percent;
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if ( arg1[0] == '\0' || arg2[0] == '\0' )
{
ch->println( "Steal what from whom?" );
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 ( ( victim = get_char_room( ch, arg2 ) ) == NULL )
{
ch->println( "They aren't here." );
return;
}
if(!IS_NPC(victim) && victim->level<10 && ch->level>(victim->level+10)
&& !IS_NPC(ch) && !IS_IMMORTAL(ch))
{
ch->println( "A faint wall of light appears to surround them preventing you from robbing them." );
return;
}
if (!IS_IMMORTAL(ch) && !IS_NPC(ch) && !IS_NPC(victim) && GAMESETTING4(GAMESET4_PREVENT_STEALING_FROM_PLAYERS)){
if(GAMESETTING4(GAMESET4_OOC_PREVENTION_MESSAGES)){
ch->println( "Stealing from other players is not permitted on this mud." );
}else{
ch->println( "A faint wall of light appears to surround them preventing you from robbing them." );
}
return;
}
if ( victim == ch ){
ch->println( "That's pointless." );
return;
}
if(GAMESETTING5(GAMESET5_NO_STEALING_FROM_FIGHTING_CHARACTERS) && victim->fighting){
ch->println( "Not while they are fighting!" );
return;
}
if (is_safe(ch,victim)){
return;
}
if ( IS_NPC(victim) && victim->position == POS_FIGHTING)
{
ch->println( "You'd better not -- you might get hit." );
return;
}
// optional stealing checks which affect stealing between players
if (!IS_IMMORTAL(ch) && !IS_NPC(victim)){
if( GAMESETTING4(GAMESET4_MUST_BE_IN_CLAN_TO_STEAL_FROM_PLAYERS) ){
ch->println( "You are not in a clan, stealing from players is restricted to clan members." );
return;
}
if( GAMESETTING4(GAMESET4_NO_STEALING_FROM_NON_CLANNED) && !victim->clan ){
ch->println( "They are not in a clan, stealing from players is restricted to clan members." );
return;
}
// optional checks relating to letgain status
if(GAMESETTING_LETGAINING_IS_REQUIRED){
// is the potential thief letgained
if ( GAMESETTING4(GAMESET4_MUST_BE_LETGAINED_TO_STEAL_FROM_PLAYERS)
&& !IS_LETGAINED(ch))
{
ch->println("You can't steal from non letgained players.");
return;
}
// is the intended victim letgained
if ( GAMESETTING4(GAMESET4_NO_STEALING_FROM_NON_LETGAINED)
&& !IS_LETGAINED(victim))
{
ch->println("You can't steal from non letgained players.");
return;
}
if(GAMESETTING5(GAMESET5_MUST_BE_ACTIVE_TO_BE_INVOLVED_IN_STEALING)){
if(!HAS_CONFIG(victim, CONFIG_ACTIVE))
{
ch->println( "You can't steal from non active players." );
return;
}
if(!HAS_CONFIG(ch, CONFIG_ACTIVE))
{
ch->println( "You must be active in order to steal from players." );
return;
}
}
if(HAS_CONFIG2(ch,CONFIG2_NOPKILL))
{
ch->println( "A faint wall of light appears to surround them preventing you from robbing them." );
return;
}
if(HAS_CONFIG2(victim,CONFIG2_NOPKILL))
{
ch->println( "A faint wall of light appears to surround them preventing you from robbing them." );
return;
}
}
// optional: stealing only permitted within ten levels of each other
if (GAMESETTING4(GAMESET4_NO_STEALING_OUTSIDE_10_LEVELS)){
if ( (ch->level - victim->level) > 10 || (ch->level - victim->level) < -10 ) {
ch->println("You may not steal from a character of more than 10 levels difference to your own." );
return;
}
}
}
// silent imms dont get lagged
if (!IS_SILENT(ch) || !IS_ICIMMORTAL(ch)){
WAIT_STATE( ch, skill_table[gsn_steal].beats );
}
// for 20 minutes you are unsafe if you steal
if(!IS_NPC(ch) && !IS_NPC(victim)){
ch->pcdata->unsafe_due_to_stealing_till=current_time+ 20*60;
if(ch->duels){
duel_unprotect_victim(ch);
}
}
if (IS_ICIMMORTAL(victim)){
ch->println( "You failed." );
victim->wraplnf( "NOTICE: %s attempted to steal '%s' from you and failed because you are considered an IC immortal.",
PERS(ch, victim), arg1);
return;
}
percent = number_percent();
if (get_skill(ch,gsn_steal) >= 1){
percent += ( IS_AWAKE(victim) ? 10 : -50 );
}
if(victim->pcdata && victim->pcdata->is_trying_aware){
percent += (get_skill(victim, gsn_awareness))/6;
}
if ( (IS_KEEPER(victim))
||(!IS_NPC(ch) && (percent+2*victim->level-2*ch->level > get_skill(ch,gsn_steal)))
||(!IS_NPC(ch) && get_skill(ch,gsn_steal)==0)
|| (ch->level<=LEVEL_HERO && victim->level>LEVEL_HERO))
{
/*
* Failure.
*/
ch->println( "Oops." );
// make them go visible
affect_strip ( ch, gsn_invisibility );
affect_strip ( ch, gsn_mass_invis );
affect_strip ( ch, gsn_sneak );
REMOVE_BIT ( ch->affected_by, AFF_HIDE );
REMOVE_BIT ( ch->affected_by, AFF_INVISIBLE );
REMOVE_BIT ( ch->affected_by, AFF_SNEAK );
if (!IS_NPC(victim))
{
ch->pksafe=0;
ch->pknorecall= (UMAX(ch->pknorecall,2));
ch->pknoquit=(UMAX(ch->pknoquit,10));
}
if (IS_AWAKE(victim)){
act( "$n tried to steal from YOU!", ch, NULL, victim, TO_VICT );
if( victim->pcdata && victim->pcdata->is_trying_aware )
check_improve(victim,gsn_awareness,true,1);
}else{
if( victim->pcdata && victim->pcdata->is_trying_aware
&& get_skill(victim, gsn_awareness) > number_percent() )
{
victim->println( "You feel the presence of another person lurking near you." );
victim->println( "You feel someone try to take something from you and instantly pop awake!" );
victim->position=POS_RESTING;
do_stand(victim,"");
check_improve(victim,gsn_awareness,true,2);
}else{
victim->println( "You are partially awakened by someone in the room." );
victim->println( "You roll over and drift back to sleep." );
}
}
act( "$n tried to steal from $N.", ch, NULL, victim, TO_NOTVICT );
if ( !IS_NPC(ch) )
{
if ( IS_NPC(victim) )
{
check_improve(ch,gsn_steal,false,2);
multi_hit( victim, ch, TYPE_UNDEFINED );
}
else
{
sprintf(buf,"$N tried to steal from %s <%d>.",
victim->name, victim->level);
wiznet(buf,ch,NULL,WIZ_THEFTS,0,0);
if(GAMESETTING3(GAMESET3_THIEF_SYSTEM_ENABLED)){
if(!IS_NPC(ch)){
if(!IS_THIEF(ch)){
ch->println( "*** You are now tagged as a THIEF!! ***");
}
ch->pcdata->thief_until=current_time+ (60*game_settings->thief_system_tagged_duration);
save_char_obj( ch );
}
}
}
}
return;
}
else
if (!IS_NPC(victim))
{
// transfer those to the void that are attacked
// while linkdead and dont have a pkill timer
if ( victim->pknorecall ==0
&& IS_LINKDEAD(victim)
&& victim->was_in_room == NULL
&& victim->in_room != NULL )
{
victim->was_in_room = victim->in_room;
if ( victim->fighting != NULL )
stop_fighting( victim, true );
act( "$n disappears into the void.", victim, NULL, NULL, TO_ROOM );
victim->println( "You disappear into the void." );
if (victim->level > 1)
save_char_obj( victim);
char_from_room( victim);
char_to_room( victim, get_room_index( ROOM_VNUM_LIMBO ) );
return;
}
ch->pksafe=0;
ch->pknoquit=(UMAX(ch->pknoquit,10));
}
if ( !str_cmp( arg1, "coin" )
|| !str_cmp( arg1, "coins" )
|| !str_cmp( arg1, "gold" )
|| !str_cmp( arg1, "silver"))
{
int gold, silver;
gold = victim->gold * number_range(1, ch->level) / MAX_LEVEL;
silver = victim->silver * number_range(1,ch->level) / MAX_LEVEL;
if (gold > victim->gold) gold = victim->gold;
if (silver > victim->silver) silver = victim->silver;
if ( gold <= 0 && silver <= 0 )
{
ch->println( "You couldn't get any coins." );
return;
}
ch->gold += gold;
ch->silver += silver;
victim->silver -= silver;
victim->gold -= gold;
if (silver <= 0)
ch->printlnf( "Bingo! You got %d gold coins.", gold );
else if (gold <= 0)
ch->printlnf( "Bingo! You got %d silver coins.", silver);
else
ch->printlnf( "Bingo! You got %d silver and %d gold coins.", silver, gold );
check_improve(ch,gsn_steal,true,2);
if (!IS_NPC(victim))
{
sprintf(buf,"$N successfully stole %d silver and %d "
"gold coins from %s <%d>.", silver, gold,
victim->name, victim->level);
wiznet(buf,ch,NULL,WIZ_THEFTS,0,0);
}
return;
}
if ( ( obj = get_obj_carry_for_looker( victim, arg1, ch ) ) == NULL )
{
ch->println( "You can't find it." );
return;
}
if ( !can_drop_obj( ch, obj )
|| IS_SET(obj->extra_flags, OBJEXTRA_INVENTORY) )
{
ch->println( "You can't pry it away." );
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;
}
obj_from_char( obj );
obj_to_char( obj, ch );
check_improve(ch,gsn_steal,true,2);
ch->println( "Got it!" );
if (!IS_NPC(victim))
{
sprintf(buf,"$N successfully stole %s [%d] from %s <%d>.",
obj->short_descr, obj->pIndexData->vnum, victim->name,
victim->level);
wiznet(buf,ch,NULL,WIZ_THEFTS,0,0);
}
return;
}
/**************************************************************************/
/*
* Shopping commands.
*/
/**************************************************************************/
char_data *find_keeper( char_data *ch )
{
char_data *keeper;
SHOP_DATA *pShop;
pShop = NULL;
for ( keeper = ch->in_room->people; keeper; keeper = keeper->next_in_room )
{
if ( IS_NPC(keeper) && (pShop = keeper->pIndexData->pShop) != NULL )
break;
}
if ( pShop == NULL )
{
ch->println("You can't do that here.");
return NULL;
}
// Shop hours.
if ( time_info.hour < pShop->open_hour )
{
do_say( keeper, "Sorry, I am closed. Come back later." );
return NULL;
}
if ( time_info.hour > pShop->close_hour )
{
do_say( keeper, "Sorry, I am closed. Come back tomorrow." );
return NULL;
}
// Invisible or hidden people.
if ( !can_see( keeper, ch ) && INVIS_LEVEL(ch)<1)
{
do_say( keeper, "I don't trade with folks I can't see." );
return NULL;
}
return keeper;
}
/**************************************************************************/
// insert an object at the right spot for the keeper
void obj_to_keeper( OBJ_DATA *obj, char_data *ch )
{
OBJ_DATA *t_obj, *t_obj_next;
// see if any duplicates are found
for (t_obj = ch->carrying; t_obj != NULL; t_obj = t_obj_next)
{
t_obj_next = t_obj->next_content;
if (obj->pIndexData == t_obj->pIndexData
&& !str_cmp(obj->short_descr,t_obj->short_descr))
{
// if this is an unlimited item, destroy the new one
if (IS_OBJ_STAT(t_obj,OBJEXTRA_INVENTORY))
{
extract_obj(obj);
return;
}
obj->cost = t_obj->cost; // keep it standard
break;
}
}
if (t_obj == NULL)
{
obj->next_content = ch->carrying;
ch->carrying = obj;
}
else
{
obj->next_content = t_obj->next_content;
t_obj->next_content = obj;
}
obj->carried_by = ch;
obj->in_room = NULL;
obj->in_obj = NULL;
ch->carry_number += get_obj_number( obj );
ch->carry_weight += get_obj_weight( obj );
}
/**************************************************************************/
// get an object from a shopkeeper's list
OBJ_DATA *get_obj_keeper( char_data *ch, char_data *keeper, char *argument )
{
char arg[MIL];
char newarg[MIL];
OBJ_DATA *obj;
int number;
int count;
// convert 'buy 5' to 'buy 5.'
if(is_number(argument)){
sprintf(newarg,"%s.",argument);
argument=newarg;
};
number = number_argument( argument, arg );
count = 0;
int uid=get_uid(arg);
if(uid){
number=1;
}
for ( obj = keeper->carrying; obj; obj = obj->next_content )
{
if (obj->wear_loc == Showing the first 100 KB of 155.2 KB. Download the archive for the full file.