9 |
9 |
10 ----------------- VARIABLES -------------------- |
10 ----------------- VARIABLES -------------------- |
11 -- globals |
11 -- globals |
12 local missionName = loc("Killing the specialists") |
12 local missionName = loc("Killing the specialists") |
13 local challengeObjectives = loc("Use your available weapons in order to eliminate the enemies.").."|".. |
13 local challengeObjectives = loc("Use your available weapons in order to eliminate the enemies.").."|".. |
14 loc("Each time you play this mission, enemy hogs will play in a random order.").."|".. |
14 loc("The enemy hogs play in a random order.").."|".. |
15 loc("At the start of the game each enemy hog has only the weapon that he is named after.").."|".. |
15 loc("At the start of the game each enemy hog has only the weapon that he is named after.").."|".. |
16 loc("A random hedgehog will inherit the weapons of his deceased team-mates.").."|".. |
16 loc("A random hedgehog will inherit the weapons of his deceased team-mates.").."|".. |
17 loc("If you kill a hedgehog with the respective weapon your health points will be set to 100.").."|".. |
17 loc("After you killed an enemy, you'll lose the weapon that he is named after.").."|".. |
18 loc("If you injure a hedgehog you'll get 35% of the damage dealt.").."|".. |
18 loc("If only one enemy is left, you'll get bonus ammo.").."|".. |
19 loc("Every time you kill an enemy hog your ammo will get reset next turn.").."|".. |
19 loc("If you hurt an enemy, you'll get one third of the damage dealt.").."|".. |
20 loc("The rope won't get reset.") |
20 loc("If you kill an enemy, your health will be set to 100.") |
21 -- mission objectives |
21 -- mission objectives |
22 local goals = { |
22 local goals = { |
23 ["init"] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 35000}, |
23 ["init"] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 35000}, |
24 } |
24 } |
25 -- hogs |
25 -- hogs |
51 } |
51 } |
52 -- After hero killed an enemy, his weapons will be reset in the next round |
52 -- After hero killed an enemy, his weapons will be reset in the next round |
53 local heroWeaponResetPending = false |
53 local heroWeaponResetPending = false |
54 local battleStarted = false |
54 local battleStarted = false |
55 local firstTurn = true |
55 local firstTurn = true |
|
56 |
|
57 -- Spawn health particles and print health message |
|
58 local function healthBoostAnim(gear, health, tint) |
|
59 if health < 1 then |
|
60 return |
|
61 end |
|
62 local h = 0 |
|
63 while (h < health and h < 1000) do |
|
64 local vg = AddVisualGear(GetX(gear), GetY(gear), vgtStraightShot, sprHealth, false) |
|
65 if vg ~= nil then |
|
66 SetVisualGearValues(vg, nil, nil, nil, nil, nil, nil, nil, nil, nil, tint) |
|
67 SetState(vg, sprHealth) |
|
68 end |
|
69 h = h + 5 |
|
70 end |
|
71 if math.floor(health) >= 1 then |
|
72 AddCaption(string.format(loc("+%d"), math.floor(health)), GetClanColor(GetHogClan(gear)), capgrpMessage2) |
|
73 end |
|
74 end |
56 |
75 |
57 -------------- LuaAPI EVENT HANDLERS ------------------ |
76 -------------- LuaAPI EVENT HANDLERS ------------------ |
58 |
77 |
59 function onGameInit() |
78 function onGameInit() |
60 Seed = 1 |
79 Seed = 1 |
109 ReadyTimeLeft = 35000 |
128 ReadyTimeLeft = 35000 |
110 firstTurn = false |
129 firstTurn = false |
111 end |
130 end |
112 if CurrentHedgehog ~= hero.gear then |
131 if CurrentHedgehog ~= hero.gear then |
113 enemyWeapons() |
132 enemyWeapons() |
114 elseif heroWeaponResetPending then |
|
115 refreshHeroAmmo() |
|
116 end |
133 end |
117 end |
134 end |
118 |
135 |
119 function onGearDelete(gear) |
136 function onGearDelete(gear) |
120 if isHog(gear) then |
137 if isHog(gear) then |
|
138 local healthDiff = 100 - GetHealth(hero.gear) |
121 SetHealth(hero.gear, 100) |
139 SetHealth(hero.gear, 100) |
|
140 healthBoostAnim(hero.gear, healthDiff, 0x00FF00FF) |
122 local deadHog = getHog(gear) |
141 local deadHog = getHog(gear) |
123 if deadHog.weapon == amMortar then |
142 if deadHog.weapon == amMortar then |
124 hero.mortarAmmo = 0 |
143 hero.mortarAmmo = 0 |
125 elseif deadHog.weapon == amFirePunch then |
144 elseif deadHog.weapon == amFirePunch then |
126 hero.firepunchAmmo = 0 |
145 hero.firepunchAmmo = 0 |
143 end |
162 end |
144 end |
163 end |
145 |
164 |
146 function onGearDamage(gear, damage) |
165 function onGearDamage(gear, damage) |
147 if isHog(gear) and GetHealth(hero.gear) then |
166 if isHog(gear) and GetHealth(hero.gear) then |
148 SetHealth(hero.gear, GetHealth(hero.gear) + damage/3) |
167 local bonusHealth = damage/3 |
|
168 SetHealth(hero.gear, GetHealth(hero.gear) + bonusHealth) |
|
169 healthBoostAnim(hero.gear, bonusHealth, 0xFF0000FF) |
149 end |
170 end |
150 end |
171 end |
151 |
172 |
152 function onGameTick() |
173 function onGameTick() |
153 AnimUnWait() |
174 AnimUnWait() |
154 if ShowAnimation() == false then |
175 if ShowAnimation() == false then |
155 return |
176 return |
156 end |
177 end |
157 ExecuteAfterAnimations() |
178 ExecuteAfterAnimations() |
158 CheckEvents() |
179 CheckEvents() |
|
180 end |
|
181 |
|
182 function onGameTick20() |
|
183 -- Refresh hero ammo immediately after its not his turn anymore |
|
184 if CurrentHedgehog ~= hero.gear and heroWeaponResetPending then |
|
185 refreshHeroAmmo() |
|
186 end |
159 end |
187 end |
160 |
188 |
161 -- Hide mission panel when player does anything |
189 -- Hide mission panel when player does anything |
162 function hideMissionOnAction() |
190 function hideMissionOnAction() |
163 if battleStarted then |
191 if battleStarted then |
233 |
261 |
234 function refreshHeroAmmo() |
262 function refreshHeroAmmo() |
235 local extraAmmo = 0 |
263 local extraAmmo = 0 |
236 if getAliveEnemiesCount() == 1 then |
264 if getAliveEnemiesCount() == 1 then |
237 extraAmmo = 2 |
265 extraAmmo = 2 |
|
266 PlaySound(sndShotgunReload) |
|
267 AddCaption(loc("Reinforcements! +2 of each weapon!"), GetClanColor(GetHogClan(hero.gear)), capgrpAmmoinfo) |
238 end |
268 end |
239 AddAmmo(hero.gear, amMortar, hero.mortarAmmo + extraAmmo) |
269 AddAmmo(hero.gear, amMortar, hero.mortarAmmo + extraAmmo) |
240 AddAmmo(hero.gear, amFirePunch, hero.firepunchAmmo + extraAmmo) |
270 AddAmmo(hero.gear, amFirePunch, hero.firepunchAmmo + extraAmmo) |
241 AddAmmo(hero.gear, amDEagle, hero.deagleAmmo + extraAmmo) |
271 AddAmmo(hero.gear, amDEagle, hero.deagleAmmo + extraAmmo) |
242 AddAmmo(hero.gear, amBazooka, hero.bazookaAmmo + extraAmmo) |
272 AddAmmo(hero.gear, amBazooka, hero.bazookaAmmo + extraAmmo) |