Event

From Dragon Age Toolset Wiki
Revision as of 19:53, 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:

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)