 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
47 #include <unordered_map>
55 #define CITYLIFE_NAME "citylife"
58 #define FIRST_MOVE_KEY "citylife_first_move"
82 std::vector<spawn_point>
points;
89 static std::unordered_map<std::string, mapzone *>
maps;
102 return find ==
maps.end() ? nullptr : find->second;
210 for (
auto map =
maps.cbegin(); map !=
maps.cend() && count < 50; map++) {
212 zones[count] = map->second;
219 int selected =
RANDOM() % count;
229 va_start(args,
type);
230 code = va_arg(args,
int);
249 object *ground, *who, *event;
252 va_start(args,
type);
254 who = va_arg(args,
object *);
255 va_arg(args,
object *);
256 va_arg(args,
object *);
257 va_arg(args,
char *);
259 event = va_arg(args,
object *);
267 LOG(
llevInfo,
"citylife: %s attacked, reverting to default behaviour\n", who->
name);
285 LOG(
llevInfo,
"citylife: removing event from object %s which we didn't generate\n", who->
name);
290 if (strcmp(value,
"1") == 0) {
294 for (
object *inv = who->
inv; inv; inv = inv->
below)
298 else if (
RANDOM()%100 < 30) {
299 int16_t sx = who->
x, sy = who->
y;
302 for (ground =
GET_MAP_OB(map, sx, sy); ground; ground = ground->
above) {
330 if (zone->
zones.empty()) {
333 if (zone->
points.empty()) {
350 if (
line[0] ==
'\0' ||
line[0] ==
'#') {
354 char *space = strchr(
line,
' ');
362 if (strcmp(
line,
"map") == 0) {
368 if (existing ==
maps.end()) {
372 zone = existing->second;
380 if (strcmp(
line,
"population") == 0) {
384 if (strcmp(
line,
"zone") == 0) {
394 zone->
zones.push_back(z);
398 if (strcmp(
line,
"point") == 0) {
406 zone->
points.push_back(p);
410 if (strcmp(
line,
"arch") == 0) {
439 for (
auto map :
maps) {
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
struct Settings settings
Server settings.
#define FLAG_STAND_STILL
NPC will not (ever) move.
size_t bufferreader_current_line(BufferReader *br)
Return the index of the last line returned by bufferreader_next_line().
@ llevError
Error, serious thing.
static std::unordered_map< std::string, mapzone * > maps
All defined maps, with the path as key.
@ EVENT_CONNECTOR
Lauwenmark: an invisible object holding a plugin event hook.
int population
Maximum of NPCs to add at load time.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
#define FLAG_UNDEAD
Monster is undead.
object * inv
Pointer to the first object in the inventory.
mapstruct * has_been_loaded(const char *name)
Checks whether map has been loaded.
static int eventListener(int *type,...)
static event_registration c
void events_unregister_object_handler(const char *id)
Remove an object event handler.
static void add_npc_to_point(const mapzone *zone, mapstruct *map)
Add an NPC somewhere at a spawn point.
#define FLAG_UNIQUE
Item is really unique (UNIQUE_ITEMS)
struct mapstruct * map
Pointer to the map in which this object is present.
std::vector< spawn_point > points
Points to spawn from when there is a player on the map.
#define EVENT_MAPLOAD
A map is loaded (pristine state)
static const mapzone * get_zone_for_map(mapstruct *map)
Finds if a map has a zone defined.
sstring title
Of foo, etc.
char path[HUGE_BUF]
Filename of the map.
const char * object_get_value(const object *op, const char *const key)
Get an extra value by key.
#define CITYLIFE_NAME
Module name for the event system.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
object * above
Pointer to the object stacked above this one.
static const house_zone_struct zones[]
Maps we work on.
event_registration events_register_global_handler(int eventcode, f_plug_event hook)
Register a global event handler.
int16_t y
Position in the map for this object.
static event_registration m
void events_register_object_handler(const char *id, f_plug_event handler)
Register an object event handler.
#define MAP_IN_MEMORY
Map is fully loaded.
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects,...
void add_hook(const char *name, collectorHook hook)
uint8_t subtype
Subtype of object.
void citylife_init(Settings *settings)
#define EVENT_CLOCK
Global time event.
static void load_citylife(BufferReader *reader, const char *filename)
Read a .citylife file.
int move_ob(object *op, int dir, object *originator)
Op is trying to move in direction dir.
void events_unregister_global_handler(int eventcode, event_registration id)
Remove a global event handler.
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Splits a string delimited by passed in sep value into characters into an array of strings.
sstring add_string(const char *str)
This will add 'str' to the hash table.
static void check_zone(const mapzone *zone, const char *path)
Check if the zone has valid parameters, LOG() when invalid ones.
object * below
Pointer to the object stacked below this one.
std::vector< spawn_zone > zones
Zones where to spawn at load time.
uint8_t type
PLAYER, BULLET, etc.
std::vector< char * > disabled_plugins
List of disabled plugins, 'All' means all.
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects,...
static void add_npcs_to_map(mapstruct *map)
Add some NPCs to the map, based on the zone definition.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
#define FLAG_NO_DROP
Object can't be dropped.
std::vector< std::string > available_archetypes
What archetypes can we chose from for an NPC?
static void add_npc_to_zone(const mapzone *zone, mapstruct *map)
Add an NPC somewhere in a spawn zone.
#define FLAG_RANDOM_MOVE
NPC will move randomly.
Point from which a NPC can come when the map is loaded.
#define P_OUT_OF_MAP
This space is outside the map.
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
pluglist shows those as well as a short text describing each the list will simply appear empty The keyword for the Python plugin is Python plugout< keyword > Unloads a given identified by its _keyword_ So if you want to unload the Python you need to do plugout Python plugin< libname > Loads a given whose _filename_ is libname So in the case of you d have to do a plugin cfpython so Note that all filenames are relative to the default plugin path(SHARE/plugins). Console messages. ----------------- When Crossfire starts
sstring slaying
Which race to do double damage to.
static int citylife_globalEventListener(int *type,...)
sstring name
The name of the object, obviously...
unsigned long event_registration
Registration identifier type.
static void add_npc_to_random_map(void)
Find a suitable map loaded and add an NPC to it.
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_.
#define EVENT_TIME
Triggered each time the object can react/move.
Zone in which to add NPCs when the map was just loaded.
#define CLEAR_FLAG(xyz, p)
Structure used to build up dialog information when a player says something.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to.
#define EVENT_ATTACKED
Object attacked, with weapon or spell.
archetype * try_find_archetype(const char *name)
int object_teleport(object *op, mapstruct *map, int x, int y)
Move the specified object in a free spot around the map's x & y.
Crossfire Architecture the general intention is to enhance the enjoyability and playability of CF In this code
static object * get_npc(const mapzone *zone)
Creates a NPC for the specified zone, and do needed initialization.
static std::vector< std::string > split(const std::string &field, const std::string &by)
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o except the maps ! You must download a map package and install them the share folder Its must look like doubleclick on crossfire32 dsw There are projects in your libcross lib and plugin_python You need to compile all Easiest way is to select the plugin_python ReleaseLog as active this will compile all others too Then in Visual C press< F7 > to compile If you don t have an appropriate compiler you can try to get the the VC copies the crossfire32 exe in the crossfire folder and the plugin_python dll in the crossfire share plugins folder we will remove it when we get time for it o Last showing lots of weird write to the Crossfire mailing list
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
#define FIRST_MOVE_KEY
Key to contain whether it's the first move of the NPC or not.
@ llevDebug
Only for debugging purposes.
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.