Crossfire Server  1.75.0
cfpython.cpp File Reference
#include <cfpython.h>
#include <fcntl.h>
#include <stdarg.h>
#include <node.h>
#include <svnversion.h>

Go to the source code of this file.

Data Structures

struct  pycode_cache_entry
 One compiled script, cached in memory. More...
 

Macros

#define MAX_COMMANDS   1024
 
#define PYTHON_CACHE_SIZE   256
 Number of python scripts to store the bytecode of at a time. More...
 

Functions

static void addConstants (PyObject *module, const char *name, const CFConstant *constants)
 Add constants and a reverse dictionary to get the name from the value. More...
 
static PyObject * addReply (PyObject *self, PyObject *args)
 
static void addSimpleConstants (PyObject *module, const char *name, const CFConstant *constants)
 Do half the job of addConstants. More...
 
CF_PLUGIN int cfpython_globalEventListener (int *type,...)
 
static void cfpython_init_types (PyObject *m)
 Set up the various types (map, object, archetype and so on) as well as some constants, and Crossfire.error. More...
 
static PyObject * cfpython_openpyfile (char *filename)
 Open a file in the way we need it for compilePython() and postInitPlugin(). More...
 
static FILE * cfpython_pyfile_asfile (PyObject *obj)
 Return a file object from a Python file (as needed for compilePython() and postInitPlugin()) More...
 
CF_PLUGIN int closePlugin (void)
 called before the plugin gets unloaded from memory. More...
 
static PyCodeObject * compilePython (char *filename)
 Outputs the compiled bytecode for a given python file, using in-memory caching of bytecode. More...
 
static PyObject * costStringFromValue (PyObject *self, PyObject *args)
 
static PyObject * createCFObject (PyObject *self, PyObject *args)
 
static PyObject * createCFObjectByName (PyObject *self, PyObject *args)
 
static PyObject * createMap (PyObject *self, PyObject *args)
 
static PyObject * destroyTimer (PyObject *self, PyObject *args)
 
static int do_script (CFPContext *context)
 
CF_PLUGIN int eventListener (int *type,...)
 Handles an object-related event. More...
 
static PyObject * findAnimation (PyObject *self, PyObject *args)
 
static PyObject * findFace (PyObject *self, PyObject *args)
 
static PyObject * findPlayer (PyObject *self, PyObject *args)
 
static void freeContext (CFPContext *context)
 
static void freeEventFiles (char **eventFiles)
 Clear the list of event files. More...
 
static PyObject * getArchetypes (PyObject *self, PyObject *args)
 
static PyObject * getCFPythonVersion (PyObject *self, PyObject *args)
 
static PyObject * getConfigDirectory (PyObject *self, PyObject *args)
 
static PyObject * getDataDirectory (PyObject *self, PyObject *args)
 
static PyObject * getEvent (PyObject *self, PyObject *args)
 
static char ** getEventFiles (CFPContext *context)
 Get the list of script files to run for the specified global event context. More...
 
static PyObject * getFriendlyList (PyObject *self, PyObject *args)
 
static const char * getGlobalEventPath (int code)
 
static PyObject * getLocalDirectory (PyObject *self, PyObject *args)
 
static PyObject * getMapDirectory (PyObject *self, PyObject *args)
 
static PyObject * getMapHasBeenLoaded (PyObject *self, PyObject *args)
 
static PyObject * getMaps (PyObject *self, PyObject *args)
 
static PyObject * getMonthName (PyObject *self, PyObject *args)
 
static PyObject * getParties (PyObject *self, PyObject *args)
 
static PyObject * getPeriodofdayName (PyObject *self, PyObject *args)
 
static PyObject * getPlayerDirectory (PyObject *self, PyObject *args)
 
static PyObject * getPlayers (PyObject *self, PyObject *args)
 
CF_PLUGIN void * getPluginProperty (int *type,...)
 The server calls this function to get information about the plugin, notably the name and version. More...
 
static PyObject * getPrivateDictionary (PyObject *self, PyObject *args)
 
static PyObject * getRegions (PyObject *self, PyObject *args)
 
static PyObject * getReturnValue (PyObject *self, PyObject *args)
 
static PyObject * getScriptName (PyObject *self, PyObject *args)
 
static PyObject * getScriptParameters (PyObject *self, PyObject *args)
 
static PyObject * getSeasonName (PyObject *self, PyObject *args)
 
static PyObject * getSharedDictionary (PyObject *self, PyObject *args)
 
static PyObject * getTempDirectory (PyObject *self, PyObject *args)
 
static PyObject * getTime (PyObject *self, PyObject *args)
 
static PyObject * getUniqueDirectory (PyObject *self, PyObject *args)
 
static PyObject * getWeekdayName (PyObject *self, PyObject *args)
 
static PyObject * getWhatIsMessage (PyObject *self, PyObject *args)
 
static PyObject * getWhoAmI (PyObject *self, PyObject *args)
 
static PyObject * getWhoIsActivator (PyObject *self, PyObject *args)
 
