-
Notifications
You must be signed in to change notification settings - Fork 33
/
co_andy.js
313 lines (296 loc) · 10.2 KB
/
co_andy.js
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
var Constructor = function()
{
this.getCOStyles = function()
{
return ["+alt", "+alt2", "+alt3"];
};
this.getAiUsePower = function(co, powerSurplus, unitCount, repairUnits, indirectUnits, directUnits, enemyUnits, turnMode)
{
if (turnMode === GameEnums.AiTurnMode_StartOfDay)
{
if (co.canUseSuperpower())
{
return GameEnums.PowerMode_Superpower;
}
else if (powerSurplus <= 0.5 &&
co.canUsePower())
{
return CO.getAiUsePowerAtUnitCount(co, powerSurplus, turnMode, repairUnits);
}
}
};
this.init = function(co, map)
{
co.setPowerStars(3);
co.setSuperpowerStars(3);
};
this.activatePower = function(co, map)
{
var dialogAnimation = co.createPowerSentence();
var powerNameAnimation = co.createPowerScreen(GameEnums.PowerMode_Power);
dialogAnimation.queueAnimation(powerNameAnimation);
var units = co.getOwner().getUnits();
var animations = [];
var counter = 0;
units.randomize();
for (var i = 0; i < units.size(); i++)
{
var unit = units.at(i);
var animation = GameAnimationFactory.createAnimation(map, unit.getX(), unit.getY());
animation.writeDataInt32(unit.getX());
animation.writeDataInt32(unit.getY());
animation.writeDataInt32(CO_ANDY.powerHeal);
animation.setEndOfAnimationCall("ANIMATION", "postAnimationHeal");
var delay = globals.randInt(135, 265);
if (animations.length < 5)
{
delay *= i;
}
animation.setSound("power0.wav", 1, delay);
if (animations.length < 5)
{
animation.addSprite("power0", -map.getImageSize() * 1.27, -map.getImageSize() * 1.27, 0, 2, delay);
powerNameAnimation.queueAnimation(animation);
animations.push(animation);
}
else
{
animation.addSprite("power0", -map.getImageSize() * 1.27, -map.getImageSize() * 1.27, 0, 2, delay);
animations[counter].queueAnimation(animation);
animations[counter] = animation;
counter++;
if (counter >= animations.length)
{
counter = 0;
}
}
}
};
this.activateSuperpower = function(co, powerMode, map)
{
var dialogAnimation = co.createPowerSentence();
var powerNameAnimation = co.createPowerScreen(powerMode);
powerNameAnimation.queueAnimationBefore(dialogAnimation);
var units = co.getOwner().getUnits();
var animations = [];
var counter = 0;
units.randomize();
for (var i = 0; i < units.size(); i++)
{
var unit = units.at(i);
var animation = GameAnimationFactory.createAnimation(map, unit.getX(), unit.getY());
animation.writeDataInt32(unit.getX());
animation.writeDataInt32(unit.getY());
animation.writeDataInt32(CO_ANDY.superPowerHeal);
animation.setEndOfAnimationCall("ANIMATION", "postAnimationHeal");
var delay = globals.randInt(135, 265);
if (animations.length < 7)
{
delay *= i;
}
if (i % 2 === 0)
{
animation.setSound("power12_1.wav", 1, delay);
}
else
{
animation.setSound("power12_2.wav", 1, delay);
}
if (animations.length < 7)
{
animation.addSprite("power12", -map.getImageSize() * 2, -map.getImageSize() * 2, 0, 2, delay);
powerNameAnimation.queueAnimation(animation);
animations.push(animation);
}
else
{
animation.addSprite("power12", -map.getImageSize() * 2, -map.getImageSize() * 2, 0, 2, delay);
animations[counter].queueAnimation(animation);
animations[counter] = animation;
counter++;
if (counter >= animations.length)
{
counter = 0;
}
}
}
};
this.loadCOMusic = function(co, map)
{
if (CO.isActive(co))
{
switch (co.getPowerMode())
{
case GameEnums.PowerMode_Power:
audio.addMusic("resources/music/cos/power.mp3", 992, 45321);
break;
case GameEnums.PowerMode_Superpower:
audio.addMusic("resources/music/cos/superpower.mp3", 1505, 49515);
break;
case GameEnums.PowerMode_Tagpower:
audio.addMusic("resources/music/cos/tagpower.mp3", 14611, 65538);
break;
default:
audio.addMusic("resources/music/cos/andy.mp3", 4466, 74972);
break;
}
}
};
this.getCOUnitRange = function(co, map)
{
return 3;
};
this.getCOArmy = function()
{
return "OS";
};
this.superPowerHeal = 5;
this.superPowerOffBonus = 30;
this.superPowerMovementBonus = 1;
this.powerDefBonus = 20;
this.powerOffBonus = 20;
this.powerHeal = 2;
this.d2dCoZoneOffBonus = 20;
this.d2dCoZoneDefBonus = 20;
this.getOffensiveBonus = function(co, attacker, atkPosX, atkPosY,
defender, defPosX, defPosY, isDefender, action, luckmode, map)
{
if (CO.isActive(co))
{
switch (co.getPowerMode())
{
case GameEnums.PowerMode_Tagpower:
case GameEnums.PowerMode_Superpower:
return CO_ANDY.superPowerOffBonus;
case GameEnums.PowerMode_Power:
return CO_ANDY.powerOffBonus;
default:
if (co.inCORange(Qt.point(atkPosX, atkPosY), attacker))
{
return CO_ANDY.d2dCoZoneOffBonus;
}
break;
}
}
return 0;
};
this.getDeffensiveBonus = function(co, attacker, atkPosX, atkPosY,
defender, defPosX, defPosY, isAttacker, action, luckmode, map)
{
if (CO.isActive(co))
{
if (co.getPowerMode() > GameEnums.PowerMode_Off)
{
return CO_ANDY.powerDefBonus;
}
else if (co.inCORange(Qt.point(defPosX, defPosY), defender))
{
return CO_ANDY.d2dCoZoneDefBonus;
}
}
return 0;
};
this.getMovementpointModifier = function(co, unit, posX, posY, map)
{
if (CO.isActive(co))
{
if (co.getPowerMode() === GameEnums.PowerMode_Superpower ||
co.getPowerMode() === GameEnums.PowerMode_Tagpower)
{
return CO_ANDY.superPowerMovementBonus;
}
}
return 0;
};
this.getCOUnits = function(co, building, map)
{
if (CO.isActive(co))
{
var buildingId = building.getBuildingID();
if (buildingId === "FACTORY" ||
buildingId === "TOWN" ||
BUILDING.isHq(building))
{
return ["ZCOUNIT_REPAIR_TANK"];
}
}
return [];
};
this.getAiCoUnitBonus = function(co, unit, map)
{
return 1;
};
// CO - Intel
this.getBio = function(co)
{
return qsTr("A whiz with a wrench, this mechanical boy wonder earned fame as the hero who saved Macro Land in the last great war.");
};
this.getHits = function(co)
{
return qsTr("Mechanics");
};
this.getMiss = function(co)
{
return qsTr("Waking up too early");
};
this.getCODescription = function(co)
{
return qsTr("No real weaknesses or strengths. Ready to fight wherever and whenever.");
};
this.getLongCODescription = function(co, map)
{
var text = qsTr("\nSpecial Unit:\nRepair Tanks\n") +
qsTr("\nGlobal Effect: \nNone.") +
qsTr("\n\nCO Zone Effect: \nAndy's units gain +%0% firepower and +%1% defence.");
text = replaceTextArgs(text, [CO_ANDY.d2dCoZoneOffBonus, CO_ANDY.d2dCoZoneDefBonus]);
return text;
};
this.getPowerDescription = function(co)
{
var text = qsTr("Restores +%0 HP to all of Andy's units. His units gain +%1% firepower and +%2% defence.");
text = replaceTextArgs(text, [CO_ANDY.powerHeal, CO_ANDY.powerOffBonus, CO_ANDY.powerDefBonus]);
return text;
};
this.getPowerName = function(co)
{
return qsTr("Hyper Repair");
};
this.getSuperPowerDescription = function(co)
{
var text = qsTr("Restores +%0 HP to all of Andy's units. His units gain +%2 movement, +%1% firepower, and +%3% defence.");
text = replaceTextArgs(text, [CO_ANDY.superPowerHeal, CO_ANDY.superPowerOffBonus, CO_ANDY.superPowerMovementBonus, CO_ANDY.powerDefBonus]);
return text;
};
this.getSuperPowerName = function(co)
{
return qsTr("Hyper Upgrade");
};
this.getPowerSentences = function(co)
{
return [qsTr("I've got parts to spare!"),
qsTr("I'm not giving up!"),
qsTr("Time to roll up my sleeves!"),
qsTr("I haven't even cranked the engine yet!"),
qsTr("Pass me my wrench!"),
qsTr("It's time for a tune-up!"),
qsTr("Never give up, and never lose! I'm on my way!"),
qsTr("I'm not worried! I can fix anything!")];
};
this.getVictorySentences = function(co)
{
return [qsTr("We won! Woohoo!"),
qsTr("I can fix anything!"),
qsTr("I did it! Did you see that!?")];
};
this.getDefeatSentences = function(co)
{
return [qsTr("Oh, come on!"),
qsTr("Next time I see you, you're in trouble!")];
};
this.getName = function()
{
return qsTr("Andy");
};
}
Constructor.prototype = CO;
var CO_ANDY = new Constructor();