author | Wuzzy <almikes@aol.com> |
Wed, 03 May 2017 03:54:18 +0200 | |
changeset 12393 | d3a9ffdc8b85 |
parent 12231 | b4878d6cd96e |
child 13056 | b1a230d21a48 |
permissions | -rw-r--r-- |
12230 | 1 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
2 |
||
3 |
local playerHog |
|
4 |
local playerTeamName = loc("Pro Killers") |
|
5 |
local enemyTeamName = loc("Galaxy Guardians") |
|
6 |
local enemyTeam1 = { |
|
7 |
{name=loc("Rocket"), x=796, y=1184}, |
|
8 |
{name=loc("Star"), x=733, y=1525}, |
|
9 |
{name=loc("Asteroid"), x=738, y=1855}, |
|
10 |
{name=loc("Comet"), x=937, y=1318}, |
|
11 |
{name=loc("Sunflame"), x=3424, y=1536}, |
|
12 |
{name=loc("Eclipse"), x=3417, y=1081}, |
|
13 |
{name=loc("Jetpack"), x=2256, y=1246}, |
|
14 |
{name=loc("Void"), x=1587, y=1231}, |
|
15 |
} |
|
16 |
local gameStarted = false |
|
17 |
local turnNo = 0 |
|
18 |
local toleranceTimer = nil |
|
19 |
local enemyHogsLeft = #enemyTeam1 |
|
20 |
local pendingDeaths = {} |
|
21 |
local enemyHogs = {} |
|
22 |
local gameEnded = false |
|
23 |
local waitGears = 0 |
|
24 |
local hasAttacked = false |
|
25 |
local minePlaced = false |
|
26 |
local delayGear = nil |
|
27 |
||
28 |
function onGameInit() |
|
29 |
Seed = "{7e34a56b-ee7b-4fe1-8f30-352a998f3f6a}" |
|
30 |
GameFlags = gfDisableWind + gfDisableLandObjects |
|
31 |
TurnTime= 45000 |
|
32 |
CaseFreq = 0 |
|
33 |
MinesNum = 0 |
|
34 |
Explosives = 0 |
|
35 |
Theme = "EarthRise" |
|
36 |
MapGen = mgRandom |
|
37 |
MapFeatureSize = 12 |
|
38 |
-- Disable Sudden Death |
|
39 |
WaterRise = 0 |
|
40 |
HealthDecrease = 0 |
|
41 |
||
12231
b4878d6cd96e
Change voices in Big Armory, remove duplicate countdown sounds
Wuzzy <almikes@aol.com>
parents:
12230
diff
changeset
|
42 |
AddTeam(playerTeamName, 0xFF0000, "Bone", "Island", "Default", "cm_scout") |
12230 | 43 |
playerHog = AddHog(loc("Ultrasoldier"), 0, 100, "Terminator_Glasses") |
44 |
SetGearPosition(playerHog, 543, 1167) |
|
45 |
||
12231
b4878d6cd96e
Change voices in Big Armory, remove duplicate countdown sounds
Wuzzy <almikes@aol.com>
parents:
12230
diff
changeset
|
46 |
AddTeam(enemyTeamName, 0xF5F808, "Earth", "Island", "Default", "cm_galaxy") |
12230 | 47 |
for i=1,8 do |
48 |
local hogID = AddHog(enemyTeam1[i].name, 0, 100, "NoHat") |
|
49 |
table.insert(enemyHogs, hogID) |
|
50 |
SetGearPosition(hogID, enemyTeam1[i].x, enemyTeam1[i].y) |
|
51 |
end |
|
52 |
end |
|
53 |
||
54 |
function onAmmoStoreInit() |
|
55 |
||
56 |
SetAmmo(amGrenade, 9, 0, 0, 1) |
|
57 |
SetAmmo(amClusterBomb, 9, 0, 0, 1) |
|
58 |
SetAmmo(amBazooka, 9, 0, 0, 1) |
|
59 |
SetAmmo(amBee, 9, 0, 0, 1) |
|
60 |
SetAmmo(amShotgun, 9, 0, 0, 1) |
|
61 |
SetAmmo(amPickHammer, 9, 0, 0, 1) |
|
62 |
SetAmmo(amSkip, 9, 0, 0, 1) |
|
63 |
SetAmmo(amRope, 9, 0, 0, 1) |
|
64 |
SetAmmo(amMine, 9, 0, 0, 1) |
|
65 |
SetAmmo(amDEagle, 9, 0, 0, 1) |
|
66 |
SetAmmo(amDynamite, 9, 0, 0, 1) |
|
67 |
SetAmmo(amFirePunch, 9, 0, 0, 1) |
|
68 |
SetAmmo(amWhip, 9, 0, 0, 1) |
|
69 |
SetAmmo(amBaseballBat, 9, 0, 0, 1) |
|
70 |
SetAmmo(amParachute, 9, 0, 0, 1) |
|
71 |
SetAmmo(amAirAttack, 9, 0, 0, 1) |
|
72 |
SetAmmo(amMineStrike, 9, 0, 0, 1) |
|
73 |
SetAmmo(amBlowTorch, 9, 0, 0, 1) |
|
74 |
SetAmmo(amGirder, 9, 0, 0, 1) |
|
75 |
SetAmmo(amTeleport, 9, 0, 0, 1) |
|
76 |
SetAmmo(amSwitch, 9, 0, 0, 1) |
|
77 |
SetAmmo(amMortar, 9, 0, 0, 1) |
|
78 |
SetAmmo(amKamikaze, 9, 0, 0, 1) |
|
79 |
SetAmmo(amCake, 9, 0, 0, 1) |
|
80 |
SetAmmo(amSeduction, 9, 0, 0, 1) |
|
81 |
SetAmmo(amWatermelon, 9, 0, 0, 1) |
|
82 |
SetAmmo(amHellishBomb, 9, 0, 0, 1) |
|
83 |
SetAmmo(amNapalm, 9, 0, 0, 1) |
|
84 |
SetAmmo(amDrill, 9, 0, 0, 1) |
|
85 |
SetAmmo(amBallgun, 9, 0, 0, 1) |
|
86 |
SetAmmo(amRCPlane, 9, 0, 0, 1) |
|
87 |
SetAmmo(amLowGravity, 9, 0, 0, 1) |
|
88 |
SetAmmo(amExtraDamage, 9, 0, 0, 1) |
|
89 |
SetAmmo(amInvulnerable, 9, 0, 0, 1) |
|
90 |
SetAmmo(amLaserSight, 9, 0, 0, 1) |
|
91 |
SetAmmo(amVampiric, 9, 0, 0, 1) |
|
92 |
SetAmmo(amSniperRifle, 9, 0, 0, 1) |
|
93 |
SetAmmo(amJetpack, 9, 0, 0, 1) |
|
94 |
SetAmmo(amMolotov, 9, 0, 0, 1) |
|
95 |
SetAmmo(amBirdy, 9, 0, 0, 1) |
|
96 |
SetAmmo(amPortalGun, 9, 0, 0, 1) |
|
97 |
SetAmmo(amPiano, 9, 0, 0, 1) |
|
98 |
SetAmmo(amGasBomb, 9, 0, 0, 1) |
|
99 |
SetAmmo(amSineGun, 9, 0, 0, 1) |
|
100 |
SetAmmo(amFlamethrower, 9, 0, 0, 1) |
|
101 |
SetAmmo(amSMine, 9, 0, 0, 1) |
|
102 |
SetAmmo(amHammer, 9, 0, 0, 1) |
|
103 |
SetAmmo(amResurrector, 9, 0, 0, 1) |
|
104 |
SetAmmo(amDrillStrike, 9, 0, 0, 1) |
|
105 |
SetAmmo(amSnowball, 9, 0, 0, 1) |
|
106 |
SetAmmo(amTardis, 9, 0, 0, 1) |
|
107 |
SetAmmo(amLandGun, 9, 0, 0, 1) |
|
108 |
SetAmmo(amIceGun, 9, 0, 0, 1) |
|
109 |
SetAmmo(amKnife, 9, 0, 0, 1) |
|
110 |
SetAmmo(amRubber, 9, 0, 0, 1) |
|
111 |
SetAmmo(amAirMine, 9, 0, 0, 1) |
|
112 |
SetAmmo(amDuck, 9, 0, 0, 1) |
|
113 |
||
114 |
SetAmmo(amExtraTime, 2, 0, 0, 0) |
|
115 |
||
116 |
end |
|
117 |
||
118 |
function onGameStart() |
|
119 |
SendHealthStatsOff() |
|
120 |
ShowMission(loc("Big Armory"), loc("Scenario"), loc("Kill all enemy hedgehogs in a single turn."), -amBazooka, 0) |
|
121 |
SetWind(15) |
|
122 |
end |
|
123 |
||
124 |
function onGameTick20() |
|
125 |
if not gameStarted and turnNo == 1 and TurnTimeLeft < TurnTime then |
|
126 |
gameStarted = true |
|
127 |
elseif gameStarted and not gameEnded then |
|
128 |
if isPlayerAlive() then |
|
129 |
if enemyHogsLeft - countPending() <= 0 then |
|
130 |
TurnTimeLeft = 0 |
|
131 |
if delayGear then |
|
132 |
DeleteGear(delayGear) |
|
133 |
end |
|
134 |
return |
|
135 |
elseif (enemyHogsLeft > 0) and TurnTimeLeft < 40 then |
|
136 |
if not toleranceTimer and waitGears <= 0 then |
|
137 |
SetInputMask(0) |
|
138 |
SetGearMessage(playerHog, 0) |
|
139 |
if not minePlaced then |
|
140 |
TurnTimeLeft = 10000000 |
|
141 |
end |
|
142 |
if hasAttacked then |
|
143 |
if minePlaced then |
|
144 |
toleranceTimer = 12000 |
|
145 |
else |
|
146 |
toleranceTimer = 7500 |
|
147 |
end |
|
148 |
else |
|
149 |
PlaySound(sndBoring, playerHog) |
|
150 |
toleranceTimer = 5020 |
|
151 |
end |
|
152 |
return |
|
153 |
end |
|
154 |
end |
|
155 |
if toleranceTimer ~= nil then |
|
156 |
if toleranceTimer % 1000 == 0 and toleranceTimer > 0 and toleranceTimer <= 5000 then |
|
157 |
AddCaption(string.format(loc("Mission failure in %d s"), div(toleranceTimer, 1000)), 0xFFFFFFFF, capgrpGameState) |
|
158 |
end |
|
159 |
if waitGears <= 0 then |
|
160 |
if toleranceTimer <= 0 then |
|
161 |
lose() |
|
162 |
return |
|
163 |
end |
|
164 |
toleranceTimer = toleranceTimer - 20 |
|
165 |
end |
|
166 |
return |
|
167 |
end |
|
168 |
end |
|
169 |
end |
|
170 |
end |
|
171 |
||
172 |
function onGearAdd(gear) |
|
173 |
local gt = GetGearType(gear) |
|
174 |
if gt == gtIceGun or gt == gtPickHammer or gt == gtSineGunShot or gt == gtCake |
|
175 |
or gt == gtTeleport or gt == gtFlamethrower or gt == gtBallGun or gt == gtSeduction |
|
176 |
or gt == gtAirAttack or gt == gtMine or gt == gtSMine or gt == gtAirMine |
|
177 |
or (isWaitGear(gear) and gt ~= gtFlame) then |
|
178 |
--[[ This is a hack to prevent the turn from instantly ending |
|
179 |
after using a weapon with a retreat time of 0. For some reason, there would be |
|
180 |
are also problems with the hellish-hand grenade without this hack. |
|
181 |
It spawns an invisible grenade with disabled gravity at (0,0) with a |
|
182 |
high timer, which will delay the end of the turn. ]] |
|
183 |
if delayGear == nil then |
|
184 |
delayGear = AddGear(0, 0, gtGrenade, gstNoGravity + gstInvisible, 0, 0, 2147483647) |
|
185 |
end |
|
186 |
end |
|
187 |
if gt == gtMine or gt == gtSMine or gt == gtAirMine then |
|
188 |
minePlaced = true |
|
189 |
end |
|
190 |
if isWaitGear(gear) then |
|
191 |
waitGears = waitGears + 1 |
|
192 |
end |
|
193 |
if gt == gtAirAttack then |
|
194 |
hasAttacked = true |
|
195 |
end |
|
196 |
end |
|
197 |
||
198 |
function onGearDelete(gear) |
|
199 |
if isWaitGear(gear) then |
|
200 |
waitGears = waitGears - 1 |
|
201 |
end |
|
202 |
if GetGearType(gear) == gtHedgehog then |
|
203 |
if GetHogTeamName(gear) == enemyTeamName then |
|
204 |
enemyHogsLeft = enemyHogsLeft - 1 |
|
205 |
pendingDeaths[gear] = nil |
|
206 |
if enemyHogsLeft <= 0 then |
|
207 |
win() |
|
208 |
end |
|
209 |
end |
|
210 |
end |
|
211 |
end |
|
212 |
||
213 |
function countPending() |
|
214 |
local p = 0 |
|
215 |
for h, v in pairs(pendingDeaths) do |
|
216 |
if v then |
|
217 |
p = p + 1 |
|
218 |
end |
|
219 |
end |
|
220 |
return p |
|
221 |
end |
|
222 |
||
223 |
function isPlayerAlive() |
|
224 |
if GetGearType(playerHog) == gtHedgehog then |
|
225 |
if GetHealth(playerHog) == 0 then |
|
226 |
return false |
|
227 |
else |
|
228 |
local _, gearDamage |
|
229 |
_, _, _, _, _, _, _, _, _, _, _, gearDamage = GetGearValues(playerHog) |
|
230 |
return (GetHealth(playerHog) - gearDamage) > 0 |
|
231 |
end |
|
232 |
else |
|
233 |
return false |
|
234 |
end |
|
235 |
end |
|
236 |
||
237 |
function onGearDamage(gear, damage) |
|
238 |
if GetGearType(gear) == gtHedgehog then |
|
239 |
if GetHogTeamName(gear) == enemyTeamName then |
|
240 |
local _, gearDamage |
|
241 |
_, _, _, _, _, _, _, _, _, _, _, gearDamage = GetGearValues(gear) |
|
242 |
if (GetHealth(gear) - gearDamage) <= 0 then |
|
243 |
pendingDeaths[gear] = true |
|
244 |
end |
|
245 |
end |
|
246 |
end |
|
247 |
end |
|
248 |
||
249 |
function isWaitGear(gear) |
|
250 |
local gt = GetGearType(gear) |
|
251 |
return gt == gtBall or gt == gtHellishBomb or gt == gtWatermelon or gt == gtMelonPiece |
|
252 |
or (gt == gtFlame and band(GetState(gear), gsttmpFlag) == 0) |
|
253 |
or gt == gtDrill or gt == gtAirAttack or gt == gtAirBomb or gt == gtCluster |
|
254 |
or gt == gtEgg or gt == gtHammerHit or gt == gtNapalmBomb or gt == gtPoisonCloud |
|
255 |
or gt == gtGasBomb |
|
256 |
end |
|
257 |
||
258 |
function onNewTurn() |
|
259 |
turnNo = turnNo + 1 |
|
260 |
if turnNo > 1 then |
|
261 |
PlaySound(sndBoring, playerHog) |
|
262 |
lose() |
|
263 |
end |
|
264 |
end |
|
265 |
||
266 |
function onHogAttack(ammoType) |
|
267 |
-- Set hasAttacked if hog attacked NOT with a non-turn ending weapon |
|
268 |
if ammoType ~= amNothing and ammoType ~= amSkip and ammoType ~= amJetpack and ammoType ~= amGirder and ammoType ~= amRubber |
|
269 |
and ammoType ~= amLandGun and ammoType ~= amParachute and ammoType ~= amResurrector and ammoType ~= amRope and ammoType ~= amSwitcher |
|
270 |
and ammoType ~= amExtraDamage and ammoType ~= amExtraTime and ammoType ~= amLowGravity and ammoType ~= amInvulnerable |
|
271 |
and ammoType ~= amLaserSight and ammoType ~= amVampiric and ammoType ~= amPortalGun and ammoType ~= amSnowball then |
|
272 |
hasAttacked = true |
|
273 |
end |
|
274 |
if ammoType == amSkip and enemyHogsLeft > 0 then |
|
275 |
PlaySound(sndCoward, playerHog) |
|
276 |
lose() |
|
277 |
return |
|
278 |
end |
|
279 |
end |
|
280 |
||
281 |
function lose() |
|
282 |
if not gameEnded then |
|
283 |
PlaySound(sndStupid, playerHog) |
|
284 |
local mission, achievement |
|
285 |
mission = loc("You failed to kill all enemies in this turn.") |
|
286 |
achievement = loc("You failed to kill all enemies in a single turn.") |
|
287 |
AddCaption(loc("Mission failed!"), 0xFFFFFFFF, capgrpGameState) |
|
288 |
ShowMission(loc("Big Armory"), loc("Scenario"), mission, -amBazooka, 5000) |
|
289 |
SendStat(siGameResult, loc("You lose!")) |
|
290 |
SendStat(siCustomAchievement, achievement) |
|
291 |
SendStat(siPlayerKills, tostring(0), enemyTeamName) |
|
292 |
SendStat(siPlayerKills, tostring(8-enemyHogsLeft), playerTeamName) |
|
293 |
gameEnded = true |
|
294 |
EndGame() |
|
295 |
end |
|
296 |
end |
|
297 |
||
298 |
function win() |
|
299 |
if not gameEnded then |
|
300 |
AddCaption(loc("Victory!"), 0xFFFFFFFF, capgrpGameState) |
|
301 |
ShowMission(loc("Big Armory"), loc("Scenario"), loc("Congratulations! You win."), 4, 5000) |
|
302 |
PlaySound(sndVictory, playerHog) |
|
303 |
SendStat(siGameResult, loc("You win!")) |
|
304 |
SendStat(siCustomAchievement, loc("You have killed all enemies.")) |
|
305 |
SendStat(siPlayerKills, tostring(8-enemyHogsLeft), playerTeamName) |
|
306 |
SendStat(siPlayerKills, tostring(0), enemyTeamName) |
|
307 |
gameEnded = true |
|
308 |
EndGame() |
|
309 |
end |
|
310 |
end |