Event

From Dragon Age Toolset Wiki
Revision as of 17:33, 20 July 2009 by BryanDerksen (Talk | contribs) (more splitting)

Jump to: navigation, search

Events are a package of information that can be passed around in the game to trigger some behaviour. They are usually passed off to an object's event script for handling, but there are a few engine-only event types that are not exposed to the end-users.

Scripting Events have an integer type, target object, a time delay and a package of parameters (arbitrary number of ints, objects, floats and strings). Certain event types will be defined by the engine and referenced as #defines in the scripts.

Events are handled in the scripting language with the following types of commands:

  • Event() Constructor — Scripters can create events of any type and signal them to other objects
  • Signal Event commands — Events can be signalled to a single object, by proximity or to all objects with a certain group id
  • Parameter access — All of the parameters on an event can be get and set through scripting.
  • Event handling — Events can be passed to other script files through the HandleEvent command. This command will be run inline so that hierarchies of event-handling behaviour can be built.

A typical event-handling script would have the form

void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev); //extract event type from current event
    int nEventHandled = FALSE; //keep track of whether the event has been handled
    switch(nEventType)
    {
         case EVENT_TYPE_AREALOAD_SPECIAL:
         {
             ...
             nEventHandled = TRUE; //set this if no further action is required for this event
             break;
         }
    }
    if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
    {
        HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
    }
}

In the event that you want to intercept some events but leave others to be handled by a default script (for example if you're overriding one aspect of a creature's event response but the rest of the default creature_core responses responses are fine) you can pass execution to the default script with the following:

    HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);

(constants for referencing core script resources are available in the "global_objects_h" include file)

Below is a list of the event types that are defined within the core resources:

Plots

EVENT_TYPE_SET_PLOT

  • Sent When: A plot is setting a plot flag
  • Sent From: engine
  • Sent To: plot script

