- some ?vel replacements.

This commit is contained in:
Christoph Oelckers 2021-08-27 17:04:34 +02:00
parent cce3d8f440
commit e69e1b9908
7 changed files with 51 additions and 49 deletions

View file

@ -448,12 +448,12 @@ void fxBouncingSleeve(DBloodActor* actor, int) // 16
int zv = actor->zvel() - velFloor[pSprite->sectnum];
if (actor->zvel() == 0) sleeveStopBouncing(pSprite);
if (actor->zvel() == 0) sleeveStopBouncing(actor);
else if (zv > 0) {
actFloorBounceVector((int*)& actor->xvel(), (int*)& actor->yvel(), &zv, pSprite->sectnum, 0x9000);
actor->zvel() = zv;
if (velFloor[pSprite->sectnum] == 0 && abs(actor->zvel()) < 0x20000) {
sleeveStopBouncing(pSprite);
sleeveStopBouncing(actor);
return;
}
@ -474,8 +474,10 @@ void fxBouncingSleeve(DBloodActor* actor, int) // 16
}
void sleeveStopBouncing(spritetype* pSprite) {
xvel[pSprite->index] = yvel[pSprite->index] = zvel[pSprite->index] = 0;
void sleeveStopBouncing(DBloodActor* actor)
{
auto pSprite = &actor->s();
actor->xvel() = actor->yvel() = actor->zvel() = 0;
if (pSprite->extra > 0) seqKill(3, pSprite->extra);
sfxKill3DSound(pSprite, -1, -1);

View file

@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#pragma once
BEGIN_BLD_NS
void sleeveStopBouncing(spritetype* pSprite);
void sleeveStopBouncing(DBloodActor* pSprite);
enum CALLBACK_ID {
kCallbackNone = -1,

View file

@ -189,8 +189,9 @@ int InsertSprite(int nSector, int nStat)
return nSprite;
}
RemoveSpriteStat(nSprite);
spritetype *pSprite = &sprite[nSprite];
memset(&sprite[nSprite], 0, sizeof(spritetype));
DBloodActor* actor = &bloodActors[nSprite];
spritetype *pSprite = &actor->s();
memset(pSprite, 0, sizeof(spritetype));
InsertSpriteStat(nSprite, nStat);
InsertSpriteSect(nSprite, nSector);
pSprite->cstat = 128;
@ -199,7 +200,7 @@ int InsertSprite(int nSector, int nStat)
pSprite->owner = -1;
pSprite->extra = -1;
pSprite->index = nSprite;
xvel[nSprite] = yvel[nSprite] = zvel[nSprite] = 0;
actor->xvel() = actor->yvel() = actor->zvel() = 0;
Numsprites++;

View file

@ -435,7 +435,6 @@ void evSend(DBloodActor* actor, int nIndex, int nType, int rxId, COMMAND_ID comm
case kChannelTeamAFlagCaptured:
case kChannelTeamBFlagCaptured:
{
int nSprite;
BloodStatIterator it(kStatItem);
while (auto actor = it.Next())
{

View file

@ -382,37 +382,39 @@ void GibThing(spritetype *pSprite, GIBTHING *pGThing, CGibPosition *pPos, CGibVe
getzsofslope(nSector, x, y, &ceilZ, &floorZ);
int dz1 = floorZ-z;
int dz2 = z-ceilZ;
spritetype *pGib = &actSpawnThing(nSector, x, y, z, pGThing->type)->s();
auto gibactor = actSpawnThing(nSector, x, y, z, pGThing->type);
if (!gibactor) return;
spritetype *pGib = &gibactor->s();
assert(pGib != NULL);
if (pGThing->Kills > -1)
pGib->picnum = pGThing->Kills;
if (pVel)
{
xvel[pGib->index] = pVel->vx+Random2(pGThing->atc);
yvel[pGib->index] = pVel->vy+Random2(pGThing->atc);
zvel[pGib->index] = pVel->vz-Random(pGThing->at10);
gibactor->xvel() = pVel->vx+Random2(pGThing->atc);
gibactor->yvel() = pVel->vy+Random2(pGThing->atc);
gibactor->zvel() = pVel->vz-Random(pGThing->at10);
}
else
{
xvel[pGib->index] = Random2((pGThing->atc<<18)/120);
yvel[pGib->index] = Random2((pGThing->atc<<18)/120);
gibactor->xvel() = Random2((pGThing->atc<<18)/120);
gibactor->yvel() = Random2((pGThing->atc<<18)/120);
switch (pSprite->cstat&48)
{
case 16:
zvel[pGib->index] = Random2((pGThing->at10<<18)/120);
gibactor->zvel() = Random2((pGThing->at10<<18)/120);
break;
default:
if (dz2 < dz1 && dz2 < 0x4000)
{
zvel[pGib->index] = 0;
gibactor->zvel() = 0;
}
else if (dz2 > dz1 && dz1 < 0x4000)
{
zvel[pGib->index] = -(int)Random((pGThing->at10<<18)/120);
gibactor->zvel() = -(int)Random((pGThing->at10<<18)/120);
}
else
{
zvel[pGib->index] = Random2((pGThing->at10<<18)/120);
gibactor->zvel() = Random2((pGThing->at10<<18)/120);
}
break;
}

View file

@ -578,8 +578,6 @@ void nnExtInitModernStuff(bool bSaveLoad)
// add in list of physics affected sprites
if (pXSprite->physAttr != 0)
{
//xvel[pSprite->index] = yvel[pSprite->index] = zvel[pSprite->index] = 0;
gPhysSpritesList[gPhysSpritesCount++] = &bloodActors[pSprite->index]; // add sprite index
getSpriteMassBySize(pSprite); // create mass cache
}
@ -1329,53 +1327,53 @@ void nnExtProcessSuperSprites() {
continue;
}
int idx = pDebris->index;
int nDebris = pDebris->index;
XSECTOR* pXSector = (sector[pDebris->sectnum].extra >= 0) ? &xsector[sector[pDebris->sectnum].extra] : NULL;
viewBackupSpriteLoc(idx, pDebris);
viewBackupSpriteLoc(nDebris, pDebris);
bool uwater = false;
int mass = debrisactor->spriteMass.mass;
int airVel = debrisactor->spriteMass.airVel;
int top, bottom;
GetSpriteExtents(pDebris, &top, &bottom);
int top, bottom;
GetSpriteExtents(pDebris, &top, &bottom);
if (pXSector != NULL) {
if ((uwater = pXSector->Underwater) != 0) airVel <<= 6;
if (pXSector->panVel != 0 && getflorzofslope(pDebris->sectnum, pDebris->x, pDebris->y) <= bottom) {
int angle = pXSector->panAngle; int speed = 0;
if (pXSector->panAlways || pXSector->state || pXSector->busy) {
speed = pXSector->panVel << 9;
if (!pXSector->panAlways && pXSector->busy)
speed = MulScale(speed, pXSector->busy, 16);
}
if (sector[pDebris->sectnum].floorstat & 64)
angle = (angle + GetWallAngle(sector[pDebris->sectnum].wallptr) + 512) & 2047;
int dx = MulScale(speed, Cos(angle), 30);
int dy = MulScale(speed, Sin(angle), 30);
xvel[idx] += dx;
yvel[idx] += dy;
speed = pXSector->panVel << 9;
if (!pXSector->panAlways && pXSector->busy)
speed = MulScale(speed, pXSector->busy, 16);
}
if (sector[pDebris->sectnum].floorstat & 64)
angle = (angle + GetWallAngle(sector[pDebris->sectnum].wallptr) + 512) & 2047;
int dx = MulScale(speed, Cos(angle), 30);
int dy = MulScale(speed, Sin(angle), 30);
debrisactor->xvel() += dx;
debrisactor->yvel() += dy;
}
}
actAirDrag(&bloodActors[pDebris->index], airVel);
if (pXDebris->physAttr & kPhysDebrisTouch) {
PLAYER* pPlayer = NULL;
for (int a = connecthead; a != -1; a = connectpoint2[a]) {
pPlayer = &gPlayer[a];
if ((gSpriteHit[pPlayer->pSprite->extra].hit & 0xc000) == 0xc000 && (gSpriteHit[pPlayer->pSprite->extra].hit & 0x3fff) == idx) {
if ((gSpriteHit[pPlayer->pSprite->extra].hit & 0xc000) == 0xc000 && (gSpriteHit[pPlayer->pSprite->extra].hit & 0x3fff) == nDebris) {
int nSpeed = approxDist(xvel[pPlayer->pSprite->index], yvel[pPlayer->pSprite->index]);
nSpeed = ClipLow(nSpeed - MulScale(nSpeed, mass, 6), 0x9000 - (mass << 3));
xvel[idx] += MulScale(nSpeed, Cos(pPlayer->pSprite->ang), 30);
yvel[idx] += MulScale(nSpeed, Sin(pPlayer->pSprite->ang), 30);
debrisactor->xvel() += MulScale(nSpeed, Cos(pPlayer->pSprite->ang), 30);
debrisactor->yvel() += MulScale(nSpeed, Sin(pPlayer->pSprite->ang), 30);
gSpriteHit[pDebris->extra].hit = pPlayer->pSprite->index | 0xc000;
@ -1384,25 +1382,25 @@ void nnExtProcessSuperSprites() {
}
if (pXDebris->physAttr & kPhysGravity) pXDebris->physAttr |= kPhysFalling;
if ((pXDebris->physAttr & kPhysFalling) || xvel[idx] || yvel[idx] || zvel[idx] || velFloor[pDebris->sectnum] || velCeil[pDebris->sectnum])
if ((pXDebris->physAttr & kPhysFalling) || debrisactor->xvel() || debrisactor->yvel() || debrisactor->zvel() || velFloor[pDebris->sectnum] || velCeil[pDebris->sectnum])
debrisMove(i);
if (xvel[idx] || yvel[idx])
pXDebris->goalAng = getangle(xvel[idx], yvel[idx]) & 2047;
if (debrisactor->xvel() || debrisactor->yvel())
pXDebris->goalAng = getangle(debrisactor->xvel(), debrisactor->yvel()) & 2047;
int ang = pDebris->ang & 2047;
if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKillActor(debrisactor, kCallbackEnemeyBubble);
else if (Chance(0x1000 - mass)) {
if (zvel[idx] > 0x100) debrisBubble(idx);
if (debrisactor->zvel() > 0x100) debrisBubble(nDebris);
if (ang == pXDebris->goalAng) {
pXDebris->goalAng = (pDebris->ang + Random3(kAng60)) & 2047;
debrisBubble(idx);
debrisBubble(nDebris);
}
}
int angStep = ClipLow(mulscale8(1, ((abs(xvel[idx]) + abs(yvel[idx])) >> 5)), (uwater) ? 1 : 0);
int angStep = ClipLow(mulscale8(1, ((abs(debrisactor->xvel()) + abs(debrisactor->yvel())) >> 5)), (uwater) ? 1 : 0);
if (ang < pXDebris->goalAng) pDebris->ang = ClipHigh(ang + angStep, pXDebris->goalAng);
else if (ang > pXDebris->goalAng) pDebris->ang = ClipLow(ang - angStep, pXDebris->goalAng);

View file

@ -724,7 +724,7 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->throwPower = 0;
pPlayer->deathTime = 0;
pPlayer->nextWeapon = kWeapNone;
xvel[pSprite->index] = yvel[pSprite->index] = zvel[pSprite->index] = 0;
actor->xvel() = actor->yvel() = actor->zvel() = 0;
pInput->avel = 0;
pInput->actions = 0;
pInput->fvel = 0;