?? handler.c
字號:
return NULL;
}
/*
* Find a char in the world.
*/
CHAR_DATA *get_char_world( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *wch;
int number;
int count;
if ( ( wch = get_char_room( ch, argument ) ) != NULL )
return wch;
number = number_argument( argument, arg );
count = 0;
for ( wch = char_list; wch != NULL ; wch = wch->next )
{
if ( !can_see( ch, wch ) || !is_name( arg, wch->name ) )
continue;
if ( ++count == number )
return wch;
}
return NULL;
}
/*
* Find some object with a given index data.
* Used by area-reset 'P' command.
*/
OBJ_DATA *get_obj_type( OBJ_INDEX_DATA *pObjIndex )
{
OBJ_DATA *obj;
for ( obj = object_list; obj != NULL; obj = obj->next )
{
if ( obj->pIndexData == pObjIndex )
return obj;
}
return NULL;
}
/*
* Find an obj in a list.
*/
OBJ_DATA *get_obj_list( CHAR_DATA *ch, char *argument, OBJ_DATA *list )
{
char arg[MAX_INPUT_LENGTH];
OBJ_DATA *obj;
int number;
int count;
number = number_argument( argument, arg );
count = 0;
for ( obj = list; obj != NULL; obj = obj->next_content )
{
if ( can_see_obj( ch, obj ) && is_name( arg, obj->name ) )
{
if ( ++count == number )
return obj;
}
}
return NULL;
}
/*
* Find an obj in player's inventory.
*/
OBJ_DATA *get_obj_carry( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
OBJ_DATA *obj;
int number;
int count;
number = number_argument( argument, arg );
count = 0;
for ( obj = ch->carrying; obj != NULL; obj = obj->next_content )
{
if ( obj->wear_loc == WEAR_NONE
&& can_see_obj( ch, obj )
&& is_name( arg, obj->name ) )
{
if ( ++count == number )
return obj;
}
}
return NULL;
}
/*
* Find an obj in player's equipment.
*/
OBJ_DATA *get_obj_wear( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
OBJ_DATA *obj;
int number;
int count;
number = number_argument( argument, arg );
count = 0;
for ( obj = ch->carrying; obj != NULL; obj = obj->next_content )
{
if ( obj->wear_loc != WEAR_NONE
&& can_see_obj( ch, obj )
&& is_name( arg, obj->name ) )
{
if ( ++count == number )
return obj;
}
}
return NULL;
}
/*
* Find an obj in the room or in inventory.
*/
OBJ_DATA *get_obj_here( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *obj;
obj = get_obj_list( ch, argument, ch->in_room->contents );
if ( obj != NULL )
return obj;
if ( ( obj = get_obj_carry( ch, argument ) ) != NULL )
return obj;
if ( ( obj = get_obj_wear( ch, argument ) ) != NULL )
return obj;
return NULL;
}
/*
* Find an obj in the world.
*/
OBJ_DATA *get_obj_world( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
OBJ_DATA *obj;
int number;
int count;
if ( ( obj = get_obj_here( ch, argument ) ) != NULL )
return obj;
number = number_argument( argument, arg );
count = 0;
for ( obj = object_list; obj != NULL; obj = obj->next )
{
if ( can_see_obj( ch, obj ) && is_name( arg, obj->name ) )
{
if ( ++count == number )
return obj;
}
}
return NULL;
}
/*
* Create a 'money' obj.
*/
OBJ_DATA *create_money( int amount )
{
char buf[MAX_STRING_LENGTH];
OBJ_DATA *obj;
if ( amount <= 0 )
{
bug( "Create_money: zero or negative money %d.", amount );
amount = 1;
}
if ( amount == 1 )
{
obj = create_object( get_obj_index( OBJ_VNUM_MONEY_ONE ), 0 );
}
else
{
obj = create_object( get_obj_index( OBJ_VNUM_MONEY_SOME ), 0 );
sprintf( buf, obj->short_descr, amount );
free_string( obj->short_descr );
obj->short_descr = str_dup( buf );
obj->value[0] = amount;
}
return obj;
}
/*
* Return # of objects which an object counts as.
* Thanks to Tony Chamberlain for the correct recursive code here.
*/
int get_obj_number( OBJ_DATA *obj )
{
/*
int number;
number = 0;
if ( obj->item_type == ITEM_CONTAINER )
for ( obj = obj->contains; obj != NULL; obj = obj->next_content )
number += get_obj_number( obj );
else
number = 1;
return number;
*/
return 1;
}
/*
* Return weight of an object, including weight of contents.
*/
int get_obj_weight( OBJ_DATA *obj )
{
int weight;
weight = obj->weight;
for ( obj = obj->contains; obj != NULL; obj = obj->next_content )
weight += get_obj_weight( obj );
return weight;
}
/*
* True if room is dark.
*/
bool room_is_dark( ROOM_INDEX_DATA *pRoomIndex )
{
if ( pRoomIndex->light > 0 )
return FALSE;
if ( IS_SET(pRoomIndex->room_flags, ROOM_DARK) )
return TRUE;
if ( pRoomIndex->sector_type == SECT_INSIDE
|| pRoomIndex->sector_type == SECT_CITY )
return FALSE;
if ( weather_info.sunlight == SUN_SET
|| weather_info.sunlight == SUN_DARK )
return TRUE;
return FALSE;
}
/*
* True if room is private.
*/
bool room_is_private( ROOM_INDEX_DATA *pRoomIndex )
{
CHAR_DATA *rch;
int count;
count = 0;
for ( rch = pRoomIndex->people; rch != NULL; rch = rch->next_in_room )
count++;
if ( IS_SET(pRoomIndex->room_flags, ROOM_PRIVATE) && count >= 2 )
return TRUE;
if ( IS_SET(pRoomIndex->room_flags, ROOM_SOLITARY) && count >= 1 )
return TRUE;
return FALSE;
}
/*
* True if char can see victim.
*/
bool can_see( CHAR_DATA *ch, CHAR_DATA *victim )
{
if ( ch == victim )
return TRUE;
if ( !IS_NPC(victim)
&& IS_SET(victim->act, PLR_WIZINVIS)
&& get_trust( ch ) < get_trust( victim ) )
return FALSE;
if ( !IS_NPC(ch) && IS_SET(ch->act, PLR_HOLYLIGHT) )
return TRUE;
if ( IS_AFFECTED(ch, AFF_BLIND) )
return FALSE;
if ( room_is_dark( ch->in_room ) && !IS_AFFECTED(ch, AFF_INFRARED) )
return FALSE;
if ( IS_AFFECTED(victim, AFF_INVISIBLE)
&& !IS_AFFECTED(ch, AFF_DETECT_INVIS) )
return FALSE;
if ( IS_AFFECTED(victim, AFF_HIDE)
&& !IS_AFFECTED(ch, AFF_DETECT_HIDDEN)
&& victim->fighting == NULL
&& ( IS_NPC(ch) ? !IS_NPC(victim) : IS_NPC(victim) ) )
return FALSE;
return TRUE;
}
/*
* True if char can see obj.
*/
bool can_see_obj( CHAR_DATA *ch, OBJ_DATA *obj )
{
if ( !IS_NPC(ch) && IS_SET(ch->act, PLR_HOLYLIGHT) )
return TRUE;
if ( obj->item_type == ITEM_POTION )
return TRUE;
if ( IS_AFFECTED( ch, AFF_BLIND ) )
return FALSE;
if ( obj->item_type == ITEM_LIGHT && obj->value[2] != 0 )
return TRUE;
if ( room_is_dark( ch->in_room ) && !IS_AFFECTED(ch, AFF_INFRARED) )
return FALSE;
if ( IS_SET(obj->extra_flags, ITEM_INVIS)
&& !IS_AFFECTED(ch, AFF_DETECT_INVIS) )
return FALSE;
return TRUE;
}
/*
* True if char can drop obj.
*/
bool can_drop_obj( CHAR_DATA *ch, OBJ_DATA *obj )
{
if ( !IS_SET(obj->extra_flags, ITEM_NODROP) )
return TRUE;
if ( !IS_NPC(ch) && ch->level >= LEVEL_IMMORTAL )
return TRUE;
return FALSE;
}
/*
* Return ascii name of an item type.
*/
char *item_type_name( OBJ_DATA *obj )
{
switch ( obj->item_type )
{
case ITEM_LIGHT: return "light";
case ITEM_SCROLL: return "scroll";
case ITEM_WAND: return "wand";
case ITEM_STAFF: return "staff";
case ITEM_WEAPON: return "weapon";
case ITEM_TREASURE: return "treasure";
case ITEM_ARMOR: return "armor";
case ITEM_POTION: return "potion";
case ITEM_FURNITURE: return "furniture";
case ITEM_TRASH: return "trash";
case ITEM_CONTAINER: return "container";
case ITEM_DRINK_CON: return "drink container";
case ITEM_KEY: return "key";
case ITEM_FOOD: return "food";
case ITEM_MONEY: return "money";
case ITEM_BOAT: return "boat";
case ITEM_CORPSE_NPC: return "npc corpse";
case ITEM_CORPSE_PC: return "pc corpse";
case ITEM_FOUNTAIN: return "fountain";
case ITEM_PILL: return "pill";
}
bug( "Item_type_name: unknown type %d.", obj->item_type );
return "(unknown)";
}
/*
* Return ascii name of an affect location.
*/
char *affect_loc_name( int location )
{
switch ( location )
{
case APPLY_NONE: return "none";
case APPLY_STR: return "strength";
case APPLY_DEX: return "dexterity";
case APPLY_INT: return "intelligence";
case APPLY_WIS: return "wisdom";
case APPLY_CON: return "constitution";
case APPLY_SEX: return "sex";
case APPLY_CLASS: return "class";
case APPLY_LEVEL: return "level";
case APPLY_AGE: return "age";
case APPLY_MANA: return "mana";
case APPLY_HIT: return "hp";
case APPLY_MOVE: return "moves";
case APPLY_GOLD: return "gold";
case APPLY_EXP: return "experience";
case APPLY_AC: return "armor class";
case APPLY_HITROLL: return "hit roll";
case APPLY_DAMROLL: return "damage roll";
case APPLY_SAVING_PARA: return "save vs paralysis";
case APPLY_SAVING_ROD: return "save vs rod";
case APPLY_SAVING_PETRI: return "save vs petrification";
case APPLY_SAVING_BREATH: return "save vs breath";
case APPLY_SAVING_SPELL: return "save vs spell";
// Don't fault on TFC zones
case APPLY_CHARISMA: return "chr";
case APPLY_LUC: return "luck"; case APPLY_NOSTEAL: return "anti-theft";
case APPLY_NOSLEEP: return "nosleep"; // steadfastness?
case APPLY_NOSUMMON: return "blocking";
case APPLY_NOCHARM: return "nocharm"; // steadfastness?
case APPLY_NOSEXCHANGE: return "familiarity";
case APPLY_TRUESEE: return "true seeing";
case APPLY_NOINFO: return "obscurement";
}
bug( "Affect_location_name: unknown location %d.", location );
return "(unknown)";
}
/*
* Return ascii name of an affect bit vector.
*/
char *affect_bit_name( int vector )
{
static char buf[512];
buf[0] = '\0';
if ( vector & AFF_BLIND ) strcat( buf, " blind" );
if ( vector & AFF_INVISIBLE ) strcat( buf, " invisible" );
if ( vector & AFF_DETECT_EVIL ) strcat( buf, " detect_evil" );
if ( vector & AFF_DETECT_INVIS ) strcat( buf, " detect_invis" );
if ( vector & AFF_DETECT_MAGIC ) strcat( buf, " detect_magic" );
if ( vector & AFF_DETECT_HIDDEN ) strcat( buf, " detect_hidden" );
if ( vector & AFF_HOLD ) strcat( buf, " hold" );
if ( vector & AFF_SANCTUARY ) strcat( buf, " sanctuary" );
if ( vector & AFF_FAERIE_FIRE ) strcat( buf, " faerie_fire" );
if ( vector & AFF_INFRARED ) strcat( buf, " infrared" );
if ( vector & AFF_CURSE ) strcat( buf, " curse" );
if ( vector & AFF_FLAMING ) strcat( buf, " flaming" );
if ( vector & AFF_POISON ) strcat( buf, " poison" );
if ( vector & AFF_PROTECT ) strcat( buf, " protect" );
if ( vector & AFF_PARALYSIS ) strcat( buf, " paralysis" );
if ( vector & AFF_SLEEP ) strcat( buf, " sleep" );
if ( vector & AFF_SNEAK ) strcat( buf, " sneak" );
if ( vector & AFF_HIDE ) strcat( buf, " hide" );
if ( vector & AFF_CHARM ) strcat( buf, " charm" );
if ( vector & AFF_FLYING ) strcat( buf, " flying" );
if ( vector & AFF_PASS_DOOR ) strcat( buf, " pass_door" );
return ( buf[0] != '\0' ) ? buf+1 : "none";
}
/*
* Return ascii name of extra flags vector.
*/
char *extra_bit_name( int extra_flags )
{
static char buf[512];
buf[0] = '\0';
if ( extra_flags & ITEM_GLOW ) strcat( buf, " glow" );
if ( extra_flags & ITEM_HUM ) strcat( buf, " hum" );
if ( extra_flags & ITEM_DARK ) strcat( buf, " dark" );
if ( extra_flags & ITEM_LOCK ) strcat( buf, " lock" );
if ( extra_flags & ITEM_EVIL ) strcat( buf, " evil" );
if ( extra_flags & ITEM_INVIS ) strcat( buf, " invis" );
if ( extra_flags & ITEM_MAGIC ) strcat( buf, " magic" );
if ( extra_flags & ITEM_NODROP ) strcat( buf, " nodrop" );
if ( extra_flags & ITEM_BLESS ) strcat( buf, " bless" );
if ( extra_flags & ITEM_ANTI_GOOD ) strcat( buf, " anti-good" );
if ( extra_flags & ITEM_ANTI_EVIL ) strcat( buf, " anti-evil" );
if ( extra_flags & ITEM_ANTI_NEUTRAL ) strcat( buf, " anti-neutral" );
if ( extra_flags & ITEM_NOREMOVE ) strcat( buf, " noremove" );
if ( extra_flags & ITEM_INVENTORY ) strcat( buf, " inventory" );
if ( extra_flags & 16384 ) strcat( buf, " metallic" ); // @@@
if ( extra_flags & ~(ITEM_GLOW|ITEM_HUM|ITEM_DARK|ITEM_LOCK|ITEM_EVIL|
ITEM_INVIS|ITEM_MAGIC|ITEM_NODROP|ITEM_BLESS|ITEM_ANTI_GOOD|
ITEM_ANTI_EVIL|ITEM_ANTI_NEUTRAL|ITEM_NOREMOVE|ITEM_INVENTORY|16384))
strcat( buf, " (and unknown bits)" ); // @@@
return ( buf[0] != '\0' ) ? buf+1 : "none";
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -