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

Common Parameters

Before we get to the functions, it's important to familiarize yourself with some of these parameters. Many of the functions use them, and most of the time they serve the same purpose. Therefore, instead of repeatedly explaining what they do every time they show up in a function, they will be explained here.

  • The co parameter refers to the CO object. You will find this in practically every function here. We use this reference data related to the CO itself, such as the aforementioned co.getPowerMode() which is used to check the current state of the CO power.
  • The action parameter refers to the action object. Typically found in functions called just before or after moving a unit, you can use this to grab data related to the act of moving the unit itself. For example, action.getMovePath().length returns a number corresponding to the number of spaces moved.
  • The map parameter refers to the map object. It is often used to reference data related to the game map, such as map.getCurrentDay() which returns the current day count as an integer.

Offensive Bonus Modifier

This function is called when calculating how much damage the CO does in battle. In addition to being called during a battle, the game calls it just before a battle to display the estimated damage percentage.

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

The function takes an integer as the return type.

Parameters

  • attacker refers to the attacking unit (your unit).
  • atkPosX and atkPosY refers to the attacker's position. This is the actual attacking position, not the attacker's starting position (if the attacker has moved before attacking).
  • defender refers to the defending unit (the enemy).
  • defPosX and defPosY refers to the defender's position.
  • isDefender is a boolean. It is false if the CO started the battle, and true otherwise.
  • The luckMode parameter appears to serve a technical purpose. The game uses it to calculate the maximum and minimum luck damage in order to display them before a battle (if the "detailed battle info" option is enabled in the settings). When the function is called during the actual battle, luckMode will always be equal to GameEnums.LuckDamageMode_On, so it should have no gameplay effect.

Defensive Bonus Modifier

This function is called when calculating how much defense the CO has. Like getOffensiveBonus, outside of the actual battle, the game also calls this to display the estimated damage percentage.

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

The function takes an integer as the return type.

Do not correct the typo in the function's name ("Deffensive" instead of "Defensive"), as it won't work if you do.

Parameters

  • attacker refers to the attacking unit (the enemy).
  • atkPosX and atkPosY refers to the attacker's position. This is the actual attacking position, not the attacker's starting position (if the attacker has moved before attacking).
  • defender refers to the defending unit (your unit).
  • defPosX and defPosY refers to the defender's position.
  • isAttacker is a boolean. It is true if the CO started the battle, and false otherwise.
  • The luckMode parameter appears to serve a technical purpose. The game uses it to calculate the maximum and minimum luck damage in order to display them before a battle (if the "detailed battle info" option is enabled in the settings). When the function is called during the actual battle, luckMode will always be equal to GameEnums.LuckDamageMode_On, so it should have no gameplay effect.

Cost Modifier

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

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

This function takes an integer as the return type.

Parameters

  • baseCost this will change the cost value in-game & it will affect units production props such as base, airport, harbor, hovercrafts & lab

Movement Points Modifier

Allows Units to move an extra number of spaces

Function structure:

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

Return type of the function is an Integer

Full example

 this.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.

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

Full Example

this.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.

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

Return type is an Integer


Full example

this.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.

this.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

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

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

Full example

this.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

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

Return type is an Integer


Full example

this.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.

this.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

this.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.

this.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.

this.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 [];
    };

Repair Cost Modifier

Lets you change the repair costs.

    this.getRepairCostModifier = function (co, id, repairCost)
    {
        return 0;
    };

If you set the return value to -1 makes it so repair costs are free, -2 or less will give you funds back, 1 and more will increase the repair costs.

Parameters

  • co will work on your co's
  • id will work on certain units type
  • repaircost will work all your unit & depends on the value you put in

Example

No repairs funds

    this.getRepairCostModifier = function (co, id, repairCost)
    {
        return -1;
    };

Receive repair funds

    this.getRepairCostModifier = function (co, id, repairCost)
    {
        return -5;
    };

How does it work? Here the value works, -1 will not drain your funds (think of it a freebie repair), -1 or beyond than -1 will receive funds e.g -10 (you gain funds when repairing a unit), if you set the value outside -1 e.g 30 you have to pay more repair funds depends on the value you put in (you have to pay more repair funds)

  • Sidenote this also effect Clauder's CO zone effects

Enemy Repair Cost Modifier

Lets you modify your opponent's repair costs.

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

This allow you just modifier your opponent (enemy) repair cost

Parameters

  • co will work on your co
  • id will work on certain units type
  • repaircost will modifier your repair cost
  • posX will work on units position X
  • posY will work on units position Y
  • map will work on map

Example

    this.getEnemyRepairCostModifier = function(co, id, repairCost, posX, posY, map)
    {
        switch (co.getPowerMode())
        {
         case GameEnums.PowerMode_Tagpower:
         case GameEnums.PowerMode_Superpower:
         return 9000;
         break
         case GameEnums.PowerMode_Power:
            return 30;
            break
        return 0;
       }
    };

How does it work? If you set the value like 30 the opponent will pay extra 30% of repairs funds, if you set like 9000 value that mean opponent (enemy) no longer repairs