shithub: choc

Download patch

ref: 0896e8f879ab0cb133c27eb6ad5b23e167205bf7
parent: b10d4acc24278460fc357aa974d7e3e56f0d5953
author: Samuel Villareal <svkaiser@gmail.com>
date: Wed Sep 1 01:44:46 EDT 2010

+ Terrain type system implemented
+ Feet clipping support added (drawing and player viewz) (TODO: Need
  FeetClipping support done for P_ZMovement)

Subversion-branch: /branches/strife-branch
Subversion-revision: 1992

--- a/src/strife/p_enemy.c
+++ b/src/strife/p_enemy.c
@@ -329,12 +329,18 @@
     }
     else
     {
-	actor->flags &= ~MF_INFLOAT;
+	actor->flags &= ~(MF_INFLOAT|MF_FEETCLIPPED);   // villsa [STRIFE]
+
+        // villsa [STRIFE]
+        if(P_GetTerrainType(actor) != FLOOR_SOLID)
+            actor->flags |= MF_FEETCLIPPED;
     }
 	
-	
-    if (! (actor->flags & MF_FLOAT) )	
-	actor->z = actor->floorz;
+
+    // villsa [STRIFE] TODO - verify
+    /*if (! (actor->flags & MF_FLOAT) )	
+	actor->z = actor->floorz;*/
+
     return true; 
 }
 
--- a/src/strife/p_local.h
+++ b/src/strife/p_local.h
@@ -32,7 +32,7 @@
 #include "r_local.h"
 #endif
 
-#define FLOATSPEED		(FRACUNIT*4)
+#define FLOATSPEED		(FRACUNIT*5)    // villsa [STRIFE] change to 5 (was 4)
 
 
 #define MAXHEALTH		100
--- a/src/strife/p_mobj.c
+++ b/src/strife/p_mobj.c
@@ -452,7 +452,7 @@
     // momentum movement
     if (mobj->momx
 	|| mobj->momy
-	|| (mobj->flags&MF_SKULLFLY) )
+	/*|| (mobj->flags&MF_SKULLFLY)*/ )  // villsa [STRIFE] unused
     {
 	P_XYMovement (mobj);
 
@@ -459,8 +459,15 @@
 	// FIXME: decent NOP/NULL/Nil function pointer please.
 	if (mobj->thinker.function.acv == (actionf_v) (-1))
 	    return;		// mobj was removed
+
+        // villsa [STRIFE]
+        if(P_GetTerrainType(mobj) == FLOOR_SOLID)
+            mobj->flags &= ~MF_FEETCLIPPED;
+        else
+            mobj->flags |= MF_FEETCLIPPED;
+
     }
-    if ( (mobj->z != mobj->floorz)
+    if ( (mobj->z != mobj->floorz && !(mobj->flags & MF_NOGRAVITY)) // villsa [STRIFE]
 	 || mobj->momz )
     {
 	P_ZMovement (mobj);
@@ -468,6 +475,16 @@
 	// FIXME: decent NOP/NULL/Nil function pointer please.
 	if (mobj->thinker.function.acv == (actionf_v) (-1))
 	    return;		// mobj was removed
+
+        // villsa [STRIFE]
+        if(P_GetTerrainType(mobj) == FLOOR_SOLID)
+             mobj->flags &= ~MF_FEETCLIPPED;
+         else
+         {
+             S_StartSound(mobj, sfx_wsplsh);
+             mobj->flags |= MF_FEETCLIPPED;
+         }
+
     }
 
     
@@ -555,7 +572,19 @@
     mobj->ceilingz = mobj->subsector->sector->ceilingheight;
 
     if (z == ONFLOORZ)
+    {
 	mobj->z = mobj->floorz;
+
+        if(mobj->type == MT_TREE7)
+        {
+            mobj->type = mobj->type;
+        }
+
+        // villsa [STRIFE]
+        if(P_GetTerrainType(mobj) != FLOOR_SOLID)
+            mobj->flags |= MF_FEETCLIPPED;
+
+    }
     else if (z == ONCEILINGZ)
 	mobj->z = mobj->ceilingz - mobj->info->height;
     else 
--- a/src/strife/p_setup.c
+++ b/src/strife/p_setup.c
@@ -781,9 +781,10 @@
 //
 void P_Init (void)
 {
-    P_InitSwitchList ();
-    P_InitPicAnims ();
-    R_InitSprites (sprnames);
+    P_InitSwitchList();
+    P_InitPicAnims();
+    P_InitTerrainTypes();   // villsa [STRIFE]
+    R_InitSprites(sprnames);
 }
 
 
--- a/src/strife/p_spec.c
+++ b/src/strife/p_spec.c
@@ -197,6 +197,79 @@
 	
 }
 
