en>Admin
No edit summary
 
(Add Income Bonus)
 
(34 intermediate revisions by 3 users not shown)
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 [[Units and Unit Types]]
The following functions modify the general stats of a CO.  For specific Units and Unit Types modifications, check out the info on [[:Category:Units]]


==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 to 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();
*The '''posX''' and '''posY''' parameters are integers containing coordinates. They usually refer to the selected unit's position.


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's units do 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.


'''Parameters'''


CO_TEST.getDeffensiveBonus = function (co, attacker, atkPosX, atkPosY,
*'''attacker''' refers to the attacking unit (your unit).
    defender, defPosX, defPosY, isAttacker, action) {
*'''atkPosX''' and '''atkPosY''' are integers referring 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''' are integers referring 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's units have. 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''' are integers referring 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''' are integers referring 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==
This function can change the costs of all the Units of a CO.
This function can change the costs of all the units of a CO.


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getCostModifier = function (co, id, baseCost) {
this.getCostModifier = function (co, id, baseCost, posX, posY, map)
    {
         return 0;
         return 0;
     };
     };
</syntaxhighlight>
</syntaxhighlight>


This function takes an integer as the return type.  
This function takes an integer as the return type.
 
'''Parameters'''
*'''id''' is a string containing the unit's ID. For example, the infantry unit's ID is "INFANTRY". Note that the IDs don't always match the unit's name, so please take a look at [[:Category:UnitIDs|these pages]] for a list of unit IDs.
*'''baseCost''' is an integer containing the unit's default price. You can use this to manipulate how much a given unit costs for your CO.
*Since the function is called before the unit itself is even built, the '''posX''' and '''posY''' parameters here instead refer to the position where the unit will be produced.
'''Full example''' <syntaxhighlight lang="javascript">
this.getCostModifier = function(co, id, baseCost, posX, posY, map)
    {
        if (id === "INFANTRY") //If the unit is Infantry
        {
            return baseCost; //By returning the baseCost itself, the baseCost will be added to the default price, effectively doubling it.
        }
        if (id === "LIGHT_TANK") //If the unit is a Light Tank
        {
            return -baseCost * 0.2; //This returns a negative value that is 20% of baseCost. In this case, 20% of the Light Tank's default price is 1400. 7000 - 1400 = 5600, therefore, your CO's Light Tanks will cost 5600.
        }
        return 0; //If none of the above conditions are met, then the cost will be unmodified.
    };
</syntaxhighlight>The above example makes your CO's Infantry cost 2000 and Light Tanks cost 5600, while everything else is unchanged.


==Movement Points Modifier==
==Movement Points Modifier==
Allows Units to move an extra number of spaces
This function allows you to modify a unit's movement points.


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


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
CO_TEST.getMovementpointModifier = function (co, unit, posX, posY) {
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)
        {
             return 2;
             return 2;
         }
         }
         else if (co.getPowerMode() === GameEnums.PowerMode_Power) {
         else if (co.getPowerMode() === GameEnums.PowerMode_Power)
        {
             return 1;
             return 1;
         }
         }
         return 0;
         return 0;
     };
     };
</syntaxhighlight>
</syntaxhighlight>The above example is exactly like Adder, where your CO's Super Power allows all units to move two additional spaces, and one space if it's the normal CO Power.


==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 155:


<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 164:
'''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 180:
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 191:
'''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 217:
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 228:
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 237:
'''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 263:
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 273:
'''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 285:


<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 294:
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 315:
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 326:
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 402:
</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 437:
</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 465: Line 516:
         return 0;
         return 0;
     };
     };
</syntaxhighlight>
You need this for getting the repair bonus
<syntaxhighlight lang="javascript">
this.d2dRepairBonus = 1;
</syntaxhighlight>
</syntaxhighlight>


Line 500: Line 555:


==Misfortune Bonus==
==Misfortune Bonus==
Increases the value of Bad Luck of CO
Increases the value of Bad Luck of an enemy CO


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
Line 509: Line 564:
</syntaxhighlight>
</syntaxhighlight>


==Offensive Reduction==
==Offensive Reduction ==
Reduces the Firepower of the CO
Reduces the Firepower of the Enemy COs
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
  this.getOffensiveReduction = function(co, attacker, atkPosX, atkPosY,
  this.getOffensiveReduction = function(co, attacker, atkPosX, atkPosY,
Line 520: Line 575:


==Defensive Reduction==
==Defensive Reduction==
Reduces the Defense of the CO's units
Reduces the Defense of the Enemy CO's units
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
   this.getDeffensiveReduction = function(co, attacker, atkPosX, atkPosY,
   this.getDeffensiveReduction = function(co, attacker, atkPosX, atkPosY,
Line 541: Line 596:
</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 550: Line 605:
</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 680: Line 735:
</syntaxhighlight>
</syntaxhighlight>


==Repair Cost Modifier==
Lets you change the repair costs.
<syntaxhighlight lang="javascript">
    this.getRepairCostModifier = function (co, id, repairCost)
    {
        return 0;
    };
 
</syntaxhighlight>
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
<syntaxhighlight lang="javascript">
    this.getRepairCostModifier = function (co, id, repairCost)
    {
        return -1;
    };
 
</syntaxhighlight>
Receive repair funds
<syntaxhighlight lang="javascript">
    this.getRepairCostModifier = function (co, id, repairCost)
    {
        return -5;
    };
 
</syntaxhighlight>
'''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)
<syntaxhighlight lang="javascript">
this.getRepairCostModifier = function (co, id, repairCost)
    {
        return repaircost; //By returning the repairCost itself, the repairCost will be added to the default repairprice, effectively doubling it or make it as freebie
    };
        {
            return repaircost; /*This return to cut the repaircost e.g fighter 4k repairs (10%) if you add +20% (0.2) that will make 30% the fighter will repair about 12K worth of your own funds for that repairs, if you want the funds back e.g fighter usually it 4k for repairs if you set like -5 you receive 16K funds for it, how that work is this 10% -50% that will go toward negative -40% so you received 40% repair funds back, for the freebie you have to set it -1 so an infantry usually repair about 200 funds for it during the next turn your funds won't drop or you could say not spending 200 funds on the infantry repairs.
            Note: this code if you set it -1 and this code can be negated EnemyRepairCostModifier but not -5 or beyond*/
        }
