Crossfire Server, Trunk
R22047
|
Modules | |
Scorn parameters | |
darcap parameters | |
Navar parameters | |
Port Joseph parameters | |
stoneville parameters | |
Wolfsburg parameters | |
Santo Dominion parameters | |
Scorn County 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) |
Variables | |
CF_PLUGIN char | SvnRevPlugin [] = SVN_REV |
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 int | citylife_globalEventListener (int *type,...) |
CF_PLUGIN int | postInitPlugin (void) |
CF_PLUGIN int | 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 110 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 664 of file citylife.c.
References cf_object_free_drop_inventory(), cf_object_teleport(), mapzone::count_points, get_npc(), mapzone::points, RANDOM, 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 697 of file citylife.c.
References add_npc_to_point(), cf_map_has_been_loaded(), mapzone::count_points, MAP_IN_MEMORY, 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 645 of file citylife.c.
References cf_object_free_drop_inventory(), cf_object_teleport(), mapzone::count_zones, spawn_zone::ex, spawn_zone::ey, get_npc(), RANDOM, 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 679 of file citylife.c.
References add_npc_to_zone(), cf_log(), get_zone_for_map(), llevDebug, mapdef::path, PLUGIN_NAME, mapzone::population, and RANDOM.
Referenced by citylife_globalEventListener().
CF_PLUGIN int citylife_globalEventListener | ( | int * | type, |
... | |||
) |
Definition at line 716 of file citylife.c.
References add_npc_to_random_map(), add_npcs_to_map(), EVENT_CLOCK, EVENT_MAPLOAD, and RANDOM.
Referenced by postInitPlugin().
CF_PLUGIN int citylife_runPluginCommand | ( | object * | op, |
char * | params | ||
) |
Definition at line 105 of file citylife.c.
CF_PLUGIN int closePlugin | ( | void | ) |
Unloading of plugin.
Close the plugin.
Closes the sqlite database.
Definition at line 829 of file citylife.c.
References cf_log(), llevDebug, and PLUGIN_VERSION.
CF_PLUGIN int eventListener | ( | int * | type, |
... | |||
) |
Unused.
type | unused. |
Handles an object-related event. Doesn't do anything.
type | ignored. |
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 770 of file citylife.c.
References cf_log(), cf_map_get_object_at(), cf_object_free_drop_inventory(), 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, FIRST_MOVE_KEY, FLAG_NO_DROP, llevInfo, and RANDOM.
|
static |
Creates a NPC for the specified zone, and do needed initialization.
zone | what NPCs to create. |
Definition at line 614 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, and RANDOM.
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 597 of file citylife.c.
References mapzone::count_points, and mapdef::path.
Referenced by add_npcs_to_map().
CF_PLUGIN void* getPluginProperty | ( | int * | type, |
... | |||
) |
Get the plugin identification or full name.
type | unused. |
Gets a plugin property.
type | ignored. |
Definition at line 79 of file citylife.c.
References buf, 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. |
Plugin initialization.
iversion | server version. |
gethooksptr | function to get hooks. |
Main plugin entry point.
iversion | server version. |
gethooksptr | function to get hooks from. |
Definition at line 71 of file citylife.c.
References cf_init_plugin(), cf_log(), llevDebug, and PLUGIN_VERSION.
CF_PLUGIN int postInitPlugin | ( | void | ) |
Plugin initialisation. Also sets the initial last_hr
Plugin was initialized, now to finish.
Registers events, initializes the database.
Plugin initialisation.
Definition at line 740 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 571 of file citylife.c.
CF_PLUGIN char SvnRevPlugin[] = SVN_REV |
Definition at line 69 of file citylife.c.