35 interface |
35 interface |
36 uses SDLh, uConsts, uFloat, uTypes; |
36 uses SDLh, uConsts, uFloat, uTypes; |
37 |
37 |
38 procedure initModule; |
38 procedure initModule; |
39 procedure freeModule; |
39 procedure freeModule; |
40 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword ): PGear; |
40 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content, cnt: Longword): PGear; |
41 function SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean ): PGear; |
41 function SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean ): PGear; |
42 function GetAmmo(Hedgehog: PHedgehog): TAmmoType; |
42 function GetAmmo(Hedgehog: PHedgehog): TAmmoType; |
43 function GetUtility(Hedgehog: PHedgehog): TAmmoType; |
43 function GetUtility(Hedgehog: PHedgehog): TAmmoType; |
44 procedure HideHog(HH: PHedgehog); |
44 procedure HideHog(HH: PHedgehog); |
45 procedure RestoreHog(HH: PHedgehog); |
45 procedure RestoreHog(HH: PHedgehog); |
57 |
57 |
58 implementation |
58 implementation |
59 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, |
59 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, |
60 uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables, |
60 uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables, |
61 uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture, |
61 uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture, |
62 uGearsHedgehog, uGearsUtils, uGearsList; |
62 uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlers; |
63 |
63 |
64 var skipFlag: boolean; |
64 var skipFlag: boolean; |
65 |
65 |
66 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward; |
66 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward; |
67 //procedure AmmoFlameWork(Ammo: PGear); forward; |
67 //procedure AmmoFlameWork(Ammo: PGear); forward; |
68 function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray; forward; |
68 function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS; forward; |
69 procedure SpawnBoxOfSmth; forward; |
69 procedure SpawnBoxOfSmth; forward; |
70 procedure ShotgunShot(Gear: PGear); forward; |
70 procedure ShotgunShot(Gear: PGear); forward; |
71 procedure doStepCase(Gear: PGear); forward; |
71 procedure doStepCase(Gear: PGear); forward; |
72 |
72 |
73 |
73 |
201 dec(StepSoundTimer, 1); |
201 dec(StepSoundTimer, 1); |
202 |
202 |
203 t:= GearsList; |
203 t:= GearsList; |
204 while t <> nil do |
204 while t <> nil do |
205 begin |
205 begin |
206 Gear:= t; |
206 curHandledGear:= t; |
207 t:= Gear^.NextGear; |
207 t:= curHandledGear^.NextGear; |
208 |
208 |
209 if Gear^.Active then |
209 if curHandledGear^.Message and gmRemoveFromList <> 0 then |
210 begin |
210 begin |
211 if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then |
211 RemoveGearFromList(curHandledGear); |
212 begin |
212 // 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 |
213 FreeTexture(Gear^.Tex); |
213 if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear); |
214 Gear^.Tex:= RenderStringTex(inttostr(Gear^.Timer div 1000), cWhiteColor, fntSmall); |
214 curHandledGear^.Message:= curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList)) |
215 end; |
215 end; |
216 Gear^.doStep(Gear); |
216 if curHandledGear^.Active then |
|
217 begin |
|
218 if curHandledGear^.RenderTimer and (curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0) then |
|
219 begin |
|
220 FreeTexture(curHandledGear^.Tex); |
|
221 curHandledGear^.Tex:= RenderStringTex(inttostr(curHandledGear^.Timer div 1000), cWhiteColor, fntSmall); |
|
222 end; |
|
223 curHandledGear^.doStep(curHandledGear); |
217 // might be useful later |
224 // might be useful later |
218 //ScriptCall('onGearStep', Gear^.uid); |
225 //ScriptCall('onGearStep', Gear^.uid); |
219 end |
226 end |
220 end; |
227 end; |
|
228 curHandledGear:= nil; |
221 |
229 |
222 if AllInactive then |
230 if AllInactive then |
223 case step of |
231 case step of |
224 stDelay: |
232 stDelay: |
225 begin |
233 begin |
623 if (GameFlags and gfLaserSight) <> 0 then |
632 if (GameFlags and gfLaserSight) <> 0 then |
624 cLaserSighting:= true; |
633 cLaserSighting:= true; |
625 |
634 |
626 if (GameFlags and gfArtillery) <> 0 then |
635 if (GameFlags and gfArtillery) <> 0 then |
627 cArtillery:= true; |
636 cArtillery:= true; |
|
637 for i:= GetRandom(10)+30 downto 0 do |
|
638 begin rx:= GetRandom(rightX-leftX)+leftX; |
|
639 ry:= GetRandom(LAND_HEIGHT-topY)+topY; |
|
640 rdx:= _90-(GetRandomf*_360); |
|
641 rdy:= _90-(GetRandomf*_360); |
|
642 AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, $FFFFFFFF); |
|
643 end; |
628 |
644 |
629 if not hasBorder and ((Theme = 'Snow') or (Theme = 'Christmas')) then |
645 if not hasBorder and ((Theme = 'Snow') or (Theme = 'Christmas')) then |
630 for i:= 0 to Pred(vobCount*2) do |
646 for i:= 0 to Pred(vobCount*2) do |
631 AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(LAND_HEIGHT div 2), gtFlake, 0, _0, _0, 0); |
647 AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(LAND_HEIGHT div 2), gtFlake, 0, _0, _0, 0); |
632 end; |
648 end; |
869 dec(Count) |
885 dec(Count) |
870 end |
886 end |
871 end |
887 end |
872 end; |
888 end; |
873 |
889 |
874 function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray; |
890 var GearsNearArray : TPGearArray; |
|
891 function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS; |
875 var |
892 var |
876 t: PGear; |
893 t: PGear; |
877 l: Longword; |
894 s: Longword; |
878 begin |
895 begin |
879 r:= r*r; |
896 r:= r*r; |
880 GearsNear := nil; |
897 s:= 0; |
|
898 SetLength(GearsNearArray, s); |
881 t := GearsList; |
899 t := GearsList; |
882 while t <> nil do |
900 while t <> nil do |
883 begin |
901 begin |
884 if (t^.Kind = Kind) |
902 if (t^.Kind = Kind) |
885 and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then |
903 and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then |
886 begin |
904 begin |
887 l:= Length(GearsNear); |
905 inc(s); |
888 SetLength(GearsNear, l + 1); |
906 SetLength(GearsNearArray, s); |
889 GearsNear[l] := t; |
907 GearsNearArray[s - 1] := t; |
890 end; |
908 end; |
891 t := t^.NextGear; |
909 t := t^.NextGear; |
892 end; |
910 end; |
|
911 |
|
912 GearsNear.size:= s; |
|
913 GearsNear.ar:= @GearsNearArray |
893 end; |
914 end; |
894 |
915 |
895 {procedure AmmoFlameWork(Ammo: PGear); |
916 {procedure AmmoFlameWork(Ammo: PGear); |
896 var t: PGear; |
917 var t: PGear; |
897 begin |
918 begin |
926 t:= t^.NextGear |
947 t:= t^.NextGear |
927 end; |
948 end; |
928 CountGears:= count; |
949 CountGears:= count; |
929 end; |
950 end; |
930 |
951 |
931 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword): PGear; |
952 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content, cnt: Longword): PGear; |
932 begin |
953 begin |
933 FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0); |
954 FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0); |
934 cCaseFactor := 0; |
955 cCaseFactor := 0; |
935 |
956 |
936 if (crate <> HealthCrate) and (content > ord(High(TAmmoType))) then |
957 if (crate <> HealthCrate) and (content > ord(High(TAmmoType))) then |
937 content := ord(High(TAmmoType)); |
958 content := ord(High(TAmmoType)); |
|
959 |
|
960 FollowGear^.Power:= cnt; |
938 |
961 |
939 case crate of |
962 case crate of |
940 HealthCrate: |
963 HealthCrate: |
941 begin |
964 begin |
942 FollowGear^.Pos := posCaseHealth; |
965 FollowGear^.Pos := posCaseHealth; |
1304 @doStepSnowball, |
1327 @doStepSnowball, |
1305 @doStepSnowflake, |
1328 @doStepSnowflake, |
1306 @doStepStructure, |
1329 @doStepStructure, |
1307 @doStepLandGun, |
1330 @doStepLandGun, |
1308 @doStepTardis, |
1331 @doStepTardis, |
1309 @doStepIceGun); |
1332 @doStepIceGun, |
|
1333 @doStepAddAmmo, |
|
1334 @doStepGenericFaller); |
1310 begin |
1335 begin |
1311 doStepHandlers:= handlers; |
1336 doStepHandlers:= handlers; |
1312 |
1337 |
1313 RegisterVariable('skip', @chSkip, false); |
1338 RegisterVariable('skip', @chSkip, false); |
1314 RegisterVariable('hogsay', @chHogSay, true ); |
1339 RegisterVariable('hogsay', @chHogSay, true ); |
1315 |
1340 |
1316 CurAmmoGear:= nil; |
1341 CurAmmoGear:= nil; |
1317 GearsList:= nil; |
1342 GearsList:= nil; |
|
1343 curHandledGear:= nil; |
|
1344 |
1318 KilledHHs:= 0; |
1345 KilledHHs:= 0; |
1319 SuddenDeath:= false; |
1346 SuddenDeath:= false; |
1320 SuddenDeathDmg:= false; |
1347 SuddenDeathDmg:= false; |
1321 SpeechType:= 1; |
1348 SpeechType:= 1; |
1322 skipFlag:= false; |
1349 skipFlag:= false; |