This Reference Page assumes you have followed or understand the basics of Custom CO creation. In case you do not, check out that tutorial first.

This page can serve as a reference on how to modify the stats of COs during the day to day, Power and Super Power. The return values of the functions in this Reference can be conditioned with the help of the function co.getPowerMode(), which has several return values, among them:

  • GameEnums.PowerMode_Tagpower
  • GameEnums.PowerMode_Superpower
  • GameEnums.PowerMode_Power

And a default value, which can be used to set the day to day abilities.

The following functions modify the general stats of a CO. For specific Units and Unit Types modifications, check out the info on Units and Unit Types

Offensive and Defensive Modifiers

The code to modify such stats is the following:

//Constructor code ommited for brevity
Constructor.prototype = CO;
var CO_TEST = new Constructor();

CO_TEST.getOffensiveBonus = function (co, attacker, atkPosX, atkPosY,
    defender, defPosX, defPosY, isDefender, action) {

     return 0; 
};


CO_TEST.getDeffensiveBonus = function (co, attacker, atkPosX, atkPosY,
    defender, defPosX, defPosY, isAttacker, action) {

    return 0;
};

The return type of both functions is an integer.

Cost Modifier

This function can change the costs of all the Units of a CO.

 CO_TEST.getCostModifier = function (co, id, baseCost) {
        return 0;
    };

This function takes an integer as the return type.

Movement Points Modifier

Allows Units to move an extra number of spaces

Function structure:

 CO_TEST.getMovementpointModifier = function (co, unit, posX, posY, map) {
        
        return 0;
    };

Return type of the function is an Integer

Full example

 CO_TEST.getMovementpointModifier = function (co, unit, posX, posY,map) {
        if (co.getPowerMode() === GameEnums.PowerMode_Superpower ||
            co.getPowerMode() === GameEnums.PowerMode_Tagpower) {
            return 2;
        }
        else if (co.getPowerMode() === GameEnums.PowerMode_Power) {
            return 1;
        }
        return 0;
    };

Movement Cost Modifier

Defines the cost of movement of Units in different Terrain Types.

 this.getMovementcostModifier = function (co, unit, posX, posY) {
       
        return 0;
    };

Return type is Integer.


Full Example

 this.getMovementcostModifier = function (co, unit, posX, posY) {
        if (unit.getOwner() === co.getOwner()) {
            if (map.getGameRules().getCurrentWeather().getWeatherId() === "WEATHER_SNOW") {
                return 0;
            }
            else {
                return -999;
            }
        }
        return 0;
    };

Terrain Defense Modifier

Modifies the amount of Terrain Stars a given Terrain Type provides for a Unit.

CO_TEST.getTerrainDefenseModifier = function (co, unit, posX, posY) {
       
                return 0;
        
    };

Full Example

CO_TEST.getTerrainDefenseModifier = function (co, unit, posX, posY) {
        switch (co.getPowerMode()) {
            case GameEnums.PowerMode_Tagpower:
            case GameEnums.PowerMode_Superpower:
                return map.getTerrain(posX, posY).getBaseDefense();
            case GameEnums.PowerMode_Power:
                return 0;
            default:
                return 0;
        }
    };

Range Modifier

Modifies the range of Units, this can increase the range of Direct Units as well.

CO_TEST.getFirerangeModifier = function (co, unit, posX, posY) {
      
        return 0;
    };

Return type is an Integer


Full example

CO_TEST.getFirerangeModifier = function (co, unit, posX, posY) {
        switch (co.getPowerMode()) {
            case GameEnums.PowerMode_Tagpower:
            case GameEnums.PowerMode_Superpower:
                if (unit.getBaseMaxRange() > 1) {
                    return 3;
                }
                break;
            case GameEnums.PowerMode_Power:
                if (unit.getBaseMaxRange() > 1) {
                    return 2;
                }
                break;
            default:
                if (unit.getBaseMaxRange() > 1) {
                    return 1;
                }
                break;
        }
        return 0;
    };

Modifying Minimum Range

Modifies the Minimum Range of Units.

CO_TEST.getMinFirerangeModifier = function (co, unit, posX, posY,map) {
      
        return 0;
    };

Return type is integer

Capture Bonus Modifier

Modifies the speed at which Infantry Type Units can capture properties

CO_TEST.getCaptureBonus = function (co, unit, posX, posY,map) {
      
        return 0;
    };

Return type is Integer in a range of 1 to 20.

Full example

CO_TEST.getCaptureBonus = function (co, unit, posX, posY,map) {
    
     if (co.getIsCO0() === true)
    {
        if (co.getPowerMode() === GameEnums.PowerMode_Superpower ||
            co.getPowerMode() === GameEnums.PowerMode_Tagpower)
        {
            return 20;
        }
        else
        {
            var hp = unit.getHpRounded();
            return hp / 2;
        }
    }
    return 0;  
    
};



Fuel Cost Modifier

Changes the amount of fuel that is consumed

TEST_CO.getFuelCostModifier = function (co, unit, costs) {
       
        return 0;
    };

Return type is an Integer


Full example

