DEADSOFTWARE

Refactor: Constants for first and last weapon
[d2df-sdl.git] / src / game / g_playermodel.pas
index 8345e785c504fa6b621aeb77bb7c979dc19f2bb7..8e895a9245645c84a11c56fc9319779c199c389c 100644 (file)
@@ -1,3 +1,18 @@
+(* Copyright (C)  DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *)
 {$MODE DELPHI}
 unit g_playermodel;
 
@@ -43,7 +58,7 @@ type
 
   TModelSoundArray = Array of TModelSound;
   TGibsArray = Array of TGibSprite;
-  TWeaponPoints = Array [WEAPON_SAW..WEAPON_SUPERPULEMET] of
+  TWeaponPoints = Array [WP_FIRST + 1..WP_LAST] of
                   Array [A_STAND..A_PAIN] of
                   Array [D_LEFT..D_RIGHT] of Array of TPoint;
 
@@ -128,18 +143,18 @@ const
   FLAG_BASEPOINT: TPoint = (X:16; Y:43);
   FLAG_DEFPOINT:  TPoint = (X:32; Y:16);
   FLAG_DEFANGLE = -20;
-  WEAPONBASE: Array [WEAPON_SAW..WEAPON_SUPERPULEMET] of TPoint =
+  WEAPONBASE: Array [WP_FIRST + 1..WP_LAST] of TPoint =
               ((X:8; Y:4), (X:8; Y:8), (X:16; Y:16), (X:16; Y:24),
                (X:16; Y:16), (X:24; Y:24), (X:16; Y:16), (X:24; Y:24), (X:16; Y:16));
 
   AnimNames: Array [A_STAND..A_PAIN] of String =
              ('StandAnim','WalkAnim','Die1Anim','Die2Anim','AttackAnim',
               'SeeUpAnim','SeeDownAnim','AttackUpAnim','AttackDownAnim','PainAnim');
-  WeapNames: Array [WEAPON_SAW..WEAPON_SUPERPULEMET] of String =
+  WeapNames: Array [WP_FIRST + 1..WP_LAST] of String =
              ('csaw', 'hgun', 'sg', 'ssg', 'mgun', 'rkt', 'plz', 'bfg', 'spl');
 
 var
-  WeaponID: Array [WEAPON_SAW..WEAPON_SUPERPULEMET] of
+  WeaponID: Array [WP_FIRST + 1..WP_LAST] of
             Array [W_POS_NORMAL..W_POS_DOWN] of
             Array [W_ACT_NORMAL..W_ACT_FIRE] of DWORD;
   PlayerModelsArray: Array of TPlayerModelInfo;
@@ -148,7 +163,7 @@ procedure g_PlayerModel_LoadData();
 var
   a: Integer;
 begin
-  for a := WEAPON_SAW to WEAPON_SUPERPULEMET do
+  for a := WP_FIRST + 1 to WP_LAST do
   begin
     g_Texture_CreateWAD(WeaponID[a][W_POS_NORMAL][W_ACT_NORMAL], GameWAD+':WEAPONS\'+UpperCase(WeapNames[a]));
     g_Texture_CreateWAD(WeaponID[a][W_POS_NORMAL][W_ACT_FIRE], GameWAD+':WEAPONS\'+UpperCase(WeapNames[a])+'_FIRE');
@@ -253,7 +268,7 @@ begin
     Exit;
   end;
 
-  if not WAD.GetResource('TEXT', 'MODEL', pData, len) then
+  if not WAD.GetResource('TEXT/MODEL', pData, len) then
   begin
     WAD.Free();
     Exit;
@@ -298,7 +313,7 @@ begin
       Exit;
     end;
 
-    for aa := WEAPON_SAW to WEAPON_SUPERPULEMET do
+    for aa := WP_FIRST + 1 to WP_LAST do
       for bb := A_STAND to A_PAIN do
         for cc := D_LEFT to D_RIGHT do
         begin
@@ -358,8 +373,8 @@ begin
     SetLength(Gibs, ReadInt('Gibs', 'count', 0));
 
     if (Gibs <> nil) and
-       (WAD.GetResource('TEXTURES', config.ReadStr('Gibs', 'resource', 'GIBS'), pData, lenpd)) and
-       (WAD.GetResource('TEXTURES', config.ReadStr('Gibs', 'mask', 'GIBSMASK'), pData2, lenpd2)) then
+       (WAD.GetResource('TEXTURES/'+config.ReadStr('Gibs', 'resource', 'GIBS'), pData, lenpd)) and
+       (WAD.GetResource('TEXTURES/'+config.ReadStr('Gibs', 'mask', 'GIBSMASK'), pData2, lenpd2)) then
     begin
       for a := 0 to High(Gibs) do
         if e_CreateTextureMemEx(pData, lenpd, Gibs[a].ID, a*32, 0, 32, 32) and
@@ -376,7 +391,7 @@ begin
     end;
 
     ok := True;
-    for aa := WEAPON_SAW to WEAPON_SUPERPULEMET do
+    for aa := WP_FIRST + 1 to WP_LAST do
       for bb := A_STAND to A_PAIN do
         if not (bb in [A_DIE1, A_DIE2, A_PAIN]) then
         begin
@@ -579,7 +594,7 @@ var
   i: DWORD;
   a, b, c: Integer;
 begin
-  for a := WEAPON_SAW to WEAPON_SUPERPULEMET do
+  for a := WP_FIRST + 1 to WP_LAST do
     for b := W_POS_NORMAL to W_POS_DOWN do
       for c := W_ACT_NORMAL to W_ACT_FIRE do
         e_DeleteTexture(WeaponID[a][b][c]);
@@ -688,7 +703,7 @@ begin
 
   if FDrawWeapon and
     (not (FCurrentAnimation in [A_DIE1, A_DIE2, A_PAIN])) and
-    (FCurrentWeapon in [WEAPON_SAW..WEAPON_SUPERPULEMET]) then
+    (FCurrentWeapon in [WP_FIRST + 1..WP_LAST]) then
   begin
     if FCurrentAnimation in [A_SEEUP, A_ATTACKUP] then
       pos := W_POS_UP
@@ -783,7 +798,7 @@ begin
   end
   else
   begin
-    if (Level in [2, 3]) and (FSlopSound > 0) then
+    if (Level in [2, 3, 5]) and (FSlopSound > 0) then
     begin
       g_Sound_PlayExAt('SOUND_MONSTER_SLOP', X, Y);
       if FSlopSound = 1 then
@@ -800,6 +815,12 @@ begin
         SetLength(TempArray, Length(TempArray)+1);
         TempArray[High(TempArray)] := FDieSounds[a].ID;
       end;
+    if (TempArray = nil) and (Level = 5) then
+    begin
+      g_Sound_PlayExAt('SOUND_MONSTER_SLOP', X, Y);
+      Result := True;
+      Exit;
+    end;
   end;
 
   if TempArray = nil then Exit;