build.c
ackfuss-4.4.0/src/build.c · 160.9 KB
From the archive ackfuss-4.4.0.tgz
Download the archive « Back to the archive contents
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* Ack 2.2 improvements copyright (C) 1994 by Stephen Dooley *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* _/ _/_/_/ _/ _/ _/ ACK! MUD is modified *
* _/_/ _/ _/ _/ _/ Merc2.0/2.1/2.2 code *
* _/ _/ _/ _/_/ _/ (c)Stephen Zepp 1998 *
* _/_/_/_/ _/ _/ _/ Version #: 4.3 *
* _/ _/ _/_/_/ _/ _/ _/ *
* *
* http://ackmud.nuc.net/ *
* zenithar@ackmud.nuc.net *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
/***************************************************************************
* _/_/_/_/ _/ _/ _/_/_/_/ _/_/_/_/ AckFUSS is modified ACK!MUD 4.3.1 *
* _/ _/ _/ _/ _/ copyright Matt Goff (Kline) 2008 *
* _/_/ _/ _/ _/_/_/_/ _/_/_/_/ *
* _/ _/ _/ _/ _/ Support for this code is provided *
* _/ _/_/_/_/ _/_/_/_/ _/_/_/_/ at www.ackmud.net -- check it out!*
***************************************************************************/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "globals.h"
#ifndef DEC_ACT_INFO_H
#include "h/act_info.h"
#endif
#ifndef DEC_ACT_MOVE_H
#include "h/act_move.h"
#endif
#ifndef DEC_ACT_WIZ_H
#include "h/act_wiz.h"
#endif
#ifndef DEC_AREACHK_H
#include "h/areachk.h"
#endif
#ifndef DEC_AREASAVE_H
#include "h/areasave.h"
#endif
#ifndef DEC_BUILD_H
#include "h/build.h"
#endif
#ifndef DEC_BUILDARE_H
#include "h/buildare.h"
#endif
#ifndef DEC_BUILDTAB_H
#include "h/buildtab.h"
#endif
#ifndef DEC_COMM_H
#include "h/comm.h"
#endif
#ifndef DEC_DB_H
#include "h/db.h"
#endif
#ifndef DEC_HANDLER_H
#include "h/handler.h"
#endif
#ifndef DEC_MONEY_H
#include "h/money.h"
#endif
#ifndef DEC_SSM_H
#include "h/ssm.h"
#endif
/* This program provides the interpreting of building commands */
/* The tables are now in buildtab.c: (This file was getting a bit big.)
Mob act flags : tab_mob_act : bitset
Player act flags : tab_player_act : bitset
Mob affected by : tab_affected_by : bit_vector
Object item type : tab_item_types : number
Object extra flags : tab_obj_flags : bitset
Object wear flags : tab_wear_flags : bitset
Object affect types : tab_obj_aff : number
Class types : tab_class : bit_vector
Wear locations : tab_wear_loc : number
Room flags : tab_room_flags : bitset
Sector types : tab_sector_types : number
Door types : tab_door_types : bitset
Door states : tab_door_states : number
*/
/*
* Directions.
*/
const char *sDirs[] = { "North", "East ", "South", "West ", "Up ", "Down " };
const char *cDirs = "NESWUD";
int RevDirs[] = { 2, 3, 0, 1, 5, 4 };
/*
* Sex.
* Used in #MOBILES.
*/
#define NEUTRAL 0
#define MALE 1
#define FEMALE 2
/* Interp. vars et al.
*
*/
/*
* Command logging types.
*/
#define LOG_NORMAL 0
#define LOG_ALWAYS 1
#define LOG_NEVER 2
/*
* God Levels
*/
#define L_GOD MAX_LEVEL
#define L_SUP L_GOD - 1
#define L_DEI L_SUP - 1
#define L_ANG L_DEI - 1
#define L_HER L_ANG - 1
/* Commands */
const struct cmd_type build_cmd_table[] = {
/*
* Common movement commands.
*/
{"north", do_north, POS_STANDING, 0, LOG_NORMAL},
{"east", do_east, POS_STANDING, 0, LOG_NORMAL},
{"south", do_south, POS_STANDING, 0, LOG_NORMAL},
{"west", do_west, POS_STANDING, 0, LOG_NORMAL},
{"up", do_up, POS_STANDING, 0, LOG_NORMAL},
{"down", do_down, POS_STANDING, 0, LOG_NORMAL},
{"goto", do_goto, POS_STANDING, 0, LOG_NORMAL},
/*
* Building commands.
*/
{"look", do_look, POS_STANDING, 0, LOG_NORMAL},
{"list", build_list, POS_STANDING, 0, LOG_NORMAL},
{"x", build_list, POS_STANDING, 0, LOG_NORMAL},
{"commands", build_commands, POS_STANDING, 0, LOG_NORMAL},
{"showarea", build_showarea, POS_STANDING, 0, LOG_NORMAL},
{"showmob", build_showmob, POS_STANDING, 0, LOG_NORMAL},
{"showroom", build_showroom, POS_STANDING, 0, LOG_NORMAL},
{"showobject", build_showobj, POS_STANDING, 0, LOG_NORMAL},
{"showresets", build_showresets, POS_STANDING, 0, LOG_NORMAL},
{"findarea", build_findarea, POS_STANDING, 0, LOG_NORMAL},
{"findmob", build_findmob, POS_STANDING, 0, LOG_NORMAL},
{"findmobroom", build_findmobroom, POS_STANDING, 0, LOG_NORMAL},
{"findroom", build_findroom, POS_STANDING, 0, LOG_NORMAL},
{"findobject", build_findobject, POS_STANDING, 0, LOG_NORMAL},
{"help", build_help, POS_STANDING, 0, LOG_NORMAL},
{"helpedit", build_helpedit, POS_STANDING, 0, LOG_NORMAL},
{"set", build_set, POS_STANDING, 0, LOG_NORMAL},
{"setarea", build_setarea, POS_STANDING, MAX_LEVEL - 1, LOG_NORMAL},
{"stop", build_stop, POS_STANDING, 0, LOG_ALWAYS},
{"dig", build_dig, POS_STANDING, 0, LOG_NORMAL},
{"makearea", build_makearea, POS_STANDING, L_SUP, LOG_NORMAL},
{"addobject", build_addobject, POS_STANDING, 0, LOG_NORMAL},
{"addmob", build_addmob, POS_STANDING, 0, LOG_NORMAL},
{"addroom", build_addroom, POS_STANDING, 0, LOG_NORMAL},
{"addreset", build_addreset, POS_STANDING, 0, LOG_NORMAL},
{"delroo", build_delwarn, POS_STANDING, 0, LOG_NORMAL},
{"delobjec", build_delwarn, POS_STANDING, 0, LOG_NORMAL},
{"delmobil", build_delwarn, POS_STANDING, 0, LOG_NORMAL},
{"delroom", build_delroom, POS_STANDING, 0, LOG_NORMAL},
{"delobject", build_delobject, POS_STANDING, 0, LOG_NORMAL},
{"delreset", build_delreset, POS_STANDING, 0, LOG_NORMAL},
{"delmobile", build_delmob, POS_STANDING, 0, LOG_NORMAL},
{"delhel", build_delwarn, POS_STANDING, MAX_LEVEL, LOG_NORMAL},
{"delhelp", build_delhelp, POS_STANDING, MAX_LEVEL, LOG_NORMAL},
{"forcereset", build_forcereset, POS_STANDING, 0, LOG_NORMAL},
{"findhelp", build_findhelp, POS_STANDING, 0, LOG_NORMAL},
{"addhelp", build_addhelp, POS_STANDING, 0, LOG_NORMAL},
{"redit", build_set_redit, POS_STANDING, 0, LOG_NORMAL},
{"oedit", build_set_oedit, POS_STANDING, 0, LOG_NORMAL},
{"medit", build_set_medit, POS_STANDING, 0, LOG_NORMAL},
{"nedit", build_set_nedit, POS_STANDING, 0, LOG_NORMAL},
{"setvnum", build_setvnum, POS_STANDING, 0, LOG_NORMAL},
{"vset", build_setvnum, POS_STANDING, 0, LOG_NORMAL},
{"uobjs", build_uobjs, POS_STANDING, 0, LOG_NORMAL},
{"urooms", build_urooms, POS_STANDING, 0, LOG_NORMAL},
{"umobs", build_umobs, POS_STANDING, 0, LOG_NORMAL},
{"values", build_listvalues, POS_STANDING, 0, LOG_NORMAL},
{"liquids", build_listliquids, POS_STANDING, 0, LOG_NORMAL},
{"weapons", build_listweapons, POS_STANDING, 0, LOG_NORMAL},
{"spells", build_listspells, POS_STANDING, 0, LOG_NORMAL},
{"check_area", do_check_area, POS_STANDING, MAX_LEVEL, LOG_NORMAL},
{"check_areas", do_check_areas, POS_STANDING, MAX_LEVEL, LOG_ALWAYS},
{"clone", build_clone, POS_STANDING, 0, LOG_NORMAL},
{"sysdata", build_sysdata, POS_STANDING, MAX_LEVEL, LOG_ALWAYS},
/*
* End of list.
*/
{"", 0, POS_DEAD, 0, LOG_NORMAL}
};
/* Variables declared in db.c, which we need */
extern char *string_hash[MAX_KEY_HASH];
extern char *string_space;
extern char *top_string;
extern char str_empty[1];
extern AREA_DATA *area_last;
extern AREA_DATA *area_first;
#define MAX_PERM_BLOCK 131072
extern long int nAllocString;
extern long int sAllocString;
extern int nAllocPerm;
extern int sAllocPerm;
void build_interpret( CHAR_DATA * ch, char *argument )
{
char command[MAX_INPUT_LENGTH];
char logline[MAX_INPUT_LENGTH];
char buffer[MAX_INPUT_LENGTH];
int cmd;
/* int trust; Unused var*/
bool found;
/*
* Strip leading spaces.
*/
while( isspace( *argument ) )
argument++;
if( argument[0] == '\0' )
return;
/*
* Grab the command word.
* Special parsing so ' can be a command,
* also no spaces needed after punctuation.
*/
strcpy( logline, argument );
if( !isalpha( argument[0] ) && !isdigit( argument[0] ) )
{
command[0] = argument[0];
command[1] = '\0';
argument++;
while( isspace( *argument ) )
argument++;
}
else
{
argument = one_argument( argument, command );
}
/*
* Look for command in command table.
*/
found = FALSE;
for( cmd = 0; build_cmd_table[cmd].name[0] != '\0'; cmd++ )
{
if( command[0] == build_cmd_table[cmd].name[0]
&& !str_prefix( command, build_cmd_table[cmd].name ) && get_trust( ch ) >= build_cmd_table[cmd].level )
{
found = TRUE;
break;
}
}
/*
* Log and snoop.
*/
if( build_cmd_table[cmd].log == LOG_NEVER )
strcpy( logline, "XXXXXXXX XXXXXXXX XXXXXXXX" );
if( ( !IS_NPC( ch ) && ch->act.test(ACT_LOG) ) || fLogAll || build_cmd_table[cmd].log == LOG_ALWAYS )
{
snprintf( log_buf, (2 * MIL), "Log %s: %s", ch->name, logline );
log_string( log_buf );
monitor_chan( log_buf, MONITOR_BUILD );
}
if( ch->desc != NULL && ch->desc->snoop_by != NULL )
{
write_to_buffer( ch->desc->snoop_by, "% ", 2 );
write_to_buffer( ch->desc->snoop_by, logline );
write_to_buffer( ch->desc->snoop_by, "\r\n", 2 );
}
if( !found )
{
snprintf( buffer, MSL, "%s %s", command, argument );
build_set( ch, buffer );
return;
}
/*
* Dispatch the command.
*/
( *build_cmd_table[cmd].do_fun ) ( ch, argument );
/*
* make sure that if in Redit, vnum is at new room.
*/
if( ch->act_build == ACT_BUILD_REDIT && ch->build_vnum != ch->in_room->vnum )
{
ch->build_vnum = ch->in_room->vnum;
send_to_char( "Redit: Vnum changed to new room.\r\n", ch );
}
tail_chain( );
return;
}
/* -S- Addition: */
void build_commands( CHAR_DATA * ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char out[MAX_STRING_LENGTH];
int cmd;
int col = 0;
snprintf( out, MSL, "Building / Editing Commands Available to You:\r\n" );
for( cmd = 0; build_cmd_table[cmd].name[0] != '\0'; cmd++ )
{
if( build_cmd_table[cmd].level > get_trust( ch ) )
continue;
snprintf( buf, MSL, "%-20s ", build_cmd_table[cmd].name );
strncat( out, buf, MSL );
if( ++col % 3 == 0 )
strncat( out, "\r\n", MSL );
}
strncat( out, "\r\n", MSL );
send_to_char( out, ch );
return;
}
void build_showmob( CHAR_DATA * ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
MOB_INDEX_DATA *pMob;
/* RESET_DATA *pReset; Unused var */
SHOP_DATA *pShop;
bool is_shopkeeper = 0;
int iTrade;
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if( arg1[0] == '\0' )
{
send_to_char( "showmob <vnum>\r\n", ch );
return;
}
if( !is_number( arg1 ) )
{
send_to_char( "must be a vnum.\r\n", ch );
return;
}
if( ( pMob = get_mob_index( atoi( arg1 ) ) ) == NULL )
{
send_to_char( "Cannot find a mob with that vnum.\r\n", ch );
return;
}
if( !build_canread( pMob->area, ch, 1 ) )
return;
buf1[0] = '\0';
snprintf( buf, MSL, "@@WName: @@y%s. @@WClass: @@y%s.\r\n", pMob->player_name, tab_mob_class[pMob->p_class].text );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WVnum: @@y%d. @@WSex: @@y%s. @@WRace:@@y %s ",
pMob->vnum,
pMob->sex == SEX_MALE ? "male" :
pMob->sex == SEX_FEMALE ? "female" : "neutral",
( ( pMob->race > -1 ) && ( pMob->race < MAX_RACE ) ) ? race_table[pMob->race].race_title : "Illegal Race" );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, " @@WLv: @@y%d. @@WAlign: @@y%d.\r\n", pMob->level, pMob->alignment );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WModifiers: AC: @@y%d. @@WHitroll: @@y%d. @@WDamroll: @@y%d.\r\n",
pMob->ac_mod, pMob->hr_mod, pMob->dr_mod );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WMob Flags:@@y\r\n%s", bs_show_values( tab_mob_act, pMob->act ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WAffected by:@@y\r\n%s", show_values( tab_affected_by, pMob->affected_by, TRUE ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WSkill Flags:@@y %s\r\n", bit_table_lookup( tab_mob_skill, pMob->skills ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WCast Flags:@@y %s\r\n", bit_table_lookup( tab_mob_cast, pMob->cast ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WDef Flags:@@y %s\r\n", bit_table_lookup( tab_mob_def, pMob->def ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WStrong Magic Realms:@@y %s\r\n", bit_table_lookup( tab_magic_realms, pMob->strong_magic ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WWeak Magic Realms:@@y %s\r\n", bit_table_lookup( tab_magic_realms, pMob->weak_magic ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WResist Magic Realms:@@y %s\r\n", bit_table_lookup( tab_magic_realms, pMob->resist ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WSuscept Magic Realms:@@y %s\r\n", bit_table_lookup( tab_magic_realms, pMob->suscept ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WRace Mods:@@y %s\r\n", bit_table_lookup( tab_mob_race_mods, pMob->race_mods ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WShort description: @@y%s.\r\n@@WLong description: @@y%s\r\n",
pMob->short_descr, pMob->long_descr[0] != '\0' ? pMob->long_descr : "(none)." );
strncat( buf1, buf, MSL );
if( pMob->spec_fun != 0 )
{
snprintf( buf, MSL, "@@WMobile has spec fun: @@y%s\r\n", rev_spec_lookup( pMob->spec_fun ) );
strncat( buf1, buf, MSL );
}
if( ( pShop = pMob->pShop ) != 0 )
{
is_shopkeeper = 1;
strncat( buf1, "@@WMobile is a shopkeeper, will buy @@y", MSL );
for( iTrade = 0; iTrade < MAX_TRADE; iTrade++ )
{
if( pShop->buy_type[iTrade] > 0 )
{
strncat( buf1, tab_item_types[pShop->buy_type[iTrade] - 1].text, MSL );
strncat( buf1, " ", MSL );
}
}
strncat( buf1, "\r\n", MSL );
snprintf( buf, MSL, "@@WOpens at @@y%i @@Whrs, shuts at @@y%i @@Whours, profbuy:@@y%i, @@Wprofsell:@@y%i.\r\n",
pShop->open_hour, pShop->close_hour, pShop->profit_buy, pShop->profit_sell );
strncat( buf1, buf, MSL );
}
strncat( buf1, "@@g", MSL );
send_to_char( buf1, ch );
return;
}
void build_showobj( CHAR_DATA * ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
AFFECT_DATA *paf;
OBJ_INDEX_DATA *obj;
int cnt;
char *foo;
int fubar;
one_argument( argument, arg );
if( arg[0] == '\0' )
{
send_to_char( "Show what object?\r\n", ch );
return;
}
if( !is_number( arg ) )
{
send_to_char( "must be a vnum.\r\n", ch );
return;
}
buf1[0] = '\0';
if( ( obj = get_obj_index( atoi( arg ) ) ) == NULL )
{
send_to_char( "Object vnum not found.\r\n", ch );
return;
}
if( !build_canread( obj->area, ch, 1 ) )
return;
snprintf( buf, MSL, "@@WName: @@y%s @@WLevel: @@y%d.\r\n", obj->name, obj->level );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WVnum: @@y%d. @@WType: @@y%s.\r\n", obj->vnum, tab_item_types[( obj->item_type ) - 1].text );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WShort description: @@y%s.\r\n@@WLong description: @@y%s\r\n", obj->short_descr, obj->long_descr );
strncat( buf1, buf, MSL );
/*
* snprintf( buf, MSL, "@@WItem type: @@y%s.\r\n",rev_table_lookup(tab_item_types,obj->item_type));
* strncat( buf1, buf, MSL);
*/
snprintf( buf, MSL, "@@WWear bits:\r\n@@y%s\r\n@@WExtra bits: @@y%s\r\n",
bs_show_values( tab_wear_flags, obj->wear_flags ), extra_bit_name( obj->extra_flags ) );
/*
* bit_table_lookup(tab_extra_flags, obj->extra_flags ) );
* I think another bit_table_lookup is better! Zen
*/
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WItem_applies: @@y%s.\r\n", bit_table_lookup( tab_item_apply, obj->item_apply ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WWeight: @@y%d.\r\n", obj->weight );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WSpeed: @@y%4.2f\r\n", obj->speed );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WDurability: @@y%d.\r\n", obj->max_durability );
strncat( buf1, buf, MSL );
strncat( buf1, "@@WObject Values:\r\n", MSL );
for( cnt = 0; cnt < 10; cnt++ )
{
snprintf( buf, MSL, "@@W[Value%d : @@y%6d@@W] %s",
cnt, obj->value[cnt], rev_table_lookup( tab_value_meanings, ( obj->item_type * 10 ) + cnt ) );
strncat( buf1, buf, MSL );
if( is_name( "Spell", rev_table_lookup( tab_value_meanings, ( obj->item_type * 10 ) + cnt ) ) )
{
fubar = obj->value[cnt];
if( fubar < 0 || fubar > MAX_SKILL )
snprintf( buf, MSL, " @@R(INVALID!)@@g\r\n" );
else
snprintf( buf, MSL, " @@y(%s)@@g\r\n", skill_table[fubar].name );
}
else if( is_name( "Liquid", rev_table_lookup( tab_value_meanings, ( obj->item_type * 10 ) + cnt ) ) )
{
foo = str_dup( rev_table_lookup( tab_drink_types, obj->value[cnt] ) );
if( foo[0] == '\0' )
snprintf( buf, MSL, " @@R(INVALID!)@@g\r\n" );
else
snprintf( buf, MSL, " @@y(%s)@@g\r\n", foo );
}
else if( is_name( "Weapon", rev_table_lookup( tab_value_meanings, ( obj->item_type * 10 ) + cnt ) ) )
{
foo = rev_table_lookup( tab_weapon_types, obj->value[cnt] );
if( foo[0] == '\0' )
snprintf( buf, MSL, " @@R(INVALID!)@@g\r\n" );
else
snprintf( buf, MSL, " @@y(%s)@@g\r\n", foo );
}
else if( is_name( "Charm", rev_table_lookup( tab_value_meanings, ( obj->item_type * 10 ) + cnt ) ) )
{
foo = rev_table_lookup( tab_charm_types, obj->value[cnt] );
if( foo[0] == '\0' )
snprintf( buf, MSL, " @@R(INVALID!)@@g\r\n" );
else
snprintf( buf, MSL, " @@y(%s)@@g\r\n", foo );
}
else
snprintf( buf, MSL, "@@g\r\n" );
strncat( buf1, buf, MSL );
}
if( obj->obj_fun != NULL )
{
snprintf( buf, MSL, "@@WObject has objfun: @@y%s.@@g\r\n", rev_obj_fun_lookup( obj->obj_fun ) );
strncat( buf1, buf, MSL );
}
if( obj->first_exdesc != NULL )
{
EXTRA_DESCR_DATA *ed;
strncat( buf1, "@@WExtra description keywords: '@@y", MSL );
for( ed = obj->first_exdesc; ed != NULL; ed = ed->next )
{
strncat( buf1, ed->keyword, MSL );
if( ed->next != NULL )
strncat( buf1, " ", MSL );
}
strncat( buf1, "'@@g.\r\n", MSL );
}
for( paf = obj->first_apply; paf != NULL; paf = paf->next )
{
snprintf( buf, MSL, "@@WAffects @@y%s @@Wby @@y%d@@g.\r\n", affect_loc_name( paf->location ), paf->modifier );
strncat( buf1, buf, MSL );
}
send_to_char( buf1, ch );
return;
}
#define DISPLAY_BRIEFDOORS 1
#define DISPLAY_RESETS 2
#define DISPLAY_FULLDOORS 4
#define DISPLAY_DESC 8
void build_showroom( CHAR_DATA * ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
char arg1[MAX_INPUT_LENGTH];
ROOM_INDEX_DATA *location;
BUILD_DATA_LIST *Pointer;
int door;
int display;
argument = one_argument( argument, arg1 );
location = ch->in_room;
if( !build_canread( location->area, ch, 1 ) )
return;
display = 0;
if( arg1[0] == '\0' )
{
display = DISPLAY_BRIEFDOORS | DISPLAY_RESETS | DISPLAY_DESC;
strncat( buf1, "Can also use showroom brief/doors/resets/desc/all.\r\n", MSL );
}
else if( !is_name( arg1, "brief doors resets desc all" ) )
{
send_to_char( "Syntax: Showroom brief/doors/resets/desc/all.\r\n", ch );
return;
}
if( !str_cmp( arg1, "brief" ) )
display = DISPLAY_BRIEFDOORS;
if( !str_cmp( arg1, "doors" ) )
display = DISPLAY_FULLDOORS;
if( !str_cmp( arg1, "resets" ) )
display = DISPLAY_RESETS;
if( !str_cmp( arg1, "desc" ) )
display = DISPLAY_DESC;
if( !str_cmp( arg1, "all" ) )
display = DISPLAY_FULLDOORS | DISPLAY_RESETS | DISPLAY_DESC;
buf1[0] = '\0';
snprintf( buf, MSL, "@@WName: @@y%s.\r\n@@WArea: @@y%s.\r\n", location->name, location->area->name );
strncat( buf1, buf, MSL );
snprintf( buf, MSL,
"@@WVnum: @@y%d. @@WSector:\r\n @@y%s",
location->vnum, show_values( tab_sector_types, location->sector_type, FALSE ) );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, "@@WFlags:\r\n@@y%s", bs_show_values( tab_room_flags, location->room_flags ) );
strncat( buf1, buf, MSL );
if( ( display & DISPLAY_DESC ) )
{
snprintf( buf, MSL, "\r\n@@WDescr: @@y%s@@N\r\n", location->description[0] != '\0' ? location->description : "(none)." );
strncat( buf1, buf, MSL );
}
if( location->first_exdesc != NULL )
{
EXTRA_DESCR_DATA *ed;
strncat( buf1, "@@WExtra description keywords:@@y '", MSL );
for( ed = location->first_exdesc; ed; ed = ed->next )
{
strncat( buf1, ed->keyword, MSL );
if( ed->next != NULL )
strncat( buf1, " ", MSL );
}
strncat( buf1, "'.\r\n", MSL );
}
/*
* Exits
*/
if( ( display & ( DISPLAY_BRIEFDOORS | DISPLAY_FULLDOORS ) ) )
for( door = 0; door < MAX_DIR; door++ )
{
EXIT_DATA *pexit;
OBJ_INDEX_DATA *pKeyObj;
if( ( pexit = location->exit[door] ) != NULL )
{
if( ( display & DISPLAY_FULLDOORS ) )
{
if( pexit->key > 0 )
pKeyObj = get_obj_index( pexit->key );
else
pKeyObj = NULL;
snprintf( buf, MSL, "@@WExit: @@y%7s @@W: To @@y%5i %s@@N\r\n", sDirs[door],
pexit->to_room != NULL ? pexit->to_room->vnum : 0,
pexit->to_room != NULL ? pexit->to_room->name : "" );
strncat( buf1, buf, MSL );
snprintf( buf, MSL, " @@WKey: @@y%5i %s@@N\r\n@@WExit Type:@@y %s@@N\r\n",
pKeyObj != NULL ? pKeyObj->vnum : 0,
pKeyObj != NULL ? pKeyObj->name : "None", bs_show_values( tab_door_types, pexit->exit_info ) );
strncat( buf1, buf, MSL );
if( pexit->keyword != NULL && pexit->keyword[0] != '\0' )
{
snprintf( buf, MSL, "@@WKeyword(s): @@y%s. ", pexit->keyword );
strncat( buf1, buf, MSL );
}
snprintf( buf, MSL, "@@WDesc: @@y%s", pexit->description[0] != '\0' ? pexit->description : "(none).\r\n" );
strncat( buf1, buf, MSL );
}
else
{
if( pexit->key > 0 )
strncat( buf1, "@@yK", MSL );
/*
* New way of showing doors... move to relevant place if it works
*/
snprintf( buf, MSL, "\r\n%s: (%s) @@WTo: @@y(%i) %s\r\n@@WExit flags:@@N %s\r\n", sDirs[door],
pexit->keyword,
pexit->to_room != NULL ? pexit->to_room->vnum : 0,
pexit->to_room != NULL ? pexit->to_room->name : "Unknown",
exit_bit_name( pexit->exit_info ));
strncat( buf1, buf, MSL );
}
}
}
/*
* Show resets for room
*/
if( ( display & DISPLAY_RESETS ) && location->first_room_reset != NULL )
{
strncat( buf1, "@@WResets:\r\n", MSL );
for( Pointer = location->first_room_reset; Pointer; )
strncat( buf1, reset_to_text( &Pointer, NULL ), MSL );
}
strncat( buf1, "@@g", MSL );
send_to_char( buf1, ch );
return;
}
void build_showresets( CHAR_DATA * ch, char *argument )
{
char buf1[MAX_STRING_LENGTH];
ROOM_INDEX_DATA *location;
BUILD_DATA_LIST *Pointer;
int count;
count = 0;
buf1[0] = '\0';
location = ch->in_room;
if( !build_canread( location->area, ch, 1 ) )
return;
strncat( buf1, "Room Resets:\r\n", MSL );
for( Pointer = location->first_room_reset; Pointer != NULL; )
strncat( buf1, reset_to_text( &Pointer, &count ), MSL );
send_to_char( buf1, ch );
}
/* spec: rewrote to catch errors and count how many resets it handled */
char *reset_to_text( BUILD_DATA_LIST ** pList, int *pcount )
{
char buf[MAX_STRING_LENGTH];
static char buf1[MAX_STRING_LENGTH];
MOB_INDEX_DATA *pMob;
OBJ_INDEX_DATA *pObj, *to_obj;
RESET_DATA *pReset;
buf[0] = '\0';
buf1[0] = '\0';
pReset = (RESET_DATA *)( *pList )->data;
strncat( buf1, build_docount( pcount ), MSL );
if( ( *pList )->is_free ) /* sanity check */
strncat( buf1, " **LIST IS FREE** ", MSL ); /* Bad Thing! */
if( pReset->is_free )
strncat( buf1, " **RESET IS FREE** ", MSL );
( *pList ) = ( *pList )->next;
switch ( pReset->command )
{
default:
snprintf( buf, MSL, " stray '%c' reset: %d %d %d.\r\n", pReset->command, pReset->arg1, pReset->arg2, pReset->arg3 );
strncat( buf1, buf, MSL );
break;
case 'G':
pObj = get_obj_index( pReset->arg1 );
if( pObj )
snprintf( buf, MSL, " stray 'give' reset: object [%d] %s.\r\n", pReset->arg1, pObj->name );
else
snprintf( buf, MSL, " stray 'give' reset: object %d (unknown).\r\n", pReset->arg1 );
strncat( buf1, buf, MSL );
break;
case 'E':
pObj = get_obj_index( pReset->arg1 );
if( pObj )
snprintf( buf, MSL, " stray 'equip' reset: object [%d] %s, on %s.\r\n",
pReset->arg1, pObj->name, tab_wear_loc[( pReset->arg3 )].text );
else
snprintf( buf, MSL, " stray 'equip' reset: object [%d] (unknown), on %s.\r\n",
pReset->arg1, tab_wear_loc[( pReset->arg3 )].text );
strncat( buf1, buf, MSL );
break;
case 'A': /* AutoMessage for room */
snprintf( buf1, MSL, "Message: (%d-%d) %s\r\n", pReset->arg2, pReset->arg3, pReset->notes );
strncat( buf1, buf, MSL );
break;
case 'M': /* Load mob */
pMob = get_mob_index( pReset->arg1 );
if( pMob != NULL )
snprintf( buf, MSL, " [%d] %s (limit of %d).\r\n", pMob->vnum, pMob->player_name, pReset->arg2 );
else
snprintf( buf, MSL, " [%d] (unknown) (limit of %d).\r\n", pReset->arg1, pReset->arg2 );
strncat( buf1, buf, MSL );
/*
* scan for give and equip commands for this mob
*/
while( *pList )
{
pReset = (RESET_DATA *)( *pList )->data;
if( pReset->command != 'G' && pReset->command != 'E' )
break;
( *pList ) = ( *pList )->next;
strncat( buf1, build_docount( pcount ), MSL );
if( pReset->command == 'G' )
{
pObj = get_obj_index( pReset->arg1 );
if( pObj != NULL )
{
if( pMob->pShop != NULL )
strncat( buf1, " sells ", MSL );
else
strncat( buf1, " with ", MSL );
snprintf( buf, MSL, "[%d] %s.\r\n", pObj->vnum, pObj->name );
strncat( buf1, buf, MSL );
}
else
{
snprintf( buf, MSL, "[%d] unknown object in give reset!\r\n", pReset->arg1 );
strncat( buf1, buf, MSL );
}
}
else if( pReset->command == 'E' )
{
pObj = get_obj_index( pReset->arg1 );
if( pObj != NULL )
snprintf( buf, MSL, " equiped with [%d] %s, on %s.\r\n", pObj->vnum,
pObj->name, tab_wear_loc[( pReset->arg3 )].text );
else
snprintf( buf, MSL, "[%d] unknown object equipped on %s.\r\n", pReset->arg1, tab_wear_loc[pReset->arg3].text );
strncat( buf1, buf, MSL );
}
}
break;
case 'O': /* Load object to room */
pObj = get_obj_index( pReset->arg1 );
if( pObj != NULL )
snprintf( buf, MSL, " [%d] %s no more than %d in room.\r\n", pObj->vnum, pObj->name, pReset->arg2 );
else
snprintf( buf, MSL, " [%d] unknown object reset!\r\n", pReset->arg1 );
strncat( buf1, buf, MSL );
break;
case 'P':
pObj = get_obj_index( pReset->arg1 );
to_obj = get_obj_index( pReset->arg3 );
if( pObj )
{
if( to_obj )
snprintf( buf, MSL, " object [%d] %s inside object [%d] %s. (limit %d)\r\n", pReset->arg1, pObj->name, pReset->arg3, to_obj->name, pReset->arg2 );
else
snprintf( buf, MSL, " object [%d] %s inside object [%d] (unknown). (limit %d)\r\n", pReset->arg1, pObj->name, pReset->arg3, pReset->arg2 );
}
else
snprintf( buf, MSL, " object [%d] (unknown) inside object [%d] (unknown). (limit %d)\r\n", pReset->arg1, pReset->arg3, pReset->arg2 );
strncat( buf1, buf, MSL );
break;
case 'D': /* close/lock doors */
buf[0] = '\0';
switch ( pReset->arg3 )
{
default:
snprintf( buf, MSL, " Illegal door state %d for door %d\r\n", pReset->arg1, pReset->arg2 );
case 0:
snprintf( buf, MSL, " Open door %s.\r\n", sDirs[pReset->arg2] );
break;
case 1:
snprintf( buf, MSL, " Close door %s.\r\n", sDirs[pReset->arg2] );
break;
case 2:
snprintf( buf, MSL, " Close and lock door %s.\r\n", sDirs[pReset->arg2] );
break;
}
strncat( buf1, buf, MSL );
break;
case 'R': /* randomise exits */
snprintf( buf, MSL, " Randomize doors up to number %d.\r\n", pReset->arg2 );
strncat( buf1, buf, MSL );
break;
}
return buf1;
}
char *build_docount( int *pcount )
{
static char buf[20];
buf[0] = '\0';
if( pcount != NULL )
snprintf( buf, MSL, "%d) ", ++*pcount );
else
buf[0] = '\0';
return buf;
}
void build_findmob( CHAR_DATA * ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
MOB_INDEX_DATA *pMobIndex;
BUILD_DATA_LIST *Pointer;
AREA_DATA *Area;
int nMatch;
bool fAll;
bool found;
one_argument( argument, arg );
if( arg[0] == '\0' )
{
send_to_char( "find which mob?\r\n", ch );
return;
}
if( !( Area = ch->in_room->area ) )
{
send_to_char( "Don't know what area you're in.\r\n", ch );
return;
}
if( !build_canread( Area, ch, 1 ) )
return;
if( !( Pointer = Area->first_area_mobile ) )
{
send_to_char( "No mobiles in this area.\r\n", ch );
return;
}
buf1[0] = '\0';
fAll = !str_cmp( arg, "all" );
found = FALSE;
nMatch = 0;
for( ; Pointer != NULL; Pointer = Pointer->next )
{
nMatch++;
pMobIndex = (MOB_INDEX_DATA *)Pointer->data;
if( fAll || is_name( arg, pMobIndex->player_name ) )
{
found = TRUE;
snprintf( buf, MSL, "[%5d] %s\r\n", pMobIndex->vnum, capitalize( pMobIndex->short_descr ) );
strncat( buf1, buf, MSL );
}
}
if( !found )
{
send_to_char( "Nothing like that in this area.\r\n", ch );
return;
}
send_to_char( buf1, ch );
return;
}
void build_findmobroom( CHAR_DATA * ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
ROOM_INDEX_DATA *pRoom;
RESET_DATA *pReset;
AREA_DATA *Area;
int vnum, found;
one_argument( argument, arg );
if( arg[0] == '\0' )
{
send_to_char( "find which mob vnum?\r\n", ch );
return;
}
if( !is_number( arg ) )
{
send_to_char( "syntax: findmobroom vnum.\r\n", ch );
return;
}
vnum = atoi( arg );
found = 0;
buf1[0] = '\0';
if( !( Area = ch->in_room->area ) )
{
send_to_char( "Don't know what area you're in.\r\n", ch );
return;
}
if( !build_canread( Area, ch, 1 ) )
return;
for( pReset = Area->first_reset; pReset != NULL; pReset = pReset->next )
{
if( pReset->command == 'M' && pReset->arg1 == vnum )
{
found = TRUE;
pRoom = get_room_index( pReset->arg3 );
if( pRoom != NULL )
snprintf( buf, MSL, "[%5d] %s\r\n", pRoom->vnum, capitalize( pRoom->name ) );
else
snprintf( buf, MSL, "[%5d] Unknown\r\n", pReset->arg3 );
strncat( buf1, buf, MSL );
}
}
if( !found )
{
send_to_char( "Mob not found in any room.\r\n", ch );
return;
}
send_to_char( buf1, ch );
return;
}
void build_findobject( CHAR_DATA * ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
OBJ_INDEX_DATA *pObjIndex;
BUILD_DATA_LIST *pList;
AREA_DATA *Area;
int nMatch;
bool fAll;
bool found;
one_argument( argument, arg );
if( arg[0] == '\0' )
{
send_to_char( "Find what object?\r\n", ch );
return;
}
if( !( Area = ch->in_room->area ) )
{
send_to_char( "Don't know what area you're in.\r\n", ch );
return;
}
if( !build_canread( Area, ch, 1 ) )
return;
if( !( pList = Area->first_area_object ) )
{
send_to_char( "No objects in this area.\r\n", ch );
return;
}
buf1[0] = '\0';
fAll = !str_cmp( arg, "all" );
found = FALSE;
nMatch = 0;
for( ; pList != NULL; pList = pList->next )
{
pObjIndex = (OBJ_INDEX_DATA *)pList->data;
nMatch++;
if( fAll || is_name( arg, pObjIndex->name ) )
{
found = TRUE;
snprintf( buf, MSL, "[%5d] %s\r\n", pObjIndex->vnum, capitalize( pObjIndex->short_descr ) );
strncat( buf1, buf, MSL );
}
}
if( !found )
{
send_to_char( "Nothing like that in the area.\r\n", ch );
return;
}
send_to_char( buf1, ch );
return;
}
void build_findroom( CHAR_DATA * ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
ROOM_INDEX_DATA *pRoomIndex;
BUILD_DATA_LIST *pList;
AREA_DATA *Area;
int nMatch;
bool fAll;
bool found;
one_argument( argument, arg );
if( arg[0] == '\0' )
{
send_to_char( "Find what room?\r\n", ch );
return;
}
if( !( Area = ch->in_room->area ) )
{
send_to_char( "Don't know what area you're in.\r\n", ch );
return;
}
if( !build_canread( Area, ch, 1 ) )
return;
if( !( pList = Area->first_area_room ) )
{
send_to_char( "No rooms in this area.\r\n", ch );
return;
}
buf1[0] = '\0';
fAll = !str_cmp( arg, "all" );
found = FALSE;
nMatch = 0;
for( ; pList != NULL; pList = pList->next )
{
pRoomIndex = (ROOM_INDEX_DATA *)pList->data;
nMatch++;
if( fAll || is_name( arg, pRoomIndex->name ) )
{
found = TRUE;
snprintf( buf, MSL, "[%5d] %s\r\n", pRoomIndex->vnum, capitalize( pRoomIndex->name ) );
strncat( buf1, buf, MSL );
}
}
if( !found )
{
send_to_char( "Nothing like that in the area.\r\n", ch );
return;
}
send_to_char( buf1, ch );
return;
}
/* -S- : More 'intelligent' way to handle things perhaps? */
void build_setmob( CHAR_DATA * ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char arg3[MAX_INPUT_LENGTH];
char arg4[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
/* char buf2 [MAX_STRING_LENGTH]; unused */
/* char buffer[MAX_STRING_LENGTH]; unused */
/* char name[MAX_INPUT_LENGTH]; unused */
MOB_INDEX_DATA *pMob;
/* char *argn, *oldperm; unused */
int value, num;
int lvalue; /* lookup value */
AREA_DATA *pArea;
smash_tilde( argument );
argument = one_argument( argument, arg1 ); /* vnum */
argument = one_argument( argument, arg2 );
strcpy( arg3, argument );
/** Changes to old setmob: *********************************
Check through the tables, to see if the
builder has entered the name of an entry. If so, toggle
entry( new way of showing bits set is now used )
Otherwise, check for other values being set, or huh? :P
************************************************************/
if( arg1[0] == '\0' || arg2[0] == '\0' )
{
send_to_char( "Syntax: [set] <field> <value>\r\n", ch );
send_to_char( "or: [set] <string> <value>\r\n", ch );
send_to_char( "or: [set] edit <string>\r\n", ch );
send_to_char( "or: [set] shop <shopspec> <value>\r\n", ch );
send_to_char( "\r\n", ch );
send_to_char( "Field being one of:\r\n", ch );
send_to_char( " sex level align aff act\r\n", ch );
send_to_char( " class clan position race\r\n", ch );
send_to_char( " skill cast def rmod\r\n", ch );
send_to_char( " hr_mod dr_mod ac_mod\r\n", ch );
send_to_char( "String being one of:\r\n", ch );
send_to_char( " name short long desc spec\r\n", ch );
send_to_char( "Use [set] spec - to clear spec_fun\r\n", ch );
send_to_char( "Shopspec being one of:\r\n", ch );
send_to_char( " trade0 - trade4 profbuy profsell openhour\r\n", ch );
send_to_char( " closehour clear\r\n", ch );
return;
}
if( !is_number( arg1 ) )
{
send_to_char( "Must be a vnum for first arg.\r\n", ch );
return;
}
if( ( pMob = get_mob_index( atoi( arg1 ) ) ) == NULL )
{
send_to_char( "Cannot find mob with that vnum.\r\n", ch );
return;
}
pArea = pMob->area;
if( !build_canwrite( pArea, ch, 1 ) )
return;
/*
* Snarf the value (which need not be numeric).
*/
value = is_number( arg3 ) ? atoi( arg3 ) : -1;
/*
* Check for act flags
*/
lvalue = table_lookup( tab_mob_act, arg2 );
if( lvalue != 0 )
{
/*
* Then we've found a value
*/
pMob->act.flip(lvalue);
send_to_char( "OK. Act Flag toggled.\r\n", ch );
area_modified( pArea );
return;
}
/*
* Check for affected_by flags
*/
lvalue = table_lookup( tab_affected_by, arg2 );
if( lvalue != 0 )
{
/*
* Then we've found a value
*/
if( IS_SET( pMob->affected_by, lvalue ) )
REMOVE_BIT( pMob->affected_by, lvalue );
else
SET_BIT( pMob->affected_by, lvalue );
send_to_char( "OK. Affected_by Flag toggled.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "skills" ) )
{
lvalue = table_lookup( tab_mob_skill, arg3 );
if( lvalue == 0 )
{
snprintf( buf, MSL, "You can toggle the following flags:\r\n" );
table_printout( tab_mob_skill, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
/*
* Toggle flag
*/
if( IS_SET( pMob->skills, lvalue ) )
REMOVE_BIT( pMob->skills, lvalue );
else
SET_BIT( pMob->skills, lvalue );
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "cast" ) )
{
lvalue = table_lookup( tab_mob_cast, arg3 );
if( lvalue == 0 )
{
snprintf( buf, MSL, "You can toggle the following flags:\r\n" );
table_printout( tab_mob_cast, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
/*
* Toggle flag
*/
if( IS_SET( pMob->cast, lvalue ) )
REMOVE_BIT( pMob->cast, lvalue );
else
SET_BIT( pMob->cast, lvalue );
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "def" ) )
{
lvalue = table_lookup( tab_mob_def, arg3 );
if( lvalue == 0 )
{
snprintf( buf, MSL, "You can toggle the following flags:\r\n" );
table_printout( tab_mob_def, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
/*
* Toggle flag
*/
if( IS_SET( pMob->def, lvalue ) )
REMOVE_BIT( pMob->def, lvalue );
else
SET_BIT( pMob->def, lvalue );
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "strong" ) )
{
lvalue = table_lookup( tab_magic_realms, arg3 );
if( lvalue == 0 )
{
snprintf( buf, MSL, "You can toggle the following flags:\r\n" );
table_printout( tab_magic_realms, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
/*
* Toggle flag
*/
if( IS_SET( pMob->strong_magic, lvalue ) )
REMOVE_BIT( pMob->strong_magic, lvalue );
else
SET_BIT( pMob->strong_magic, lvalue );
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "rmod" ) )
{
lvalue = table_lookup( tab_mob_race_mods, arg3 );
if( lvalue == 0 )
{
snprintf( buf, MSL, "You can toggle the following flags:\r\n" );
table_printout( tab_mob_race_mods, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
/*
* Toggle flag
*/
if( IS_SET( pMob->race_mods, lvalue ) )
REMOVE_BIT( pMob->race_mods, lvalue );
else
SET_BIT( pMob->race_mods, lvalue );
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "weak" ) )
{
lvalue = table_lookup( tab_magic_realms, arg3 );
if( lvalue == 0 )
{
snprintf( buf, MSL, "You can toggle the following flags:\r\n" );
table_printout( tab_magic_realms, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
/*
* Toggle flag
*/
if( IS_SET( pMob->weak_magic, lvalue ) )
REMOVE_BIT( pMob->weak_magic, lvalue );
else
SET_BIT( pMob->weak_magic, lvalue );
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "resist" ) )
{
lvalue = table_lookup( tab_magic_realms, arg3 );
if( lvalue == 0 )
{
snprintf( buf, MSL, "You can toggle the following flags:\r\n" );
table_printout( tab_magic_realms, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
/*
* Toggle flag
*/
if( IS_SET( pMob->resist, lvalue ) )
REMOVE_BIT( pMob->resist, lvalue );
else
SET_BIT( pMob->resist, lvalue );
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "suscept" ) )
{
lvalue = table_lookup( tab_magic_realms, arg3 );
if( lvalue == 0 )
{
snprintf( buf, MSL, "You can toggle the following flags:\r\n" );
table_printout( tab_magic_realms, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
/*
* Toggle flag
*/
if( IS_SET( pMob->suscept, lvalue ) )
REMOVE_BIT( pMob->suscept, lvalue );
else
SET_BIT( pMob->suscept, lvalue );
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "rmod" ) )
{
lvalue = table_lookup( tab_mob_race_mods, arg3 );
if( lvalue == 0 )
{
snprintf( buf, MSL, "You can toggle the following flags:\r\n" );
table_printout( tab_mob_race_mods, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
/*
* Toggle flag
*/
if( IS_SET( pMob->race_mods, lvalue ) )
REMOVE_BIT( pMob->race_mods, lvalue );
else
SET_BIT( pMob->race_mods, lvalue );
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "class" ) )
{
lvalue = table_lookup( tab_mob_class, arg3 );
if( lvalue == -1 )
{
snprintf( buf, MSL, "You can use the following classes:\r\n" );
table_printout( tab_mob_class, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
pMob->p_class = lvalue;
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "race" ) )
{
lvalue = is_number( arg3 ) ? atoi( arg3 ) : -1;
if( ( lvalue < -1 ) || ( lvalue > MAX_RACE ) )
{
int looper;
char catbuf[MSL];
snprintf( buf, MSL, "You can use the following races:\r\n" );
for( looper = 0; looper < MAX_RACE; looper++ )
{
snprintf( catbuf, MSL, "[%i]:%s ", looper, race_table[looper].race_title );
strncat( buf, catbuf, MSL );
}
strncat( buf, "\r\n", MSL );
send_to_char( buf, ch );
return;
}
pMob->race = lvalue;
send_to_char( "Ok.\r\n", ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "position" ) )
{
if( !str_prefix( arg3, "standing" ) )
value = POS_STANDING;
else if( !str_prefix( arg3, "resting" ) )
value = POS_RESTING;
else if( !str_prefix( arg3, "sleeping" ) )
value = POS_SLEEPING;
else
{
send_to_char( "position must be standing, resting or sleeping.\r\n", ch );
return;
}
pMob->position = value;
area_modified( pArea );
send_to_char( "Ok.\r\n", ch );
return;
}
if( !str_cmp( arg2, "sex" ) )
{
value = -1;
if( arg3[0] == 'm' && !str_prefix( arg3, "male" ) )
value = SEX_MALE;
else if( arg3[0] == 'f' && !str_prefix( arg3, "female" ) )
value = SEX_FEMALE;
else if( arg3[0] == 'n' && !str_prefix( arg3, "neutral" ) )
value = SEX_NEUTRAL;
if( value == -1 )
{
send_to_char( "Must be male, female or neutral.\r\n", ch );
return;
}
pMob->sex = value;
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "level" ) )
{
if( value < 1 || value > 140 )
{
send_to_char( "Level range is 1 to 140.\r\n", ch );
return;
}
pMob->level = value;
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "align" ) )
{
if( value < -1000 || value > 1000 )
{
send_to_char( "Alignment range is -1000 to 1000.\r\n", ch );
return;
}
pMob->alignment = value;
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "ac_mod" ) )
{
if( value < -2500 || value > 500 )
{
send_to_char( "ac_mod range is -2500 to 500.\r\n", ch );
return;
}
pMob->ac_mod = value;
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "hr_mod" ) )
{
if( value < -10 || value > 1000 )
{
send_to_char( "hr_mod range is -10 to 1000.\r\n", ch );
return;
}
pMob->hr_mod = value;
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "dr_mod" ) )
{
if( value < -10 || value > 1000 )
{
send_to_char( "dr_mod range is -10 to 1000.\r\n", ch );
return;
}
pMob->dr_mod = value;
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "edit" ) )
{
if( is_name( arg3, "desc name short long" ) )
snprintf( buf, MSL, "%s %s $edit", arg1, arg3 );
else
snprintf( buf, MSL, " " );
build_setmob( ch, buf );
return;
}
if( !str_cmp( arg2, "name" ) )
{
build_strdup( &pMob->player_name, arg3, TRUE, FALSE, ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "short" ) )
{
build_strdup( &pMob->short_descr, arg3, TRUE, FALSE, ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "long" ) )
{
build_strdup( &pMob->long_descr, arg3, TRUE, FALSE, ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "desc" ) )
{
build_strdup( &pMob->description, arg3, TRUE, FALSE, ch );
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "spec" ) )
{
if( arg3[0] == '-' )
{
if( pMob->spec_fun == NULL )
return;
pMob->spec_fun = NULL;
return;
}
if( ( pMob->spec_fun = spec_lookup( arg3 ) ) == 0 )
{
snprintf( buf, MSL, "Valid spec funs are :\r\n" );
print_spec_lookup( buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "shop" ) )
{
SHOP_DATA *pShop;
BUILD_DATA_LIST *pList;
int iTrade;
argument = one_argument( argument, arg3 );
strcpy( arg4, argument );
pArea = pMob->area;
pShop = pMob->pShop;
if( !str_cmp( arg3, "clear" ) )
{
if( pShop != NULL )
{
for( pList = pArea->first_area_shop; pList != NULL; pList = pList->next )
{
if( pShop == pList->data )
break;
}
if( pList != NULL )
{
UNLINK( pList, pArea->first_area_shop, pArea->last_area_shop, next, prev );
build_dat_list.remove(pList);
delete pList;
}
pMob->pShop = NULL; /* Take away link from mob */
shop_list.remove(pShop);
delete pShop; /* Free the memory it occupies */
}
area_modified( pArea );
return;
}
if( ( str_prefix( "trade", arg3 ) && !is_name( arg3, "profbuy profsell openhour closehour" ) ) )
{
/*
* Usage message
*/
build_setmob( ch, "" );
return;
}
area_modified( pArea );
if( pShop == NULL )
{
pShop = new SHOP_DATA;
if( pShop == NULL ) /* Couldn't alloc space. */
{
send_to_char( "Out of memory, please reboot ASAP.\r\n", ch );
return;
}
pList = new BUILD_DATA_LIST;
if( pList == NULL )
{
send_to_char( "Out of memory, please reboot ASAP.\r\n", ch );
return;
}
pShop->keeper = pMob->vnum;
pMob->pShop = pShop; /* Add link to mob */
pList->data = pShop; /* Add to area list */
LINK( pList, pArea->first_area_shop, pArea->last_area_shop, next, prev );
for( iTrade = 0; iTrade < MAX_TRADE; iTrade++ )
pShop->buy_type[iTrade] = 0;
pShop->profit_buy = 100;
pShop->profit_sell = 100;
pShop->open_hour = 0;
pShop->close_hour = 23;
}
if( !str_prefix( "trade", arg3 ) )
{
num = arg3[5] - '0';
if( num < 0 || num > MAX_TRADE )
{
snprintf( buf, MSL, "trade must be between 0 and %i\r\n", MAX_TRADE );
send_to_char( buf, ch );
return;
}
value = table_lookup( tab_item_types, arg4 );
if( value == 0 )
{
snprintf( buf, MSL, "Item type must be one of the following:\r\n" );
table_printout( tab_item_types, buf + strlen( buf ) );
send_to_char( buf, ch );
}
pShop->buy_type[num] = value;
return;
}
value = is_number( arg4 ) ? atoi( arg4 ) : -1;
if( !str_cmp( "profbuy", arg3 ) )
{
if( value < 0 )
{
send_to_char( "Profbuy must be a number more than 0.\r\n", ch );
return;
}
if( value < 100 )
{
send_to_char( "WARNING: Profbuy should be over 100.\r\n", ch );
return;
}
pShop->profit_buy = value;
return;
}
if( !str_cmp( "profsell", arg3 ) )
{
if( value < 0 )
{
send_to_char( "Profsell must be a number more than 0.\r\n", ch );
return;
}
if( value > 100 )
{
send_to_char( "WARNING: Profsell should be over 100.\r\n", ch );
return;
}
pShop->profit_sell = value;
return;
}
if( !str_cmp( "openhour", arg3 ) )
{
if( value < 0 || value > 24 )
{
send_to_char( "Openhour must be a number between 0 and 24.\r\n", ch );
return;
}
pShop->open_hour = value;
return;
}
if( !str_cmp( "closehour", arg3 ) )
{
if( value < 0 || value > 24 )
{
send_to_char( "closehour must be a number between 0 and 24.\r\n", ch );
return;
}
pShop->close_hour = value;
return;
}
}
/*
* Generate usage message.
*/
build_setmob( ch, "" );
return;
}
/* spec: nuke any stray resets for a changed exit */
void nuke_exit_resets( ROOM_INDEX_DATA * pRoomIndex, int door )
{
BUILD_DATA_LIST *pList, *pListNext;
RESET_DATA *pReset;
AREA_DATA *pArea = pRoomIndex->area;
for( pList = pRoomIndex->first_room_reset; pList; pList = pListNext )
{
pListNext = pList->next;
pReset = (RESET_DATA *)pList->data;
if( pReset->command == 'D' && pReset->arg2 == door )
{
/*
* nuke this reset
*/
UNLINK( pList, pRoomIndex->first_room_reset, pRoomIndex->last_room_reset, next, prev );
build_dat_list.remove(pList);
delete pList;
UNLINK( pReset, pArea->first_reset, pArea->last_reset, next, prev );
delete pReset;
}
}
}
void build_setroom( CHAR_DATA * ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char arg3[MAX_INPUT_LENGTH];
char arg4[MAX_INPUT_LENGTH];
char arg5[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
char *argn;
ROOM_INDEX_DATA *location;
int value, num;
smash_tilde( argument );
argument = one_argument( argument, arg1 );
strcpy( arg2, argument );
if( arg1[0] == '\0' )
{
send_to_char( "Syntax: [set] <arguments> \r\n", ch );
send_to_char( " Or: [set] <string> value\r\n", ch );
send_to_char( " Or: [set] edit <string>\r\n", ch );
send_to_char( "\r\n", ch );
send_to_char( "Arguments being one of:\r\n", ch );
send_to_char( " flags +/-<ascii-flag> \r\n", ch );
send_to_char( " sector <ascii-sector-type>\r\n", ch );
send_to_char( " door <door-number> to <vnum> [onesided]\r\n", ch );
send_to_char( " keyword <string>\r\n", ch );
send_to_char( " desc <string>\r\n", ch );
send_to_char( " key <vnum> [onesided]\r\n", ch );
send_to_char( " type <ascii-type> [onesided]\r\n", ch );
send_to_char( " clear [onesided]\r\n", ch );
send_to_char( " extra <keyword> <string>\r\n", ch );
send_to_char( " extra -<keyword>\r\n", ch );
send_to_char( "String being one of:\r\n", ch );
send_to_char( " name desc\r\n", ch );
return;
}
location = get_room_index( ch->build_vnum );
if( location == NULL )
{
send_to_char( "Invalid vnum selected!\r\n", ch );
return;
}
if( !build_canwrite( location->area, ch, 1 ) )
return;
area_modified( location->area );
/*
* Check for flags first, then other values...
*/
value = table_lookup( tab_room_flags, arg1 );
if( value != 0 )
{
/*
* Flag found
*/
location->room_flags.flip(value);
snprintf( buf, MSL, "@@WRoom flag @@y%s@@W toggled to @@y%s@@W.@@g\r\n",
rev_table_lookup( tab_room_flags, value ), location->room_flags.test(value) ? "ON" : "OFF" );
send_to_char( buf, ch );
return;
}
value = table_lookup( tab_sector_types, arg1 );
if( value >= 1 )
{
/*
* Sector found
*/
location->sector_type = value;
snprintf( buf, MSL, "@@WSector type set to @@y%s@@W.@@g\r\n", rev_table_lookup( tab_sector_types, value ) );
send_to_char( buf, ch );
return;
}
if( !str_cmp( arg1, "edit" ) && is_name( arg2, "name desc" ) )
{
snprintf( buf, MSL, "%s $edit", arg2 );
build_setroom( ch, buf );
return;
}
if( !str_cmp( arg1, "name" ) )
{
build_strdup( &location->name, arg2, TRUE, FALSE, ch );
return;
}
if( !str_cmp( arg1, "desc" ) )
{
build_strdup( &location->description, arg2, TRUE, FALSE, ch );
return;
}
if( !str_cmp( arg1, "extra" ) )
{
EXTRA_DESCR_DATA *ed;
bool found;
argument = one_argument( argument, arg2 );
strcpy( arg3, argument );
if( strlen(arg2) < 1 || strlen(arg3) < 1 )
{
send_to_char("Extra descrs must have a keyword and description.\r\n",ch );
return;
}
argn = arg2;
if( argn[0] == '-' )
{
argn++;
found = FALSE;
for( ed = location->first_exdesc; ed != NULL; ed = ed->next )
{
if( is_name( argn, ed->keyword ) )
{
found = TRUE;
break;
}
}
if( !found )
{
send_to_char( "Keyword not found.\r\n", ch );
return;
}
/*
* Delete description
*/
UNLINK( ed, location->first_exdesc, location->last_exdesc, next, prev );
exdesc_list.remove(ed);
delete ed;
return;
}
found = FALSE;
for( ed = location->first_exdesc; ed != NULL; ed = ed->next )
if( is_name( arg2, ed->keyword ) )
{
found = TRUE;
break;
}
if( !found )
{
ed = new EXTRA_DESCR_DATA;
build_strdup( &ed->keyword, arg2, FALSE, FALSE, ch );
build_strdup( &ed->description, arg3, FALSE, FALSE, ch );
LINK( ed, location->first_exdesc, location->last_exdesc, next, prev );
return;
}
build_strdup( &ed->description, arg3, TRUE, FALSE, ch );
return;
}
/*
* spec: remove resets referring to this door if we clear the 'door'
* * state
*/
if( !str_cmp( arg1, "door" ) )
{
EXIT_DATA *pExit;
int door;
char *temp;
ROOM_INDEX_DATA *pDestRoom;
EXIT_DATA *pDestExit;
argument = one_argument( argument, arg2 );
argument = one_argument( argument, arg3 );
strcpy( arg4, argument );
if( is_number( arg2 ) )
door = atoi( arg2 );
else
{
if( ( temp = index( cDirs, UPPER( arg2[0] ) ) ) != NULL )
door = temp - cDirs;
else
door = -1;
}
if( door < 0 || door > MAX_DIR )
{
send_to_char( "Door number must be a number between 0 and 5, or NSEWUD\r\n", ch );
return;
}
pExit = location->exit[door];
if( !str_cmp( arg3, "clear" ) )
{
if( pExit == NULL )
return;
pDestRoom = get_room_index( pExit->vnum );
if( pDestRoom == NULL )
return;
if( !build_canwrite( pDestRoom->area, ch, 0 ) )
{
send_to_char( "You cannot change this exit.", ch );
return;
}
/*
* Delete exit
*/
exit_list.remove(pExit);
delete pExit;
location->exit[door] = NULL;
/*
* spec: nuke any resets for it
*/
nuke_exit_resets( location, door );
/*
* Delete corresponding exit on other side
*/
if( str_cmp( arg4, "onesided" ) && pDestRoom != NULL )
{
pExit = pDestRoom->exit[RevDirs[door]];
if( pExit != NULL )
if( pExit->vnum == location->vnum )
{
exit_list.remove(pExit);
delete pExit;
pDestRoom->exit[RevDirs[door]] = NULL;
/*
* spec: nuke any resets for it
*/
nuke_exit_resets( pDestRoom, RevDirs[door] );
area_modified( pDestRoom->area );
}
else
send_to_char( "Note: Door in exit room does not point to this door, so not deleted.", ch );
else
send_to_char( "Note: There is no corresponding exit in the room pointed to by this exit.", ch );
}
}
if( !is_name( arg3, "to key desc keyword type" ) )
{
build_setroom( ch, "" );
return;
}
if( pExit == NULL )
{
pExit = new EXIT_DATA;
location->exit[door] = pExit;
}
pDestRoom = pExit->to_room; /* Setup pDestRoom to point to dest. room */
if( pDestRoom != NULL )
{
pDestExit = pDestRoom->exit[RevDirs[door]]; /* Setup pDestExit to exit from DestRoom to here. */
if( pDestExit != NULL && pDestExit->to_room != location )
pDestExit = NULL;
}
else
pDestExit = NULL;
if( !str_cmp( arg3, "to" ) )
{
ROOM_INDEX_DATA *pRoom;
argument = one_argument( argument, arg4 );
argument = one_argument( argument, arg5 );
if( !is_number( arg4 ) )
{
send_to_char( "Room number must be a vnum\r\n", ch );
return;
}
value = atoi( arg4 );
if( !( pRoom = get_room_index( value ) ) )
{
send_to_char( "No such vnum.\r\n", ch );
return;
}
if( !build_canwrite( pRoom->area, ch, 0 ) )
{
send_to_char( "You cannot connect to this room.\r\n", ch );
return;
}
if( pDestRoom != NULL && !build_canwrite( pDestRoom->area, ch, 0 ) )
{
send_to_char( "You cannot change the destination of this exit.", ch );
return;
}
if( str_cmp( arg5, "onesided" ) ) /* If NOT onesided, do checks */
{
if( pDestRoom != NULL && pDestExit != NULL ) /* If already connected */
{
exit_list.remove(pDestExit);
delete pDestExit;
pDestRoom->exit[RevDirs[door]] = NULL;
/*
* spec: nuke exit resets
*/
nuke_exit_resets( pDestRoom, RevDirs[door] );
}
if( !( pDestExit = pRoom->exit[RevDirs[door]] ) ) /* If exit hasn't been made on other side */
{
/*
* Create door coming other way.
*/
pDestExit = new EXIT_DATA;
pDestExit->to_room = location;
pDestExit->vnum = location->vnum;
build_strdup( &pDestExit->keyword, pExit->keyword, FALSE, FALSE, ch );
pDestExit->exit_info = pExit->exit_info;
pDestExit->key = pExit->vnum;
pRoom->exit[RevDirs[door]] = pDestExit;
area_modified( pRoom->area );
}
if( pDestExit->to_room != location )
{
snprintf( buf, MSL, "The door in room %i going %s points to room [%i] %s.\r\n",
value,
sDirs[RevDirs[door]], pDestExit->vnum, pDestExit->to_room != NULL ? pDestExit->to_room->name : "" );
send_to_char( buf, ch );
}
}
pExit->vnum = value;
pExit->to_room = pRoom;
return;
}
if( !str_cmp( arg3, "keyword" ) )
{
build_strdup( &pExit->keyword, arg4, TRUE, FALSE, ch );
return;
}
if( !str_cmp( arg3, "desc" ) )
{
build_strdup( &pExit->description, arg4, TRUE, FALSE, ch );
return;
}
if( !str_cmp( arg3, "key" ) )
{
OBJ_INDEX_DATA *pObject;
argument = one_argument( argument, arg4 );
argument = one_argument( argument, arg5 );
if( arg4[0] == '\0' )
{
pExit->key = -1;
return;
}
if( !is_number( arg4 ) )
{
send_to_char( "Object number must be a vnum, or blank.\r\n", ch );
return;
}
if( !( pObject = get_obj_index( atoi( arg4 ) ) ) )
{
send_to_char( "No such vnum.\r\n", ch );
return;
}
pExit->key = pObject->vnum;
if( pDestExit && str_cmp( arg5, "onesided" ) )
pDestExit->key = pObject->vnum;
return;
}
if( !str_cmp( arg3, "type" ) )
{
argument = one_argument( argument, arg4 );
argument = one_argument( argument, arg5 );
/*
* Make SURE that closed/locked flags are NOT set. -S-
*/
/*
* Resets set these bits, nothing else :P
*/
argn = arg4;
num = 1;
if( argn[0] == '-' )
{
num = 0;
argn++;
}
if( argn[0] == '+' )
{
num = 1;
argn++;
}
value = table_lookup( tab_door_types, argn );
if( value == 0 )
{
snprintf( buf, MSL, "Possible door types are +/-:\r\n" );
table_printout( tab_door_types, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
if( value == EX_CLOSED || value == EX_LOCKED )
{
send_to_char( "To CLOSE or LOCK a door, use a reset.\r\n", ch );
return;
}
if( num == 1 )
{
if( pDestExit && str_cmp( arg5, "onesided" ) )
{
pDestExit->exit_info.set(value);
area_modified( pDestRoom->area );
}
pExit->exit_info.set(value);
}
else
{
if( pDestExit && str_cmp( arg5, "onesided" ) )
{
pDestExit->exit_info.reset(value);
if( value == EX_ISDOOR )
nuke_exit_resets( pDestRoom, RevDirs[door] );
area_modified( pDestRoom->area );
}
pExit->exit_info.reset(value);
if( value == EX_ISDOOR )
nuke_exit_resets( location, door );
}
return;
}
}
/*
* Generate usage message.
*/
build_setroom( ch, "" );
return;
}
void build_setobject( CHAR_DATA * ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char arg3[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
char *argn;
OBJ_INDEX_DATA *pObj;
AREA_DATA *pArea;
int value, num;
smash_tilde( argument );
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
strcpy( arg3, argument );
if( arg1[0] == '\0' || arg2[0] == '\0' )
{
send_to_char( "Syntax: [set] <field> <value>\r\n", ch );
send_to_char( "or: [set] <string> <value>\r\n", ch );
send_to_char( "or: aobj [<slot>]\r\n", ch );
send_to_char( "\r\n", ch );
send_to_char( "Field being one of:\r\n", ch );
send_to_char( " value0 value1 value2 value3 speed magic\r\n", ch );
send_to_char( " level extra wear weight aff type durability\r\n", ch );
send_to_char( "\r\n", ch );
send_to_char( "String being one of:\r\n", ch );
send_to_char( " name short long ed objfun\r\n", ch );
send_to_char( "Use [set] objfun - to clear objfun.\r\n", ch );
return;
}
if( ( pObj = get_obj_index( atoi( arg1 ) ) ) == NULL )
{
send_to_char( "Vnum not found.\r\n", ch );
return;
}
pArea = pObj->area;
if( !build_canwrite( pArea, ch, 1 ) )
return;
/*
* Check for extra flag: clan_eq
*/
if( IS_OBJ_STAT(pObj,ITEM_EXTRA_CLAN_EQ) && get_trust( ch ) != 85 )
{
send_to_char( "Only a Creator can set Clan-Eq.\r\n", ch );
return;
}
area_modified( pObj->area );
/*
* Snarf the value (which need not be numeric).
*/
value = atol( arg3 );
/*
* Set something.
*/
if( !str_prefix( "aobj", arg2 ) )
{
float mult = 0.0;
float ac = 0, dr = 0, hp = 0, hr = 0, mp = 0, mv = 0, svs = 0;
if( pObj->level < 1 ) /* Should never happen anyhow, but sanity checks are never bad */
{
send_to_char("You can only auto-object items that are at least level 1.\r\n",ch);
return;
}
mult = (float)pObj->level / 120.0000;
if( IS_OBJ_STAT(pObj,ITEM_EXTRA_RARE) )
{
mult += 0.15; /* Rares are 15% better by default */
send_to_char("Applying 15% bonus for rare flag.\r\n",ch);
}
ac = sysdata.build_obj_ac * mult;
dr = sysdata.build_obj_dr * mult;
hp = sysdata.build_obj_hp * mult;
hr = sysdata.build_obj_hr * mult;
mp = sysdata.build_obj_mp * mult;
mv = sysdata.build_obj_mv * mult;
svs = sysdata.build_obj_svs * mult;
if( arg3[0] != '\0' ) /* Use modifiers based on wear slot */
{
short i = 0;
bool found = FALSE;
for( i = 0; tab_auto_obj[i].name != NULL; i++ )
{
if( !str_prefix(arg3,"list") )
{
snprintf(buf,MSL,"Valid object types:");
for( i = 0; tab_auto_obj[i].name != NULL; i++ )
{
char tmp[MSL];
snprintf(tmp,MSL," %s",tab_auto_obj[i].name);
strncat(buf,tmp,MSL);
}
strncat(buf,".\r\n",MSL);
send_to_char(buf,ch);
return;
}
if( !str_prefix(arg3,tab_auto_obj[i].name) )
{
found = TRUE;
ac *= tab_auto_obj[i].ac;
dr *= tab_auto_obj[i].dr;
hp *= tab_auto_obj[i].hp;
hr *= tab_auto_obj[i].hr;
mp *= tab_auto_obj[i].mp;
mv *= tab_auto_obj[i].mv;
svs *= tab_auto_obj[i].svs;
break;
}
}
if( found )
{
snprintf(buf,MSL,"Values modified based on object type: %s.\r\n",tab_auto_obj[i].name);
send_to_char(buf,ch);
}
else
{
snprintf(buf,MSL,"Invalid object type. Valid object types:");
for( i = 0; tab_auto_obj[i].name != NULL; i++ )
{
char tmp[MSL];
snprintf(tmp,MSL," %s",tab_auto_obj[i].name);
strncat(buf,tmp,MSL);
}
strncat(buf,".\r\n",MSL);
send_to_char(buf,ch);
}
}
snprintf(buf,MSL,"%d aff %sac %.0f",pObj->vnum,ac == 0 ? "-" : "",ac);
build_setobject(ch,buf);
snprintf(buf,MSL,"%d aff %sdamroll %.0f",pObj->vnum,dr == 0 ? "-" : "",dr);
build_setobject(ch,buf);
snprintf(buf,MSL,"%d aff %shit %.0f",pObj->vnum,hp == 0 ? "-" : "",hp);
build_setobject(ch,buf);
snprintf(buf,MSL,"%d aff %shitroll %.0f",pObj->vnum,hr == 0 ? "-" : "",hr);
build_setobject(ch,buf);
snprintf(buf,MSL,"%d aff %smana %.0f",pObj->vnum,mp == 0 ? "-" : "",mp);
build_setobject(ch,buf);
snprintf(buf,MSL,"%d aff %smove %.0f",pObj->vnum,mv == 0 ? "-" : "",mv);
build_setobject(ch,buf);
snprintf(buf,MSL,"%d aff %ssaving_spell %.0f",pObj->vnum,svs == 0 ? "-" : "",svs);
build_setobject(ch,buf);
snprintf(buf,MSL,"Auto-object complete based on item level %d. Stats are %0.2f%% of max.\r\n",pObj->level,(mult * 100));
send_to_char(buf,ch);
return;
}
if( !str_prefix( "value", arg2 ) )
{
num = arg2[5] - '0';
if( num < 0 || num > 9 )
{
send_to_char( "Value0-9.\r\n", ch );
return;
}
pObj->value[num] = value;
return;
}
if( !str_cmp( arg2, "level" ) )
{
if( value < 1 || value > 120 )
{
send_to_char( "item level is 1 to 120.\r\n", ch );
return;
}
if( pObj->item_type == ITEM_WEAPON )
{
pObj->value[1] = number_range((value - 10),value);
pObj->value[2] = number_range((value - 5),(value +5));
if( pObj->value[1] < 1 )
pObj->value[1] = 1;
if( pObj->value[2] < 1 )
pObj->value[2] = 1;
}
pObj->max_durability = value * 5;
pObj->durability = pObj->max_durability;
pObj->level = value;
return;
}
if( !str_cmp( arg2, "speed" ) )
{
if( atof(arg3) < 0.01 || atof(arg3) > 4 )
{
send_to_char("item speed is 0.01 to 4.00.\r\n", ch );
return;
}
pObj->speed = atof(arg3);
return;
}
if( UPPER( arg2[0] ) == 'V' && arg2[2] == '\0' )
{
num = arg2[1] - '0';
if( num < 0 || num > 9 )
{
send_to_char( "v0-v9.\r\n", ch );
return;
}
pObj->value[num] = value;
return;
}
if( !str_cmp( arg2, "objfun" ) )
{
if( arg3[0] == '-' )
{
if( pObj->obj_fun == NULL )
return;
pObj->obj_fun = NULL;
return;
}
if( ( pObj->obj_fun = obj_fun_lookup( arg3 ) ) == 0 )
{
snprintf( buf, MSL, "Valid obj funs are :\r\n" );
print_obj_fun_lookup( buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
area_modified( pArea );
return;
}
if( !str_cmp( arg2, "extra" ) )
{
num = 1;
argn = arg3;
if( argn[0] == '+' )
{
num = 1;
argn++;
}
if( argn[0] == '-' )
{
num = 0;
argn++;
}
value = table_lookup( tab_obj_flags, argn );
if( value == 0 )
{
snprintf( buf, MSL, "Values for extra flags are +/- :\r\n" );
table_printout( tab_obj_flags, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
if( num == 1 )
pObj->extra_flags.set(value);
else
pObj->extra_flags.reset(value);
return;
}
if( !str_cmp( arg2, "magic" ) )
{
num = 1;
argn = arg3;
if( argn[0] == '+' )
argn++;
if( argn[0] == '-' )
{
num = 0;
argn++;
}
value = table_lookup( tab_item_apply, argn );
if( value == 0 )
{
snprintf( buf, MSL, "Values for magical applies are +/- :\r\n" );
table_printout( tab_item_apply, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
if( num == 1 )
SET_BIT( pObj->item_apply, value );
else
REMOVE_BIT( pObj->item_apply, value );
return;
}
if( !str_cmp( arg2, "wear" ) )
{
num = 1;
argn = arg3;
if( argn[0] == '+' )
{
num = 1;
argn++;
}
if( argn[0] == '-' )
{
num = 0;
argn++;
}
value = table_lookup( tab_wear_flags, argn );
if( value == 0 )
{
snprintf( buf, MSL, "Values for wear flags are +/- :\r\n" );
table_printout( tab_wear_flags, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
if( num == 1 )
pObj->wear_flags.set(value);
else
pObj->wear_flags.reset(value);
return;
}
if( !str_cmp( arg2, "type" ) )
{
value = table_lookup( tab_item_types, arg3 );
if( value == 0 )
{
snprintf( buf, MSL, "Values for item types are :\r\n" );
table_printout( tab_item_types, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
if( value == ITEM_EXTRA_CLAN_EQ && get_trust( ch ) != 85 )
{
send_to_char( "Only a CREATOR may set this flag.\r\n", ch );
return;
}
pObj->item_type = value;
return;
}
if( !str_cmp( arg2, "weight" ) )
{
pObj->weight = value;
return;
}
if( !str_cmp( arg2, "name" ) )
{
build_strdup( &pObj->name, arg3, TRUE, FALSE, ch );
return;
}
if( !str_cmp( arg2, "short" ) )
{
build_strdup( &pObj->short_descr, arg3, TRUE, FALSE, ch );
return;
}
if( !str_cmp( arg2, "long" ) )
{
build_strdup( &pObj->long_descr, arg3, TRUE, FALSE, ch );
return;
}
if( !str_cmp( arg2, "ed" ) )
{
EXTRA_DESCR_DATA *ed;
int found;
argument = one_argument( argument, arg3 );
if( argument == NULL )
{
send_to_char( "Syntax: setobject <object> ed [-]<keyword> <string>\r\n", ch );
return;
}
if( arg3[0] == '-' )
{
/*
* Find and delete keyword
*/
argn = arg3 + 1;
found = FALSE;
for( ed = pObj->first_exdesc; ed != NULL; ed = ed->next )
{
if( is_name( argn, ed->keyword ) )
{
found = TRUE;
break;
}
}
if( !found )
{
send_to_char( "Keyword not found.\r\n", ch );
return;
}
UNLINK( ed, pObj->first_exdesc, pObj->last_exdesc, next, prev );
exdesc_list.remove(ed);
delete ed;
return;
}
found = FALSE;
for( ed = pObj->first_exdesc; ed != NULL; ed = ed->next )
{
if( is_name( arg3, ed->keyword ) )
{
found = TRUE;
break;
}
}
if( found )
{
build_strdup( &ed->description, argument, TRUE, FALSE, ch );
return;
}
ed = new EXTRA_DESCR_DATA;
build_strdup( &ed->keyword, arg3, FALSE, FALSE, ch );
build_strdup( &ed->description, argument, FALSE, FALSE, ch );
LINK( ed, pObj->first_exdesc, pObj->last_exdesc, next, prev );
return;
}
if( !str_cmp( arg2, "aff" ) )
{
AFFECT_DATA *paf;
int found, location, neg;
argument = one_argument( argument, arg3 );
if( argument == NULL )
{
send_to_char( "Syntax: setobject <object> aff [-]<location> <mod>\r\n", ch );
return;
}
argn = arg3;
neg = 0;
if( argn[0] == '-' )
{
neg = 1;
argn++;
}
location = table_lookup( tab_obj_aff, argn );
if( location == 0 )
{
snprintf( buf, MSL, "Location can be one of the following [-]:\r\n" );
table_printout( tab_obj_aff, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
found = FALSE;
for( paf = pObj->first_apply; paf != NULL; paf = paf->next )
{
if( paf->location == location )
{
found = TRUE;
break;
}
}
if( neg == 1 )
{
if( !found )
{ /* Commenting this to squelch auto-object. It's not that important to generate a message. --Kline
send_to_char( "Location not found.\r\n", ch ); */
return;
}
UNLINK( paf, pObj->first_apply, pObj->last_apply, next, prev );
delete paf;
return;
}
if( !found )
{
paf = new AFFECT_DATA;
paf->location = location;
paf->modifier = atoi( argument );
LINK( paf, pObj->first_apply, pObj->last_apply, next, prev );
}
else
paf->modifier = atoi( argument );
return;
}
if( !str_prefix(arg2,"durability") )
{
if( !is_number(arg3) )
{
send_to_char("Durability must be a number.\r\n",ch);
return;
}
if( atoi(arg3) < 2 )
{
send_to_char("Value must be at least 2. An object with only 1 durability is considered 'broken' and un-usable.\r\n",ch);
return;
}
pObj->max_durability = atoi(arg3);
pObj->durability = pObj->max_durability;
return;
}
/*
* Generate usage message.
*/
build_setobject( ch, "" );
return;
}
void build_dig( CHAR_DATA * ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char arg3[MAX_INPUT_LENGTH];
char buffer[MAX_INPUT_LENGTH];
ROOM_INDEX_DATA *pRoomIndex;
ROOM_INDEX_DATA *pCurRoom;
int vnum, dir;
char *temp;
int iHash;
EXIT_DATA *pExit;
BUILD_DATA_LIST *pList;
AREA_DATA *pArea;
smash_tilde( argument );
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
strcpy( arg3, argument );
if( arg1[0] == '\0' || arg2[0] == '\0' )
{
send_to_char( "Syntax: dig <dir> <vnum> [onesided]\r\n", ch );
return;
}
if( !( temp = index( cDirs, UPPER( arg1[0] ) ) ) )
{
send_to_char( "Direction must be one of NSEWUP\r\n", ch );
return;
}
dir = temp - cDirs;
if( ch->in_room->exit[dir] != NULL )
{
send_to_char( "There is already an exit in that direction\n.", ch );
return;
}
vnum = is_number( arg2 ) ? atoi( arg2 ) : -1;
if( vnum < 0 || vnum > MAX_VNUM )
{
send_to_char( "Vnum must be between 0 and 16777216.\r\n", ch );
return;
}
if( get_room_index( vnum ) != NULL )
{
send_to_char( "There is already a room with that vnum.\r\n", ch );
return;
}
pCurRoom = ch->in_room;
pArea = pCurRoom->area;
if( !build_canwrite( pArea, ch, 1 ) )
return;
if( vnum < pArea->min_vnum || vnum > pArea->max_vnum )
{
snprintf( buffer, MSL, "Vnum must be between %i and %i.\r\n", pArea->min_vnum, pArea->max_vnum );
send_to_char( buffer, ch );
return;
}
/*
* Create room
*/
pRoomIndex = new ROOM_INDEX_DATA;
pRoomIndex->area = pArea;
pRoomIndex->vnum = vnum;
pRoomIndex->sector_type = ch->in_room->sector_type;
/*
* Add room to hash table
*/
iHash = vnum % MAX_KEY_HASH;
SING_TOPLINK( pRoomIndex, room_index_hash[iHash], next );
/*
* Add room into area list.
*/
pList = new BUILD_DATA_LIST;
pList->data = pRoomIndex;
LINK( pList, pCurRoom->area->first_area_room, pCurRoom->area->last_area_room, next, prev );
/*
* Create door
*/
pExit = new EXIT_DATA;
pExit->to_room = pRoomIndex;
pExit->vnum = vnum;
pCurRoom->exit[dir] = pExit;
if( str_cmp( arg3, "onesided" ) ) /* If NOT onesided */
{
pExit = new EXIT_DATA;
pExit->to_room = pCurRoom;
pExit->vnum = pCurRoom->vnum;
pRoomIndex->exit[RevDirs[dir]] = pExit;
}
area_modified(pArea);
return;
}
void build_stop( CHAR_DATA * ch, char *argument )
{
ch->position = POS_STANDING;
send_to_char( "Building stopped.\r\n", ch );
}
void do_build( CHAR_DATA * ch, char *argument )
{
if( !ch->act.test(ACT_BUILDER) )
{
send_to_char( "You aren't allowed to build!\r\n", ch );
return;
}
ch->position = POS_BUILDING;
do_help( ch, "build_bmotd" ); /* motd for builders -S- */
send_to_char( "Building commands are now operative. Type stop to stop building.\r\n", ch );
}
void build_addmob( CHAR_DATA * ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char buffer[MAX_INPUT_LENGTH];
MOB_INDEX_DATA *pMobIndex;
/* ROOM_INDEX_DATA *room; unused */
AREA_DATA *pArea;
BUILD_DATA_LIST *pList;
int vnum;
int iHash;
smash_tilde( argument );
argument = one_argument( argument, arg1 );
strcpy( arg2, argument );
if( arg1[0] == '\0' || arg2[0] == '\0' )
{
send_to_char( "Syntax: addmob <vnum> <name>\r\n", ch );
return;
}
vnum = is_number( arg1 ) ? atoi( arg1 ) : -1;
if( vnum < 0 || vnum > MAX_VNUM )
{
send_to_char( "Vnum must be between 0 and 16777216.\r\n", ch );
return;
}
if( get_mob_index( vnum ) != NULL )
{
send_to_char( "There is already a mob with that vnum.\r\n", ch );
return;
}
pArea = ch->in_room->area; /* bugger. this might need fixing!! */
if( !build_canwrite( pArea, ch, 1 ) )
return;
if( vnum < pArea->min_vnum || vnum > pArea->max_vnum )
{
snprintf( buffer, MSL, "Vnum must be between %i and %i.\r\n", pArea->min_vnum, pArea->max_vnum );
send_to_char( buffer, ch );
return;
}
ch->build_vnum = vnum;
ch->act_build = ACT_BUILD_MEDIT;
pMobIndex = new MOB_INDEX_DATA;
pMobIndex->vnum = vnum;
pMobIndex->area = pArea;
pMobIndex->player_name = str_dup( arg2 );
iHash = vnum % MAX_KEY_HASH;
SING_TOPLINK( pMobIndex, mob_index_hash[iHash], next );
pList = new BUILD_DATA_LIST;
pList->data = pMobIndex;
LINK( pList, pArea->first_area_mobile, pArea->last_area_mobile, next, prev );
kill_table[URANGE( 0, pMobIndex->level, MAX_LEVEL - 1 )].number++;
return;
}
void build_addobject( CHAR_DATA * ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char buffer[MAX_INPUT_LENGTH];
OBJ_INDEX_DATA *pObjIndex;
AREA_DATA *pArea;
BUILD_DATA_LIST *pList;
int vnum;
int iHash;
smash_tilde( argument );
argument = one_argument( argument, arg1 );
strcpy( arg2, argument );
if( arg1[0] == '\0' || arg2[0] == '\0' )
{
send_to_char( "Syntax: addobject <vnum> <name>\r\n", ch );
return;
}
vnum = is_number( arg1 ) ? atoi( arg1 ) : -1;
if( vnum < 0 || vnum > MAX_VNUM )
{
send_to_char( "Vnum must be between 0 and 16777216.\r\n", ch );
return;
}
if( get_obj_index( vnum ) != NULL )
{
send_to_char( "There is already an object with that vnum.\r\n", ch );
return;
}
pArea = ch->in_room->area;
if( !build_canwrite( pArea, ch, 1 ) )
return;
if( vnum < pArea->min_vnum || vnum > pArea->max_vnum )
{
snprintf( buffer, MSL, "Vnum must be between %i and %i.\r\n", pArea->min_vnum, pArea->max_vnum );
send_to_char( buffer, ch );
return;
}
ch->build_vnum = vnum;
ch->act_build = ACT_BUILD_OEDIT;
pObjIndex = new OBJ_INDEX_DATA;
pObjIndex->vnum = vnum;
pObjIndex->area = pArea;
pObjIndex->name = str_dup(arg2);
iHash = vnum % MAX_KEY_HASH;
SING_TOPLINK( pObjIndex, obj_index_hash[iHash], next );
pList = new BUILD_DATA_LIST;
pList->data = pObjIndex;
LINK( pList, pArea->first_area_object, pArea->last_area_object, next, prev );
return;
}
void build_addroom( CHAR_DATA *ch, char *argument )
{
ROOM_INDEX_DATA *pRoomIndex;
AREA_DATA *pArea;
BUILD_DATA_LIST *pList;
int vnum = 0, iHash = 0;
ROOM_INDEX_DATA *pCurRoom;
smash_tilde( argument );
if( argument[0] == '\0' )
{
send_to_char( "Syntax: addroom <vnum>\r\n", ch );
return;
}
vnum = is_number( argument ) ? atoi( argument ) : -1;
if( vnum < 0 || vnum > MAX_VNUM )
{
send_to_char( "Vnum must be between 0 and 16777216.\r\n", ch );
return;
}
if( get_room_index( vnum ) != NULL )
{
send_to_char( "There is already a room with that vnum.\r\n", ch );
return;
}
pCurRoom = ch->in_room;
pArea = pCurRoom->area;
if( !build_canwrite( pArea, ch, 1 ) )
return;
if( vnum < pArea->min_vnum || vnum > pArea->max_vnum )
{
snprintf( argument, MSL, "Vnum must be between %i and %i.\r\n", pArea->min_vnum, pArea->max_vnum );
send_to_char( argument, ch );
return;
}
/*
* Create room
*/
pRoomIndex = new ROOM_INDEX_DATA;
pRoomIndex->area = pArea;
pRoomIndex->vnum = vnum;
pRoomIndex->sector_type = ch->in_room->sector_type;
ch->build_vnum = vnum;
ch->act_build = ACT_BUILD_REDIT;
/*
* Add room to hash table
*/
iHash = vnum % MAX_KEY_HASH;
SING_TOPLINK( pRoomIndex, room_index_hash[iHash], next );
/*
* Add room into area list.
*/
pList = new BUILD_DATA_LIST;
pList->data = pRoomIndex;
LINK( pList, pCurRoom->area->first_area_room, pCurRoom->area->last_area_room, next, prev );
}
void build_addreset( CHAR_DATA * ch, char *argument )
{
RESET_DATA *pReset;
RESET_DATA *pMobReset;
RESET_DATA *pObjReset;
BUILD_DATA_LIST *pList;
BUILD_DATA_LIST *pMobList;
BUILD_DATA_LIST *pObjList;
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char arg3[MAX_INPUT_LENGTH];
char arg4[MAX_INPUT_LENGTH];
char buf[MAX_INPUT_LENGTH];
char command;
int rarg1, rarg2, rarg3;
char *rauto = "";
ROOM_INDEX_DATA *pRoomIndex;
int vnum, num;
int found;
char *temp;
AREA_DATA *pArea;
MOB_INDEX_DATA *pMob;
OBJ_INDEX_DATA *pObj;
EXIT_DATA *pExit;
smash_tilde( argument );
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
argument = one_argument( argument, arg3 );
argument = one_argument( argument, arg4 );
if( arg1[0] == '\0' || ( arg2[0] == '\0' && strcmp( arg1, "message" ) ) )
{
send_to_char( "addreset mob <vnum> <limit>\r\n", ch );
send_to_char( " obj <vnum> <max number in room>\r\n", ch );
send_to_char( " equip <n.mob-vnum> <obj-vnum> <location>\r\n", ch );
send_to_char( " give <n.mob-vnum> <obj-vnum>\r\n", ch );
send_to_char( " within <n.obj-vnum> <obj-vnum> <max num>\r\n", ch);
send_to_char( " door <dir> <state>\r\n", ch );
send_to_char( " rand <num-dirs>\r\n", ch );
send_to_char( " message <min_lev> <max_lev> <text>\r\n", ch );
return;
}
if( !is_name( arg1, "mob obj equip message give within door rand" ) )
{
build_addreset( ch, "" );
return;
}
command = '*';
rarg1 = 0;
rarg2 = 0;
rarg3 = 0;
pRoomIndex = ch->in_room;
pArea = pRoomIndex->area;
pMobReset = NULL;
pMobList = NULL;
if( !build_canwrite( pArea, ch, 1 ) )
return;
if( !str_cmp( arg1, "mob" ) )
{
vnum = is_number( arg2 ) ? atoi( arg2 ) : -1;
if( vnum < 0 || vnum > MAX_VNUM )
{
snprintf( buf, MSL, "Vnum must be between 0 and %i.\r\n", MAX_VNUM );
send_to_char( buf, ch );
return;
}
if( !( pMob = get_mob_index( vnum ) ) )
{
send_to_char( "Mob not found.\r\n", ch );
return;
}
if( !build_canread( pMob->area, ch, 0 ) )
{
send_to_char( "You cannot use that mob.\r\n", ch );
return;
}
num = is_number( arg3 ) ? atoi( arg3 ) : -1;
if( num < 0 )
{
send_to_char( "Limit must be a number more than 0.\r\n", ch );
return;
}
command = 'M';
rarg1 = vnum;
rarg2 = num;
rarg3 = pRoomIndex->vnum;
}
if( !str_cmp( arg1, "message" ) )
{
if( !is_number( arg2 ) || !is_number( arg3 ) )
{
send_to_char( "Must specify TWO levels: min and max before message.\r\n", ch );
return;
}
rarg1 = pRoomIndex->vnum;
rarg2 = atoi( arg2 );
rarg3 = atoi( arg3 );
rauto = str_dup( arg4 );
command = 'A';
}
if( !str_cmp( arg1, "obj" ) )
{
vnum = is_number( arg2 ) ? atoi( arg2 ) : -1;
if( vnum < 0 || vnum > MAX_VNUM )
{
snprintf( buf, MSL, "Vnum must be between 0 and %i.\r\n", MAX_VNUM );
send_to_char( buf, ch );
return;
}
if( !( pObj = get_obj_index( vnum ) ) )
{
send_to_char( "Object not found.\r\n", ch );
return;
}
if( !build_canread( pObj->area, ch, 0 ) )
{
send_to_char( "You cannot use that object.\r\n", ch );
return;
}
if( IS_OBJ_STAT(pObj,ITEM_EXTRA_CLAN_EQ) && !IS_IMMORTAL( ch ) )
{
send_to_char( "You can't use that object for a reset.\r\n", ch );
return;
}
command = 'O';
rarg1 = vnum;
rarg2 = ( is_number( arg3 ) ? atoi( arg3 ) : 1 );
rarg3 = pRoomIndex->vnum;
}
if( !str_cmp( arg1, "equip" ) )
{
num = number_argument( arg2, buf );
if( num == 0 )
{
send_to_char( "Count portion of vnum cannot be 0. Indicate which instance of the mob, or -1 for all instances.\r\n",
ch );
return;
}
vnum = is_number( buf ) ? atoi( buf ) : -1;
found = num;
for( pMobList = pRoomIndex->first_room_reset; pMobList != NULL; pMobList = pMobList->next )
{
pMobReset = (RESET_DATA *)pMobList->data;
if( pMobReset->command == 'M' && pMobReset->arg1 == vnum )
{
found--;
if( found <= 0 )
break;
}
}
if( found == num )
{
send_to_char( "None of that mob loaded in the room resets.\r\n", ch );
return;
}
if( num > 0 && found > 0 )
{
send_to_char( "Not enough of that mob loaded in the room resets.\r\n", ch );
return;
}
vnum = is_number( arg3 ) ? atoi( arg3 ) : -1;
if( !( pObj = get_obj_index( vnum ) ) )
{
send_to_char( "Object not found.\r\n", ch );
return;
}
if( IS_OBJ_STAT(pObj,ITEM_EXTRA_CLAN_EQ) && !IS_IMMORTAL( ch ) )
{
send_to_char( "You can't use that object for a reset.\r\n", ch );
return;
}
if( !build_canread( pObj->area, ch, 0 ) )
{
send_to_char( "You cannot use that object.\r\n", ch );
return;
}
rarg1 = vnum;
num = table_lookup( tab_wear_loc, arg4 );
if( num == -2 )
{
snprintf( buf, MSL, "Location must be one of the following:\r\n" );
table_printout( tab_wear_loc, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
rarg2 = 0;
rarg3 = num;
command = 'E';
}
if( !str_cmp( arg1, "give" ) )
{
num = number_argument( arg2, buf );
if( num == 0 )
{
send_to_char( "Count portion of vnum cannot be 0. Indicate which instance of the mob, or -1 for all instances.\r\n",
ch );
return;
}
vnum = is_number( buf ) ? atoi( buf ) : -1;
found = num;
for( pMobList = pRoomIndex->first_room_reset; pMobList != NULL; pMobList = pMobList->next )
{
pMobReset = (RESET_DATA *)pMobList->data;
if( pMobReset->command == 'M' && pMobReset->arg1 == vnum )
{
found--;
if( found <= 0 )
break;
}
}
if( found == num )
{
send_to_char( "None of that mob loaded in the room resets.\r\n", ch );
return;
}
if( num > 0 && found > 0 )
{
send_to_char( "Not enough of that mob loaded in the room resets.\r\n", ch );
return;
}
vnum = is_number( arg3 ) ? atoi( arg3 ) : -1;
if( !( pObj = get_obj_index( vnum ) ) )
{
send_to_char( "Object not found.\r\n", ch );
return;
}
if( IS_OBJ_STAT(pObj,ITEM_EXTRA_CLAN_EQ) && !IS_IMMORTAL( ch ) )
{
send_to_char( "You can't use that object for a reset.\r\n", ch );
return;
}
if( !build_canread( pObj->area, ch, 0 ) )
{
send_to_char( "You cannot use that object.\r\n", ch );
return;
}
rarg1 = vnum;
rarg2 = 0;
rarg3 = 0;
command = 'G';
}
if( !str_cmp( arg1, "within" ) )
{
int vnum1;
num = number_argument( arg2, buf );
if( num == 0 )
{
send_to_char( "Count portion of vnum cannot be 0. Indicate which instance of the obj, or -1 for all instances.\r\n",
ch );
return;
}
vnum = is_number( buf ) ? atoi( buf ) : -1;
found = num;
for( pObjList = pRoomIndex->first_room_reset; pObjList != NULL; pObjList = pObjList->next )
{
pObjReset = (RESET_DATA *)pObjList->data;
if( pObjReset->command == 'O' && pObjReset->arg1 == vnum )
{
found--;
if( found <= 0 )
break;
}
}
if( found == num )
{
send_to_char( "None of that obj loaded in the room resets.\r\n", ch );
return;
}
if( num > 0 && found > 0 )
{
send_to_char( "Not enough of that obj loaded in the room resets.\r\n", ch );
return;
}
vnum = is_number( arg3 ) ? atoi( arg3 ) : -1;
if( !( pObj = get_obj_index( vnum ) ) )
{
send_to_char( "Object not found.\r\n", ch );
return;
}
if( IS_OBJ_STAT(pObj,ITEM_EXTRA_CLAN_EQ) && !IS_IMMORTAL( ch ) )
{
send_to_char( "You can't use that object for a reset.\r\n", ch );
return;
}
vnum1 = is_number( arg2 ) ? atoi( arg2 ) : -1;
if( !( pObj = get_obj_index( vnum1 ) ) )
{
send_to_char( "Object not found.\r\n", ch );
return;
}
if( IS_OBJ_STAT(pObj,ITEM_EXTRA_CLAN_EQ) && !IS_IMMORTAL( ch ) )
{
send_to_char( "You can't use that object for a reset.\r\n", ch );
return;
}
if( !build_canread( pObj->area, ch, 0 ) )
{
send_to_char( "You cannot use that object.\r\n", ch );
return;
}
rarg1 = vnum;
rarg2 = is_number( arg4 ) ? atoi ( arg4 ) : 1;
rarg3 = vnum1;
command = 'P';
}
if( !str_cmp( arg1, "door" ) )
{
temp = index( cDirs, UPPER( arg2[0] ) );
if( !temp )
{
send_to_char( "Direction must be one of NSEWUP.\r\n", ch );
return;
}
rarg1 = pRoomIndex->vnum;
rarg2 = temp - cDirs;
if( ( pExit = pRoomIndex->exit[rarg2] ) == NULL || !pExit->exit_info.test(EX_ISDOOR) )
{
send_to_char( "That exit isn't a door.\r\n", ch );
return;
}
num = table_lookup( tab_door_states, arg3 );
if( num < 0 )
{
snprintf( buf, MSL, "Door state can be one of the following:\r\n" );
table_printout( tab_door_states, buf + strlen( buf ) );
send_to_char( buf, ch );
return;
}
rarg3 = num;
command = 'D';
}
if( !str_cmp( arg1, "rand" ) )
{
num = is_number( arg2 ) ? atoi( arg2 ) : -1;
if( num < 1 || num > 6 )
{
send_to_char( "Number of doors must be from 1 to 6.\r\n", ch );
return;
}
rarg1 = pRoomIndex->vnum;
rarg2 = num;
command = 'R';
}
if( command == '*' )
{
bug( "build_addreset: Shouldn't have come this far.\r\n", 0 );
build_addreset( ch, "" );
return;
}
/*
* Now create new pReset
*/
pReset = new RESET_DATA;
pReset->command = command;
pReset->arg1 = rarg1;
pReset->arg2 = rarg2;
pReset->arg3 = rarg3;
if( command == 'A' )
pReset->notes = rauto;
pList = new BUILD_DATA_LIST;
pList->data = pReset;
if( pMobReset != NULL )
{
pReset->next = pMobReset->next;
pMobReset->next = pReset;
pReset->prev = pMobReset;
if( pReset->next )
pReset->next->prev = pReset;
else
pRoomIndex->area->last_reset = pReset;
pList->next = pMobList->next;
pMobList->next = pList;
pList->prev = pMobList;
if( pList->next )
pList->next->prev = pList;
else
pRoomIndex->last_room_reset = pList;
}
else
{
pArea = pRoomIndex->area;
LINK( pReset, pArea->first_reset, pArea->last_reset, next, prev );
LINK( pList, pRoomIndex->first_room_reset, pRoomIndex->last_room_reset, next, prev );
}
area_modified( pArea );
return;
}
/* spec: rewrote the internals of this, it might work somewhat more reliably
* now :) .. please, someone put the reset lists out of their misery.. */
void build_delreset( CHAR_DATA * ch, char *argument )
{
RESET_DATA *pReset;
BUILD_DATA_LIST *pList;
BUILD_DATA_LIST *pNextList;
char arg1[MAX_INPUT_LENGTH];
ROOM_INDEX_DATA *pRoomIndex;
int found;
AREA_DATA *pArea;
smash_tilde( argument );
argument = one_argument( argument, arg1 );
if( arg1[0] == '\0' || !is_number( arg1 ) )
{
send_to_char( "delreset <reset-number> (type showresets for numbers)\r\nShowing the first 100 KB of 160.9 KB. Download the archive for the full file.