TEST_CO.getFuelCostModifier = function (co, unit, costs) {
        if (unit.getUnitType() === GameEnums.UnitType_Air) {
            return -2;
        }
        return 0;
    };

Hiding Units' HP

Sets whether the opponent can see the HP of Units or not.

CO_TEST.getHpHidden = function (co, unit, posX, posY) {
        
        return true;
    };

Return type is boolean

Hiding Units' Rank

Sets whether the Rank of Units is visible to the opponent or not

CO_TEST.getRankInfoHidden = function (co, unit, posX, posY, map) {
        
        return true;
    };

Perfect HP View

Allows seeing HP of Units with more precision, both your own and the Enemy's. For instance a 10 HP unit would display as having 100/100 HP.

this.getPerfectHpView = function (co, unit, posX, posY) {
        
        return true;
    };

Return type is boolean

First Strike

Defines whether the CO's Units strike first or not.

CO_TEST.getFirstStrike = function (co, unit, posX, posY, attacker) {
        return true; 
    };

Return type is boolean

Perfect Vision (Fog of War)

In Fog of War, defines whether Enemy Units hidden in reefs and forests are visible or not, if not there are no adjacent allied units, next to them.

CO_TEST.getPerfectVision = function (co) {
        
        return true;
        
    };

Return type is boolean

Vision Modifier(Fog of War)

Increases the vision of Units in Fog of War.

this.getVisionrangeModifier = function (co, unit, posX, posY) {
      
        return 1;
        
    };

Return type is Integer.


Full Example

this.getVisionrangeModifier = function (co, unit, posX, posY) {
        switch (co.getPowerMode()) {
            case GameEnums.PowerMode_Tagpower:
            case GameEnums.PowerMode_Superpower:
            case GameEnums.PowerMode_Power:
                return 2;
            default:
                return 1;
        }
    };

Attack HP Bonus

Units fight as though as if they were X HP stronger

this.getAttackHpBonus = function (co, unit, posX, posY) {
      
        return 0;
        
    };

Return type is Integer.

Full Example

this.getAttackHpBonus = function (co, unit, posX, posY) {
      if (co.getIsCO0() === true)
    {
        switch (co.getPowerMode())
        {
        case GameEnums.PowerMode_Tagpower:
        case GameEnums.PowerMode_Superpower:
            return 4;
        case GameEnums.PowerMode_Power:
            return 0;
        default:
            break;
        }
    }
    return 0;
       
        
    };

Damage Reduction

Reduces the amount of Damage taken by a Unit

this.getDamageReduction = function(co, damage, attacker, atkPosX, atkPosY, attackerBaseHp,
                                  defender, defPosX, defPosY, isDefender, luckMode, map)
    {
        return 0;
    };

Full Example

 this.getDamageReduction = function(co, damage, attacker, atkPosX, atkPosY, attackerBaseHp,
                                       defender, defPosX, defPosY, isDefender, luckMode, map)
    {
        switch (co.getPowerMode())
        {
        case GameEnums.PowerMode_Tagpower:
        case GameEnums.PowerMode_Superpower:
            return 0;
        case GameEnums.PowerMode_Power:
            var defHp = defender.getHp() * 10;
            if (damage  > defHp / 2)
            {
                return damage - defHp / 2;
            }
            return 0;
        default:
            break;
        }
        return 0;
    };

Counter Attack

Determines if Units can Counter Attack or not. Possible values are determined by GameEnums variables:

GameEnums.CounterAttackMode_Undefined , GameEnums.CounterAttackMode_Impossible, GameEnums.CounterAttackMode_Possible

this.canCounterAttack = function(co, attacker, atkPosX, atkPosY,
                                defender, defPosX, defPosY, luckMode, map)
    {
        return GameEnums.CounterAttackMode_Undefined;
    };

True Damage

Increases or decreases damage, by a flat value, ignoring base weapon damage, offensive or defensive bonuses. Can be countered by flat damage reduction.

 this.getTrueDamage = function(co, damage, attacker, atkPosX, atkPosY, attackerBaseHp,
                             defender, defPosX, defPosY, isDefender, action, luckMode, map)
    {
        return 0;
    };

Full Example

 this.getTrueDamage = function(co, damage, attacker, atkPosX, atkPosY, attackerBaseHp,
                                  defender, defPosX, defPosY, isDefender, action, luckmode, map)
    {
        // check for luck finish if  the attacker is in co range or a power mode is active
        if (defender !== null && attacker !== null &&
                ((co.inCORange(Qt.point(atkPosX, atkPosY), attacker) && !isDefender) ||
                 (co.inCORange(Qt.point(defPosX, defPosY), defender) && isDefender) ||
                 co.getPowerMode() > GameEnums.PowerMode_Off))
        {
            // check for finishing blow return absurd amount of true damage if luck is enough
            if (isDefender)
            {
                if (defender.getHp() - damage / 10.0 - attackerBaseHp / 20.0 <= 0)
                {
                    return 100;
                }
            }
            else
            {
                if (defender.getHp() - damage / 10.0  - attacker.getHpRounded() / 20.0 <= 0)
                {
                    return 100;
                }
            }
        }
        // 0
        return 0;
    };