static PyObject * getWhoIsThird (PyObject *self, PyObject *args)
 
static void initConstants (PyObject *module)
 
static void initContextStack (void)
 
int initPlugin (const char *iversion, f_plug_api gethooksptr)
 The server calls this function after loading the plugin. More...
 
static PyObject * log_message (PyObject *self, PyObject *args)
 
static void log_python_error (void)
 Trace a Python error to the Crossfire log. More...
 
static PyObject * matchString (PyObject *self, PyObject *args)
 
static PyObject * npcSay (PyObject *self, PyObject *args)
 
static CFPContextpopContext (void)
 
CF_PLUGIN int postInitPlugin (void)
 The server calls this function to actually initialize the plugin here, after object handlers are registered. More...
 
static void pushContext (CFPContext *context)
 
PyObject * PyInit_cjson (void)
 
static PyObject * PyInit_Crossfire (void)
 
static void python_command_function (object *op, const char *params, const char *script)
 
static PyObject * readyMap (PyObject *self, PyObject *args)
 
static PyObject * registerCommand (PyObject *self, PyObject *args)
 
static PyObject * registerGEvent (PyObject *self, PyObject *args)
 
static void set_exception (const char *fmt,...)
 Set up an Python exception object. More...
 
static PyObject * setPlayerMessage (PyObject *self, PyObject *args)
 
static PyObject * setReturnValue (PyObject *self, PyObject *args)
 
static PyObject * unregisterGEvent (PyObject *self, PyObject *args)
 

Variables

static PyObject * catcher = NULL
 A Python object receiving the contents of Python's stderr, and used to output to the Crossfire log instead of stderr. More...
 
static PyObject * CFPythonError
 
PyMethodDef CFPythonMethods []
 
CFPContextcontext_stack
 
static PyModuleDef CrossfireModule
 
const CFConstant cstAttackMovement []
 
const CFConstant cstAttackType []
 
const CFConstant cstAttackTypeNumber []
 
const CFConstant cstDirection []
 
const CFConstant cstEventType []
 
const CFConstant cstMessageFlag []
 
const CFConstant cstMove []
 
const CFConstant cstReplyTypes []
 
const CFConstant cstTime []
 
const CFConstant cstType []
 
CFPContextcurrent_context
 
static int GECodes []
 
static const char * GEPaths []
 
static PyObject * private_data = NULL
 
static pycode_cache_entry pycode_cache [PYTHON_CACHE_SIZE]
 Cached compiled scripts. More...
 
static command_registration registered_commands [MAX_COMMANDS]
 
static PyObject * shared_data = NULL
 
CF_PLUGIN char SvnRevPlugin [] = SVN_REV
 

Macro Definition Documentation

◆ MAX_COMMANDS

#define MAX_COMMANDS   1024

Definition at line 84 of file cfpython.cpp.

Referenced by closePlugin(), initPlugin(), and registerCommand().

◆ PYTHON_CACHE_SIZE

#define PYTHON_CACHE_SIZE   256

Number of python scripts to store the bytecode of at a time.

Definition at line 72 of file cfpython.cpp.

Referenced by closePlugin(), compilePython(), and postInitPlugin().

Function Documentation

◆ addConstants()

static void addConstants ( PyObject *  module,
const char *  name,
const CFConstant constants 
)
static

Add constants and a reverse dictionary to get the name from the value.

The reverse dictionary will be named '{name}Name'.

Parameters
modulewhere to add the constants to.
nameenum name containing the constants.
constantsconstants to add, the last item must have its values all NULL.

Definition at line 1064 of file cfpython.cpp.

Referenced by initConstants().

◆ addReply()

static PyObject* addReply ( PyObject *  self,
PyObject *  args 
)
static

◆ addSimpleConstants()

static void addSimpleConstants ( PyObject *  module,
const char *  name,
const CFConstant constants 
)
static

Do half the job of addConstants.

It only sets constants, but not a hashtable to get constant names from values. To be used for collections of constants which are not unique but still are useful for scripts.

Parameters
modulewhere to add the constants to.
nameenum name containing the constants.
constantsconstants to add, the last item must have its values all NULL.

Definition at line 1096 of file cfpython.cpp.

Referenced by initConstants().

◆ cfpython_globalEventListener()

◆ cfpython_init_types()

static void cfpython_init_types ( PyObject *  m)
static

Set up the various types (map, object, archetype and so on) as well as some constants, and Crossfire.error.

Definition at line 1434 of file cfpython.cpp.

References CFPythonError, Crossfire_ArchetypeType, Crossfire_MapType, Crossfire_ObjectType, Crossfire_PartyType, Crossfire_PlayerType, Crossfire_RegionType, llevDebug, llevError, llevInfo, llevMonster, and PyInit_cjson().

Referenced by initPlugin().

◆ cfpython_openpyfile()

static PyObject* cfpython_openpyfile ( char *  filename)
static

Open a file in the way we need it for compilePython() and postInitPlugin().

Definition at line 855 of file cfpython.cpp.

