1 ------------------------------------ |
1 ------------------------------------ |
2 -- TUMBLER |
2 -- TUMBLER |
3 -- v.0.7.1 |
3 -- v.0.8.0 |
4 ------------------------------------ |
4 ------------------------------------ |
|
5 |
|
6 --[[ |
|
7 SCRIPT PARAMETER |
|
8 The script is configured with the script parameter. |
|
9 |
|
10 Additional configuration in the game scheme is permitted. |
|
11 |
|
12 The script parameter is a comma-separated list of key=value pairs. |
|
13 |
|
14 The values are always whole numbers, the keys are listed below. |
|
15 |
|
16 Key Default Description |
|
17 ---------------------------------------------------------------------- |
|
18 spawnbarrels 2 Number of barrels that spawn per turn |
|
19 spawnmines 4 Number of mines that spawn per turn |
|
20 ammoflamer 50 Initial fuel/ammo of Flamer |
|
21 ammobarrel 2 Initial ammo of Barrel Launcher |
|
22 ammomine 1 Initial ammo of Mine Deployer |
|
23 minetimerplaced 1000 Mine timer of mines dropped from Mine Deployer (!) in milliseconds |
|
24 bonustime 25 Bonus time in utility crates, in seconds |
|
25 bonusflames 800 Flamer fuel bonus in ammo crates |
|
26 chanceammo 30 Chance (in %) that an ammo crate will drop before a turn |
|
27 chancetime 50 Chance (in %) that an utility crate (extra time) will drop before a turn |
|
28 |
|
29 |
|
30 EXAMPLES: |
|
31 |
|
32 ammoflamer=800, ammomine=5 |
|
33 --> Starts the game with 800 Flamer fuel and 5 Mine Deployer mines. |
|
34 |
|
35 chancetime=0 |
|
36 --> No clock crates. |
|
37 |
|
38 |
|
39 GAME SCHEME CONFIGURATION |
|
40 The script recognizes most game modifiers and settings, but changing the following game modifiers |
|
41 will have no effect: |
|
42 - Artillery |
|
43 - Tag Team |
|
44 - Shared ammo |
|
45 - Per-hog ammo |
|
46 - Place hogs |
|
47 - Invulnerable |
|
48 - Reset weapons |
|
49 ]] |
|
50 |
5 |
51 |
6 HedgewarsScriptLoad("/Scripts/Locale.lua") |
52 HedgewarsScriptLoad("/Scripts/Locale.lua") |
7 HedgewarsScriptLoad("/Scripts/Tracker.lua") |
53 HedgewarsScriptLoad("/Scripts/Tracker.lua") |
|
54 HedgewarsScriptLoad("/Scripts/Params.lua") |
8 |
55 |
9 local fMod = 1000000 -- use this for dev and .16+ games |
56 local fMod = 1000000 -- use this for dev and .16+ games |
10 |
57 |
11 local leftOn = false |
58 local leftOn = false |
12 local rightOn = false |
59 local rightOn = false |
114 -- version 0.7.1 |
173 -- version 0.7.1 |
115 ------------------------ |
174 ------------------------ |
116 |
175 |
117 -- redraw HUD on screen resolution change |
176 -- redraw HUD on screen resolution change |
118 |
177 |
|
178 ------------------------ |
|
179 -- version 0.8.0 |
|
180 ------------------------ |
|
181 -- Allow detailed configuration with script parameter (see above) |
|
182 -- Alternative weapon selection with slot keys |
|
183 --- Slot 1: Barrel Launcher |
|
184 --- Slot 2: Mine Deployer |
|
185 --- Slot 3: Flamer |
|
186 -- Add mine/barrel launch sounds |
|
187 -- Improved ammo display |
|
188 -- Denied sound + message when trying to fire empty ammo weapon |
|
189 -- Slightly better mission description |
|
190 --- The old hacks by (ab)using MinesNum, Explosives and HealthCaseAmount have been removed |
|
191 -- Permanently disable some gameflags which currently won't work together with this script (see above) |
|
192 -- Show flamer ammo as fuel everywhere (no more percentage confusion) |
|
193 |
119 --------------------------- |
194 --------------------------- |
120 -- some other ideas/things |
195 -- some other ideas/things |
121 --------------------------- |
196 --------------------------- |
122 --[[ |
197 --[[ |
123 -- add better gameflag handling |
198 -- allow invulnerability mode (currently broken, thus disabled) |
124 -- fix flamer "shots remaining" message on start or choose a standard versus % |
|
125 -- add more sounds |
|
126 -- better barrel/minespawn effects |
199 -- better barrel/minespawn effects |
127 -- separate grab distance for mines/barrels |
200 -- separate grab distance for mines/barrels |
|
201 -- bug: message color for remaining ammo does not change if two times the same message |
|
202 (but in different desired color) is shown in quick succession (i.e. "Out of ammo!" for all weapons) |
128 -- [probably not] make barrels always explode? |
203 -- [probably not] make barrels always explode? |
129 -- [probably not] persistent ammo? |
204 -- [probably not] persistent ammo? |
130 -- [probably not] dont hurt tumblers and restore their health at turn end? |
205 -- [probably not] dont hurt tumblers and restore their health at turn end? |
131 ]] |
206 ]] |
132 |
207 |
274 if (GetGearType(gear) == gtExplosives) then |
349 if (GetGearType(gear) == gtExplosives) then |
275 |
350 |
276 wepAmmo[0] = wepAmmo[0] + 1 |
351 wepAmmo[0] = wepAmmo[0] + 1 |
277 PlaySound(sndShotgunReload) |
352 PlaySound(sndShotgunReload) |
278 DeleteGear(gear) |
353 DeleteGear(gear) |
279 AddCaption(wep[0] .. " " .. loc("ammo extended!"), wepCol[0], capgrpAmmoinfo ) |
354 AddCaption(loc("+1 barrel!"), wepCol[0], capgrpAmmoinfo ) |
280 DrawTag(1) |
355 DrawTag(1) |
281 |
356 |
282 barrelsEaten = barrelsEaten + 1 |
357 barrelsEaten = barrelsEaten + 1 |
283 if barrelsEaten == 5 then |
358 if barrelsEaten == 5 then |
284 AddCaption(loc("Achievement Unlocked") .. ": " .. loc("Barrel Eater!"),0xffba00ff,capgrpMessage2) |
359 AddCaption(loc("Achievement obtained: Barrel Eater!"),0xffba00ff,capgrpMessage2) |
285 end |
360 end |
286 |
361 |
287 elseif (GetGearType(gear) == gtMine) then |
362 elseif (GetGearType(gear) == gtMine) then |
288 wepAmmo[1] = wepAmmo[1] + 1 |
363 wepAmmo[1] = wepAmmo[1] + 1 |
289 PlaySound(sndShotgunReload) |
364 PlaySound(sndShotgunReload) |
290 DeleteGear(gear) |
365 DeleteGear(gear) |
291 AddCaption(wep[1] .. " " .. loc("ammo extended!"), wepCol[1], capgrpAmmoinfo ) |
366 AddCaption(loc("+1 mine!"), wepCol[1], capgrpAmmoinfo ) |
292 DrawTag(2) |
367 DrawTag(2) |
293 |
368 |
294 minesEaten = minesEaten + 1 |
369 minesEaten = minesEaten + 1 |
295 if minesEaten == 5 then |
370 if minesEaten == 5 then |
296 AddCaption(loc("Achievement Unlocked") .. ": " .. loc("Mine Eater!"),0xffba00ff,capgrpMessage2) |
371 AddCaption(loc("Achievement obtained: Mine Eater!"),0xffba00ff,capgrpMessage2) |
297 end |
372 end |
298 |
373 |
299 end |
374 end |
300 |
375 |
301 else |
|
302 --AddCaption("There is nothing here...") |
|
303 end |
376 end |
304 |
377 |
305 end |
378 end |
306 |
379 |
307 -- check proximity on crates |
380 -- check proximity on crates |
309 |
382 |
310 dist = GetGearDistance(gear) |
383 dist = GetGearDistance(gear) |
311 |
384 |
312 if (dist < 1600) and (GetGearType(gear) == gtCase) then |
385 if (dist < 1600) and (GetGearType(gear) == gtCase) then |
313 |
386 |
314 if GetHealth(gear) > 0 then |
387 if band(GetGearPos(gear), 0x4) ~= 0 then |
315 |
388 |
316 AddCaption(loc("Tumbling Time Extended!"), 0xffba00ff, capgrpMessage2 ) |
389 AddCaption(string.format(loc("+%d seconds!"), bonusTime), 0xffba00ff, capgrpMessage2 ) |
317 |
390 |
318 TimeLeft = TimeLeft + HealthCaseAmount --5 --5s |
391 TimeLeft = TimeLeft + bonusTime |
319 DrawTag(0) |
392 DrawTag(0) |
320 --PlaySound(sndShotgunReload) |
393 PlaySound(sndExtraTime) |
|
394 elseif band(GetGearPos(gear), 0x1) ~= 0 then |
|
395 wepAmmo[2] = wepAmmo[2] + bonusFlames |
|
396 PlaySound(sndShotgunReload) |
|
397 AddCaption(string.format(loc("+%d flamer fuel!"), bonusFlames), wepCol[2], capgrpAmmoinfo ) |
|
398 DrawTag(3) |
|
399 end |
|
400 |
|
401 DeleteGear(gear) |
|
402 |
|
403 end |
|
404 |
|
405 end |
|
406 |
|
407 function shotsRemainingMessage() |
|
408 local shotsMsg |
|
409 if wepAmmo[wepIndex] <= 0 then |
|
410 shotsMsg = loc("Out of ammo!") |
|
411 else |
|
412 if wepIndex == 2 then |
|
413 shotsMsg = loc("%d fuel remaining") |
321 else |
414 else |
322 wepAmmo[2] = wepAmmo[2] + 800 |
415 shotsMsg = loc("%d shots remaining") |
323 PlaySound(sndShotgunReload) |
416 end |
324 AddCaption(wep[2] .. " " .. loc("fuel extended!"), wepCol[2], capgrpAmmoinfo ) |
417 end |
325 DrawTag(3) |
418 AddCaption(string.format(shotsMsg, wepAmmo[wepIndex]), wepCol[wepIndex],capgrpMessage2) |
326 end |
419 end |
327 |
420 |
328 DeleteGear(gear) |
421 function ChangeWeapon(newIndex) |
329 |
422 if newIndex == nil then |
330 end |
423 wepIndex = wepIndex + 1 |
331 |
424 if wepIndex == wepCount then |
332 end |
425 wepIndex = 0 |
333 |
426 end |
334 function ChangeWeapon() |
427 else |
335 |
428 wepIndex = newIndex |
336 wepIndex = wepIndex + 1 |
429 end |
337 if wepIndex == wepCount then |
430 |
338 wepIndex = 0 |
431 local selText |
339 end |
432 if wepIndex == 0 then |
340 |
433 selText = loc("Barrel Launcher selected!") |
341 AddCaption(wep[wepIndex] .. " " .. loc("selected!"), wepCol[wepIndex],capgrpAmmoinfo ) |
434 elseif wepIndex == 1 then |
342 AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), wepCol[wepIndex],capgrpMessage2) |
435 selText = loc("Mine Deployer selected!") |
343 |
436 else |
|
437 selText = loc("Flamer selected!") |
|
438 end |
|
439 AddCaption(selText, wepCol[wepIndex],capgrpAmmoinfo ) |
|
440 |
|
441 shotsRemainingMessage() |
|
442 end |
|
443 |
|
444 --------------- |
|
445 -- Parse parameters |
|
446 --------------- |
|
447 |
|
448 function parseNum(key, default, min, max) |
|
449 local num = tonumber(params[key]) |
|
450 if type(num) ~= "number" then |
|
451 if default ~= nil then |
|
452 return default |
|
453 else |
|
454 return nil |
|
455 end |
|
456 end |
|
457 |
|
458 if min ~= nil then |
|
459 num = math.max(min, num) |
|
460 end |
|
461 if max ~= nil then |
|
462 num = math.min(max, num) |
|
463 end |
|
464 return num |
|
465 end |
|
466 |
|
467 function onParameters() |
|
468 parseParams() |
|
469 |
|
470 barrelSpawn = parseNum("spawnbarrels", barrelSpawn, 0) |
|
471 mineSpawn = parseNum("spawnmines", mineSpawn, 0) |
|
472 |
|
473 initAmmoFlamer = parseNum("ammoflamer", initAmmoFlamer, 0) |
|
474 initAmmoBarrel = parseNum("ammobarrel", initAmmoBarrel, 0) |
|
475 initAmmoMine = parseNum("ammomine", initAmmoMine, 0) |
|
476 |
|
477 placedMineTime = parseNum("minetimeplaced", placedMineTime, 0, 5000) |
|
478 |
|
479 bonusTime = parseNum("bonustime", bonusTime, 0) |
|
480 bonusFlames = parseNum("bonusflames", bonusFlames, 0) |
|
481 |
|
482 chanceAmmo = parseNum("chanceammo", chanceAmmo, 0, 100) |
|
483 chanceTime = parseNum("chancetime", chanceTime, 0, 100) |
344 end |
484 end |
345 |
485 |
346 --------------- |
486 --------------- |
347 -- action keys |
487 -- action keys |
348 --------------- |
488 --------------- |
349 |
489 |
350 function onPrecise() |
490 function onPrecise() |
351 |
491 |
352 if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (wepAmmo[wepIndex] > 0) then |
492 if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then |
353 |
493 |
354 wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1 |
494 if wepAmmo[wepIndex] <= 0 then |
355 AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), wepCol[wepIndex],capgrpMessage2) |
495 PlaySound(sndDenied) |
356 |
496 shotsRemainingMessage() |
357 if wep[wepIndex] == loc("Barrel Launcher") then |
497 else |
358 morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1) |
498 |
359 CopyPV(CurrentHedgehog, morte) -- new addition |
499 wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1 |
360 x,y = GetGearVelocity(morte) |
500 shotsRemainingMessage() |
361 x = x*2 |
501 |
362 y = y*2 |
502 if wep[wepIndex] == loc("Barrel Launcher") then |
363 SetGearVelocity(morte, x, y) |
503 morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1) |
364 DrawTag(1) |
504 CopyPV(CurrentHedgehog, morte) -- new addition |
365 |
505 x,y = GetGearVelocity(morte) |
366 elseif wep[wepIndex] == loc("Mine Deployer") then |
506 x = x*2 |
367 morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtMine, 0, 0, 0, 0) |
507 y = y*2 |
368 SetTimer(morte, 1000) |
508 SetGearVelocity(morte, x, y) |
369 DrawTag(2) |
509 DrawTag(1) |
|
510 PlaySound(sndThrowRelease) |
|
511 |
|
512 elseif wep[wepIndex] == loc("Mine Deployer") then |
|
513 morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtMine, 0, 0, 0, 0) |
|
514 SetTimer(morte, placedMineTime) |
|
515 DrawTag(2) |
|
516 PlaySound(sndThrowRelease) |
|
517 |
|
518 end |
370 end |
519 end |
371 |
520 |
372 end |
521 end |
373 |
522 |
374 preciseOn = true |
523 preciseOn = true |
467 wepCol[1] = 0xa12a77ff |
620 wepCol[1] = 0xa12a77ff |
468 wepCol[2] = 0xf49318ff |
621 wepCol[2] = 0xf49318ff |
469 |
622 |
470 wepCount = 3 |
623 wepCount = 3 |
471 |
624 |
|
625 DisableGameFlags(gfArtillery + gfSharedAmmo + gfPerHogAmmo + gfTagTeam + gfPlaceHog + gfInvulnerable) |
|
626 |
472 end |
627 end |
473 |
628 |
474 function onGameStart() |
629 function onGameStart() |
475 |
630 |
|
631 local clockStr |
|
632 local timeStr |
|
633 |
|
634 if chanceTime > 0 then |
|
635 clockStr = loc("Utility crates extend your time.") .. "|" |
|
636 timeStr = string.format(loc("Time extension: %ds"), bonusTime) .. "|" |
|
637 else |
|
638 clockStr = "" |
|
639 timeStr = "" |
|
640 end |
|
641 |
476 ShowMission ( |
642 ShowMission ( |
477 "TUMBLER", |
643 "Tumbler", |
478 loc("a Hedgewars mini-game"), |
644 loc("A Hedgewars mini-game"), |
|
645 loc("Fly around and hurl explosives to your enemies.") .."|".. |
479 loc("Eliminate the enemy hogs to win.") .. "|" .. |
646 loc("Eliminate the enemy hogs to win.") .. "|" .. |
480 " " .. "|" .. |
647 " " .. "|" .. |
481 |
648 |
482 loc("New Mines Per Turn") .. ": " .. (mineSpawn) .. "|" .. |
649 string.format(loc("New mines per turn: %d"), mineSpawn) .. "|" .. |
483 loc("New Barrels Per Turn") .. ": " .. (barrelSpawn) .. "|" .. |
650 string.format(loc("New barrels per turn: %d"), barrelSpawn) .. "|" .. |
484 loc("Time Extension") .. ": " .. (HealthCaseAmount) .. loc("sec") .. "|" .. |
651 timeStr .. |
485 " " .. "|" .. |
652 " " .. "|" .. |
486 |
653 |
487 loc("Movement: [Up], [Down], [Left], [Right]") .. "|" .. |
654 loc("Movement: [Up], [Down], [Left], [Right]") .. "|" .. |
488 loc("Fire") .. ": " .. loc("[Left Shift]") .. "|" .. |
655 loc("Fire: [Precise]") .. "|" .. |
489 loc("Change Weapon") .. ": " .. loc("[Enter]") .. "|" .. |
656 loc("Change weapon: [Long jump] or [Slot 1]-[Slot 3]") .. "|" .. |
490 loc("Grab Mines/Explosives") .. ": " .. loc("[Backspace]") .. "|" .. |
657 loc("Grab mines/barrels: [High jump]") .. "|" .. |
491 |
658 |
492 " " .. "|" .. |
659 " " .. "|" .. |
493 |
660 |
494 loc("Health crates extend your time.") .. "|" .. |
661 clockStr .. |
495 loc("Ammo is reset at the end of your turn.") .. "|" .. |
662 loc("Ammo is reset at the end of your turn.") .. "|" .. |
496 |
663 |
497 "", 4, 4000 |
664 "", 4, 4000 |
498 ) |
665 ) |
499 |
666 |