44 procedure DrawGears; |
44 procedure DrawGears; |
45 procedure DrawGearsTimers; |
45 procedure DrawGearsTimers; |
46 procedure FreeGearsList; |
46 procedure FreeGearsList; |
47 procedure AddMiscGears; |
47 procedure AddMiscGears; |
48 procedure AssignHHCoords; |
48 procedure AssignHHCoords; |
|
49 procedure StartSuddenDeath; |
49 function GearByUID(uid : Longword) : PGear; |
50 function GearByUID(uid : Longword) : PGear; |
50 function IsClockRunning() : boolean; |
51 function IsClockRunning() : boolean; |
51 |
52 |
52 implementation |
53 implementation |
53 uses uStore, uSound, uTeams, uRandom, uIO, uLandGraphics, |
54 uses uStore, uSound, uTeams, uRandom, uIO, uLandGraphics, |
59 |
60 |
60 var skipFlag: boolean; |
61 var skipFlag: boolean; |
61 |
62 |
62 var delay: LongWord; |
63 var delay: LongWord; |
63 delay2: LongWord; |
64 delay2: LongWord; |
64 step: (stDelay, stChDmg, stSweep, stTurnReact, |
65 step: (stInit, stDelay, stChDmg, stSweep, stTurnReact, |
65 stAfterDelay, stChWin, stWater, stChWin2, stHealth, |
66 stAfterDelay, stChWin, stWater, stChWin2, stHealth, |
66 stSpawn, stNTurn); |
67 stSpawn, stNTurn); |
67 NewTurnTick: LongWord; |
68 NewTurnTick: LongWord; |
68 //SDMusic: shortstring; |
69 //SDMusic: shortstring; |
69 |
70 |
131 begin |
132 begin |
132 inc(tmp, ModifyDamage(Gear^.Hedgehog^.Effects[hePoisoned], Gear)); |
133 inc(tmp, ModifyDamage(Gear^.Hedgehog^.Effects[hePoisoned], Gear)); |
133 if (GameFlags and gfResetHealth) <> 0 then |
134 if (GameFlags and gfResetHealth) <> 0 then |
134 dec(Gear^.Hedgehog^.InitialHealth) // does not need a minimum check since <= 1 basically disables it |
135 dec(Gear^.Hedgehog^.InitialHealth) // does not need a minimum check since <= 1 basically disables it |
135 end; |
136 end; |
|
137 // Apply SD health decrease as soon as SD starts |
136 if (TotalRounds > cSuddenDTurns - 1) then |
138 if (TotalRounds > cSuddenDTurns - 1) then |
137 begin |
139 begin |
138 inc(tmp, cHealthDecrease); |
140 inc(tmp, cHealthDecrease); |
139 if (GameFlags and gfResetHealth) <> 0 then |
141 if (GameFlags and gfResetHealth) <> 0 then |
140 dec(Gear^.Hedgehog^.InitialHealth, cHealthDecrease) |
142 dec(Gear^.Hedgehog^.InitialHealth, cHealthDecrease) |
154 dec(Gear^.Hedgehog^.InitialHealth, 5) |
156 dec(Gear^.Hedgehog^.InitialHealth, 5) |
155 end |
157 end |
156 end; |
158 end; |
157 if tmp > 0 then |
159 if tmp > 0 then |
158 begin |
160 begin |
159 inc(Gear^.Damage, min(tmp, max(0,Gear^.Health - 1 - Gear^.Damage))); |
161 // SD damage never reduces health below 1 |
160 HHHurt(Gear^.Hedgehog, dsPoison); |
162 tmp:= min(tmp, max(0, Gear^.Health - 1 - Gear^.Damage)); |
|
163 inc(Gear^.Damage, tmp); |
|
164 if tmp > 0 then |
|
165 // Make hedgehog moan on damage |
|
166 HHHurt(Gear^.Hedgehog, dsPoison); |
161 end |
167 end |
162 end; |
168 end; |
163 |
169 |
164 Gear:= Gear^.NextGear |
170 Gear:= Gear^.NextGear |
165 end; |
171 end; |
304 inc(step) |
316 inc(step) |
305 end; |
317 end; |
306 stWater: |
318 stWater: |
307 if (not bBetweenTurns) and (not isInMultiShoot) then |
319 if (not bBetweenTurns) and (not isInMultiShoot) then |
308 begin |
320 begin |
|
321 // Start Sudden Death water rise in the 2nd round of Sudden Death |
309 if TotalRounds = cSuddenDTurns + 1 then |
322 if TotalRounds = cSuddenDTurns + 1 then |
310 bWaterRising:= true; |
323 bWaterRising:= true; |
311 if bWaterRising and (cWaterRise > 0) then |
324 if bWaterRising and (cWaterRise > 0) then |
312 AddGear(0, 0, gtWaterUp, 0, _0, _0, 0)^.Tag:= cWaterRise; |
325 AddGear(0, 0, gtWaterUp, 0, _0, _0, 0)^.Tag:= cWaterRise; |
313 inc(step) |
326 inc(step) |
323 stHealth: |
336 stHealth: |
324 begin |
337 begin |
325 if (cWaterRise <> 0) or (cHealthDecrease <> 0) then |
338 if (cWaterRise <> 0) or (cHealthDecrease <> 0) then |
326 begin |
339 begin |
327 if (TotalRounds = cSuddenDTurns) and (not SuddenDeath) and (not isInMultiShoot) then |
340 if (TotalRounds = cSuddenDTurns) and (not SuddenDeath) and (not isInMultiShoot) then |
328 begin |
341 StartSuddenDeath() |
329 SuddenDeath:= true; |
|
330 if cHealthDecrease <> 0 then |
|
331 begin |
|
332 SuddenDeathDmg:= true; |
|
333 |
|
334 // flash |
|
335 ScreenFade:= sfFromWhite; |
|
336 ScreenFadeValue:= sfMax; |
|
337 ScreenFadeSpeed:= 1; |
|
338 |
|
339 ChangeToSDClouds; |
|
340 ChangeToSDFlakes; |
|
341 SetSkyColor(SDSkyColor.r * (SDTint.r/255) / 255, SDSkyColor.g * (SDTint.r/255) / 255, SDSkyColor.b * (SDTint.b/255) / 255); |
|
342 Ammoz[amTardis].SkipTurns:= 9999; |
|
343 Ammoz[amTardis].Probability:= 0; |
|
344 end; |
|
345 AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState); |
|
346 ScriptCall('onSuddenDeath'); |
|
347 playSound(sndSuddenDeath); |
|
348 StopMusic; |
|
349 if SDMusicFN <> '' then PlayMusic |
|
350 end |
|
351 else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then |
342 else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then |
352 begin |
343 begin |
353 i:= cSuddenDTurns - TotalRounds; |
344 i:= cSuddenDTurns - TotalRounds; |
354 s:= ansistring(inttostr(i)); |
345 s:= ansistring(inttostr(i)); |
355 if i = 1 then |
346 if i = 1 then |
526 begin |
517 begin |
527 cLaserSighting:= false; |
518 cLaserSighting:= false; |
528 cLaserSightingSniper:= false |
519 cLaserSightingSniper:= false |
529 end; |
520 end; |
530 |
521 |
531 if (GameFlags and gfArtillery) = 0 then |
|
532 cArtillery:= false; |
|
533 // have to sweep *all* current team hedgehogs since it is theoretically possible if you have enough invulnerabilities and switch turns to make your entire team invulnerable |
522 // have to sweep *all* current team hedgehogs since it is theoretically possible if you have enough invulnerabilities and switch turns to make your entire team invulnerable |
534 if (CurrentTeam <> nil) then |
523 if (CurrentTeam <> nil) then |
535 with CurrentTeam^ do |
524 with CurrentTeam^ do |
536 for i:= 0 to cMaxHHIndex do |
525 for i:= 0 to cMaxHHIndex do |
537 with Hedgehogs[i] do |
526 with Hedgehogs[i] do |
546 |
535 |
547 if (Gear <> nil) then |
536 if (Gear <> nil) then |
548 begin |
537 begin |
549 if (GameFlags and gfInvulnerable) = 0 then |
538 if (GameFlags and gfInvulnerable) = 0 then |
550 Gear^.Hedgehog^.Effects[heInvulnerable]:= 0; |
539 Gear^.Hedgehog^.Effects[heInvulnerable]:= 0; |
|
540 if (Gear^.Hedgehog^.Effects[heArtillery] = 2) then |
|
541 Gear^.Hedgehog^.Effects[heArtillery]:= 0; |
551 end; |
542 end; |
552 end; |
543 end; |
553 t:= GearsList; |
544 t:= GearsList; |
554 while t <> nil do |
545 while t <> nil do |
555 begin |
546 begin |
556 t^.PortalCounter:= 0; |
547 t^.PortalCounter:= 0; |
557 if ((GameFlags and gfResetHealth) <> 0) and (t^.Kind = gtHedgehog) and (t^.Health < t^.Hedgehog^.InitialHealth) then |
548 if ((GameFlags and gfResetHealth) <> 0) and (t^.Kind = gtHedgehog) and (t^.Health < t^.Hedgehog^.InitialHealth) then |
558 begin |
549 begin |
|
550 i:= t^.Hedgehog^.InitialHealth - t^.Health; |
559 t^.Health:= t^.Hedgehog^.InitialHealth; |
551 t^.Health:= t^.Hedgehog^.InitialHealth; |
|
552 if i > 0 then |
|
553 HHHeal(t^.Hedgehog, i, false, $00FF0040); |
560 RenderHealth(t^.Hedgehog^); |
554 RenderHealth(t^.Hedgehog^); |
561 end; |
555 end; |
562 t:= t^.NextGear |
556 t:= t^.NextGear |
563 end; |
557 end; |
564 |
558 |
743 Effects[heInvulnerable]:= 1; |
737 Effects[heInvulnerable]:= 1; |
744 |
738 |
745 if (GameFlags and gfLaserSight) <> 0 then |
739 if (GameFlags and gfLaserSight) <> 0 then |
746 cLaserSighting:= true; |
740 cLaserSighting:= true; |
747 |
741 |
748 if (GameFlags and gfArtillery) <> 0 then |
|
749 cArtillery:= true; |
|
750 for i:= (LAND_WIDTH*LAND_HEIGHT) div 524288+2 downto 0 do |
742 for i:= (LAND_WIDTH*LAND_HEIGHT) div 524288+2 downto 0 do |
751 begin |
743 begin |
752 rx:= GetRandom(rightX-leftX)+leftX; |
744 rx:= GetRandom(rightX-leftX)+leftX; |
753 ry:= GetRandom(LAND_HEIGHT-topY)+topY; |
745 ry:= GetRandom(LAND_HEIGHT-topY)+topY; |
754 rdx:= _90-(GetRandomf*_360); |
746 rdx:= _90-(GetRandomf*_360); |
755 rdy:= _90-(GetRandomf*_360); |
747 rdy:= _90-(GetRandomf*_360); |
756 AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, $FFFFFFFF); |
748 Gear:= AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, $FFFFFFFF); |
|
749 // Tag=1: This allows this generic faller to be displaced randomly by events |
|
750 Gear^.Tag:= 1; |
757 end; |
751 end; |
758 |
752 |
759 snowRight:= max(LAND_WIDTH,4096)+512; |
753 snowRight:= max(LAND_WIDTH,4096)+512; |
760 snowLeft:= -(snowRight-LAND_WIDTH); |
754 snowLeft:= -(snowRight-LAND_WIDTH); |
761 |
755 |
1055 FindPlace(FollowGear, true, 0, LAND_WIDTH); |
1049 FindPlace(FollowGear, true, 0, LAND_WIDTH); |
1056 |
1050 |
1057 SpawnFakeCrateAt := FollowGear; |
1051 SpawnFakeCrateAt := FollowGear; |
1058 end; |
1052 end; |
1059 |
1053 |
|
1054 procedure StartSuddenDeath(); |
|
1055 begin |
|
1056 if SuddenDeath then |
|
1057 exit; |
|
1058 |
|
1059 SuddenDeath:= true; |
|
1060 SuddenDeathActive:= true; |
|
1061 |
|
1062 // Special effects (only w/ health decrease) |
|
1063 if cHealthDecrease <> 0 then |
|
1064 begin |
|
1065 SuddenDeathDmg:= true; |
|
1066 // White screen flash |
|
1067 ScreenFade:= sfFromWhite; |
|
1068 ScreenFadeValue:= sfMax; |
|
1069 ScreenFadeSpeed:= 1; |
|
1070 |
|
1071 // Clouds, flakes, sky tint |
|
1072 ChangeToSDClouds; |
|
1073 ChangeToSDFlakes; |
|
1074 SetSkyColor(SDSkyColor.r * (SDTint.r/255) / 255, SDSkyColor.g * (SDTint.g/255) / 255, SDSkyColor.b * (SDTint.b/255) / 255); |
|
1075 end; |
|
1076 |
|
1077 // Disable tardis |
|
1078 Ammoz[amTardis].SkipTurns:= 9999; |
|
1079 Ammoz[amTardis].Probability:= 0; |
|
1080 |
|
1081 AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState); |
|
1082 ScriptCall('onSuddenDeath'); |
|
1083 playSound(sndSuddenDeath); |
|
1084 StopMusic; |
|
1085 if SDMusicFN <> '' then |
|
1086 PlayMusic |
|
1087 end; |
1060 |
1088 |
1061 function GearByUID(uid : Longword) : PGear; |
1089 function GearByUID(uid : Longword) : PGear; |
1062 var gear: PGear; |
1090 var gear: PGear; |
1063 begin |
1091 begin |
1064 GearByUID:= nil; |
1092 GearByUID:= nil; |
1248 @doStepTardis, |
1277 @doStepTardis, |
1249 @doStepIceGun, |
1278 @doStepIceGun, |
1250 @doStepAddAmmo, |
1279 @doStepAddAmmo, |
1251 @doStepGenericFaller, |
1280 @doStepGenericFaller, |
1252 @doStepKnife, |
1281 @doStepKnife, |
1253 @doStepDuck); |
1282 @doStepDuck, |
|
1283 @doStepMinigun, |
|
1284 @doStepMinigunBullet); |
1254 begin |
1285 begin |
1255 doStepHandlers:= handlers; |
1286 doStepHandlers:= handlers; |
1256 |
1287 |
1257 RegisterVariable('skip', @chSkip, false); |
1288 RegisterVariable('skip', @chSkip, false); |
1258 RegisterVariable('hogsay', @chHogSay, true ); |
1289 RegisterVariable('hogsay', @chHogSay, true ); |