Weather Immunity

Defines whether the Units are affected by Weather conditions or not

  this.getWeatherImmune = function(co, map)
    {
        
        return false;
    }

Return Type is Boolean

Repair Bonus

Increases the HP increased per Repair on Units

 this.getRepairBonus = function(co, unit, posX, posY, map)
    {
        return 0;
    };

You need this for getting the repair bonus

this.d2dRepairBonus = 1;

Luck Bonus

Increases the CO's Luck values

  this.getBonusLuck = function(co, unit, posX, posY, map)
    {
        return 0;
    };

Full Example

 this.getBonusLuck = function(co, unit, posX, posY, map)
    {
        switch (co.getPowerMode())
        {
            case GameEnums.PowerMode_Tagpower:
            case GameEnums.PowerMode_Superpower:
                return 100;
            case GameEnums.PowerMode_Power:
                return 60;
            default:
                if (co.inCORange(Qt.point(posX, posY), unit))
                {
                    return 15;
                }
                break;
        }
    };

Misfortune Bonus

Increases the value of Bad Luck of an enemy CO

 this.getBonusMisfortune = function(co, unit, posX, posY, map)
    {
        return 0;
    };

Offensive Reduction

Reduces the Firepower of the Enemy COs

 this.getOffensiveReduction = function(co, attacker, atkPosX, atkPosY,
                                 defender, defPosX, defPosY, isDefender, action, luckMode, map)
    {
        return 0;
    };

Defensive Reduction

Reduces the Defense of the Enemy CO's units

   this.getDeffensiveReduction = function(co, attacker, atkPosX, atkPosY,
                                  defender, defPosX, defPosY, isAttacker, action, luckMode, map)
    {
        return 0;
    };

Unit Repairability

Defines whether a given CO Unit can be repaired or not

  this.canBeRepaired = function(co, unit, posX, posY, map)
    {
        
        return true;
    }

Enemy Cost Modifier

Changes deployment costs of Enemy COs

 this.getEnemyCostModifier = function(co, id, baseCost, posX, posY, map)
    {
        return 0;
    };

Movement Fuel Cost Modifier

Modifies the fuel cost for movement in Units

 this.getMovementFuelCostModifier = function(co, unit, fuelCost, map)
    {
      return 0;
    };

Full Example

   this.getMovementFuelCostModifier = function(co, unit, fuelCost, map)
    {
        if (co.getPowerMode() === GameEnums.PowerMode_Power &&
            co.getOwner().isEnemyUnit(unit) === true)
        {
            return fuelCost * 5;
        }
        return 0;
    };

Movement and Firing

Defines if a Unit can move and fire on the same turn

 this.getCanMoveAndFire = function(co, unit, posX, posY, map)
    {
        return false;
    };

Enemy Vision Bonus

Modifies the Vision of Enemy Units in Fog of War

  this.getEnemyVisionBonus = function (co, unit, x, y, map)
    {
        return 0;
    };

Enemy Range Modifier

Modifies the Enemy's Minimum Range

 this.getEnemyMinFirerangeModifier = function (co, unit, x, y, map)
    {
        return 0;
    };

Enemy Fire Range Modifier

Modifies the Range of Enemy Units, this can modify direct Units' Range as well

 this.getEnemyFirerangeModifier = function (co, unit, x, y, map)
    {
        return 0;
    };

Get Bonus Loading Place

Allows the Unloading of a Unit inside a Cargo Unit, at an extra space

 this.getBonusLoadingPlace = function (co, unit, x, y, map)
    {
        return 0;
    };

Additional Building Actions

Allows Buildings to perform extra actions

 this.getAdditionalBuildingActions = function(co, building, map)
    {
        
        return "";
    };

Full Example

 this.getAdditionalBuildingActions = function(co, building, map)
    {
        switch (co.getPowerMode())
        {
            case GameEnums.PowerMode_Tagpower:
            case GameEnums.PowerMode_Superpower:
                return ""
            case GameEnums.PowerMode_Power:
                // disable enemy production line
                if (co.getOwner().isEnemy(building.getOwner()))
                {
                    return "-ACTION_BUILD_UNITS";
                }
                break;
            default:
                break;
        }
        return "";
    };

For Parameters that can be passed to the return statement, check the Actions Functions

Additional Transportable Units

Allows adding a list of Units that can be transported by Transport Units

 this.getTransportUnits = function(co, unit, map)
    {
        // called to check for additional loading units for a transporter
        // - before an unit id will remove the unit from the loading list
        return [];
    };

RepairCostModifier

Allows to modifier the repair cost

   this.getRepairCostModifier = function (co, id, repairCost)
   {
       return 0;
   };
   (-1 allow you not spending any of your funds into repairs, -2 or beyond will give you repair funds back, while +1 or beyond will increase the repairCost)

getEnemyRepairCostModifier

Allows to modifier opponents repaircost

       this.getEnemyRepairCostModifier = function(co, id, repairCost, posX, posY, map)
   {
       return 0;
   };
   (This allow your co to jack up the price against your opponents units repair cost)

</syntaxhighlight>