Commit 7d1b8de3 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

Duke3d: CON control over player height

You're gonna have to talk to me or read the source for full details on usage, sorry.
parent 0fb8ed19
......@@ -389,7 +389,12 @@ wallsfinished:
int spriteDist = dist(pSprite, pDamage);
if (pDamage->picnum == APLAYER)
spriteDist = FindDistance3D(pSprite->x - pDamage->x, pSprite->y - pDamage->y, pSprite->z - (pDamage->z - PHEIGHT));
{
int const playerNum = P_Get(damageSprite);
auto const pPlayer = g_player[playerNum].ps;
spriteDist = FindDistance3D(pSprite->x - pDamage->x, pSprite->y - pDamage->y, pSprite->z - (pDamage->z - pPlayer->spritezoffset));
}
if (spriteDist < blastRadius)
A_RadiusDamageObject_Internal(spriteNum, damageSprite, blastRadius, spriteDist, randomZOffset, dmg1, dmg2, dmg3, dmg4);
......@@ -1369,7 +1374,7 @@ ACTOR_STATIC void G_MovePlayers(void)
{
pSprite->x = pPlayer->opos.x;
pSprite->y = pPlayer->opos.y;
pSprite->z = pPlayer->opos.z + PHEIGHT;
pSprite->z = pPlayer->opos.z + pPlayer->spritezoffset;
actor[spriteNum].bpos.z = pSprite->z;
pSprite->ang = fix16_to_int(pPlayer->oq16ang);
......@@ -3680,7 +3685,7 @@ static void P_FinishWaterChange(int const playerNum, DukePlayer_t * const pPlaye
changespritesect(playerNum, newSector);
vec3_t vect = pPlayer->pos;
vect.z += PHEIGHT;
vect.z += pPlayer->spritezoffset;
setsprite(pPlayer->i, &vect);
P_UpdateScreenPal(pPlayer);
......@@ -3772,7 +3777,7 @@ ACTOR_STATIC void G_MoveTransports(void)
}
pPlayer->pos = sprite[OW(spriteNum)].pos;
pPlayer->pos.z -= PHEIGHT;
pPlayer->pos.z -= pPlayer->spritezoffset;
pPlayer->opos = pPlayer->pos;
pPlayer->bobpos = pPlayer->pos.vec2;
......@@ -7770,9 +7775,9 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
pPlayer->opos.x = pPlayer->pos.x;
pPlayer->opos.y = pPlayer->pos.y;
pPlayer->pos.z += PHEIGHT;
pPlayer->pos.z += pPlayer->spritezoffset;
setsprite(pPlayer->i, &pPlayer->pos);
pPlayer->pos.z -= PHEIGHT;
pPlayer->pos.z -= pPlayer->spritezoffset;
}
}
......@@ -7893,7 +7898,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
if (pPlayer->cursectnum == pSprite->sectnum && pPlayer->on_ground)
{
if (klabs(pPlayer->pos.z - pPlayer->truefz) < PHEIGHT + (9 << 8))
if (klabs(pPlayer->pos.z - pPlayer->truefz) < pPlayer->spritezoffset + ZOFFSET3)
{
pPlayer->fric.x += vect.x << 3;
pPlayer->fric.y += vect.y << 3;
......
......@@ -3848,7 +3848,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
// dirty hack
if (ps->dead_flag || sprite[ps->i].extra <= 0) t->z = ps->opos.z;
t->z += mulscale16(smoothratio,ps->pos.z-ps->opos.z) -
((ps->dead_flag || sprite[ps->i].extra <= 0) ? 0 : PHEIGHT) + PHEIGHT;
((ps->dead_flag || sprite[ps->i].extra <= 0) ? 0 : ps->spritezoffset) + ps->spritezoffset;
}
else if (pSprite->picnum != CRANEPOLE)
{
......
......@@ -406,6 +406,14 @@ enum PlayerLabel_t
PLAYER_BSUBWEAPON,
PLAYER_CROUCH_TOGGLE,
PLAYER_GRAVITY,
PLAYER_FLOORZOFFSET,
PLAYER_SPRITEZOFFSET,
PLAYER_MINWATERZOFFSET,
PLAYER_MAXWATERZOFFSET,
PLAYER_SHRUNKZOFFSET,
PLAYER_CROUCHZINCREMENT,
PLAYER_CROUCHSPEEDMODIFIER,
PLAYER_WATERSPEEDMODIFIER,
PLAYER_END
};
......
......@@ -549,7 +549,16 @@ memberlabel_t const PlayerLabels[] =
MEMBER(g_player[0].ps, last_used_weapon, PLAYER_LAST_USED_WEAPON),
{ "bsubweapon", PLAYER_BSUBWEAPON, LABEL_HASPARM2, MAX_WEAPONS, -1 },
MEMBER(g_player[0].ps, crouch_toggle, PLAYER_CROUCH_TOGGLE),
MEMBER(g_player[0].ps, gravity, PLAYER_GRAVITY),
MEMBER(g_player[0].ps, floorzoffset, PLAYER_FLOORZOFFSET),
MEMBER(g_player[0].ps, spritezoffset, PLAYER_SPRITEZOFFSET),
MEMBER(g_player[0].ps, minwaterzoffset, PLAYER_MINWATERZOFFSET),
MEMBER(g_player[0].ps, maxwaterzoffset, PLAYER_MAXWATERZOFFSET),
MEMBER(g_player[0].ps, shrunkzoffset, PLAYER_SHRUNKZOFFSET),
MEMBER(g_player[0].ps, crouchzincrement, PLAYER_CROUCHZINCREMENT),
MEMBER(g_player[0].ps, crouchspeedmodifier, PLAYER_CROUCHSPEEDMODIFIER),
MEMBER(g_player[0].ps, waterspeedmodifier, PLAYER_WATERSPEEDMODIFIER),
};
int32_t __fastcall VM_GetPlayer(int const playerNum, int32_t labelNum, int const lParm2)
......
......@@ -192,7 +192,7 @@ static void A_HitscanProjTrail(const vec3_t *startPos, const vec3_t *endPos, int
int32_t A_GetHitscanRange(int spriteNum)
{
int const zOffset = (PN(spriteNum) == APLAYER) ? PHEIGHT : 0;
int const zOffset = (PN(spriteNum) == APLAYER) ? g_player[P_Get(spriteNum)].ps->spritezoffset : 0;
hitdata_t hitData;
SZ(spriteNum) -= zOffset;
......@@ -864,7 +864,7 @@ static int A_ShootCustom(int const spriteNum, int const projecTile, int shootAng
pSprite->x += x;
pSprite->y += y;
G_AddGameLight(0, spriteNum, PHEIGHT, 8192, pProj->flashcolor, PR_LIGHT_PRIO_MAX_GAME);
G_AddGameLight(0, spriteNum, pPlayer->spritezoffset, 8192, pProj->flashcolor, PR_LIGHT_PRIO_MAX_GAME);
practor[spriteNum].lightcount = 2;
pSprite->x -= x;
pSprite->y -= y;
......@@ -2071,7 +2071,7 @@ static void P_FireWeapon(int playerNum)
s->x += x;
s->y += y;
G_AddGameLight(0, pPlayer->i, PHEIGHT, 8192, PWEAPON(playerNum, pPlayer->curr_weapon, FlashColor),
G_AddGameLight(0, pPlayer->i, pPlayer->spritezoffset, 8192, PWEAPON(playerNum, pPlayer->curr_weapon, FlashColor),
PR_LIGHT_PRIO_MAX_GAME);
practor[pPlayer->i].lightcount = 2;
s->x -= x;
......@@ -4144,7 +4144,7 @@ static void P_ProcessWeapon(int playerNum)
pSprite->x += glowXOffset;
pSprite->y += glowYOffset;
G_AddGameLight(0, pPlayer->i, PHEIGHT, max(glowRange, 0),
G_AddGameLight(0, pPlayer->i, pPlayer->spritezoffset, max(glowRange, 0),
PWEAPON(playerNum, pPlayer->curr_weapon, FlashColor), PR_LIGHT_PRIO_HIGH_GAME);
practor[pPlayer->i].lightcount = 2;
......@@ -4815,7 +4815,7 @@ static void P_Dead(int const playerNum, int const sectorLotag, int const floorZ,
{
if (pPlayer->on_warping_sector == 0)
{
if (klabs(pPlayer->pos.z-floorZ) >(PHEIGHT>>1))
if (klabs(pPlayer->pos.z-floorZ) >(pPlayer->spritezoffset>>1))
pPlayer->pos.z += 348;
}
else
......@@ -4953,7 +4953,7 @@ void P_ProcessInput(int playerNum)
int const trueFloorZ = pPlayer->truefz;
int const trueFloorDist = klabs(pPlayer->pos.z - trueFloorZ);
if ((lowZhit & 49152) == 16384 && sectorLotag == 1 && trueFloorDist > PHEIGHT + ZOFFSET2)
if ((lowZhit & 49152) == 16384 && sectorLotag == 1 && trueFloorDist > pPlayer->spritezoffset + ZOFFSET2)
sectorLotag = 0;
if ((highZhit & 49152) == 49152)
......@@ -5104,7 +5104,7 @@ void P_ProcessInput(int playerNum)
int velocityModifier = TICSPERFRAME;
const uint8_t *const weaponFrame = &pPlayer->kickback_pic;
int floorZOffset = 40;
int floorZOffset = pPlayer->floorzoffset;
int const playerShrunk = (pSprite->yrepeat < 32);
vec3_t const backupPos = pPlayer->opos;
......@@ -5153,16 +5153,16 @@ void P_ProcessInput(int playerNum)
if (sectorLotag == ST_1_ABOVE_WATER && pPlayer->spritebridge == 0)
{
floorZOffset = 12;
floorZOffset = pPlayer->shrunkzoffset;
if (!playerShrunk)
{
floorZOffset = 34;
floorZOffset = pPlayer->maxwaterzoffset;
pPlayer->pycount += 32;
pPlayer->pycount &= 2047;
pPlayer->pyoff = sintable[pPlayer->pycount] >> 6;
if (trueFloorDist <= PHEIGHT)
if (trueFloorDist <= pPlayer->spritezoffset)
{
if (pPlayer->on_ground == 1)
{
......@@ -5217,12 +5217,12 @@ void P_ProcessInput(int playerNum)
}
}
if (pPlayer->pos.z < (floorZ-(floorZOffset<<8))) //falling
if (pPlayer->pos.z < (floorZ-floorZOffset)) //falling
{
// this is what keeps you glued to the ground when you're running down slopes
if ((!TEST_SYNC_KEY(playerBits, SK_JUMP) && !(TEST_SYNC_KEY(playerBits, SK_CROUCH))) && pPlayer->on_ground &&
(sector[pPlayer->cursectnum].floorstat & 2) && pPlayer->pos.z >= (floorZ - (floorZOffset << 8) - ZOFFSET2))
pPlayer->pos.z = floorZ - (floorZOffset << 8);
(sector[pPlayer->cursectnum].floorstat & 2) && pPlayer->pos.z >= (floorZ - floorZOffset - ZOFFSET2))
pPlayer->pos.z = floorZ - floorZOffset;
else
{
pPlayer->vel.z += pPlayer->gravity; // (TICSPERFRAME<<6);
......@@ -5241,7 +5241,7 @@ void P_ProcessInput(int playerNum)
}
}
if ((pPlayer->pos.z + pPlayer->vel.z) >= (floorZ - (floorZOffset << 8)) && pPlayer->cursectnum >= 0) // hit the ground
if ((pPlayer->pos.z + pPlayer->vel.z) >= (floorZ - floorZOffset) && pPlayer->cursectnum >= 0) // hit the ground
{
if (sector[pPlayer->cursectnum].lotag != ST_1_ABOVE_WATER)
{
......@@ -5295,10 +5295,10 @@ void P_ProcessInput(int playerNum)
pPlayer->on_ground = 1;
if (floorZOffset==40)
if (floorZOffset==pPlayer->floorzoffset)
{
//Smooth on the ground
int Zdiff = ((floorZ - (floorZOffset << 8)) - pPlayer->pos.z) >> 1;
int Zdiff = ((floorZ - floorZOffset) - pPlayer->pos.z) >> 1;
if (klabs(Zdiff) < 256)
Zdiff = 0;
......@@ -5312,11 +5312,11 @@ void P_ProcessInput(int playerNum)
}
else if (pPlayer->jumping_counter == 0)
{
pPlayer->pos.z += ((floorZ - (floorZOffset << 7)) - pPlayer->pos.z) >> 1; // Smooth on the water
pPlayer->pos.z += ((floorZ - (floorZOffset >> 1)) - pPlayer->pos.z) >> 1; // Smooth on the water
if (pPlayer->on_warping_sector == 0 && pPlayer->pos.z > floorZ - ZOFFSET2)
if (pPlayer->on_warping_sector == 0 && pPlayer->pos.z > floorZ - pPlayer->minwaterzoffset)
{
pPlayer->pos.z = floorZ - ZOFFSET2;
pPlayer->pos.z = floorZ - pPlayer->minwaterzoffset;
pPlayer->vel.z >>= 1;
}
}
......@@ -5328,7 +5328,7 @@ void P_ProcessInput(int playerNum)
{
if (pPlayer->jumping_toggle == 0)
{
pPlayer->pos.z += PCROUCHINCREMENT;
pPlayer->pos.z += pPlayer->crouchzincrement;
pPlayer->crack_time = PCRACKTIME;
}
}
......@@ -5344,7 +5344,7 @@ void P_ProcessInput(int playerNum)
getzrange(&pPlayer->pos, pPlayer->cursectnum, &ceilZ2, &dummy, &floorZ2, &dummy2, getZRangeClipDist, CLIPMASK0);
if (klabs(floorZ2-ceilZ2) > PTOTALHEIGHT)
if (klabs(floorZ2-ceilZ2) > pPlayer->spritezoffset + ZOFFSET3)
{
if (VM_OnEvent(EVENT_JUMP,pPlayer->i,playerNum) == 0)
{
......@@ -5431,7 +5431,7 @@ void P_ProcessInput(int playerNum)
}
}
#endif
if (pPlayer->on_ground && trueFloorDist <= PHEIGHT+ZOFFSET2 && P_CheckFloorDamage(pPlayer, floorPicnum))
if (pPlayer->on_ground && trueFloorDist <= pPlayer->spritezoffset+ZOFFSET2 && P_CheckFloorDamage(pPlayer, floorPicnum))
{
P_DoQuote(QUOTE_BOOTS_ON, pPlayer);
pPlayer->inv_amount[GET_BOOTS] -= 2;
......@@ -5463,7 +5463,7 @@ void P_ProcessInput(int playerNum)
{
int const checkWalkSound = sintable[pPlayer->bobcounter & 2047] >> 12;
if (trueFloorDist < PHEIGHT + ZOFFSET3)
if (trueFloorDist < pPlayer->spritezoffset + ZOFFSET3)
{
if (checkWalkSound == 1 || checkWalkSound == 3)
{
......@@ -5514,14 +5514,14 @@ void P_ProcessInput(int playerNum)
int playerSpeedReduction = 0;
if (sectorLotag == ST_2_UNDERWATER)
playerSpeedReduction = PWATERSPEEDMODIFIER;
playerSpeedReduction = pPlayer->waterspeedmodifier;
else if (((pPlayer->on_ground && TEST_SYNC_KEY(playerBits, SK_CROUCH))
|| (*weaponFrame > 10 && PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == KNEE_WEAPON)))
playerSpeedReduction = PCROUCHSPEEDMODIFIER;
playerSpeedReduction = pPlayer->crouchspeedmodifier;
else if (pPlayer->on_ground && !pPlayer->jumping_toggle && !TEST_SYNC_KEY(playerBits, SK_CROUCH)
&& (klabs(pPlayer->truefz - pPlayer->truecz) - (PMINHEIGHT << 1)) < stepHeight)
{
playerSpeedReduction = PCROUCHSPEEDMODIFIER;
playerSpeedReduction = pPlayer->crouchspeedmodifier;
// pPlayer->pos.z += PCROUCHINCREMENT;
}
......@@ -5612,9 +5612,9 @@ HORIZONLY:;
if (pPlayer->cursectnum >= 0)
{
pPlayer->pos.z += PHEIGHT;
pPlayer->pos.z += pPlayer->spritezoffset;
sprite[pPlayer->i].pos = pPlayer->pos;
pPlayer->pos.z -= PHEIGHT;
pPlayer->pos.z -= pPlayer->spritezoffset;
changespritesect(pPlayer->i, pPlayer->cursectnum);
}
......@@ -5634,7 +5634,7 @@ HORIZONLY:;
}
#ifndef EDUKE32_STANDALONE
if (!FURY && (pPlayer->cursectnum >= 0 && trueFloorDist < PHEIGHT && pPlayer->on_ground && sectorLotag != ST_1_ABOVE_WATER &&
if (!FURY && (pPlayer->cursectnum >= 0 && trueFloorDist < pPlayer->spritezoffset && pPlayer->on_ground && sectorLotag != ST_1_ABOVE_WATER &&
playerShrunk == 0 && sector[pPlayer->cursectnum].lotag == ST_1_ABOVE_WATER) && (!A_CheckSoundPlaying(pPlayer->i, DUKE_ONWATER)))
A_PlaySound(DUKE_ONWATER, pPlayer->i);
#endif
......@@ -5649,7 +5649,7 @@ RECHECK:
int const pushResult = pushmove(&pPlayer->pos, &pPlayer->cursectnum, pPlayer->clipdist - 1, (4L<<8), (4L<<8), CLIPMASK0, !mashedPotato);
bool const squishPlayer = pushResult < 0;
if (squishPlayer || klabs(actor[pPlayer->i].floorz-actor[pPlayer->i].ceilingz) < PTOTALHEIGHT)
if (squishPlayer || klabs(actor[pPlayer->i].floorz-actor[pPlayer->i].ceilingz) < pPlayer->spritezoffset + ZOFFSET3)
{
if (!(sector[pSprite->sectnum].lotag & 0x8000u) &&
(isanunderoperator(sector[pSprite->sectnum].lotag) || isanearoperator(sector[pSprite->sectnum].lotag)))
......
......@@ -41,16 +41,10 @@ extern int32_t g_mostConcurrentPlayers;
#define HORIZ_MAX 299
#define AUTO_AIM_ANGLE 48
#define PHEIGHT (38<<8)
#define PCROUCHHEIGHT (16<<8)
#define PCROUCHINCREMENT (2048+768)
#define PMINHEIGHT 1024 // this is NOT the value I wanted here, but Duke It Out in DC's shitty vents said otherwise
#define PTOTALHEIGHT (48<<8)
#define PCRACKTIME 777
#define PWATERSPEEDMODIFIER 0x1400
#define PCROUCHSPEEDMODIFIER 0x2000
#define TRIPBOMB_TRIPWIRE 0x00000001
#define TRIPBOMB_TIMER 0x00000002
......@@ -204,9 +198,11 @@ typedef struct {
uint16_t frag, fraggedself;
vec2_16_t loogie[6];
int16_t filler[115]; // jesus fucking christ
int16_t filler[107]; // jesus fucking christ
int16_t floorzoffset, spritezoffset, minwaterzoffset, maxwaterzoffset, shrunkzoffset;
int16_t crouchzincrement, crouchspeedmodifier, waterspeedmodifier, gravity;
int16_t gravity;
int16_t sbs, sound_pitch;
int16_t cursectnum, look_ang, last_extra, subweapon;
......
......@@ -665,6 +665,23 @@ static inline void P_ResetTintFade(DukePlayer_t *const pPlayer)
pPlayer->pals.f = 0;
}
void P_ResetExtents(DukePlayer_t *const pPlayer)
{
pPlayer->autostep = 20 << 8;
pPlayer->autostep_sbw = 4 << 8;
pPlayer->clipdist = 164;
pPlayer->crouchspeedmodifier = 8192;
pPlayer->crouchzincrement = 2048 + 768;
pPlayer->floorzoffset = 40 << 8;
pPlayer->gravity = g_spriteGravity + 80;
pPlayer->maxwaterzoffset = 34 << 8;
pPlayer->minwaterzoffset = 16 << 8;
pPlayer->runspeed = g_playerFriction;
pPlayer->shrunkzoffset = 12 << 8;
pPlayer->spritezoffset = 38 << 8/*PHEIGHT*/;
pPlayer->waterspeedmodifier = 5120;
}
void P_ResetMultiPlayer(int playerNum)
{
auto &p = *g_player[playerNum].ps;
......@@ -676,7 +693,7 @@ void P_ResetMultiPlayer(int playerNum)
vec3_t tmpvect = p.pos;
tmpvect.z += PHEIGHT;
tmpvect.z += p.spritezoffset;
P_MoveToRandomSpawnPoint(playerNum);
......@@ -705,13 +722,11 @@ void P_ResetMultiPlayer(int playerNum)
p.frag_ps = playerNum;
p.fta = 0;
p.ftq = 0;
p.gravity = g_spriteGravity+80;
p.on_crane = -1;
p.opyoff = 0;
p.q16horiz = F16(100);
p.q16horizoff = 0;
p.rotscrnang = 0;
p.runspeed = g_playerFriction;
p.vel = { 0, 0, 0 };
p.wackedbyactor = -1;
p.wantweaponfire = -1;
......@@ -748,12 +763,9 @@ void P_ResetPlayer(int playerNum)
p.access_spritenum = -1;
p.actorsqu = -1;
p.airleft = 15 * GAMETICSPERSEC;
p.autostep = (20L << 8);
p.autostep_sbw = (4L << 8);
p.bobcounter = 0;
p.buttonpalette = 0;
p.cheat_phase = 0;
p.clipdist = 164;
p.crack_time = 0;
p.dead_flag = 0;
p.dummyplayersprite = -1;
......@@ -770,7 +782,6 @@ void P_ResetPlayer(int playerNum)
p.fta = 0;
p.ftq = 0;
p.got_access = ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_ACCESSATSTART)) ? 7 : 0;
p.gravity = g_spriteGravity+80;
p.hard_landing = 0;
p.hbomb_hold_delay = 0;
p.heat_on = 0;
......@@ -846,6 +857,7 @@ void P_ResetPlayer(int playerNum)
thisPlayer.horizSkew = 0;
thisPlayer.horizAngleAdjust = 0;
P_ResetExtents(&p);
P_UpdateScreenPal(&p);
VM_OnEvent(EVENT_RESETPLAYER, p.i, playerNum);
}
......@@ -1512,7 +1524,6 @@ static void G_CollectSpawnPoints(int gameMode)
if ((gameMode & MODE_EOL) != MODE_EOL || p.last_extra == 0)
{
p.runspeed = g_playerFriction;
p.last_extra = p.max_player_health;
s.extra = p.max_player_health;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment