From: Ketmar Dark Date: Sun, 20 Aug 2017 05:21:19 +0000 (+0300) Subject: use tree to check collisions with shot projectiles X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=3bfb3c21b8428a30bcd430263499b64522b6e1d5;p=d2df-sdl.git use tree to check collisions with shot projectiles --- diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas index afebce7..2d0b6d1 100644 --- a/src/game/g_weapons.pas +++ b/src/game/g_weapons.pas @@ -533,6 +533,7 @@ begin gPlayers[i].BFGHit(); end; + //FIXME g_Mons_ForEach(monsCheck); end; @@ -794,6 +795,7 @@ var end; end; + { function monsCheckHit (monidx: Integer; mon: TMonster): Boolean; begin result := false; // don't stop @@ -810,10 +812,26 @@ var end; end; end; + } + + function monsCheckHit (monidx: Integer; mon: TMonster): Boolean; + begin + result := false; // don't stop + if HitMonster(mon, d, obj.Vel.X, obj.Vel.Y, SpawnerUID, t) then + begin + if (t <> HIT_FLAME) then + begin + mon.Push((obj.Vel.X+obj.Accel.X)*IfThen(t = HIT_BFG, 8, 1) div 4, + (obj.Vel.Y+obj.Accel.Y)*IfThen(t = HIT_BFG, 8, 1) div 4); + end; + result := true; + end; + end; function MonsterHit(): Boolean; begin - result := g_Mons_ForEach(monsCheckHit); + //result := g_Mons_ForEach(monsCheckHit); + result := g_Mons_ForEachAtAlive(obj.X+obj.Rect.X, obj.Y+obj.Rect.Y, obj.Rect.Width, obj.Rect.Height, monsCheckHit); end; begin