Parameters:

  • Creator: owner of the plot table, should be a player
  • String 0: plot GUID, defined as string constant
  • Int 1: bit flag number being affected
  • Int 2: the value about to be written (on a normal SET that should be '1', and on a 'clear' it should be '0')
  • Int 3: On SET call, the current flag value (can be either 1 or 0 regardless if it's a set or clear event)
  • Int 4: 1 if the current flag (Int 1) is defined, 0 for normal flag.

IMPORTANT: The flag value on a SET event is set only AFTER this script finishes running!

EVENT_TYPE_GET_PLOT

  • Sent When: A plot is setting a plot flag
  • Sent From: engine
  • Sent To: plot script

Parameters:

  • Creator: owner of the plot table, should be a player
  • String 0: plot GUID, defined as string constants
  • Int 1: bit flag number being affected
  • Int 4: 1 if the current flag (Int 1) is defined, 0 for normal flag.


Dialogue

EVENT_TYPE_DIALOGUE

  • Sent When: An object tries to initiate dialog with the object receiving the event, either by clicking or by scripting
  • Sent From: engine (clicking on object to talk) or scripts (manually sending this event)
  • Sent To: creatures, placeables

Parameters:

  • Creator: Initiating object
  • String 0: Dialog to initiate, "" to use default object dialog

EVENT_TYPE_DELAYED_SHOUT

  • Sent When: Used to fire a dialog shout every few seconds.
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_AMBIENT_CONTINUE

  • Sent When: conversation ends or player is nearby to resume ambient behaviour
  • Sent From: engine
  • Sent To: creature

If the event was fired because the party is near a creature, the 'instigator' is the nearest party member. If the event was fired at the end of a conversation, the 'instigator' is the creature conversing.

Parameters:

  • Object 0: Instigator

Party management

EVENT_TYPE_PARTYMEMBER_ADDED

  • Sent When: Party member added to active party using the party GUI
  • Sent From:
  • Sent To: module

Parameters:

EVENT_TYPE_PARTYMEMBER_DROPPED

  • Sent When: Party member removed from active party using the party GUI
  • Sent From:
  • Sent To: module

Parameters:

EVENT_TYPE_PARTYPICKER_CLOSED

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:

EVENT_TYPE_PARTY_MEMBER_HIRED

  • Sent When: Fires first time a party member is added to the party. For plot followers: follower recruited (added to pool). For other followers: UT_Hire called
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_PARTY_MEMBER_FIRED

  • Sent When: Fires when an active or locked-active party member is removed from the active party
  • Sent From:
  • Sent To:

Parameters:


EVENT_TYPE_PARTY_MEMBER_RES_TIMER

Resurrection timer used if a creature dies in explore mode.

party members are rezzed on this event if it happens outside of combat.

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_GIFT_ITEM

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_MODULE_HANDLE_FOLLOWER_DEATH

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_MODULE_HANDLE_GIFT

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

  • Follower: Object 0
  • GiftTag: String 0

EVENT_TYPE_SUMMON_DIED

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:


Character generation and level advancement

EVENT_TYPE_CHARGEN_START and EVENT_TYPE_CHARGEN_END

A range of event constants (nEvent >= EVENT_TYPE_CHARGEN_START && nEvent <= EVENT_TYPE_CHARGEN_END) that occur during character generation.

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:

EVENT_TYPE_PLAYER_LEVELUP

  • Sent When: Creature is spawned.
  • Sent From: Fired by sys_rewards_h.RewardXP (the levelup system)
  • Sent To: player_core

Parameters:

EVENT_TYPE_PLAYERLEVELUP

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:

EVENT_TYPE_CHARGEN_AUTOLEVEL

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_MODULE_CHARGEN_DONE

Fired the the core chargen script into the module

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_GUI_OPENED

GUI tutorial calls

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:

World map

EVENT_TYPE_TRANSITION_TO_WORLD_MAP

  • Sent When: Player uses the generic transition system to open the world map
  • Sent From:
  • Sent To: module

Parameters:

  • string sWorldMap = GetEventString(ev, 0);
  • string sTransType = GetEventString(ev, 1);
  • string sWorldMapLoc1 = GetEventString(ev, 2);
  • string sWorldMapLoc2 = GetEventString(ev, 3);
  • string sWorldMapLoc3 = GetEventString(ev, 4);
  • string sWorldMapLoc4 = GetEventString(ev, 5);
  • string sWorldMapLoc5 = GetEventString(ev, 6);


EVENT_TYPE_WORLD_MAP_CLOSED

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:

  • Integer 0: close type, 0 for cancel, 1 for travel.

EVENT_TYPE_WORLD_MAP_USED

!!Note: This event may be obsolete, I think EVENT_TYPE_BEGIN_TRAVEL is the one that actually fires now.!!

  • Sent When: the player clicks on a destination in the world map
  • Sent From: engine
  • Sent To: module

Parameters:

  • int nFrom = GetEventInteger(ev, 0); // travel start location
  • int nTo = GetEventInteger(ev, 1); // travel target location

EVENT_TYPE_BEGIN_TRAVEL

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:

  • string sSource = GetEventString(ev, 0); // area tag source location
  • string sTarget = GetEventString(ev, 1); // area tag target location
  • string sWPOverride = GetEventString(ev, 2); // waypoint tag override
  • int nSourceTerrain = GetEventInteger(ev, 0);
  • int nTargetTerrain = GetEventInteger(ev, 1);
  • int nWorldMap = GetEventInteger(ev, 2);
  • object oSourceLocation = GetEventObject(ev, 0); // source location object

EVENT_TYPE_WORLDMAP_PRETRANSITION

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:

EVENT_TYPE_WORLDMAP_POSTTRANSITION

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:

EVENT_TYPE_FINISH_TRAVEL

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:


Found in placeable_core

EVENT_TYPE_PLACEABLE_ONCLICK

  • Sent When: player clicks on object.
  • Sent From: engine
  • Sent To: placeable

Parameters:

EVENT_TYPE_USE

  • Sent When: creature clicks on the placeable.
  • Sent From: engine
  • Sent To: placeable

Parameters:


EVENT_TYPE_UNLOCKED

  • Sent When: Sent by script when placeable is unlocked.
  • Sent From:
  • Sent To: placeable

Parameters:

EVENT_TYPE_SET_OBJECT_ACTIVE

  • Sent When: Sent by script to change active state. Needed since CommandDoFunction was removed and we're using CommandDoEvent
  • Sent From:
  • Sent To:

Parameters:


EVENT_TYPE_PLACEABLE_COLLISION

  • Sent When: player collides with object (if EnableCollisionEvent column in placeables.xls is non-zero).
  • Sent From: engine
  • Sent To:

Parameters:

EVENT_TYPE_POPUP_RESULT

  • Sent When: player responds to area transition prompt.
  • Sent From:
  • Sent To: module

Parameters:

  • object oOwner = GetEventObject(ev, 0); // owner of popup
  • int nPopupID = GetEventInteger(ev, 0); // popup ID
  • int nButton = GetEventInteger(ev, 1); // button result (1 - 4)
  • string sInput = GetEventString(ev,0); // string entered into optional text field

Calling the "ShowPopup" script function causes a popup window to be displayed to the user, with up to four buttons whose text is defined in the "popups" 2DA and up to one text input field (with a filter on the input the player can type there that's the same as the filter on player names - up to 20 characters, no spaces, limited punctuation, no empty strings). This event is generated and sent to the module script with the popup's result.

Found in rules_core

EVENT_TYPE_ITEM_ONHIT

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_CONFUSION_CALLBACK

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:



EVENT_TYPE_DESTROY_OBJECT

  • Sent When: Object should be destroyed
  • Sent From:
  • Sent To:

Parameters:

Found in player_core

EVENT_TYPE_HEARTBEAT

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:


EVENT_TYPE_LOAD_TACTICS_PRESET

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:




Spellcasting

EVENT_TYPE_ABILITY_CAST_START

- Update mana/stamina - Calculate *combat* attack/miss (only for hit based talents like Deadly Strike) - Calculate resistance check/failure for non-AOE abilities (if valid) - Calculate *combat* damage (only for hit based talents like Deadly Strike) Most of the above information is then passed on to the engine who need to decide what animations to play (or not to play). The engine then returns most of this information along with the CAST_IMPACT event back to this script (see below)

  • Sent When: whenever any ability (spell, talent) is used
  • Sent From: engine
  • Sent To:

Parameters:

  • Object 1 - the item used to cast the ability (optional)
  • Object 2 - the object that the ability was targeted

note: in case of a projectile impact, there might be more than one target (object 2+...) this allows doing things like lightning bolts going through targets, but this is not currently made use of in Dragon Age.

EVENT_TYPE_ABILITY_CAST_IMPACT

  • Sent When: Fires for the moment of impact for every ability. This is where damage should be applied, fireballs explode, enemies get poisoned etc. We assume that stamina/mana have been deducted when the ability was triggered (COMMAND_PENDING stage)
  • Sent From: engine
  • Sent To:

Parameters:

  • Object 1 - the item used to cast the ability (optional)
  • Object 2 - the object that the ability was targeted

note: in case of a projectile impact, there might be more than one target (object 2+...) this allows doing things like lightning bolts going through targets, but this is not currently made use of in Dragon Age.

EVENT_TYPE_CAST_AT

  • Sent When: placeable is hit by a spell.
  • Sent From: engine
  • Sent To: placeable

Parameters:

EVENT_TYPE_COMBO_IGNITE

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:


EVENT_TYPE_SPELLCASTAT

  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_SPELLSCRIPT_CAST

  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_SPELLSCRIPT_DEACTIVATE

  • Sent When: Talent deactivated
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_SPELLSCRIPT_IMPACT

  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_SPELLSCRIPT_PENDING

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:


Proving events

EVENT_TYPE_PROVING_ENTER

  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_PROVING_EXIT

  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_PROVING_LOSE

  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_PROVING_START

  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_PROVING_WIN

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:



Debugging

EVENT_TYPE_DEBUG_KICKSTART_AI

  • Sent When: Kickstart the AI if it was frozen out. Debug Event, do not use in production scripts
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_DEATH_RES_PARTY

Party Resurrection button (cheat, death UI)

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:


EVENT_TYPE_DEBUG_RESURRECTION

This makes the resurrection button work.

  • Sent When:
  • Sent From:
  • Sent To: module

Parameters:


Stats

EVENT_TYPE_STAT_REGEN

  • Sent When: Stat regeneration. might be changed in the future.
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_MANA_STAM_DEPLETED

  • Sent When: Creature ran out of mana or stamina
  • Sent From:
  • Sent To:

Parameters:


Miscellaney

EVENT_TYPE_CLICK

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_CUSTOM_COMMAND_COMPLETE

Also EVENT_TYPE_CUSTOM_EVENT_01 to EVENT_TYPE_CUSTOM_EVENT_08

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_FAILTOOPEN

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_HANDLE_CUSTOM_AI

Handle any custom AI before handling the built-in AI.

This event is sent to creature scripts after custom AI has been enabled (call CAI_SetCustomAI(OBJECT_SELF, CAI_INITIATE) in the EVENT_TYPE_SPAWN event).

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_INVALID

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_LISTENER


  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_LOCKED

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_QA_EVENT

  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_QA_EVENT_BLA

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_STEALING_FAILURE

  • Sent When:
  • Sent From:
  • Sent To:

Parameters: EVENT_TYPE_STEALING_SUCCESS

  • Sent When:
  • Sent From:
  • Sent To:

Parameters:

EVENT_TYPE_UNIQUE_POWER

  • Sent When: a unique power for an item is used
  • Sent From:
  • Sent To:

Parameters:

  • Ability = Integer 0
  • Item = Object 0
  • Caster = Object 1
  • Target = Object 2


Shouts

Shouts (events) are used to make creatures communicate with one another. This is a list of all the shouts referenced in the AI documentation.

Creature Shouts

  • SHOUT_TYPE_WASATTACKED When I am attacked, signal this event for all allies. What do the allies do? They will go into combat round, not specifically targeting this attacker but becoming combat ready.
  • SHOUT_TYPE_SAWENEMY Attack enemy.
  • SHOUT_TYPE_KILLEDME Attack enemy.
  • SHOUT_TYPE_SWITCH_MELEE Will switch to melee weapons, useful for certain plot situations
  • SHOUT_TYPE_WAKE_UP Any creature that hears this shout will wake up, if sleeping. This shout needs to be manually called.
  • SHOUT_TYPE_FOUND_SOMEONE (YaronToDo) a scout sees someone they broadcasts this event. Allies go here. (NOT DONE)

Commander-Specific Orders

  • SHOUT_TYPE_FINISHHIM Attacks a specified enemy till they are dead. A Commander issues order generally.
  • SHOUT_TYPE_ATTACK_WIZARD (YaronToDo) Starting targeting wizard class enemies instead of others.
  • SHOUT_TYPE_FLANK Rogues will get into a flanking position to an appropriate enemy
  • SHOUT_TYPE_SWITCH_RANGED Will randomly choose one ally and ask them to switch to a ranged weapon. This is mostly done to even out the number of participants in melee battle for animation purposes (closer to even the sides are, the better things look)