Python Actions - GrognardsFromHell/TemplePlus GitHub Wiki
#Introduction
Temple+ enables creating new action definitions.
This allows extending the Action Sequence system of ToEE. Please review this topic as the basic concepts and inner workings of Actions are explained there.
In addition, many of the internals are exposed via the new built-in Python module tpactions.
Files
To create a new action definition, create a file entry in
rules\d20_actions\
The filename must be of the form
actionNNNN_*.py
Where NNNN is the action ID.
For example: action02100_assn_study_target.py
Action IDs
Action IDs are actually sub-IDs of a new action type, D20A_PYTHON_ACTION. They'll be used to look up the relevant file/entry from the d20_actions folder above.
When creating Python Modifier callbacks that handle Actions, you need to use the action ID as the Event Key. For example:
deathAttackStudyEnum = 2100
death_attack_feat.AddHook(ET_OnD20PythonActionPerform, deathAttackStudyEnum, OnStudyTargetPerform, ())
Much like Class enums, action IDs have to be coordinated in advance. If you wish to create a new action for your mod, please inquire as to which range is available for use and we'll reserve it for you.
Class-specific Action IDs
The convention for class-specific actions is to base them on the class enum, allowing for up to 100 actions per class.
For example: The Assassin class enum is 21, hence all of its action IDs shall be in the range of 2100-2199.
Psi Actions
The range of 200-299 is reserved for generic Psi actions (such as Psionic Focus).
Python Action Specification & API
The engine creates an internal entry for each action file, using several API functions to get properties and others for execution.
Example file:
from toee import *
import tpactions
def GetActionName():
return "Study Target"
def GetActionDefinitionFlags():
return D20ADF_TargetSingleExcSelf | D20ADF_UseCursorForPicking | D20ADF_MagicEffectTargeting | D20ADF_Breaks_Concentration
def GetTargetingClassification():
return D20TC_CastSpell
def GetActionCostType():
return D20ACT_NULL
def AddToSequence(d20action, action_seq, tb_status):
action_seq.add_action(d20action)
return AEC_OK
Action Name
Returned via the GetActionName()
function. Will be used for radial menu entries unless a string is directly specified.
Action Definition Flags
Returned via the GetActionDefinitionFlags()
function. Fairly straightforward.
Targeting Classification
Returned via the GetTargetingClassification()
function.
Available targeting classifications are:
D20TC_Target0 - no targeting
D20TC_Movement - movement related targeting
D20TC_SingleExcSelf
D20TC_CastSpell - use rules\spell\ entry for targeting rules. Should be used in conjunction with a spell definition. This is currently the only way for using the AoE / Multiple targets as spells do.
D20TC_SingleIncSelf
D20TC_CallLightning
D20TC_ItemInteraction - includes: portals, container, dead critters
Action Cost
Returned via the GetActionCostType()
function.
This defines the action cost type. Available options are:
D20ACT_NULL
D20ACT_Move_Action
D20ACT_Standard_Action
D20ACT_Partial_Charge
D20ACT_Full_Round_Action
Adding actions to Sequence
The function AddToSequence
is called in the Add to Sequence stage. For most actions it's a simple matter of appending the action to the sequence, as in the above example, but it's possible to do more complex things, such as prepending a Move action, manipulating other actions in the sequence, and so on.
Action Checks
Currently performed via a Dispatch event of type ET_OnD20PythonActionCheck
, with event key equal to the action ID.
This means that the action performer needs a suitable Python Modifier with a callback to handle this event.
See:
Python Modifiers
D20Action Event Object
Action Perform callbacks
Currently performed via a Dispatch event of type ET_OnD20PythonActionPerform
, with event key equal to the action ID.
See above.
Render callback
Todo