# HG changeset patch # User nemo # Date 1331773924 14400 # Node ID a8aa5984185f53b95856c1b4c0d186c412b09af6 # Parent 2c02ccb8f4ec6f6c955c3c6d99e67fe494227df5 Allow RC plane to go through portals diff -r 2c02ccb8f4ec -r a8aa5984185f hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Wed Mar 14 11:07:22 2012 +0400 +++ b/hedgewars/GSHandlers.inc Wed Mar 14 21:12:04 2012 -0400 @@ -3466,11 +3466,9 @@ fChanged := true; if Gear^.Angle > 2048 then dec(Gear^.Angle) - else - if Gear^.Angle < 2048 then - inc(Gear^.Angle) - else - fChanged := false + else if Gear^.Angle < 2048 then + inc(Gear^.Angle) + else fChanged := false end else begin @@ -4034,7 +4032,7 @@ break; // don't port portals or other gear that wouldn't make sense - if (iterator^.Kind in [gtPortal, gtRope, gtRCPlane]) + if (iterator^.Kind in [gtPortal, gtRope]) or (iterator^.PortalCounter > 32) then continue; @@ -4273,6 +4271,22 @@ iterator^.State:= iterator^.State and (not gstHHHJump) end; + // is it worth adding an arcsin table? Just how often would we end up doing something like this? + if iterator^.Kind = gtRCPlane then + begin + // recycling as temp vars + resety.isNegative:= false; + resety.QWordValue:= 4294967296 * 112; + resetx.isNegative:= false; + resetx.QWordValue:= 4294967296 * 35; + resetdx.isNegative:= false; + resetdx.QWordValue:= 4294967296 * 1152; + + resetdy:=hwAbs(iterator^.dX*4); + resetdy:= resetdy + hwPow(resetdy,3)/_6 + _3 * hwPow(resetdy,5) / _40 + _5 * hwPow(resetdy,7) / resety + resetx * hwPow(resetdy,9) / resetdx; + iterator^.Angle:= hwRound(resetdy*_2048 / _PI) + end; + if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (iterator = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) diff -r 2c02ccb8f4ec -r a8aa5984185f hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Wed Mar 14 11:07:22 2012 +0400 +++ b/hedgewars/uAIMisc.pas Wed Mar 14 21:12:04 2012 -0400 @@ -358,8 +358,7 @@ else if Score > 0 then inc(rate, dmg+fallDmg) - else - dec(rate, (dmg+fallDmg) * friendlyfactor div 100) + else dec(rate, (dmg+fallDmg) * friendlyfactor div 100) end; end; RateExplosion:= rate * 1024; @@ -475,7 +474,7 @@ begin // hammer hit radius is 8, shift is 10 if abs(Point.x - x) + abs(Point.y - y) < 18 then - r:= trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y))); + r:= trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y))); if r <= 18 then if Score > 0 then diff -r 2c02ccb8f4ec -r a8aa5984185f hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Wed Mar 14 11:07:22 2012 +0400 +++ b/hedgewars/uFloat.pas Wed Mar 14 21:12:04 2012 -0400 @@ -82,6 +82,7 @@ function hwRound(const t: hwFloat): LongInt; inline; // Does NOT really round but returns the integer representation of the hwFloat without fractional digits. (-_0_9 -> -0, _1_5 -> _1) function hwAbs(const t: hwFloat): hwFloat; inline; // Returns the value of t with positive sign. function hwSqr(const t: hwFloat): hwFloat; inline; // Returns the square value of parameter t. +function hwPow(const t: hwFloat; p: LongWord): hwFloat; inline; // Returns the power of the value function hwSqrt(const t: hwFloat): hwFloat; inline; // Returns the the positive square root of parameter t. function Distance(const dx, dy: hwFloat): hwFloat; // Returns the distance between two points in 2-dimensional space, of which the parameters are the horizontal and vertical distance. function DistanceI(const dx, dy: LongInt): hwFloat; // Same as above for integer parameters. @@ -148,6 +149,7 @@ _1_9: hwFloat = (isNegative: false; QWordValue: 8160437862); _2: hwFloat = (isNegative: false; QWordValue: 4294967296 * 2); _3: hwFloat = (isNegative: false; QWordValue: 4294967296 * 3); + _PI: hwFloat = (isNegative: false; QWordValue: 13493037704); _4: hwFloat = (isNegative: false; QWordValue: 4294967296 * 4); _4_5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 9 div 2); _5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 5); @@ -355,6 +357,18 @@ hwSqr.QWordValue:= ((QWord(t.Round) * t.Round) shl 32) + QWord(t.Round) * t.Frac * 2 + ((QWord(t.Frac) * t.Frac) shr 32); end; +function hwPow(const t: hwFloat;p: LongWord): hwFloat; +begin +hwPow:= t; +if p mod 2 = 0 then hwPow.isNegative:= t.isNegative; + +while p > 0 do + begin + hwPow.QWordValue:= QWord(hwPow.Round) * t.Frac + QWord(hwPow.Frac) * t.Round + ((QWord(hwPow.Frac) * t.Frac) shr 32); + dec(p) + end +end; + function hwSqrt(const t: hwFloat): hwFloat; var l, r: QWord; c: hwFloat;