Referenced by compilePython(), and postInitPlugin().

◆ cfpython_pyfile_asfile()

static FILE* cfpython_pyfile_asfile ( PyObject *  obj)
static

Return a file object from a Python file (as needed for compilePython() and postInitPlugin())

Definition at line 869 of file cfpython.cpp.

Referenced by compilePython(), and postInitPlugin().

◆ compilePython()

static PyCodeObject* compilePython ( char *  filename)
static

Outputs the compiled bytecode for a given python file, using in-memory caching of bytecode.

Definition at line 913 of file cfpython.cpp.

References pycode_cache_entry::cached_time, cf_add_string(), cf_free_string(), cf_log(), cfpython_openpyfile(), cfpython_pyfile_asfile(), pycode_cache_entry::code, pycode_cache_entry::file, llevDebug, llevError, log_python_error(), PYTHON_CACHE_SIZE, and replace().

Referenced by do_script().

◆ costStringFromValue()

static PyObject* costStringFromValue ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 752 of file cfpython.cpp.

References buf, and cf_cost_string_from_value().

◆ createCFObject()

static PyObject* createCFObject ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 142 of file cfpython.cpp.

References cf_create_object(), and Crossfire_Object_wrap().

◆ createCFObjectByName()

static PyObject* createCFObjectByName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 152 of file cfpython.cpp.

References cf_create_object_by_name(), and Crossfire_Object_wrap().

◆ createMap()

static PyObject* createMap ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 238 of file cfpython.cpp.

References cf_get_empty_map(), and Crossfire_Map_wrap().

◆ destroyTimer()

static PyObject* destroyTimer ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 562 of file cfpython.cpp.

References cf_timer_destroy().

◆ do_script()

static int do_script ( CFPContext context)
static

◆ findAnimation()

static PyObject* findAnimation ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 626 of file cfpython.cpp.

References cf_find_animation().

◆ findFace()

static PyObject* findFace ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 580 of file cfpython.cpp.

References cf_find_face().

◆ findPlayer()

static PyObject* findPlayer ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 206 of file cfpython.cpp.

References cf_player_find(), Crossfire_Object_wrap(), and player::ob.

◆ freeContext()

static void freeContext ( CFPContext context)
static

◆ freeEventFiles()

static void freeEventFiles ( char **  eventFiles)
static

Clear the list of event files.

Parameters
eventFileslist as returned by getEventFiles(), will be invalid after this function call.

Definition at line 1615 of file cfpython.cpp.

Referenced by cfpython_globalEventListener().

◆ getArchetypes()

static PyObject* getArchetypes ( PyObject *  self,
PyObject *  args 
)
static

◆ getCFPythonVersion()

static PyObject* getCFPythonVersion ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 165 of file cfpython.cpp.

◆ getConfigDirectory()

static PyObject* getConfigDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 269 of file cfpython.cpp.

References cf_get_directory().

◆ getDataDirectory()

static PyObject* getDataDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 287 of file cfpython.cpp.

References cf_get_directory().

◆ getEvent()

static PyObject* getEvent ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 351 of file cfpython.cpp.

References CFPContext::event.

◆ getEventFiles()

static char** getEventFiles ( CFPContext context)
static

Get the list of script files to run for the specified global event context.

Parameters
contextevent context, must have its options field correctly filled.
Returns
list of event files that must be deleted by calling freeEventFiles().

Definition at line 1628 of file cfpython.cpp.

References cf_get_maps_directory(), closedir(), dirent, HUGE_BUF, NAME_MAX, opendir(), CFPContext::options, and readdir().

Referenced by cfpython_globalEventListener().

◆ getFriendlyList()

static PyObject* getFriendlyList ( PyObject *  self,
PyObject *  args 
)
static

◆ getGlobalEventPath()

static const char* getGlobalEventPath ( int  code)
static

Definition at line 1697 of file cfpython.cpp.

References GECodes, and GEPaths.

Referenced by cfpython_globalEventListener().

◆ getLocalDirectory()

static PyObject* getLocalDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 275 of file cfpython.cpp.

References cf_get_directory().

◆ getMapDirectory()

static PyObject* getMapDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 251 of file cfpython.cpp.

References cf_get_directory().

◆ getMapHasBeenLoaded()

static PyObject* getMapHasBeenLoaded ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 571 of file cfpython.cpp.

References cf_map_has_been_loaded(), and Crossfire_Map_wrap().

◆ getMaps()

static PyObject* getMaps ( PyObject *  self,
PyObject *  args 
)
static

◆ getMonthName()

static PyObject* getMonthName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 644 of file cfpython.cpp.

References cf_get_month_name().

◆ getParties()

static PyObject* getParties ( PyObject *  self,
PyObject *  args 
)
static

◆ getPeriodofdayName()

static PyObject* getPeriodofdayName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 662 of file cfpython.cpp.

References cf_get_periodofday_name().

◆ getPlayerDirectory()

static PyObject* getPlayerDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 281 of file cfpython.cpp.

References cf_get_directory().

◆ getPlayers()

