bool unlock_door( char_data* ch, exit_data* exit ) { action_data* action; room_data* room; obj_data* key; if( !is_set( &exit->exit_info, EX_CLOSED ) ) { send( ch, "The %s exit is not associated with a door.\n\r", dir_table[ exit->direction ].name ); return FALSE; } if( !is_set( &exit->exit_info, EX_CLOSED ) ) { send( ch, "%s is not closed.\n\r", exit ); return FALSE; } if( exit->key < 0 ) { send( ch, "You see no obvious way to unlock %s.\n\r", exit ); return FALSE; } if( ( key = has_key( ch, exit->key ) ) == NULL ) { send( ch, "You lack the key - perhaps try picking it.\n\r" ); return FALSE; } if( !is_set( &exit->exit_info, EX_LOCKED ) ) { send( ch, "%s is already unlocked.\n\r", exit ); return FALSE; } room = ch->in_room; for( action = room->action; action != NULL; action = action->next ) if( action->trigger == TRIGGER_UNLOCK_DOOR && is_set( &action->flags, exit->direction ) ) { var_ch = ch; var_room = room; if( !execute( action ) || ch->in_room != room ) return TRUE; break; } act( ch, prog_msg( action, unlock_door_msg[0], unlock_door_msg[1] ), key, exit ); act_notchar( prog_msg( action, unlock_door_msg[2], unlock_door_msg[3] ), ch, key, exit ); remove_bit( &exit->exit_info, EX_LOCKED ); room = exit->to_room; if( ( exit = reverse( exit ) ) != NULL ) { remove_bit( &exit->exit_info, EX_LOCKED ); act_room( room, prog_msg( action, unlock_door_msg[4], unlock_door_msg[5] ), exit ); } return TRUE; }
void find_buddy( char_data* ch, obj_data* obj, int level, int species_list, int obj_list ) { char_data* buddy; player_data* pc; species_data* species; int i; if( obj == NULL ) { bug( "Find_Buddy: Null Object as reagent!?" ); return; } if( ( pc = player( ch ) ) == NULL ) return; for( i = 0; i < 10; i++ ) if( obj->pIndexData->vnum == list_value[ obj_list ][ 10*(ch->shdata->alignment%3)+i ] ) break; if( i == 10 ) { send( ch, "Nothing happens.\n\r" ); return; } send( *ch->array, "%s disintegrates in a burst of blue flame.\n\r", obj ); obj->Extract( 1 ); if( number_range( 0,100 ) < 50-7*level+10*i ) { send( ch, "You feel the summoning fail.\n\r" ); return; } i = list_value[ species_list ][ 10*(ch->shdata->alignment%3)+i ]; if( ( species = get_species( i ) ) == NULL ) { bug( "Find_buddy: unknown species." ); return; } buddy = create_mobile( species ); set_bit( &buddy->status, STAT_PET ); remove_bit( &buddy->status, STAT_AGGR_ALL ); remove_bit( &buddy->status, STAT_AGGR_GOOD ); remove_bit( &buddy->status, STAT_AGGR_EVIL ); buddy->To( ch->array ); send( ch, "%s comes to your summons, stepping from the shadows.\n\r", buddy ); add_follower( buddy, ch ); return; }
bool open_door( char_data* ch, exit_data* exit ) { action_data* action; room_data* room = ch->in_room; if( !is_set( &exit->exit_info, EX_ISDOOR ) ) { send( ch, "There is no door or wall there.\n\r" ); return FALSE; } if( !is_set( &exit->exit_info, EX_CLOSED ) ) { send( ch, "%s is already open.\n\r", exit ); return FALSE; } if( is_set( &exit->exit_info, EX_LOCKED ) ) { send( ch, "%s is locked.\n\r", exit ); return FALSE; } if( is_set( &exit->exit_info, EX_NO_OPEN ) ) { send( ch, "You see no way to open %s.\n\r", exit ); return FALSE; } for( action = room->action; action != NULL; action = action->next ) if( action->trigger == TRIGGER_OPEN_DOOR && is_set( &action->flags, exit->direction ) ) { var_ch = ch; var_room = room; if( !execute( action ) || ch->in_room != room ) return FALSE; break; } act( ch, prog_msg( action, open_msg[0], open_msg[1] ), exit ); act_notchar( prog_msg( action, open_msg[2], open_msg[3] ), ch, exit ); remove_bit( &exit->exit_info, EX_CLOSED ); room = exit->to_room; if( ( exit = reverse( exit ) ) != NULL ) { remove_bit( &exit->exit_info, EX_CLOSED ); act_room( room, prog_msg( action, open_msg[4], open_msg[5] ), exit ); } return TRUE; }
void setup() { set_name( "elephant" ); set_long( "This is an elephant. A large creature with a thick grey " "hide. He seems to weigh a lot so don't let him step on your " "toe.\n" ); set_height( 280 ); set_weight( 100000 ); set_desc( "an elephant that looks back at you with small nice eyes" ); remove_bit( "nose" ); remove_bit( "head" ); add_bit( "head", "head", ({ 0, 135, 0, "left eye", "right eye", "skull", "tongue", "left ear", "right ear", "tusk", "tusks", "trunk" }) );
void open_object( char_data* ch, obj_data* obj ) { if( obj->pIndexData->item_type != ITEM_CONTAINER ) { send( ch, "%s is not a container.\n\r", obj ); return; } if( !is_set( &obj->value[1], CONT_CLOSED ) ) { send( ch, "%s is already open.\n\r", obj ); return; } if( !is_set( &obj->value[1], CONT_CLOSEABLE ) ) { send( ch, "You can't do that.\n\r", ch ); return; } if( is_set( &obj->value[1], CONT_LOCKED ) ) { send( ch, "%s is locked.\n\r", obj ); return; } remove_bit( &obj->value[1], CONT_CLOSED ); send( ch, "You open %s.\n\r", obj ); send( *ch->array, "%s opens %s.\n\r", ch, obj ); }
void stop_fight( char_data* ch ) { char_data* rch; remove_bit( &ch->status, STAT_BERSERK ); ch->fighting = NULL; disrupt_spell( ch ); clear( ch->aggressive ); stop_events( ch, execute_leap ); for( int i = 0; i < *ch->array; i++ ) { if( ( rch = character( ch->array->list[i] ) ) == NULL ) continue; if( rch->cast != NULL && rch->cast->target == ch && spell_table[rch->cast->spell].type != STYPE_WORLD ) disrupt_spell( rch ); rch->aggressive -= ch; if( rch->fighting == ch ) rch->fighting = NULL; for( int j = rch->events-1; j >= 0; j-- ) if( rch->events[j]->pointer == (void*) ch ) { extract( rch->events[j] ); init_attack( rch ); } } }
void char_bash( char_data* ch, char_data* victim ) { int delay; if( victim == ch ) { send( ch, "Bashing yourself is not very productive.\n\r" ); return; } if( victim->species != NULL ) { if( is_set( &victim->species->act_flags, ACT_NO_BASH ) ) { send( ch, "Bashing that does not make sense.\n\r" ); return; } if( is_set( &victim->species->act_flags, ACT_GHOST ) ) { send( ch, "Bashing a ghost is a completely futile exercise.\n\r" ); return; } } if( victim->position < POS_FIGHTING ) { send( ch, "Your victim is already on the ground!\n\r" ); return; } if( victim->Size( ) > ch->Size( )+1 ) { send( ch, "%s is way too large for you to successfully bash %s.\n\r", victim, victim->Him_Her( ) ); return; } if( !can_kill( ch, victim ) ) return; check_killer( ch, victim ); ch->fighting = victim; react_attack( ch, victim ); remove_bit( &ch->status, STAT_LEAPING ); remove_bit( &ch->status, STAT_WIMPY ); ch->improve_skill( SKILL_BASH ); delay = bash_attack( ch, victim ); add_queue( &ch->active, delay ); }
void death( char_data* victim, char_data* ch, char* dt ) { char tmp [ TWO_LINES ]; obj_data* corpse; content_array* where = victim->array; char_data* rch; bool survive; remove_bit( &victim->status, STAT_BERSERK ); if( ch == NULL ) for( int i = 0; i < *where; i++ ) if( ( rch = character( where->list[i] ) ) != NULL && includes( rch->aggressive, victim ) ) { ch = rch; break; } stop_fight( victim ); clear_queue( victim ); if( !can_die( victim ) ) return; disburse_exp( victim ); register_death( victim, ch, dt ); clear_queue( victim ); death_cry( victim ); if( survive = !die_forever( victim ) ) raw_kill( victim ); corpse = make_corpse( victim, where ); loot_corpse( corpse, ch, victim ); if( survive ) return; if( mob( victim ) != NULL ) { victim->Extract( ); return; } sprintf( tmp, "%s's soul is taken by death.", victim->Name( ) ); info( tmp, LEVEL_BUILDER, tmp, IFLAG_DEATHS, 1, victim ); clear_screen( victim ); reset_screen( victim ); send( victim, "Death is surprisingly peaceful.\n\r" ); send( victim, "Good night.\n\r" ); purge( player( victim ) ); }
bool spell_tame( char_data* ch, char_data* victim, void*, int level, int ) { if( null_caster( ch, SPELL_TAME ) ) return TRUE; if( is_set( &victim->status, STAT_PET ) ) { send( ch, "%s is already tame.\r\n", victim ); return TRUE; } if( victim->species == NULL || !is_set( &victim->species->act_flags, ACT_CAN_TAME ) || makes_save( victim, ch, RES_MIND, SPELL_TAME, level ) || victim->leader != NULL || victim->shdata->level > ch->shdata->level ) { send( ch, "%s ignores you.\r\n", victim ); send( *ch->array, "%s ignores %s.\r\n", victim, ch ); return TRUE; } if( victim->shdata->level > ch->shdata->level-pet_levels( ch ) ) { send( ch, "You fail as you are unable to control more animals.\r\n" ); return TRUE; } if( is_set( &victim->species->act_flags, ACT_MOUNT ) && has_mount( ch ) ) return TRUE; if( ch->leader == victim ) stop_follower( ch ); set_bit( &victim->status, STAT_PET ); set_bit( &victim->status, STAT_TAMED ); remove_bit( &victim->status, STAT_AGGR_ALL ); remove_bit( &victim->status, STAT_AGGR_GOOD ); remove_bit( &victim->status, STAT_AGGR_EVIL ); add_follower( victim, ch ); return TRUE; }
void fix( obj_clss_data* obj_clss ) { if( obj_clss->item_type == ITEM_SCROLL ) set_bit( &obj_clss->materials, MAT_PAPER ); for( int i = 0; i < MAX_ANTI; i++ ) if( !strncasecmp( anti_flags[i], "unused", 6 ) ) remove_bit( &obj_clss->anti_flags, i ); return; }
bool pick_door( char_data* ch, exit_data* exit ) { if( !is_set( &exit->exit_info, EX_CLOSED ) ) { send( ch, "%s is not closed.\n\r", exit ); return FALSE; } if( !is_set( &exit->exit_info, EX_LOCKED ) ) { send( ch, "%s is already unlocked.\n\r", exit ); return FALSE; } if( exit->key < 0 ) { send( ch, "You see no keyhole in the door to pick.\n\r" ); return FALSE; } if( is_set( &exit->exit_info, EX_PICKPROOF ) ) { send( ch, "You failed.\n\r" ); return FALSE; } if( ch->species != NULL || !ch->check_skill( SKILL_PICK_LOCK ) ) { send( ch, "You failed.\n\r" ); return FALSE; } remove_bit( &exit->exit_info, EX_LOCKED ); send( ch, "*Click*\n\r" ); send_seen( ch, "%s picks %s.\n\r", ch, exit ); ch->improve_skill( SKILL_PICK_LOCK ); if( ( exit = reverse( exit ) ) != NULL ) remove_bit( &exit->exit_info, EX_LOCKED ); return TRUE; }
void struggle_web( char_data* ch ) { affect_data* affect; for( int i = 0; ; i++ ) { if( i > ch->affected ) { bug( "Execute_Web: Entangled Character with no affect." ); remove_bit( ch->affected_by, AFF_ENTANGLED ); return; } if( ch->affected[i]->type == AFF_ENTANGLED ) { affect = ch->affected[i]; break; } } if( roll_dice( 2,7 )+number_range( 0, affect->level ) < ch->Strength( ) ) strip_affect( ch, AFF_ENTANGLED ); }
void execute_wander( event_data* event ) { char_data* ch = (char_data*) event->owner; exit_data* exit; if( is_set( &ch->status, STAT_ALERT ) && number_range( 0, 30 ) == 0 ) remove_bit( &ch->status, STAT_ALERT ); if( ch->position == POS_STANDING && ch->leader == NULL && ( exit = random_movable_exit( ch ) ) != NULL && !is_set( &exit->to_room->room_flags, RFLAG_NO_MOB ) && ( !is_set( &ch->species->act_flags, ACT_STAY_AREA ) || exit->to_room->area == ch->in_room->area ) ) move_char( ch, exit->direction, FALSE ); if( ch->Is_Valid( ) ) delay_wander( event ); }
void passive_action( char_data* ch ) { command_data* cmd; if( ch->cast != NULL ) { spell_update( ch ); return; } for( ; ; ) { if( ( cmd = pop( ch->cmd_queue ) ) == NULL ) break; assign_bit( &ch->status, STAT_ORDERED, cmd->ordered ); interpret( ch, cmd->string ); remove_bit( &ch->status, STAT_ORDERED ); delete cmd; if( ch->link != NULL ) ch->link->idle = 0; if( ch->active.time != -1 ) return; } check_wimpy( ch ); if( is_set( ch->affected_by, AFF_ENTANGLED ) ) { struggle_web( ch ); add_queue( &ch->active, 32 ); return; } if( ch->position < POS_STANDING && ( ch->fighting != NULL || !is_empty( ch->aggressive ) ) ) { jump_feet( ch ); add_queue( &ch->active, 32 ); } }
void advance_level( char_data* ch, bool message ) { char buf [ MAX_STRING_LENGTH ]; int clss = ch->pcdata->clss; int add_hp; int add_mana; int add_move; int pracs = 0; bool regain; if( ch->species != NULL ) return; ch->shdata->level++; regain = ( ch->pcdata->max_level != -1 ); if( message ) { send( ch, "\r\n-=-= CONGRATS!!! =-=-\r\n\r\n" ); send( ch, "You have %sgained level %d.\r\n", regain ? "re" : "", ch->shdata->level ); send( ch, "You need %d exp for the next level.\r\n", exp_for_level( ch )-ch->exp ); sprintf( buf, "%s has %sgained level %d.", ch->descr->name, regain ? "re" : "", ch->shdata->level ); info( buf, LEVEL_BUILDER, buf, IFLAG_LEVELS, regain ? 2 : 1, ch ); } if( ch->pcdata->max_level == ch->shdata->level ) { ch->pcdata->max_level = -1; ch->base_hit = ch->pcdata->level_hit; ch->base_mana = ch->pcdata->level_mana; ch->base_move = ch->pcdata->level_move; } else { add_hp = number_range( clss_table[ clss ].hit_min, clss_table[ clss ].hit_max ); add_mana = number_range( clss_table[ clss ].mana_min, clss_table[ clss ].mana_max ); add_move = number_range( clss_table[ clss ].move_min, clss_table[ clss ].move_max ); ch->base_hit += add_hp; ch->base_mana += add_mana; ch->base_move += add_move; if( ch->pcdata->max_level == -1 ) { if( ( pracs = 12-ch->shdata->level ) > 0 ) { if( message ) send( ch, "\r\n>> You gain %d practice point%s. <<\r\n\r\n", pracs, pracs == 1 ? "" : "s" ); ch->pcdata->practice += pracs; } remove_bit( ch->pcdata->pfile->flags, PLR_FAMILIAR ); } } if( message ) { sprintf( buf, "%sained level %d.", regain ? "Reg" : "G", ch->shdata->level ); player_log( ch, buf ); } ch->pcdata->pfile->level = ch->shdata->level; calc_resist( ch ); update_maxes( ch ); }
void find_familiar( char_data* ch, obj_data* obj, int level, int species_list, int obj_list ) { char_data* familiar; player_data* pc; species_data* species; int i; if( obj == NULL ) { bug( "Find_Familiar: Null Object as reagent!?" ); return; } if( ( pc = player( ch ) ) == NULL ) return; if( ch->shdata->level < LEVEL_APPRENTICE && is_set( ch->pcdata->pfile->flags, PLR_FAMILIAR ) ) { send( ch, "Nothing happens.\n\r" ); send( ch, "You can only summon one familiar per level.\n\r" ); return; } if( pc->familiar != NULL ) { send( ch, "Nothing happens.\n\r" ); send( ch, "You can only have one familiar at a time.\n\r" ); return; } for( i = 0; i < 10; i++ ) if( obj->pIndexData->vnum == list_value[ obj_list ][ 10*(ch->shdata->alignment%3)+i ] ) break; if( i == 10 ) { send( ch, "Nothing happens.\n\r" ); return; } send( *ch->array, "%s disintegrates in a burst of blue flame.\n\r", obj ); obj->Extract( 1 ); if( number_range( 0,100 ) < 50-7*level+10*i ) { send( ch, "You feel the summoning fail.\n\r" ); return; } i = list_value[ species_list ][ 10*(ch->shdata->alignment%3)+i ]; if( ( species = get_species( i ) ) == NULL ) { bug( "Find_familiar: unknown species." ); return; } familiar = create_mobile( species ); familiar->reset = NULL; pc->familiar = familiar; set_bit( &familiar->status, STAT_PET ); set_bit( &familiar->status, STAT_FAMILIAR ); set_bit( ch->pcdata->pfile->flags, PLR_FAMILIAR ); remove_bit( &familiar->status, STAT_AGGR_ALL ); remove_bit( &familiar->status, STAT_AGGR_GOOD ); remove_bit( &familiar->status, STAT_AGGR_EVIL ); familiar->To( ch->array ); send( ch, "%s comes to your summons, stepping from the shadows.\n\r", familiar ); add_follower( familiar, ch ); return; }
void do_mount( char_data* ch, char* argument ) { char_data* victim; if( IS_NPC( ch ) || ch->shdata->skill[SKILL_RIDING] == 0 ) { send( ch, "You don't know how to ride.\r\n" ); return; } if( ch->mount != NULL ) { send( ch, "You are already riding %s.\r\n", ch->mount ); return; } if( ( victim = one_character( ch, argument, "mount", ch->array ) ) == NULL ) return; if( IS_SET( ch->in_room->room_flags, RFLAG_NO_MOUNT ) ) { send( "You can't mount here.\r\n", ch ); return; } if( victim->rider != NULL ) { send( ch, "Someone else is already riding them.\r\n" ); return; } if( victim->leader != ch || !is_set( &victim->status, STAT_PET ) || !is_set( &victim->species->act_flags, ACT_MOUNT ) ) { send( ch, "%s refuses to let you mount %s.\r\n", victim, victim->Him_Her( ) ); return; } if( victim->fighting != NULL ) { send( ch, "It is impossible to mount a fighting beast.\r\n" ); return; } if( victim->Size( ) < ch->Size( )+1 ) { send( ch, "%s is too small to carry your weight.\r\n", victim ); return; } if( victim->position != POS_STANDING ) { send( ch, "You can only mount a beast while it is standing.\r\n" ); return; } leave_shadows( ch ); if( ch->pcdata != NULL ) remove_bit( ch->pcdata->pfile->flags, PLR_SNEAK ); send( ch, "You mount %s.\r\n", victim ); send( *ch->array, "%s mounts %s.\r\n", ch, victim ); ch->mount = victim; victim->rider = ch; ch->improve_skill( SKILL_RIDING ); return; }
void do_unlock( char_data* ch, char* argument ) { obj_data* key; exit_data* door; obj_data* obj; oprog_data* oprog; thing_data* thing; if( ( thing = one_thing( ch, argument, "unlock", (thing_array*) &ch->in_room->exits, ch->array, &ch->contents ) ) == NULL ) return; if( ( obj = object( thing ) ) != NULL ) { if( obj->pIndexData->item_type != ITEM_CONTAINER ) { send( ch, "%s isn't a container.\n\r", obj ); return; } if( !is_set( &obj->value[1], CONT_CLOSED ) ) { send( ch, "%s isn't closed.\n\r", obj ); return; } if( obj->pIndexData->value[2] < 0 ) { send( ch, "%s can't be unlocked.\n\r", obj ); return; } if( ( key = has_key( ch, obj->pIndexData->value[2] ) ) == NULL ) { send( ch, "You lack the key.\n\r" ); return; } if( !is_set( &obj->value[1], CONT_LOCKED ) ) { send( ch, "%s is already unlocked.\n\r", obj ); return; } for( oprog = obj->pIndexData->oprog; oprog != NULL; oprog = oprog->next ) if( oprog->trigger == OPROG_TRIGGER_UNLOCK ) { var_ch = ch; var_room = ch->in_room; var_obj = key; var_container = obj; execute( oprog ); break; } act( ch, prog_msg( oprog, unlock_msg[0], unlock_msg[1] ), obj, key ); act_notchar( prog_msg( oprog, unlock_msg[2], unlock_msg[3] ), ch, obj, key ); remove_bit( &obj->value[1], CONT_LOCKED ); return; } if( ( door = exit( thing ) ) != NULL ) { unlock_door( ch, door ); return; } send( ch, "%s isn't unlockable.\n\r", thing ); }
void Char_Data :: To( content_array* where ) { room_data* room; wizard_data* imm; char_data* rch; if( array != NULL ) { roach( "Adding character somewhere which isn't nowhere." ); roach( "-- Ch = %s", this ); From( number ); } Thing_Data :: To( where ); /* CHARACTER TO ROOM */ if( ( room = Room( where->where ) ) != NULL ) { room_position = -1; in_room = room; if( pcdata != NULL ) room->area->nplayer++; if( ( imm = wizard( this ) ) != NULL ) { imm->custom_edit = 0; imm->room_edit = NULL; imm->action_edit = NULL; imm->exit_edit = NULL; } if( water_logged( room ) ) { remove_bit( &status, STAT_SNEAKING ); remove_bit( &status, STAT_HIDING ); remove_bit( &status, STAT_CAMOUFLAGED ); remove_bit( affected_by, AFF_HIDE ); remove_bit( affected_by, AFF_CAMOUFLAGE ); } if( is_submerged( this ) ) enter_water( this ); for( int i = 0; i < room->contents; i++ ) { if( ( rch = character( room->contents[i] ) ) == NULL || rch == this ) continue; if( rch->species != NULL && species != NULL && rch->species->group == species->group && rch->species->group != GROUP_NONE ) { share_enemies( this, rch ); share_enemies( rch, this ); } if( is_aggressive( this, rch ) ) init_attack( this, rch ); if( is_aggressive( rch, this ) ) init_attack( rch, this ); } return; } roach( "Attempted transfer of character to non-room object." ); }