Opened 14 months ago

Last modified 14 months ago

#6769 new defect

Add prefered classes for healers

Reported by: Stan Owned by:
Priority: Should Have Milestone: Backlog
Component: Simulation Keywords: simple
Cc: Patch:

Description (last modified by Stan)

TODO: Maybe it should be user defined, but that's way harder.

Target: UnitAi.js:5095

Old code

/**
 * Try to respond to healable entities.
 * Returns true if it responded.
 */
UnitAI.prototype.RespondToHealableEntities = function(ents)
{
    let ent = ents.find(ent => this.CanHeal(ent));
    if (!ent)
        return false;

    this.PushOrderFront("Heal", { "target": ent, "force": false });
    return true;
};

New code

/**
 * Try to respond to healable entities.
 * Returns true if it responded.
 */
UnitAI.prototype.RespondToHealableEntities = function(ents)
{
    // TODO: Don't call that twice.
    const cmpHeal = Engine.QueryInterface(this.entity, IID_HEAL)
    let ent = ents.sort(cmpHeal.GetPreference).find(ent => this.CanHeal(ent));
    if (!ent)
        return false;

    this.PushOrderFront("Heal", { "target": ent, "force": false });
    return true;
};

Add this to the schema of the heal component

    "<optional>" +
        "<element name='PreferredClasses' a:help='Space delimited list of classes preferred for attacking. If an entity has any of theses classes, it is preferred. The classes are in decending order of preference'>" +
            "<attribute name='datatype'>" +
                "<value>tokens</value>" +
            "</attribute>" +
            "<text/>" +
        "</element>" +
    "</optional>";
Heal.prototype.GetPreference = function(entA, entB)
{
    //TODO: Sort shenanigans

    // Orderby MatchClassList
    // then by most injured
};

Change History (1)

comment:1 by Stan, 14 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.