-
Notifications
You must be signed in to change notification settings - Fork 33
/
co_sami.js
430 lines (415 loc) · 15.3 KB
/
co_sami.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
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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
var Constructor = function()
{
this.getCOStyles = function()
{
return ["+alt", "+alt2", "+alt3"];
};
this.init = function(co, map)
{
co.setPowerStars(3);
co.setSuperpowerStars(6);
};
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/sami.mp3", 1934, 62918);
break;
}
}
};
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);
if (unit.getUnitType() === GameEnums.UnitType_Infantry)
{
var animation = GameAnimationFactory.createAnimation(map, unit.getX(), unit.getY());
var delay = globals.randInt(135, 265);
if (animations.length < 5)
{
delay *= i;
}
if (i % 2 === 0)
{
animation.setSound("power10_1.wav", 1, delay);
}
else
{
animation.setSound("power10_2.wav", 1, delay);
}
if (animations.length < 5)
{
animation.addSprite("power10", -map.getImageSize() * 1.27, -map.getImageSize() * 1.27, 0, 2, delay);
powerNameAnimation.queueAnimation(animation);
animations.push(animation);
}
else
{
animation.addSprite("power10", -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);
if (unit.getUnitType() === GameEnums.UnitType_Infantry)
{
var animation = GameAnimationFactory.createAnimation(map, unit.getX(), unit.getY());
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.getCOUnitRange = function(co, map)
{
return 3;
};
this.getCOArmy = function()
{
return "OS";
};
this.superPowerOffBonus = 80;
this.superpowerMovementPoints = 2;
this.superpowerCaptureMultiplier = 20;
this.powerOffBonus = 50;
this.powerDefBonus = 10;
this.powerBaseOffBonus = 10;
this.powerMovementPoints = 1;
this.powerMovementCostModifier = 0;
this.d2dCoZoneOffBonus = 50;
this.d2dCoZoneBaseOffBonus = 10;
this.d2dCoZoneDefBonus = 10;
this.d2dInfOffBonus = 20;
this.d2dInfDefBonus = 0;
this.d2dDirectOffBonus = -10;
this.d2dCaptureMultiplier = 0.5;
this.d2dTransporterMovementPoints = 1;
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:
if (attacker.getUnitType() === GameEnums.UnitType_Infantry)
{
return CO_SAMI.superPowerOffBonus;
}
else if (attacker.getBaseMaxRange() === 1)
{
return CO_SAMI.powerBaseOffBonus + CO_SAMI.d2dDirectOffBonus;
}
return CO_SAMI.powerBaseOffBonus;
case GameEnums.PowerMode_Power:
if (attacker.getUnitType() === GameEnums.UnitType_Infantry)
{
return CO_SAMI.powerOffBonus;
}
else if (attacker.getBaseMaxRange() === 1)
{
return CO_SAMI.powerBaseOffBonus + CO_SAMI.d2dDirectOffBonus;
}
return CO_SAMI.powerBaseOffBonus;
default:
if (co.inCORange(Qt.point(atkPosX, atkPosY), attacker))
{
if (attacker.getUnitType() === GameEnums.UnitType_Infantry)
{
return CO_SAMI.d2dCoZoneOffBonus;
}
else if (attacker.getBaseMaxRange() === 1)
{
return CO_SAMI.d2dCoZoneBaseOffBonus + CO_SAMI.d2dDirectOffBonus;
}
return CO_SAMI.d2dCoZoneBaseOffBonus;
}
else if (attacker.getUnitType() === GameEnums.UnitType_Infantry)
{
if (map === null ||
(map !== null && map.getGameRules().getCoGlobalD2D()))
{
return CO_SAMI.d2dInfOffBonus;
}
}
break;
}
if (attacker.getBaseMaxRange() === 1)
{
if (map === null ||
(map !== null && map.getGameRules().getCoGlobalD2D()))
{
return CO_SAMI.d2dDirectOffBonus;
}
}
}
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)
{
if (defender.getUnitType() === GameEnums.UnitType_Infantry)
{
return CO_SAMI.powerDefBonus + CO_SAMI.d2dInfDefBonus;
}
return CO_SAMI.powerDefBonus;
}
else if (co.inCORange(Qt.point(defPosX, defPosY), defender))
{
return CO_SAMI.d2dCoZoneDefBonus;
}
else if (defender.getUnitType() === GameEnums.UnitType_Infantry)
{
if (map === null ||
(map !== null && map.getGameRules().getCoGlobalD2D()))
{
return CO_SAMI.d2dInfDefBonus;
}
}
}
return 0;
};
this.getCaptureBonus = function(co, unit, posX, posY, map)
{
if (CO.isActive(co))
{
var hp = unit.getHpRounded();
if (co.getPowerMode() === GameEnums.PowerMode_Superpower ||
co.getPowerMode() === GameEnums.PowerMode_Tagpower)
{
return hp * CO_SAMI.superpowerCaptureMultiplier;
}
else if (map === null ||
(map !== null && map.getGameRules().getCoGlobalD2D()))
{
return hp * CO_SAMI.d2dCaptureMultiplier;
}
}
return 0;
};
this.getMovementpointModifier = function(co, unit, posX, posY, map)
{
if (CO.isActive(co))
{
if (unit.isTransporter())
{
return CO_SAMI.d2dTransporterMovementPoints;
}
if (unit.getUnitType() === GameEnums.UnitType_Infantry)
{
switch (co.getPowerMode())
{
case GameEnums.PowerMode_Tagpower:
case GameEnums.PowerMode_Superpower:
return CO_SAMI.superpowerMovementPoints;
case GameEnums.PowerMode_Power:
return CO_SAMI.powerMovementPoints;
default:
return 0;
}
}
}
return 0;
};
this.getMovementcostModifier = function(co, unit, posX, posY, map)
{
if (CO.isActive(co))
{
if (unit.getOwner() === co.getOwner() &&
unit.getUnitType() === GameEnums.UnitType_Infantry)
{
switch (co.getPowerMode())
{
case GameEnums.PowerMode_Tagpower:
case GameEnums.PowerMode_Superpower:
case GameEnums.PowerMode_Power:
return CO_SAMI.powerMovementCostModifier;
default:
return 0;
}
}
}
return 0;
};
this.getAiCoUnitBonus = function(co, unit, map)
{
if (unit.getUnitID() !== "INFANTRY")
{
if (unit.getUnitType() === GameEnums.UnitType_Infantry)
{
return 8;
}
else if (unit.getBaseMaxRange() === 1)
{
return -1;
}
}
return 2;
};
this.getAiCoBuildRatioModifier = function(co, map)
{
return 0.5;
};
this.getCOUnits = function(co, building, map)
{
if (CO.isActive(co))
{
var buildingId = building.getBuildingID();
if (buildingId === "FACTORY" ||
buildingId === "TOWN" ||
BUILDING.isHq(building))
{
return ["ZCOUNIT_COMMANDO"];
}
}
return [];
};
// CO - Intel
this.getBio = function(co)
{
return qsTr("A strong-willed Orange Star special forces captain who loves long hair, despite having short hair for some reason.");
};
this.getHits = function(co)
{
return qsTr("Chocolate");
};
this.getMiss = function(co)
{
return qsTr("Cowards");
};
this.getCODescription = function(co)
{
return qsTr("As an infantry specialist, her footsoldiers do more damage and capture faster. Her other direct-combat units have weaker firepower.");
};
this.getLongCODescription = function(co, map)
{
var values = [0, 0, 0, 0, 0];
if (map === null ||
(map !== null && map.getGameRules().getCoGlobalD2D()))
{
values = [CO_SAMI.d2dTransporterMovementPoints, CO_SAMI.d2dCaptureMultiplier * 100, CO_SAMI.d2dInfOffBonus, CO_SAMI.d2dInfDefBonus, CO_SAMI.d2dDirectOffBonus];
}
var text = qsTr("\nSpecial Unit:\nCommando\n") +
qsTr("\nGlobal Effect: \nSami's footsoldiers gain +%2% firepower, +%3% defence, and a +%1% capture bonus. Her non-combat transporter units have +%0 movement. Her other direct-combat units have %4% firepower.") +
qsTr("\n\nCO Zone Effect: \nSami's footsoldiers gain +%5% firepower. Her other direct units have -%6% firepower. Her indirect units gain +%7% firepower. All of her units gain +%8% defence.");
text = replaceTextArgs(text, [values[0], values[1], values[2], values[3], values[4], CO_SAMI.d2dCoZoneOffBonus, CO_SAMI.d2dCoZoneBaseOffBonus+CO_SAMI.d2dDirectOffBonus, CO_SAMI.d2dCoZoneBaseOffBonus, CO_SAMI.d2dCoZoneDefBonus]);
return text;
};
this.getPowerDescription = function(co)
{
var text = qsTr("Sami's footsoldiers gain +%0 movement and +%1% firepower. Her other direct units have -%2% firepower. Her indirect units gain +%3% firepower. All of her units gain +%4% defence.");
text = replaceTextArgs(text, [CO_SAMI.powerMovementPoints, CO_SAMI.powerOffBonus, CO_SAMI.powerBaseOffBonus+CO_SAMI.d2dDirectOffBonus, CO_SAMI.powerBaseOffBonus, CO_SAMI.powerDefBonus]);
return text;
};
this.getPowerName = function(co)
{
return qsTr("Double Time");
};
this.getSuperPowerDescription = function(co)
{
var text = qsTr("Sami's footsoldiers gain +%1 movement, +%2% firepower, and an outrageous +%0% capture bonus. Her other direct units have -%3% firepower. Her indirect units gain +%4% firepower. All of her units gain +%5% defence.");
text = replaceTextArgs(text, [CO_SAMI.superpowerCaptureMultiplier * 100, CO_SAMI.superpowerMovementPoints, CO_SAMI.superPowerOffBonus, CO_SAMI.powerBaseOffBonus+CO_SAMI.d2dDirectOffBonus, CO_SAMI.powerBaseOffBonus, CO_SAMI.powerDefBonus]);
return text;
};
this.getSuperPowerName = function(co)
{
return qsTr("Victory March");
};
this.getPowerSentences = function(co)
{
return [qsTr("You're not bad! Now it's my turn!"),
qsTr("All right! Time to end this!"),
qsTr("Infantry... Assault!"),
qsTr("Ready or not, here I come!"),
qsTr("All right, it's make-or-break time!"),
qsTr("Move out, grunts!")];
};
this.getVictorySentences = function(co)
{
return [qsTr("Mission accomplished! Awaiting further orders!"),
qsTr("Commandos always complete their mission."),
qsTr("Score one for the grunts!")];
};
this.getDefeatSentences = function(co)
{
return [qsTr("Things would be easier if we had more infantry units..."),
qsTr("Next time's for real. I won't lose focus.")];
};
this.getName = function()
{
return qsTr("Sami");
};
}
Constructor.prototype = CO;
var CO_SAMI = new Constructor();