Tricks
Written by: Alian713 & Kramb
1. Changing unit specific damage class value¶
To change unit damage class values you need to multiply the damage class by 256 and add its value.
If you need a negative value you need to then multiply that whole number by -1.
This does not work for values greater than 255.
For cMulAttribute you need to also multiply the value by 100.
This total value can't exceed 255, so in practice you can only multiply by 2.55 times at most.
If you need greater values, you will have to call this function several times.
This example sets the genghis pierce attack to 5, adds 5, subtracts 3 and then multiplies it by 2, making it 14 in total:
1 2 3 4 5 6 | |
2. Setting and unsetting costs¶
You can unset the objects resource cost by multiplying its cost by -2 and creating a new resource cost by multiplying its cost by -1.
A house normally costs 25 wood, but what if we want to make it cost, lets say, 10 stone instead?
1 2 3 4 5 | |
3. Adding auras¶
Adding auras to units can be a bit tricky with lots of function calls and edge cases. This xs function handles most of those cases.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
To use, copy the code above to a non-running Script Call effect or to your scenarios .xs file and then call the function in your xs code, eg:
1 2 3 4 5 6 7 8 9 10 11 12 | |
4. Changing multiple train locations and damage sprites¶
To change multiple train locations and damage sprites you can use global struct cTrainLocationsEntryMod, cTrainLocationsTotalNum, cDamageGraphicsEntryMod and cDamageGraphicsTotalNum values.
Based on developer notes:
1 2 3 4 5 6 7 8 9 10 | |
We can create these examples for locations:
Change 2nd location:
1 2 | |
Read total location count:
1 | |
Insert 2nd location (eg: middle of the list):
1 2 | |
Remove 2nd location:
1 | |
Add new location to the end of the list:
1 2 | |
Read 2nd location:
1 2 | |
If location change or value read is needed it's always better to set cTrainLocationsEntryMod beforehand.
The same principle can be used for damage sprites just using its constants: cDamageGraphicsEntryMod and cDamageGraphicsTotalNum.
But for last index value you should use 254 instead of 32767 (since sprites list is smaller).
5. Changing tech cost or time¶
To change tech cost or time xsEffectAmount(cModifyTech, techId, subCommand, value, player) command variants should be used.
Other commands cSetTechCost, cAddTechCost and cModTechTime no longer work.
You can not add or change which resources the tech cost, only their amounts.
So if a tech cost food and gold you can not add wood cost.
Be careful when using addition and multiplication sub commands such as: cAttrAddFoodCost or cAttrMulGoldCost. When doing calculations sometimes they take current tech price and sometimes the original price.
This leads to unexpected results. It is better to do calculations and cost tracking yourself and use sub commands such as cAttrSetGoldCost to update the cost.
Same things apply to time changing sub commands such as cAttrSetTime, cAttrAddTime and cAttrMulTime.
1 2 3 4 5 6 7 8 9 10 11 12 | |
Safe multiplying cost:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |