Commit b3a831c6 authored by Dino Bollinger's avatar Dino Bollinger
Browse files

Duke3D: Add actor struct members `htfloorzoffset` and `htwaterzoffset`

Values range from -128 to 127. The former defines the distance of the
actor from all floors, the latter applies additively to the hardcoded
offset applied when on lotag 1 sectors. Positive values lift the actor
off the ground, negative values move the actor into the floor.

The default values for both struct members is 0. To achieve a net zero
displacement, htfloorzoffset needs to be set to -1, and htwaterzoffset
must be set to 24. Also note that internally, the offset is multiplied
by 256 to receive the actual z coordinates (like `iffloordistl`).
parent 1cc6b192
......@@ -1821,7 +1821,7 @@ ACTOR_STATIC void G_MoveFallers(void)
else if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(pSprite->sectnum)))
spriteGravity = g_spriteGravity / 6;
if (pSprite->z < (sector[sectNum].floorz-ACTOR_FLOOR_OFFSET))
if (pSprite->z < (sector[sectNum].floorz - AC_FZOFFSET(spriteNum)))
{
pSprite->zvel += spriteGravity;
if (pSprite->zvel > ACTOR_MAXFALLINGZVEL)
......@@ -5196,7 +5196,7 @@ ACTOR_STATIC void G_MoveActors(void)
{
A_Fall(spriteNum);
if ((sector[sectNum].lotag != ST_1_ABOVE_WATER || actor[spriteNum].floorz != sector[sectNum].floorz) && pSprite->z >= actor[spriteNum].floorz-(ACTOR_FLOOR_OFFSET) && pSprite->yvel < 3)
if ((sector[sectNum].lotag != ST_1_ABOVE_WATER || actor[spriteNum].floorz != sector[sectNum].floorz) && pSprite->z >= actor[spriteNum].floorz - AC_FZOFFSET(spriteNum) && pSprite->yvel < 3)
{
if (pSprite->yvel > 0 || (pSprite->yvel == 0 && actor[spriteNum].floorz == sector[sectNum].floorz))
A_PlaySound(PIPEBOMB_BOUNCE,spriteNum);
......@@ -6034,7 +6034,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
if (sectNum < 0)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
if (pSprite->z == actor[spriteNum].floorz-(ACTOR_FLOOR_OFFSET) && pData[0] < 3)
if (pSprite->z == actor[spriteNum].floorz-AC_FZOFFSET(spriteNum) && pData[0] < 3)
{
pSprite->zvel = -((3-pData[0])<<8)-(krand()&511);
if (sector[sectNum].lotag == ST_2_UNDERWATER)
......
......@@ -32,7 +32,8 @@ extern "C" {
#define MAXSLEEPDIST 16384
#define SLEEPTIME 1536
#define ACTOR_FLOOR_OFFSET (1<<8)
#define AC_FZOFFSET(t) (((int32_t) actor[t].floorzoffset + 1) << 8)
#define ZOFFSET2 (16<<8)
#define ZOFFSET3 (8<<8)
#define ZOFFSET4 (12<<8)
......@@ -127,17 +128,18 @@ typedef struct
{
int32_t t_data[10]; // 40b sometimes used to hold offsets to con code
uint32_t flags; // 4b
vec3_t bpos; // 12b
int32_t floorz, ceilingz; // 8b
vec2_t lastv; // 8b
int16_t htpicnum, htang; // 4b
int16_t htextra, htowner; // 4b
int16_t movflag, tempang; // 4b
int16_t timetosleep, stayput; // 4b
uint8_t filler[4]; // 4b
int16_t dispicnum; // 2b NOTE: updated every frame, not in sync with game tics!
uint8_t cgg, lasttransport; // 2b
uint32_t flags; // 4b
vec3_t bpos; // 12b
int32_t floorz, ceilingz; // 8b
vec2_t lastv; // 8b
int16_t htpicnum, htang; // 4b
int16_t htextra, htowner; // 4b
int16_t movflag, tempang; // 4b
int16_t timetosleep, stayput; // 4b
int8_t floorzoffset, waterzoffset; // 2b
uint8_t filler[2]; // 3b
int16_t dispicnum; // 2b NOTE: updated every frame, not in sync with game tics!
uint8_t cgg, lasttransport; // 2b
} actor_t;
EDUKE32_STATIC_ASSERT(sizeof(actor_t) == 96);
......@@ -212,8 +214,9 @@ typedef struct netactor_s
movflag,
tempang,
timetosleep,
stayput,
floorzoffset,
waterzoffset,
dispicnum;
// note: lightId, lightcount, lightmaxrange are not synchronized between client and server
......
......@@ -712,6 +712,8 @@ enum ActorLabel_t
ACTOR_HTUMOVFLAG,
ACTOR_HTTEMPANG,
ACTOR_HTSTAYPUT,
ACTOR_HTFLOORZOFFSET,
ACTOR_HTWATERZOFFSET,
ACTOR_HTDISPICNUM,
ACTOR_HTTIMETOSLEEP,
ACTOR_HTFLOORZ,
......
......@@ -457,11 +457,11 @@ void VM_GetZRange(int const spriteNum, int32_t* const ceilhit, int32_t* const fl
int const ocstat = pSprite->cstat;
pSprite->cstat = 0;
pSprite->z -= ACTOR_FLOOR_OFFSET;
pSprite->z -= AC_FZOFFSET(spriteNum);
getzrange(&pSprite->xyz, pSprite->sectnum, &pActor->ceilingz, ceilhit, &pActor->floorz, florhit, wallDist, CLIPMASK0);
pSprite->z += ACTOR_FLOOR_OFFSET;
pSprite->z += AC_FZOFFSET(spriteNum);
pSprite->cstat = ocstat;
//pz->hi = *ceilhit;
......@@ -535,7 +535,7 @@ void A_Fall(int const spriteNum)
int fbunch = (sector[pSprite->sectnum].floorstat&512) ? -1 : yax_getbunch(pSprite->sectnum, YAX_FLOOR);
#endif
if (pSprite->z < actor[spriteNum].floorz-ACTOR_FLOOR_OFFSET
if (pSprite->z < actor[spriteNum].floorz - AC_FZOFFSET(spriteNum)
#ifdef YAX_ENABLE
|| fbunch >= 0
#endif
......@@ -551,9 +551,9 @@ void A_Fall(int const spriteNum)
setspritez(spriteNum, &pSprite->xyz);
else
#endif
if (pSprite->z >= actor[spriteNum].floorz-ACTOR_FLOOR_OFFSET)
if (pSprite->z >= actor[spriteNum].floorz - AC_FZOFFSET(spriteNum))
{
pSprite->z = actor[spriteNum].floorz-ACTOR_FLOOR_OFFSET;
pSprite->z = actor[spriteNum].floorz - AC_FZOFFSET(spriteNum);
pSprite->zvel = 0;
}
}
......@@ -1026,7 +1026,7 @@ static int32_t A_GetWaterZOffset(int const spriteNum)
if ((AC_MOVFLAGS(pSprite, pActor) & jumptoplayer_only) || (G_TileHasActor(pSprite->picnum) && A_GetVerticalVel(pActor) != 0))
return 0;
return ACTOR_ONWATER_ADDZ;
return ACTOR_ONWATER_ADDZ - ((int32_t) pActor->waterzoffset << 8);
}
return 0;
......@@ -1050,7 +1050,7 @@ static void VM_Fall(int const spriteNum, spritetype * const pSprite)
A_GetZLimits(spriteNum);
if (pSprite->z < actor[spriteNum].floorz-ACTOR_FLOOR_OFFSET)
if (pSprite->z < actor[spriteNum].floorz - AC_FZOFFSET(spriteNum))
{
// Free fall.
pSprite->zvel = min(pSprite->zvel+spriteGravity, ACTOR_MAXFALLINGZVEL);
......@@ -1061,15 +1061,15 @@ static void VM_Fall(int const spriteNum, spritetype * const pSprite)
setspritez(spriteNum, &pSprite->xyz);
else
#endif
if (newZ > actor[spriteNum].floorz - ACTOR_FLOOR_OFFSET)
newZ = actor[spriteNum].floorz - ACTOR_FLOOR_OFFSET;
if (newZ > actor[spriteNum].floorz - AC_FZOFFSET(spriteNum))
newZ = actor[spriteNum].floorz - AC_FZOFFSET(spriteNum);
pSprite->z = newZ;
return;
}
// Preliminary new z position of the actor.
int newZ = actor[spriteNum].floorz - ACTOR_FLOOR_OFFSET;
int newZ = actor[spriteNum].floorz - AC_FZOFFSET(spriteNum);
if (A_CheckEnemySprite(pSprite) || (pSprite->picnum == APLAYER && pSprite->owner >= 0))
{
......
......@@ -247,6 +247,8 @@ memberlabel_t const ActorLabels[]=
{ "htumovflag", ACTOR_HTUMOVFLAG, sizeof(actor[0].movflag) | LABEL_UNSIGNED, 0, offsetof(actor_t, movflag) },
LABEL(actor, tempang, "httempang", ACTOR_HTTEMPANG),
LABEL(actor, stayput, "htactorstayput", ACTOR_HTSTAYPUT),
LABEL(actor, floorzoffset,"htfloorzoffset", ACTOR_HTFLOORZOFFSET),
LABEL(actor, waterzoffset,"htwaterzoffset", ACTOR_HTWATERZOFFSET),
LABEL(actor, dispicnum, "htdispicnum", ACTOR_HTDISPICNUM),
LABEL(actor, timetosleep, "httimetosleep", ACTOR_HTTIMETOSLEEP),
LABEL(actor, floorz, "htfloorz", ACTOR_HTFLOORZ),
......
......@@ -338,6 +338,8 @@ static netField_t ActorFields[] =
{ ACTF(timetosleep), 16 },
{ ACTF(stayput), 16 },
{ ACTF(floorzoffset), 8 },
{ ACTF(waterzoffset), 8 },
{ ACTF(dispicnum), 16 },
{ ACTF(cgg), 8},
......@@ -974,6 +976,8 @@ static void Net_CopyActorFromNet(const netactor_t* netActor, actor_t *gameActor)
gameActor->timetosleep = netActor->timetosleep;
gameActor->stayput = netActor->stayput;
gameActor->floorzoffset = netActor->floorzoffset;
gameActor->waterzoffset = netActor->waterzoffset;
gameActor->dispicnum = netActor->dispicnum;
gameActor->cgg = netActor->cgg;
......@@ -1312,6 +1316,8 @@ static void Net_CopyActorToNet(const actor_t* gameActor, netactor_t *netActor)
netActor->timetosleep = gameActor->timetosleep;
netActor->stayput = gameActor->stayput;
netActor->floorzoffset = gameActor->floorzoffset;
netActor->waterzoffset = gameActor->waterzoffset;
netActor->dispicnum = gameActor->dispicnum;
netActor->cgg = gameActor->cgg;
......
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