changeset 498 | 9c8b385dc9a1 |
parent 495 | 62c1c2b4414c |
child 503 | 2cfdc4bfc2be |
497:adf1aee202c6 | 498:9c8b385dc9a1 |
---|---|
163 inc(Counter); |
163 inc(Counter); |
164 {$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF} |
164 {$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF} |
165 New(Result); |
165 New(Result); |
166 {$IFDEF DEBUGFILE}AddFileLog('AddGear: type = ' + inttostr(ord(Kind)));{$ENDIF} |
166 {$IFDEF DEBUGFILE}AddFileLog('AddGear: type = ' + inttostr(ord(Kind)));{$ENDIF} |
167 FillChar(Result^, sizeof(TGear), 0); |
167 FillChar(Result^, sizeof(TGear), 0); |
168 Result^.X:= X; |
168 Result^.X:= int2hwFloat(X); |
169 Result^.Y:= Y; |
169 Result^.Y:= int2hwFloat(Y); |
170 Result^.Kind := Kind; |
170 Result^.Kind := Kind; |
171 Result^.State:= State; |
171 Result^.State:= State; |
172 Result^.Active:= true; |
172 Result^.Active:= true; |
173 Result^.dX:= dX; |
173 Result^.dX:= dX; |
174 Result^.dY:= dY; |
174 Result^.dY:= dY; |
214 gtPickHammer: begin |
214 gtPickHammer: begin |
215 Result^.Radius:= 10; |
215 Result^.Radius:= 10; |
216 Result^.Timer:= 4000 |
216 Result^.Timer:= 4000 |
217 end; |
217 end; |
218 gtSmokeTrace: begin |
218 gtSmokeTrace: begin |
219 Result^.X:= Result^.X - 16; |
219 Result^.X:= Result^.X - _16; |
220 Result^.Y:= Result^.Y - 16; |
220 Result^.Y:= Result^.Y - _16; |
221 Result^.State:= 8 |
221 Result^.State:= 8 |
222 end; |
222 end; |
223 gtRope: begin |
223 gtRope: begin |
224 Result^.Radius:= 3; |
224 Result^.Radius:= 3; |
225 Result^.Friction:= 450; |
225 Result^.Friction:= _450; |
226 RopePoints.Count:= 0; |
226 RopePoints.Count:= 0; |
227 end; |
227 end; |
228 gtExplosion: begin |
228 gtExplosion: begin |
229 Result^.X:= Result^.X - 25; |
229 Result^.X:= Result^.X - _25; |
230 Result^.Y:= Result^.Y - 25; |
230 Result^.Y:= Result^.Y - _25; |
231 end; |
231 end; |
232 gtMine: begin |
232 gtMine: begin |
233 Result^.Radius:= 3; |
233 Result^.Radius:= 3; |
234 Result^.Elasticity:= _0_55; |
234 Result^.Elasticity:= _0_55; |
235 Result^.Friction:= _0_995; |
235 Result^.Friction:= _0_995; |
238 gtCase: begin |
238 gtCase: begin |
239 Result^.Radius:= 16; |
239 Result^.Radius:= 16; |
240 Result^.Elasticity:= _0_4 |
240 Result^.Elasticity:= _0_4 |
241 end; |
241 end; |
242 gtDEagleShot: begin |
242 gtDEagleShot: begin |
243 Result^.Radius:= 1; |
|
244 Result^.Radius:= 1; |
243 Result^.Radius:= 1; |
245 Result^.Health:= 50 |
244 Result^.Health:= 50 |
246 end; |
245 end; |
247 gtDynamite: begin |
246 gtDynamite: begin |
248 Result^.Radius:= 3; |
247 Result^.Radius:= 3; |
290 Gear^.Message:= gm_Destroy; |
289 Gear^.Message:= gm_Destroy; |
291 CurAmmoGear^.Message:= gm_Destroy; |
290 CurAmmoGear^.Message:= gm_Destroy; |
292 exit |
291 exit |
293 end else |
292 end else |
294 begin |
293 begin |
295 if not (Gear^.Y < cWaterLine) then |
294 if not (hwRound(Gear^.Y) < cWaterLine) then |
296 begin |
295 begin |
297 t:= max(Gear^.Damage, Gear^.Health); |
296 t:= max(Gear^.Damage, Gear^.Health); |
298 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog; |
297 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
299 inc(StepDamage, t) |
298 inc(StepDamage, t) |
300 end; |
299 end; |
301 team:= PHedgehog(Gear^.Hedgehog)^.Team; |
300 team:= PHedgehog(Gear^.Hedgehog)^.Team; |
302 if CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = Gear then |
301 if CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = Gear then |
303 FreeActionsList; // to avoid ThinkThread on drawned gear |
302 FreeActionsList; // to avoid ThinkThread on drawned gear |
325 CheckNoDamage:= false; |
324 CheckNoDamage:= false; |
326 inc(StepDamage, Gear^.Damage); |
325 inc(StepDamage, Gear^.Damage); |
327 if Gear^.Health < Gear^.Damage then Gear^.Health:= 0 |
326 if Gear^.Health < Gear^.Damage then Gear^.Health:= 0 |
328 else dec(Gear^.Health, Gear^.Damage); |
327 else dec(Gear^.Health, Gear^.Damage); |
329 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12 - PHedgehog(Gear^.Hedgehog)^.HealthTag^.h, |
328 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12 - PHedgehog(Gear^.Hedgehog)^.HealthTag^.h, |
330 gtHealthTag, Gear^.Damage, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog; |
329 gtHealthTag, Gear^.Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
331 RenderHealth(PHedgehog(Gear^.Hedgehog)^); |
330 RenderHealth(PHedgehog(Gear^.Hedgehog)^); |
332 RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); |
331 RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); |
333 |
332 |
334 Gear^.Damage:= 0 |
333 Gear^.Damage:= 0 |
335 end; |
334 end; |
620 end; |
619 end; |
621 |
620 |
622 procedure AddMiscGears; |
621 procedure AddMiscGears; |
623 var i: LongInt; |
622 var i: LongInt; |
624 begin |
623 begin |
625 AddGear(0, 0, gtATStartGame, 0, 0, 0, 2000); |
624 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000); |
626 if (GameFlags and gfForts) = 0 then |
625 if (GameFlags and gfForts) = 0 then |
627 for i:= 0 to 3 do |
626 for i:= 0 to 3 do |
628 FindPlace(AddGear(0, 0, gtMine, 0, 0, 0, 0), false, 0, 2048); |
627 FindPlace(AddGear(0, 0, gtMine, 0, _0, _0, 0), false, 0, 2048); |
629 end; |
628 end; |
630 |
629 |
631 procedure AddClouds; |
630 procedure AddClouds; |
632 var i: LongInt; |
631 var i: LongInt; |
633 dx, dy: hwFloat; |
632 dx, dy: hwFloat; |
648 dmg: LongInt; |
647 dmg: LongInt; |
649 begin |
648 begin |
650 TargetPoint.X:= NoPointX; |
649 TargetPoint.X:= NoPointX; |
651 {$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
650 {$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
652 if (Mask and EXPLDontDraw) = 0 then DrawExplosion(X, Y, Radius); |
651 if (Mask and EXPLDontDraw) = 0 then DrawExplosion(X, Y, Radius); |
653 if Radius = 50 then AddGear(X, Y, gtExplosion, 0, 0, 0, 0); |
652 if Radius = 50 then AddGear(X, Y, gtExplosion, 0, _0, _0, 0); |
654 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false); |
653 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false); |
655 if (Mask and EXPLAllDamageInRadius)=0 then Radius:= Radius shl 1; |
654 if (Mask and EXPLAllDamageInRadius)=0 then Radius:= Radius shl 1; |
656 Gear:= GearsList; |
655 Gear:= GearsList; |
657 while Gear <> nil do |
656 while Gear <> nil do |
658 begin |
657 begin |
659 dmg:= Radius - hwRound(Distance(Gear^.X - X, Gear^.Y - Y)); |
658 dmg:= Radius - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
660 if dmg > 0 then |
659 if dmg > 0 then |
661 begin |
660 begin |
662 dmg:= dmg div 2; |
661 dmg:= dmg div 2; |
663 case Gear^.Kind of |
662 case Gear^.Kind of |
664 gtHedgehog, |
663 gtHedgehog, |
667 gtFlame: begin |
666 gtFlame: begin |
668 {$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
667 {$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
669 if (Mask and EXPLNoDamage) = 0 then inc(Gear^.Damage, dmg); |
668 if (Mask and EXPLNoDamage) = 0 then inc(Gear^.Damage, dmg); |
670 if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
669 if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
671 begin |
670 begin |
672 Gear^.dX:= Gear^.dX + (_0_005 * dmg + cHHKick) * hwSign(Gear^.X - X); |
671 Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); |
673 Gear^.dY:= Gear^.dY + (_0_005 * dmg + cHHKick) * hwSign(Gear^.Y - Y); |
672 Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); |
674 Gear^.Active:= true; |
673 Gear^.Active:= true; |
675 FollowGear:= Gear |
674 FollowGear:= Gear |
676 end; |
675 end; |
677 end; |
676 end; |
678 gtGrave: begin |
677 gtGrave: begin |
681 end; |
680 end; |
682 end; |
681 end; |
683 end; |
682 end; |
684 Gear:= Gear^.NextGear |
683 Gear:= Gear^.NextGear |
685 end; |
684 end; |
686 //uAIMisc.AwareOfExplosion(0, 0, 0) |
685 uAIMisc.AwareOfExplosion(0, 0, 0) |
687 end; |
686 end; |
688 |
687 |
689 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
688 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
690 var t: PGearArray; |
689 var t: PGearArray; |
691 i: LongInt; |
690 i: LongInt; |
740 rX:= sqr(rX); |
739 rX:= sqr(rX); |
741 rY:= sqr(rY); |
740 rY:= sqr(rY); |
742 while t <> nil do |
741 while t <> nil do |
743 begin |
742 begin |
744 if (t <> Gear) and (t^.Kind = Kind) then |
743 if (t <> Gear) and (t^.Kind = Kind) then |
745 if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > 1) then |
744 if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
746 exit(t); |
745 exit(t); |
747 t:= t^.NextGear |
746 t:= t^.NextGear |
748 end; |
747 end; |
749 CheckGearNear:= nil |
748 CheckGearNear:= nil |
750 end; |
749 end; |
754 begin |
753 begin |
755 t:= GearsList; |
754 t:= GearsList; |
756 while t <> nil do |
755 while t <> nil do |
757 begin |
756 begin |
758 if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
757 if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
759 if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - cHHRadius) * 2 > 2) then |
758 if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
760 begin |
759 begin |
761 inc(t^.Damage, 5); |
760 inc(t^.Damage, 5); |
762 t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
761 t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
763 t^.dY:= - _0_25; |
762 t^.dY:= - _0_25; |
764 t^.Active:= true; |
763 t^.Active:= true; |
776 rX:= sqr(rX); |
775 rX:= sqr(rX); |
777 rY:= sqr(rY); |
776 rY:= sqr(rY); |
778 while t <> nil do |
777 while t <> nil do |
779 begin |
778 begin |
780 if t^.Kind in Kind then |
779 if t^.Kind in Kind then |
781 if not (hwSqr(mX - t^.X) / rX + hwSqr(mY - t^.Y) / rY > 1) then |
780 if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
782 exit(t); |
781 exit(t); |
783 t:= t^.NextGear |
782 t:= t^.NextGear |
784 end; |
783 end; |
785 CheckGearsNear:= nil |
784 CheckGearsNear:= nil |
786 end; |
785 end; |
802 procedure SpawnBoxOfSmth; |
801 procedure SpawnBoxOfSmth; |
803 var t: LongInt; |
802 var t: LongInt; |
804 i: TAmmoType; |
803 i: TAmmoType; |
805 begin |
804 begin |
806 if (CountGears(gtCase) >= 5) or (getrandom(cCaseFactor) <> 0) then exit; |
805 if (CountGears(gtCase) >= 5) or (getrandom(cCaseFactor) <> 0) then exit; |
807 FollowGear:= AddGear(0, 0, gtCase, 0, 0, 0, 0); |
806 FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
808 case getrandom(2) of |
807 case getrandom(2) of |
809 0: begin |
808 0: begin |
810 FollowGear^.Health:= 25; |
809 FollowGear^.Health:= 25; |
811 FollowGear^.Pos:= posCaseHealth |
810 FollowGear^.Pos:= posCaseHealth |
812 end; |
811 end; |
888 dec(Delta, 60) |
887 dec(Delta, 60) |
889 until (cnt2 > 0) or (Delta < 70); |
888 until (cnt2 > 0) or (Delta < 70); |
890 if cnt2 > 0 then |
889 if cnt2 > 0 then |
891 with ar2[GetRandom(cnt2)] do |
890 with ar2[GetRandom(cnt2)] do |
892 begin |
891 begin |
893 Gear^.X:= x; |
892 Gear^.X:= int2hwFloat(x); |
894 Gear^.Y:= y; |
893 Gear^.Y:= int2hwFloat(y); |
895 {$IFDEF DEBUGFILE} |
894 {$IFDEF DEBUGFILE} |
896 AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
895 AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
897 {$ENDIF} |
896 {$ENDIF} |
898 end |
897 end |
899 else |
898 else |