static PyObject* getPlayers ( PyObject *  self,
PyObject *  args 
)
static

◆ getPrivateDictionary()

static PyObject* getPrivateDictionary ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 362 of file cfpython.cpp.

References private_data, and CFPContext::script.

◆ getRegions()

static PyObject* getRegions ( PyObject *  self,
PyObject *  args 
)
static

◆ getReturnValue()

static PyObject* getReturnValue ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 173 of file cfpython.cpp.

References CFPContext::returnvalue.

◆ getScriptName()

static PyObject* getScriptName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 335 of file cfpython.cpp.

References CFPContext::script.

◆ getScriptParameters()

static PyObject* getScriptParameters ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 341 of file cfpython.cpp.

References CFPContext::options.

◆ getSeasonName()

static PyObject* getSeasonName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 635 of file cfpython.cpp.

References cf_get_season_name().

◆ getSharedDictionary()

static PyObject* getSharedDictionary ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 377 of file cfpython.cpp.

References shared_data.

◆ getTempDirectory()

static PyObject* getTempDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 263 of file cfpython.cpp.

References cf_get_directory().

◆ getTime()

static PyObject* getTime ( PyObject *  self,
PyObject *  args 
)
static

◆ getUniqueDirectory()

static PyObject* getUniqueDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 257 of file cfpython.cpp.

References cf_get_directory().

◆ getWeekdayName()

static PyObject* getWeekdayName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 653 of file cfpython.cpp.

References cf_get_weekday_name().

◆ getWhatIsMessage()

static PyObject* getWhatIsMessage ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 326 of file cfpython.cpp.

References CFPContext::message.

◆ getWhoAmI()

static PyObject* getWhoAmI ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 293 of file cfpython.cpp.

References CFPContext::who.

◆ getWhoIsActivator()

static PyObject* getWhoIsActivator ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 304 of file cfpython.cpp.

References CFPContext::activator.

◆ getWhoIsThird()

static PyObject* getWhoIsThird ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 315 of file cfpython.cpp.

References CFPContext::third.

◆ initConstants()

static void initConstants ( PyObject *  module)
static

Definition at line 1413 of file cfpython.cpp.

References addConstants(), and addSimpleConstants().

Referenced by initPlugin().

◆ initContextStack()

static void initContextStack ( void  )
static

Definition at line 817 of file cfpython.cpp.

Referenced by postInitPlugin().

◆ log_message()

static PyObject* log_message ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 589 of file cfpython.cpp.

References cf_log(), level, llevDebug, llevError, llevInfo, and llevMonster.

◆ log_python_error()

static void log_python_error ( void  )
static

Trace a Python error to the Crossfire log.

This uses code from: http://stackoverflow.com/questions/4307187/how-to-catch-python-stdout-in-c-code See also in initPlugin() the parts about stdOutErr.

Definition at line 893 of file cfpython.cpp.

References catcher, cf_log_plain(), and llevError.

Referenced by compilePython(), and do_script().

◆ matchString()

static PyObject* matchString ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 190 of file cfpython.cpp.

References cf_re_cmp().

◆ npcSay()

static PyObject* npcSay ( PyObject *  self,
PyObject *  args 
)
static

◆ popContext()

static CFPContext * popContext ( void  )
static

◆ pushContext()

static void pushContext ( CFPContext context)
static

Definition at line 822 of file cfpython.cpp.

References current_context, and CFPContext::down.

Referenced by do_script().

◆ PyInit_cjson()

PyObject* PyInit_cjson ( void  )

Definition at line 1165 of file cjson.cpp.

References cjsonModule, initcjson_shared(), and m.

Referenced by cfpython_init_types(), and initPlugin().

◆ PyInit_Crossfire()

static PyObject* PyInit_Crossfire ( void  )
static

Definition at line 1487 of file cfpython.cpp.

References CrossfireModule, and m.

Referenced by initPlugin().

◆ python_command_function()

static void python_command_function ( object op,
const char *  params,
const char *  script 
)
static

◆ readyMap()

static PyObject* readyMap ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 224 of file cfpython.cpp.

References cf_map_get_map(), Crossfire_Map_wrap(), and flags.

◆ registerCommand()

static PyObject* registerCommand ( PyObject *  self,
PyObject *  args 
)
static

◆ registerGEvent()

static PyObject* registerGEvent ( PyObject *  self,
PyObject *  args 
)
static

◆ set_exception()

static void set_exception ( const char *  fmt,
  ... 
)
static

Set up an Python exception object.

Definition at line 93 of file cfpython.cpp.

References buf.

Referenced by addReply(), npcSay(), registerCommand(), and setPlayerMessage().

◆ setPlayerMessage()

static PyObject* setPlayerMessage ( PyObject *  self,
PyObject *  args 
)
static

◆ setReturnValue()

static PyObject* setReturnValue ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 179 of file cfpython.cpp.

References CFPContext::returnvalue.

◆ unregisterGEvent()

static PyObject* unregisterGEvent ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 129 of file cfpython.cpp.

