![]() |
Crossfire Server, Trunk
1.75.0
|
This module adds random NPCs to town, and makes them enter houses, spawns new ones. More...
Files | |
file | citylife.cpp |
Data Structures | |
struct | mapzone |
Options for a map. More... | |
struct | spawn_point |
Point from which a NPC can come when the map is loaded. More... | |
struct | spawn_zone |
Zone in which to add NPCs when the map was just loaded. More... | |
Macros | |
#define | CITYLIFE_NAME "citylife" |
Module name for the event system. More... | |
#define | FIRST_MOVE_KEY "citylife_first_move" |
Key to contain whether it's the first move of the NPC or not. More... | |
Functions | |
static void | add_npc_to_point (const mapzone *zone, mapstruct *map) |
Add an NPC somewhere at a spawn point. More... | |
static void | add_npc_to_random_map (void) |
Find a suitable map loaded and add an NPC to it. More... | |
static void | add_npc_to_zone (const mapzone *zone, mapstruct *map) |
Add an NPC somewhere in a spawn zone. More... | |
static void | add_npcs_to_map (mapstruct *map) |
Add some NPCs to the map, based on the zone definition. More... | |
static void | check_zone (const mapzone *zone, const char *path) |
Check if the zone has valid parameters, LOG() when invalid ones. More... | |
void | citylife_close () |
static int | citylife_globalEventListener (int *type,...) |
void | citylife_init (Settings *, ServerSettings *serverSettings) |
static int | eventListener (int *type,...) |
static object * | get_npc (const mapzone *zone) |
Creates a NPC for the specified zone, and do needed initialization. More... | |
static const mapzone * | get_zone_for_map (mapstruct *map) |
Finds if a map has a zone defined. More... | |
static void | load_citylife (BufferReader *reader, const char *filename) |
Read a .citylife file. More... | |
mapzone::mapzone () | |
Variables | |
std::vector< std::string > | mapzone::available_archetypes |
What archetypes can we chose from for an NPC? More... | |
static event_registration | c |
int | spawn_zone::ex |
int | spawn_zone::ey |
static event_registration | m |
static std::unordered_map< std::string, mapzone * > | maps |
All defined maps, with the path as key. More... | |
std::vector< spawn_point > | mapzone::points |
Points to spawn from when there is a player on the map. More... | |
int | mapzone::population |
Maximum of NPCs to add at load time. More... | |
int | spawn_zone::sx |
int | spawn_zone::sy |
int | spawn_point::x |
int | spawn_point::y |
std::vector< spawn_zone > | mapzone::zones |
Zones where to spawn at load time. More... | |
This module adds random NPCs to town, and makes them enter houses, spawns new ones.
When a map is loaded, NPCs are randomly added so they appear already. During the course of the server, some will enter houses (disappear), others will exit from houses (appear on a house).
For each map to be processed, two things are defined:
NPCs use a key/value to prevent them from immediately entering the building they exited.
#define CITYLIFE_NAME "citylife" |
Module name for the event system.
Definition at line 57 of file citylife.cpp.
#define FIRST_MOVE_KEY "citylife_first_move" |
Key to contain whether it's the first move of the NPC or not.
Definition at line 60 of file citylife.cpp.
Add an NPC somewhere at a spawn point.
zone | map zone definition from which to get a spawn point. |
map | map to insert into. |
Definition at line 173 of file citylife.cpp.
References get_npc(), object_free_drop_inventory(), object_teleport(), mapzone::points, and RANDOM.
Referenced by add_npc_to_random_map().
|
static |
Find a suitable map loaded and add an NPC to it.
Definition at line 206 of file citylife.cpp.
References add_npc_to_point(), has_been_loaded(), list, MAP_IN_MEMORY, maps, RANDOM, and zones.
Referenced by citylife_globalEventListener().
Add an NPC somewhere in a spawn zone.
zone | map zone definition from which to get a spawn zone. |
map | map to insert into. |
Definition at line 154 of file citylife.cpp.
References get_npc(), object_free_drop_inventory(), object_teleport(), RANDOM, and mapzone::zones.
Referenced by add_npcs_to_map().
|
static |
Add some NPCs to the map, based on the zone definition.
map | map to add to. |
Definition at line 188 of file citylife.cpp.
References add_npc_to_zone(), CITYLIFE_NAME, get_zone_for_map(), llevDebug, LOG(), mapstruct::path, mapzone::population, and RANDOM.
Referenced by citylife_globalEventListener().
|
static |
Check if the zone has valid parameters, LOG() when invalid ones.
zone | zone to check. |
path | zone path in case of error. |
Definition at line 325 of file citylife.cpp.
References mapzone::available_archetypes, llevError, LOG(), mapzone::points, mapzone::population, and mapzone::zones.
Referenced by load_citylife().
void citylife_close | ( | ) |
Definition at line 437 of file citylife.cpp.
References c, CITYLIFE_NAME, EVENT_CLOCK, EVENT_MAPLOAD, events_unregister_global_handler(), events_unregister_object_handler(), m, and maps.
|
static |
Definition at line 225 of file citylife.cpp.
References add_npc_to_random_map(), add_npcs_to_map(), code, EVENT_CLOCK, EVENT_MAPLOAD, RANDOM, and is_valid_types_gen::type.
Referenced by citylife_init().
void citylife_init | ( | Settings * | , |
ServerSettings * | serverSettings | ||
) |
Definition at line 426 of file citylife.cpp.
References assets_add_collector_hook(), c, citylife_globalEventListener(), CITYLIFE_NAME, ServerSettings::disabled_plugins, EVENT_CLOCK, EVENT_MAPLOAD, eventListener(), events_register_global_handler(), events_register_object_handler(), load_citylife(), m, and serverSettings.
|
static |
If the key doesn't exist, it means 'who' wasn't created by us, since we do set the key each time. So play it safe and totally remove the event.
Definition at line 249 of file citylife.cpp.
References object::above, object::below, CLEAR_FLAG, EVENT_ATTACKED, EVENT_CONNECTOR, EVENT_TIME, EXIT, FIRST_MOVE_KEY, FLAG_NO_DROP, FLAG_RANDOM_MOVE, FLAG_STAND_STILL, get_map_flags(), GET_MAP_OB, object::inv, llevInfo, LOG(), object::map, move_ob(), object::name, object_find_by_type_subtype(), object_free(), object_free_drop_inventory(), object_get_value(), object_remove(), object_set_value(), P_OUT_OF_MAP, RANDOM, SET_FLAG, object::subtype, is_valid_types_gen::type, object::type, object::x, and object::y.
Referenced by citylife_init().
Creates a NPC for the specified zone, and do needed initialization.
zone | what NPCs to create. |
Definition at line 114 of file citylife.cpp.
References add_string(), arch_to_object(), mapzone::available_archetypes, CITYLIFE_NAME, create_archetype(), FIRST_MOVE_KEY, FLAG_RANDOM_MOVE, FLAG_UNDEAD, FLAG_UNIQUE, llevError, LOG(), object_insert_in_ob(), object_set_value(), RANDOM, SET_FLAG, object::slaying, object::title, and try_find_archetype().
Referenced by add_npc_to_point(), and add_npc_to_zone().
Finds if a map has a zone defined.
map | candidat map. |
Definition at line 102 of file citylife.cpp.
References maps, and mapstruct::path.
Referenced by add_npcs_to_map().
|
static |
Read a .citylife file.
reader | file reader. |
filename | full file path in case of error. |
Definition at line 345 of file citylife.cpp.
References mapzone::available_archetypes, bufferreader_current_line(), bufferreader_next_line(), check_zone(), spawn_zone::ex, spawn_zone::ey, is_valid_types_gen::found, is_valid_types_gen::line, llevError, LOG(), maps, mapzone::points, mapzone::population, split(), split_string(), spawn_zone::sx, spawn_zone::sy, spawn_point::x, spawn_point::y, and mapzone::zones.
Referenced by citylife_init().
|
inline |
Definition at line 82 of file citylife.cpp.
std::vector<std::string> mapzone::available_archetypes |
What archetypes can we chose from for an NPC?
Definition at line 87 of file citylife.cpp.
Referenced by check_zone(), get_npc(), and load_citylife().
|
static |
Definition at line 424 of file citylife.cpp.
Referenced by citylife_close(), citylife_init(), closePlugin(), compare_map_info(), crypt_string(), decode_array(), decode_number(), decode_object(), decode_string(), encode_string(), find_map_by_key(), find_next_coin(), find_region_by_key(), hiscore_init(), initPlugin(), AssetsCollection< Animations >::next(), player_changer_type_process(), re_match_token(), sort_struct_map_in_quest(), stringbuffer_append_char(), writeConstants(), and writeEnum().
int spawn_zone::ex |
Definition at line 75 of file citylife.cpp.
Referenced by load_citylife().
int spawn_zone::ey |
Definition at line 75 of file citylife.cpp.
Referenced by load_citylife().
|
static |
Definition at line 424 of file citylife.cpp.
Referenced by allocate_map(), animate_weapon(), apply_auto_fix(), attempt_jump(), auto_apply_fix_inventory(), blocked_link(), calculate_difficulty(), can_see_monsterP(), cast_cause_disease(), cast_cone(), cast_create_obj(), cast_destruction(), cast_detection(), cast_earth_to_dust(), cast_light(), cast_polymorph(), cast_raise_dead_spell(), cast_transfer(), cf_map_change_light(), cf_map_get_object_at(), cf_map_insert_object_there(), cf_map_message(), cf_object_change_map(), cfapi_map_get_map(), cfpython_init_types(), change_map_light(), check_bullet(), check_pick(), citylife_close(), citylife_init(), clean_tmp_files(), clean_tmp_map(), command_reset(), command_swap(), common_process_projectile(), counterspell(), create_bomb(), create_map_in_quest_array(), create_maps_array(), current_map_info(), dawn_to_dusk(), decay_objects(), delete_map(), delete_unique_items(), dimension_door(), dispel_rune(), do_auto_apply(), do_skill_ident(), do_throw(), draw_client_map(), draw_client_map2(), dump_all_maps(), dump_map(), expand_lighted_sight(), explosion(), fill_json(), find_spot_for_submap(), find_target_for_friendly_spell(), find_traps(), fire_arch_from_position(), fire_bow(), flee_player(), flush_old_maps(), forklightning(), free_all_objects(), free_map(), get_empty_map(), get_map_from_coord(), get_name_of_region_for_map(), get_rangevector_from_mapcoord(), get_region_by_map(), initcjson_shared(), initPlugin(), link_multipart_objects(), load_map_header(), load_objects(), load_overlay_map(), load_temporary_map(), load_unique_objects(), look_at(), magic_wall(), malloc_info(), map_find_by_archetype(), map_find_by_type(), map_info(), map_light_on(), map_reset_swap(), map_size(), map_space(), mapfile_load(), mapfile_load_lowlevel(), monster_check_doors(), monster_check_earthwalls(), monster_find_nearest_enemy(), monster_move(), monster_npc_call_help(), mood_change(), move_aura(), move_ball_spell(), move_bolt(), move_bullet(), move_ob(), move_player_attack(), move_player_mover(), move_swarm_spell(), ob_blocked(), object_check_move_on(), object_find_first_free_spot(), object_find_free_spot(), Object_GetMap(), object_insert_in_map(), object_insert_in_map_at(), object_remove(), ok_to_put_more(), out_of_map(), path_to_player(), pets_move(), pets_move_golem(), pick_arrow_target(), place_alchemy_objects(), players_on_map(), polymorph_item(), print_shop_string(), probe(), process_map(), push_ob(), PyInit_cjson(), PyInit_Crossfire(), ready_map_name(), reflwall(), remove_adjacent_doors(), remove_trap(), roll_ob(), save_map(), save_objects(), save_throw_object(), send_map_info(), set_darkness_map(), singing(), skill_attack(), spell_find_dir(), stand_near_hostile(), steal(), teleport(), try_fit(), update_buttons(), update_position(), use_oratory(), wall_blocked(), wildcard_match(), write_rune(), and writeMethods().
|
static |
All defined maps, with the path as key.
Definition at line 91 of file citylife.cpp.
Referenced by add_npc_to_random_map(), citylife_close(), get_zone_for_map(), and load_citylife().
std::vector<spawn_point> mapzone::points |
Points to spawn from when there is a player on the map.
Definition at line 82 of file citylife.cpp.
Referenced by add_npc_to_point(), check_zone(), and load_citylife().
int mapzone::population |
Maximum of NPCs to add at load time.
Definition at line 86 of file citylife.cpp.
Referenced by add_npcs_to_map(), check_zone(), and load_citylife().
int spawn_zone::sx |
Definition at line 75 of file citylife.cpp.
Referenced by load_citylife().
int spawn_zone::sy |
Definition at line 75 of file citylife.cpp.
Referenced by load_citylife().
int spawn_point::x |
Definition at line 66 of file citylife.cpp.
Referenced by load_citylife().
int spawn_point::y |
Definition at line 67 of file citylife.cpp.
Referenced by load_citylife().
std::vector<spawn_zone> mapzone::zones |
Zones where to spawn at load time.
Definition at line 85 of file citylife.cpp.
Referenced by add_npc_to_zone(), check_zone(), and load_citylife().