1 loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
1 loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
|
2 loadfile(GetDataPath() .. "Scripts/Tracker.lua")() |
2 |
3 |
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 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 |
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 -- 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 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} |
13 local utilities = { amTeleport, amGirder, amSwitch, amLowGravity, amResurrector, amRope, amParachute, amJetpack, amPortalGun, amSnowball } |
14 local utilities = { amTeleport, amGirder, amSwitch, amLowGravity, amResurrector, amRope, amParachute, amJetpack, amPortalGun, amSnowball } |
14 |
15 |
15 -- T,G,S,L,R,R,P,J,P,S |
16 -- 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 local utilities_values = {1,2,2,1,2,2,1,2,2,2} |
17 |
18 |
|
19 function randomAmmo() |
|
20 local n = 3 --"points" to be allocated on weapons |
|
21 |
|
22 --pick random weapon and subtract cost |
|
23 local r = GetRandom(table.maxn(weapons_values)) + 1 |
|
24 local picked_items = {} |
|
25 table.insert(picked_items, weapons[r]) |
|
26 n = n - weapons_values[r] |
|
27 |
|
28 |
|
29 --choose any weapons or utilities to use up remaining n |
|
30 |
|
31 while n > 0 do |
|
32 local items = {} |
|
33 local items_values = {} |
|
34 |
|
35 for i, w in pairs(weapons_values) do |
|
36 local used = false |
|
37 if w <= n then |
|
38 --check that this weapon hasn't been given already |
|
39 for j, k in pairs(picked_items) do |
|
40 if weapons[i] == k then |
|
41 used = true |
|
42 end |
|
43 end |
|
44 if not used then |
|
45 table.insert(items_values, w) |
|
46 table.insert(items, weapons[i]) |
|
47 end |
|
48 end |
|
49 end |
|
50 |
|
51 for i, w in pairs(utilities_values) do |
|
52 local used = false |
|
53 if w <= n then |
|
54 --check that this weapon hasn't been given already |
|
55 for j, k in pairs(picked_items) do |
|
56 if utilities[i] == k then |
|
57 used = true |
|
58 end |
|
59 end |
|
60 if not used then |
|
61 table.insert(items_values, w) |
|
62 table.insert(items, utilities[i]) |
|
63 end |
|
64 end |
|
65 end |
|
66 |
|
67 local r = GetRandom(table.maxn(items_values)) + 1 |
|
68 table.insert(picked_items, items[r]) |
|
69 n = n - items_values[r] |
|
70 end |
|
71 |
|
72 return picked_items |
|
73 end |
|
74 |
|
75 function assignAmmo(hog) |
|
76 local name = GetHogTeamName(hog) |
|
77 local processed = getTeamValue(name, "processed") |
|
78 if processed == nil or not processed then |
|
79 local ammo = getTeamValue(name, "ammo") |
|
80 if ammo == nil then |
|
81 ammo = randomAmmo() |
|
82 setTeamValue(name, "ammo", ammo) |
|
83 end |
|
84 for i, w in pairs(ammo) do |
|
85 AddAmmo(hog, w) |
|
86 end |
|
87 setTeamValue(name, "processed", true) |
|
88 end |
|
89 end |
|
90 |
|
91 function reset(hog) |
|
92 setTeamValue(GetHogTeamName(hog), "processed", false) |
|
93 end |
|
94 |
18 function onGameInit() |
95 function onGameInit() |
19 GameFlags = band(bor(GameFlags, gfResetWeps), bnot(gfPerHogAmmo)) |
96 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") |
97 Goals = loc("Each turn you get 1-3 random weapons") |
21 end |
98 end |
22 |
99 |
23 function onGameStart() |
100 function onGameStart() |
|
101 trackTeams() |
24 if MapHasBorder() == false then |
102 if MapHasBorder() == false then |
25 for i, w in pairs(airweapons) do |
103 for i, w in pairs(airweapons) do |
26 table.insert(weapons, w) |
104 table.insert(weapons, w) |
27 end |
105 end |
28 for i, w in pairs(airweapons_values) do |
106 for i, w in pairs(airweapons_values) do |
29 table.insert(weapons_values, w) |
107 table.insert(weapons_values, w) |
30 end |
108 end |
31 end |
109 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 |
110 end |
35 |
111 |
36 function onAmmoStoreInit() |
112 function onAmmoStoreInit() |
37 SetAmmo(amSkip, 9, 0, 0, 0) |
113 SetAmmo(amSkip, 9, 0, 0, 0) |
38 |
114 |
54 SetAmmo(w, 0, 0, 0, 1) |
130 SetAmmo(w, 0, 0, 0, 1) |
55 end |
131 end |
56 end |
132 end |
57 |
133 |
58 function onNewTurn() |
134 function onNewTurn() |
59 local n = 3 --"points" to be allocated on weapons |
135 runOnGears(assignAmmo) |
60 |
136 runOnGears(reset) |
61 --pick random weapon and subtract cost |
137 setTeamValue(GetHogTeamName(CurrentHedgehog), "ammo", nil) |
62 local r = GetRandom(table.maxn(weapons_values)) + 1 |
138 end |
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 |
139 |
75 for i, w in pairs(weapons_values) do |
140 function onGearAdd(gear) |
76 local used = false |
141 if GetGearType(gear) == gtHedgehog then |
77 if w <= n then |
142 trackGear(gear) |
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 |
143 end |
112 end |
144 end |
|
145 |
|
146 function onGearDelete(gear) |
|
147 trackDeletion(gear) |
|
148 end |