Crossfire Server, Branches 1.12
R18729
|
Modules | |
Scorn parameters | |
Files | |
file | citylife.c |
Data Structures | |
struct | mapzone |
struct | spawn_point |
struct | spawn_zone |
Macros | |
#define | FIRST_MOVE_KEY "citylife_first_move" |
Functions | |
CF_PLUGIN int | citylife_runPluginCommand (object *op, char *params) |
CF_PLUGIN void * | getPluginProperty (int *type,...) |
CF_PLUGIN int | initPlugin (const char *iversion, f_plug_api gethooksptr) |
static const mapzone | available_zones [] |
static const mapzone * | get_zone_for_map (mapstruct *map) |
static object * | get_npc (const mapzone *zone) |
static void | add_npc_to_zone (const mapzone *zone, mapstruct *map) |
static void | add_npc_to_point (const mapzone *zone, mapstruct *map) |
static void | add_npcs_to_map (mapstruct *map) |
static void | add_npc_to_random_map (void) |
CF_PLUGIN void * | citylife_globalEventListener (int *type,...) |
CF_PLUGIN int | postInitPlugin (void) |
CF_PLUGIN void * | eventListener (int *type,...) |
CF_PLUGIN int | closePlugin (void) |
This plugin 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 FIRST_MOVE_KEY "citylife_first_move" |
Key to contain whether it's the first move of the NPC or not.
Definition at line 106 of file citylife.c.
Referenced by eventListener(), and get_npc().
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 304 of file citylife.c.
References cf_object_free(), cf_object_teleport(), mapzone::count_points, get_npc(), mapzone::points, spawn_point::x, and spawn_point::y.
Referenced by add_npc_to_random_map().
|
static |
Find a suitable map loaded and add an NPC to it.
Definition at line 337 of file citylife.c.
References add_npc_to_point(), cf_log(), cf_map_has_been_loaded(), mapzone::count_points, llevDebug, MAP_IN_MEMORY, PLUGIN_NAME, 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 285 of file citylife.c.
References cf_object_free(), cf_object_teleport(), mapzone::count_zones, spawn_zone::ex, spawn_zone::ey, get_npc(), spawn_zone::sx, spawn_zone::sy, 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 319 of file citylife.c.
References add_npc_to_zone(), cf_log(), get_zone_for_map(), llevDebug, mapdef::path, PLUGIN_NAME, and mapzone::population.
Referenced by citylife_globalEventListener().
CF_PLUGIN void* citylife_globalEventListener | ( | int * | type, |
... | |||
) |
Definition at line 358 of file citylife.c.
References add_npc_to_random_map(), add_npcs_to_map(), EVENT_CLOCK, and EVENT_MAPLOAD.
Referenced by postInitPlugin().
Definition at line 101 of file citylife.c.
CF_PLUGIN int closePlugin | ( | void | ) |
Close the plugin.
Closes the sqlite database.
Unloading of plugin.
Definition at line 462 of file citylife.c.
References cf_log(), llevDebug, and PLUGIN_VERSION.
CF_PLUGIN void* eventListener | ( | int * | type, |
... | |||
) |
Handles an object-related event. Doesn't do anything.
type | ignored. |
Unused.
type | unused. |
Definition at line 414 of file citylife.c.
References cf_log(), cf_map_get_object_at(), cf_object_free(), cf_object_get_key(), cf_object_get_object_property(), cf_object_move(), cf_object_remove(), cf_object_set_flag(), cf_object_set_key(), CFAPI_OBJECT_PROP_INVENTORY, CFAPI_OBJECT_PROP_OB_ABOVE, CFAPI_OBJECT_PROP_OB_BELOW, EXIT, FIRST_MOVE_KEY, FLAG_NO_DROP, llevDebug, obj::map, PLUGIN_NAME, obj::type, obj::x, and obj::y.
Creates a NPC for the specified zone, and do needed initialization.
zone | what NPCs to create. |
Definition at line 254 of file citylife.c.
References mapzone::archetypes_count, mapzone::available_archetypes, cf_add_string(), cf_create_object_by_name(), cf_log(), cf_object_insert_object(), cf_object_set_flag(), cf_object_set_key(), FIRST_MOVE_KEY, FLAG_RANDOM_MOVE, FLAG_UNDEAD, llevError, PLUGIN_NAME, obj::slaying, and obj::title.
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 237 of file citylife.c.
References mapzone::count_points, and mapdef::path.
Referenced by add_npcs_to_map().
CF_PLUGIN void* getPluginProperty | ( | int * | type, |
... | |||
) |
Gets a plugin property.
type | ignored. |
type | unused. |
Definition at line 75 of file citylife.c.
References PLUGIN_NAME, PLUGIN_VERSION, and snprintf().
CF_PLUGIN int initPlugin | ( | const char * | iversion, |
f_plug_api | gethooksptr | ||
) |
Plugin initialisation function.
iversion | server version. |
gethooksptr | function to get the hooks. |
Main plugin entry point.
iversion | server version. |
gethooksptr | function to get hooks from. |
Plugin initialization.
iversion | server version. |
gethooksptr | function to get hooks. |
Definition at line 67 of file citylife.c.
References cf_init_plugin(), cf_log(), llevDebug, and PLUGIN_VERSION.
CF_PLUGIN int postInitPlugin | ( | void | ) |
Plugin was initialized, now to finish.
Registers events, initializes the database.
Plugin initialisation.
Definition at line 384 of file citylife.c.
References cf_log(), cf_system_register_global_event(), citylife_globalEventListener(), EVENT_CLOCK, EVENT_MAPLOAD, llevDebug, PLUGIN_NAME, and PLUGIN_VERSION.
|
static |
All maps we work on.
Definition at line 221 of file citylife.c.