# HG changeset patch # User nemo # Date 1313593080 14400 # Node ID 3bb02b92df7d7d131f5a6c667602a7005c5373a8 # Parent c09f5b41644a129a972457e02ba7c8237aaa1823 Add square check to shotgun. This a minor optimisation that might sidestep a bug on iOS/Android. Still need to find out why the bug is happening though diff -r c09f5b41644a -r 3bb02b92df7d hedgewars/uGears.pas --- a/hedgewars/uGears.pas Wed Aug 17 00:11:57 2011 -0400 +++ b/hedgewars/uGears.pas Wed Aug 17 10:58:00 2011 -0400 @@ -1335,15 +1335,13 @@ procedure ShotgunShot(Gear: PGear); var t: PGear; - dmg, dist: LongInt; + dmg, r, dist: LongInt; + dx, dy: hwFloat; begin Gear^.Radius:= cShotgunRadius; t:= GearsList; while t <> nil do begin - dist:= hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)); - dmg:= ModifyDamage(min(Gear^.Radius + t^.Radius - dist, 25), t); - if dmg > 0 then case t^.Kind of gtHedgehog, gtMine, @@ -1352,22 +1350,48 @@ gtTarget, gtExplosives, gtStructure: begin -addFileLog('ShotgunShot radius: ' + inttostr(Gear^.Radius) + ', t^.Radius = ' + inttostr(t^.Radius) + ', distance = ' + inttostr(dist) + ', dmg = ' + inttostr(dmg)); - if (not t^.Invulnerable) then - ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet) - else - Gear^.State:= Gear^.State or gstWinner; +//addFileLog('ShotgunShot radius: ' + inttostr(Gear^.Radius) + ', t^.Radius = ' + inttostr(t^.Radius) + ', distance = ' + inttostr(dist) + ', dmg = ' + inttostr(dmg)); + r:= Gear^.Radius + t^.Radius; + dx:= Gear^.X-t^.X; + dx.isNegative:= false; + dy:= Gear^.Y-t^.Y; + dy.isNegative:= false; + if r - hwRound(dx+dy) < 25 then + begin + dist:= hwRound(Distance(dx, dy)); + dmg:= ModifyDamage(min(r - dist, 25), t); + end; + if dmg > 0 then + begin + if (not t^.Invulnerable) then + ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet) + else + Gear^.State:= Gear^.State or gstWinner; - DeleteCI(t); - t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); - t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; - t^.State:= t^.State or gstMoving; - t^.Active:= true; - FollowGear:= t + DeleteCI(t); + t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); + t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; + t^.State:= t^.State or gstMoving; + t^.Active:= true; + FollowGear:= t + end end; gtGrave: begin - t^.dY:= - _0_1; - t^.Active:= true + r:= Gear^.Radius + t^.Radius; + dx:= Gear^.X-t^.X; + dx.isNegative:= false; + dy:= Gear^.Y-t^.Y; + dy.isNegative:= false; + if r - hwRound(dx+dy) < 25 then + begin + dist:= hwRound(Distance(dx, dy)); + dmg:= ModifyDamage(min(r - dist, 25), t); + end; + if dmg > 0 then + begin + t^.dY:= - _0_1; + t^.Active:= true + end end; end; t:= t^.NextGear