|
Crossfire Server, Branch 1.12
R12190
|
This plugin adds random NPCs to town, and makes them enter houses, spawns new ones. More...
|
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... | |
Modules | |
| Scorn parameters | |
Parameters for the City life plugin for Scorn. | |
Files | |
| file | citylife.c |
This file is part of the city life plugin. | |
Defines | |
| #define | FIRST_MOVE_KEY "citylife_first_move" |
| Key to contain whether it's the first move of the NPC or not. | |
Functions | |
| CF_PLUGIN int | citylife_runPluginCommand (object *op, char *params) |
| CF_PLUGIN void * | getPluginProperty (int *type,...) |
| Gets a plugin property. | |
| CF_PLUGIN int | initPlugin (const char *iversion, f_plug_api gethooksptr) |
| Plugin initialisation function. | |
| static const mapzone | available_zones [] |
| All maps we work on. | |
| static const mapzone * | get_zone_for_map (mapstruct *map) |
| Finds if a map has a zone defined. | |
| static object * | get_npc (const mapzone *zone) |
| Creates a NPC for the specified zone, and do needed initialization. | |
| static void | add_npc_to_zone (const mapzone *zone, mapstruct *map) |
| Add an NPC somewhere in a spawn zone. | |
| static void | add_npc_to_point (const mapzone *zone, mapstruct *map) |
| Add an NPC somewhere at a spawn point. | |
| static void | add_npcs_to_map (mapstruct *map) |
| Add some NPCs to the map, based on the zone definition. | |
| static void | add_npc_to_random_map (void) |
| Find a suitable map loaded and add an NPC to it. | |
| CF_PLUGIN void * | citylife_globalEventListener (int *type,...) |
| CF_PLUGIN int | postInitPlugin (void) |
| Plugin was initialized, now to finish. | |
| CF_PLUGIN void * | eventListener (int *type,...) |
| Handles an object-related event. | |
| CF_PLUGIN int | closePlugin (void) |
| Close the plugin. | |
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().
| static void add_npc_to_point | ( | const mapzone * | zone, |
| mapstruct * | map | ||
| ) | [static] |
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 void add_npc_to_random_map | ( | void | ) | [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().


| static void add_npc_to_zone | ( | const mapzone * | zone, |
| mapstruct * | map | ||
| ) | [static] |
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 void add_npcs_to_map | ( | mapstruct * | 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().


| CF_PLUGIN int citylife_runPluginCommand | ( | object * | op, |
| char * | params | ||
| ) |
Definition at line 101 of file citylife.c.
| CF_PLUGIN int closePlugin | ( | void | ) |
Close the plugin.
Closes the sqlite database.
Close the 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. |
Handles an object-related event.
| 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, and PLUGIN_NAME.

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, and PLUGIN_NAME.
Referenced by add_npc_to_point(), and add_npc_to_zone().


| static const mapzone* get_zone_for_map | ( | mapstruct * | map | ) | [static] |
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. |
Plugin initialisation function.
| iversion | server version. |
| gethooksptr | function to get hooks from. |
Plugin initialisation function.
| 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 was initialized, now to finish.
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.

const mapzone available_zones[] [static] |
{
{ scorn_nw_points, 5, scorn_nw_zones, 1, 2, "/world/world_104_115", scorn_archs, 12 },
{ scorn_ne_points, 1, scorn_ne_zones, 1, 5, "/world/world_105_115", scorn_archs, 12 },
{ scorn_sw_points, 3, scorn_sw_zones, 1, 5, "/world/world_104_116", scorn_archs, 12 },
{ scorn_se_points, 1, scorn_se_zones, 1, 5, "/world/world_105_116", scorn_archs, 12 },
{ NULL, -1, NULL, -1, 1, "", NULL, 0 },
}
All maps we work on.
Definition at line 221 of file citylife.c.
1.7.6.1