Timestamp:
Apr 12, 2021, 8:51:39 AM (3 years ago)
Author:
Freagarach
Message:

Attack using cmpAttack instead of UnitAI.

Keep responsibilities separated, allow easier modding of attacking behaviour.
Ideally the BuildingAI attacking routine would be merged in here as well, but not done for now.

Part of #5810
Differential revision: D3816
Comments by: @smiley, @Stan

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/simulation/components/Heal.js

    r25207 r25235  
    167167
    168168/**
    169  * @param {string} reason - The reason why we stopped healing. Currently implemented are:
    170  *  "outOfRange", "targetInvalidated".
     169 * @param {string} reason - The reason why we stopped healing.
    171170 */
    172171Heal.prototype.StopHealing = function(reason)
    173172{
    174     if (this.timer)
    175     {
    176         let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
    177         cmpTimer.CancelTimer(this.timer);
    178         delete this.timer;
    179     }
     173    if (!this.target)
     174        return;
     175
     176    let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
     177    cmpTimer.CancelTimer(this.timer);
     178    delete this.timer;
     179
     180    delete this.target;
    180181
    181182    let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual);
     
    183184        cmpVisual.SelectAnimation("idle", false, 1.0);
    184185
    185     delete this.target;
    186 
    187     // The callerIID component may start healing again,
     186    // The callerIID component may start again,
    188187    // replacing the callerIID, hence save that.
    189188    let callerIID = this.callerIID;
     
    200199/**
    201200 * Heal our target entity.
    202  * @params - data and lateness are unused.
     201 * @param data - Unused.
     202 * @param {number} lateness - The offset of the actual call and when it was expected.
    203203 */
    204204Heal.prototype.PerformHeal = function(data, lateness)
Note: See TracChangeset for help on using the changeset viewer.