</syntaxhighlight>
*Sidenote this also effect Caulder's CO zone effects
==Enemy Repair Cost Modifier==
Lets you modify your opponent's repair costs.
<syntaxhighlight lang="javascript">
        this.getEnemyRepairCostModifier = function(co, id, repairCost, posX, posY, map)
    {
        return 0;
    };
</syntaxhighlight>
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'''
<syntaxhighlight lang="javascript">
    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;
      }
    };
 
</syntaxhighlight>
'''How does it work?'''
If you set the value like 30 the opponent will pay extra 300% of repairs funds, if you set like 9000 value that mean opponent (enemy) no longer repairs
<syntaxhighlight lang="javascript">
this.getEnemyRepairCostModifier = function(co, id, repairCost, posX, posY, map)
    {
        return repaircost; //This allow you to effect against your opponents repaircost, the normal repair cost an infantry 200 funds for that repairs it will increase the repair cost on opponents turns by how much the value is.
    };
</syntaxhighlight>
== Income Bonus ==
Let you modified Income gains<syntaxhighlight lang="js">
    this.getBonusIncome = function(co, building, income, map)
    {
        if (CO.isActive(co))
        {
            return income * CO_TEST.d2dPercentIncomeBonus + CO_TEST.d2dFlatIncomeBonus;
        }
        return 0;
    };
    d2dPercentIncomeBonus//This allow you to put the value whatever number you want it like this 0.1 or 0.whatever the value you wanted.
    d2dFlatIncomeBonus//This allow you to gain additional funds as a extra income
</syntaxhighlight>'''How does it work?'''
Since this is only affect on your co income gain per props you own, e.g City (Town) usually give you 1000 per turn but with the bonus income you gain what ever amount of income value you put in the income code


The FlatIncomeBonus will set it self as a permanent itself so you have a city if you put the D2Dflatincome bonus let just say 50 you gain 1050 fund per turns
[[Category:Modding tutorials]]
[[Category:Modding tutorials]]

Latest revision as of 07:31, 16 December 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 Category:Units

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 to 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.
  • The posX and posY parameters are integers containing coordinates. They usually refer to the selected unit's position.

Offensive Bonus Modifier

This function is called when calculating how much damage the CO's units do 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 are integers referring 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 are integers referring 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's units have. 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 are integers referring 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 are integers referring 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, posX, posY, map)
    {
        return 0;
    };

This function takes an integer as the return type.

Parameters

  • id is a string containing the unit's ID. For example, the infantry unit's ID is "INFANTRY". Note that the IDs don't always match the unit's name, so please take a look at these pages for a list of unit IDs.
  • baseCost is an integer containing the unit's default price. You can use this to manipulate how much a given unit costs for your CO.
  • Since the function is called before the unit itself is even built, the posX and posY parameters here instead refer to the position where the unit will be produced.

Full example

this.getCostModifier = function(co, id, baseCost, posX, posY, map)
    {
        if (id === "INFANTRY") //If the unit is Infantry
        {
            return baseCost; //By returning the baseCost itself, the baseCost will be added to the default price, effectively doubling it.
        }
        if (id === "LIGHT_TANK") //If the unit is a Light Tank
        {
            return -baseCost * 0.2; //This returns a negative value that is 20% of baseCost. In this case, 20% of the Light Tank's default price is 1400. 7000 - 1400 = 5600, therefore, your CO's Light Tanks will cost 5600.
        }
        return 0; //If none of the above conditions are met, then the cost will be unmodified.
    };

The above example makes your CO's Infantry cost 2000 and Light Tanks cost 5600, while everything else is unchanged.

Movement Points Modifier

This function allows you to modify a unit's movement points.

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;
    };

The above example is exactly like Adder, where your CO's Super Power allows all units to move two additional spaces, and one space if it's the normal CO Power.

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)

this.getRepairCostModifier = function (co, id, repairCost)
    {
        return repaircost; //By returning the repairCost itself, the repairCost will be added to the default repairprice, effectively doubling it or make it as freebie
    };

        {
            return repaircost; /*This return to cut the repaircost e.g fighter 4k repairs (10%) if you add +20% (0.2) that will make 30% the fighter will repair about 12K worth of your own funds for that repairs, if you want the funds back e.g fighter usually it 4k for repairs if you set like -5 you receive 16K funds for it, how that work is this 10% -50% that will go toward negative -40% so you received 40% repair funds back, for the freebie you have to set it -1 so an infantry usually repair about 200 funds for it during the next turn your funds won't drop or you could say not spending 200 funds on the infantry repairs.
            Note: this code if you set it -1 and this code can be negated EnemyRepairCostModifier but not -5 or beyond*/
        }
  • Sidenote this also effect Caulder'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 300% of repairs funds, if you set like 9000 value that mean opponent (enemy) no longer repairs

this.getEnemyRepairCostModifier = function(co, id, repairCost, posX, posY, map)
    {
        return repaircost; //This allow you to effect against your opponents repaircost, the normal repair cost an infantry 200 funds for that repairs it will increase the repair cost on opponents turns by how much the value is.
    };

Income Bonus

Let you modified Income gains

    this.getBonusIncome = function(co, building, income, map)
    {
        if (CO.isActive(co))
        {
            return income * CO_TEST.d2dPercentIncomeBonus + CO_TEST.d2dFlatIncomeBonus;
        }
        return 0;
    };
    d2dPercentIncomeBonus//This allow you to put the value whatever number you want it like this 0.1 or 0.whatever the value you wanted.
    d2dFlatIncomeBonus//This allow you to gain additional funds as a extra income

How does it work?

Since this is only affect on your co income gain per props you own, e.g City (Town) usually give you 1000 per turn but with the bonus income you gain what ever amount of income value you put in the income code

The FlatIncomeBonus will set it self as a permanent itself so you have a city if you put the D2Dflatincome bonus let just say 50 you gain 1050 fund per turns