References cf_system_unregister_global_event(), EVENT_TELL, and PLUGIN_NAME.

Variable Documentation

◆ catcher

PyObject* catcher = NULL
static

A Python object receiving the contents of Python's stderr, and used to output to the Crossfire log instead of stderr.

Definition at line 877 of file cfpython.cpp.

Referenced by initPlugin(), and log_python_error().

◆ CFPythonError

PyObject* CFPythonError
static

Definition at line 90 of file cfpython.cpp.

Referenced by cfpython_init_types().

◆ CFPythonMethods

PyMethodDef CFPythonMethods[]

Definition at line 765 of file cfpython.cpp.

Referenced by main().

◆ context_stack

CFPContext* context_stack

Definition at line 104 of file cfpython.cpp.

◆ CrossfireModule

PyModuleDef CrossfireModule
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"Crossfire",
NULL,
-1,
NULL,
NULL,
NULL,
NULL
}
PyMethodDef CFPythonMethods[]
Definition: cfpython.cpp:765

Definition at line 1475 of file cfpython.cpp.

Referenced by PyInit_Crossfire().

◆ cstAttackMovement

const CFConstant cstAttackMovement[]
Initial value:
= {
{ "DISTATT", DISTATT },
{ "RUNATT", RUNATT },
{ "HITRUN", HITRUN },
{ "WAITATT", WAITATT },
{ "RUSH", RUSH },
{ "ALLRUN", ALLRUN },
{ "DISTHIT", DISTHIT },
{ "WAIT2", WAIT2 },
{ "PETMOVE", PETMOVE },
{ "CIRCLE1", CIRCLE1 },
{ "CIRCLE2", CIRCLE2 },
{ "PACEH", PACEH },
{ "PACEH2", PACEH2 },
{ "RANDO", RANDO },
{ "RANDO2", RANDO2 },
{ "PACEV", PACEV },
{ "PACEV2", PACEV2 },
{ NULL, 0 }
}
#define RANDO
The monster will go in a random direction until it is stopped by an obstacle, then it chooses another...
Definition: define.h:535
#define PACEV2
The monster will pace as above but the length of the pace area is longer and the monster stops before...
Definition: define.h:544
#define CIRCLE1
If the upper four bits of move_type / attack_movement are set to this number, the monster will move i...
Definition: define.h:517
#define PETMOVE
If the upper four bits of attack_movement are set to this number, the monster follows a player until ...
Definition: define.h:502
#define HITRUN
Run to then hit player then run away cyclicly.
Definition: define.h:494
#define RUNATT
Run but attack if player catches up to object.
Definition: define.h:493
#define PACEH
The monster will pace back and forth until attacked.
Definition: define.h:525
#define WAITATT
Wait for player to approach then hit, move if hit.
Definition: define.h:495
#define ALLRUN
Always run, never attack good for sim.
Definition: define.h:497
#define RUSH
Rush toward player blindly, similiar to dumb monster.
Definition: define.h:496
#define WAIT2
Monster does not try to move towards player if far.
Definition: define.h:499
#define RANDO2
Constantly move in a different random direction.
Definition: define.h:540
#define DISTATT
Move toward a player if far, but maintain some space, attack from a distance - good for missile users...
Definition: define.h:490
#define PACEH2
The monster will pace as above but the length of the pace area is longer and the monster stops before...
Definition: define.h:528
#define PACEV
The monster will pace back and forth until attacked.
Definition: define.h:541
#define CIRCLE2
Same as CIRCLE1 but a larger circle is used.
Definition: define.h:524
#define DISTHIT
Attack from a distance if hit as recommended by Frank.
Definition: define.h:498

Definition at line 1392 of file cfpython.cpp.

Referenced by main().

◆ cstAttackType

