|
1 |
|
2 loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
|
3 loadfile(GetDataPath() .. "Scripts/Tracker.lua")() |
|
4 |
|
5 --------------------------------------------------- |
|
6 --------------------------------------------------- |
|
7 --------------------------------------------------- |
|
8 --- Space Invasion Code Follows (1.1) |
|
9 --------------------------------------------------- |
|
10 --------------------------------------------------- |
|
11 -- VERSION HISTORY |
|
12 ---------------- |
|
13 -- version 0.1 |
|
14 ---------------- |
|
15 -- conversion of tumbler into space invasion |
|
16 -- a million and one changes |
|
17 -- bells and whistles |
|
18 |
|
19 ---------------- |
|
20 -- version 0.2 |
|
21 ---------------- |
|
22 -- code slowly getting cleaner, it still looks like a spaghetti monster tho |
|
23 -- lots of console tracking :/ |
|
24 -- all visual gears are now compulsary (will probably revert this) |
|
25 -- implemented fMod to try combat desyncs and bring this in line with dev |
|
26 |
|
27 ---------------- |
|
28 -- version 0.3 |
|
29 ---------------- |
|
30 -- values of scoring changed to 3:10, and now based on vCircScore |
|
31 -- time gained from killing a red circ increased from 3 to 4 |
|
32 -- circles now spawn at a distance of at least 800 or until sanity limit |
|
33 -- roundsLimit now based off MinesTime (kinda, its an experiment) |
|
34 |
|
35 ----------------- |
|
36 --0.4 |
|
37 ----------------- |
|
38 -- commented out a lot of WriteLnToConsoles (dont need them at this point) |
|
39 -- added some different WriteLnToConsoles |
|
40 -- changed some of the collision detect for explosives in checkvarious() |
|
41 |
|
42 ----------------- |
|
43 --0.5 |
|
44 ----------------- |
|
45 -- added implementation for a projectile shield |
|
46 -- added a "bonus" orange invader that partially recharges player shield |
|
47 -- added a tough "blueboss" blue invader |
|
48 -- expanded user feedback |
|
49 -- circles now have health and are capable of being merely "damaged" |
|
50 -- redid a lot of the collision code and added CircleDamaged |
|
51 -- added more sounds to events |
|
52 -- added more visual gears |
|
53 |
|
54 ----------------- |
|
55 --0.6 |
|
56 ----------------- |
|
57 -- removed a few WriteLns |
|
58 -- added randomized grunts on circ damage |
|
59 -- added (mostly) graceful fading out of circles :D: |
|
60 -- changed odds for circles |
|
61 -- changed user feedback |
|
62 -- fixed the location of the explosion where player bashes into circ |
|
63 |
|
64 ----------------- |
|
65 --0.7 |
|
66 ----------------- |
|
67 -- added PlaySound(sndSuddenDeath) when ammo gets depleted |
|
68 -- added an extra "Ammo Depleted" note if user presses fire while empty |
|
69 -- specified how much shield power is gained on shield powerup collection |
|
70 -- changed odds for circles AGAIN, ammo is now sliiightly more common |
|
71 -- switched most of the explosions/smoke effects back to non-critical vgears (with a few exceptions) |
|
72 -- tumbletime is now based off turntime and is variable |
|
73 -- delete explosives in DeleteFarFlungBarrel rather than explode them on map boundaries to save on performance |
|
74 -- utilized the improved AddCaption to tint / prevent overrides |
|
75 -- temporarily disabled bugged sort that displays teams according to their score |
|
76 -- reluctantly changed the colour of the bonus circ to purple |
|
77 -- standarized point notation |
|
78 -- added some missing locs |
|
79 -- commented out remaining WriteLnToConsoles for the meanwhile with the prefix "nw" |
|
80 |
|
81 -- ACHIEIVEMENTS added |
|
82 -- (during one turn) aka repeatable |
|
83 -- Ammo Manic (Destroy 3 green circles for + 5 points) |
|
84 -- Drone Hunter (Destroy 5 red circles for + 10 points) |
|
85 -- Shield Seeker (Destroy 3 purple circles for +10 points) |
|
86 -- Boss Slayer (Destroy 2 blue circles for +25 points) |
|
87 |
|
88 -- Shield Master (disolve 5 shells for +10 points) |
|
89 -- Shield Miser (don't use your shield at all (3.5*roundkills)+2 points) |
|
90 |
|
91 -- Depleted Kamikaze! (kamikaze into a blue/red circ when you are out of ammo) 5pts |
|
92 -- Timed Kamikaze! (kamikaze into a blue/red circ when you only have 5s left) 10pts |
|
93 -- Kamikaze Expert (combination of the above two) 15pts |
|
94 |
|
95 -- Multi-shot (destroy more than 1 invader with a single bullet) 15pts |
|
96 -- X-Hit Combo (destroy another invader in less than 3 seconds) chainLength*2 points |
|
97 |
|
98 -- Accuracy Bonus (80% accuracy at the end of your turn with more than 5 shots fired) 15pts |
|
99 |
|
100 --(during the length of the game) aka non-repeatable |
|
101 -- 10/25/50 kills (+25/+50/+100 points) |
|
102 |
|
103 ----------------- |
|
104 --0.8 |
|
105 ----------------- |
|
106 -- added a HUD for turntimeleft, ammo, shield |
|
107 -- shieldhealth hits 0 properly |
|
108 |
|
109 ------------------------ |
|
110 -- version 0.8.1 |
|
111 ------------------------ |
|
112 |
|
113 -- stop hiding non-existant 4th Tag |
|
114 -- redraw HUD on screen resolution change |
|
115 |
|
116 ------------------------ |
|
117 -- version 0.9 |
|
118 ------------------------ |
|
119 -- time for more 'EXPERIMENTS' mwahahahahahaha D: |
|
120 -- (hopefully) balanced Shield Miser |
|
121 -- bosses are no longer a redunkulous 50 points, but toned down to 30 |
|
122 -- experimental radar (it's INTERACTIVE and math-heavy :D) (visual gears are safe... right? D:) |
|
123 -- bugfix and balance for multishot |
|
124 |
|
125 ------------------------ |
|
126 -- version 1.0 |
|
127 ------------------------ |
|
128 -- if only version numbers actually worked like this, wouldn't that be awful :D |
|
129 -- added surfer achievement |
|
130 -- increased value of shield miser by 1 point per kill (OP?) |
|
131 |
|
132 ------------------------ |
|
133 -- version 1.1 |
|
134 ------------------------ |
|
135 -- fixed radar so that blips dont go past circs when you get very close |
|
136 -- added a missing loc for shield depletion |
|
137 -- increased delay to 1000 to try stop noobies missing their turn |
|
138 -- added sniper achievement for hits from over a 1000000 away |
|
139 -- added achievement for 3 "sniper" shots in a round |
|
140 -- added achievement for 3 "point blank" shots in a round |
|
141 -- added "fierce Competition" achievement for shooting an enemy hog (once per round) |
|
142 -- some support for more weapons later |
|
143 |
|
144 -------------------------- |
|
145 --notes for later |
|
146 -------------------------- |
|
147 -- maybe add a check for a tie, IMPOSSIBRU THERE ARE NO TIES |
|
148 -- more achievements? (3 kamikazes in a row, supreme shield expert/miser etc?) |
|
149 |
|
150 -- if more weps are added, replace primshotsfired all over the place |
|
151 |
|
152 -- look for derp and let invaders shoot again |
|
153 |
|
154 -- more weps? flamer/machineballgun, |
|
155 -- some kind of bomb that just drops straight down |
|
156 -- "fire and forget" missile |
|
157 -- shockwave |
|
158 |
|
159 -- some kind of ability-meter that lets you do something awesome when you are |
|
160 -- doing really well in a given round. |
|
161 -- probably new kind of shield that pops any invaders who come near |
|
162 |
|
163 -- fix game never ending bug |
|
164 -- fix radar |
|
165 -- new invader: golden snitch, doesn't show up on your radar |
|
166 |
|
167 -- maybe replace (48/100*vCircRadius[i])/2 with something better |
|
168 |
|
169 |
|
170 --[[CAPTION CATEGORIES |
|
171 ----------------- |
|
172 capgrpGameState |
|
173 ----------------- |
|
174 AddCaption(LOC_NOT("Sniper!") .. " +10 " .. LOC_NOT("points") .. "!",0xffba00ff,capgrpAmmostate) |
|
175 --they call me bullsye |
|
176 --point blank combo |
|
177 --fierce Competition |
|
178 ----------------- |
|
179 capgrpAmmostate |
|
180 ----------------- |
|
181 AddCaption( chainLength .. LOC_NOT("-chain! +") .. chainLength*2 .. LOC_NOT(" points!"),0xffba00ff,capgrpAmmostate) |
|
182 AddCaption(LOC_NOT("Multi-shot! +15 points!"),0xffba00ff,capgrpAmmostate) |
|
183 |
|
184 ----------------- |
|
185 capgrpAmmoinfo |
|
186 ----------------- |
|
187 AddCaption(LOC_NOT("Shield Miser! +20 points!"),0xffba00ff,capgrpAmmoinfo) |
|
188 AddCaption(LOC_NOT("Shield Master! +10 points!"),0xffba00ff,capgrpAmmoinfo) |
|
189 |
|
190 ----------------- |
|
191 capgrpVolume |
|
192 ----------------- |
|
193 AddCaption(LOC_NOT("Boom! +25 points!"),0xffba00ff,capgrpVolume) |
|
194 AddCaption(LOC_NOT("BOOM! +50 points!"),0xffba00ff,capgrpVolume) |
|
195 AddCaption(LOC_NOT("BOOM! BOOM! BOOM! +100 points!"),0xffba00ff,capgrpVolume) |
|
196 AddCaption(LOC_NOT("Accuracy Bonus! +15 points!"),0xffba00ff,capgrpVolume) |
|
197 AddCaption(LOC_NOT("Surfer! +15 points!"),0xffba00ff,capgrpVolume) |
|
198 |
|
199 ----------------- |
|
200 capgrpMessage |
|
201 ----------------- |
|
202 AddCaption(LOC_NOT("Ammo Depleted!"),0xff0000ff,capgrpMessage) |
|
203 AddCaption(LOC_NOT("Ammo: ") .. primShotsLeft) |
|
204 AddCaption(LOC_NOT("Shield Depleted"),0xff0000ff,capgrpMessage) |
|
205 AddCaption( LOC_NOT("Shield ON:") .. " " .. shieldHealth - 80 .. " " .. LOC_NOT("Power Remaining") ) |
|
206 AddCaption(LOC_NOT("Shield OFF:") .. " " .. shieldHealth - 80 .. " " .. LOC_NOT("Power Remaining") ) |
|
207 |
|
208 AddCaption(LOC_NOT("Time Extended!") .. "+" .. 4 .. LOC_NOT("s"), 0xff0000ff,capgrpMessage ) |
|
209 AddCaption("+" .. 3 .. " " .. LOC_NOT("Ammo"), 0x00ff00ff,capgrpMessage) |
|
210 AddCaption(LOC_NOT("Shield boosted! +30 power"), 0xff00ffff,capgrpMessage) |
|
211 AddCaption(LOC_NOT("Shield is fully recharged!"), 0xffae00ff,capgrpMessage) |
|
212 AddCaption(LOC_NOT("Boss defeated! +50 points!"), 0x0050ffff,capgrpMessage) |
|
213 |
|
214 AddCaption(LOC_NOT("GOTCHA!")) |
|
215 AddCaption(LOC_NOT("Kamikaze Expert! +15 points!"),0xffba00ff,capgrpMessage) |
|
216 AddCaption(LOC_NOT("Depleted Kamikaze! +5 points!"),0xffba00ff,capgrpMessage) |
|
217 AddCaption(LOC_NOT("Timed Kamikaze! +10 points!"),0xffba00ff,capgrpMessage) |
|
218 |
|
219 ----------------- |
|
220 capgrpMessage2 |
|
221 ----------------- |
|
222 AddCaption(LOC_NOT("Drone Hunter! +10 points!"),0xffba00ff,capgrpMessage2) |
|
223 AddCaption(LOC_NOT("Ammo Maniac! +5 points!"),0xffba00ff,capgrpMessage2) |
|
224 AddCaption(LOC_NOT("Shield Seeker! +10 points!"),0xffba00ff,capgrpMessage2) |
|
225 AddCaption(LOC_NOT("Boss Slayer! +25 points!"),0xffba00ff,capgrpMessage2) |
|
226 ]] |
|
227 |
|
228 ---------------------------------- |
|
229 -- so I herd u liek wariables |
|
230 ---------------------------------- |
|
231 |
|
232 --local fMod = 1 -- for use in .15 single player only, otherwise desync |
|
233 local fMod = 1000000 -- use this for dev and .16+ games |
|
234 |
|
235 -- some console stuff |
|
236 local shellID = 0 |
|
237 local explosivesID = 0 |
|
238 |
|
239 -- gaudyRacer |
|
240 local boosterOn = false |
|
241 local roundLimit = 3 -- no longer set here (see version history) |
|
242 local roundNumber = 0 |
|
243 local firstClan = 10 |
|
244 local gameOver = false |
|
245 local gameBegun = false |
|
246 |
|
247 local bestClan = 10 |
|
248 local bestScore = 0 |
|
249 local sdScore = {} |
|
250 local sdName = {} |
|
251 local sdKills = {} |
|
252 |
|
253 local roundN = 0 |
|
254 local lastRound |
|
255 local RoundHasChanged = true |
|
256 |
|
257 -------------------------- |
|
258 -- hog and team tracking variales |
|
259 -------------------------- |
|
260 |
|
261 local numhhs = 0 |
|
262 local hhs = {} |
|
263 |
|
264 local numTeams |
|
265 local teamNameArr = {} |
|
266 local teamClan = {} |
|
267 local teamSize = {} |
|
268 local teamIndex = {} |
|
269 |
|
270 local teamComment = {} |
|
271 local teamScore = {} |
|
272 local teamCircsKilled = {} |
|
273 local teamSurfer = {} |
|
274 |
|
275 -- stats variables |
|
276 --local teamRed = {} |
|
277 --local teamBlue = {} |
|
278 --local teamOrange = {} |
|
279 --local teamGreen = {} |
|
280 local roundKills = 0 |
|
281 local RK = 0 |
|
282 local GK = 0 |
|
283 local BK = 0 |
|
284 local OK = 0 |
|
285 local SK = 0 |
|
286 local shieldMiser = true |
|
287 local fierceComp = false |
|
288 local chainCounter = 0 |
|
289 local chainLength = 0 |
|
290 local shotsFired = 0 |
|
291 local shotsHit = 0 |
|
292 local SurfTime = 0 |
|
293 local sniperHits = 0 |
|
294 local pointBlankHits = 0 |
|
295 --------------------- |
|
296 -- tumbler goods |
|
297 --------------------- |
|
298 |
|
299 local leftOn = false |
|
300 local rightOn = false |
|
301 local upOn = false |
|
302 local downOn = false |
|
303 |
|
304 ---------------- |
|
305 -- TUMBLER |
|
306 local wep = {} |
|
307 local wepAmmo = {} |
|
308 local wepCol = {} |
|
309 local wepIndex = 0 |
|
310 local wepCount = 0 |
|
311 local fireTimer = 0 |
|
312 ---------------- |
|
313 |
|
314 |
|
315 |
|
316 local primShotsMax = 5 |
|
317 local primShotsLeft = 0 |
|
318 |
|
319 local TimeLeft = 0 |
|
320 local stopMovement = false |
|
321 local tumbleStarted = false |
|
322 |
|
323 local beam = false |
|
324 local pShield |
|
325 local shieldHealth |
|
326 |
|
327 local shockwave |
|
328 local shockwaveHealth = 0 |
|
329 local shockwaveRad = 300 |
|
330 |
|
331 local vTag = {} |
|
332 |
|
333 ----------------------------------------------- |
|
334 -- CIRCLY GOODIES |
|
335 ----------------------------------------------- |
|
336 |
|
337 local CirclesAreGo = false |
|
338 local playerIsFine = true |
|
339 local targetHit = false |
|
340 |
|
341 local FadeAlpha = 0 -- used to fade the circles out gracefully when player dies |
|
342 local pTimer = 0 -- tracking projectiles following player |
|
343 |
|
344 --local m2Count = 0 -- handle speed of circs |
|
345 |
|
346 local vCirc = {} |
|
347 local vCCount = 0 |
|
348 |
|
349 local rCirc = {} |
|
350 local rCircX = {} |
|
351 local rCircY = {} |
|
352 local rAlpha = 255 |
|
353 local radShotsLeft = 0 |
|
354 |
|
355 local vCircActive = {} |
|
356 local vCircHealth = {} |
|
357 local vType = {} |
|
358 local vCounter = {} -- how often this circ gets to "fire" etc |
|
359 local vCounterLim = {} -- when vCounter == vCounterLim circle performs its special |
|
360 local vCircScore = {} -- how many points killing this invader gives |
|
361 |
|
362 local vCircRadMax = {} |
|
363 local vCircRadMin = {} |
|
364 local vCircRadDir = {} |
|
365 local vCircRadCounter = {} |
|
366 |
|
367 local vCircDX = {} |
|
368 local vCircDY = {} |
|
369 |
|
370 local vCircX = {} |
|
371 local vCircY = {} |
|
372 local vCircMinA = {} |
|
373 local vCircMaxA = {} |
|
374 local vCircType = {} |
|
375 local vCircPulse = {} |
|
376 local vCircFuckAll = {} |
|
377 local vCircRadius = {} |
|
378 local vCircWidth = {} |
|
379 local vCircCol = {} |
|
380 |
|
381 ------------------------------------------- |
|
382 -- some lazy copypasta/modified methods |
|
383 ------------------------------------------- |
|
384 |
|
385 |
|
386 |
|
387 function HideTags() |
|
388 |
|
389 for i = 0, 2 do |
|
390 SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00) |
|
391 end |
|
392 |
|
393 end |
|
394 |
|
395 function DrawTag(i) |
|
396 |
|
397 zoomL = 1.3 |
|
398 |
|
399 xOffset = 40 |
|
400 |
|
401 if i == 0 then |
|
402 yOffset = 40 |
|
403 tCol = 0xffba00ff |
|
404 tValue = TimeLeft |
|
405 elseif i == 1 then |
|
406 zoomL = 1.1 |
|
407 yOffset = 70 |
|
408 tCol = 0x00ff00ff |
|
409 tValue = wepAmmo[wepIndex] --primShotsLeft |
|
410 elseif i == 2 then |
|
411 zoomL = 1.1 |
|
412 xOffset = 40 + 35 |
|
413 yOffset = 70 |
|
414 tCol = 0xa800ffff |
|
415 tValue = shieldHealth - 80 |
|
416 end |
|
417 |
|
418 DeleteVisualGear(vTag[i]) |
|
419 vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false) |
|
420 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vTag[i]) |
|
421 SetVisualGearValues ( |
|
422 vTag[i], --id |
|
423 -(ScreenWidth/2) + xOffset, --xoffset |
|
424 ScreenHeight - yOffset, --yoffset |
|
425 0, --dx |
|
426 0, --dy |
|
427 zoomL, --zoom |
|
428 1, --~= 0 means align to screen |
|
429 g7, --frameticks |
|
430 tValue, --value |
|
431 240000, --timer |
|
432 tCol --GetClanColor( GetHogClan(CurrentHedgehog) ) |
|
433 ) |
|
434 |
|
435 end |
|
436 |
|
437 function RebuildTeamInfo() |
|
438 |
|
439 -- make a list of individual team names |
|
440 for i = 0, (TeamsCount-1) do |
|
441 teamNameArr[i] = " " -- = i |
|
442 teamSize[i] = 0 |
|
443 teamIndex[i] = 0 |
|
444 teamScore[i] = 0 |
|
445 teamCircsKilled[i] = 0 |
|
446 teamSurfer[i] = false |
|
447 end |
|
448 numTeams = 0 |
|
449 |
|
450 for i = 0, (numhhs-1) do |
|
451 |
|
452 z = 0 |
|
453 unfinished = true |
|
454 while(unfinished == true) do |
|
455 |
|
456 newTeam = true |
|
457 tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name |
|
458 |
|
459 if tempHogTeamName == teamNameArr[z] then |
|
460 newTeam = false |
|
461 unfinished = false |
|
462 end |
|
463 |
|
464 z = z + 1 |
|
465 |
|
466 if z == (TeamsCount-1) then |
|
467 unfinished = false |
|
468 if newTeam == true then |
|
469 teamNameArr[numTeams] = tempHogTeamName |
|
470 numTeams = numTeams + 1 |
|
471 end |
|
472 end |
|
473 |
|
474 end |
|
475 |
|
476 end |
|
477 |
|
478 -- find out how many hogs per team, and the index of the first hog in hhs |
|
479 for i = 0, (TeamsCount-1) do |
|
480 |
|
481 for z = 0, (numhhs-1) do |
|
482 if GetHogTeamName(hhs[z]) == teamNameArr[i] then |
|
483 teamClan[i] = GetHogClan(hhs[z]) |
|
484 if teamSize[i] == 0 then |
|
485 teamIndex[i] = z -- should give starting index |
|
486 end |
|
487 teamSize[i] = teamSize[i] + 1 |
|
488 --add a pointer so this hog appears at i in hhs |
|
489 end |
|
490 end |
|
491 |
|
492 end |
|
493 |
|
494 end |
|
495 |
|
496 -- control |
|
497 function AwardPoints(p) |
|
498 |
|
499 for i = 0,(TeamsCount-1) do |
|
500 if teamClan[i] == GetHogClan(CurrentHedgehog) then |
|
501 teamScore[i] = teamScore[i] + p |
|
502 end |
|
503 end |
|
504 |
|
505 end |
|
506 |
|
507 function AwardKills(t) |
|
508 |
|
509 roundKills = roundKills + 1 |
|
510 |
|
511 for i = 0,(TeamsCount-1) do |
|
512 if teamClan[i] == GetHogClan(CurrentHedgehog) then |
|
513 teamCircsKilled[i] = teamCircsKilled[i] + 1 |
|
514 |
|
515 if teamCircsKilled[i] == 10 then |
|
516 AddCaption(loc("Boom!") .. " +25 " .. loc("points").."!",0xffba00ff,capgrpVolume) |
|
517 AwardPoints(25) |
|
518 elseif teamCircsKilled[i] == 25 then |
|
519 AddCaption(loc("BOOM!") .. " +50 " .. loc("points") .. "!",0xffba00ff,capgrpVolume) |
|
520 AwardPoints(50) |
|
521 elseif teamCircsKilled[i] == 50 then |
|
522 AddCaption(loc("BOOM!") .. loc("BOOM!") .. loc("BOOM!") .. " +100 " .. loc("points") .. "!",0xffba00ff,capgrpVolume) |
|
523 AwardPoints(100) |
|
524 end |
|
525 |
|
526 --[[ |
|
527 if t == "R" then |
|
528 redCircsKilled[i] = redCircsKilled[i] + 1 |
|
529 end |
|
530 --etc |
|
531 --etc |
|
532 ]] |
|
533 end |
|
534 end |
|
535 |
|
536 end |
|
537 |
|
538 ----------------- |
|
539 |
|
540 function bubbleSort(table) |
|
541 |
|
542 for i = 1, #table do |
|
543 for j = 2, #table do |
|
544 if table[j] < table[j-1] then |
|
545 |
|
546 temp = table[j-1] |
|
547 t2 = sdName[j-1] |
|
548 t3 = sdKills[j-1] |
|
549 |
|
550 table[j-1] = table[j] |
|
551 sdName[j-1] = sdName[j] |
|
552 sdKills[j-1] = sdKills[j] |
|
553 |
|
554 table[j] = temp |
|
555 sdName[j] = t2 |
|
556 sdKills[j] = t3 |
|
557 |
|
558 end |
|
559 end |
|
560 end |
|
561 |
|
562 return |
|
563 |
|
564 end |
|
565 |
|
566 ----------------- |
|
567 |
|
568 function CommentOnScore() |
|
569 |
|
570 for i = 0,(TeamsCount-1) do |
|
571 sdScore[i] = teamScore[i] |
|
572 sdKills[i] = teamCircsKilled[i] |
|
573 sdName[i] = teamNameArr[i] |
|
574 end |
|
575 |
|
576 --bubbleSort(sdScore) |
|
577 |
|
578 for i = 0,(TeamsCount-1) do |
|
579 if sdName[i] ~= " " then |
|
580 teamComment[i] = sdName[i] .. " |" .. |
|
581 loc("SCORE") .. ": " .. sdScore[i] .. " " .. loc("points") .. "|" .. |
|
582 loc("KILLS") .. ": " .. sdKills[i] .. " " .. loc("invaders destroyed") .. "|" .. |
|
583 " " .. "|" |
|
584 elseif sdName[i] == " " then |
|
585 teamComment[i] = "|" |
|
586 end |
|
587 end |
|
588 |
|
589 entireC = "" |
|
590 for i = (TeamsCount-1),0,-1 do |
|
591 entireC = entireC .. teamComment[i] |
|
592 end |
|
593 |
|
594 ShowMission("SPACE INVASION", loc("STATUS UPDATE"), loc("Rounds Complete") .. ": " .. roundNumber .. "/" .. roundLimit .. "| " .. "|" .. loc("Team Scores") .. ": |" ..entireC, 4, 1) |
|
595 |
|
596 end |
|
597 |
|
598 function onNewRound() |
|
599 roundNumber = roundNumber + 1 |
|
600 |
|
601 CommentOnScore() |
|
602 |
|
603 -- end game if its at round limit |
|
604 if roundNumber == roundLimit then |
|
605 |
|
606 for i = 0, (TeamsCount-1) do |
|
607 if teamScore[i] > bestScore then |
|
608 bestScore = teamScore[i] |
|
609 bestClan = teamClan[i] |
|
610 end |
|
611 end |
|
612 |
|
613 for i = 0, (numhhs-1) do |
|
614 if GetHogClan(hhs[i]) ~= bestClan then |
|
615 SetEffect(hhs[i], heResurrectable, false) |
|
616 SetHealth(hhs[i],0) |
|
617 end |
|
618 end |
|
619 gameOver = true |
|
620 TurnTimeLeft = 0 --1 |
|
621 TimeLeft = 0 |
|
622 end |
|
623 end |
|
624 |
|
625 -- gaudy racer |
|
626 function CheckForNewRound() |
|
627 |
|
628 ---------- |
|
629 -- new |
|
630 ---------- |
|
631 |
|
632 --[[if gameBegun == true then |
|
633 |
|
634 if RoundHasChanged == true then |
|
635 roundN = roundN + 1 |
|
636 RoundHasChanged = false |
|
637 onNewRound() |
|
638 end |
|
639 |
|
640 if lastRound ~= TotalRounds then -- new round, but not really |
|
641 |
|
642 if RoundHasChanged == false then |
|
643 RoundHasChanged = true |
|
644 end |
|
645 |
|
646 end |
|
647 |
|
648 --AddCaption("RoundN:" .. roundN .. "; " .. "TR: " .. TotalRounds) |
|
649 lastRound = TotalRounds |
|
650 |
|
651 end]] |
|
652 |
|
653 ---------- |
|
654 -- old |
|
655 ---------- |
|
656 if GetHogClan(CurrentHedgehog) == firstClan then |
|
657 onNewRound() |
|
658 end |
|
659 |
|
660 end |
|
661 |
|
662 |
|
663 ---------------------------------------- |
|
664 -- some tumbler/space invaders methods |
|
665 ---------------------------------------- |
|
666 |
|
667 function isATrackedGear(gear) |
|
668 if (GetGearType(gear) == gtExplosives) or |
|
669 (GetGearType(gear) == gtShell) or |
|
670 (GetGearType(gear) == gtFlame) or-- new -- gtBall |
|
671 (GetGearType(gear) == gtBall) |
|
672 then |
|
673 return(true) |
|
674 else |
|
675 return(false) |
|
676 end |
|
677 end |
|
678 |
|
679 function setNewGearValues(gear) |
|
680 |
|
681 if GetGearType(gear) == gtShell then |
|
682 lfs = 50 -- roughly 5 seconds |
|
683 shellID = shellID + 1 |
|
684 setGearValue(gear,"ID",shellID) |
|
685 --nw WriteLnToConsole("Just assigned ID " .. getGearValue(gear,"ID") .. " to this shell") |
|
686 elseif GetGearType(gear) == gtBall then |
|
687 lfs = 5 --70 -- 7s |
|
688 elseif GetGearType(gear) == gtExplosives then |
|
689 lfs = 15 -- 1.5s |
|
690 explosivesID = explosivesID + 1 |
|
691 setGearValue(gear,"ID",explosivesID) |
|
692 setGearValue(gear,"XP", GetX(gear)) |
|
693 setGearValue(gear,"YP", GetY(gear)) |
|
694 --nw WriteLnToConsole("Just assigned ID " .. getGearValue(gear,"ID") .. " to this explosives") |
|
695 elseif GetGearType(gear) == gtFlame then |
|
696 lfs = 5 -- 0.5s |
|
697 else |
|
698 lfs = 100 |
|
699 end |
|
700 |
|
701 setGearValue(gear,"lifespan",lfs) |
|
702 --WriteLnToConsole("I also set its lifespan to " .. lfs) |
|
703 |
|
704 |
|
705 end |
|
706 |
|
707 function HandleLifeSpan(gear) |
|
708 |
|
709 decreaseGearValue(gear,"lifespan") |
|
710 |
|
711 --WriteLnToConsole("Just decreased the lifespan of a gear to " .. getGearValue(gear,"lifespan")) |
|
712 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
713 |
|
714 |
|
715 if getGearValue(gear,"lifespan") == 0 then |
|
716 |
|
717 if GetGearType(gear) == gtShell then |
|
718 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
|
719 WriteLnToConsole("about to delete a shell due to lifespan == 0") |
|
720 --elseif GetGearType(gear) == gtBall then |
|
721 -- AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, true) |
|
722 elseif GetGearType(gear) == gtExplosives then |
|
723 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
724 --nw WriteLnToConsole("about to delete a explosive due to lifespan == 0") |
|
725 elseif GetGearType(gear) == gtFlame then |
|
726 AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false) |
|
727 --WriteLnToConsole("about to delete flame due to lifespan == 0") |
|
728 end |
|
729 |
|
730 DeleteGear(gear) |
|
731 |
|
732 end |
|
733 |
|
734 end |
|
735 |
|
736 -- this prevents ugly barrel clipping sounds when a barrel flies off map limits |
|
737 function DeleteFarFlungBarrel(gear) |
|
738 |
|
739 if GetGearType(gear) == gtExplosives then |
|
740 if (GetX(gear) < -1900) or |
|
741 (GetX(gear) > 6200) or |
|
742 (GetY(gear) < -3400) |
|
743 then |
|
744 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
745 DeleteGear(gear) |
|
746 --SetHealth(gear, 0) |
|
747 --WriteLnToConsole("I'm setting barrel ID " .. getGearValue(gear,"ID") .. " to 0 health because it's been flung too close to the map edges. at Game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
748 end |
|
749 |
|
750 end |
|
751 |
|
752 end |
|
753 |
|
754 ----------------------- |
|
755 --EVENT HANDLERS |
|
756 -- action keys |
|
757 ----------------------- |
|
758 |
|
759 function HandleFlameThrower() |
|
760 |
|
761 -- |
|
762 --flamer |
|
763 |
|
764 fireTimer = fireTimer + 1 |
|
765 if fireTimer == 6 then -- 6 |
|
766 fireTimer = 0 |
|
767 |
|
768 if (wep[wepIndex] == loc("Flamer") ) and (preciseOn == true) and (wepAmmo[wepIndex] > 0) and (stopMovement == false) and (tumbleStarted == true) then |
|
769 |
|
770 wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1 |
|
771 AddCaption( |
|
772 loc("Flamer") .. ": " .. |
|
773 (wepAmmo[wepIndex]/800*100) - (wepAmmo[wepIndex]/800*100)%2 .. "%", |
|
774 wepCol[2], |
|
775 capgrpMessage2 |
|
776 ) |
|
777 DrawTag(3) |
|
778 |
|
779 dx, dy = GetGearVelocity(CurrentHedgehog) --gtFlame -- gtSnowball -- gtAirBomb |
|
780 shell = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtFlame, 0, 0, 0, 0) |
|
781 |
|
782 xdev = 1 + GetRandom(35) --25 |
|
783 xdev = xdev / 100 |
|
784 |
|
785 r = GetRandom(2) |
|
786 if r == 1 then |
|
787 xdev = xdev*-1 |
|
788 end |
|
789 |
|
790 ydev = 1 + GetRandom(35) --25 |
|
791 ydev = ydev / 100 |
|
792 |
|
793 r = GetRandom(2) |
|
794 if r == 1 then |
|
795 ydev = ydev*-1 |
|
796 end |
|
797 |
|
798 --4.5 or 2.5 nonflames --4.5 |
|
799 SetGearVelocity(shell, (dx*4.5)+(xdev*fMod), (dy*4.5)+(ydev*fMod)) --10 |
|
800 |
|
801 end |
|
802 |
|
803 end |
|
804 |
|
805 |
|
806 end |
|
807 |
|
808 function ChangeWeapon() |
|
809 |
|
810 wepIndex = wepIndex + 1 |
|
811 if wepIndex == wepCount then |
|
812 wepIndex = 0 |
|
813 end |
|
814 |
|
815 AddCaption(wep[wepIndex] .. " " .. loc("selected!"), wepCol[wepIndex],capgrpAmmoinfo ) |
|
816 AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), wepCol[wepIndex],capgrpMessage2) |
|
817 |
|
818 end |
|
819 |
|
820 --function onTimer() |
|
821 |
|
822 -- experimental wep |
|
823 --[[SetVisualGearValues(shockwave, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 40, 255, 1, 10, 0, 300, 1, 0xff33ffff) |
|
824 AddCaption("boom") |
|
825 PlaySound(sndWarp) |
|
826 shockwaveHealth = 100 |
|
827 shockwaveRad = 100]] |
|
828 |
|
829 |
|
830 --change wep |
|
831 --ChangeWeapon() |
|
832 |
|
833 -- booster |
|
834 --[[if boosterOn == false then |
|
835 boosterOn = true |
|
836 else |
|
837 boosterOn = false |
|
838 end]] |
|
839 |
|
840 --end |
|
841 |
|
842 -- o rite dis wan iz liek synched n stuff hope full lee |
|
843 -- old method |
|
844 --[[function onPrecise() |
|
845 |
|
846 |
|
847 -- Fire Barrel |
|
848 if (primShotsLeft > 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then |
|
849 |
|
850 shotsFired = shotsFired +1 |
|
851 |
|
852 morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1) |
|
853 |
|
854 primShotsLeft = primShotsLeft - 1 |
|
855 |
|
856 if primShotsLeft == 0 then |
|
857 PlaySound(sndSuddenDeath) |
|
858 AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage) |
|
859 else |
|
860 AddCaption(loc("Ammo") .. ": " .. primShotsLeft) |
|
861 end |
|
862 DrawTag(1) |
|
863 |
|
864 CopyPV(CurrentHedgehog, morte) -- new addition |
|
865 x,y = GetGearVelocity(morte) |
|
866 |
|
867 x = x*2 |
|
868 y = y*2 |
|
869 SetGearVelocity(morte, x, y) |
|
870 |
|
871 |
|
872 elseif (primShotsLeft == 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then |
|
873 AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage) |
|
874 end |
|
875 |
|
876 |
|
877 end]] |
|
878 |
|
879 -- derp tumbler |
|
880 function onPrecise() |
|
881 |
|
882 if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (wepAmmo[wepIndex] > 0) then |
|
883 |
|
884 wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1 |
|
885 --AddCaption(wepAmmo[wepIndex] .. " " .. loc("shots remaining."), wepCol[wepIndex],capgrpMessage2) |
|
886 |
|
887 if wep[wepIndex] == loc("Barrel Launcher") then |
|
888 shotsFired = shotsFired +1 |
|
889 |
|
890 morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1) |
|
891 CopyPV(CurrentHedgehog, morte) -- new addition |
|
892 x,y = GetGearVelocity(morte) |
|
893 x = x*2 |
|
894 y = y*2 |
|
895 SetGearVelocity(morte, x, y) |
|
896 |
|
897 if wepAmmo[wepIndex] == 0 then |
|
898 PlaySound(sndSuddenDeath) |
|
899 AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage) |
|
900 else |
|
901 --AddCaption(loc("Ammo") .. ": " .. wepAmmo[wepIndex]) |
|
902 end |
|
903 DrawTag(1) |
|
904 |
|
905 elseif wep[wepIndex] == loc("Mine Deployer") then |
|
906 morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtAirBomb, 0, 0, 0, 0) |
|
907 SetTimer(morte, 1000) |
|
908 DrawTag(1) |
|
909 end |
|
910 |
|
911 elseif (wepAmmo[wepIndex] == 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then |
|
912 AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage) |
|
913 end |
|
914 |
|
915 preciseOn = true |
|
916 |
|
917 end |
|
918 |
|
919 function onPreciseUp() |
|
920 preciseOn = false |
|
921 end |
|
922 |
|
923 function onLJump() |
|
924 |
|
925 if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then |
|
926 shieldMiser = false |
|
927 if shieldHealth == 80 then |
|
928 AddCaption(loc("Shield Depleted"),0xff0000ff,capgrpMessage) |
|
929 PlaySound(sndMineTick) |
|
930 PlaySound(sndSwitchHog) |
|
931 elseif (beam == false) and (shieldHealth > 80) then |
|
932 beam = true |
|
933 SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 40, 255, 1, 10, 0, 300, 1, 0xa800ffff) |
|
934 AddCaption( loc("Shield ON:") .. " " .. shieldHealth - 80 .. " " .. loc("Power Remaining") ) |
|
935 PlaySound(sndWarp) |
|
936 else |
|
937 beam = false |
|
938 SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 0, 0, 1, 10, 0, 0, 0, 0xa800ffff) |
|
939 AddCaption(loc("Shield OFF:") .. " " .. shieldHealth - 80 .. " " .. loc("Power Remaining") ) |
|
940 end |
|
941 end |
|
942 end |
|
943 |
|
944 function onHJump() |
|
945 |
|
946 if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and |
|
947 (rAlpha == 255) and (radShotsLeft > 0) then |
|
948 rPingTimer = 0 |
|
949 rAlpha = 0 |
|
950 radShotsLeft = radShotsLeft -1 |
|
951 AddCaption(loc("Pings left:") .. " " .. radShotsLeft,GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage) |
|
952 end |
|
953 |
|
954 end |
|
955 |
|
956 ----------------- |
|
957 -- movement keys |
|
958 ----------------- |
|
959 |
|
960 function onLeft() |
|
961 leftOn = true |
|
962 end |
|
963 |
|
964 function onRight() |
|
965 rightOn = true |
|
966 end |
|
967 |
|
968 function onUp() |
|
969 upOn = true |
|
970 end |
|
971 |
|
972 function onDown() |
|
973 downOn = true |
|
974 end |
|
975 |
|
976 function onDownUp() |
|
977 downOn = false |
|
978 end |
|
979 |
|
980 function onUpUp() |
|
981 upOn = false |
|
982 end |
|
983 |
|
984 function onLeftUp() |
|
985 leftOn = false |
|
986 end |
|
987 |
|
988 function onRightUp() |
|
989 rightOn = false |
|
990 end |
|
991 |
|
992 -------------------------- |
|
993 -- other event handlers |
|
994 -------------------------- |
|
995 |
|
996 function onGameInit() |
|
997 GameFlags = 0 + gfRandomOrder |
|
998 Theme = "EarthRise" |
|
999 CaseFreq = 0 |
|
1000 HealthCaseProb = 0 |
|
1001 MinesNum = 0 |
|
1002 Explosives = 0 |
|
1003 Delay = 1000 |
|
1004 |
|
1005 for i = 0, 3 do |
|
1006 vTag[0] = AddVisualGear(0, 0, vgtHealthTag, 0, false) |
|
1007 end |
|
1008 |
|
1009 HideTags() |
|
1010 |
|
1011 wep[0] = loc("Barrel Launcher") |
|
1012 wep[1] = loc("Mine Deployer") |
|
1013 wep[2] = loc("Flamer") |
|
1014 |
|
1015 wepCol[0] = 0x78818eff |
|
1016 wepCol[1] = 0xa12a77ff |
|
1017 wepCol[2] = 0xf49318ff |
|
1018 |
|
1019 wepCount = 3 |
|
1020 |
|
1021 end |
|
1022 |
|
1023 function onGameStart() |
|
1024 |
|
1025 if (MinesTime == -1000) or (MinesTime == 0) then |
|
1026 roundLimit = 3 |
|
1027 else |
|
1028 roundLimit = (MinesTime / 1000) |
|
1029 end |
|
1030 |
|
1031 ShowMission ( |
|
1032 "SPACE INVASION", |
|
1033 loc("a Hedgewars mini-game"), |
|
1034 |
|
1035 loc("Destroy invaders to score points.") .. "|" .. |
|
1036 " " .. "|" .. |
|
1037 |
|
1038 loc("Round Limit") .. ": " .. roundLimit .. "|" .. |
|
1039 loc("Turn Time") .. ": " .. (TurnTime/1000) .. loc("sec") .. "|" .. |
|
1040 " " .. "|" .. |
|
1041 |
|
1042 loc("Movement: [Up], [Down], [Left], [Right]") .. "|" .. |
|
1043 loc("Fire") .. ": " .. loc("[Left Shift]") .. "|" .. |
|
1044 loc("Toggle Shield") .. ": " .. loc("[Enter]") .. "|" .. |
|
1045 loc("Radar Ping") .. ": " .. loc("[Backspace]") .. "|" .. |
|
1046 |
|
1047 --" " .. "|" .. |
|
1048 --LOC_NOT("Invaders List: ") .. "|" .. |
|
1049 --LOC_NOT("Blue Jabberwock: (50 points)") .. "|" .. |
|
1050 --LOC_NOT("Red Warbler: (10 points)") .. "|" .. |
|
1051 --LOC_NOT("Orange Gob: (5 points)") .. "|" .. |
|
1052 --LOC_NOT("Green Wrangler: (3 points)") .. "|" .. |
|
1053 |
|
1054 |
|
1055 "", 4, 4000 |
|
1056 ) |
|
1057 |
|
1058 CreateMeSomeCircles() |
|
1059 RebuildTeamInfo() -- control |
|
1060 lastRound = TotalRounds |
|
1061 |
|
1062 end |
|
1063 |
|
1064 function onScreenResize() |
|
1065 |
|
1066 -- redraw Tags so that their screen locations are updated |
|
1067 if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then |
|
1068 DrawTag(0) |
|
1069 DrawTag(1) |
|
1070 DrawTag(2) |
|
1071 end |
|
1072 |
|
1073 end |
|
1074 |
|
1075 function onNewTurn() |
|
1076 |
|
1077 --primShotsLeft = primShotsMax |
|
1078 radShotsLeft = 2 |
|
1079 stopMovement = false |
|
1080 tumbleStarted = false |
|
1081 boosterOn = false |
|
1082 beam = false |
|
1083 shieldHealth = 30 + 80 -- 50 = 5 secs, roughly |
|
1084 shockwaveHealth = 0 |
|
1085 |
|
1086 RK = 0 |
|
1087 GK = 0 |
|
1088 BK = 0 |
|
1089 OK = 0 |
|
1090 SK = 0 |
|
1091 roundKills = 0 |
|
1092 shieldMiser = true |
|
1093 fierceComp = false |
|
1094 shotsFired = 0 |
|
1095 shotsHit = 0 |
|
1096 sniperHits = 0 |
|
1097 pointBlankHits = 0 |
|
1098 chainLength = 0 |
|
1099 chainCounter = 0 |
|
1100 SurfTime = 12 |
|
1101 |
|
1102 ------------------------- |
|
1103 -- gaudy racer |
|
1104 ------------------------- |
|
1105 CheckForNewRound() |
|
1106 |
|
1107 -- Handle Starting Stage of Game |
|
1108 if (gameOver == false) and (gameBegun == false) then |
|
1109 gameBegun = true |
|
1110 roundNumber = 0 -- 0 |
|
1111 firstClan = GetHogClan(CurrentHedgehog) |
|
1112 end |
|
1113 |
|
1114 if gameOver == true then |
|
1115 gameBegun = false |
|
1116 stopMovement = true |
|
1117 tumbleStarted = false |
|
1118 SetMyCircles(false) |
|
1119 end |
|
1120 |
|
1121 |
|
1122 ------- |
|
1123 -- tumbler |
|
1124 ---- |
|
1125 |
|
1126 wepAmmo[0] = 5 |
|
1127 wepAmmo[1] = 2 |
|
1128 wepAmmo[2] = 5000 |
|
1129 wepIndex = 2 |
|
1130 ChangeWeapon() |
|
1131 |
|
1132 |
|
1133 HideTags() |
|
1134 |
|
1135 --------------- |
|
1136 --------------- |
|
1137 --AddCaption("num g: " .. numGears() ) |
|
1138 --WriteLnToConsole("onNewTurn, I just set a bunch of variables to their necessary states. This was done at:") |
|
1139 --WriteLnToConsole("The above occured at Game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1140 |
|
1141 end |
|
1142 |
|
1143 function ThingsToBeRunOnGears(gear) |
|
1144 |
|
1145 HandleLifeSpan(gear) |
|
1146 DeleteFarFlungBarrel(gear) |
|
1147 |
|
1148 if CirclesAreGo == true then |
|
1149 CheckVarious(gear) |
|
1150 ProjectileTrack(gear) |
|
1151 end |
|
1152 |
|
1153 end |
|
1154 |
|
1155 |
|
1156 function onGameTick20() |
|
1157 |
|
1158 |
|
1159 --WriteLnToConsole("Start of GameTick") |
|
1160 |
|
1161 HandleCircles() |
|
1162 |
|
1163 -- derp |
|
1164 --if shockwaveHealth > 0 then |
|
1165 -- shockwaveHealth = shockwaveHealth - 1 |
|
1166 -- shockwaveRad = shockwaveRad + 5 |
|
1167 --end |
|
1168 |
|
1169 |
|
1170 if GameTime%100 == 0 then |
|
1171 |
|
1172 if beam == true then |
|
1173 shieldHealth = shieldHealth - 1 |
|
1174 if shieldHealth < 80 then -- <= 80 |
|
1175 shieldHealth = 80 |
|
1176 beam = false |
|
1177 AddCaption(loc("Shield Depleted"),0xff0000ff,capgrpMessage) |
|
1178 PlaySound(sndMineTick) |
|
1179 PlaySound(sndSwitchHog) |
|
1180 end |
|
1181 end |
|
1182 |
|
1183 |
|
1184 |
|
1185 --nw WriteLnToConsole("Starting ThingsToBeRunOnGears()") |
|
1186 |
|
1187 runOnGears(ThingsToBeRunOnGears) |
|
1188 |
|
1189 --nw WriteLnToConsole("Finished ThingsToBeRunOnGears()") |
|
1190 |
|
1191 --runOnGears(HandleLifeSpan) |
|
1192 --runOnGears(DeleteFarFlungBarrel) |
|
1193 |
|
1194 if CirclesAreGo == true and CurrentHedgehog ~= nil then |
|
1195 CheckDistances() |
|
1196 --runOnGears(CheckVarious) -- used to be in handletracking for some bizarre reason |
|
1197 --runOnGears(ProjectileTrack) |
|
1198 end |
|
1199 |
|
1200 -- white smoke trail as player falls from the sky |
|
1201 if (TimeLeft <= 0) and (stopMovement == true) and (CurrentHedgehog ~= nil) then |
|
1202 j,k = GetGearVelocity(CurrentHedgehog) |
|
1203 if (j ~= 0) and (k ~= 0) then |
|
1204 AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, true) |
|
1205 end |
|
1206 end |
|
1207 |
|
1208 --nw WriteLnToConsole("Finished 100Timer") |
|
1209 |
|
1210 end |
|
1211 |
|
1212 |
|
1213 -- start the player tumbling with a boom once their turn has actually begun |
|
1214 if (tumbleStarted == false) and (gameOver == false) then |
|
1215 if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then |
|
1216 --AddCaption(LOC_NOT("Good to go!")) |
|
1217 tumbleStarted = true |
|
1218 TimeLeft = div(TurnTime, 1000) --45 |
|
1219 FadeAlpha = 0 |
|
1220 rAlpha = 255 |
|
1221 AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1) |
|
1222 DrawTag(0) |
|
1223 DrawTag(1) |
|
1224 DrawTag(2) |
|
1225 SetMyCircles(true) |
|
1226 end |
|
1227 end |
|
1228 |
|
1229 --WriteLnToConsole("Finished initial check") |
|
1230 |
|
1231 if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then |
|
1232 |
|
1233 --AddCaption(GetX(CurrentHedgehog) .. ";" .. GetY(CurrentHedgehog) ) |
|
1234 |
|
1235 -- Calculate and display turn time |
|
1236 if GameTime%1000 == 0 then |
|
1237 TimeLeft = TimeLeft - 1 |
|
1238 |
|
1239 if TimeLeft >= 0 then |
|
1240 --AddCaption(LOC_NOT("Time Left: ") .. TimeLeft) |
|
1241 DrawTag(0) |
|
1242 end |
|
1243 |
|
1244 end |
|
1245 |
|
1246 --WriteLnToConsole("Finished timeleft calculations") |
|
1247 |
|
1248 ------------------------------- |
|
1249 -- Player has run out of luck (out of time or hit by gtShell) |
|
1250 ------------------------------- |
|
1251 -- checks in FloatyThings |
|
1252 if PlayerIsFine() == false then |
|
1253 TimeLeft = 0 |
|
1254 end |
|
1255 |
|
1256 --WriteLnToConsole("successfully checked playerIsFine") |
|
1257 |
|
1258 if (TimeLeft == 0) then |
|
1259 if (stopMovement == false) then --time to stop the player |
|
1260 stopMovement = true |
|
1261 boosterOn = false |
|
1262 beam = false |
|
1263 upOn = false |
|
1264 down = false |
|
1265 leftOn = false |
|
1266 rightOn = false |
|
1267 SetMyCircles(false) |
|
1268 HideTags() |
|
1269 rAlpha = 255 |
|
1270 --nw WriteLnToConsole("Player is out of luck") |
|
1271 |
|
1272 if shieldMiser == true then |
|
1273 |
|
1274 p = (roundKills*3.5) - ((roundKills*3.5)%1) + 2 |
|
1275 |
|
1276 AddCaption(loc("Shield Miser!") .." +" .. p .." ".. loc("points") .. "!",0xffba00ff,capgrpAmmoinfo) |
|
1277 AwardPoints(p) |
|
1278 end |
|
1279 |
|
1280 if ((shotsHit / shotsFired * 100) >= 80) and (shotsFired > 4) then |
|
1281 AddCaption(loc("Accuracy Bonus!") .. " +15 " .. loc("points") .. "!",0xffba00ff,capgrpVolume) |
|
1282 AwardPoints(15) |
|
1283 end |
|
1284 |
|
1285 end |
|
1286 else -- remove this if you want tumbler to fall slowly on death |
|
1287 ------------------------------- |
|
1288 -- Player is still in luck |
|
1289 ------------------------------- |
|
1290 |
|
1291 |
|
1292 --WriteLnToConsole("about to do chainCounter checks") |
|
1293 if chainCounter > 0 then |
|
1294 chainCounter = chainCounter -1 |
|
1295 if chainCounter == 0 then |
|
1296 chainLength = 0 |
|
1297 end |
|
1298 end |
|
1299 |
|
1300 -- handle movement based on IO |
|
1301 if GameTime%100 == 0 then -- 100 |
|
1302 --nw WriteLnToConsole("Start of Player MoveTimer") |
|
1303 |
|
1304 --------------- |
|
1305 -- new trail code |
|
1306 --------------- |
|
1307 -- the trail lets you know you have 5s left to pilot, akin to birdy feathers |
|
1308 if (TimeLeft <= 5) and (TimeLeft > 0) then --vgtSmoke |
|
1309 tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, true) |
|
1310 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
1311 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(GetHogClan(CurrentHedgehog)) ) |
|
1312 end |
|
1313 -------------- |
|
1314 -------------- |
|
1315 |
|
1316 ------------------------ |
|
1317 -- surfer achievement |
|
1318 ------------------------ |
|
1319 |
|
1320 if (WaterLine - GetY(CurrentHedgehog)) < 15 then |
|
1321 SurfTime = SurfTime -1 |
|
1322 end |
|
1323 |
|
1324 if SurfTime ~= 12 then |
|
1325 |
|
1326 SurfTime = SurfTime - 1 |
|
1327 if SurfTime <= 0 then |
|
1328 for i = 0,(TeamsCount-1) do |
|
1329 if teamClan[i] == GetHogClan(CurrentHedgehog) and (teamSurfer[i] == false) then |
|
1330 teamSurfer[i] = true |
|
1331 SurfTime = 12 |
|
1332 AddCaption(loc("Surfer! +15 points!"),0xffba00ff,capgrpVolume) |
|
1333 AwardPoints(15) |
|
1334 end |
|
1335 end |
|
1336 end |
|
1337 end |
|
1338 |
|
1339 |
|
1340 dx, dy = GetGearVelocity(CurrentHedgehog) |
|
1341 |
|
1342 --WriteLnToConsole("I just got the velocity of currenthedgehog. It is dx: " .. dx .. "; dy: " .. dy) |
|
1343 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1344 |
|
1345 if boosterOn == true then |
|
1346 tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtDust, 0, false) |
|
1347 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
1348 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, 1, g9, GetClanColor(GetHogClan(CurrentHedgehog)) ) |
|
1349 dxlimit = 0.8*fMod |
|
1350 dylimit = 0.8*fMod |
|
1351 else |
|
1352 dxlimit = 0.4*fMod |
|
1353 dylimit = 0.4*fMod |
|
1354 end |
|
1355 |
|
1356 if dx > dxlimit then |
|
1357 dx = dxlimit |
|
1358 end |
|
1359 if dy > dylimit then |
|
1360 dy = dylimit |
|
1361 end |
|
1362 if dx < -dxlimit then |
|
1363 dx = -dxlimit |
|
1364 end |
|
1365 if dy < -dylimit then |
|
1366 dy = -dylimit |
|
1367 end |
|
1368 |
|
1369 |
|
1370 if leftOn == true then |
|
1371 dx = dx - 0.1*fMod |
|
1372 end |
|
1373 if rightOn == true then |
|
1374 dx = dx + 0.1*fMod |
|
1375 end |
|
1376 |
|
1377 if upOn == true then |
|
1378 dy = dy - 0.1*fMod |
|
1379 end |
|
1380 if downOn == true then |
|
1381 dy = dy + 0.1*fMod |
|
1382 end |
|
1383 |
|
1384 SetGearVelocity(CurrentHedgehog, dx, dy) |
|
1385 |
|
1386 --WriteLnToConsole("I just SET the velocity of currenthedgehog. It is now dx: " .. dx .. "; dy: " .. dy) |
|
1387 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1388 --nw WriteLnToConsole("End of Player MoveTimer") |
|
1389 |
|
1390 end |
|
1391 |
|
1392 |
|
1393 HandleFlameThrower() |
|
1394 |
|
1395 |
|
1396 end -- new end I put here to check if he's still alive or not |
|
1397 |
|
1398 end |
|
1399 |
|
1400 --WriteLnToConsole("End of GameTick") |
|
1401 |
|
1402 end |
|
1403 |
|
1404 function onGearDamage(gear, damage) |
|
1405 if GetGearType(gear) == gtHedgehog then |
|
1406 if (fierceComp == false) and (damage >= 60) and (GetHogClan(gear) ~= GetHogClan(CurrentHedgehog)) then |
|
1407 fierceComp = true |
|
1408 AddCaption(loc("Fierce Competition!") .. " +8 " .. loc("points") .. "!",0xffba00ff,capgrpGameState) |
|
1409 AwardPoints(8) |
|
1410 end |
|
1411 end |
|
1412 end |
|
1413 |
|
1414 function onGearResurrect(gear) |
|
1415 |
|
1416 -- did I fall into the water? well, that was a stupid thing to do |
|
1417 if gear == CurrentHedgehog then |
|
1418 TimeLeft = 0 |
|
1419 --WriteLnToConsole("Current hedgehog just drowned himself") |
|
1420 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1421 end |
|
1422 |
|
1423 end |
|
1424 |
|
1425 function onGearAdd(gear) |
|
1426 |
|
1427 if isATrackedGear(gear) then |
|
1428 trackGear(gear) |
|
1429 setNewGearValues(gear) |
|
1430 end |
|
1431 |
|
1432 --if GetGearType(gear) == gtBall then |
|
1433 -- SetTimer(gear, 5000) |
|
1434 --end |
|
1435 |
|
1436 if GetGearType(gear) == gtHedgehog then |
|
1437 SetEffect(gear, heResurrectable, true) |
|
1438 |
|
1439 ----------- |
|
1440 -- control |
|
1441 hhs[numhhs] = gear |
|
1442 numhhs = numhhs + 1 |
|
1443 ----------- |
|
1444 end |
|
1445 |
|
1446 end |
|
1447 |
|
1448 function onGearDelete(gear) |
|
1449 |
|
1450 |
|
1451 --[[if GetGearType(gear) == gtShell then |
|
1452 --nw WriteLnToConsole("on GearDelete call. Shell ID: " .. getGearValue(gear,"ID")) |
|
1453 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1454 |
|
1455 --if CurrentHedgehog ~= nil then |
|
1456 -- WriteLnToConsole("As it happens, player is at: " .. GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog)) |
|
1457 --end |
|
1458 elseif GetGearType(gear) == gtExplosives then |
|
1459 --nw WriteLnToConsole("on GearDelete call. Explosives ID: " .. getGearValue(gear,"ID")) |
|
1460 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1461 |
|
1462 --if CurrentHedgehog ~= nil then |
|
1463 -- WriteLnToConsole("As it happens, player is at: " .. GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog)) |
|
1464 --end |
|
1465 elseif GetGearType(gear) == gtFlame then |
|
1466 --WriteLnToConsole("on GearDelete flame") |
|
1467 end]] |
|
1468 |
|
1469 if isATrackedGear(gear) then |
|
1470 trackDeletion(gear) |
|
1471 end |
|
1472 |
|
1473 if CurrentHedgehog ~= nil then |
|
1474 FollowGear(CurrentHedgehog) |
|
1475 end |
|
1476 |
|
1477 end |
|
1478 |
|
1479 |
|
1480 |
|
1481 ------------------------------------------------------------ |
|
1482 ------------------------------------------------------------ |
|
1483 ------------------------------------------------------------ |
|
1484 ------------------------------------------------------------ |
|
1485 -- FLOATY THINGS |
|
1486 -- "I'll make this into a generic library and code properly |
|
1487 -- when I have more time and feel less lazy" |
|
1488 ------------------------------------------------------------ |
|
1489 ------------------------------------------------------------ |
|
1490 ------------------------------------------------------------ |
|
1491 ------------------------------------------------------------ |
|
1492 |
|
1493 function DoHorribleThings(cUID) |
|
1494 |
|
1495 -- work out the distance to the target |
|
1496 g1X, g1Y = GetGearPosition(CurrentHedgehog) |
|
1497 g2X, g2Y = vCircX[cUID], vCircY[cUID] |
|
1498 q = g1X - g2X |
|
1499 w = g1Y - g2Y |
|
1500 r = math.sqrt( (q*q) + (w*w) ) --alternate |
|
1501 |
|
1502 opp = w |
|
1503 if opp < 0 then |
|
1504 opp = opp*-1 |
|
1505 end |
|
1506 |
|
1507 -- work out the angle (theta) to the target |
|
1508 t = math.deg ( math.asin(opp / r) ) |
|
1509 |
|
1510 -- based on the radius of the radar, calculate what x/y displacement should be |
|
1511 NR = 150 -- radius at which to draw circs |
|
1512 NX = math.cos( math.rad(t) ) * NR |
|
1513 NY = math.sin( math.rad(t) ) * NR |
|
1514 |
|
1515 -- displace xy based on where this thing actually is |
|
1516 |
|
1517 if r < NR then |
|
1518 rCircX[cUID] = g2X |
|
1519 elseif q > 0 then |
|
1520 rCircX[cUID] = g1X - NX |
|
1521 else |
|
1522 rCircX[cUID] = g1X + NX |
|
1523 end |
|
1524 |
|
1525 if r < NR then |
|
1526 rCircY[cUID] = g2Y |
|
1527 elseif w > 0 then |
|
1528 rCircY[cUID] = g1Y - NY |
|
1529 else |
|
1530 rCircY[cUID] = g1Y + NY |
|
1531 end |
|
1532 |
|
1533 end |
|
1534 |
|
1535 function PlayerIsFine() |
|
1536 return (playerIsFine) |
|
1537 end |
|
1538 |
|
1539 function GetDistFromXYtoXY(a, b, c, d) |
|
1540 q = a - c |
|
1541 w = b - d |
|
1542 return ( (q*q) + (w*w) ) |
|
1543 end |
|
1544 |
|
1545 function GetDistFromGearToGear(gear, gear2) |
|
1546 |
|
1547 g1X, g1Y = GetGearPosition(gear) |
|
1548 g2X, g2Y = GetGearPosition(gear2) |
|
1549 q = g1X - g2X |
|
1550 w = g1Y - g2Y |
|
1551 |
|
1552 |
|
1553 --[[ |
|
1554 WriteLnToConsole("I just got the position of two gears and calculated the distance betwen them") |
|
1555 if gear == CurrentHedgehog then |
|
1556 WriteLnToConsole("Gear 1 is CurrentHedgehog.") |
|
1557 end |
|
1558 if gear2 == CurrentHedgehog then |
|
1559 WriteLnToConsole("Gear 2 is CurrentHedgehog.") |
|
1560 end |
|
1561 WriteLnToConsole("G1X: " .. g1X .. "; G1Y: " .. g1Y) |
|
1562 WriteLnToConsole("G2X: " .. g2X .. "; G2Y: " .. g2Y) |
|
1563 WriteLnToConsole("Their distance is " .. (q*q) + (w*w) ) |
|
1564 WriteLnToConsole("The above events occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1565 ]] |
|
1566 |
|
1567 |
|
1568 return ( (q*q) + (w*w) ) |
|
1569 |
|
1570 end |
|
1571 |
|
1572 function GetDistFromGearToXY(gear, g2X, g2Y) |
|
1573 |
|
1574 g1X, g1Y = GetGearPosition(gear) |
|
1575 q = g1X - g2X |
|
1576 w = g1Y - g2Y |
|
1577 |
|
1578 |
|
1579 --[[WriteLnToConsole("I just got the position of a gear and calculated the distance betwen it and another xy") |
|
1580 if gear == CurrentHedgehog then |
|
1581 WriteLnToConsole("Gear 1 is CurrentHedgehog.") |
|
1582 end |
|
1583 |
|
1584 WriteLnToConsole("G1X: " .. g1X .. "; G1Y: " .. g1Y) |
|
1585 WriteLnToConsole("Other X: " .. g2X .. "; Other Y: " .. g2Y) |
|
1586 WriteLnToConsole("Their distance is " .. (q*q) + (w*w) ) |
|
1587 WriteLnToConsole("The above events occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1588 ]] |
|
1589 |
|
1590 |
|
1591 return ( (q*q) + (w*w) ) |
|
1592 |
|
1593 |
|
1594 end |
|
1595 |
|
1596 function CreateMeSomeCircles() |
|
1597 |
|
1598 for i = 0, 7 do |
|
1599 vCCount = vCCount +1 |
|
1600 vCirc[i] = AddVisualGear(0,0,vgtCircle,0,true) |
|
1601 |
|
1602 rCirc[i] = AddVisualGear(0,0,vgtCircle,0,true) |
|
1603 rCircX[i] = 0 |
|
1604 rCircY[i] = 0 |
|
1605 |
|
1606 vCircDX[i] = 0 |
|
1607 vCircDY[i] = 0 |
|
1608 |
|
1609 vType[i] = "generic" |
|
1610 vCounter[i] = 0 |
|
1611 vCounterLim[i] = 150 |
|
1612 vCircScore[i] = 0 |
|
1613 vCircHealth[i] = 1 |
|
1614 |
|
1615 vCircMinA[i] = 80 --80 --20 |
|
1616 vCircMaxA[i] = 255 |
|
1617 vCircType[i] = 1 --1 |
|
1618 vCircPulse[i] = 10 |
|
1619 vCircFuckAll[i] = 0 |
|
1620 vCircRadius[i] = 0 |
|
1621 vCircWidth[i] = 3 --5 |
|
1622 |
|
1623 vCircRadMax[i] = 0 |
|
1624 vCircRadMin[i] = 0 |
|
1625 vCircRadDir[i] = -1 |
|
1626 vCircRadCounter[i] = 0 |
|
1627 |
|
1628 vCircX[i], vCircY[i] = 0,0 |
|
1629 |
|
1630 vCircCol[i] = 0xff00ffff |
|
1631 |
|
1632 SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], vCircCol[i]) |
|
1633 |
|
1634 SetVisualGearValues(rCirc[i], 0, 0, 100, 255, 1, 10, 0, 40, 3, vCircCol[i]) |
|
1635 |
|
1636 end |
|
1637 |
|
1638 pShield = AddVisualGear(0,0,vgtCircle,0,true) |
|
1639 --SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 80, 200, 1, 10, 0, 200, 5, 0xff00ffff) |
|
1640 |
|
1641 |
|
1642 shockwave = AddVisualGear(0,0,vgtCircle,0,true) |
|
1643 |
|
1644 end |
|
1645 |
|
1646 function IGotMeASafeXYValue(i) |
|
1647 |
|
1648 acceptibleDistance = 800 |
|
1649 |
|
1650 -- put this in here to thwart attempts at repositioning and test sanity limit |
|
1651 --vCircX[i] = GetX(CurrentHedgehog)+250 |
|
1652 --vCircY[i] = GetY(CurrentHedgehog)+250 |
|
1653 |
|
1654 vCircX[i] = GetRandom(5000) |
|
1655 vCircY[i] = GetRandom(2000) |
|
1656 dist = GetDistFromGearToXY(CurrentHedgehog, vCircX[i], vCircY[i]) |
|
1657 if dist > acceptibleDistance*acceptibleDistance then |
|
1658 return(true) |
|
1659 else |
|
1660 return(false) |
|
1661 end |
|
1662 |
|
1663 end |
|
1664 |
|
1665 function CircleDamaged(i) |
|
1666 |
|
1667 res = "" |
|
1668 vCircHealth[i] = vCircHealth[i] -1 |
|
1669 |
|
1670 if vCircHealth[i] <= 0 then |
|
1671 -- circle is dead, do death effects/consequences |
|
1672 |
|
1673 vCircActive[i] = false |
|
1674 |
|
1675 if (vType[i] == "drone") then |
|
1676 PlaySound(sndHellishImpact4) |
|
1677 TimeLeft = TimeLeft + 4 |
|
1678 AddCaption(loc("Time Extended!") .. "+" .. 4 .. loc("sec"), 0xff0000ff,capgrpMessage ) |
|
1679 DrawTag(0) |
|
1680 |
|
1681 morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1) |
|
1682 SetHealth(morte, 0) |
|
1683 |
|
1684 RK = RK + 1 |
|
1685 if RK == 5 then |
|
1686 RK = 0 |
|
1687 AddCaption(loc("Drone Hunter!") .. " +10 " .. loc("points") .. "!",0xffba00ff,capgrpMessage2) |
|
1688 AwardPoints(10) |
|
1689 end |
|
1690 |
|
1691 elseif (vType[i] == "ammo") then |
|
1692 AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false) |
|
1693 PlaySound(sndExplosion) |
|
1694 PlaySound(sndShotgunReload) |
|
1695 wepAmmo[0] = wepAmmo[0] +3 |
|
1696 --primShotsLeft = primShotsLeft + 3 |
|
1697 AddCaption("+" .. 3 .. " " .. loc("Ammo"), 0x00ff00ff,capgrpMessage) |
|
1698 DrawTag(1) |
|
1699 |
|
1700 GK = GK + 1 |
|
1701 if GK == 3 then |
|
1702 GK = 0 |
|
1703 AddCaption(loc("Ammo Maniac!") .. " +5 " .. loc("points") .. "!",0xffba00ff,capgrpMessage2) |
|
1704 AwardPoints(5) |
|
1705 end |
|
1706 |
|
1707 elseif (vType[i] == "bonus") then |
|
1708 |
|
1709 AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false) |
|
1710 PlaySound(sndExplosion) |
|
1711 |
|
1712 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1713 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1714 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1715 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1716 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1717 AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, false) |
|
1718 |
|
1719 PlaySound(sndVaporize) |
|
1720 --sndWarp sndMineTick --sndSwitchHog --sndSuddenDeath |
|
1721 |
|
1722 shieldHealth = shieldHealth + 30 |
|
1723 AddCaption(loc("Shield boosted! +30 power"), 0xa800ffff,capgrpMessage) |
|
1724 if shieldHealth >= 250 then |
|
1725 shieldHealth = 250 |
|
1726 AddCaption(loc("Shield is fully recharged!"),0xa800ffff,capgrpMessage) |
|
1727 end |
|
1728 DrawTag(2) |
|
1729 |
|
1730 OK = OK + 1 |
|
1731 if OK == 3 then |
|
1732 OK = 0 |
|
1733 AddCaption(loc("Shield Seeker!") .. " + 10 " .. loc("points") .. "!",0xffba00ff,capgrpMessage2) |
|
1734 AwardPoints(10) |
|
1735 end |
|
1736 |
|
1737 elseif (vType[i] == "blueboss") then |
|
1738 PlaySound(sndHellishImpact3) |
|
1739 AddCaption(loc("Boss defeated!") .. " +30 " .. loc("points") .. "!", 0x0050ffff,capgrpMessage) |
|
1740 |
|
1741 morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1) |
|
1742 SetHealth(morte, 0) |
|
1743 |
|
1744 BK = BK + 1 |
|
1745 if BK == 2 then |
|
1746 BK = 0 |
|
1747 AddCaption(loc("Boss Slayer!") .. " +25 " .. loc("points") .. "!",0xffba00ff,capgrpMessage2) |
|
1748 AwardPoints(25) |
|
1749 end |
|
1750 |
|
1751 end |
|
1752 |
|
1753 AwardPoints(vCircScore[i]) |
|
1754 AwardKills() |
|
1755 SetUpCircle(i) |
|
1756 res = "fatal" |
|
1757 |
|
1758 chainCounter = 3000 |
|
1759 chainLength = chainLength + 1 |
|
1760 if chainLength > 1 then |
|
1761 AddCaption( chainLength .. "-" .. loc("Hit Combo!") .. " +" .. chainLength*2 .. " " .. loc("points") .. "!",0xffba00ff,capgrpAmmostate) |
|
1762 AwardPoints(chainLength*2) |
|
1763 end |
|
1764 |
|
1765 else |
|
1766 -- circle is merely damaged |
|
1767 -- do damage effects/sounds |
|
1768 AddVisualGear(vCircX[i], vCircY[i], vgtSteam, 0, false) |
|
1769 r = GetRandom(4) |
|
1770 if r == 0 then |
|
1771 PlaySound(sndHellishImpact1) |
|
1772 elseif r == 1 then |
|
1773 PlaySound(sndHellishImpact2) |
|
1774 elseif r == 2 then |
|
1775 PlaySound(sndHellishImpact3) |
|
1776 elseif r == 3 then |
|
1777 PlaySound(sndHellishImpact4) |
|
1778 end |
|
1779 res = "non-fatal" |
|
1780 |
|
1781 end |
|
1782 |
|
1783 return(res) |
|
1784 |
|
1785 end |
|
1786 |
|
1787 function SetUpCircle(i) |
|
1788 |
|
1789 |
|
1790 r = GetRandom(10) |
|
1791 --r = 8 |
|
1792 -- 80% of spawning either red/green |
|
1793 if r <= 7 then |
|
1794 |
|
1795 --r = GetRandom(5) |
|
1796 r = GetRandom(2) |
|
1797 --r = 1 |
|
1798 if r == 0 then |
|
1799 --if r <= 2 then |
|
1800 vCircCol[i] = 0xff0000ff -- red |
|
1801 vType[i] = "drone" |
|
1802 vCircRadMin[i] = 50 *5 |
|
1803 vCircRadMax[i] = 90 *5 |
|
1804 vCounterLim[i] = 150 |
|
1805 vCircScore[i] = 10 |
|
1806 vCircHealth[i] = 1 |
|
1807 --else |
|
1808 elseif r == 1 then |
|
1809 vCircCol[i] = 0x00ff00ff -- green |
|
1810 vType[i] = "ammo" |
|
1811 vCircRadMin[i] = 25 *7 |
|
1812 vCircRadMax[i] = 30 *7 |
|
1813 vCircScore[i] = 3 |
|
1814 vCircHealth[i] = 1 |
|
1815 end |
|
1816 |
|
1817 -- 20% chance of spawning boss or bonus |
|
1818 else |
|
1819 r = GetRandom(5) |
|
1820 --r = GetRandom(2) |
|
1821 --r = 0 |
|
1822 if r <= 1 then |
|
1823 --if r == 0 then |
|
1824 vCircCol[i] = 0x0050ffff -- sexy blue |
|
1825 vType[i] = "blueboss" |
|
1826 vCircRadMin[i] = 100*5 |
|
1827 vCircRadMax[i] = 180*5 |
|
1828 vCircWidth[i] = 1 |
|
1829 vCounterLim[i] = 100 |
|
1830 vCircScore[i] = 30 |
|
1831 vCircHealth[i] = 3 |
|
1832 else |
|
1833 --elseif r == 1 then |
|
1834 --vCircCol[i] = 0xffae00ff -- orange |
|
1835 vCircCol[i] = 0xa800ffff -- purp |
|
1836 vType[i] = "bonus" |
|
1837 vCircRadMin[i] = 20 *7 |
|
1838 vCircRadMax[i] = 40 *7 |
|
1839 vCircScore[i] = 5 |
|
1840 vCircHealth[i] = 1 |
|
1841 end |
|
1842 |
|
1843 end |
|
1844 |
|
1845 -- regenerate circle xy if too close to player or until sanity limit kicks in |
|
1846 reN = 0 |
|
1847 --zzz = 0 |
|
1848 while (reN < 10) do |
|
1849 if IGotMeASafeXYValue(i) == false then |
|
1850 reN = reN + 1 |
|
1851 --zzz = zzz + 1 |
|
1852 else |
|
1853 reN = 15 |
|
1854 end |
|
1855 end |
|
1856 --AddCaption("Took me this many retries: " .. zzz) -- number of times it took to work |
|
1857 |
|
1858 vCircRadius[i] = vCircRadMax[i] - GetRandom(vCircRadMin[i]) |
|
1859 |
|
1860 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i]) |
|
1861 SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], vCircWidth[i], vCircCol[i]-0x000000ff) |
|
1862 -- - -0x000000ff |
|
1863 |
|
1864 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(rCirc[i]) |
|
1865 SetVisualGearValues(rCirc[i], 0, 0, g3, g4, g5, g6, g7, g8, g9, vCircCol[i]-0x000000ff) |
|
1866 |
|
1867 |
|
1868 vCircActive[i] = true -- new |
|
1869 |
|
1870 --nw WriteLnToConsole("CIRC " .. i .. ": X: " .. vCircX[i] .. "; Y: " .. vCircY[i]) |
|
1871 --nw WriteLnToConsole("CIRC " .. i .. ": dX: " .. vCircDX[i] .. "; dY: " .. vCircDY[i]) |
|
1872 --nw WriteLnToConsole("CIRC " .. i .. ": RAD:" .. vCircRadius[i]) |
|
1873 |
|
1874 end |
|
1875 |
|
1876 function SetMyCircles(s) |
|
1877 |
|
1878 CirclesAreGo = s |
|
1879 playerIsFine = s |
|
1880 |
|
1881 if s == true then |
|
1882 --nw WriteLnToConsole("About to set up all circles, old values are here:") |
|
1883 for i = 0,(vCCount-1) do |
|
1884 --nw WriteLnToConsole("CIRC " .. i .. ": X: " .. vCircX[i] .. "; Y: " .. vCircY[i]) |
|
1885 --nw WriteLnToConsole("CIRC " .. i .. ": dX: " .. vCircDX[i] .. "; dY: " .. vCircDY[i]) |
|
1886 --nw WriteLnToConsole("CIRC " .. i .. ": RAD:" .. vCircRadius[i]) |
|
1887 end |
|
1888 --nw WriteLnToConsole("Old values given, new values to follow...") |
|
1889 end |
|
1890 |
|
1891 for i = 0,(vCCount-1) do |
|
1892 |
|
1893 if s == false then |
|
1894 --vCircCol[i] = 0xffffffff |
|
1895 vCircActive[i] = false |
|
1896 elseif s == true then |
|
1897 SetUpCircle(i) |
|
1898 end |
|
1899 |
|
1900 end |
|
1901 |
|
1902 end |
|
1903 |
|
1904 function WellHeAintGonnaJumpNoMore(x,y) |
|
1905 |
|
1906 AddVisualGear(x, y, vgtBigExplosion, 0, false) |
|
1907 playerIsFine = false |
|
1908 AddCaption(loc("GOTCHA!")) |
|
1909 PlaySound(sndExplosion) |
|
1910 PlaySound(sndHellish) |
|
1911 |
|
1912 targetHit = true |
|
1913 |
|
1914 end |
|
1915 |
|
1916 --- collision detection for weapons fire |
|
1917 function CheckVarious(gear) |
|
1918 |
|
1919 --if (GetGearType(gear) == gtExplosives) then |
|
1920 --nw WriteLnToConsole("Start of CheckVarious(): Exp ID: " .. getGearValue(gear,"ID")) |
|
1921 --elseif (GetGearType(gear) == gtShell) then |
|
1922 --nw WriteLnToConsole("Start of CheckVarious(): Shell ID: " .. getGearValue(gear,"ID")) |
|
1923 --end |
|
1924 |
|
1925 targetHit = false |
|
1926 |
|
1927 -- if circle is hit by player fire |
|
1928 if (GetGearType(gear) == gtExplosives) then |
|
1929 circsHit = 0 |
|
1930 |
|
1931 for i = 0,(vCCount-1) do |
|
1932 |
|
1933 --nw WriteLnToConsole("Is it neccessary to check for collision with circ " .. i) |
|
1934 |
|
1935 --if (vCircActive[i] == true) and ( (vType[i] == "drone") ) then |
|
1936 |
|
1937 --nw WriteLnToConsole("YES. about to calc distance between gtExplosives and circ " .. i) |
|
1938 |
|
1939 dist = GetDistFromGearToXY(gear, vCircX[i], vCircY[i]) |
|
1940 |
|
1941 -- calculate my real radius if I am an aura |
|
1942 if vCircType[i] == 0 then |
|
1943 NR = vCircRadius[i] |
|
1944 else |
|
1945 NR = (48/100*vCircRadius[i])/2 |
|
1946 end |
|
1947 |
|
1948 if dist <= NR*NR then |
|
1949 |
|
1950 |
|
1951 --nw WriteLnToConsole("Collision confirmed. The gtExplosives is within the circ radius!") |
|
1952 |
|
1953 dist = (GetDistFromXYtoXY(vCircX[i], vCircY[i], getGearValue(gear,"XP"), getGearValue(gear,"YP")) - (NR*NR)) |
|
1954 --AddCaption(loc("Dist: ") .. dist .. "!",0xffba00ff,capgrpGameState) |
|
1955 if dist >= 1000000 then |
|
1956 sniperHits = sniperHits +1 |
|
1957 AddCaption(loc("Sniper!") .. " +8 " .. loc("points") .. "!",0xffba00ff,capgrpGameState) |
|
1958 AwardPoints(8) |
|
1959 if sniperHits == 3 then |
|
1960 sniperHits = 0 |
|
1961 AddCaption(loc("They Call Me Bullseye!") .. " +16 " .. loc("points") .. "!",0xffba00ff,capgrpGameState) |
|
1962 AwardPoints(15) |
|
1963 end |
|
1964 elseif dist <= 6000 then |
|
1965 pointBlankHits = pointBlankHits +1 |
|
1966 if pointBlankHits == 3 then |
|
1967 pointBlankHits = 0 |
|
1968 AddCaption(loc("Point Blank Combo!") .. " +5 " .. loc("points") .. "!",0xffba00ff,capgrpGameState) |
|
1969 AwardPoints(5) |
|
1970 end |
|
1971 end |
|
1972 |
|
1973 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
1974 |
|
1975 targetHit = true |
|
1976 --DeleteGear(gear) |
|
1977 --SetHealth(gear,0) |
|
1978 --WriteLnToConsole("set " .. "Exp ID: " .. getGearValue(gear,"ID") .. " health to 0") |
|
1979 --WriteLnToConsole("targetHit set to true, explosive is at distance " .. dist .. "(within range " .. NR*NR.. ") of circ" ) |
|
1980 |
|
1981 CircleDamaged(i) |
|
1982 |
|
1983 circsHit = circsHit + 1 |
|
1984 if circsHit > 1 then |
|
1985 AddCaption(loc("Multi-shot!") .. " +15 " .. loc("points") .. "!",0xffba00ff,capgrpAmmostate) |
|
1986 AwardPoints(15) |
|
1987 circsHit = 0 |
|
1988 end |
|
1989 |
|
1990 shotsHit = shotsHit + 1 |
|
1991 |
|
1992 |
|
1993 |
|
1994 end |
|
1995 |
|
1996 --end |
|
1997 |
|
1998 end |
|
1999 |
|
2000 -- if player is hit by circle bazooka |
|
2001 elseif (GetGearType(gear) == gtShell) and (CurrentHedgehog ~= nil) then --or (GetGearType(gear) == gtBall) then |
|
2002 |
|
2003 dist = GetDistFromGearToGear(gear, CurrentHedgehog) |
|
2004 |
|
2005 if beam == true then |
|
2006 |
|
2007 if dist < 3000 then |
|
2008 tempE = AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, true) |
|
2009 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
2010 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, 0xff00ffff ) |
|
2011 PlaySound(sndVaporize) |
|
2012 DeleteGear(gear) |
|
2013 |
|
2014 SK = SK + 1 |
|
2015 if SK == 5 then |
|
2016 SK = 0 |
|
2017 AddCaption(loc("Shield Master!") .. " +10 " .. loc("points") .. "!",0xffba00ff,capgrpAmmoinfo) |
|
2018 AwardPoints(10) |
|
2019 end |
|
2020 end |
|
2021 |
|
2022 elseif dist < 1600 then |
|
2023 WellHeAintGonnaJumpNoMore(GetX(gear), GetY(gear)) |
|
2024 end |
|
2025 |
|
2026 --[[if targetHit == true then |
|
2027 WriteLnToConsole("about to delete shell due to targetHit being set to true earlier") |
|
2028 DeleteGear(gear) |
|
2029 WriteLnToConsole("there, I deleted it") |
|
2030 end]] |
|
2031 |
|
2032 |
|
2033 end |
|
2034 |
|
2035 if targetHit == true then |
|
2036 --nw WriteLnToConsole("about to delete something due to targetHit being set to true earlier") |
|
2037 DeleteGear(gear) |
|
2038 --nw WriteLnToConsole("there, I deleted it") |
|
2039 end |
|
2040 |
|
2041 --nw WriteLnToConsole("End of CheckVarious()") |
|
2042 |
|
2043 end |
|
2044 |
|
2045 -- collision detection for player entering a circle |
|
2046 function CheckDistances() |
|
2047 |
|
2048 --nw WriteLnToConsole("Start of CheckDistances()") |
|
2049 |
|
2050 for i = 0,(vCCount-1) do |
|
2051 |
|
2052 |
|
2053 --nw WriteLnToConsole("Attempting to calculate dist of circ " .. i) |
|
2054 |
|
2055 g1X, g1Y = GetGearPosition(CurrentHedgehog) |
|
2056 g2X, g2Y = vCircX[i], vCircY[i] |
|
2057 |
|
2058 g1X = g1X - g2X |
|
2059 g1Y = g1Y - g2Y |
|
2060 dist = (g1X*g1X) + (g1Y*g1Y) |
|
2061 |
|
2062 --DoHorribleThings(i, g1X, g1Y, g2X, g2Y, dist) |
|
2063 |
|
2064 --nw WriteLnToConsole("Calcs done. Dist to CurrentHedgehog is " .. dist) |
|
2065 |
|
2066 -- calculate my real radius if I am an aura |
|
2067 if vCircType[i] == 0 then |
|
2068 NR = vCircRadius[i] |
|
2069 else |
|
2070 NR = (48/100*vCircRadius[i])/2 |
|
2071 end |
|
2072 |
|
2073 if dist <= NR*NR then |
|
2074 |
|
2075 if (vCircActive[i] == true) and |
|
2076 ((vType[i] == "ammo") or (vType[i] == "bonus") ) |
|
2077 then |
|
2078 |
|
2079 CircleDamaged(i) |
|
2080 |
|
2081 elseif (vCircActive[i] == true) and |
|
2082 ( (vType[i] == "drone") or (vType[i] == "blueboss") ) |
|
2083 then |
|
2084 |
|
2085 ss = CircleDamaged(i) |
|
2086 WellHeAintGonnaJumpNoMore(GetX(CurrentHedgehog),GetY(CurrentHedgehog)) |
|
2087 |
|
2088 if ss == "fatal" then |
|
2089 |
|
2090 if (wepAmmo[0] == 0) and (TimeLeft <= 9) then |
|
2091 --if (primShotsLeft == 0) and (TimeLeft <= 9) then |
|
2092 AddCaption(loc("Kamikaze Expert!") .. " +15 " .. loc("points") .. "!",0xffba00ff,capgrpMessage) |
|
2093 AwardPoints(15) |
|
2094 elseif (wepAmmo[0] == 0) then |
|
2095 AddCaption(loc("Depleted Kamikaze!") .. " +5 " .. loc("points") .. "!",0xffba00ff,capgrpMessage) |
|
2096 AwardPoints(5) |
|
2097 elseif TimeLeft <= 9 then |
|
2098 AddCaption(loc("Timed Kamikaze!") .. " +10 " .. loc("points") .. "!",0xffba00ff,capgrpMessage) |
|
2099 AwardPoints(10) |
|
2100 end |
|
2101 end |
|
2102 |
|
2103 end |
|
2104 |
|
2105 |
|
2106 end |
|
2107 |
|
2108 end |
|
2109 |
|
2110 --nw WriteLnToConsole("End of CheckDistances()") |
|
2111 |
|
2112 end |
|
2113 |
|
2114 function HandleCircles() |
|
2115 |
|
2116 --[[if CirclesAreGo == true then |
|
2117 |
|
2118 --CheckDistances() |
|
2119 --runOnGears(CheckVarious) -- used to be in handletracking for some bizarre reason |
|
2120 |
|
2121 --pTimer = pTimer + 1 |
|
2122 --if pTimer == 100 then |
|
2123 -- pTimer = 0 |
|
2124 -- runOnGears(ProjectileTrack) |
|
2125 --end |
|
2126 |
|
2127 end]] |
|
2128 |
|
2129 |
|
2130 if rAlpha ~= 255 then |
|
2131 |
|
2132 if GameTime%100 == 0 then |
|
2133 |
|
2134 rAlpha = rAlpha + 5 |
|
2135 if rAlpha >= 255 then |
|
2136 rAlpha = 255 |
|
2137 end |
|
2138 end |
|
2139 |
|
2140 end |
|
2141 |
|
2142 for i = 0,(vCCount-1) do |
|
2143 |
|
2144 --if (vCircActive[i] == true) then |
|
2145 SetVisualGearValues(rCirc[i], rCircX[i], rCircY[i], 100, 255, 1, 10, 0, 40, 3, vCircCol[i]-rAlpha) |
|
2146 --end |
|
2147 |
|
2148 |
|
2149 |
|
2150 vCounter[i] = vCounter[i] + 1 |
|
2151 if vCounter[i] >= vCounterLim[i] then |
|
2152 |
|
2153 vCounter[i] = 0 |
|
2154 |
|
2155 if ((vType[i] == "drone") or (vType[i] == "blueboss") ) and |
|
2156 (vCircActive[i] == true) then |
|
2157 AddGear(vCircX[i], vCircY[i], gtShell, 0, 0, 0, 1) |
|
2158 |
|
2159 --WriteLnToConsole("Circle " .. i .. " just fired/added a gtShell") |
|
2160 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
2161 |
|
2162 --elseif (vType[i] == "bluebottle") and (vCircActive[i] == true) then |
|
2163 -- AddGear(vCircX[i], vCircY[i]-vCircRadius[i], gtBall, 0, 0, 0, 1) |
|
2164 -- AddGear(vCircX[i], vCircY[i]+vCircRadius[i], gtBall, 0, 0, 0, 1) |
|
2165 -- AddGear(vCircX[i]-vCircRadius[i], vCircY[i], gtBall, 0, 0, 0, 1) |
|
2166 -- AddGear(vCircX[i]+vCircRadius[i], vCircY[i], gtBall, 0, 0, 0, 1) |
|
2167 end |
|
2168 |
|
2169 end |
|
2170 |
|
2171 if (vCircActive[i] == true) then |
|
2172 |
|
2173 vCircRadCounter[i] = vCircRadCounter[i] + 1 |
|
2174 if vCircRadCounter[i] == 100 then |
|
2175 |
|
2176 vCircRadCounter[i] = 0 |
|
2177 |
|
2178 -- make my radius increase/decrease faster if I am an aura |
|
2179 if vCircType[i] == 0 then |
|
2180 M = 1 |
|
2181 else |
|
2182 M = 10 |
|
2183 end |
|
2184 |
|
2185 vCircRadius[i] = vCircRadius[i] + vCircRadDir[i] |
|
2186 if vCircRadius[i] > vCircRadMax[i] then |
|
2187 vCircRadDir[i] = -M |
|
2188 elseif vCircRadius[i] < vCircRadMin[i] then |
|
2189 vCircRadDir[i] = M |
|
2190 end |
|
2191 |
|
2192 |
|
2193 -- random effect test |
|
2194 -- maybe use this to tell the difference between circs |
|
2195 -- you can kill by shooting or not |
|
2196 --vgtSmoke vgtSmokeWhite |
|
2197 --vgtSteam -- nice long trail |
|
2198 --vgtDust -- short trail on earthrise |
|
2199 --vgtSmokeTrace |
|
2200 if vType[i] == "ammo" then |
|
2201 |
|
2202 tempE = AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, true) |
|
2203 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff |
|
2204 SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, g8, g9, vCircCol[i] ) |
|
2205 |
|
2206 --AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, true) |
|
2207 |
|
2208 elseif vType[i] == "bonus" then |
|
2209 |
|
2210 tempE = AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, true) |
|
2211 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff --vCircCol[i] |
|
2212 SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, 1, g9, 0xff00ffff ) |
|
2213 |
|
2214 |
|
2215 elseif vType[i] == "blueboss" then |
|
2216 |
|
2217 k = 25 |
|
2218 g = vgtSteam |
|
2219 trailColour = 0xae00ffff |
|
2220 |
|
2221 -- 0xffae00ff -- orange |
|
2222 -- 0xae00ffff -- purp |
|
2223 |
|
2224 tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true) |
|
2225 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff |
|
2226 SetVisualGearValues(tempE, vCircX[i], vCircY[i]+k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 ) |
|
2227 |
|
2228 tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true) |
|
2229 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff |
|
2230 SetVisualGearValues(tempE, vCircX[i]+k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 ) |
|
2231 |
|
2232 tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true) |
|
2233 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff |
|
2234 SetVisualGearValues(tempE, vCircX[i]-k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 ) |
|
2235 |
|
2236 |
|
2237 end |
|
2238 |
|
2239 |
|
2240 end |
|
2241 |
|
2242 end |
|
2243 |
|
2244 |
|
2245 end |
|
2246 |
|
2247 -- alter the circles velocities |
|
2248 if GameTime%2000 == 0 then |
|
2249 |
|
2250 for i = 0,(vCCount-1) do |
|
2251 |
|
2252 -- bounce the circles off the edges if they go too far |
|
2253 -- or make them move in random directions |
|
2254 |
|
2255 if vCircX[i] > 5500 then |
|
2256 vCircDX[i] = -4 --5 circmovchange |
|
2257 elseif vCircX[i] < -1500 then |
|
2258 vCircDX[i] = 4 --5 circmovchange |
|
2259 else |
|
2260 |
|
2261 z = GetRandom(2) |
|
2262 if z == 1 then |
|
2263 z = 1 |
|
2264 else |
|
2265 z = -1 |
|
2266 end |
|
2267 vCircDX[i] = vCircDX[i] + GetRandom(3)*z --3 circmovchange |
|
2268 end |
|
2269 |
|
2270 if vCircY[i] > 1500 then |
|
2271 vCircDY[i] = -4 --5 circmovchange |
|
2272 elseif vCircY[i] < -2900 then |
|
2273 vCircDY[i] = 4 --5 circmovchange |
|
2274 else |
|
2275 z = GetRandom(2) |
|
2276 if z == 1 then |
|
2277 z = 1 |
|
2278 else |
|
2279 z = -1 |
|
2280 end |
|
2281 vCircDY[i] = vCircDY[i] + GetRandom(3)*z --3 circmovchange |
|
2282 end |
|
2283 |
|
2284 end |
|
2285 |
|
2286 end |
|
2287 |
|
2288 -- move the circles according to their current velocities |
|
2289 --m2Count = m2Count + 1 |
|
2290 --if m2Count == 25 then --25 circmovchange |
|
2291 |
|
2292 -- m2Count = 0 |
|
2293 for i = 0,(vCCount-1) do |
|
2294 vCircX[i] = vCircX[i] + vCircDX[i] |
|
2295 vCircY[i] = vCircY[i] + vCircDY[i] |
|
2296 |
|
2297 if (CurrentHedgehog ~= nil) and (rAlpha ~= 255) then |
|
2298 DoHorribleThings(i)--(i, g1X, g1Y, g2X, g2Y, dist) |
|
2299 end |
|
2300 |
|
2301 end |
|
2302 |
|
2303 if (TimeLeft == 0) and (tumbleStarted == true) then |
|
2304 |
|
2305 FadeAlpha = FadeAlpha + 1 |
|
2306 if FadeAlpha >= 255 then |
|
2307 FadeAlpha = 255 |
|
2308 end |
|
2309 |
|
2310 --new |
|
2311 --if FadeAlpha == 1 then |
|
2312 -- AddCaption("GOT IT") |
|
2313 -- for i = 0,(vCCount-1) do |
|
2314 -- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i]) |
|
2315 -- vCircCol[i] = g10 |
|
2316 -- end |
|
2317 --end |
|
2318 |
|
2319 end |
|
2320 |
|
2321 |
|
2322 -- derp |
|
2323 if shockwaveHealth > 0 then |
|
2324 shockwaveHealth = shockwaveHealth - 1 |
|
2325 shockwaveRad = shockwaveRad + 80 |
|
2326 |
|
2327 --mrm = ((48/100*shockwaveRad)/2) |
|
2328 --AddVisualGear(GetX(CurrentHedgehog)-mrm+GetRandom(mrm*2),GetY(CurrentHedgehog)-mrm+GetRandom(mrm*2), vgtSmoke, 0, false) |
|
2329 end |
|
2330 |
|
2331 |
|
2332 |
|
2333 --end |
|
2334 |
|
2335 for i = 0,(vCCount-1) do |
|
2336 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i]) -- vCircCol[i] g10 |
|
2337 SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, g10) |
|
2338 end |
|
2339 |
|
2340 if (TimeLeft == 0) or |
|
2341 ((tumbleStarted == false)) then |
|
2342 for i = 0,(vCCount-1) do |
|
2343 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i]) -- vCircCol[i] g10 |
|
2344 SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, (vCircCol[i]-FadeAlpha)) |
|
2345 end |
|
2346 end |
|
2347 |
|
2348 |
|
2349 if (CurrentHedgehog ~= nil) then |
|
2350 if beam == true then |
|
2351 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(pShield) |
|
2352 --SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, g10 ) |
|
2353 SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, 0xa800ffff-0x000000ff - -shieldHealth ) |
|
2354 DrawTag(2) |
|
2355 else |
|
2356 SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 0, g9, g10 ) |
|
2357 end |
|
2358 |
|
2359 if shockwaveHealth > 0 then |
|
2360 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(shockwave) |
|
2361 SetVisualGearValues(shockwave, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, shockwaveRad, g9, 0xff3300ff-0x000000ff - -shockwaveHealth ) |
|
2362 else |
|
2363 SetVisualGearValues(shockwave, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 0, g9, g10 ) |
|
2364 end |
|
2365 |
|
2366 end |
|
2367 |
|
2368 |
|
2369 end |
|
2370 |
|
2371 function ProjectileTrack(gear) |
|
2372 |
|
2373 if (GetGearType(gear) == gtShell) then |
|
2374 |
|
2375 --nw WriteLnToConsole("ProjectileTrack() for Shell ID: " .. getGearValue(gear,"ID")) |
|
2376 |
|
2377 -- newnew |
|
2378 if (GetGearType(gear) == gtShell) then |
|
2379 turningSpeed = 0.1*fMod |
|
2380 --elseif (GetGearType(gear) == gtBall) then |
|
2381 -- turningSpeed = 0.2*fMod |
|
2382 end |
|
2383 |
|
2384 dx, dy = GetGearVelocity(gear) |
|
2385 |
|
2386 --WriteLnToConsole("I'm trying to track currenthedge with shell ID: " .. getGearValue(gear,"ID")) |
|
2387 --WriteLnToConsole("I just got the velocity of the shell. It is dx: " .. dx .. "; dy: " .. dy) |
|
2388 --WriteLnToConsole("CurrentHedgehog is at X: " .. GetX(CurrentHedgehog) .. "; Y: " .. GetY(CurrentHedgehog) ) |
|
2389 |
|
2390 if CurrentHedgehog ~= nil then |
|
2391 if GetX(gear) > GetX(CurrentHedgehog) then |
|
2392 dx = dx - turningSpeed--0.1 |
|
2393 else |
|
2394 dx = dx + turningSpeed--0.1 |
|
2395 end |
|
2396 |
|
2397 if GetY(gear) > GetY(CurrentHedgehog) then |
|
2398 dy = dy - turningSpeed--0.1 |
|
2399 else |
|
2400 dy = dy + turningSpeed--0.1 |
|
2401 end |
|
2402 end |
|
2403 |
|
2404 |
|
2405 if (GetGearType(gear) == gtShell) then |
|
2406 dxlimit = 0.4*fMod |
|
2407 dylimit = 0.4*fMod |
|
2408 --elseif (GetGearType(gear) == gtBall) then |
|
2409 -- dxlimit = 0.5 -- 0.5 is about the same |
|
2410 -- dylimit = 0.5 -- 0.6 is faster than player |
|
2411 end |
|
2412 |
|
2413 if dx > dxlimit then |
|
2414 dx = dxlimit |
|
2415 end |
|
2416 if dy > dylimit then |
|
2417 dy = dylimit |
|
2418 end |
|
2419 if dx < -dxlimit then |
|
2420 dx = -dxlimit |
|
2421 end |
|
2422 if dy < -dylimit then |
|
2423 dy = -dylimit |
|
2424 end |
|
2425 |
|
2426 SetGearVelocity(gear, dx, dy) |
|
2427 |
|
2428 --WriteLnToConsole("I just SET the velocity of shell towards currenthegdge. It is now dx: " .. dx .. "; dy: " .. dy) |
|
2429 --WriteLnToConsole("The above events occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
2430 --nw WriteLnToConsole("ProjectileTrack() finished successfully") |
|
2431 |
|
2432 end |
|
2433 |
|
2434 end |
|
2435 |