Crossfire Server, Trunk
|
This module adds random NPCs to town, and makes them enter houses, spawns new ones. More...
Files | |
file | citylife.cpp |
Data Structures | |
struct | mapzone |
struct | spawn_point |
struct | spawn_zone |
Macros | |
#define | CITYLIFE_NAME "citylife" |
#define | FIRST_MOVE_KEY "citylife_first_move" |
Functions | |
static void | add_npc_to_point (const mapzone *zone, mapstruct *map) |
static void | add_npc_to_random_map (void) |
static void | add_npc_to_zone (const mapzone *zone, mapstruct *map) |
static void | add_npcs_to_map (mapstruct *map) |
static void | check_zone (const mapzone *zone, const char *path) |
void | citylife_close () |
static int | citylife_globalEventListener (int *type,...) |
void | citylife_init (Settings *settings) |
static int | eventListener (int *type,...) |
static object * | get_npc (const mapzone *zone) |
static const mapzone * | get_zone_for_map (mapstruct *map) |
static void | load_citylife (BufferReader *reader, const char *filename) |
mapzone::mapzone () | |
Variables | |
std::vector< std::string > | mapzone::available_archetypes |
static event_registration | c |
int | spawn_zone::ex |
int | spawn_zone::ey |
static event_registration | m |
static std::unordered_map< std::string, mapzone * > | maps |
std::vector< spawn_point > | mapzone::points |
int | mapzone::population |
int | spawn_zone::sx |
int | spawn_zone::sy |
int | spawn_point::x |
int | spawn_point::y |
std::vector< spawn_zone > | mapzone::zones |
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 60 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 63 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 176 of file citylife.cpp.
References get_npc(), disinfect::map, npc_dialog::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 209 of file citylife.cpp.
References add_npc_to_point(), disinfect::count, has_been_loaded(), guildoracle::list, disinfect::map, 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 157 of file citylife.cpp.
References get_npc(), disinfect::map, npc_dialog::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 191 of file citylife.cpp.
References add_npc_to_zone(), CITYLIFE_NAME, get_zone_for_map(), llevDebug, LOG(), disinfect::map, 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 328 of file citylife.cpp.
References mapzone::available_archetypes, llevError, LOG(), python_init::path, mapzone::points, mapzone::population, and mapzone::zones.
Referenced by load_citylife().
void citylife_close | ( | ) |
Definition at line 447 of file citylife.cpp.
References c, CITYLIFE_NAME, EVENT_CLOCK, EVENT_MAPLOAD, events_unregister_global_handler(), events_unregister_object_handler(), m, disinfect::map, and maps.
|
static |
Definition at line 228 of file citylife.cpp.
References add_npc_to_random_map(), add_npcs_to_map(), make_face_from_files::args, EVENT_CLOCK, EVENT_MAPLOAD, disinfect::map, RANDOM, and is_valid_types_gen::type.
Referenced by citylife_init().
void citylife_init | ( | Settings * | settings | ) |
Definition at line 430 of file citylife.cpp.
References c, citylife_globalEventListener(), CITYLIFE_NAME, Settings::disabled_plugins, EVENT_CLOCK, EVENT_MAPLOAD, eventListener(), events_register_global_handler(), events_register_object_handler(), Settings::hooks, Settings::hooks_count, Settings::hooks_filename, load_citylife(), m, linked_char::name, linked_char::next, and settings.
|
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 252 of file citylife.cpp.
References obj::above, make_face_from_files::args, CLEAR_FLAG, animate::event, 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, commongive::inv, llevInfo, LOG(), disinfect::map, move_ob(), 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, is_valid_types_gen::type, obj::type, autojail::value, and autojail::who.
Referenced by citylife_init().
Creates a NPC for the specified zone, and do needed initialization.
zone | what NPCs to create. |
Definition at line 117 of file citylife.cpp.
References add_string(), archininventory::arch, arch_to_object(), mapzone::available_archetypes, CITYLIFE_NAME, create_archetype(), roll-o-matic::evt, FIRST_MOVE_KEY, FLAG_RANDOM_MOVE, FLAG_UNDEAD, FLAG_UNIQUE, llevError, LOG(), npc_dialog::npc, object_insert_in_ob(), object_set_value(), RANDOM, SET_FLAG, 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 105 of file citylife.cpp.
References disinfect::map, and maps.
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 348 of file citylife.cpp.
References mapzone::available_archetypes, bufferreader_current_line(), bufferreader_next_line(), check_zone(), npc_dialog::filename, is_valid_types_gen::found, is_valid_types_gen::line, llevError, LOG(), maps, python_init::path, mapzone::points, mapzone::population, split(), split_string(), spawn_point::x, spawn_point::y, Moving_Fog::z, and mapzone::zones.
Referenced by citylife_init().
|
inline |
Definition at line 85 of file citylife.cpp.
std::vector<std::string> mapzone::available_archetypes |
What archetypes can we chose from for an NPC?
Definition at line 90 of file citylife.cpp.
Referenced by check_zone(), get_npc(), and load_citylife().
|
static |
Definition at line 427 of file citylife.cpp.
Referenced by nlohmann::detail::lexer< BasicJsonType, InputAdapterType >::add(), TreasureWrapper::childIndex(), citylife_close(), citylife_init(), closePlugin(), compare_map_info(), crypt_string(), decode_array(), decode_number(), decode_object(), decode_string(), encode_string(), UseFilterAssetModel::filterAcceptsRow(), ScriptFilterAssetModel::filterAcceptsRow(), find_map_by_key(), find_next_coin(), find_region_by_key(), generate_condition(), generate_name(), generate_step(), nlohmann::detail::lexer< BasicJsonType, InputAdapterType >::get_token_string(), hiscore_init(), initPlugin(), QuestLoader::load(), main(), AssetsCollection< Animations >::next(), nssv_DISABLE_MSVC_WARNINGS(), player_changer_type_process(), re_match_token(), LicenseManager::readLicense(), CREMessageItemModel::setSelectedRule(), sort_equipment(), sort_struct_map_in_quest(), stringbuffer_append_char(), nlohmann::detail::output_vector_adapter< CharType >::write_character(), nlohmann::detail::output_stream_adapter< CharType >::write_character(), nlohmann::detail::output_string_adapter< CharType, StringType >::write_character(), writeConstants(), and writeEnum().
int spawn_zone::ex |
Definition at line 78 of file citylife.cpp.
int spawn_zone::ey |
Definition at line 78 of file citylife.cpp.
|
static |
Definition at line 427 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(), CREMapInformationManager::checkItem(), citylife_close(), citylife_init(), clean_tmp_files(), clean_tmp_map(), command_reset(), 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_map_info(), 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(), nlohmann::detail::from_json(), get_empty_map(), get_map_from_coord(), get_name_of_region_for_map(), get_rangevector_from_mapcoord(), get_region_by_map(), nlohmann::detail::dtoa_impl::grisu2_digit_gen(), initcjson_shared(), initPlugin(), link_multipart_objects(), load_map_header(), load_objects(), load_overlay_map(), load_temporary_map(), load_unique_objects(), look_at(), magic_wall(), main(), malloc_info(), map_find_by_archetype(), map_find_by_type(), map_info(), map_size(), mapfile_load(), mapsave_test(), monster_check_doors(), monster_check_earthwalls(), monster_find_nearest_enemy(), monster_move(), monster_npc_call_help(), monster_stand_in_light(), mood_change(), move_aura(), move_ball_spell(), move_bolt(), move_bullet(), move_missile(), 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(), CREMapInformationManager::process(), 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(), 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 94 of file citylife.cpp.
Referenced by add_npc_to_random_map(), buildShopReport(), citylife_close(), create_maps_array(), CREFacePanel::CREFacePanel(), fill_json(), get_zone_for_map(), load_citylife(), CREMainWindow::onReportShops(), RandomMaps::RandomMaps(), CREMapInformationManager::randomMaps(), and CREMapInformationManager::storeCache().
std::vector<spawn_point> mapzone::points |
Points to spawn from when there is a player on the map.
Definition at line 85 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 89 of file citylife.cpp.
Referenced by add_npcs_to_map(), check_zone(), and load_citylife().
int spawn_zone::sx |
Definition at line 78 of file citylife.cpp.
int spawn_zone::sy |
Definition at line 78 of file citylife.cpp.
int spawn_point::x |
Definition at line 69 of file citylife.cpp.
Referenced by load_citylife().
int spawn_point::y |
Definition at line 70 of file citylife.cpp.
Referenced by load_citylife().
std::vector<spawn_zone> mapzone::zones |
Zones where to spawn at load time.
Definition at line 88 of file citylife.cpp.
Referenced by add_npc_to_zone(), check_zone(), and load_citylife().