No edit summary
(Added more details about parameters. Hopefully this is the start of a gradual rewrite.)
Line 8: Line 8:
And a '''default''' value, which can be used to set the day to day abilities.
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 [[:Category:Units|Units]]
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==
==Common Parameters==
The code to modify such stats is the following:
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.


<syntaxhighlight lang="javascript">
* 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.
//Constructor code ommited for brevity
*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.
Constructor.prototype = CO;
*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.
var CO_TEST = new Constructor();


CO_TEST.getOffensiveBonus = function (co, attacker, atkPosX, atkPosY,
==Offensive Bonus Modifier==
    defender, defPosX, defPosY, isDefender, action) {
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.


<syntaxhighlight lang="javascript">
this.getOffensiveBonus = function (co, attacker, atkPosX, atkPosY,
    defender, defPosX, defPosY, isDefender, action, luckMode, map)
{
     return 0;  
     return 0;  
};
};
</syntaxhighlight>


The function takes an integer as the return type.


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


*'''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.
<syntaxhighlight lang="javascript">
this.getDeffensiveBonus = function (co, attacker, atkPosX, atkPosY,
    defender, defPosX, defPosY, isAttacker, action, luckMode, map)
{
     return 0;
     return 0;
};
};


</syntaxhighlight>
</syntaxhighlight>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'''