const CFConstant cstAttackType[]
Initial value:
= {
{ "PHYSICAL", AT_PHYSICAL },
{ "MAGIC", AT_MAGIC },
{ "FIRE", AT_FIRE },
{ "ELECTRICITY", AT_ELECTRICITY },
{ "COLD", AT_COLD },
{ "CONFUSION", AT_CONFUSION },
{ "ACID", AT_ACID },
{ "DRAIN", AT_DRAIN },
{ "WEAPONMAGIC", AT_WEAPONMAGIC },
{ "GHOSTHIT", AT_GHOSTHIT },
{ "POISON", AT_POISON },
{ "SLOW", AT_SLOW },
{ "PARALYZE", AT_PARALYZE },
{ "TURN_UNDEAD", AT_TURN_UNDEAD },
{ "FEAR", AT_FEAR },
{ "CANCELLATION", AT_CANCELLATION },
{ "DEPLETE", AT_DEPLETE },
{ "DEATH", AT_DEATH },
{ "CHAOS", AT_CHAOS },
{ "COUNTERSPELL", AT_COUNTERSPELL },
{ "GODPOWER", AT_GODPOWER },
{ "HOLYWORD", AT_HOLYWORD },
{ "BLIND", AT_BLIND },
{ "INTERNAL", AT_INTERNAL },
{ "LIFE_STEALING", AT_LIFE_STEALING },
{ "DISEASE", AT_DISEASE },
{ NULL, 0 }
}
#define AT_HOLYWORD
Damage based on race and caster&#39;s god.
Definition: attack.h:99
#define AT_ELECTRICITY
Can also ignite objects (8)
Definition: attack.h:81
#define AT_COUNTERSPELL
Cancels magic spells (524288) peterm@soda.berkeley.edu.
Definition: attack.h:97
#define AT_DEPLETE
Lose one point from one stat, can be restored (65536) vick@bern.docs.uu.se.
Definition: attack.h:94
#define AT_GHOSTHIT
Attacker dissolves (512)
Definition: attack.h:87
#define AT_INTERNAL
Only used for internal calculations.
Definition: attack.h:101
#define AT_CANCELLATION
Removes magic from items (32768) ylitalo@student.docs.uu.se.
Definition: attack.h:93
#define AT_COLD
Can freeze objects into ice cubes (16)
Definition: attack.h:82
#define AT_BLIND
Blinds victim (4194304) thomas@astro.psu.edu.
Definition: attack.h:100
#define AT_TURN_UNDEAD
Like Fear, but for undead only (8192)
Definition: attack.h:91
#define AT_LIFE_STEALING
16777216 for hp drain
Definition: attack.h:102
#define AT_CHAOS
None by itself, uses random other types (262144) peterm@soda.berkeley.edu.
Definition: attack.h:96
#define AT_GODPOWER
Adds relevant god&#39;s attacktype (1048576) peterm@soda.berkeley.edu.
Definition: attack.h:98
#define AT_DISEASE
33554432 disease attacktypes
Definition: attack.h:104
#define AT_FIRE
Can ignite objects (4)
Definition: attack.h:80
#define AT_PHYSICAL
Basic attack (1)
Definition: attack.h:78
#define AT_DRAIN
Victim loses 2% exp, attacker gains half of that (128)
Definition: attack.h:85
#define AT_POISON
Some damage each turn thereafter (1024)
Definition: attack.h:88
#define AT_FEAR
(16384)
Definition: attack.h:92
#define AT_SLOW
Speed is reduced (2048)
Definition: attack.h:89
#define AT_MAGIC
All magic spells, but not prayers (2)
Definition: attack.h:79
#define AT_CONFUSION
Movement/attack directions become random (32)
Definition: attack.h:83
#define AT_ACID
Random equipped item might corrode when hit (64)
Definition: attack.h:84
#define AT_DEATH
Chance of instant death, otherwise nothing (131072) peterm@soda.berkeley.edu.
Definition: attack.h:95
#define AT_WEAPONMAGIC
Direct damage, very special, use with care (256)
Definition: attack.h:86
#define AT_PARALYZE
Speed is reduced to zero (4096)
Definition: attack.h:90

Definition at line 1271 of file cfpython.cpp.

Referenced by main().

◆ cstAttackTypeNumber

const CFConstant cstAttackTypeNumber[]
Initial value:
= {
{ "PHYSICAL", ATNR_PHYSICAL },
{ "MAGIC", ATNR_MAGIC },
{ "FIRE", ATNR_FIRE },
{ "ELECTRICITY", ATNR_ELECTRICITY },
{ "COLD", ATNR_COLD },
{ "CONFUSION", ATNR_CONFUSION },
{ "ACID", ATNR_ACID },
{ "DRAIN", ATNR_DRAIN },
{ "WEAPONMAGIC", ATNR_WEAPONMAGIC },
{ "GHOSTHIT", ATNR_GHOSTHIT },
{ "POISON", ATNR_POISON },
{ "SLOW", ATNR_SLOW },
{ "PARALYZE", ATNR_PARALYZE },
{ "TURN_UNDEAD", ATNR_TURN_UNDEAD },
{ "FEAR", ATNR_FEAR },
{ "CANCELLATION", ATNR_CANCELLATION },
{ "DEPLETE", ATNR_DEPLETE },
{ "DEATH", ATNR_DEATH },
{ "CHAOS", ATNR_CHAOS },
{ "COUNTERSPELL", ATNR_COUNTERSPELL },
{ "GODPOWER", ATNR_GODPOWER },
{ "HOLYWORD", ATNR_HOLYWORD },
{ "BLIND", ATNR_BLIND },
{ "INTERNAL", ATNR_INTERNAL },
{ "LIFE_STEALING", ATNR_LIFE_STEALING },
{ "DISEASE", ATNR_DISEASE },
{ NULL, 0 }
}
#define ATNR_FEAR
Definition: attack.h:61
#define ATNR_ELECTRICITY
Definition: attack.h:50
#define ATNR_SLOW
Definition: attack.h:58
#define ATNR_FIRE
Definition: attack.h:49
#define ATNR_DISEASE
Definition: attack.h:72
#define ATNR_ACID
Definition: attack.h:53
#define ATNR_WEAPONMAGIC
Definition: attack.h:55
#define ATNR_CONFUSION
Definition: attack.h:52
#define ATNR_CHAOS
Definition: attack.h:65
#define ATNR_PARALYZE
Definition: attack.h:59
#define ATNR_TURN_UNDEAD
Definition: attack.h:60
#define ATNR_DEATH
Definition: attack.h:64
#define ATNR_COLD
Definition: attack.h:51
#define ATNR_INTERNAL
Definition: attack.h:70
#define ATNR_GODPOWER
Definition: attack.h:67
#define ATNR_BLIND
Definition: attack.h:69
#define ATNR_POISON
Definition: attack.h:57
#define ATNR_COUNTERSPELL
Definition: attack.h:66
#define ATNR_DRAIN
Definition: attack.h:54
#define ATNR_GHOSTHIT
Definition: attack.h:56
#define ATNR_CANCELLATION
Definition: attack.h:62
#define ATNR_MAGIC
Definition: attack.h:48
#define ATNR_HOLYWORD
Definition: attack.h:68
#define ATNR_DEPLETE
Definition: attack.h:63
#define ATNR_LIFE_STEALING
Definition: attack.h:71
#define ATNR_PHYSICAL
Definition: attack.h:47

