- tabified MoveDude

# Conflicts:
#	source/games/blood/src/actor.cpp
This commit is contained in:
Christoph Oelckers 2020-12-05 10:40:13 +01:00
parent 8c01c363a9
commit 29c2e68270

View file

@ -4835,24 +4835,24 @@ int MoveThing(DBloodActor* actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void MoveDude(DBloodActor *actor) void MoveDude(DBloodActor* actor)
{ {
auto const pSprite = &actor->s(); auto const pSprite = &actor->s();
auto const pXSprite = &actor->x(); auto const pXSprite = &actor->x();
PLAYER *pPlayer = nullptr; PLAYER* pPlayer = nullptr;
if (actor->IsPlayerActor()) pPlayer = &gPlayer[pSprite->type-kDudePlayer1]; if (actor->IsPlayerActor()) pPlayer = &gPlayer[pSprite->type - kDudePlayer1];
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax))
{ {
Printf(PRINT_HIGH, "%d: pSprite->type >= kDudeBase && pSprite->type < kDudeMax", pSprite->type); Printf(PRINT_HIGH, "%d: pSprite->type >= kDudeBase && pSprite->type < kDudeMax", pSprite->type);
return; return;
} }
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int top, bottom; int top, bottom;
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
int bz = (bottom-pSprite->z)/4; int bz = (bottom - pSprite->z) / 4;
int tz = (pSprite->z-top)/4; int tz = (pSprite->z - top) / 4;
int wd = pSprite->clipdist<<2; int wd = pSprite->clipdist << 2;
int nSector = pSprite->sectnum; int nSector = pSprite->sectnum;
int nAiStateType = (pXSprite->aiState) ? pXSprite->aiState->stateType : -1; int nAiStateType = (pXSprite->aiState) ? pXSprite->aiState->stateType : -1;
@ -4862,8 +4862,8 @@ void MoveDude(DBloodActor *actor)
{ {
if (pPlayer && gNoClip) if (pPlayer && gNoClip)
{ {
pSprite->x += actor->xvel()>>12; pSprite->x += actor->xvel() >> 12;
pSprite->y += actor->yvel()>>12; pSprite->y += actor->yvel() >> 12;
if (!FindSector(pSprite->x, pSprite->y, &nSector)) if (!FindSector(pSprite->x, pSprite->y, &nSector))
nSector = pSprite->sectnum; nSector = pSprite->sectnum;
} }
@ -4871,12 +4871,12 @@ void MoveDude(DBloodActor *actor)
{ {
short bakCstat = pSprite->cstat; short bakCstat = pSprite->cstat;
pSprite->cstat &= ~257; pSprite->cstat &= ~257;
actor->hit().hit = ClipMove(&pSprite->x, &pSprite->y, &pSprite->z, &nSector, actor->xvel()>>12, actor->yvel()>>12, wd, tz, bz, CLIPMASK0); actor->hit().hit = ClipMove(&pSprite->x, &pSprite->y, &pSprite->z, &nSector, actor->xvel() >> 12, actor->yvel() >> 12, wd, tz, bz, CLIPMASK0);
if (nSector == -1) if (nSector == -1)
{ {
nSector = pSprite->sectnum; nSector = pSprite->sectnum;
if (pSprite->statnum == kStatDude || pSprite->statnum == kStatThing) if (pSprite->statnum == kStatDude || pSprite->statnum == kStatThing)
actDamageSprite(pSprite->index, pSprite, kDamageFall, 1000<<4); actDamageSprite(pSprite->index, pSprite, kDamageFall, 1000 << 4);
} }
if (sector[nSector].type >= kSectorPath && sector[nSector].type <= kSectorRotate) if (sector[nSector].type >= kSectorPath && sector[nSector].type <= kSectorRotate)
@ -4891,7 +4891,7 @@ void MoveDude(DBloodActor *actor)
pSprite->cstat = bakCstat; pSprite->cstat = bakCstat;
} }
Collision coll = actor->hit().hit; Collision coll = actor->hit().hit;
switch (actor->hit().hit&0xc000) switch (actor->hit().hit & 0xc000)
{ {
case kHitSprite: case kHitSprite:
{ {
@ -4900,20 +4900,20 @@ void MoveDude(DBloodActor *actor)
auto Owner = coll.actor->GetOwner(); auto Owner = coll.actor->GetOwner();
if (pHitSprite->statnum == kStatProjectile && !(pHitSprite->flags&32) && actor != Owner) if (pHitSprite->statnum == kStatProjectile && !(pHitSprite->flags & 32) && actor != Owner)
{ {
HITINFO hitInfo = gHitInfo; HITINFO hitInfo = gHitInfo;
gHitInfo.hitsprite = pSprite->index; gHitInfo.hitsprite = pSprite->index;
actImpactMissile(actor, 3); actImpactMissile(actor, 3);
gHitInfo = hitInfo; gHitInfo = hitInfo;
} }
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
if (!gModernMap && pHitXSprite && pHitXSprite->Touch && !pHitXSprite->state && !pHitXSprite->isTriggered) if (!gModernMap && pHitXSprite && pHitXSprite->Touch && !pHitXSprite->state && !pHitXSprite->isTriggered)
trTriggerSprite(coll.actor, kCmdSpriteTouch); trTriggerSprite(coll.actor, kCmdSpriteTouch);
#else #else
if (pHitXSprite && pHitXSprite->Touch && !pHitXSprite->state && !pHitXSprite->isTriggered) if (pHitXSprite && pHitXSprite->Touch && !pHitXSprite->state && !pHitXSprite->isTriggered)
trTriggerSprite(coll.actor, kCmdSpriteTouch); trTriggerSprite(coll.actor, kCmdSpriteTouch);
#endif #endif
if (pDudeInfo->lockOut && pHitXSprite && pHitXSprite->Push && !pHitXSprite->key && !pHitXSprite->DudeLockout && !pHitXSprite->state && !pHitXSprite->busy && !pPlayer) if (pDudeInfo->lockOut && pHitXSprite && pHitXSprite->Push && !pHitXSprite->key && !pHitXSprite->DudeLockout && !pHitXSprite->state && !pHitXSprite->busy && !pPlayer)
trTriggerSprite(coll.actor, kCmdSpritePush); trTriggerSprite(coll.actor, kCmdSpritePush);
@ -4923,8 +4923,8 @@ void MoveDude(DBloodActor *actor)
case kHitWall: case kHitWall:
{ {
int nHitWall = coll.index; int nHitWall = coll.index;
walltype *pHitWall = &wall[nHitWall]; walltype* pHitWall = &wall[nHitWall];
XWALL *pHitXWall = nullptr; XWALL* pHitXWall = nullptr;
if (pHitWall->extra > 0) pHitXWall = &xwall[pHitWall->extra]; if (pHitWall->extra > 0) pHitXWall = &xwall[pHitWall->extra];
if (pDudeInfo->lockOut && pHitXWall && pHitXWall->triggerPush && !pHitXWall->key && !pHitXWall->dudeLockout && !pHitXWall->state && !pHitXWall->busy && !pPlayer) if (pDudeInfo->lockOut && pHitXWall && pHitXWall->triggerPush && !pHitXWall->key && !pHitXWall->dudeLockout && !pHitXWall->state && !pHitXWall->busy && !pPlayer)
@ -4932,8 +4932,8 @@ void MoveDude(DBloodActor *actor)
if (pHitWall->nextsector != -1) if (pHitWall->nextsector != -1)
{ {
sectortype *pHitSector = &sector[pHitWall->nextsector]; sectortype* pHitSector = &sector[pHitWall->nextsector];
XSECTOR *pHitXSector = nullptr; XSECTOR* pHitXSector = nullptr;
if (pHitSector->extra > 0) if (pHitSector->extra > 0)
pHitXSector = &xsector[pHitSector->extra]; pHitXSector = &xsector[pHitSector->extra];
@ -4958,7 +4958,7 @@ void MoveDude(DBloodActor *actor)
if (pSprite->sectnum != nSector) if (pSprite->sectnum != nSector)
{ {
assert(nSector >= 0 && nSector < kMaxSectors); assert(nSector >= 0 && nSector < kMaxSectors);
XSECTOR *pXSector; XSECTOR* pXSector;
int nXSector = sector[pSprite->sectnum].extra; int nXSector = sector[pSprite->sectnum].extra;
if (nXSector > 0) if (nXSector > 0)
pXSector = &xsector[nXSector]; pXSector = &xsector[nXSector];
@ -4967,10 +4967,10 @@ void MoveDude(DBloodActor *actor)
if (pXSector && pXSector->Exit && (pPlayer || !pXSector->dudeLockout)) if (pXSector && pXSector->Exit && (pPlayer || !pXSector->dudeLockout))
trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit); trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit);
ChangeSpriteSect(pSprite->index, nSector); ChangeSpriteSect(pSprite->index, nSector);
nXSector = sector[nSector].extra; nXSector = sector[nSector].extra;
pXSector = (nXSector > 0) ? &xsector[nXSector] : nullptr; pXSector = (nXSector > 0) ? &xsector[nXSector] : nullptr;
if (pXSector && pXSector->Enter && (pPlayer || !pXSector->dudeLockout)) if (pXSector && pXSector->Enter && (pPlayer || !pXSector->dudeLockout))
{ {
if (sector[nSector].type == kSectorTeleport) if (sector[nSector].type == kSectorTeleport)
pXSector->data = pPlayer ? pSprite->index : -1; pXSector->data = pPlayer ? pSprite->index : -1;
@ -4983,7 +4983,7 @@ void MoveDude(DBloodActor *actor)
int bDepth = 0; int bDepth = 0;
if (sector[nSector].extra > 0) if (sector[nSector].extra > 0)
{ {
XSECTOR *pXSector = &xsector[sector[nSector].extra]; XSECTOR* pXSector = &xsector[sector[nSector].extra];
if (pXSector->Underwater) bUnderwater = 1; if (pXSector->Underwater) bUnderwater = 1;
if (pXSector->Depth) bDepth = 1; if (pXSector->Depth) bDepth = 1;
} }
@ -4992,10 +4992,10 @@ void MoveDude(DBloodActor *actor)
if (pUpperLink && (pUpperLink->s().type == kMarkerUpWater || pUpperLink->s().type == kMarkerUpGoo)) bDepth = 1; if (pUpperLink && (pUpperLink->s().type == kMarkerUpWater || pUpperLink->s().type == kMarkerUpGoo)) bDepth = 1;
if (pLowerLink && (pLowerLink->s().type == kMarkerLowWater || pLowerLink->s().type == kMarkerLowGoo)) bDepth = 1; if (pLowerLink && (pLowerLink->s().type == kMarkerLowWater || pLowerLink->s().type == kMarkerLowGoo)) bDepth = 1;
if (pPlayer) wd += 16; if (pPlayer) wd += 16;
if (actor->zvel()) pSprite->z += actor->zvel()>>8; if (actor->zvel()) pSprite->z += actor->zvel() >> 8;
int ceilZ, ceilHit, floorZ, floorHit; int ceilZ, ceilHit, floorZ, floorHit;
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR); GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
GetActorExtents(actor, &top, &bottom); GetActorExtents(actor, &top, &bottom);
if (pSprite->flags & 2) if (pSprite->flags & 2)
@ -5007,7 +5007,7 @@ void MoveDude(DBloodActor *actor)
{ {
int cz = getceilzofslope(nSector, pSprite->x, pSprite->y); int cz = getceilzofslope(nSector, pSprite->x, pSprite->y);
if (cz > top) if (cz > top)
vc += ((bottom-cz)*-80099) / (bottom-top); vc += ((bottom - cz) * -80099) / (bottom - top);
else else
vc = 0; vc = 0;
} }
@ -5015,7 +5015,7 @@ void MoveDude(DBloodActor *actor)
{ {
int fz = getflorzofslope(nSector, pSprite->x, pSprite->y); int fz = getflorzofslope(nSector, pSprite->x, pSprite->y);
if (fz < bottom) if (fz < bottom)
vc += ((bottom-fz)*-80099) / (bottom-top); vc += ((bottom - fz) * -80099) / (bottom - top);
} }
} }
else else
@ -5027,7 +5027,7 @@ void MoveDude(DBloodActor *actor)
} }
if (vc) if (vc)
{ {
pSprite->z += ((vc*4)/2)>>8; pSprite->z += ((vc * 4) / 2) >> 8;
actor->zvel() += vc; actor->zvel() += vc;
} }
} }
@ -5044,10 +5044,10 @@ void MoveDude(DBloodActor *actor)
int nLink = CheckLink(pSprite); int nLink = CheckLink(pSprite);
if (nLink) if (nLink)
{ {
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR); GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, wd, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
if (pPlayer) if (pPlayer)
playerCorrectInertia(pPlayer, &oldpos); playerCorrectInertia(pPlayer, &oldpos);
switch (nLink) switch (nLink)
{ {
case kMarkerLowStack: case kMarkerLowStack:
if (pPlayer == gView) if (pPlayer == gView)
@ -5060,31 +5060,31 @@ void MoveDude(DBloodActor *actor)
case kMarkerLowWater: case kMarkerLowWater:
case kMarkerLowGoo: case kMarkerLowGoo:
pXSprite->medium = kMediumNormal; pXSprite->medium = kMediumNormal;
if (pPlayer) if (pPlayer)
{ {
pPlayer->posture = 0; pPlayer->posture = 0;
pPlayer->bubbleTime = 0; pPlayer->bubbleTime = 0;
if (!pPlayer->cantJump && (pPlayer->input.actions & SB_JUMP)) if (!pPlayer->cantJump && (pPlayer->input.actions & SB_JUMP))
{ {
actor->zvel() = -0x6aaaa; actor->zvel() = -0x6aaaa;
pPlayer->cantJump = 1; pPlayer->cantJump = 1;
} }
sfxPlay3DSound(pSprite, 721, -1, 0); sfxPlay3DSound(pSprite, 721, -1, 0);
} }
else else
{ {
switch (pSprite->type) switch (pSprite->type)
{ {
case kDudeCultistTommy: case kDudeCultistTommy:
case kDudeCultistShotgun: case kDudeCultistShotgun:
aiNewState(&bloodActors[pXSprite->reference], &cultistGoto); aiNewState(&bloodActors[pXSprite->reference], &cultistGoto);
break; break;
case kDudeGillBeast: case kDudeGillBeast:
aiNewState(&bloodActors[pXSprite->reference], &gillBeastGoto); aiNewState(&bloodActors[pXSprite->reference], &gillBeastGoto);
pSprite->flags |= 6; pSprite->flags |= 6;
break; break;
case kDudeBoneEel: case kDudeBoneEel:
actKillDude(pSprite->index, pSprite, kDamageFall, 1000<<4); actKillDude(pSprite->index, pSprite, kDamageFall, 1000 << 4);
break; break;
} }
@ -5098,7 +5098,7 @@ void MoveDude(DBloodActor *actor)
case kMarkerUpGoo: case kMarkerUpGoo:
{ {
int chance = 0xa00; int medium = kMediumWater; int chance = 0xa00; int medium = kMediumWater;
if (nLink == kMarkerUpGoo){ if (nLink == kMarkerUpGoo) {
medium = kMediumGoo; medium = kMediumGoo;
chance = 0x400; chance = 0x400;
} }
@ -5107,9 +5107,10 @@ void MoveDude(DBloodActor *actor)
if (pPlayer) if (pPlayer)
{ {
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
// look for palette in data2 of marker. If value <= 0, use default ones. // look for palette in data2 of marker. If value <= 0, use default ones.
if (gModernMap) { if (gModernMap)
{
pPlayer->nWaterPal = 0; pPlayer->nWaterPal = 0;
auto pUpper = getUpperLink(nSector); auto pUpper = getUpperLink(nSector);
if (pUpper && pUpper->hasX()) pPlayer->nWaterPal = pUpper->x().data2; if (pUpper && pUpper->hasX()) pPlayer->nWaterPal = pUpper->x().data2;
@ -5124,7 +5125,7 @@ void MoveDude(DBloodActor *actor)
} }
else else
{ {
switch (pSprite->type) switch (pSprite->type)
{ {
case kDudeCultistTommy: case kDudeCultistTommy:
case kDudeCultistShotgun: case kDudeCultistShotgun:
@ -5207,7 +5208,7 @@ void MoveDude(DBloodActor *actor)
{ {
int floorZ2 = floorZ; int floorZ2 = floorZ;
int floorHit2 = floorHit; int floorHit2 = floorHit;
GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, pSprite->clipdist<<2, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR); GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, pSprite->clipdist << 2, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR);
if (bottom <= floorZ && pSprite->z - floorZ2 < bz) if (bottom <= floorZ && pSprite->z - floorZ2 < bz)
{ {
floorZ = floorZ2; floorZ = floorZ2;
@ -5217,8 +5218,8 @@ void MoveDude(DBloodActor *actor)
if (floorZ <= bottom) if (floorZ <= bottom)
{ {
actor->hit().florhit = floorHit; actor->hit().florhit = floorHit;
pSprite->z += floorZ-bottom; pSprite->z += floorZ - bottom;
int v30 = actor->zvel()-velFloor[pSprite->sectnum]; int v30 = actor->zvel() - velFloor[pSprite->sectnum];
if (v30 > 0) if (v30 > 0)
{ {
int vax = actFloorBounceVector((int*)&actor->xvel(), (int*)&actor->yvel(), (int*)&v30, pSprite->sectnum, 0); int vax = actFloorBounceVector((int*)&actor->xvel(), (int*)&actor->yvel(), (int*)&v30, pSprite->sectnum, 0);
@ -5227,12 +5228,12 @@ void MoveDude(DBloodActor *actor)
{ {
pPlayer->fallScream = 0; pPlayer->fallScream = 0;
if (nDamage > (15<<4) && (pSprite->flags&4)) if (nDamage > (15 << 4) && (pSprite->flags & 4))
playerLandingSound(pPlayer); playerLandingSound(pPlayer);
if (nDamage > (30<<4)) if (nDamage > (30 << 4))
sfxPlay3DSound(pSprite, 701, 0, 0); sfxPlay3DSound(pSprite, 701, 0, 0);
} }
nDamage -= 100<<4; nDamage -= 100 << 4;
if (nDamage > 0) if (nDamage > 0)
actDamageSprite(actor, actor, kDamageFall, nDamage); actDamageSprite(actor, actor, kDamageFall, nDamage);
actor->zvel() = v30; actor->zvel() = v30;
@ -5252,7 +5253,7 @@ void MoveDude(DBloodActor *actor)
break; break;
case kSurfLava: case kSurfLava:
{ {
spritetype *pFX = gFX.fxSpawn(FX_10, pSprite->sectnum, pSprite->x, pSprite->y, floorZ, 0); spritetype* pFX = gFX.fxSpawn(FX_10, pSprite->sectnum, pSprite->x, pSprite->y, floorZ, 0);
if (pFX) if (pFX)
{ {
for (int i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
@ -5278,23 +5279,23 @@ void MoveDude(DBloodActor *actor)
{ {
actor->hit().florhit = 0; actor->hit().florhit = 0;
if (pSprite->flags&2) if (pSprite->flags & 2)
pSprite->flags |= 4; pSprite->flags |= 4;
} }
if (top <= ceilZ) if (top <= ceilZ)
{ {
actor->hit().ceilhit = ceilHit; actor->hit().ceilhit = ceilHit;
pSprite->z += ClipLow(ceilZ-top, 0); pSprite->z += ClipLow(ceilZ - top, 0);
if (actor->zvel() <= 0 && (pSprite->flags&4)) if (actor->zvel() <= 0 && (pSprite->flags & 4))
actor->zvel() = MulScale(-actor->zvel(), 0x2000, 16); actor->zvel() = MulScale(-actor->zvel(), 0x2000, 16);
} }
else else
actor->hit().ceilhit = 0; actor->hit().ceilhit = 0;
GetActorExtents(actor,&top,&bottom); GetActorExtents(actor, &top, &bottom);
pXSprite->height = ClipLow(floorZ-bottom, 0)>>8; pXSprite->height = ClipLow(floorZ - bottom, 0) >> 8;
if (actor->xvel() || actor->yvel()) if (actor->xvel() || actor->yvel())
{ {
Collision coll = floorHit; Collision coll = floorHit;
@ -5324,6 +5325,12 @@ void MoveDude(DBloodActor *actor)
} }
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int MoveMissile(spritetype *pSprite) int MoveMissile(spritetype *pSprite)
{ {
int nXSprite = pSprite->extra; int nXSprite = pSprite->extra;