This repository was archived by the owner on Jul 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtemplate.lua
More file actions
363 lines (278 loc) · 6.98 KB
/
template.lua
File metadata and controls
363 lines (278 loc) · 6.98 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
function canApplyAsLowerSpell()
return false
end
function canApplyAsBoostSpell()
return true
end
function canApplyToUnit(unitImpl)
-- The function is called when the game selects leader upgrades to offer (from GleaUpg.dbf).
-- Thus, you can filter which upgrades to provide depending on current unit implementation.
-- Can only apply on Rod-planter leader
return unitImpl.leaderType == Leader.Rod
end
function canApplyToUnitType(unitType)
-- Can apply on stack leader only
return
unitType == Unit.Noble or
unitType == Unit.Leader or
unitType == Unit.Summon or
unitType == Unit.Illusion
end
function getModifierDisplay(unit, prev)
if unit.impl.level < 3 then
return true
end
-- Default is DISPLAY from Gmodif.dbf
return prev
end
function getModifierDescTxt(unit, prev)
if unit.impl.level < 3 then
-- Description text from Tglobal.dbf
return Id.new("x000tg0112")
end
-- Default is DESC_TXT from Gmodif.dbf
return prev
end
function getModifierIconName(unit, prev)
if unit.impl.level < 3 then
-- Any 31x36 icon name from Icons.ff
return "ABIL0007"
end
-- Default is MODIF_ID from Gmodif.dbf
return prev
end
function getNameTxt(unit, prev)
-- You can use format text like "Overpowered %BASE%" to get names like "Overpowered Peasant"
if unit.hpMax == 100 and unit.type == Leader.Rod then
return Id.new("x000tgb004")
elseif prev == Id.new("x000tg2201") then -- Peasant
return Id.new("x000tg2053") -- Berzerker
end
return Id.new("x000tg2054") -- Anti-Paladin
end
function getDescTxt(unit, prev)
if unit.impl.base and unit.impl.base.subrace == Subrace.Heretic then
return Id.new("x000tg0112")
end
if unit.type == Leader.Rod then
return Id.new("x160tgc536") --return "x000tgb004" -- Plants Rods
end
return Id.new("x000tg2054") -- Anti-Paladin
end
function getHitPoint(unit, prev)
if unit.hpMax == 100 then
return 1234
end
return prev + 69
end
function getArmor(unit, prev)
return prev + 5
end
function getDeathAnim(unit, prev)
-- Currently there is a bug in the game that prevents this from working
return DeathAnimation.Heretic
end
function getRegen(unit, prev)
return 50
end
function getXpNext(unit, prev)
return prev / 2
end
function getXpKilled(unit, prev)
return prev * 2
end
function getImmuneToAttack(unit, attack, prev)
if attack == Attack.Poison then
return Immune.Always
end
return prev
end
function getImmuneToSource(unit, source, prev)
if source == Source.Fire and prev ~= Immune.Always then
return Immune.Once
end
return prev
end
function getAtckTwice(unit, prev)
if unit.hp / unit.hpMax < 0.5 then
return true
end
return prev
end
function getEnrollCost(unit, prev)
local cost = Currency.new(prev)
cost.gold = cost.gold + 100
return cost
end
function getReviveCost(unit, prev)
local cost = Currency.new(prev)
cost.gold = 10
return cost
end
function getHealCost(unit, prev)
local cost = Currency.new(prev)
cost.gold = 1
return cost
end
function getTrainingCost(unit, prev)
local cost = Currency.new(prev)
cost.gold = 1
return cost
end
function getMovement(unit, prev)
return prev + 25
end
function hasMovementBonus(unit, ground, prev)
if ground == Ground.Forest then
return true
end
return prev
end
function getScout(unit, prev)
return prev + 1
end
function getLeadership(unit, prev)
return prev + math.floor(unit.impl.level / 3)
end
function getNegotiate(unit, prev)
return prev + 10
end
function hasAbility(unit, ability, prev)
if ability == Ability.BannerUse then
return true
end
return prev
end
function getFastRetreat(unit, prev)
return true
end
function getLowerCost(unit, prev)
return 25
end
function getAttackInitiative(unit, prev)
return prev * (2 - unit.hp / unit.hpMax)
end
function getAttackReach(unit, prev)
if unit.hp / unit.hpMax < 0.5 then
return Reach.All
end
return 5 -- Some custom attack reach
end
function getAttackId(unit, prev)
return Id.new("g000aa0164")
end
function getAltAttackId(unit, prev)
return unit.leveledImpl.attack1.id -- Leveled primary attack
end
function getAttackNameTxt(unit, prev)
return Id.new("x160tgc536")
end
function getAttackDescTxt(unit, prev)
return Id.new("x160tgc537")
end
function getAttackClass(unit, prev)
return Attack.Drain
end
function getAttackSource(unit, prev)
if unit.hp > 50 then
return Source.Fire
end
return 14 -- Some custom attack source
end
function getAttackPower(unit, prev)
return 69
end
function getAttackDamage(unit, prev)
-- Note that Poison/Frostbite/Blister attack damage cannot be altered by modifiers.
-- This is by the game design.
-- Try using 'getAttackId' to replace such attacks with more/less powerful versions
-- if you want to boost/lower its damage.
return prev + 100
end
function getAttackHeal(unit, prev)
return prev + 50
end
function getAttackDrain(unit, damage, prev)
return prev + damage * 0.75
end
function getAttackLevel(unit, prev)
return 3
end
function getAttackInfinite(unit, prev)
return true
end
function getAttackCritHit(unit, prev)
return true
end
function getAttackCritDamage(unit, prev)
return 50
end
function getAttackCritPower(unit, prev)
-- Crit chance (0 : 100)
return 30
end
function getAttackDamRatio(unit, prev)
return 50
end
function getAttackDrRepeat(unit, prev)
return true
end
function getAttackDrSplit(unit, prev)
return true
end
function getAttackWards(unit, prev)
local result = prev
table.insert(result, Id.new("g000um0011")) -- Add mind ward
return result
end
function getAttack2Id(unit, prev)
if prev == Id.new("g000000000") then
return Id.new("g000aa9020")
end
return prev
end
function getAttack2NameTxt(unit, prev)
end
function getAttack2DescTxt(unit, prev)
end
function getAttack2Class(unit, prev)
end
function getAttack2Source(unit, prev)
end
function getAttack2Power(unit, prev)
end
function getAttack2Damage(unit, prev)
-- Note that Poison/Frostbite/Blister attack damage cannot be altered by modifiers.
-- This is by the game design.
-- Try using 'getAttack2Id' to replace such attacks with more/less powerful versions
-- if you want to boost/lower its damage.
end
function getAttack2Heal(unit, prev)
end
function getAttack2Drain(unit, damage, prev)
end
function getAttack2Level(unit, prev)
end
function getAttack2Infinite(unit, prev)
end
function getAttack2CritHit(unit, prev)
end
function getAttack2CritDamage(unit, prev)
end
function getAttack2CritPower(unit, prev)
end
function getAttack2DamRatio(unit, prev)
end
function getAttack2DrRepeat(unit, prev)
end
function getAttack2DrSplit(unit, prev)
end
function getAttack2Wards(unit, prev)
end
function onModifiersChanged(unit)
-- Called when this modifier is applied to the unit, and the unit gets the its modifiers changed.
-- Note that, on client's side, changed units are constantly getting rebuilt when a server sends updated data,
-- thus all of such unit's modifiers are getting re-applied (removed and added again).
-- Also note that the modifier is notified about its own addition (because it is already applied),
-- but is *not* notified about its own removal (because it is already un-applied).
end