Definition at line 1301 of file cfpython.cpp.

Referenced by main().

◆ cstDirection

const CFConstant cstDirection[]
Initial value:
= {
{ "NORTH", 1 },
{ "NORTHEAST", 2 },
{ "EAST", 3 },
{ "SOUTHEAST", 4 },
{ "SOUTH", 5 },
{ "SOUTHWEST", 6 },
{ "WEST", 7 },
{ "NORTHWEST", 8 },
{ NULL, 0 }
}

Definition at line 1112 of file cfpython.cpp.

Referenced by main().

◆ cstEventType

const CFConstant cstEventType[]

Definition at line 1331 of file cfpython.cpp.

Referenced by main().

◆ cstMessageFlag

const CFConstant cstMessageFlag[]
Initial value:
= {
{ "NDI_BLACK", NDI_BLACK },
{ "NDI_WHITE", NDI_WHITE },
{ "NDI_NAVY", NDI_NAVY },
{ "NDI_RED", NDI_RED },
{ "NDI_ORANGE", NDI_ORANGE },
{ "NDI_BLUE", NDI_BLUE },
{ "NDI_DK_ORANGE", NDI_DK_ORANGE },
{ "NDI_GREEN", NDI_GREEN },
{ "NDI_LT_GREEN", NDI_LT_GREEN },
{ "NDI_GREY", NDI_GREY },
{ "NDI_BROWN", NDI_BROWN },
{ "NDI_GOLD", NDI_GOLD },
{ "NDI_TAN", NDI_TAN },
{ "NDI_UNIQUE", NDI_UNIQUE },
{ "NDI_ALL", NDI_ALL },
{ "NDI_ALL_DMS", NDI_ALL_DMS },
{ NULL, 0 }
}
#define NDI_ALL
Inform all players of this message.
Definition: newclient.h:271
#define NDI_WHITE
Definition: newclient.h:247
#define NDI_ORANGE
Definition: newclient.h:250
#define NDI_BROWN
Sienna.
Definition: newclient.h:258
#define NDI_BLUE
Actually, it is Dodger Blue.
Definition: newclient.h:251
#define NDI_BLACK
Definition: newclient.h:246
#define NDI_DK_ORANGE
DarkOrange2.
Definition: newclient.h:252
#define NDI_NAVY
Definition: newclient.h:248
#define NDI_RED
Definition: newclient.h:249
#define NDI_ALL_DMS
Inform all logged in DMs.
Definition: newclient.h:272
#define NDI_GREEN
SeaGreen.
Definition: newclient.h:253
#define NDI_LT_GREEN
DarkSeaGreen, which is actually paler than seagreen - also background color.
Definition: newclient.h:254
#define NDI_GREY
Definition: newclient.h:257
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:270
#define NDI_TAN
Khaki.
Definition: newclient.h:260
#define NDI_GOLD
Definition: newclient.h:259

Definition at line 1251 of file cfpython.cpp.

Referenced by main().

◆ cstMove

const CFConstant cstMove[]
Initial value:
= {
{ "WALK", MOVE_WALK },
{ "FLY_LOW", MOVE_FLY_LOW },
{ "FLY_HIGH", MOVE_FLY_HIGH },
{ "FLYING", MOVE_FLYING },
{ "SWIM", MOVE_SWIM },
{ "BOAT", MOVE_BOAT },
{ "ALL", MOVE_ALL },
{ NULL, 0 }
}
#define MOVE_WALK
Object walks.
Definition: define.h:398
#define MOVE_ALL
Mask of all movement types.
Definition: define.h:404
#define MOVE_SWIM
Swimming object.
Definition: define.h:402
#define MOVE_FLY_LOW
Low flying object.
Definition: define.h:399
#define MOVE_FLYING
Combo of fly_low and fly_high.
Definition: define.h:401
#define MOVE_FLY_HIGH
High flying object.
Definition: define.h:400
#define MOVE_BOAT
Boats/sailing.
Definition: define.h:403

