88 ------------------------------- |
88 ------------------------------- |
89 |
89 |
90 HedgewarsScriptLoad("/Scripts/Locale.lua") |
90 HedgewarsScriptLoad("/Scripts/Locale.lua") |
91 HedgewarsScriptLoad("/Scripts/Tracker.lua") |
91 HedgewarsScriptLoad("/Scripts/Tracker.lua") |
92 |
92 |
93 local airWeapons = {amAirAttack, amMineStrike, amNapalm, amDrillStrike --[[,amPiano]]} |
93 -- These define weps allowed by the script. At present Tardis and Resurrection is banned for example |
94 |
94 -- These were arbitrarily defined out-of-order in initial script, so that was preserved here, resulting |
95 local atkArray = { |
95 -- in a moderately odd syntax. |
96 amBazooka, amBee, amMortar, amDrill, --[[amSnowball,]] |
96 local atkWeps = { |
97 amGrenade, amClusterBomb, amMolotov, amWatermelon, amHellishBomb, amGasBomb, |
97 [amBazooka]=true, [amBee]=true, [amMortar]=true, [amDrill]=true, [amSnowball]=true, |
98 amShotgun, amDEagle, amFlamethrower, amSniperRifle, amSineGun, amIceGun, |
98 [amGrenade]=true, [amClusterBomb]=true, [amMolotov]=true, [amWatermelon]=true, |
99 amFirePunch, amWhip, amBaseballBat, --[[amKamikaze,]] amSeduction, --[[amHammer,]] |
99 [amHellishBomb]=true, [amGasBomb]=true, [amShotgun]=true, [amDEagle]=true, |
100 amMine, amDynamite, amCake, amBallgun, amRCPlane, amSMine, |
100 [amFlamethrower]=true, [amSniperRifle]=true, [amSineGun]=true, |
101 amRCPlane, amSMine, |
101 [amFirePunch]=true, [amWhip]=true, [amBaseballBat]=true, [amKamikaze]=true, |
102 amBirdy |
102 [amSeduction]=true, [amHammer]=true, [amMine]=true, [amDynamite]=true, [amCake]=true, |
|
103 [amBallgun]=true, [amSMine]=true, [amRCPlane]=true, [amBirdy]=true, [amKnife]=true, |
|
104 [amAirAttack]=true, [amMineStrike]=true, [amNapalm]=true, [amDrillStrike]=true, [amPiano]=true |
103 } |
105 } |
104 |
106 |
105 local utilArray = { |
107 local utilWeps = { |
106 amBlowTorch, amPickHammer, amGirder, amPortalGun, |
108 [amBlowTorch]=true, [amPickHammer]=true, [amGirder]=true, [amPortalGun]=true, |
107 amRope, amParachute, amTeleport, amJetpack, |
109 [amRope]=true, [amParachute]=true, [amTeleport]=true, [amJetpack]=true, |
108 amInvulnerable, amLaserSight, --[[amVampiric,]] |
110 [amInvulnerable]=true, [amLaserSight]=true, [amVampiric]=true, |
109 amLowGravity, amExtraDamage, --[[amExtraTime,]] |
111 [amLowGravity]=true, [amExtraDamage]=true, [amExtraTime]=true, |
110 amLandGun |
112 [amLandGun]=true, [amSwitch]=true, [amRubber]=true, [amIceGun]=true, |
111 --[[,amTardis, amResurrector, amSwitch]] |
|
112 } |
113 } |
113 |
114 |
114 local wepArray = {} |
115 local wepArray = {} |
|
116 |
|
117 local atkChoices = {} |
|
118 local utilChoices = {} |
115 |
119 |
116 local currHog |
120 local currHog |
117 local lastHog |
121 local lastHog |
118 local started = false |
122 local started = false |
119 local switchStage = 0 |
123 local switchStage = 0 |
120 |
124 |
121 local lastWep = amNothing |
125 local lastWep = amNothing |
122 local shotsFired = 0 |
126 local shotsFired = 0 |
123 |
127 |
|
128 local probability = {1,20,30,60,100,200,400,600,1000000}; |
|
129 local atktot = 0 |
|
130 local utiltot = 0 |
|
131 local maxWep = 56 -- game crashes if you exceed supported # |
|
132 |
|
133 local someHog = nil -- just for looking up the weps |
|
134 |
124 function CheckForWeaponSwap() |
135 function CheckForWeaponSwap() |
125 if GetCurAmmoType() ~= lastWep then |
136 if GetCurAmmoType() ~= lastWep then |
126 shotsFired = 0 |
137 shotsFired = 0 |
127 end |
138 end |
128 lastWep = GetCurAmmoType() |
139 lastWep = GetCurAmmoType() |
140 CheckForWeaponSwap() |
151 CheckForWeaponSwap() |
141 shotsFired = shotsFired + 1 |
152 shotsFired = shotsFired + 1 |
142 end |
153 end |
143 |
154 |
144 function StartingSetUp(gear) |
155 function StartingSetUp(gear) |
145 |
156 for i = 1,maxWep do |
146 for i = 1, #wepArray do |
157 setGearValue(gear,i,0) |
147 setGearValue(gear,wepArray[i],0) |
158 end |
148 end |
159 for w,c in pairs(wepArray) do |
149 |
160 if c == 9 then |
150 setGearValue(gear,amKamikaze,100) |
161 setGearValue(gear,w,100) |
|
162 end |
|
163 end |
|
164 |
151 setGearValue(gear,amSkip,100) |
165 setGearValue(gear,amSkip,100) |
152 |
166 |
153 i = 1 + GetRandom(#atkArray) |
167 local r = 0 |
154 setGearValue(gear,atkArray[i],1) |
168 if atktot > 0 then |
155 |
169 r = GetRandom(atktot)+1 |
156 i = 1 + GetRandom(#utilArray) |
170 for w,c in pairs(atkChoices) do |
157 setGearValue(gear,utilArray[i],1) |
171 WriteLnToConsole(' c: '..c..' w:'..w..' r:'..r) |
158 |
172 if c >= r then |
|
173 setGearValue(gear,w,1) |
|
174 break |
|
175 end |
|
176 end |
|
177 end |
|
178 if utiltot > 0 then |
|
179 r = GetRandom(utiltot)+1 |
|
180 for w,c in pairs(utilChoices) do |
|
181 if c >= r then |
|
182 setGearValue(gear,w,1) |
|
183 break |
|
184 end |
|
185 end |
|
186 end |
159 end |
187 end |
160 |
188 |
161 --[[function SaveWeapons(gear) |
189 --[[function SaveWeapons(gear) |
162 -- er, this has no 0 check so presumably if you use a weapon then when it saves you wont have it |
190 -- er, this has no 0 check so presumably if you use a weapon then when it saves you wont have it |
163 |
191 |
167 end |
195 end |
168 |
196 |
169 end]] |
197 end]] |
170 |
198 |
171 function ConvertValues(gear) |
199 function ConvertValues(gear) |
172 |
200 for w,c in pairs(wepArray) do |
173 for i = 1, #wepArray do |
201 AddAmmo(gear, w, getGearValue(gear,w) ) |
174 AddAmmo(gear, wepArray[i], getGearValue(gear,wepArray[i]) ) |
202 end |
175 end |
|
176 |
|
177 end |
203 end |
178 |
204 |
179 -- this is called when a hog dies |
205 -- this is called when a hog dies |
180 function TransferWeps(gear) |
206 function TransferWeps(gear) |
181 |
207 |
182 if CurrentHedgehog ~= nil then |
208 if CurrentHedgehog ~= nil then |
183 |
209 |
184 for i = 1, #wepArray do |
210 for w,c in pairs(wepArray) do |
185 val = getGearValue(gear,wepArray[i]) |
211 val = getGearValue(gear,w) |
186 if val ~= 0 then |
212 if val ~= 0 then |
187 |
213 setGearValue(CurrentHedgehog, w, val) |
188 setGearValue(CurrentHedgehog, wepArray[i], val) |
|
189 |
214 |
190 -- if you are using multi-shot weapon, gimme one more |
215 -- if you are using multi-shot weapon, gimme one more |
191 if (GetCurAmmoType() == wepArray[i]) and (shotsFired ~= 0) then |
216 if (GetCurAmmoType() == w) and (shotsFired ~= 0) then |
192 AddAmmo(CurrentHedgehog, wepArray[i], val+1) |
217 AddAmmo(CurrentHedgehog, w, val+1) |
193 -- assign ammo as per normal |
218 -- assign ammo as per normal |
194 else |
219 else |
195 AddAmmo(CurrentHedgehog, wepArray[i], val) |
220 AddAmmo(CurrentHedgehog, w, val) |
196 end |
221 end |
197 |
222 |
198 end |
223 end |
199 end |
224 end |
200 |
225 |
218 "- " .. loc("Weapons reset.") .. "|" .. |
264 "- " .. loc("Weapons reset.") .. "|" .. |
219 "- " .. loc("Unlimited Attacks") .. "|" .. |
265 "- " .. loc("Unlimited Attacks") .. "|" .. |
220 "", 4, 4000 |
266 "", 4, 4000 |
221 ) |
267 ) |
222 |
268 |
223 if MapHasBorder() == false then |
|
224 for i, w in pairs(airWeapons) do |
|
225 table.insert(atkArray, w) |
|
226 end |
|
227 end |
|
228 |
|
229 for i, w in pairs(atkArray) do |
|
230 table.insert(wepArray, w) |
|
231 end |
|
232 |
|
233 for i, w in pairs(utilArray) do |
|
234 table.insert(wepArray, w) |
|
235 end |
|
236 |
|
237 table.insert(wepArray, amSkip) |
|
238 table.insert(wepArray, amKamikaze) |
|
239 |
|
240 runOnGears(StartingSetUp) |
269 runOnGears(StartingSetUp) |
241 runOnGears(ConvertValues) |
270 runOnGears(ConvertValues) |
242 |
|
243 |
|
244 end |
271 end |
245 |
272 |
246 function CheckForHogSwitch() |
273 function CheckForHogSwitch() |
247 |
274 |
248 if (CurrentHedgehog ~= nil) then |
275 if (CurrentHedgehog ~= nil) then |