|
1 |
|
2 loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
|
3 loadfile(GetDataPath() .. "Scripts/Tracker.lua")() |
|
4 |
|
5 --------------------------------------------------- |
|
6 --------------------------------------------------- |
|
7 --------------------------------------------------- |
|
8 --- Space Invasion Code Follows (0.7) |
|
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 +20 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) 5pts |
|
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 --notes for later |
|
105 -------------------------- |
|
106 -- maybe add a check for a tie, NAH |
|
107 -- more achievements? (3 kamikazes in a row, long distance shooter, supreme shield expert/miser etc?) |
|
108 |
|
109 --[[CAPTION CATEGORIES |
|
110 ----------------- |
|
111 capgrpGameState |
|
112 ----------------- |
|
113 |
|
114 ----------------- |
|
115 capgrpAmmostate |
|
116 ----------------- |
|
117 AddCaption( chainLength .. loc("-chain! +") .. chainLength*2 .. loc(" points!"),0xffba00ff,capgrpAmmostate) |
|
118 AddCaption(loc("Multi-shot! +5 points!"),0xffba00ff,capgrpAmmostate) |
|
119 |
|
120 ----------------- |
|
121 capgrpAmmoinfo |
|
122 ----------------- |
|
123 AddCaption(loc("Shield Miser! +20 points!"),0xffba00ff,capgrpAmmoinfo) |
|
124 AddCaption(loc("Shield Master! +10 points!"),0xffba00ff,capgrpAmmoinfo) |
|
125 |
|
126 ----------------- |
|
127 capgrpVolume |
|
128 ----------------- |
|
129 AddCaption(loc("Boom! +25 points!"),0xffba00ff,capgrpVolume) |
|
130 AddCaption(loc("BOOM! +50 points!"),0xffba00ff,capgrpVolume) |
|
131 AddCaption(loc("BOOM! BOOM! BOOM! +100 points!"),0xffba00ff,capgrpVolume) |
|
132 AddCaption(loc("Accuracy Bonus! +15 points!"),0xffba00ff,capgrpVolume) |
|
133 |
|
134 ----------------- |
|
135 capgrpMessage |
|
136 ----------------- |
|
137 AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage) |
|
138 AddCaption(loc("Ammo: ") .. primShotsLeft) |
|
139 AddCaption("Shield Depleted",0xff0000ff,capgrpMessage) |
|
140 AddCaption( loc("Shield ON:") .. " " .. shieldHealth - 80 .. " " .. loc("Power Remaining") ) |
|
141 AddCaption(loc("Shield OFF:") .. " " .. shieldHealth - 80 .. " " .. loc("Power Remaining") ) |
|
142 |
|
143 AddCaption(loc("Time Extended!") .. "+" .. 4 .. loc("s"), 0xff0000ff,capgrpMessage ) |
|
144 AddCaption("+" .. 3 .. " " .. loc("Ammo"), 0x00ff00ff,capgrpMessage) |
|
145 AddCaption(loc("Shield boosted! +30 power"), 0xff00ffff,capgrpMessage) |
|
146 AddCaption(loc("Shield is fully recharged!"), 0xffae00ff,capgrpMessage) |
|
147 AddCaption(loc("Boss defeated! +50 points!"), 0x0050ffff,capgrpMessage) |
|
148 |
|
149 AddCaption(loc("GOTCHA!")) |
|
150 AddCaption(loc("Kamikaze Expert! +15 points!"),0xffba00ff,capgrpMessage) |
|
151 AddCaption(loc("Depleted Kamikaze! +5 points!"),0xffba00ff,capgrpMessage) |
|
152 AddCaption(loc("Timed Kamikaze! +10 points!"),0xffba00ff,capgrpMessage) |
|
153 |
|
154 ----------------- |
|
155 capgrpMessage2 |
|
156 ----------------- |
|
157 AddCaption(loc("Drone Hunter! +10 points!"),0xffba00ff,capgrpMessage2) |
|
158 AddCaption(loc("Ammo Maniac! +5 points!"),0xffba00ff,capgrpMessage2) |
|
159 AddCaption(loc("Shield Seeker! +10 points!"),0xffba00ff,capgrpMessage2) |
|
160 AddCaption(loc("Boss Slayer! +25 points!"),0xffba00ff,capgrpMessage2) |
|
161 ]] |
|
162 |
|
163 ---------------------------------- |
|
164 -- so I herd u liek wariables |
|
165 ---------------------------------- |
|
166 |
|
167 --local fMod = 1 -- for use in .15 single player only, otherwise desync |
|
168 local fMod = 1000000 -- use this for dev and .16+ games |
|
169 |
|
170 -- some console stuff |
|
171 local shellID = 0 |
|
172 local explosivesID = 0 |
|
173 local luaGameTicks = 0 |
|
174 |
|
175 -- gaudyRacer |
|
176 local roundLimit = 3 -- no longer set here (see version history) |
|
177 local roundNumber = 0 |
|
178 local firstClan = 10 |
|
179 local gameOver = false |
|
180 local gameBegun = false |
|
181 |
|
182 local bestClan = 10 |
|
183 local bestScore = 0 |
|
184 local sdScore = {} |
|
185 local sdName = {} |
|
186 local sdKills = {} |
|
187 |
|
188 -------------------------- |
|
189 -- hog and team tracking variales |
|
190 -------------------------- |
|
191 |
|
192 local numhhs = 0 |
|
193 local hhs = {} |
|
194 |
|
195 local numTeams |
|
196 local teamNameArr = {} |
|
197 local teamClan = {} |
|
198 local teamSize = {} |
|
199 local teamIndex = {} |
|
200 |
|
201 local teamComment = {} |
|
202 local teamScore = {} |
|
203 local teamCircsKilled = {} |
|
204 |
|
205 -- stats variables |
|
206 --local teamRed = {} |
|
207 --local teamBlue = {} |
|
208 --local teamOrange = {} |
|
209 --local teamGreen = {} |
|
210 local RK = 0 |
|
211 local GK = 0 |
|
212 local BK = 0 |
|
213 local OK = 0 |
|
214 local SK = 0 |
|
215 local shieldMiser = true |
|
216 local chainCounter = 0 |
|
217 local chainLength = 0 |
|
218 local shotsFired = 0 |
|
219 local shotsHit = 0 |
|
220 |
|
221 --------------------- |
|
222 -- tumbler goods |
|
223 --------------------- |
|
224 |
|
225 local moveTimer = 0 |
|
226 local leftOn = false |
|
227 local rightOn = false |
|
228 local upOn = false |
|
229 local downOn = false |
|
230 |
|
231 local primShotsMax = 5 |
|
232 local primShotsLeft = 0 |
|
233 |
|
234 local TimeLeftCounter = 0 |
|
235 local TimeLeft = 0 |
|
236 local stopMovement = false |
|
237 local tumbleStarted = false |
|
238 |
|
239 local beam = false |
|
240 local pShield |
|
241 local shieldHealth |
|
242 |
|
243 local Timer100 = 0 |
|
244 |
|
245 |
|
246 ----------------------------------------------- |
|
247 -- CIRCLY GOODIES |
|
248 ----------------------------------------------- |
|
249 |
|
250 local CirclesAreGo = false |
|
251 local playerIsFine = true |
|
252 local targetHit = false |
|
253 |
|
254 local FadeAlpha = 0 -- used to fade the circles out gracefully when player dies |
|
255 local pTimer = 0 -- tracking projectiles following player |
|
256 |
|
257 local circAdjustTimer = 0 -- handle adjustment of circs direction |
|
258 local m2Count = 0 -- handle speed of circs |
|
259 |
|
260 local vCirc = {} |
|
261 local vCCount = 0 |
|
262 |
|
263 local vCircActive = {} |
|
264 local vCircHealth = {} |
|
265 local vType = {} |
|
266 local vCounter = {} -- how often this circ gets to "fire" etc |
|
267 local vCounterLim = {} -- when vCounter == vCounterLim circle performs its special |
|
268 local vCircScore = {} -- how many points killing this invader gives |
|
269 |
|
270 local vCircRadMax = {} |
|
271 local vCircRadMin = {} |
|
272 local vCircRadDir = {} |
|
273 local vCircRadCounter = {} |
|
274 |
|
275 local vCircDX = {} |
|
276 local vCircDY = {} |
|
277 |
|
278 local vCircX = {} |
|
279 local vCircY = {} |
|
280 local vCircMinA = {} |
|
281 local vCircMaxA = {} |
|
282 local vCircType = {} |
|
283 local vCircPulse = {} |
|
284 local vCircFuckAll = {} |
|
285 local vCircRadius = {} |
|
286 local vCircWidth = {} |
|
287 local vCircCol = {} |
|
288 |
|
289 ------------------------------------------- |
|
290 -- some lazy copypasta/modified methods |
|
291 ------------------------------------------- |
|
292 |
|
293 function RebuildTeamInfo() |
|
294 |
|
295 -- make a list of individual team names |
|
296 for i = 0, (TeamsCount-1) do |
|
297 teamNameArr[i] = " " -- = i |
|
298 teamSize[i] = 0 |
|
299 teamIndex[i] = 0 |
|
300 teamScore[i] = 0 |
|
301 teamCircsKilled[i] = 0 |
|
302 end |
|
303 numTeams = 0 |
|
304 |
|
305 for i = 0, (numhhs-1) do |
|
306 |
|
307 z = 0 |
|
308 unfinished = true |
|
309 while(unfinished == true) do |
|
310 |
|
311 newTeam = true |
|
312 tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name |
|
313 |
|
314 if tempHogTeamName == teamNameArr[z] then |
|
315 newTeam = false |
|
316 unfinished = false |
|
317 end |
|
318 |
|
319 z = z + 1 |
|
320 |
|
321 if z == (TeamsCount-1) then |
|
322 unfinished = false |
|
323 if newTeam == true then |
|
324 teamNameArr[numTeams] = tempHogTeamName |
|
325 numTeams = numTeams + 1 |
|
326 end |
|
327 end |
|
328 |
|
329 end |
|
330 |
|
331 end |
|
332 |
|
333 -- find out how many hogs per team, and the index of the first hog in hhs |
|
334 for i = 0, (TeamsCount-1) do |
|
335 |
|
336 for z = 0, (numhhs-1) do |
|
337 if GetHogTeamName(hhs[z]) == teamNameArr[i] then |
|
338 teamClan[i] = GetHogClan(hhs[z]) |
|
339 if teamSize[i] == 0 then |
|
340 teamIndex[i] = z -- should give starting index |
|
341 end |
|
342 teamSize[i] = teamSize[i] + 1 |
|
343 --add a pointer so this hog appears at i in hhs |
|
344 end |
|
345 end |
|
346 |
|
347 end |
|
348 |
|
349 end |
|
350 |
|
351 -- control |
|
352 function AwardPoints(p) |
|
353 |
|
354 for i = 0,(TeamsCount-1) do |
|
355 if teamClan[i] == GetHogClan(CurrentHedgehog) then |
|
356 teamScore[i] = teamScore[i] + p |
|
357 end |
|
358 end |
|
359 |
|
360 end |
|
361 |
|
362 function AwardKills(t) |
|
363 |
|
364 for i = 0,(TeamsCount-1) do |
|
365 if teamClan[i] == GetHogClan(CurrentHedgehog) then |
|
366 teamCircsKilled[i] = teamCircsKilled[i] + 1 |
|
367 |
|
368 if teamCircsKilled[i] == 10 then |
|
369 AddCaption(loc("Boom! +25 points!"),0xffba00ff,capgrpVolume) |
|
370 AwardPoints(25) |
|
371 elseif teamCircsKilled[i] == 25 then |
|
372 AddCaption(loc("BOOM! +50 points!"),0xffba00ff,capgrpVolume) |
|
373 AwardPoints(50) |
|
374 elseif teamCircsKilled[i] == 50 then |
|
375 AddCaption(loc("BOOM! BOOM! BOOM! +100 points!"),0xffba00ff,capgrpVolume) |
|
376 AwardPoints(100) |
|
377 end |
|
378 |
|
379 --[[ |
|
380 if t == "R" then |
|
381 redCircsKilled[i] = redCircsKilled[i] + 1 |
|
382 end |
|
383 --etc |
|
384 --etc |
|
385 ]] |
|
386 end |
|
387 end |
|
388 |
|
389 end |
|
390 |
|
391 ----------------- |
|
392 |
|
393 function bubbleSort(table) |
|
394 |
|
395 for i = 1, #table do |
|
396 for j = 2, #table do |
|
397 if table[j] < table[j-1] then |
|
398 |
|
399 temp = table[j-1] |
|
400 t2 = sdName[j-1] |
|
401 t3 = sdKills[j-1] |
|
402 |
|
403 table[j-1] = table[j] |
|
404 sdName[j-1] = sdName[j] |
|
405 sdKills[j-1] = sdKills[j] |
|
406 |
|
407 table[j] = temp |
|
408 sdName[j] = t2 |
|
409 sdKills[j] = t3 |
|
410 |
|
411 end |
|
412 end |
|
413 end |
|
414 |
|
415 return |
|
416 |
|
417 end |
|
418 |
|
419 ----------------- |
|
420 |
|
421 function CommentOnScore() |
|
422 |
|
423 for i = 0,(TeamsCount-1) do |
|
424 sdScore[i] = teamScore[i] |
|
425 sdKills[i] = teamCircsKilled[i] |
|
426 sdName[i] = teamNameArr[i] |
|
427 end |
|
428 |
|
429 --bubbleSort(sdScore) |
|
430 |
|
431 for i = 0,(TeamsCount-1) do |
|
432 if sdName[i] ~= " " then |
|
433 teamComment[i] = sdName[i] .. " |" .. |
|
434 loc("SCORE: ") .. sdScore[i] .. loc (" points|") .. |
|
435 loc("KILLS: ") .. sdKills[i] .. loc (" invaders destroyed|") .. |
|
436 " " .. "|" |
|
437 elseif sdName[i] == " " then |
|
438 teamComment[i] = "|" |
|
439 end |
|
440 end |
|
441 |
|
442 entireC = "" |
|
443 for i = (TeamsCount-1),0,-1 do |
|
444 entireC = entireC .. teamComment[i] |
|
445 end |
|
446 |
|
447 ShowMission(loc("SPACE INVASION"), loc("STATUS UPDATE"), loc("Rounds Complete: ") .. roundNumber .. "/" .. roundLimit .. "|" .. " " .. "|" .. loc("Team Scores: ") .. "|" ..entireC, 4, 1) |
|
448 |
|
449 end |
|
450 |
|
451 -- gaudy racer |
|
452 function CheckForNewRound() |
|
453 |
|
454 if GetHogClan(CurrentHedgehog) == firstClan then |
|
455 |
|
456 roundNumber = roundNumber + 1 |
|
457 |
|
458 CommentOnScore() |
|
459 |
|
460 -- end game if its at round limit |
|
461 if roundNumber == roundLimit then |
|
462 |
|
463 for i = 0, (TeamsCount-1) do |
|
464 if teamScore[i] > bestScore then |
|
465 bestScore = teamScore[i] |
|
466 bestClan = teamClan[i] |
|
467 end |
|
468 end |
|
469 |
|
470 for i = 0, (numhhs-1) do |
|
471 if GetHogClan(hhs[i]) ~= bestClan then |
|
472 SetEffect(hhs[i], heResurrectable, false) |
|
473 SetHealth(hhs[i],0) |
|
474 end |
|
475 end |
|
476 gameOver = true |
|
477 TurnTimeLeft = 0 --1 |
|
478 TimeLeft = 0 |
|
479 end |
|
480 |
|
481 end |
|
482 |
|
483 end |
|
484 |
|
485 |
|
486 ---------------------------------------- |
|
487 -- some tumbler/space invaders methods |
|
488 ---------------------------------------- |
|
489 |
|
490 function isATrackedGear(gear) |
|
491 if (GetGearType(gear) == gtExplosives) or |
|
492 (GetGearType(gear) == gtShell) or |
|
493 (GetGearType(gear) == gtFlame) or-- new -- gtBall |
|
494 (GetGearType(gear) == gtBall) |
|
495 then |
|
496 return(true) |
|
497 else |
|
498 return(false) |
|
499 end |
|
500 end |
|
501 |
|
502 function setNewGearValues(gear) |
|
503 |
|
504 if GetGearType(gear) == gtShell then |
|
505 lfs = 50 -- roughly 5 seconds |
|
506 shellID = shellID + 1 |
|
507 setGearValue(gear,"ID",shellID) |
|
508 --nw WriteLnToConsole("Just assigned ID " .. getGearValue(gear,"ID") .. " to this shell") |
|
509 elseif GetGearType(gear) == gtBall then |
|
510 lfs = 70 -- 7s |
|
511 elseif GetGearType(gear) == gtExplosives then |
|
512 lfs = 15 -- 1.5s |
|
513 explosivesID = explosivesID + 1 |
|
514 setGearValue(gear,"ID",explosivesID) |
|
515 --nw WriteLnToConsole("Just assigned ID " .. getGearValue(gear,"ID") .. " to this explosives") |
|
516 elseif GetGearType(gear) == gtFlame then |
|
517 lfs = 5 -- 0.5s |
|
518 else |
|
519 lfs = 100 |
|
520 end |
|
521 |
|
522 setGearValue(gear,"lifespan",lfs) |
|
523 --WriteLnToConsole("I also set its lifespan to " .. lfs) |
|
524 |
|
525 |
|
526 end |
|
527 |
|
528 function HandleLifeSpan(gear) |
|
529 |
|
530 decreaseGearValue(gear,"lifespan") |
|
531 |
|
532 --WriteLnToConsole("Just decreased the lifespan of a gear to " .. getGearValue(gear,"lifespan")) |
|
533 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
534 |
|
535 |
|
536 if getGearValue(gear,"lifespan") == 0 then |
|
537 |
|
538 if GetGearType(gear) == gtShell then |
|
539 AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false) |
|
540 WriteLnToConsole("about to delete a shell due to lifespan == 0") |
|
541 --elseif GetGearType(gear) == gtBall then |
|
542 -- AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, true) |
|
543 elseif GetGearType(gear) == gtExplosives then |
|
544 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
545 --nw WriteLnToConsole("about to delete a explosive due to lifespan == 0") |
|
546 elseif GetGearType(gear) == gtFlame then |
|
547 AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false) |
|
548 --WriteLnToConsole("about to delete flame due to lifespan == 0") |
|
549 end |
|
550 |
|
551 DeleteGear(gear) |
|
552 |
|
553 end |
|
554 |
|
555 end |
|
556 |
|
557 -- this prevents ugly barrel clipping sounds when a barrel flies off map limits |
|
558 function DeleteFarFlungBarrel(gear) |
|
559 |
|
560 if GetGearType(gear) == gtExplosives then |
|
561 if (GetX(gear) < -1900) or |
|
562 (GetX(gear) > 6200) or |
|
563 (GetY(gear) < -3400) |
|
564 then |
|
565 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
566 DeleteGear(gear) |
|
567 --SetHealth(gear, 0) |
|
568 --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) |
|
569 end |
|
570 |
|
571 end |
|
572 |
|
573 end |
|
574 |
|
575 ----------------------- |
|
576 --EVENT HANDLERS |
|
577 -- action keys |
|
578 ----------------------- |
|
579 |
|
580 -- o rite dis wan iz liek synched n stuff hope full lee |
|
581 function onPrecise() |
|
582 |
|
583 --WriteLnToConsole("onPrecise event handler at Game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
584 |
|
585 -- Fire Barrel |
|
586 if (primShotsLeft > 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then |
|
587 |
|
588 shotsFired = shotsFired +1 |
|
589 |
|
590 morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1) |
|
591 |
|
592 primShotsLeft = primShotsLeft - 1 |
|
593 |
|
594 if primShotsLeft == 0 then |
|
595 PlaySound(sndSuddenDeath) |
|
596 AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage) |
|
597 else |
|
598 AddCaption(loc("Ammo: ") .. primShotsLeft) |
|
599 end |
|
600 |
|
601 CopyPV(CurrentHedgehog, morte) -- new addition |
|
602 x,y = GetGearVelocity(morte) |
|
603 --WriteLnToConsole("I'm going to shoot a barrel so I just got the velocity of currenthedgehog. It is dx: " .. x .. "; dy: " .. y) |
|
604 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
605 |
|
606 |
|
607 |
|
608 x = x*2 |
|
609 y = y*2 |
|
610 SetGearVelocity(morte, x, y) |
|
611 |
|
612 --WriteLnToConsole("I just SET the velocity of a barrel I created. It is now dx: " .. x .. "; dy: " .. y) |
|
613 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
614 |
|
615 |
|
616 |
|
617 elseif (primShotsLeft == 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then |
|
618 AddCaption(loc("Ammo Depleted!"),0xff0000ff,capgrpMessage) |
|
619 end |
|
620 |
|
621 |
|
622 end |
|
623 |
|
624 function onLJump() |
|
625 |
|
626 if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then |
|
627 shieldMiser = false |
|
628 if shieldHealth == 80 then |
|
629 AddCaption("Shield Depleted",0xff0000ff,capgrpMessage) |
|
630 PlaySound(sndMineTick) |
|
631 PlaySound(sndSwitchHog) |
|
632 elseif (beam == false) and (shieldHealth > 80) then |
|
633 beam = true |
|
634 SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 40, 255, 1, 10, 0, 300, 1, 0xa800ffff) |
|
635 AddCaption( loc("Shield ON:") .. " " .. shieldHealth - 80 .. " " .. loc("Power Remaining") ) |
|
636 PlaySound(sndWarp) |
|
637 else |
|
638 beam = false |
|
639 SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 0, 0, 1, 10, 0, 0, 0, 0xa800ffff) |
|
640 AddCaption(loc("Shield OFF:") .. " " .. shieldHealth - 80 .. " " .. loc("Power Remaining") ) |
|
641 end |
|
642 end |
|
643 end |
|
644 |
|
645 ----------------- |
|
646 -- movement keys |
|
647 ----------------- |
|
648 |
|
649 function onLeft() |
|
650 leftOn = true |
|
651 end |
|
652 |
|
653 function onRight() |
|
654 rightOn = true |
|
655 end |
|
656 |
|
657 function onUp() |
|
658 upOn = true |
|
659 end |
|
660 |
|
661 function onDown() |
|
662 downOn = true |
|
663 end |
|
664 |
|
665 function onDownUp() |
|
666 downOn = false |
|
667 end |
|
668 |
|
669 function onUpUp() |
|
670 upOn = false |
|
671 end |
|
672 |
|
673 function onLeftUp() |
|
674 leftOn = false |
|
675 end |
|
676 |
|
677 function onRightUp() |
|
678 rightOn = false |
|
679 end |
|
680 |
|
681 -------------------------- |
|
682 -- other event handlers |
|
683 -------------------------- |
|
684 |
|
685 function onGameInit() |
|
686 GameFlags = 0 + gfRandomOrder |
|
687 Theme = "EarthRise" |
|
688 CaseFreq = 0 |
|
689 HealthCaseProb = 0 |
|
690 MinesNum = 0 |
|
691 Explosives = 0 |
|
692 end |
|
693 |
|
694 function onGameStart() |
|
695 |
|
696 if (MinesTime == -1000) or (MinesTime == 0) then |
|
697 roundLimit = 3 |
|
698 else |
|
699 roundLimit = (MinesTime / 1000) |
|
700 end |
|
701 |
|
702 ShowMission ( |
|
703 loc("SPACE INVASION"), |
|
704 loc("a Hedgewars mini-game"), |
|
705 |
|
706 loc("Destroy invaders to score points.") .. "|" .. |
|
707 " " .. "|" .. |
|
708 |
|
709 loc("Round Limit:") .. " " .. roundLimit .. "|" .. |
|
710 loc("Turn Time:") .. " " .. (TurnTime/1000) .. loc("s") .. "|" .. |
|
711 " " .. "|" .. |
|
712 |
|
713 loc("Movement: [Up], [Down], [Left], [Right]") .. "|" .. |
|
714 loc("Fire:") .. " " .. loc("[Left Shift]") .. "|" .. |
|
715 loc("Toggle Shield:") .. " " .. loc("[Enter]") .. "|" .. |
|
716 |
|
717 --" " .. "|" .. |
|
718 --loc("Invaders List: ") .. "|" .. |
|
719 --loc("Blue Jabberwock: (50 points)") .. "|" .. |
|
720 --loc("Red Warbler: (10 points)") .. "|" .. |
|
721 --loc("Orange Gob: (5 points)") .. "|" .. |
|
722 --loc("Green Wrangler: (3 points)") .. "|" .. |
|
723 |
|
724 |
|
725 "", 4, 4000 |
|
726 ) |
|
727 |
|
728 CreateMeSomeCircles() |
|
729 RebuildTeamInfo() -- control |
|
730 |
|
731 end |
|
732 |
|
733 |
|
734 function onNewTurn() |
|
735 |
|
736 primShotsLeft = primShotsMax |
|
737 stopMovement = false |
|
738 tumbleStarted = false |
|
739 beam = false |
|
740 shieldHealth = 30 + 80 -- 50 = 5 secs, roughly |
|
741 |
|
742 RK = 0 |
|
743 GK = 0 |
|
744 BK = 0 |
|
745 OK = 0 |
|
746 SK = 0 |
|
747 shieldMiser = true |
|
748 shotsFired = 0 |
|
749 shotsHit = 0 |
|
750 chainLength = 0 |
|
751 chainCounter = 0 |
|
752 |
|
753 ------------------------- |
|
754 -- gaudy racer |
|
755 ------------------------- |
|
756 CheckForNewRound() |
|
757 |
|
758 -- Handle Starting Stage of Game |
|
759 if (gameOver == false) and (gameBegun == false) then |
|
760 gameBegun = true |
|
761 roundNumber = 0 -- 0 |
|
762 firstClan = GetHogClan(CurrentHedgehog) |
|
763 end |
|
764 |
|
765 if gameOver == true then |
|
766 gameBegun = false |
|
767 stopMovement = true |
|
768 tumbleStarted = false |
|
769 SetMyCircles(false) |
|
770 end |
|
771 --------------- |
|
772 --------------- |
|
773 --AddCaption("num g: " .. numGears() ) |
|
774 |
|
775 --WriteLnToConsole("onNewTurn, I just set a bunch of variables to their necessary states. This was done at:") |
|
776 --WriteLnToConsole("The above occured at Game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
777 |
|
778 end |
|
779 |
|
780 function ThingsToBeRunOnGears(gear) |
|
781 |
|
782 HandleLifeSpan(gear) |
|
783 DeleteFarFlungBarrel(gear) |
|
784 |
|
785 if CirclesAreGo == true then |
|
786 CheckVarious(gear) |
|
787 ProjectileTrack(gear) |
|
788 end |
|
789 |
|
790 end |
|
791 |
|
792 |
|
793 function onGameTick() |
|
794 |
|
795 |
|
796 --WriteLnToConsole("Start of GameTick") |
|
797 luaGameTicks = luaGameTicks + 1 -- GameTime |
|
798 |
|
799 HandleCircles() |
|
800 |
|
801 Timer100 = Timer100 + 1 |
|
802 if Timer100 >= 100 then |
|
803 Timer100 = 0 |
|
804 |
|
805 if beam == true then |
|
806 shieldHealth = shieldHealth - 1 |
|
807 if shieldHealth <= 80 then |
|
808 shieldHealth = 80 |
|
809 beam = false |
|
810 AddCaption(loc("Shield Depleted"),0xff0000ff,capgrpMessage) |
|
811 PlaySound(sndMineTick) |
|
812 PlaySound(sndSwitchHog) |
|
813 end |
|
814 end |
|
815 |
|
816 |
|
817 --nw WriteLnToConsole("Starting ThingsToBeRunOnGears()") |
|
818 |
|
819 runOnGears(ThingsToBeRunOnGears) |
|
820 |
|
821 --nw WriteLnToConsole("Finished ThingsToBeRunOnGears()") |
|
822 |
|
823 --runOnGears(HandleLifeSpan) |
|
824 --runOnGears(DeleteFarFlungBarrel) |
|
825 |
|
826 if CirclesAreGo == true then |
|
827 CheckDistances() |
|
828 --runOnGears(CheckVarious) -- used to be in handletracking for some bizarre reason |
|
829 --runOnGears(ProjectileTrack) |
|
830 end |
|
831 |
|
832 -- white smoke trail as player falls from the sky |
|
833 if (TimeLeft <= 0) and (stopMovement == true) and (CurrentHedgehog ~= nil) then |
|
834 j,k = GetGearVelocity(CurrentHedgehog) |
|
835 if (j ~= 0) and (k ~= 0) then |
|
836 AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, true) |
|
837 end |
|
838 end |
|
839 |
|
840 --nw WriteLnToConsole("Finished 100Timer") |
|
841 |
|
842 end |
|
843 |
|
844 |
|
845 -- start the player tumbling with a boom once their turn has actually begun |
|
846 if (tumbleStarted == false) and (gameOver == false) then |
|
847 if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then |
|
848 --AddCaption(loc("Good to go!")) |
|
849 tumbleStarted = true |
|
850 TimeLeft = (TurnTime/1000) --45 |
|
851 FadeAlpha = 0 |
|
852 AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1) |
|
853 SetMyCircles(true) |
|
854 end |
|
855 end |
|
856 |
|
857 --WriteLnToConsole("Finished initial check") |
|
858 |
|
859 if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then |
|
860 |
|
861 --AddCaption(GetX(CurrentHedgehog) .. ";" .. GetY(CurrentHedgehog) ) |
|
862 |
|
863 -- Calculate and display turn time |
|
864 TimeLeftCounter = TimeLeftCounter + 1 |
|
865 if TimeLeftCounter == 1000 then |
|
866 TimeLeftCounter = 0 |
|
867 TimeLeft = TimeLeft - 1 |
|
868 |
|
869 if TimeLeft >= 0 then |
|
870 --AddCaption(loc("Time Left: ") .. TimeLeft) |
|
871 end |
|
872 |
|
873 end |
|
874 |
|
875 --WriteLnToConsole("Finished timeleft calculations") |
|
876 |
|
877 ------------------------------- |
|
878 -- Player has run out of luck (out of time or hit by gtShell) |
|
879 ------------------------------- |
|
880 -- checks in FloatyThings |
|
881 if PlayerIsFine() == false then |
|
882 TimeLeft = 0 |
|
883 end |
|
884 |
|
885 --WriteLnToConsole("successfully checked playerIsFine") |
|
886 |
|
887 if (TimeLeft == 0) then |
|
888 if (stopMovement == false) then --time to stop the player |
|
889 stopMovement = true |
|
890 beam = false |
|
891 upOn = false |
|
892 down = false |
|
893 leftOn = false |
|
894 rightOn = false |
|
895 SetMyCircles(false) |
|
896 --nw WriteLnToConsole("Player is out of luck") |
|
897 |
|
898 if shieldMiser == true then |
|
899 AddCaption(loc("Shield Miser! +20 points!"),0xffba00ff,capgrpAmmoinfo) |
|
900 AwardPoints(20) |
|
901 end |
|
902 |
|
903 if ((shotsHit / shotsFired * 100) >= 80) and (shotsFired > 4) then |
|
904 AddCaption(loc("Accuracy Bonus! +15 points!"),0xffba00ff,capgrpVolume) |
|
905 AwardPoints(15) |
|
906 end |
|
907 |
|
908 end |
|
909 else -- remove this if you want tumbler to fall slowly on death |
|
910 ------------------------------- |
|
911 -- Player is still in luck |
|
912 ------------------------------- |
|
913 |
|
914 |
|
915 --WriteLnToConsole("about to do chainCounter checks") |
|
916 if chainCounter > 0 then |
|
917 chainCounter = chainCounter -1 |
|
918 if chainCounter == 0 then |
|
919 chainLength = 0 |
|
920 end |
|
921 end |
|
922 |
|
923 -- handle movement based on IO |
|
924 moveTimer = moveTimer + 1 |
|
925 if moveTimer == 100 then -- 100 |
|
926 --nw WriteLnToConsole("Start of Player MoveTimer") |
|
927 moveTimer = 0 |
|
928 |
|
929 --------------- |
|
930 -- new trail code |
|
931 --------------- |
|
932 -- the trail lets you know you have 5s left to pilot, akin to birdy feathers |
|
933 if (TimeLeft <= 5) and (TimeLeft > 0) then --vgtSmoke |
|
934 tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, true) |
|
935 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
936 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(GetHogClan(CurrentHedgehog)) ) |
|
937 end |
|
938 -------------- |
|
939 -------------- |
|
940 |
|
941 dx, dy = GetGearVelocity(CurrentHedgehog) |
|
942 |
|
943 --WriteLnToConsole("I just got the velocity of currenthedgehog. It is dx: " .. dx .. "; dy: " .. dy) |
|
944 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
945 |
|
946 |
|
947 dxlimit = 0.4*fMod |
|
948 dylimit = 0.4*fMod |
|
949 |
|
950 if dx > dxlimit then |
|
951 dx = dxlimit |
|
952 end |
|
953 if dy > dylimit then |
|
954 dy = dylimit |
|
955 end |
|
956 if dx < -dxlimit then |
|
957 dx = -dxlimit |
|
958 end |
|
959 if dy < -dylimit then |
|
960 dy = -dylimit |
|
961 end |
|
962 |
|
963 |
|
964 if leftOn == true then |
|
965 dx = dx - 0.1*fMod |
|
966 end |
|
967 if rightOn == true then |
|
968 dx = dx + 0.1*fMod |
|
969 end |
|
970 |
|
971 if upOn == true then |
|
972 dy = dy - 0.1*fMod |
|
973 end |
|
974 if downOn == true then |
|
975 dy = dy + 0.1*fMod |
|
976 end |
|
977 |
|
978 SetGearVelocity(CurrentHedgehog, dx, dy) |
|
979 |
|
980 --WriteLnToConsole("I just SET the velocity of currenthedgehog. It is now dx: " .. dx .. "; dy: " .. dy) |
|
981 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
982 --nw WriteLnToConsole("End of Player MoveTimer") |
|
983 |
|
984 end |
|
985 |
|
986 end -- new end I put here to check if he's still alive or not |
|
987 |
|
988 end |
|
989 |
|
990 --WriteLnToConsole("End of GameTick") |
|
991 |
|
992 end |
|
993 |
|
994 function onGearResurrect(gear) |
|
995 |
|
996 -- did I fall into the water? well, that was a stupid thing to do |
|
997 if gear == CurrentHedgehog then |
|
998 TimeLeft = 0 |
|
999 --WriteLnToConsole("Current hedgehog just drowned himself") |
|
1000 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1001 |
|
1002 end |
|
1003 |
|
1004 end |
|
1005 |
|
1006 function onGearAdd(gear) |
|
1007 |
|
1008 if isATrackedGear(gear) then |
|
1009 trackGear(gear) |
|
1010 setNewGearValues(gear) |
|
1011 end |
|
1012 |
|
1013 --if GetGearType(gear) == gtBall then |
|
1014 -- SetTimer(gear, 5000) |
|
1015 --end |
|
1016 |
|
1017 if GetGearType(gear) == gtHedgehog then |
|
1018 SetEffect(gear, heResurrectable, true) |
|
1019 |
|
1020 ----------- |
|
1021 -- control |
|
1022 hhs[numhhs] = gear |
|
1023 numhhs = numhhs + 1 |
|
1024 ----------- |
|
1025 end |
|
1026 |
|
1027 end |
|
1028 |
|
1029 function onGearDelete(gear) |
|
1030 |
|
1031 if GetGearType(gear) == gtShell then |
|
1032 --nw WriteLnToConsole("on GearDelete call. Shell ID: " .. getGearValue(gear,"ID")) |
|
1033 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1034 |
|
1035 --if CurrentHedgehog ~= nil then |
|
1036 -- WriteLnToConsole("As it happens, player is at: " .. GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog)) |
|
1037 --end |
|
1038 elseif GetGearType(gear) == gtExplosives then |
|
1039 --nw WriteLnToConsole("on GearDelete call. Explosives ID: " .. getGearValue(gear,"ID")) |
|
1040 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1041 |
|
1042 --if CurrentHedgehog ~= nil then |
|
1043 -- WriteLnToConsole("As it happens, player is at: " .. GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog)) |
|
1044 --end |
|
1045 elseif GetGearType(gear) == gtFlame then |
|
1046 --WriteLnToConsole("on GearDelete flame") |
|
1047 end |
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 if isATrackedGear(gear) then |
|
1054 trackDeletion(gear) |
|
1055 end |
|
1056 |
|
1057 if CurrentHedgehog ~= nil then |
|
1058 FollowGear(CurrentHedgehog) |
|
1059 end |
|
1060 |
|
1061 end |
|
1062 |
|
1063 |
|
1064 |
|
1065 ------------------------------------------------------------ |
|
1066 ------------------------------------------------------------ |
|
1067 ------------------------------------------------------------ |
|
1068 ------------------------------------------------------------ |
|
1069 -- FLOATY THINGS |
|
1070 -- "I'll make this into a generic library and code properly |
|
1071 -- when I have more time and feel less lazy" |
|
1072 ------------------------------------------------------------ |
|
1073 ------------------------------------------------------------ |
|
1074 ------------------------------------------------------------ |
|
1075 ------------------------------------------------------------ |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 function PlayerIsFine() |
|
1081 return (playerIsFine) |
|
1082 end |
|
1083 |
|
1084 function GetDistFromGearToGear(gear, gear2) |
|
1085 |
|
1086 g1X, g1Y = GetGearPosition(gear) |
|
1087 g2X, g2Y = GetGearPosition(gear2) |
|
1088 q = g1X - g2X |
|
1089 w = g1Y - g2Y |
|
1090 |
|
1091 |
|
1092 --[[ |
|
1093 WriteLnToConsole("I just got the position of two gears and calculated the distance betwen them") |
|
1094 if gear == CurrentHedgehog then |
|
1095 WriteLnToConsole("Gear 1 is CurrentHedgehog.") |
|
1096 end |
|
1097 if gear2 == CurrentHedgehog then |
|
1098 WriteLnToConsole("Gear 2 is CurrentHedgehog.") |
|
1099 end |
|
1100 WriteLnToConsole("G1X: " .. g1X .. "; G1Y: " .. g1Y) |
|
1101 WriteLnToConsole("G2X: " .. g2X .. "; G2Y: " .. g2Y) |
|
1102 WriteLnToConsole("Their distance is " .. (q*q) + (w*w) ) |
|
1103 WriteLnToConsole("The above events occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1104 ]] |
|
1105 |
|
1106 |
|
1107 return ( (q*q) + (w*w) ) |
|
1108 |
|
1109 end |
|
1110 |
|
1111 function GetDistFromGearToXY(gear, g2X, g2Y) |
|
1112 |
|
1113 g1X, g1Y = GetGearPosition(gear) |
|
1114 q = g1X - g2X |
|
1115 w = g1Y - g2Y |
|
1116 |
|
1117 |
|
1118 --[[WriteLnToConsole("I just got the position of a gear and calculated the distance betwen it and another xy") |
|
1119 if gear == CurrentHedgehog then |
|
1120 WriteLnToConsole("Gear 1 is CurrentHedgehog.") |
|
1121 end |
|
1122 |
|
1123 WriteLnToConsole("G1X: " .. g1X .. "; G1Y: " .. g1Y) |
|
1124 WriteLnToConsole("Other X: " .. g2X .. "; Other Y: " .. g2Y) |
|
1125 WriteLnToConsole("Their distance is " .. (q*q) + (w*w) ) |
|
1126 WriteLnToConsole("The above events occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1127 ]] |
|
1128 |
|
1129 |
|
1130 return ( (q*q) + (w*w) ) |
|
1131 |
|
1132 |
|
1133 end |
|
1134 |
|
1135 function CreateMeSomeCircles() |
|
1136 |
|
1137 for i = 0, 7 do |
|
1138 vCCount = vCCount +1 |
|
1139 vCirc[i] = AddVisualGear(0,0,vgtCircle,0,true) |
|
1140 |
|
1141 vCircDX[i] = 0 |
|
1142 vCircDY[i] = 0 |
|
1143 |
|
1144 vType[i] = "generic" |
|
1145 vCounter[i] = 0 |
|
1146 vCounterLim[i] = 3000 |
|
1147 vCircScore[i] = 0 |
|
1148 vCircHealth[i] = 1 |
|
1149 |
|
1150 vCircMinA[i] = 80 --80 --20 |
|
1151 vCircMaxA[i] = 255 |
|
1152 vCircType[i] = 1 --1 |
|
1153 vCircPulse[i] = 10 |
|
1154 vCircFuckAll[i] = 0 |
|
1155 vCircRadius[i] = 0 |
|
1156 vCircWidth[i] = 3 --5 |
|
1157 |
|
1158 vCircRadMax[i] = 0 |
|
1159 vCircRadMin[i] = 0 |
|
1160 vCircRadDir[i] = -1 |
|
1161 vCircRadCounter[i] = 0 |
|
1162 |
|
1163 vCircX[i], vCircY[i] = 0,0 |
|
1164 |
|
1165 vCircCol[i] = 0xff00ffff |
|
1166 |
|
1167 SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], vCircCol[i]) |
|
1168 end |
|
1169 |
|
1170 pShield = AddVisualGear(0,0,vgtCircle,0,true) |
|
1171 --SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 80, 200, 1, 10, 0, 200, 5, 0xff00ffff) |
|
1172 |
|
1173 |
|
1174 end |
|
1175 |
|
1176 function IGotMeASafeXYValue(i) |
|
1177 |
|
1178 acceptibleDistance = 800 |
|
1179 |
|
1180 -- put this in here to thwart attempts at repositioning and test sanity limit |
|
1181 --vCircX[i] = GetX(CurrentHedgehog)+250 |
|
1182 --vCircY[i] = GetY(CurrentHedgehog)+250 |
|
1183 |
|
1184 vCircX[i] = GetRandom(5000) |
|
1185 vCircY[i] = GetRandom(2000) |
|
1186 dist = GetDistFromGearToXY(CurrentHedgehog, vCircX[i], vCircY[i]) |
|
1187 if dist > acceptibleDistance*acceptibleDistance then |
|
1188 return(true) |
|
1189 else |
|
1190 return(false) |
|
1191 end |
|
1192 |
|
1193 end |
|
1194 |
|
1195 function CircleDamaged(i) |
|
1196 |
|
1197 res = "" |
|
1198 vCircHealth[i] = vCircHealth[i] -1 |
|
1199 |
|
1200 if vCircHealth[i] <= 0 then |
|
1201 -- circle is dead, do death effects/consequences |
|
1202 |
|
1203 vCircActive[i] = false |
|
1204 |
|
1205 if (vType[i] == "drone") then |
|
1206 PlaySound(sndHellishImpact4) |
|
1207 TimeLeft = TimeLeft + 4 |
|
1208 AddCaption(loc("Time Extended!") .. "+" .. 4 .. loc("s"), 0xff0000ff,capgrpMessage ) |
|
1209 |
|
1210 morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1) |
|
1211 SetHealth(morte, 0) |
|
1212 |
|
1213 RK = RK + 1 |
|
1214 if RK == 5 then |
|
1215 RK = 0 |
|
1216 AddCaption(loc("Drone Hunter! +10 points!"),0xffba00ff,capgrpMessage2) |
|
1217 AwardPoints(10) |
|
1218 end |
|
1219 |
|
1220 elseif (vType[i] == "ammo") then |
|
1221 AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false) |
|
1222 PlaySound(sndExplosion) |
|
1223 PlaySound(sndShotgunReload) |
|
1224 primShotsLeft = primShotsLeft + 3 |
|
1225 AddCaption("+" .. 3 .. " " .. loc("Ammo"), 0x00ff00ff,capgrpMessage) |
|
1226 |
|
1227 GK = GK + 1 |
|
1228 if GK == 3 then |
|
1229 GK = 0 |
|
1230 AddCaption(loc("Ammo Maniac! +5 points!"),0xffba00ff,capgrpMessage2) |
|
1231 AwardPoints(5) |
|
1232 end |
|
1233 |
|
1234 elseif (vType[i] == "bonus") then |
|
1235 |
|
1236 AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false) |
|
1237 PlaySound(sndExplosion) |
|
1238 |
|
1239 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1240 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1241 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1242 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1243 AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false) |
|
1244 AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, false) |
|
1245 |
|
1246 PlaySound(sndVaporize) |
|
1247 --sndWarp sndMineTick --sndSwitchHog --sndSuddenDeath |
|
1248 |
|
1249 shieldHealth = shieldHealth + 30 |
|
1250 AddCaption(loc("Shield boosted! +30 power"), 0xa800ffff,capgrpMessage) |
|
1251 if shieldHealth >= 250 then |
|
1252 shieldHealth = 250 |
|
1253 AddCaption(loc("Shield is fully recharged!"),0xa800ffff,capgrpMessage) |
|
1254 end |
|
1255 |
|
1256 OK = OK + 1 |
|
1257 if OK == 3 then |
|
1258 OK = 0 |
|
1259 AddCaption(loc("Shield Seeker! + 10 points!"),0xffba00ff,capgrpMessage2) |
|
1260 AwardPoints(10) |
|
1261 end |
|
1262 |
|
1263 elseif (vType[i] == "blueboss") then |
|
1264 PlaySound(sndHellishImpact3) |
|
1265 AddCaption(loc("Boss defeated! +50 points!"), 0x0050ffff,capgrpMessage) |
|
1266 |
|
1267 morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1) |
|
1268 SetHealth(morte, 0) |
|
1269 |
|
1270 BK = BK + 1 |
|
1271 if BK == 2 then |
|
1272 BK = 0 |
|
1273 AddCaption(loc("Boss Slayer! +25 points!"),0xffba00ff,capgrpMessage2) |
|
1274 AwardPoints(25) |
|
1275 end |
|
1276 |
|
1277 end |
|
1278 |
|
1279 AwardPoints(vCircScore[i]) |
|
1280 AwardKills() |
|
1281 SetUpCircle(i) |
|
1282 res = "fatal" |
|
1283 |
|
1284 chainCounter = 3000 |
|
1285 chainLength = chainLength + 1 |
|
1286 if chainLength > 1 then |
|
1287 AddCaption( chainLength .. loc("-Hit Combo! +") .. chainLength*2 .. loc(" points!"),0xffba00ff,capgrpAmmostate) |
|
1288 AwardPoints(chainLength*2) |
|
1289 end |
|
1290 |
|
1291 else |
|
1292 -- circle is merely damaged |
|
1293 -- do damage effects/sounds |
|
1294 AddVisualGear(vCircX[i], vCircY[i], vgtSteam, 0, false) |
|
1295 r = GetRandom(4) |
|
1296 if r == 0 then |
|
1297 PlaySound(sndHellishImpact1) |
|
1298 elseif r == 1 then |
|
1299 PlaySound(sndHellishImpact2) |
|
1300 elseif r == 2 then |
|
1301 PlaySound(sndHellishImpact3) |
|
1302 elseif r == 3 then |
|
1303 PlaySound(sndHellishImpact4) |
|
1304 end |
|
1305 res = "non-fatal" |
|
1306 |
|
1307 end |
|
1308 |
|
1309 return(res) |
|
1310 |
|
1311 end |
|
1312 |
|
1313 function SetUpCircle(i) |
|
1314 |
|
1315 |
|
1316 r = GetRandom(10) |
|
1317 --r = 8 |
|
1318 -- 80% of spawning either red/green |
|
1319 if r <= 7 then |
|
1320 |
|
1321 --r = GetRandom(5) |
|
1322 r = GetRandom(2) |
|
1323 --r = 1 |
|
1324 if r == 0 then |
|
1325 --if r <= 2 then |
|
1326 vCircCol[i] = 0xff0000ff -- red |
|
1327 vType[i] = "drone" |
|
1328 vCircRadMin[i] = 50 *5 |
|
1329 vCircRadMax[i] = 90 *5 |
|
1330 vCounterLim[i] = 3000 |
|
1331 vCircScore[i] = 10 |
|
1332 vCircHealth[i] = 1 |
|
1333 --else |
|
1334 elseif r == 1 then |
|
1335 vCircCol[i] = 0x00ff00ff -- green |
|
1336 vType[i] = "ammo" |
|
1337 vCircRadMin[i] = 25 *7 |
|
1338 vCircRadMax[i] = 30 *7 |
|
1339 vCircScore[i] = 3 |
|
1340 vCircHealth[i] = 1 |
|
1341 end |
|
1342 |
|
1343 -- 20% chance of spawning boss or bonus |
|
1344 else |
|
1345 r = GetRandom(5) |
|
1346 --r = GetRandom(2) |
|
1347 --r = 0 |
|
1348 if r <= 1 then |
|
1349 --if r == 0 then |
|
1350 vCircCol[i] = 0x0050ffff -- sexy blue |
|
1351 vType[i] = "blueboss" |
|
1352 vCircRadMin[i] = 100*5 |
|
1353 vCircRadMax[i] = 180*5 |
|
1354 vCircWidth[i] = 1 |
|
1355 vCounterLim[i] = 2000 |
|
1356 vCircScore[i] = 50 |
|
1357 vCircHealth[i] = 3 |
|
1358 else |
|
1359 --elseif r == 1 then |
|
1360 --vCircCol[i] = 0xffae00ff -- orange |
|
1361 vCircCol[i] = 0xa800ffff -- purp |
|
1362 vType[i] = "bonus" |
|
1363 vCircRadMin[i] = 20 *7 |
|
1364 vCircRadMax[i] = 40 *7 |
|
1365 vCircScore[i] = 5 |
|
1366 vCircHealth[i] = 1 |
|
1367 end |
|
1368 |
|
1369 end |
|
1370 |
|
1371 -- regenerate circle xy if too close to player or until sanity limit kicks in |
|
1372 reN = 0 |
|
1373 --zzz = 0 |
|
1374 while (reN < 10) do |
|
1375 if IGotMeASafeXYValue(i) == false then |
|
1376 reN = reN + 1 |
|
1377 --zzz = zzz + 1 |
|
1378 else |
|
1379 reN = 15 |
|
1380 end |
|
1381 end |
|
1382 --AddCaption("Took me this many retries: " .. zzz) -- number of times it took to work |
|
1383 |
|
1384 vCircRadius[i] = vCircRadMax[i] - GetRandom(vCircRadMin[i]) |
|
1385 |
|
1386 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i]) |
|
1387 SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], vCircWidth[i], vCircCol[i]-0x000000ff) |
|
1388 -- - -0x000000ff |
|
1389 vCircActive[i] = true -- new |
|
1390 |
|
1391 --nw WriteLnToConsole("CIRC " .. i .. ": X: " .. vCircX[i] .. "; Y: " .. vCircY[i]) |
|
1392 --nw WriteLnToConsole("CIRC " .. i .. ": dX: " .. vCircDX[i] .. "; dY: " .. vCircDY[i]) |
|
1393 --nw WriteLnToConsole("CIRC " .. i .. ": RAD:" .. vCircRadius[i]) |
|
1394 |
|
1395 end |
|
1396 |
|
1397 function SetMyCircles(s) |
|
1398 |
|
1399 CirclesAreGo = s |
|
1400 playerIsFine = s |
|
1401 |
|
1402 if s == true then |
|
1403 --nw WriteLnToConsole("About to set up all circles, old values are here:") |
|
1404 for i = 0,(vCCount-1) do |
|
1405 --nw WriteLnToConsole("CIRC " .. i .. ": X: " .. vCircX[i] .. "; Y: " .. vCircY[i]) |
|
1406 --nw WriteLnToConsole("CIRC " .. i .. ": dX: " .. vCircDX[i] .. "; dY: " .. vCircDY[i]) |
|
1407 --nw WriteLnToConsole("CIRC " .. i .. ": RAD:" .. vCircRadius[i]) |
|
1408 end |
|
1409 --nw WriteLnToConsole("Old values given, new values to follow...") |
|
1410 end |
|
1411 |
|
1412 for i = 0,(vCCount-1) do |
|
1413 |
|
1414 if s == false then |
|
1415 --vCircCol[i] = 0xffffffff |
|
1416 vCircActive[i] = false |
|
1417 elseif s == true then |
|
1418 SetUpCircle(i) |
|
1419 end |
|
1420 |
|
1421 end |
|
1422 |
|
1423 end |
|
1424 |
|
1425 function WellHeAintGonnaJumpNoMore(x,y) |
|
1426 |
|
1427 AddVisualGear(x, y, vgtBigExplosion, 0, false) |
|
1428 playerIsFine = false |
|
1429 AddCaption(loc("GOTCHA!")) |
|
1430 PlaySound(sndExplosion) |
|
1431 PlaySound(sndHellish) |
|
1432 |
|
1433 targetHit = true |
|
1434 |
|
1435 end |
|
1436 |
|
1437 --- collision detection for weapons fire |
|
1438 function CheckVarious(gear) |
|
1439 |
|
1440 --if (GetGearType(gear) == gtExplosives) then |
|
1441 --nw WriteLnToConsole("Start of CheckVarious(): Exp ID: " .. getGearValue(gear,"ID")) |
|
1442 --elseif (GetGearType(gear) == gtShell) then |
|
1443 --nw WriteLnToConsole("Start of CheckVarious(): Shell ID: " .. getGearValue(gear,"ID")) |
|
1444 --end |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 targetHit = false |
|
1450 |
|
1451 -- if circle is hit by player fire |
|
1452 if (GetGearType(gear) == gtExplosives) then |
|
1453 circsHit = 0 |
|
1454 |
|
1455 for i = 0,(vCCount-1) do |
|
1456 |
|
1457 --nw WriteLnToConsole("Is it neccessary to check for collision with circ " .. i) |
|
1458 |
|
1459 --if (vCircActive[i] == true) and ( (vType[i] == "drone") ) then |
|
1460 |
|
1461 --nw WriteLnToConsole("YES. about to calc distance between gtExplosives and circ " .. i) |
|
1462 |
|
1463 dist = GetDistFromGearToXY(gear, vCircX[i], vCircY[i]) |
|
1464 |
|
1465 -- calculate my real radius if I am an aura |
|
1466 if vCircType[i] == 0 then |
|
1467 NR = vCircRadius[i] |
|
1468 else |
|
1469 NR = (48/100*vCircRadius[i])/2 |
|
1470 end |
|
1471 |
|
1472 if dist <= NR*NR then |
|
1473 |
|
1474 --nw WriteLnToConsole("Collision confirmed. The gtExplosives is within the circ radius!") |
|
1475 |
|
1476 --SetGearPosition(gear, vCircX[i], vCircY[i]) |
|
1477 --WriteLnToConsole("set the gtExplosives to be in the center of circ") |
|
1478 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
1479 |
|
1480 targetHit = true |
|
1481 --DeleteGear(gear) |
|
1482 --SetHealth(gear,0) |
|
1483 --WriteLnToConsole("set " .. "Exp ID: " .. getGearValue(gear,"ID") .. " health to 0") |
|
1484 --WriteLnToConsole("targetHit set to true, explosive is at distance " .. dist .. "(within range " .. NR*NR.. ") of circ" ) |
|
1485 |
|
1486 CircleDamaged(i) |
|
1487 |
|
1488 circsHit = circsHit + 1 |
|
1489 if circsHit > 1 then |
|
1490 AddCaption(loc("Multi-shot! +5 points!"),0xffba00ff,capgrpAmmostate) |
|
1491 end |
|
1492 |
|
1493 shotsHit = shotsHit + 1 |
|
1494 |
|
1495 end |
|
1496 |
|
1497 --end |
|
1498 |
|
1499 end |
|
1500 |
|
1501 -- if player is hit by circle bazooka |
|
1502 elseif (GetGearType(gear) == gtShell) or (GetGearType(gear) == gtBall) then |
|
1503 |
|
1504 dist = GetDistFromGearToGear(gear, CurrentHedgehog) |
|
1505 |
|
1506 if beam == true then |
|
1507 |
|
1508 if dist < 3000 then |
|
1509 tempE = AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, true) |
|
1510 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
1511 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, 0xff00ffff ) |
|
1512 PlaySound(sndVaporize) |
|
1513 DeleteGear(gear) |
|
1514 |
|
1515 SK = SK + 1 |
|
1516 if SK == 5 then |
|
1517 SK = 0 |
|
1518 AddCaption(loc("Shield Master! +10 points!"),0xffba00ff,capgrpAmmoinfo) |
|
1519 AwardPoints(10) |
|
1520 end |
|
1521 end |
|
1522 |
|
1523 elseif dist < 1600 then |
|
1524 WellHeAintGonnaJumpNoMore(GetX(gear), GetY(gear)) |
|
1525 end |
|
1526 |
|
1527 --[[if targetHit == true then |
|
1528 WriteLnToConsole("about to delete shell due to targetHit being set to true earlier") |
|
1529 DeleteGear(gear) |
|
1530 WriteLnToConsole("there, I deleted it") |
|
1531 end]] |
|
1532 |
|
1533 |
|
1534 end |
|
1535 |
|
1536 if targetHit == true then |
|
1537 --nw WriteLnToConsole("about to delete something due to targetHit being set to true earlier") |
|
1538 DeleteGear(gear) |
|
1539 --nw WriteLnToConsole("there, I deleted it") |
|
1540 end |
|
1541 |
|
1542 --nw WriteLnToConsole("End of CheckVarious()") |
|
1543 |
|
1544 end |
|
1545 |
|
1546 -- collision detection for player entering a circle |
|
1547 function CheckDistances() |
|
1548 |
|
1549 --nw WriteLnToConsole("Start of CheckDistances()") |
|
1550 |
|
1551 for i = 0,(vCCount-1) do |
|
1552 |
|
1553 |
|
1554 --nw WriteLnToConsole("Attempting to calculate dist of circ " .. i) |
|
1555 |
|
1556 g1X, g1Y = GetGearPosition(CurrentHedgehog) |
|
1557 g2X, g2Y = vCircX[i], vCircY[i] |
|
1558 |
|
1559 g1X = g1X - g2X |
|
1560 g1Y = g1Y - g2Y |
|
1561 dist = (g1X*g1X) + (g1Y*g1Y) |
|
1562 |
|
1563 --nw WriteLnToConsole("Calcs done. Dist to CurrentHedgehog is " .. dist) |
|
1564 |
|
1565 -- calculate my real radius if I am an aura |
|
1566 if vCircType[i] == 0 then |
|
1567 NR = vCircRadius[i] |
|
1568 else |
|
1569 NR = (48/100*vCircRadius[i])/2 |
|
1570 end |
|
1571 |
|
1572 if dist <= NR*NR then |
|
1573 |
|
1574 if (vCircActive[i] == true) and |
|
1575 ((vType[i] == "ammo") or (vType[i] == "bonus") ) |
|
1576 then |
|
1577 |
|
1578 CircleDamaged(i) |
|
1579 |
|
1580 elseif (vCircActive[i] == true) and |
|
1581 ( (vType[i] == "drone") or (vType[i] == "blueboss") ) |
|
1582 then |
|
1583 |
|
1584 ss = CircleDamaged(i) |
|
1585 WellHeAintGonnaJumpNoMore(GetX(CurrentHedgehog),GetY(CurrentHedgehog)) |
|
1586 |
|
1587 if ss == "fatal" then |
|
1588 if (primShotsLeft == 0) and (TimeLeft <= 9) then |
|
1589 AddCaption(loc("Kamikaze Expert! +15 points!"),0xffba00ff,capgrpMessage) |
|
1590 AwardPoints(15) |
|
1591 elseif (primShotsLeft == 0) then |
|
1592 AddCaption(loc("Depleted Kamikaze! +5 points!"),0xffba00ff,capgrpMessage) |
|
1593 AwardPoints(5) |
|
1594 elseif TimeLeft <= 9 then |
|
1595 AddCaption(loc("Timed Kamikaze! +10 points!"),0xffba00ff,capgrpMessage) |
|
1596 AwardPoints(10) |
|
1597 end |
|
1598 end |
|
1599 |
|
1600 end |
|
1601 |
|
1602 |
|
1603 end |
|
1604 |
|
1605 end |
|
1606 |
|
1607 --nw WriteLnToConsole("End of CheckDistances()") |
|
1608 |
|
1609 end |
|
1610 |
|
1611 function HandleCircles() |
|
1612 |
|
1613 |
|
1614 --[[if CirclesAreGo == true then |
|
1615 |
|
1616 --CheckDistances() |
|
1617 --runOnGears(CheckVarious) -- used to be in handletracking for some bizarre reason |
|
1618 |
|
1619 --pTimer = pTimer + 1 |
|
1620 --if pTimer == 100 then |
|
1621 -- pTimer = 0 |
|
1622 -- runOnGears(ProjectileTrack) |
|
1623 --end |
|
1624 |
|
1625 end]] |
|
1626 |
|
1627 for i = 0,(vCCount-1) do |
|
1628 |
|
1629 vCounter[i] = vCounter[i] + 1 |
|
1630 if vCounter[i] >= vCounterLim[i] then |
|
1631 |
|
1632 vCounter[i] = 0 |
|
1633 |
|
1634 if ((vType[i] == "drone") or (vType[i] == "blueboss") ) and |
|
1635 (vCircActive[i] == true) then |
|
1636 AddGear(vCircX[i], vCircY[i], gtShell, 0, 0, 0, 1) |
|
1637 |
|
1638 --WriteLnToConsole("Circle " .. i .. " just fired/added a gtShell") |
|
1639 --WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1640 |
|
1641 --elseif (vType[i] == "bluebottle") and (vCircActive[i] == true) then |
|
1642 -- AddGear(vCircX[i], vCircY[i]-vCircRadius[i], gtBall, 0, 0, 0, 1) |
|
1643 -- AddGear(vCircX[i], vCircY[i]+vCircRadius[i], gtBall, 0, 0, 0, 1) |
|
1644 -- AddGear(vCircX[i]-vCircRadius[i], vCircY[i], gtBall, 0, 0, 0, 1) |
|
1645 -- AddGear(vCircX[i]+vCircRadius[i], vCircY[i], gtBall, 0, 0, 0, 1) |
|
1646 end |
|
1647 |
|
1648 end |
|
1649 |
|
1650 if (vCircActive[i] == true) then |
|
1651 |
|
1652 vCircRadCounter[i] = vCircRadCounter[i] + 1 |
|
1653 if vCircRadCounter[i] == 100 then |
|
1654 |
|
1655 vCircRadCounter[i] = 0 |
|
1656 |
|
1657 -- make my radius increase/decrease faster if I am an aura |
|
1658 if vCircType[i] == 0 then |
|
1659 M = 1 |
|
1660 else |
|
1661 M = 10 |
|
1662 end |
|
1663 |
|
1664 vCircRadius[i] = vCircRadius[i] + vCircRadDir[i] |
|
1665 if vCircRadius[i] > vCircRadMax[i] then |
|
1666 vCircRadDir[i] = -M |
|
1667 elseif vCircRadius[i] < vCircRadMin[i] then |
|
1668 vCircRadDir[i] = M |
|
1669 end |
|
1670 |
|
1671 |
|
1672 -- random effect test |
|
1673 -- maybe use this to tell the difference between circs |
|
1674 -- you can kill by shooting or not |
|
1675 --vgtSmoke vgtSmokeWhite |
|
1676 --vgtSteam -- nice long trail |
|
1677 --vgtDust -- short trail on earthrise |
|
1678 --vgtSmokeTrace |
|
1679 if vType[i] == "ammo" then |
|
1680 |
|
1681 tempE = AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, true) |
|
1682 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff |
|
1683 SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, g8, g9, vCircCol[i] ) |
|
1684 |
|
1685 --AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, true) |
|
1686 |
|
1687 elseif vType[i] == "bonus" then |
|
1688 |
|
1689 tempE = AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, true) |
|
1690 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff --vCircCol[i] |
|
1691 SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, 1, g9, 0xff00ffff ) |
|
1692 |
|
1693 |
|
1694 elseif vType[i] == "blueboss" then |
|
1695 |
|
1696 k = 25 |
|
1697 g = vgtSteam |
|
1698 trailColour = 0xae00ffff |
|
1699 |
|
1700 -- 0xffae00ff -- orange |
|
1701 -- 0xae00ffff -- purp |
|
1702 |
|
1703 tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true) |
|
1704 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff |
|
1705 SetVisualGearValues(tempE, vCircX[i], vCircY[i]+k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 ) |
|
1706 |
|
1707 tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true) |
|
1708 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff |
|
1709 SetVisualGearValues(tempE, vCircX[i]+k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 ) |
|
1710 |
|
1711 tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true) |
|
1712 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --0xff00ffff --0x00ff00ff |
|
1713 SetVisualGearValues(tempE, vCircX[i]-k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 ) |
|
1714 |
|
1715 |
|
1716 end |
|
1717 |
|
1718 |
|
1719 end |
|
1720 |
|
1721 end |
|
1722 |
|
1723 |
|
1724 end |
|
1725 |
|
1726 -- alter the circles velocities |
|
1727 circAdjustTimer = circAdjustTimer + 1 |
|
1728 if circAdjustTimer == 2000 then |
|
1729 |
|
1730 circAdjustTimer = 0 |
|
1731 |
|
1732 for i = 0,(vCCount-1) do |
|
1733 |
|
1734 -- bounce the circles off the edges if they go too far |
|
1735 -- or make them move in random directions |
|
1736 |
|
1737 if vCircX[i] > 5500 then |
|
1738 vCircDX[i] = -5 --5 circmovchange |
|
1739 elseif vCircX[i] < -1500 then |
|
1740 vCircDX[i] = 5 --5 circmovchange |
|
1741 else |
|
1742 |
|
1743 z = GetRandom(2) |
|
1744 if z == 1 then |
|
1745 z = 1 |
|
1746 else |
|
1747 z = -1 |
|
1748 end |
|
1749 vCircDX[i] = vCircDX[i] + GetRandom(3)*z --3 circmovchange |
|
1750 end |
|
1751 |
|
1752 if vCircY[i] > 1500 then |
|
1753 vCircDY[i] = -5 --5 circmovchange |
|
1754 elseif vCircY[i] < -2900 then |
|
1755 vCircDY[i] = 5 --5 circmovchange |
|
1756 else |
|
1757 z = GetRandom(2) |
|
1758 if z == 1 then |
|
1759 z = 1 |
|
1760 else |
|
1761 z = -1 |
|
1762 end |
|
1763 vCircDY[i] = vCircDY[i] + GetRandom(3)*z --3 circmovchange |
|
1764 end |
|
1765 |
|
1766 end |
|
1767 |
|
1768 end |
|
1769 |
|
1770 -- move the circles according to their current velocities |
|
1771 m2Count = m2Count + 1 |
|
1772 if m2Count == 25 then --25 circmovchange |
|
1773 |
|
1774 m2Count = 0 |
|
1775 for i = 0,(vCCount-1) do |
|
1776 vCircX[i] = vCircX[i] + vCircDX[i] |
|
1777 vCircY[i] = vCircY[i] + vCircDY[i] |
|
1778 end |
|
1779 |
|
1780 if (TimeLeft == 0) and (tumbleStarted == true) then |
|
1781 |
|
1782 FadeAlpha = FadeAlpha + 1 |
|
1783 if FadeAlpha >= 255 then |
|
1784 FadeAlpha = 255 |
|
1785 end |
|
1786 |
|
1787 --new |
|
1788 --if FadeAlpha == 1 then |
|
1789 -- AddCaption("GOT IT") |
|
1790 -- for i = 0,(vCCount-1) do |
|
1791 -- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i]) |
|
1792 -- vCircCol[i] = g10 |
|
1793 -- end |
|
1794 --end |
|
1795 |
|
1796 end |
|
1797 |
|
1798 end |
|
1799 |
|
1800 for i = 0,(vCCount-1) do |
|
1801 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i]) -- vCircCol[i] g10 |
|
1802 SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, g10) |
|
1803 end |
|
1804 |
|
1805 if (TimeLeft == 0) or |
|
1806 ((tumbleStarted == false)) then |
|
1807 for i = 0,(vCCount-1) do |
|
1808 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i]) -- vCircCol[i] g10 |
|
1809 SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, (vCircCol[i]-FadeAlpha)) |
|
1810 end |
|
1811 end |
|
1812 |
|
1813 |
|
1814 if (CurrentHedgehog ~= nil) and (beam == true) then |
|
1815 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(pShield) |
|
1816 --SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, g10 ) |
|
1817 SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, 0xa800ffff-0x000000ff - -shieldHealth ) |
|
1818 else |
|
1819 SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 0, g9, g10 ) |
|
1820 end |
|
1821 |
|
1822 end |
|
1823 |
|
1824 function ProjectileTrack(gear) |
|
1825 |
|
1826 if (GetGearType(gear) == gtShell) then |
|
1827 |
|
1828 --nw WriteLnToConsole("ProjectileTrack() for Shell ID: " .. getGearValue(gear,"ID")) |
|
1829 |
|
1830 -- newnew |
|
1831 if (GetGearType(gear) == gtShell) then |
|
1832 turningSpeed = 0.1*fMod |
|
1833 --elseif (GetGearType(gear) == gtBall) then |
|
1834 -- turningSpeed = 0.2*fMod |
|
1835 end |
|
1836 |
|
1837 dx, dy = GetGearVelocity(gear) |
|
1838 |
|
1839 --WriteLnToConsole("I'm trying to track currenthedge with shell ID: " .. getGearValue(gear,"ID")) |
|
1840 --WriteLnToConsole("I just got the velocity of the shell. It is dx: " .. dx .. "; dy: " .. dy) |
|
1841 --WriteLnToConsole("CurrentHedgehog is at X: " .. GetX(CurrentHedgehog) .. "; Y: " .. GetY(CurrentHedgehog) ) |
|
1842 |
|
1843 if GetX(gear) > GetX(CurrentHedgehog) then |
|
1844 dx = dx - turningSpeed--0.1 |
|
1845 else |
|
1846 dx = dx + turningSpeed--0.1 |
|
1847 end |
|
1848 |
|
1849 if GetY(gear) > GetY(CurrentHedgehog) then |
|
1850 dy = dy - turningSpeed--0.1 |
|
1851 else |
|
1852 dy = dy + turningSpeed--0.1 |
|
1853 end |
|
1854 |
|
1855 |
|
1856 if (GetGearType(gear) == gtShell) then |
|
1857 dxlimit = 0.4*fMod |
|
1858 dylimit = 0.4*fMod |
|
1859 --elseif (GetGearType(gear) == gtBall) then |
|
1860 -- dxlimit = 0.5 -- 0.5 is about the same |
|
1861 -- dylimit = 0.5 -- 0.6 is faster than player |
|
1862 end |
|
1863 |
|
1864 if dx > dxlimit then |
|
1865 dx = dxlimit |
|
1866 end |
|
1867 if dy > dylimit then |
|
1868 dy = dylimit |
|
1869 end |
|
1870 if dx < -dxlimit then |
|
1871 dx = -dxlimit |
|
1872 end |
|
1873 if dy < -dylimit then |
|
1874 dy = -dylimit |
|
1875 end |
|
1876 |
|
1877 SetGearVelocity(gear, dx, dy) |
|
1878 |
|
1879 --WriteLnToConsole("I just SET the velocity of shell towards currenthegdge. It is now dx: " .. dx .. "; dy: " .. dy) |
|
1880 --WriteLnToConsole("The above events occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks) |
|
1881 --nw WriteLnToConsole("ProjectileTrack() finished successfully") |
|
1882 |
|
1883 end |
|
1884 |
|
1885 end |
|
1886 |