DEADSOFTWARE

particle cosmetix for mplats
[d2df-sdl.git] / src / game / g_monsters.pas
index 2b70da642e49892257507eadf3da63de2a0d32db..a437ff9bdcd13e7c1ea72bc56b75efe61c4a72cb 100644 (file)
@@ -14,6 +14,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *)
 {$INCLUDE ../shared/a_modes.inc}
+{$M+}
 {.$DEFINE D2F_DEBUG_MONS_MOVE}
 unit g_monsters;
 
@@ -90,6 +91,9 @@ type
     function findNewPrey(): Boolean;
     procedure ActivateTriggers();
 
+    procedure setGameX (v: Integer); inline;
+    procedure setGameY (v: Integer); inline;
+
   public
     FNoRespawn: Boolean;
     FFireTime: Integer;
@@ -134,8 +138,17 @@ type
 
     procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
 
+    procedure setPosition (ax, ay: Integer; callPosChanged: Boolean=true); inline;
+
     procedure getMapBox (out x, y, w, h: Integer); inline;
 
+  public
+    property Obj: TObj read FObj;
+
+    property proxyId: Integer read mProxyId;
+    property arrIdx: Integer read mArrIdx;
+
+  published
     property MonsterType: Byte read FMonsterType;
     property MonsterHealth: Integer read FHealth write FHealth;
     property MonsterAmmo: Integer read FAmmo write FAmmo;
@@ -148,12 +161,11 @@ type
     property MonsterPain: Integer read FPain write FPain;
     property MonsterAnim: Byte read FCurAnim write FCurAnim;
 
-    property Obj: TObj read FObj;
     property UID: Word read FUID write FUID;
     property SpawnTrigger: Integer read FSpawnTrigger write FSpawnTrigger;
 
-    property GameX: Integer read FObj.X write FObj.X;
-    property GameY: Integer read FObj.Y write FObj.Y;
+    property GameX: Integer read FObj.X write setGameX;
+    property GameY: Integer read FObj.Y write setGameY;
     property GameVelX: Integer read FObj.Vel.X write FObj.Vel.X;
     property GameVelY: Integer read FObj.Vel.Y write FObj.Vel.Y;
     property GameAccelX: Integer read FObj.Accel.X write FObj.Accel.X;
@@ -161,9 +173,6 @@ type
     property GameDirection: TDirection read FDirection write FDirection;
 
     property StartID: Integer read FStartID;
-
-    property proxyId: Integer read mProxyId;
-    property arrIdx: Integer read mArrIdx;
   end;
 
 
@@ -252,6 +261,7 @@ uses
   g_language, g_netmsg, idpool;
 
 
+
 // ////////////////////////////////////////////////////////////////////////// //
 procedure g_Mons_ProfilersBegin ();
 begin
@@ -452,8 +462,8 @@ const
        LeftAnim: Boolean;
        wX, wY: Integer; // Îòêóäà âûëåòèò ïóëÿ
        AnimSpeed: Array [ANIM_SLEEP..ANIM_PAIN] of Byte;
-       AnimDeltaRight: Array [ANIM_SLEEP..ANIM_PAIN] of TPoint;
-       AnimDeltaLeft: Array [ANIM_SLEEP..ANIM_PAIN] of TPoint;
+       AnimDeltaRight: Array [ANIM_SLEEP..ANIM_PAIN] of TDFPoint;
+       AnimDeltaLeft: Array [ANIM_SLEEP..ANIM_PAIN] of TDFPoint;
      end =          // SLEEP           GO              DIE             MESS            ATTACK          ATTACK2         PAIN
    ((LeftAnim: False; wX: 54; wY: 32; AnimSpeed:(3, 2, 3, 2, 3, 0, 4); //DEMON
      AnimDeltaRight: ((X:  1; Y:  4), (X:  1; Y:  4), (X:  0; Y:  4), (X:  0; Y:  4), (X:  2; Y:  6), (X:  2; Y:  6), (X:  2; Y:  5));
@@ -1487,6 +1497,11 @@ end;
 
 { T M o n s t e r : }
 
+procedure TMonster.setGameX (v: Integer); inline; begin FObj.X := v; positionChanged(); end;
+procedure TMonster.setGameY (v: Integer); inline; begin FObj.Y := v; positionChanged(); end;
+procedure TMonster.setPosition (ax, ay: Integer; callPosChanged: Boolean=true); inline; begin FObj.X := ax; FObj.Y := ay; if callPosChanged then positionChanged(); end;
+
+
 procedure TMonster.ActionSound();
 begin
   case FMonsterType of
@@ -1675,8 +1690,8 @@ begin
   FObj.Accel.X := 0;
   FObj.Accel.Y := 0;
   FDirection := FStartDirection;
-  GameX := FStartX;
-  GameY := FStartY;
+  {GameX}FObj.X := FStartX;
+  {GameY}FObj.Y := FStartY;
   FObj.Rect := MONSTERTABLE[FMonsterType].Rect;
   FHealth := MONSTERTABLE[FMonsterType].Health;
   FAmmo := 0;
@@ -2051,9 +2066,12 @@ begin
                       o.Y+o.Rect.Y+o.Rect.Height-128, M_NONE);
 
 // Íå â îáëàñòè ðèñîâàíèÿ íå ðåñóåì:
-  if not g_Collide(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, FObj.Rect.Width, FObj.Rect.Height,
-                   sX-128, sY-128, sWidth+256, sHeight+256) then
-    Exit;
+  if (g_dbg_scale = 1.0) then
+  begin
+    if not g_Collide(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, FObj.Rect.Width, FObj.Rect.Height,
+                     sX-128, sY-128, sWidth+256, sHeight+256) then
+      Exit;
+  end;
 
 // Ýòè ìîíñòðû, óìèðàÿ, íå îñòàâëÿþò òðóïîâ:
   if FState = MONSTATE_DEAD then