Definition at line 1240 of file cfpython.cpp.

Referenced by main().

◆ cstReplyTypes

const CFConstant cstReplyTypes[]
Initial value:
= {
{ "SAY", rt_say },
{ "REPLY", rt_reply },
{ "QUESTION", rt_question },
{ NULL, 0 }
}
Asking a question.
Definition: dialog.h:10
Reply to something.
Definition: dialog.h:9
Basic sentence.
Definition: dialog.h:8

Definition at line 1385 of file cfpython.cpp.

Referenced by main().

◆ cstTime

const CFConstant cstTime[]
Initial value:
= {
{ "HOURS_PER_DAY", HOURS_PER_DAY },
{ "DAYS_PER_WEEK", DAYS_PER_WEEK },
{ "WEEKS_PER_MONTH", WEEKS_PER_MONTH },
{ "MONTHS_PER_YEAR", MONTHS_PER_YEAR },
{ "SEASONS_PER_YEAR", SEASONS_PER_YEAR },
{ "PERIODS_PER_DAY", PERIODS_PER_DAY },
{ NULL, 0 }
}
#define DAYS_PER_WEEK
Definition: tod.h:16
#define PERIODS_PER_DAY
Definition: tod.h:20
#define HOURS_PER_DAY
Definition: tod.h:15
#define WEEKS_PER_MONTH
Definition: tod.h:17
#define MONTHS_PER_YEAR
Definition: tod.h:18
#define SEASONS_PER_YEAR
Definition: tod.h:19

Definition at line 1375 of file cfpython.cpp.

Referenced by main().

◆ cstType

const CFConstant cstType[]

Definition at line 1124 of file cfpython.cpp.

Referenced by main().

◆ current_context

CFPContext* current_context

◆ GECodes

int GECodes[]
static
Initial value:
= {
0
}
#define EVENT_REMOVE
A Player character has been removed.
Definition: events.h:67
#define EVENT_LOGOUT
Player logout.
Definition: events.h:58
#define EVENT_MAPUNLOAD
A map is freed (includes swapping out)
Definition: events.h:64
#define EVENT_LOGIN
Player login.
Definition: events.h:57
#define EVENT_KICK
A player was Kicked by a DM.
Definition: events.h:56
#define EVENT_MAPRESET
A map is resetting.
Definition: events.h:63
#define EVENT_BORN
A new character has been created.
Definition: events.h:52
#define EVENT_GKILL
Triggered when anything got killed by anyone.
Definition: events.h:55
#define EVENT_CLOCK
Global time event.
Definition: events.h:53
#define EVENT_MAPREADY
A map is ready, either first load or after reload.
Definition: events.h:62
#define EVENT_TELL
A player &#39;tell&#39; something.
Definition: events.h:69
#define EVENT_MAPLEAVE
A player left a map.
Definition: events.h:60
#define EVENT_PLAYER_DEATH
Global Death event.
Definition: events.h:66
#define EVENT_GSOLD
Player sold object in shop, but global.
Definition: events.h:71
#define EVENT_MAPENTER
A player entered a map.
Definition: events.h:59
#define EVENT_MAPLOAD
A map is loaded (pristine state)
Definition: events.h:61
#define EVENT_MUZZLE
A player was Muzzled (no_shout set).
Definition: events.h:65
#define EVENT_SHOUT
A player &#39;shout&#39; something.
Definition: events.h:68
#define EVENT_GBOUGHT
Player bought object in shop, but global.
Definition: events.h:70

Definition at line 1564 of file cfpython.cpp.

Referenced by getGlobalEventPath(), and postInitPlugin().

◆ GEPaths

const char* GEPaths[]
static
Initial value:
= {
"born",
"clock",
"death",
"gkill",
"login",
"logout",
"mapenter",
"mapleave",
"mapreset",
"remove",
"shout",
"tell",
"muzzle",
"kick",
"mapunload",
"mapload",
"mapready",
"gbought",
"gsold",
NULL
}

Definition at line 1587 of file cfpython.cpp.

Referenced by getGlobalEventPath().

◆ private_data

PyObject* private_data = NULL
static

Definition at line 110 of file cfpython.cpp.

Referenced by getPrivateDictionary(), and initPlugin().

◆ pycode_cache

pycode_cache_entry pycode_cache[PYTHON_CACHE_SIZE]
static

Cached compiled scripts.

Definition at line 88 of file cfpython.cpp.

◆ registered_commands

command_registration registered_commands[MAX_COMMANDS]
static

Definition at line 85 of file cfpython.cpp.

Referenced by closePlugin(), initPlugin(), and registerCommand().

◆ shared_data

PyObject* shared_data = NULL
static

Definition at line 108 of file cfpython.cpp.

Referenced by getSharedDictionary(), and initPlugin().

◆ SvnRevPlugin

CF_PLUGIN char SvnRevPlugin[] = SVN_REV

Definition at line 69 of file cfpython.cpp.