The return type of both functions is an integer.
*'''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==
==Cost Modifier==
Line 39: Line 66:


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
  CO_TEST.getCostModifier = function (co, id, baseCost) {
  this.getCostModifier = function (co, id, baseCost) {
         return 0;
         return 0;
     };
     };
Line 51: Line 78:
Function structure:
Function structure:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
  CO_TEST.getMovementpointModifier = function (co, unit, posX, posY, map) {
  this.getMovementpointModifier = function (co, unit, posX, posY, map) {
          
          
         return 0;
         return 0;
Line 61: Line 88:


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
  CO_TEST.getMovementpointModifier = function (co, unit, posX, posY,map) {
  this.getMovementpointModifier = function (co, unit, posX, posY,map) {
         if (co.getPowerMode() === GameEnums.PowerMode_Superpower ||
         if (co.getPowerMode() === GameEnums.PowerMode_Superpower ||
             co.getPowerMode() === GameEnums.PowerMode_Tagpower) {
             co.getPowerMode() === GameEnums.PowerMode_Tagpower) {
Line 73: Line 100:
</syntaxhighlight>
</syntaxhighlight>


==Movement Cost Modifier==
== Movement Cost Modifier ==
Defines the cost of movement of Units in different Terrain Types.
Defines the cost of movement of Units in different Terrain Types.
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
Line 104: Line 131:


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getTerrainDefenseModifier = function (co, unit, posX, posY) {
this.getTerrainDefenseModifier = function (co, unit, posX, posY) {
        
        
                 return 0;
                 return 0;
Line 113: Line 140:
'''Full Example'''
'''Full Example'''
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getTerrainDefenseModifier = function (co, unit, posX, posY) {
this.getTerrainDefenseModifier = function (co, unit, posX, posY) {
         switch (co.getPowerMode()) {
         switch (co.getPowerMode()) {
             case GameEnums.PowerMode_Tagpower:
             case GameEnums.PowerMode_Tagpower:
Line 129: Line 156:
Modifies the range of Units, this can increase the range of Direct Units as well.
Modifies the range of Units, this can increase the range of Direct Units as well.
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getFirerangeModifier = function (co, unit, posX, posY) {
this.getFirerangeModifier = function (co, unit, posX, posY) {
        
        
         return 0;
         return 0;
Line 140: Line 167:
'''Full example'''
'''Full example'''
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getFirerangeModifier = function (co, unit, posX, posY) {
this.getFirerangeModifier = function (co, unit, posX, posY) {
         switch (co.getPowerMode()) {
         switch (co.getPowerMode()) {
             case GameEnums.PowerMode_Tagpower:
             case GameEnums.PowerMode_Tagpower:
Line 166: Line 193:
Modifies the Minimum Range of Units.
Modifies the Minimum Range of Units.
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getMinFirerangeModifier = function (co, unit, posX, posY,map) {
this.getMinFirerangeModifier = function (co, unit, posX, posY,map) {
        
        
         return 0;
         return 0;
Line 177: Line 204:
Modifies the speed at which Infantry Type Units can capture properties
Modifies the speed at which Infantry Type Units can capture properties
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getCaptureBonus = function (co, unit, posX, posY,map) {
this.getCaptureBonus = function (co, unit, posX, posY,map) {
        
        
         return 0;
         return 0;
Line 186: Line 213:
'''Full example'''
'''Full example'''
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getCaptureBonus = function (co, unit, posX, posY,map) {
this.getCaptureBonus = function (co, unit, posX, posY,map) {
      
      
     if (co.getIsCO0() === true)
     if (co.getIsCO0() === true)
Line 212: Line 239:
Changes the amount of fuel that is consumed
Changes the amount of fuel that is consumed
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
TEST_CO.getFuelCostModifier = function (co, unit, costs) {
this.getFuelCostModifier = function (co, unit, costs) {
        
        
         return 0;
         return 0;
Line 222: Line 249:
'''Full example'''
'''Full example'''
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
TEST_CO.getFuelCostModifier = function (co, unit, costs) {
this.getFuelCostModifier = function (co, unit, costs) {
         if (unit.getUnitType() === GameEnums.UnitType_Air) {
         if (unit.getUnitType() === GameEnums.UnitType_Air) {
             return -2;
             return -2;
Line 234: Line 261:


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getHpHidden = function (co, unit, posX, posY) {
this.getHpHidden = function (co, unit, posX, posY) {
          
          
         return true;
         return true;
Line 243: Line 270:
Return type is boolean
Return type is boolean


==Hiding Units' Rank==
== Hiding Units' Rank ==
Sets whether the Rank of Units is visible to the opponent or not
Sets whether the Rank of Units is visible to the opponent or not
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getRankInfoHidden = function (co, unit, posX, posY, map) {
this.getRankInfoHidden = function (co, unit, posX, posY, map) {
          
          
         return true;
         return true;
Line 264: Line 291:
Return type is boolean
Return type is boolean


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


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getFirstStrike = function (co, unit, posX, posY, attacker) {
this.getFirstStrike = function (co, unit, posX, posY, attacker) {
         return true;  
         return true;  
     };
     };
Line 275: Line 302:
Return type is boolean
Return type is boolean


==Perfect Vision (Fog of War)==
== 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.
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.
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getPerfectVision = function (co) {
this.getPerfectVision = function (co) {
          
          
         return true;
         return true;
Line 351: Line 378:
</syntaxhighlight>
</syntaxhighlight>


==Damage Reduction==
== Damage Reduction==
Reduces the amount of Damage taken by a Unit
Reduces the amount of Damage taken by a Unit


Line 386: Line 413:
</syntaxhighlight>
</syntaxhighlight>


==Counter Attack==
== Counter Attack==
Determines if Units can Counter Attack or not.
Determines if Units can Counter Attack or not.
Possible values are determined by GameEnums variables:
Possible values are determined by GameEnums variables:
Line 513: Line 540:
</syntaxhighlight>
</syntaxhighlight>


==Offensive Reduction==
==Offensive Reduction ==
Reduces the Firepower of the Enemy COs
Reduces the Firepower of the Enemy COs
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
Line 545: Line 572:
</syntaxhighlight>
</syntaxhighlight>


==Enemy Cost Modifier==
==Enemy Cost Modifier ==
Changes deployment costs of Enemy COs
Changes deployment costs of Enemy COs
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
Line 554: Line 581:
</syntaxhighlight>
</syntaxhighlight>


==Movement Fuel Cost Modifier==
== Movement Fuel Cost Modifier ==
Modifies the fuel cost for movement in Units
Modifies the fuel cost for movement in Units


Line 698: Line 725:
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.
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.


== Enemy Repair Cost Modifier==
==Enemy Repair Cost Modifier==
Lets you modify your opponent's repair costs.
Lets you modify your opponent's repair costs.



Revision as of 03:50, 12 September 2023

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.

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.

Enemy Repair Cost Modifier

Lets you modify your opponent's repair costs.

        this.getEnemyRepairCostModifier = function(co, id, repairCost, posX, posY, map)
    {
        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.