Atrinik Server 2.5
Functions
Python functions

Functions

static PyObject * Atrinik_LoadObject (PyObject *self, PyObject *args)
static PyObject * Atrinik_ReadyMap (PyObject *self, PyObject *args)
static PyObject * Atrinik_FindPlayer (PyObject *self, PyObject *args)
static PyObject * Atrinik_PlayerExists (PyObject *self, PyObject *args)
static PyObject * Atrinik_WhoAmI (PyObject *self, PyObject *args)
static PyObject * Atrinik_WhoIsActivator (PyObject *self, PyObject *args)
static PyObject * Atrinik_WhoIsOther (PyObject *self, PyObject *args)
static PyObject * Atrinik_WhatIsEvent (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetEventNumber (PyObject *self, PyObject *args)
static PyObject * Atrinik_WhatIsMessage (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetOptions (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetReturnValue (PyObject *self, PyObject *args)
static PyObject * Atrinik_SetReturnValue (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetEventParameters (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetSpellNr (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetSpell (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetSkillNr (PyObject *self, PyObject *args)
static PyObject * Atrinik_RegisterCommand (PyObject *self, PyObject *args)
static PyObject * Atrinik_CreatePathname (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetTime (PyObject *self, PyObject *args)
static PyObject * Atrinik_LocateBeacon (PyObject *self, PyObject *args)
static PyObject * Atrinik_FindParty (PyObject *self, PyObject *args)
static PyObject * Atrinik_CleanupChatString (PyObject *self, PyObject *args)
static PyObject * Atrinik_LOG (PyObject *self, PyObject *args)
static PyObject * Atrinik_DestroyTimer (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetRangeVectorFromMapCoords (PyObject *self, PyObject *args)
static PyObject * Atrinik_CostString (PyObject *self, PyObject *args)
static PyObject * Atrinik_CacheAdd (PyObject *self, PyObject *args)
static PyObject * Atrinik_CacheGet (PyObject *self, PyObject *args)
static PyObject * Atrinik_CacheRemove (PyObject *self, PyObject *args)
static PyObject * Atrinik_GetFirst (PyObject *self, PyObject *args)
static PyObject * Atrinik_CreateMap (PyObject *self, PyObject *args)
static PyObject * Atrinik_CreateObject (PyObject *self, PyObject *args)

Function Documentation

static PyObject* Atrinik_CacheAdd ( PyObject *  self,
PyObject *  args 
) [static]

CacheAdd(string key, object what)

Store 'what' in memory identified by unique identifier 'key'.

The object will be stored forever in memory, until it's either removed by CacheRemove() or the server is shut down; in both cases, the object will be closed, if applicable (databases, file objects, etc).

A stored object can be retrieved at any time using CacheGet().

Parameters:
keyThe unique identifier for the cache entry.
whatAny Python object (string, integer, database, etc) to store in memory.
Returns:
True if the object was cached successfully, False otherwise (cache entry with same key name already exists).

Definition at line 1176 of file plugin_python.c.

static PyObject* Atrinik_CacheGet ( PyObject *  self,
PyObject *  args 
) [static]

CacheGet(string key)

Attempt to find a cache entry identified by 'key' that was previously added using CacheAdd().

Parameters:
keyUnique identifier of the cache entry to find.
Exceptions:
ValueErrorif the cache entry could not be found.
Returns:
The cache entry. An exception is raised if the cache entry was not found.

Definition at line 1208 of file plugin_python.c.

static PyObject* Atrinik_CacheRemove ( PyObject *  self,
PyObject *  args 
) [static]

CacheRemove(string key)

Remove a cache entry that was added with a previous call to CacheAdd().

Parameters:
keyUnique identifier of the cache entry to remove.
Exceptions:
ValueErrorif the cache entry could not be removed (it didn't exist).
Returns:
True if the cache entry was removed. An exception is raised if the cache entry was not found.

Definition at line 1246 of file plugin_python.c.

static PyObject* Atrinik_CleanupChatString ( PyObject *  self,
PyObject *  args 
) [static]

CleanupChatString(string text)

Cleans up a chat text removing special characters and extra whitespace.

Parameters:
textThe text to cleanup.
Returns:
Cleaned up text; can be None.

Definition at line 1031 of file plugin_python.c.

static PyObject* Atrinik_CostString ( PyObject *  self,
PyObject *  args 
) [static]

CostString(int value)

Build a string representation of the value in the game's money syntax, for example, a value of 134 would become "1 silver coin and 34 copper coins".

Parameters:
valueValue to build the string from.
Returns:
The built string.

Definition at line 1148 of file plugin_python.c.

static PyObject* Atrinik_CreateMap ( PyObject *  self,
PyObject *  args 
) [static]

CreateMap(int width, int height, string path)

Creates an empty map.

Parameters:
widthThe new map's width.
heightThe new map's height.
pathPath to the new map. This should be a unique path to avoid collisions. "/python-maps/" is prepended to this to ensure no collision with regular maps.
Returns:
The new empty map.

Definition at line 1327 of file plugin_python.c.

static PyObject* Atrinik_CreateObject ( PyObject *  self,
PyObject *  args 
) [static]

CreateObject(string archname)

Creates a new object. If the created object is not put on map or inside an inventory of another object, it will be removed by the garbage collector.

Parameters:
archnameName of the arch to create.
Exceptions:
AtrinikErrorif 'archname' is not a valid archetype.
Returns:
The newly created object. *

Definition at line 1356 of file plugin_python.c.

static PyObject* Atrinik_CreatePathname ( PyObject *  self,
PyObject *  args 
) [static]

CreatePathname(string path)

Creates path to file in the maps directory using the create_pathname() function.

Parameters:
pathPath to file to create.
Returns:
The path to file in the maps directory.

Definition at line 925 of file plugin_python.c.

static PyObject* Atrinik_DestroyTimer ( PyObject *  self,
PyObject *  args 
) [static]

DestroyTimer(int timer)

Destroy an existing timer.

Parameters:
timerID of the timer.
Returns:
True on success, False on failure.

Definition at line 1083 of file plugin_python.c.

static PyObject* Atrinik_FindParty ( PyObject *  self,
PyObject *  args 
) [static]

FindParty(string name)

Find a party by name.

Parameters:
nameThe party name to find.
Returns:
The party if found, None otherwise.

Definition at line 1012 of file plugin_python.c.

static PyObject* Atrinik_FindPlayer ( PyObject *  self,
PyObject *  args 
) [static]

FindPlayer(string name)

Find a player by name.

Parameters:
nameThe player name to find.
Returns:
The player's object if found, None otherwise.

Definition at line 608 of file plugin_python.c.

static PyObject* Atrinik_GetEventNumber ( PyObject *  self,
PyObject *  args 
) [static]

GetEventNumber()

Get the ID of the event that is being triggered.

Returns:
Event ID.

Definition at line 707 of file plugin_python.c.

static PyObject* Atrinik_GetEventParameters ( PyObject *  self,
PyObject *  args 
) [static]

GetEventParameters()

Get the parameters of an event. This varies from event to event, and some events pass all parameters as 0. EVENT_ATTACK usually passes damage done and the WC of the hit as second and third parameter, respectively.

Returns:
A list of the event parameters. The last entry is the event flags, used to determine whom to call fix_player() on after executing the script.

Definition at line 775 of file plugin_python.c.

static PyObject* Atrinik_GetFirst ( PyObject *  self,
PyObject *  args 
) [static]

GetFirst(string what)

Get first member of various linked lists.

Parameters:
whatWhat list to get first member of. Available list names:
  • player: First player.
  • map: First map.
  • archetype: First archetype.
  • party: First party.
  • region: First region.
Returns:
First member of the specified linked list.

Definition at line 1282 of file plugin_python.c.

static PyObject* Atrinik_GetOptions ( PyObject *  self,
PyObject *  args 
) [static]

GetOptions()

Gets the script options (as passed in the event's slaying field).

Returns:
The script options.

Definition at line 729 of file plugin_python.c.

static PyObject* Atrinik_GetRangeVectorFromMapCoords ( PyObject *  self,
PyObject *  args 
) [static]

GetRangeVectorFromMapCoords(map map, int x, int y, map map2, int x2, int y2, int [flags = 0])

Get the distance and direction from one map coordinate to another.

Parameters:
mapFrom which map to get distance from.
xX on 'map'.
yY on 'map'.
map2Which map to get distance to.
x2X on 'map2'.
y2Y on 'map2'.
flagsOne or a combination of Range Vector Flags.
Returns:
None if the distance couldn't be calculated, otherwise a tuple containing:
  • Direction from the first coordinate to the second, one of Direction constants.
  • Distance between the two coordinates.
  • X distance.
  • Y distance.

Definition at line 1113 of file plugin_python.c.

static PyObject* Atrinik_GetReturnValue ( PyObject *  self,
PyObject *  args 
) [static]

GetReturnValue()

Gets the script's return value.

Returns:
The return value.

Definition at line 740 of file plugin_python.c.

static PyObject* Atrinik_GetSkillNr ( PyObject *  self,
PyObject *  args 
) [static]

GetSkillNr(string name)

Get the ID of the skill.

Parameters:
nameThe skill name.
Returns:
ID of the skill, -1 if no such skill exists.

Definition at line 857 of file plugin_python.c.

static PyObject* Atrinik_GetSpell ( PyObject *  self,
PyObject *  args 
) [static]

GetSpell(int spell)

Get various information about a spell, including things like its level, type, etc.

Parameters:
spellID of the spell, can be acquired using GetSpellNr().
Exceptions:
ValueErrorif the spell ID being looked up is invalid.
Returns:
Dictionary containing information about the spell, with the following entries:
  • name: Name of the spell.
  • level: Level required to cast the spell.
  • type: 'wizard' if the spell is a wizard spell, 'priest' otherwise.
  • sp: Base mana/grace required to cast the spell; modified by various factors.
  • time: Delay in ticks needed to cast another spell.

Definition at line 823 of file plugin_python.c.

static PyObject* Atrinik_GetSpellNr ( PyObject *  self,
PyObject *  args 
) [static]

GetSpellNr(string name)

Get the ID of the passed spell name.

Parameters:
nameThe spell name.
Returns:
ID of the spell, -1 if no such spell exists.

Definition at line 796 of file plugin_python.c.

static PyObject* Atrinik_GetTime ( PyObject *  self,
PyObject *  args 
) [static]

GetTime()

Get the game time.

Returns:
A dictionary containing all the information about the in-game time:
  • year: Current year.
  • month: Current month.
  • month_name: Name of the current month.
  • day: Day.
  • hour: Hour.
  • minute: Minute.
  • dayofweek: Day of the week.
  • dayofweek_name: Name of the week day.
  • season: Season.
  • season_name: Name of the season.
  • periodofday: Period of the day.
  • periodofday_name: Name of the period of the day.

Definition at line 956 of file plugin_python.c.

static PyObject* Atrinik_LoadObject ( PyObject *  self,
PyObject *  args 
) [static]

LoadObject(string dump)

Load an object from a string dump, for example, one stored using Save().

Parameters:
dumpThe string dump from which to load the actual object.

Definition at line 562 of file plugin_python.c.

static PyObject* Atrinik_LocateBeacon ( PyObject *  self,
PyObject *  args 
) [static]

LocateBeacon(string name)

Locate a beacon.

Parameters:
nameThe beacon name to find.
Returns:
The beacon if found, None otherwise.

Definition at line 987 of file plugin_python.c.

static PyObject* Atrinik_LOG ( PyObject *  self,
PyObject *  args 
) [static]

LOG(int mode, string message)

Logs a message.

Parameters:
modeLogging mode to use, one of:
  • llevError: An irrecoverable error. Will shut down the server.
  • llevBug: A bug; too many in the same tick will shut down the server.
  • llevInfo: Info.
  • llevDebug: Debug information.
messageThe message to log.

Definition at line 1060 of file plugin_python.c.

static PyObject* Atrinik_PlayerExists ( PyObject *  self,
PyObject *  args 
) [static]

PlayerExists(string name)

Check if player exists.

Parameters:
nameThe player name to check.
Returns:
True if the player exists, False otherwise

Definition at line 636 of file plugin_python.c.

static PyObject* Atrinik_ReadyMap ( PyObject *  self,
PyObject *  args 
) [static]

ReadyMap(string path, int [unique = False])

Make sure the named map is loaded into memory, loading it if necessary.

Parameters:
pathPath to the map.
uniqueWhether the destination should be loaded as unique map, for example, apartments.
Returns:
The loaded map.

Definition at line 583 of file plugin_python.c.

static PyObject* Atrinik_RegisterCommand ( PyObject *  self,
PyObject *  args 
) [static]

RegisterCommand(string name, string path, float speed)

Register a custom command ran using Python script.

Parameters:
nameName of the command. For example, "roll" in order to create /roll command. Note the lack forward slash in the name.
pathPath to the Python script to be executed when the command is used.
speedHow long it takes to execute the command; 1.0 is usually fine.
Exceptions:
ValueErrorif the command is already registered.

Definition at line 879 of file plugin_python.c.

static PyObject* Atrinik_SetReturnValue ( PyObject *  self,
PyObject *  args 
) [static]

SetReturnValue(int value)

Sets the script's return value.

Parameters:
valueThe new return value.

Definition at line 751 of file plugin_python.c.

static PyObject* Atrinik_WhatIsEvent ( PyObject *  self,
PyObject *  args 
) [static]

WhatIsEvent()

Get the event object that caused this event to trigger.

Returns:
The event object.

Definition at line 696 of file plugin_python.c.

static PyObject* Atrinik_WhatIsMessage ( PyObject *  self,
PyObject *  args 
) [static]

WhatIsMessage()

Gets the actual message in SAY events.

Returns:
The message.

Definition at line 718 of file plugin_python.c.

static PyObject* Atrinik_WhoAmI ( PyObject *  self,
PyObject *  args 
) [static]

WhoAmI()

Get the owner of the active script (the object that has the event handler).

Returns:
The script owner.

Definition at line 662 of file plugin_python.c.

static PyObject* Atrinik_WhoIsActivator ( PyObject *  self,
PyObject *  args 
) [static]

WhoIsActivator()

Get the object that activated the current event.

Returns:
The script activator.

Definition at line 673 of file plugin_python.c.

static PyObject* Atrinik_WhoIsOther ( PyObject *  self,
PyObject *  args 
) [static]

WhoIsOther()

Get another object related to the event. What this object is depends on the event.

Returns:
The other object.

Definition at line 685 of file plugin_python.c.