54 function GearByUID(uid : Longword) : PGear; |
54 function GearByUID(uid : Longword) : PGear; |
55 procedure doStepDrowningGear(Gear: PGear); |
55 procedure doStepDrowningGear(Gear: PGear); |
56 |
56 |
57 implementation |
57 implementation |
58 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, |
58 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, |
59 uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables, |
59 uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uVariables, |
60 uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture, |
60 uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture, |
61 uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlers, uGearsHandlersRope; |
61 uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlers, uGearsHandlersRope; |
62 |
62 |
63 var skipFlag: boolean; |
63 var skipFlag: boolean; |
64 |
64 |
170 inc(tmp, 5); |
170 inc(tmp, 5); |
171 if (GameFlags and gfResetHealth) <> 0 then |
171 if (GameFlags and gfResetHealth) <> 0 then |
172 dec(Gear^.Hedgehog^.InitialHealth, 5) |
172 dec(Gear^.Hedgehog^.InitialHealth, 5) |
173 end |
173 end |
174 end; |
174 end; |
175 if tmp > 0 then |
175 if tmp > 0 then |
176 begin |
176 begin |
177 inc(Gear^.Damage, min(tmp, max(0,Gear^.Health - 1 - Gear^.Damage))); |
177 inc(Gear^.Damage, min(tmp, max(0,Gear^.Health - 1 - Gear^.Damage))); |
178 HHHurt(Gear^.Hedgehog, dsPoison); |
178 HHHurt(Gear^.Hedgehog, dsPoison); |
179 end |
179 end |
180 end; |
180 end; |
210 |
210 |
211 if curHandledGear^.Message and gmDelete <> 0 then |
211 if curHandledGear^.Message and gmDelete <> 0 then |
212 DeleteGear(curHandledGear) |
212 DeleteGear(curHandledGear) |
213 else |
213 else |
214 begin |
214 begin |
215 if curHandledGear^.Message and gmRemoveFromList <> 0 then |
215 if curHandledGear^.Message and gmRemoveFromList <> 0 then |
216 begin |
216 begin |
217 RemoveGearFromList(curHandledGear); |
217 RemoveGearFromList(curHandledGear); |
218 // since I can't think of any good reason this would ever be separate from a remove from list, going to keep it inside this block |
218 // since I can't think of any good reason this would ever be separate from a remove from list, going to keep it inside this block |
219 if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear); |
219 if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear); |
220 curHandledGear^.Message:= (curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList))) |
220 curHandledGear^.Message:= (curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList))) |
313 begin |
313 begin |
314 SuddenDeath:= true; |
314 SuddenDeath:= true; |
315 if cHealthDecrease <> 0 then |
315 if cHealthDecrease <> 0 then |
316 begin |
316 begin |
317 SuddenDeathDmg:= true; |
317 SuddenDeathDmg:= true; |
318 |
318 |
319 // flash |
319 // flash |
320 ScreenFade:= sfFromWhite; |
320 ScreenFade:= sfFromWhite; |
321 ScreenFadeValue:= sfMax; |
321 ScreenFadeValue:= sfMax; |
322 ScreenFadeSpeed:= 1; |
322 ScreenFadeSpeed:= 1; |
323 |
323 |
324 ChangeToSDClouds; |
324 ChangeToSDClouds; |
325 ChangeToSDFlakes; |
325 ChangeToSDFlakes; |
326 glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99); |
326 glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99); |
327 Ammoz[amTardis].SkipTurns:= 9999; |
327 Ammoz[amTardis].SkipTurns:= 9999; |
328 Ammoz[amTardis].Probability:= 0; |
328 Ammoz[amTardis].Probability:= 0; |
528 t^.Health:= t^.Hedgehog^.InitialHealth; |
528 t^.Health:= t^.Hedgehog^.InitialHealth; |
529 RenderHealth(t^.Hedgehog^); |
529 RenderHealth(t^.Hedgehog^); |
530 end; |
530 end; |
531 t:= t^.NextGear |
531 t:= t^.NextGear |
532 end; |
532 end; |
533 |
533 |
534 if ((GameFlags and gfResetWeps) <> 0) and (not PlacingHogs) then |
534 if ((GameFlags and gfResetWeps) <> 0) and (not PlacingHogs) then |
535 ResetWeapons; |
535 ResetWeapons; |
536 |
536 |
537 if (GameFlags and gfResetHealth) <> 0 then |
537 if (GameFlags and gfResetHealth) <> 0 then |
538 for i:= 0 to Pred(TeamsCount) do |
538 for i:= 0 to Pred(TeamsCount) do |
675 gtMine, |
675 gtMine, |
676 gtSMine, |
676 gtSMine, |
677 gtKnife, |
677 gtKnife, |
678 gtCase, |
678 gtCase, |
679 gtTarget, |
679 gtTarget, |
680 gtExplosives, |
680 gtExplosives: begin//, |
681 gtStructure: begin |
681 // gtStructure: begin |
682 //addFileLog('ShotgunShot radius: ' + inttostr(Gear^.Radius) + ', t^.Radius = ' + inttostr(t^.Radius) + ', distance = ' + inttostr(dist) + ', dmg = ' + inttostr(dmg)); |
682 //addFileLog('ShotgunShot radius: ' + inttostr(Gear^.Radius) + ', t^.Radius = ' + inttostr(t^.Radius) + ', distance = ' + inttostr(dist) + ', dmg = ' + inttostr(dmg)); |
683 dmg:= 0; |
683 dmg:= 0; |
684 r:= Gear^.Radius + t^.Radius; |
684 r:= Gear^.Radius + t^.Radius; |
685 dx:= Gear^.X-t^.X; |
685 dx:= Gear^.X-t^.X; |
686 dx.isNegative:= false; |
686 dx.isNegative:= false; |
758 Gear:= t^.ar[i]; |
758 Gear:= t^.ar[i]; |
759 tmpDmg:= ModifyDamage(Damage, Gear); |
759 tmpDmg:= ModifyDamage(Damage, Gear); |
760 if (Gear^.State and gstNoDamage) = 0 then |
760 if (Gear^.State and gstNoDamage) = 0 then |
761 begin |
761 begin |
762 |
762 |
763 if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then |
763 if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then |
764 begin |
764 begin |
765 VGear := AddVisualGear(hwround(Ammo^.X), hwround(Ammo^.Y), vgtBulletHit); |
765 VGear := AddVisualGear(hwround(Ammo^.X), hwround(Ammo^.Y), vgtBulletHit); |
766 if VGear <> nil then |
766 if VGear <> nil then |
767 VGear^.Angle := DxDy2Angle(-Ammo^.dX, Ammo^.dY); |
767 VGear^.Angle := DxDy2Angle(-Ammo^.dX, Ammo^.dY); |
768 end; |
768 end; |
808 end; |
808 end; |
809 ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove) |
809 ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove) |
810 end |
810 end |
811 else |
811 else |
812 Gear^.State:= Gear^.State or gstWinner; |
812 Gear^.State:= Gear^.State or gstWinner; |
813 if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then |
813 if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then |
814 begin |
814 begin |
815 if (Ammo^.Hedgehog^.Gear <> nil) then |
815 if (Ammo^.Hedgehog^.Gear <> nil) then |
816 Ammo^.Hedgehog^.Gear^.State:= (Ammo^.Hedgehog^.Gear^.State and (not gstNotKickable)); |
816 Ammo^.Hedgehog^.Gear^.State:= (Ammo^.Hedgehog^.Gear^.State and (not gstNotKickable)); |
817 ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch |
817 ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch |
818 end; |
818 end; |
904 begin |
904 begin |
905 ar[Count]:= @Hedgehogs[i]; |
905 ar[Count]:= @Hedgehogs[i]; |
906 inc(Count) |
906 inc(Count) |
907 end; |
907 end; |
908 end; |
908 end; |
909 // unC0Rr, while it is true user can watch value on map screen, IMO this (and check above) should be enforced in UI |
|
910 // - is there a good place to put values for the different widgets to check? Right now they are kind of disconnected. |
|
911 //it would be nice if divide teams, forts mode and hh per map could all be checked by the team widget, or maybe disable start button |
|
912 TryDo(Count <= MaxHedgehogs, 'Too many hedgehogs for this map! (max # is ' + inttostr(MaxHedgehogs) + ')', true); |
|
913 while (Count > 0) do |
909 while (Count > 0) do |
914 begin |
910 begin |
915 i:= GetRandom(Count); |
911 i:= GetRandom(Count); |
916 if PlacingHogs then |
912 if PlacingHogs then |
917 ar[i]^.Unplaced:= true |
913 ar[i]^.Unplaced:= true |
936 begin |
932 begin |
937 r:= r*r; |
933 r:= r*r; |
938 s:= 0; |
934 s:= 0; |
939 SetLength(GearsNearArray, s); |
935 SetLength(GearsNearArray, s); |
940 t := GearsList; |
936 t := GearsList; |
941 while t <> nil do |
937 while t <> nil do |
942 begin |
938 begin |
943 if (t^.Kind = Kind) |
939 if (t^.Kind = Kind) |
944 and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then |
940 and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then |
945 begin |
941 begin |
946 inc(s); |
942 inc(s); |
947 SetLength(GearsNearArray, s); |
943 SetLength(GearsNearArray, s); |
948 GearsNearArray[s - 1] := t; |
944 GearsNearArray[s - 1] := t; |
1030 function SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean): PGear; |
1026 function SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean): PGear; |
1031 begin |
1027 begin |
1032 FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0); |
1028 FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0); |
1033 cCaseFactor := 0; |
1029 cCaseFactor := 0; |
1034 FollowGear^.Pos := posCaseDummy; |
1030 FollowGear^.Pos := posCaseDummy; |
1035 |
1031 |
1036 if explode then |
1032 if explode then |
1037 FollowGear^.Pos := FollowGear^.Pos + posCaseExplode; |
1033 FollowGear^.Pos := FollowGear^.Pos + posCaseExplode; |
1038 if poison then |
1034 if poison then |
1039 FollowGear^.Pos := FollowGear^.Pos + posCasePoison; |
1035 FollowGear^.Pos := FollowGear^.Pos + posCasePoison; |
1040 |
1036 |
1269 if (x < 4) and (TeamsArray[t] <> nil) then |
1265 if (x < 4) and (TeamsArray[t] <> nil) then |
1270 begin |
1266 begin |
1271 // if team matches current hedgehog team, default to current hedgehog |
1267 // if team matches current hedgehog team, default to current hedgehog |
1272 if (i = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Team = TeamsArray[t]) then |
1268 if (i = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Team = TeamsArray[t]) then |
1273 hh:= CurrentHedgehog |
1269 hh:= CurrentHedgehog |
1274 else |
1270 else |
1275 begin |
1271 begin |
1276 // otherwise use the first living hog or the hog amongs the remaining ones indicated by i |
1272 // otherwise use the first living hog or the hog amongs the remaining ones indicated by i |
1277 j:= 0; |
1273 j:= 0; |
1278 c:= 0; |
1274 c:= 0; |
1279 while (j <= cMaxHHIndex) and (hh = nil) do |
1275 while (j <= cMaxHHIndex) and (hh = nil) do |