119 (proc: nil; flags: 0), // amLandGun |
119 (proc: nil; flags: 0), // amLandGun |
120 (proc: nil; flags: 0), // amIceGun |
120 (proc: nil; flags: 0), // amIceGun |
121 (proc: nil; flags: 0) // amKnife |
121 (proc: nil; flags: 0) // amKnife |
122 ); |
122 ); |
123 |
123 |
124 const BadTurn = Low(LongInt) div 4; |
|
125 |
|
126 implementation |
124 implementation |
127 uses uAIMisc, uVariables, uUtils, uGearsHandlers; |
125 uses uAIMisc, uVariables, uUtils, uGearsHandlers; |
128 |
126 |
129 function Metric(x1, y1, x2, y2: LongInt): LongInt; inline; |
127 function Metric(x1, y1, x2, y2: LongInt): LongInt; inline; |
130 begin |
128 begin |
147 ap.ExplR:= 0; |
145 ap.ExplR:= 0; |
148 valueResult:= BadTurn; |
146 valueResult:= BadTurn; |
149 repeat |
147 repeat |
150 rTime:= rTime + 300 + Level * 50 + random(300); |
148 rTime:= rTime + 300 + Level * 50 + random(300); |
151 Vx:= - windSpeed * rTime * 0.5 + (Targ.X + AIrndSign(2) - mX) / rTime; |
149 Vx:= - windSpeed * rTime * 0.5 + (Targ.X + AIrndSign(2) - mX) / rTime; |
152 Vy:= cGravityf * rTime * 0.5 - (Targ.Y - mY) / rTime; |
150 Vy:= cGravityf * rTime * 0.5 - (Targ.Y + 1 - mY) / rTime; |
153 r:= sqr(Vx) + sqr(Vy); |
151 r:= sqr(Vx) + sqr(Vy); |
154 if not (r > 1) then |
152 if not (r > 1) then |
155 begin |
153 begin |
156 x:= mX; |
154 x:= mX; |
157 y:= mY; |
155 y:= mY; |
171 EY:= trunc(y); |
169 EY:= trunc(y); |
172 if Level = 1 then |
170 if Level = 1 then |
173 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) |
171 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) |
174 else value:= RateExplosion(Me, EX, EY, 101); |
172 else value:= RateExplosion(Me, EX, EY, 101); |
175 if value = 0 then |
173 if value = 0 then |
176 value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64; |
174 value:= 1024 - Metric(Targ.X, Targ.Y, EX, EY) div 64; |
177 if valueResult <= value then |
175 if valueResult <= value then |
178 begin |
176 begin |
179 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); |
177 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); |
180 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1); |
178 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1); |
181 ap.ExplR:= 100; |
179 ap.ExplR:= 100; |
227 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0); |
225 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0); |
228 EX:= trunc(x); |
226 EX:= trunc(x); |
229 EY:= trunc(y); |
227 EY:= trunc(y); |
230 |
228 |
231 value:= RateShove(trunc(x), trunc(y), 5, 1, trunc((abs(dX)+abs(dY))*20), -dX, -dY, afTrackFall); |
229 value:= RateShove(trunc(x), trunc(y), 5, 1, trunc((abs(dX)+abs(dY))*20), -dX, -dY, afTrackFall); |
232 if value = 0 then |
230 // LOL copypasta: this is score for digging with... snowball |
233 value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64; |
231 //if value = 0 then |
|
232 // value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64; |
234 |
233 |
235 if valueResult <= value then |
234 if valueResult <= value then |
236 begin |
235 begin |
237 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); |
236 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); |
238 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1); |
237 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1); |
335 Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) |
334 Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) |
336 else Score:= RateExplosion(Me, EX, EY, 101) |
335 else Score:= RateExplosion(Me, EX, EY, 101) |
337 else |
336 else |
338 Score:= BadTurn; |
337 Score:= BadTurn; |
339 |
338 |
340 if valueResult < Score then |
339 if (valueResult < Score) and (Score > 0) then |
341 begin |
340 begin |
342 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); |
341 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); |
343 ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15); |
342 ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15); |
344 ap.Time:= TestTime; |
343 ap.Time:= TestTime; |
345 ap.ExplR:= 100; |
344 ap.ExplR:= 100; |
580 x:= x + vX * 8; |
579 x:= x + vX * 8; |
581 y:= y + vY * 8; |
580 y:= y + vY * 8; |
582 valueResult:= RateShotgun(Me, vX, vY, rx, ry); |
581 valueResult:= RateShotgun(Me, vX, vY, rx, ry); |
583 |
582 |
584 if valueResult = 0 then |
583 if valueResult = 0 then |
585 valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64 |
584 valueResult:= 1024 - Metric(Targ.X, Targ.Y, rx, ry) div 64 |
586 else |
585 else |
587 dec(valueResult, Level * 4000); |
586 dec(valueResult, Level * 4000); |
588 // 27/20 is reuse bonus |
587 // 27/20 is reuse bonus |
589 exit(valueResult * 27 div 20) |
588 exit(valueResult * 27 div 20) |
590 end |
589 end |