5127
|
1 |
loadfile(GetDataPath() .. "Scripts/Locale.lua")()
|
|
2 |
|
|
3 |
local weapons = { amGrenade, amClusterBomb, amBazooka, amBee, amShotgun, amMine, amDEagle, amDynamite, amFirePunch, amWhip, amPickHammer, amBaseballBat, amMortar, amCake, amSeduction, amWatermelon, amHellishBomb, amDrill, amBallgun, amRCPlane, amSniperRifle, amMolotov, amBirdy, amBlowTorch, amGasBomb, amFlamethrower, amSMine, amKamikaze }
|
|
4 |
|
|
5 |
-- G,C,B,B,S,M,D,D,F,W,P,B,M,C,S,W,H,D,B,R,S,M,B,B,G,F,S,K
|
|
6 |
local weapons_values = {1,1,1,2,1,1,1,2,1,1,1,2,1,3,1,3,3,2,3,3,1,1,2,1,1,2,2,1}
|
|
7 |
|
|
8 |
local airweapons = { amAirAttack, amMineStrike, amNapalm, amDrillStrike }
|
|
9 |
|
|
10 |
-- A,M,N,D
|
|
11 |
local airweapons_values = {2,2,2,2}
|
|
12 |
|
|
13 |
local utilities = { amTeleport, amGirder, amSwitch, amLowGravity, amResurrector, amRope, amParachute, amJetpack, amPortalGun, amSnowball }
|
|
14 |
|
|
15 |
-- T,G,S,L,R,R,P,J,P,S
|
|
16 |
local utilities_values = {1,2,2,1,2,2,1,2,2,2}
|
|
17 |
|
|
18 |
function onGameInit()
|
|
19 |
GameFlags = band(bor(GameFlags, gfResetWeps), bnot(gfPerHogAmmo))
|
|
20 |
Goals = loc("Each turn you get 1-3 random weapons|The stronger they are, the fewer you get")
|
|
21 |
end
|
|
22 |
|
|
23 |
function onGameStart()
|
|
24 |
if MapHasBorder() == false then
|
|
25 |
for i, w in pairs(airweapons) do
|
|
26 |
table.insert(weapons, w)
|
|
27 |
end
|
|
28 |
for i, w in pairs(airweapons_values) do
|
|
29 |
table.insert(weapons_values, w)
|
|
30 |
end
|
|
31 |
end
|
|
32 |
|
|
33 |
--ShowMission(loc("Balanced Random Weapons"), loc("A game of luck"), loc("Each turn you'll get a weapon, and if it sucks you'll get some more!"), -amSkip, 0)
|
|
34 |
end
|
|
35 |
|
|
36 |
function onAmmoStoreInit()
|
|
37 |
SetAmmo(amSkip, 9, 0, 0, 0)
|
|
38 |
|
|
39 |
SetAmmo(amExtraDamage, 0, 1, 0, 1)
|
|
40 |
SetAmmo(amInvulnerable, 0, 1, 0, 1)
|
|
41 |
SetAmmo(amExtraTime, 0, 1, 0, 1)
|
|
42 |
SetAmmo(amLaserSight, 0, 1, 0, 1)
|
|
43 |
SetAmmo(amVampiric, 0, 1, 0, 1)
|
|
44 |
|
|
45 |
for i, w in pairs(utilities) do
|
|
46 |
SetAmmo(w, 0, 0, 0, 1)
|
|
47 |
end
|
|
48 |
|
|
49 |
for i, w in pairs(weapons) do
|
|
50 |
SetAmmo(w, 0, 0, 0, 1)
|
|
51 |
end
|
|
52 |
|
|
53 |
for i, w in pairs(airweapons) do
|
|
54 |
SetAmmo(w, 0, 0, 0, 1)
|
|
55 |
end
|
|
56 |
end
|
|
57 |
|
|
58 |
function onNewTurn()
|
|
59 |
local n = 3 --"points" to be allocated on weapons
|
|
60 |
|
|
61 |
--pick random weapon and subtract cost
|
|
62 |
local r = GetRandom(table.maxn(weapons_values)) + 1
|
|
63 |
AddAmmo(CurrentHedgehog, weapons[r])
|
|
64 |
local items_used = {}
|
|
65 |
items_used[1] = weapons[r]
|
|
66 |
n = n - weapons_values[r]
|
|
67 |
|
|
68 |
|
|
69 |
--choose any weapons or utilities to use up remaining n
|
|
70 |
|
|
71 |
while n > 0 do
|
|
72 |
local items = {}
|
|
73 |
local items_values = {}
|
|
74 |
|
|
75 |
for i, w in pairs(weapons_values) do
|
|
76 |
local used = false
|
|
77 |
if w <= n then
|
|
78 |
--check that this weapon hasn't been given already
|
|
79 |
for j = 1, table.maxn(items_used) do
|
|
80 |
if weapons[i] == items_used[j] then
|
|
81 |
used = true
|
|
82 |
end
|
|
83 |
end
|
|
84 |
if not used then
|
|
85 |
table.insert(items_values, w)
|
|
86 |
table.insert(items, weapons[i])
|
|
87 |
end
|
|
88 |
end
|
|
89 |
end
|
|
90 |
|
|
91 |
for i, w in pairs(utilities_values) do
|
|
92 |
local used = false
|
|
93 |
if w <= n then
|
|
94 |
--check that this weapon hasn't been given already
|
|
95 |
for j = 1, table.maxn(items_used) do
|
|
96 |
if utilities[i] == items_used[j] then
|
|
97 |
used = true
|
|
98 |
end
|
|
99 |
end
|
|
100 |
if not used then
|
|
101 |
table.insert(items_values, w)
|
|
102 |
table.insert(items, utilities[i])
|
|
103 |
end
|
|
104 |
end
|
|
105 |
end
|
|
106 |
|
|
107 |
local r = GetRandom(table.maxn(items_values)) + 1
|
|
108 |
AddAmmo(CurrentHedgehog, items[r])
|
|
109 |
table.insert(items_used, items[r])
|
|
110 |
n = n - items_values[r]
|
|
111 |
end
|
|
112 |
end
|