From 0896e8f879ab0cb133c27eb6ad5b23e167205bf7 Mon Sep 17 00:00:00 2001 From: Samuel Villareal Date: Wed, 1 Sep 2010 05:44:46 +0000 Subject: + 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 --- src/strife/p_enemy.c | 14 +++++++--- src/strife/p_local.h | 2 +- src/strife/p_mobj.c | 33 +++++++++++++++++++++-- src/strife/p_setup.c | 7 ++--- src/strife/p_spec.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/strife/p_spec.h | 12 +++++++++ src/strife/p_user.c | 4 +++ src/strife/r_things.c | 9 ++++++- 8 files changed, 143 insertions(+), 11 deletions(-) (limited to 'src/strife') diff --git a/src/strife/p_enemy.c b/src/strife/p_enemy.c index a96d8557..acae8479 100644 --- a/src/strife/p_enemy.c +++ b/src/strife/p_enemy.c @@ -329,12 +329,18 @@ boolean P_Move (mobj_t* actor) } 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; } diff --git a/src/strife/p_local.h b/src/strife/p_local.h index 9d4fa48f..3a6ef7aa 100644 --- 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 diff --git a/src/strife/p_mobj.c b/src/strife/p_mobj.c index 891e453f..954bb819 100644 --- a/src/strife/p_mobj.c +++ b/src/strife/p_mobj.c @@ -452,15 +452,22 @@ void P_MobjThinker (mobj_t* mobj) // momentum movement if (mobj->momx || mobj->momy - || (mobj->flags&MF_SKULLFLY) ) + /*|| (mobj->flags&MF_SKULLFLY)*/ ) // villsa [STRIFE] unused { P_XYMovement (mobj); // 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 @@ void P_MobjThinker (mobj_t* mobj) // 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 @@ P_SpawnMobj 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 diff --git a/src/strife/p_setup.c b/src/strife/p_setup.c index 50205d4f..eeefe2dc 100644 --- a/src/strife/p_setup.c +++ b/src/strife/p_setup.c @@ -781,9 +781,10 @@ P_SetupLevel // void P_Init (void) { - P_InitSwitchList (); - P_InitPicAnims (); - R_InitSprites (sprnames); + P_InitSwitchList(); + P_InitPicAnims(); + P_InitTerrainTypes(); // villsa [STRIFE] + R_InitSprites(sprnames); } diff --git a/src/strife/p_spec.c b/src/strife/p_spec.c index b17866bf..4a59bf05 100644 --- a/src/strife/p_spec.c +++ b/src/strife/p_spec.c @@ -197,6 +197,79 @@ void P_InitPicAnims (void) } +// 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++; + } + } +} + // diff --git a/src/strife/p_spec.h b/src/strife/p_spec.h index f5b57032..f3a5c074 100644 --- a/src/strife/p_spec.h +++ b/src/strife/p_spec.h @@ -46,6 +46,18 @@ extern int levelTimeCount; // 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); diff --git a/src/strife/p_user.c b/src/strife/p_user.c index 25a80ff9..9d44f78c 100644 --- a/src/strife/p_user.c +++ b/src/strife/p_user.c @@ -137,6 +137,10 @@ void P_CalcHeight (player_t* player) } 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; } diff --git a/src/strife/r_things.c b/src/strife/r_things.c index 68f4b2fe..82039dd8 100644 --- a/src/strife/r_things.c +++ b/src/strife/r_things.c @@ -553,7 +553,14 @@ void R_ProjectSprite (mobj_t* thing) 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; -- cgit v1.2.3