- useTeleportTarget

This commit is contained in:
Christoph Oelckers 2021-09-02 23:36:57 +02:00
parent f21dc51207
commit 1847b905ba

View file

@ -3041,17 +3041,22 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, int objIndex, D
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) { void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
auto actor = &bloodActors[pSprite->index]; {
spritetype* pSource = &sprite[pXSource->reference]; PLAYER* pPlayer = getPlayerById(pSprite->type); auto pSprite = &actor->s();
auto pSource = &sourceactor->s();
auto pXSource = &sourceactor->x();
PLAYER* pPlayer = getPlayerById(pSprite->type);
XSECTOR* pXSector = (sector[pSource->sectnum].extra >= 0) ? &xsector[sector[pSource->sectnum].extra] : NULL; XSECTOR* pXSector = (sector[pSource->sectnum].extra >= 0) ? &xsector[sector[pSource->sectnum].extra] : NULL;
bool isDude = (!pPlayer && IsDudeSprite(pSprite)); bool isDude = (!pPlayer && actor->IsDudeActor());
if (pSprite->sectnum != pSource->sectnum) if (pSprite->sectnum != pSource->sectnum)
changespritesect(pSprite->index, pSource->sectnum); ChangeActorSect(actor, pSource->sectnum);
pSprite->x = pSource->x; pSprite->y = pSource->y; pSprite->x = pSource->x; pSprite->y = pSource->y;
int zTop, zBot; GetSpriteExtents(pSource, &zTop, &zBot); int zTop, zBot;
GetActorExtents(sourceactor, &zTop, &zBot);
pSprite->z = zBot; pSprite->z = zBot;
clampSprite(pSprite, 0x01); clampSprite(pSprite, 0x01);
@ -3059,7 +3064,6 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
if (pSource->flags & kModernTypeFlag1) // force telefrag if (pSource->flags & kModernTypeFlag1) // force telefrag
TeleFrag(pSprite->index, pSource->sectnum); TeleFrag(pSprite->index, pSource->sectnum);
if (pSprite->flags & kPhysGravity) if (pSprite->flags & kPhysGravity)
pSprite->flags |= kPhysFalling; pSprite->flags |= kPhysFalling;
@ -3102,7 +3106,7 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
} }
else else
{ {
xsprite[pSprite->extra].medium = kMediumNormal; actor->x().medium = kMediumNormal;
if (pPlayer) if (pPlayer)
{ {
pPlayer->posture = (!(pPlayer->input.actions & SB_CROUCH)) ? kPostureStand : kPostureCrouch; pPlayer->posture = (!(pPlayer->input.actions & SB_CROUCH)) ? kPostureStand : kPostureCrouch;
@ -3112,18 +3116,23 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
} }
} }
if (pSprite->statnum == kStatDude && IsDudeSprite(pSprite) && !IsPlayerSprite(pSprite)) { if (pSprite->statnum == kStatDude && actor->IsDudeActor() && !actor->IsPlayerActor())
XSPRITE* pXDude = &xsprite[pSprite->extra]; {
int x = pXDude->targetX; int y = pXDude->targetY; int z = pXDude->targetZ; XSPRITE* pXDude = &actor->x();
int x = pXDude->targetX;
int y = pXDude->targetY;
int z = pXDude->targetZ;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
aiInitSprite(actor); aiInitSprite(actor);
if (target != nullptr) if (target != nullptr)
{ {
pXDude->targetX = x; pXDude->targetY = y; pXDude->targetZ = z; pXDude->targetX = x;
pXDude->targetY = y;
pXDude->targetZ = z;
actor->SetTarget(target); actor->SetTarget(target);
aiActivateDude(&bloodActors[pXDude->reference]); aiActivateDude(actor);
} }
} }
@ -3134,12 +3143,12 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
pPlayer->angle.settarget(pSource->ang); pPlayer->angle.settarget(pSource->ang);
pPlayer->angle.lockinput(); pPlayer->angle.lockinput();
} }
else if (isDude) xsprite[pSprite->extra].goalAng = pSprite->ang = pSource->ang; else if (isDude) pXSource->goalAng = pSprite->ang = pSource->ang;
else pSprite->ang = pSource->ang; else pSprite->ang = pSource->ang;
} }
if (pXSource->data3 == 1) if (pXSource->data3 == 1)
xvel[pSprite->index] = yvel[pSprite->index] = zvel[pSprite->index] = 0; actor->xvel() = actor->yvel() = actor->zvel() = 0;
viewBackupSpriteLoc(pSprite->index, pSprite); viewBackupSpriteLoc(pSprite->index, pSprite);
@ -4681,7 +4690,7 @@ void modernTypeTrigger(int destObjType, int destObjIndex, EVENT event) {
// allows teleport any sprite from any location to the source destination // allows teleport any sprite from any location to the source destination
case kMarkerWarpDest: case kMarkerWarpDest:
if (destObjType != OBJ_SPRITE) break; if (destObjType != OBJ_SPRITE) break;
useTeleportTarget(pXSource, &sprite[destObjIndex]); useTeleportTarget(event.actor, destactor);
break; break;
// changes slope of sprite or sector // changes slope of sprite or sector
case kModernSlopeChanger: case kModernSlopeChanger:
@ -5365,7 +5374,7 @@ bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite
PLAYER* pPlayer = getPlayerById(pXSprite->data1); PLAYER* pPlayer = getPlayerById(pXSprite->data1);
if (pPlayer != NULL && SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1) == 1) if (pPlayer != NULL && SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1) == 1)
useTeleportTarget(pXSprite, pPlayer->pSprite); useTeleportTarget(&bloodActors[nSprite], pPlayer->actor());
return true; return true;
} }
[[fallthrough]]; [[fallthrough]];