OnPlayerTileAction
The script attached to this event fires when surfacemat.2da actions are used. It must be set using SetEventScript (for instance in OnModuleLoad).
Trigger
When EnterTargetingMode is used and the player either selects a target or manually exits targeting mode.
Function(s)
- GetLastTileActionId - Gets the ID (1..8) of the last tile action performed in OnPlayerTileAction
- GetLastTileActionPosition - Gets the target position in the module OnPlayerTileAction event.
- GetLastPlayerToDoTileAction - Gets the player object that triggered the OnPlayerTileAction event.
Setup
Note: A script for the OnPlayerTileAction event cannot be specified in module properties. There is no default script for this event, so no action will be taken unless a script is assigned to this event. To assign a script to this event, use this code:
SetEventScript(GetModule(), EVENT_SCRIPT_MODULE_ON_PLAYER_TILE_ACTION, "script_name").
Remarks
This allows actions to be selected under the radial when right clicking a location on the ground if a suitable action is found under the surfacemat.2da file. The actions appear under "More actions" and cannot be added to the quickbar, but up to 8 can be defined with different names and icons using new columns.
Once the action is selected the script is run (if set) and you can get the ID of the action, the player that triggered it (which you can also find out the area from) and the position chosen.
You could use this for various things:
- Teleporting and jumping around
- Assigning location based commands for AI companions ("go here")
- Bring up skill based actions such as "investigate", "search", "nature" etc.
- Allow the ground itself to be examined
Known Bugs
Version
This event was added in 1.84.8193.29 of NWN:EE.
Example
// Simple example to use OnPlayerTileAction to fire a VFX at the given location
void main()
{
// Define variables
int nAction = GetLastTileActionId();
vector vPosition = GetLastTileActionPosition();
object oPlayer = GetLastPlayerToDoTileAction();
location lTarget = Location(GetArea(oPlayer), vPosition, 0.0);
// We play a VFX at the target location depending on the action ID
int nVFX;
switch(nAction)
{
case 1: nVFX = VFX_FNF_GAS_EXPLOSION_ACID; break;
case 2: nVFX = VFX_FNF_HOWL_MIND; break;
case 3: nVFX = VFX_FNF_PWKILL; break;
case 4: nVFX = VFX_FNF_MYSTICAL_EXPLOSION; break;
case 5: nVFX = VFX_FNF_LOS_HOLY_30; break;
case 6: nVFX = VFX_FNF_SUMMON_GATE; break;
case 7: nVFX = VFX_FNF_WEIRD; break;
case 8: nVFX = VFX_FNF_TIME_STOP; break;
}
// Apply VFX
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(nVFX), lTarget);
}
See Also
| functions: |
GetLastTileActionId GetLastTileActionPosition GetLastPlayerToDoTileAction |