3081 procedure doStepAirAttackWork(Gear: PGear); |
3081 procedure doStepAirAttackWork(Gear: PGear); |
3082 var uw, nuw: boolean; |
3082 var uw, nuw: boolean; |
3083 tmpFloat: hwFloat; |
3083 tmpFloat: hwFloat; |
3084 begin |
3084 begin |
3085 AllInactive := false; |
3085 AllInactive := false; |
|
3086 if (WorldEdge = weWrap) then |
|
3087 if (WorldWrap(Gear)) then |
|
3088 inc(Gear^.Power); |
3086 Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
3089 Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
3087 if (Gear^.Health > 0) and (not (Gear^.X < Gear^.dX)) and (Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
3090 if (Gear^.Health > 0) and (Gear^.Power >= Gear^.WDTimer) and (((Gear^.Tag = 1) and (not (Gear^.X < Gear^.dX))) or ((Gear^.Tag = -1) and (not (Gear^.X > Gear^.dX)))) then |
3088 begin |
3091 begin |
3089 dec(Gear^.Health); |
3092 dec(Gear^.Health); |
|
3093 Gear^.FlightTime:= 0; |
3090 // Spawn missile |
3094 // Spawn missile |
3091 case Gear^.State of |
3095 case Gear^.State of |
3092 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
3096 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
3093 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
3097 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
3094 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
3098 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
3095 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1); |
3099 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1); |
3096 end; |
3100 end; |
3097 Gear^.dX := Gear^.dX + int2hwFloat(Gear^.Damage * Gear^.Tag); |
3101 Gear^.dX := Gear^.X + int2hwFloat(Gear^.Damage * Gear^.Tag); |
|
3102 if (WorldEdge = weWrap) then |
|
3103 begin |
|
3104 Gear^.dX := int2hwFloat(CalcWorldWrap(hwRound(Gear^.dX), 0)); |
|
3105 if (((Gear^.Tag = 1) and (not (Gear^.X < Gear^.dX))) or ((Gear^.Tag = -1) and (not (Gear^.X > Gear^.dX)))) then |
|
3106 inc(Gear^.WDTimer); |
|
3107 end; |
|
3108 |
3098 if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then |
3109 if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then |
3099 FollowGear^.State:= FollowGear^.State or gstSubmersible; |
3110 FollowGear^.State:= FollowGear^.State or gstSubmersible; |
3100 if (Gear^.SoundChannel <> -1) and (WorldEdge <> weSea) then |
3111 if (Gear^.SoundChannel <> -1) and (WorldEdge <> weSea) then |
3101 begin |
3112 begin |
3102 StopSoundChan(Gear^.SoundChannel, 4000); |
3113 StopSoundChan(Gear^.SoundChannel, 4000); |
3103 Gear^.SoundChannel := -1; |
3114 Gear^.SoundChannel := -1; |
3104 end; |
3115 end; |
3105 end; |
3116 end; |
|
3117 |
|
3118 if (Gear^.Health = 0) then |
|
3119 inc(Gear^.FlightTime); |
3106 |
3120 |
3107 // Particles |
3121 // Particles |
3108 if (GameTicks and $3F) = 0 then |
3122 if (GameTicks and $3F) = 0 then |
3109 if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then |
3123 if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then |
3110 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble) |
3124 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble) |
3111 else |
3125 else |
3112 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); |
3126 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); |
3113 |
3127 |
3114 // Get rid of gear and cleanup |
3128 // Get rid of gear and cleanup |
3115 if (hwRound(Gear^.X) > (max(LAND_WIDTH,4096)+2048)) or (hwRound(Gear^.X) < -2048) or ((Gear^.Message and gmDestroy) > 0) then |
3129 if ((WorldEdge = weWrap) and (Gear^.FlightTime >= 4000)) or |
|
3130 ((WorldEdge <> weWrap) and ((hwRound(Gear^.X) > (max(LAND_WIDTH,4096)+2048)) or (hwRound(Gear^.X) < -2048) or ((Gear^.Message and gmDestroy) > 0))) then |
3116 begin |
3131 begin |
3117 // fail-safe: instanly stop sound if it wasn't disabled before |
3132 // fail-safe: instanly stop sound if it wasn't disabled before |
3118 if (Gear^.SoundChannel <> -1) then |
3133 if (Gear^.SoundChannel <> -1) then |
3119 begin |
3134 begin |
3120 StopSoundChan(Gear^.SoundChannel); |
3135 StopSoundChan(Gear^.SoundChannel); |
3191 // calcs for regular falling gears |
3212 // calcs for regular falling gears |
3192 else if (int2hwFloat(Gear^.Target.Y) - Gear^.Y > _0) then |
3213 else if (int2hwFloat(Gear^.Target.Y) - Gear^.Y > _0) then |
3193 Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(Gear^.Target.Y) - Gear^.Y) * 2 / |
3214 Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(Gear^.Target.Y) - Gear^.Y) * 2 / |
3194 cGravity) * Gear^.Tag; |
3215 cGravity) * Gear^.Tag; |
3195 |
3216 |
|
3217 if (WorldEdge = weWrap) then |
|
3218 begin |
|
3219 Gear^.dX := int2hwFloat(CalcWorldWrap(hwRound(Gear^.dX), 0)); |
|
3220 if (((Gear^.Tag = 1) and (not (Gear^.X < Gear^.dX))) or ((Gear^.Tag = -1) and (not (Gear^.X > Gear^.dX)))) then |
|
3221 Gear^.WDTimer:= 1; |
|
3222 end; |
|
3223 |
3196 Gear^.doStep := @doStepAirAttackWork; |
3224 Gear^.doStep := @doStepAirAttackWork; |
3197 |
3225 |
3198 if (WorldEdge = weSea) then |
3226 if (WorldEdge = weSea) then |
3199 begin |
3227 begin |
3200 Gear^.SoundChannel := LoopSound(sndPlaneWater, 4000); |
3228 Gear^.SoundChannel := LoopSound(sndPlaneWater, 4000); |
3201 Gear^.Karma := 1; |
3229 Gear^.Karma := 1; |
|
3230 end |
|
3231 else if (WorldEdge = weWrap) then |
|
3232 begin |
|
3233 Gear^.SoundChannel := LoopSound(sndPlane); |
|
3234 Gear^.Karma := 0; |
3202 end |
3235 end |
3203 else |
3236 else |
3204 begin |
3237 begin |
3205 Gear^.SoundChannel := LoopSound(sndPlane, 4000); |
3238 Gear^.SoundChannel := LoopSound(sndPlane, 4000); |
3206 Gear^.Karma := 0; |
3239 Gear^.Karma := 0; |