+// villsa [STRIFE] terrain type definitions
+typedef struct
+{
+    char*   flat;
+    int     type;
+    int     num;
+} terraintype_t;
+
+terraintype_t   terraintypes[] =
+{
+    {   "F_WATR03", FLOOR_WATER,    -1  },
+    {   "F_WATR02", FLOOR_WATER,    -1  },
+    {   "F_WATR01", FLOOR_WATER,    -1  },
+    {   "F_VWATR3", FLOOR_WATER,    -1  },
+    {   "F_VWATR2", FLOOR_WATER,    -1  },
+    {   "P_VWATR1", FLOOR_WATER,    -1  },
+    {   "F_HWATR3", FLOOR_WATER,    -1  },
+    {   "F_HWATR2", FLOOR_WATER,    -1  },
+    {   "F_HWATR1", FLOOR_WATER,    -1  },
+    {   "F_PWATR3", FLOOR_SLIME,    -1  },
+    {   "F_PWATR2", FLOOR_SLIME,    -1  },
+    {   "F_PWATR1", FLOOR_SLIME,    -1  },
+    {   "END",      FLOOR_END,      -1  },
+};
+
+//
+// P_GetTerrainType
+// villsa [STRIFE] new function
+//
+
+terraintype_e P_GetTerrainType(mobj_t* mobj)
+{
+    int i = 0;
+    subsector_t* ss = mobj->subsector;
+
+    if(mobj->z <= ss->sector->floorheight &&
+        terraintypes[0].type != FLOOR_END)
+    {
+        while(ss->sector->floorpic != terraintypes[i].num)
+        {
+            if(terraintypes[i+1].type == FLOOR_END)
+                return FLOOR_SOLID;
+
+            i++;
+        }
+
+        return terraintypes[i].type;
+    }
+
+    return FLOOR_SOLID;
+}
+
+//
+// P_InitTerrainTypes
+// villsa [STRIFE] new function
+// Initialize terrain types
+//
+
+void P_InitTerrainTypes(void)
+{
+    int pic = 0;
+    int i = 0;
+
+    if(terraintypes[0].type != FLOOR_END)
+    {
+        while(terraintypes[i].type != FLOOR_END)
+        {
+            terraintypes[i].num = R_FlatNumForName(terraintypes[i].flat);
+            i++;
+        }
+    }
+}
+
 
 
 //
--- a/src/strife/p_spec.h
+++ b/src/strife/p_spec.h
@@ -46,6 +46,18 @@
 // at game start
 void    P_InitPicAnims (void);
 
+// villsa [STRIFE]
+typedef enum
+{
+    FLOOR_WATER = 0,
+    FLOOR_SLIME = 1,
+    FLOOR_SOLID = 2,
+    FLOOR_END   = -1
+} terraintype_e;
+
+void P_InitTerrainTypes(void);                  // villsa [STRIFE]
+terraintype_e P_GetTerrainType(mobj_t* mobj);   // villsa [STRIFE]
+
 // at map load
 void    P_SpawnSpecials (void);
 
--- a/src/strife/p_user.c
+++ b/src/strife/p_user.c
@@ -137,6 +137,10 @@
     }
     player->viewz = player->mo->z + player->viewheight + bob;
 
+    // villsa [STRIFE] TODO - verify
+    if(player->mo->flags & MF_FEETCLIPPED)
+        player->viewz -= (13*FRACUNIT);
+
     if (player->viewz > player->mo->ceilingz-4*FRACUNIT)
 	player->viewz = player->mo->ceilingz-4*FRACUNIT;
 }
--- a/src/strife/r_things.c
+++ b/src/strife/r_things.c
@@ -553,7 +553,14 @@
     vis->gx = thing->x;
     vis->gy = thing->y;
     vis->gz = thing->z;
-    vis->gzt = thing->z + spritetopoffset[lump];
+
+    // villsa [STRIFE]
+    if(thing->flags & MF_FEETCLIPPED)
+        vis->gz -= (10*FRACUNIT);
+
+    // villsa [STRIFE]
+    vis->gzt = vis->gz + spritetopoffset[lump];
+
     vis->texturemid = vis->gzt - viewz;
     vis->x1 = x1 < 0 ? 0 : x1;
     vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;