Changes between Initial Version and Version 1 of Ticket #52, comment 6


Ignore:
Timestamp:
Feb 3, 2014, 6:30:13 PM (10 years ago)
Author:
O.Davoodi

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #52, comment 6

    initial v1  
    11One important note before anything else:
    22To implement the triggers, we need a way to serialize and deserialize js functions; something not present in out current engine. For the patch to work, I've made a temporary hack so that it doesn't crash the game but save games will be broken. So, to really implement this, we should first fix the serializer.
     3
    34
    45This patch is work in progress. It implements a basic trigger system.
     
    67To create a trigger, an "action" function must be made. Then, a trigger is registered using RegisterTrigger function, which binds the "action" to an "event". During the game, when those "events" occur, the "action" functions are called.
    78Currently these are the implemented events:
     9
     10
    811OnEntityTookDamage
     12
    913OnEntityKilled
     14
    1015OnStructureBuilt
     16
    1117OnConstructionStarted
     18
    1219OnTrainingFinished
     20
    1321OnTrainingQueued
     22
    1423OnResearchFinished
     24
    1525OnResearchQueued
     26
    1627Always (Special case, describes bellow)
     28
    1729OnUnitRangeFromEntity
     30
    1831
    1932Always event occurs every "updateInterval" defined by the creator of the triggers. It is an integer which describes the miliseconds interval by which the "Always" event occurs. As this could be performance heavy, it is disabled by default, so if a map maker really needs to check for something (for eg.) each second, it should enable this event manually. If his/her work is done with it, it can be disabled again.
    2033
    2134OnUnitRangeFromEntity is another special case. For one, it "needs" to be updated. So for this to work, the update interval should be set.
     35
    2236It handles three closely related "events":
     37
    2338"OnUnitEnteredRangeFromEntity" which occurs when an entity moves into a radius from a specific entity.
     39
    2440"OnUnitLeftRangeFromEntity" which occurs when an entity that moves out of a radius from a specific entity.
     41
    2542"OnUnitMovedInsideRangeFromEntity" which occurs when an entity that moves inside of a radius from a specific entity. (doesn't leave it, but has already entered it).
     43
    2644
    2745One of the other important events to implement would be an "OnUnitRangeFromPoint" event that uses a point instead of an entity as the center of the radius.