1224 HedgehogChAngle(HHGear); |
1224 HedgehogChAngle(HHGear); |
1225 |
1225 |
1226 b := false; |
1226 b := false; |
1227 |
1227 |
1228 if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
1228 if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
1229 begin |
1229 begin |
1230 Gear^.dX := SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); |
1230 Gear^.dX := SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); |
1231 Gear^.dY := AngleCos(HHGear^.Angle) * ( - _0_5); |
1231 Gear^.dY := AngleCos(HHGear^.Angle) * ( - _0_5); |
1232 BTPrevAngle := HHGear^.Angle; |
1232 BTPrevAngle := HHGear^.Angle; |
1233 b := true |
1233 b := true |
1234 end; |
1234 end; |
1235 |
1235 |
1236 if ((HHGear^.State and gstMoving) <> 0) then |
1236 if ((HHGear^.State and gstMoving) <> 0) then |
1237 begin |
1237 begin |
1238 doStepHedgehogMoving(HHGear); |
1238 doStepHedgehogMoving(HHGear); |
1239 if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer := 0 |
1239 if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer := 0 |
1240 end; |
1240 end; |
1241 |
1241 |
1242 if Gear^.Timer mod cHHStepTicks = 0 then |
1242 if Gear^.Timer mod cHHStepTicks = 0 then |
1243 begin |
1243 begin |
1244 b := true; |
1244 b := true; |
1245 if Gear^.dX.isNegative then |
1245 if Gear^.dX.isNegative then |
1246 HHGear^.Message := (HHGear^.Message and (gmAttack or gmUp or gmDown)) or gmLeft |
1246 HHGear^.Message := (HHGear^.Message and (gmAttack or gmUp or gmDown)) or gmLeft |
1247 else |
1247 else |
1248 HHGear^.Message := (HHGear^.Message and (gmAttack or gmUp or gmDown)) or gmRight; |
1248 HHGear^.Message := (HHGear^.Message and (gmAttack or gmUp or gmDown)) or gmRight; |
1249 |
1249 |
1250 if ((HHGear^.State and gstMoving) = 0) then |
1250 if ((HHGear^.State and gstMoving) = 0) then |
1251 begin |
1251 begin |
1252 HHGear^.State := HHGear^.State and not gstAttacking; |
1252 HHGear^.State := HHGear^.State and not gstAttacking; |
1253 prevX := hwRound(HHGear^.X); |
1253 prevX := hwRound(HHGear^.X); |
1254 |
1254 |
1255 // why the call to HedgehogStep then a further increment of X? |
1255 // why the call to HedgehogStep then a further increment of X? |
1256 if (prevX = hwRound(HHGear^.X)) and |
1256 if (prevX = hwRound(HHGear^.X)) and |
1259 |
1259 |
1260 if (prevX = hwRound(HHGear^.X)) and |
1260 if (prevX = hwRound(HHGear^.X)) and |
1261 CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), |
1261 CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), |
1262 lfIndestructible) then HHGear^.X := HHGear^.X + SignAs(_1, HHGear^.dX); |
1262 lfIndestructible) then HHGear^.X := HHGear^.X + SignAs(_1, HHGear^.dX); |
1263 HHGear^.State := HHGear^.State or gstAttacking |
1263 HHGear^.State := HHGear^.State or gstAttacking |
1264 end; |
1264 end; |
1265 |
1265 |
1266 inc(BTSteps); |
1266 inc(BTSteps); |
1267 if BTSteps = 7 then |
1267 if BTSteps = 7 then |
1268 begin |
1268 begin |
1269 BTSteps := 0; |
1269 BTSteps := 0; |
1270 if CheckLandValue(hwRound(HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC) + SignAs(_6, |
1270 if CheckLandValue(hwRound(HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC) + SignAs(_6, |
1271 Gear^.dX)), hwRound(HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC)), |
1271 Gear^.dX)), hwRound(HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC)), |
1272 lfIndestructible) then |
1272 lfIndestructible) then |
1273 begin |
1273 begin |
1274 Gear^.X := HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); |
1274 Gear^.X := HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); |
1275 Gear^.Y := HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); |
1275 Gear^.Y := HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); |
1276 end; |
1276 end; |
1277 HHGear^.State := HHGear^.State or gstNoDamage; |
1277 HHGear^.State := HHGear^.State or gstNoDamage; |
1278 AmmoShove(Gear, 2, 15); |
1278 AmmoShove(Gear, 2, 15); |
1279 HHGear^.State := HHGear^.State and not gstNoDamage |
1279 HHGear^.State := HHGear^.State and not gstNoDamage |
1280 end; |
1280 end; |
1281 end; |
1281 end; |
1282 |
1282 |
1283 if b then |
1283 if b then |
1284 DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs( |
1284 DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs( |
1285 Gear^.dY) * 7, |
1285 Gear^.dY) * 7, |
1286 Gear^.dX, Gear^.dY, |
1286 Gear^.dX, Gear^.dY, |
1287 cHHRadius * 5, cHHRadius * 2 + 7); |
1287 cHHRadius * 5, cHHRadius * 2 + 7); |
1288 |
1288 |
1289 if (Gear^.Timer = 0) or ((HHGear^.Message and gmAttack) <> 0) then |
1289 if (Gear^.Timer = 0) or ((HHGear^.Message and gmAttack) <> 0) then |
1290 begin |
1290 begin |
1291 HHGear^.Message := 0; |
1291 HHGear^.Message := 0; |
1292 HHGear^.State := HHGear^.State and (not gstNotKickable); |
1292 HHGear^.State := HHGear^.State and (not gstNotKickable); |
1293 DeleteGear(Gear); |
1293 DeleteGear(Gear); |
1294 AfterAttack |
1294 AfterAttack |
1295 end |
1295 end |
1296 end; |
1296 end; |
1297 |
1297 |
1298 procedure doStepBlowTorch(Gear: PGear); |
1298 procedure doStepBlowTorch(Gear: PGear); |
1299 var |
1299 var |
1300 HHGear: PGear; |
1300 HHGear: PGear; |
4900 doMakeExplosion(x, y, 50, CurrentHedgehog, EXPLAutoSound); |
4898 doMakeExplosion(x, y, 50, CurrentHedgehog, EXPLAutoSound); |
4901 end; |
4899 end; |
4902 end; |
4900 end; |
4903 |
4901 |
4904 //////////////////////////////////////////////////////////////////////////////// |
4902 //////////////////////////////////////////////////////////////////////////////// |
|
4903 (* |
|
4904 TARDIS needs |
|
4905 Warp in. Pos = 1 |
|
4906 Pause. Pos = 2 |
|
4907 Hide gear (TARDIS hedgehog was nil) |
|
4908 Warp out. Pos = 3 |
|
4909 ... idle active for some time period ... Pos = 4 |
|
4910 Warp in. Pos = 1 |
|
4911 Pause. Pos = 2 |
|
4912 Restore gear (TARDIS hedgehog was not nil) |
|
4913 Warp out. Pos = 3 |
|
4914 *) |
|
4915 |
|
4916 procedure doStepTardisWarp(Gear: PGear); |
|
4917 var HH: PHedgehog; |
|
4918 i,j,cnt: LongWord; |
|
4919 begin |
|
4920 |
|
4921 HH:= Gear^.Hedgehog; |
|
4922 if Gear^.Pos = 2 then |
|
4923 begin |
|
4924 if (Gear^.Timer = 0) then |
|
4925 begin |
|
4926 if HH^.Gear <> nil then |
|
4927 begin |
|
4928 if Gear = CurAmmoGear then CurAmmoGear := nil; |
|
4929 DeleteCI(HH^.Gear); |
|
4930 RemoveGearFromList(HH^.Gear); |
|
4931 HH^.Gear^.Z := cHHZ; |
|
4932 HH^.Gear^.Active := false; |
|
4933 HH^.Gear^.State:= HH^.Gear^.State and not (gstHHDriven or gstAttacking); |
|
4934 HH^.GearHidden:= HH^.Gear; |
|
4935 HH^.Gear:= nil |
|
4936 end |
|
4937 else if HH^.GearHidden <> nil then |
|
4938 begin |
|
4939 HH^.Gear:= HH^.GearHidden; |
|
4940 HH^.GearHidden:= nil; |
|
4941 InsertGearToList(HH^.Gear); |
|
4942 HH^.Gear^.State:= (HH^.Gear^.State or gstAttacked) and not gstHHDriven; |
|
4943 AddGearCI(HH^.Gear); |
|
4944 HH^.Gear^.Active:= true |
|
4945 end; |
|
4946 end; |
|
4947 |
|
4948 inc(Gear^.Timer); |
|
4949 if (Gear^.Timer > 2000) and ((GameTicks mod 2000) = 1000) then |
|
4950 begin |
|
4951 Gear^.Pos:= 3; |
|
4952 end; |
|
4953 end; |
|
4954 |
|
4955 if (Gear^.Pos = 1) and (GameTicks and $1F = 0) and (Gear^.Power < 255) then inc(Gear^.Power); |
|
4956 if (Gear^.Pos = 3) and (GameTicks and $1F = 0) and (Gear^.Power > 0) then dec(Gear^.Power); |
|
4957 if (Gear^.Pos = 1) and (Gear^.Power = 255) and ((GameTicks mod 2000) = 1000) then Gear^.Pos:= 2; |
|
4958 if (Gear^.Pos = 3) and (Gear^.Power = 0) then |
|
4959 begin |
|
4960 Gear^.Pos:= 4; |
|
4961 // This condition might need tweaking |
|
4962 Gear^.Timer:= GetRandom(cHedgehogTurnTime*TeamsCount)+cHedgehogTurnTime |
|
4963 end; |
|
4964 |
|
4965 if (Gear^.Pos = 4) then |
|
4966 begin |
|
4967 cnt:= 0; |
|
4968 for j:= 0 to Pred(HH^.Team^.Clan^.TeamsNumber) do |
|
4969 for i:= 0 to Pred(HH^.Team^.Clan^.Teams[j]^.HedgehogsNumber) do |
|
4970 if (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear <> nil) and |
|
4971 ((HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.State and gstDrowning) = 0) and |
|
4972 (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Health > |
|
4973 HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Damage) then inc(cnt); |
|
4974 if (cnt = 0) or SuddenDeathDmg or (Gear^.Timer = 0) then |
|
4975 begin |
|
4976 Gear^.Pos:= 1; |
|
4977 Gear^.Power:= 0; |
|
4978 Gear^.Timer:= 0; |
|
4979 FindPlace(HH^.GearHidden, false, 0, LAND_WIDTH,true); |
|
4980 if HH^.GearHidden <> nil then |
|
4981 begin |
|
4982 Gear^.X:= HH^.GearHidden^.X; |
|
4983 Gear^.Y:= HH^.GearHidden^.Y; |
|
4984 end |
|
4985 end |
|
4986 else dec(Gear^.Timer); |
|
4987 end; |
|
4988 |
|
4989 end; |
|
4990 |
4905 procedure doStepTardis(Gear: PGear); |
4991 procedure doStepTardis(Gear: PGear); |
4906 (*var |
4992 var i,j,cnt: LongWord; |
4907 i, x, y: LongInt; |
4993 HH: PHedgehog; |
4908 dX, dY: hwFloat; |
4994 begin |
4909 Fire: PGear; |
4995 (* |
4910 vg: PVisualGear;*) |
4996 Conditions for not activating. |
4911 begin |
4997 1. Hog is last of his clan |
4912 if (Gear^.State and gstTmpFlag) = 0 then dec(Gear^.Timer); |
4998 2. Sudden Death is in play |
4913 if (Gear^.Timer = 0) and (CurAmmoGear = Gear) then |
4999 3. Hog is a king |
4914 begin |
5000 *) |
4915 if (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then |
5001 HH:= Gear^.Hedgehog; |
4916 begin |
5002 if (HH^.Gear = nil) or (HH^.King) or (SuddenDeathDmg) then |
4917 DeleteGear(Gear); |
5003 begin |
4918 exit |
5004 DeleteGear(gear); |
4919 end; |
5005 exit |
4920 if Gear = CurAmmoGear then CurAmmoGear := nil; |
5006 end; |
4921 Gear^.Hedgehog:= CurrentHedgehog; |
5007 cnt:= 0; |
4922 RemoveGearFromList(CurrentHedgehog^.Gear); |
5008 for j:= 0 to Pred(HH^.Team^.Clan^.TeamsNumber) do |
4923 CurrentHedgehog^.Gear^.Z := cHHZ; |
5009 for i:= 0 to Pred(HH^.Team^.Clan^.Teams[j]^.HedgehogsNumber) do |
4924 CurrentHedgehog^.Gear^.Active := false; |
5010 if (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear <> nil) and |
4925 CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and not gstHHDriven; |
5011 ((HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.State and gstDrowning) = 0) and |
4926 CurrentHedgehog^.GearHidden:= CurrentHedgehog^.Gear; |
5012 (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Health > |
4927 CurrentHedgehog^.Gear:= nil; |
5013 HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Damage) then inc(cnt); |
4928 Gear^.State:= Gear^.State or gstTmpFlag; |
5014 if cnt < 2 then |
4929 Gear^.Timer:= GameTicks + GetRandom(cHedgehogTurnTime*TeamsCount)+cHedgehogTurnTime; |
5015 begin |
4930 end |
5016 DeleteGear(gear); |
4931 else if (((Gear^.State and gstTmpFlag) <> 0) and (Gear^.Timer = GameTicks)) or SuddenDeath then |
5017 exit |
4932 begin |
5018 end; |
4933 if Gear^.Hedgehog <> nil then |
5019 with HH^.Gear^ do |
4934 begin |
5020 begin |
4935 Gear^.Hedgehog^.Gear:= Gear^.Hedgehog^.GearHidden; |
5021 Message := Message and not gmAttack |
4936 Gear^.Hedgehog^.GearHidden:= nil; |
5022 end; |
4937 FindPlace(Gear^.Hedgehog^.Gear, false, 0, LAND_WIDTH,true); |
5023 Gear^.doStep:= @doStepTardisWarp |
4938 InsertGearToList(Gear^.Hedgehog^.Gear); |
5024 end; |
4939 Gear^.Hedgehog^.Gear^.State:= (Gear^.Hedgehog^.Gear^.State or gstTmpFlag or gstAttacked) and not gstHHDriven; |
5025 |
4940 Gear^.Hedgehog^.Gear^.Timer:= $FF; |
5026 //////////////////////////////////////////////////////////////////////////////// |
4941 Gear^.Hedgehog^.Gear^.doStep:= @doStepHedgehogReturn; |
5027 |
4942 SetAllHHToActive; |
|
4943 end; |
|
4944 DeleteGear(Gear) |
|
4945 end |
|
4946 end; |
|
4947 |
|
4948 //////////////////////////////////////////////////////////////////////////////// |
|
4949 |
|