- handle the rest of the collision code.

This commit is contained in:
Christoph Oelckers 2021-11-14 17:16:16 +01:00
parent bd3b94f93e
commit 705c89de68
9 changed files with 110 additions and 99 deletions

View file

@ -236,9 +236,8 @@ void aiProcess() {
{
SPRITE& spr = actor->s();
i = actor->GetSpriteIndex();
short movestat = (short)movesprite((short)i, (bcos(spr.ang) * TICSPERFRAME) << 3,
Collision moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
auto moveStat = Collision(movestat);
if (zr_florz > spr.z + (48 << 8)) {
SetActorPos(actor, &spr.pos);
moveStat.type = -1;
@ -445,31 +444,31 @@ Collision aimove(DWHActor* actor)
int oz = spr.z;
// short osect = spr.sectnum;
int movestat = movesprite(actor->GetSpriteIndex(), (bcos(spr.ang) * TICSPERFRAME) << 3,
Collision moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, CLIFFCLIP);
if (((zr_florz - oz) >> 4) > tileHeight(spr.picnum) + (spr.yrepeat << 2)
|| (movestat & kHitTypeMask) == kHitWall) {
|| moveStat.type == kHitWall) {
SetActorPos(actor, ox, oy, oz);
if ((movestat & kHitTypeMask) != kHitWall) {
if (moveStat.type != kHitWall) {
if (isWh2())
spr.z += WH2GRAVITYCONSTANT;
else
spr.z += GRAVITYCONSTANT;
return 16384 | zr_florhit;
return moveStat.setSector(zr_florhit);
}
}
spr.z = zr_florz;
return movestat;
return moveStat;
}
Collision aifly(DWHActor* actor) {
SPRITE& spr = actor->s();
int movestat = movesprite(actor->GetSpriteIndex(), (bcos(spr.ang) * TICSPERFRAME) << 3,
Collision moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, CLIFFCLIP);
spr.z -= TICSPERFRAME << 8;
@ -482,7 +481,7 @@ Collision aifly(DWHActor* actor) {
if (spr.z - (tileHeight(spr.picnum) << 7) < zr_ceilz)
spr.z = zr_ceilz + (tileHeight(spr.picnum) << 7);
return Collision(movestat);
return moveStat;
}
@ -934,12 +933,12 @@ void attack(PLAYER& plr, int const i) {
int checkmove(DWHActor* actor, int dax, int day) {
auto& spr = actor->s();
int movestat = movesprite(actor->GetSpriteIndex(), dax, day, 0, 4 << 8, 4 << 8, CLIFFCLIP);
Collision moveStat = movesprite(actor, dax, day, 0, 4 << 8, 4 << 8, CLIFFCLIP);
if (movestat != 0) // (moveStat.type != kHitNone)
if (moveStat.type != kHitNone)
spr.ang = (short)((spr.ang + TICSPERFRAME) & 2047);
return movestat;
return moveStat.legacyVal;
}
boolean checkdist(PLAYER& plr, DWHActor* actor) {

View file

@ -559,7 +559,7 @@ void gonzoProcess(PLAYER& plr)
}
}
short movestat;
Collision moveStat;
it.Reset(AMBUSH);
while (auto actor = it.Next())
{
@ -570,7 +570,7 @@ void gonzoProcess(PLAYER& plr)
case 1: // forward
spr.zvel += TICSPERFRAME << 3;
movestat = (short)movesprite(i, (bcos(spr.ang) * TICSPERFRAME) << 3,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, spr.zvel, 4 << 8, 4 << 8, 0);
spr.lotag -= TICSPERFRAME;
@ -580,19 +580,19 @@ void gonzoProcess(PLAYER& plr)
changespritestat(i, LAND);
}
if ((movestat & 0xc000) == 49152) { // Bullet hit a sprite
int k = (movestat & 4095);
if (moveStat.type== kHitSprite) { // Bullet hit a sprite
int k = moveStat.actor->GetSpriteIndex();
for (int j = 0; j < 15; j++) {
shards(k, 1);
}
damageactor(plr, movestat, i);
damageactor(plr, moveStat.actor->GetSpriteIndex(), i);
}
break;
case 2: // fall
spr.zvel += TICSPERFRAME << 4;
movestat = (short)movesprite(i, (bcos(spr.ang) * TICSPERFRAME) << 1,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 1,
(bsin(spr.ang) * TICSPERFRAME) << 1, spr.zvel, 4 << 8, 4 << 8, 0);
spr.lotag -= TICSPERFRAME;
@ -607,7 +607,7 @@ void gonzoProcess(PLAYER& plr)
spr.zvel -= TICSPERFRAME << 4;
movestat = (short)movesprite(i, (bcos(spr.ang) * TICSPERFRAME) << 3,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, spr.zvel, 4 << 8, 4 << 8, 0);
spr.lotag -= TICSPERFRAME;

View file

@ -458,10 +458,11 @@ static void checkexplgron(PLAYER& plr, DWHActor* actor)
static void throwhalberd(int s) {
int j = insertsprite(sprite[s].sectnum, JAVLIN);
auto spawnedactor = &whActors[j];
if (j == -1)
return;
SPRITE& spr = sprite[j];
SPRITE& spr = spawnedactor->s();
spr.x = sprite[s].x;
spr.y = sprite[s].y;
spr.z = sprite[s].z - (40 << 8);
@ -487,7 +488,7 @@ static void throwhalberd(int s) {
spr.cstat = 0;
int daz = (((spr.zvel) * TICSPERFRAME) >> 3);
movesprite((short)j, (bcos(spr.extra) * TICSPERFRAME) << 7,
movesprite(spawnedactor, (bcos(spr.extra) * TICSPERFRAME) << 7,
(bsin(spr.extra) * TICSPERFRAME) << 7, daz, 4 << 8, 4 << 8, 1);
spr.cstat = 21;
spr.backuploc();

View file

@ -1756,7 +1756,8 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
}
if (pHitInfo.hitwall > 0 && pHitInfo.hitsprite > 0) {
j = insertsprite(pHitInfo.hitsect, FX);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
spawned.x = pHitInfo.hitx;
spawned.y = pHitInfo.hity;
spawned.z = pHitInfo.hitz + (8 << 8);
@ -1773,7 +1774,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spawned.owner = sprite[plr.spritenum].owner;
spawned.lotag = 32;
spawned.hitag = 0;
movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3,
movesprite(spawnedactor, (bcos(spawned.ang) * TICSPERFRAME) << 3,
(bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
spawned.backuploc();
}
@ -1955,7 +1956,8 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (plr.weapon[plr.currweapon] == 3) {
j = insertsprite(plr.sector, MISSILE);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
throwpikesprite[throwpikecnt] = j;
spawned.x = plr.x;
spawned.y = plr.y;
@ -1980,7 +1982,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spawned.lotag = 1024;
spawned.hitag = 0;
spawned.pal = 0;
movesprite((short) j, (bcos(spawned.extra) * TICSPERFRAME) << 3,
movesprite(spawnedactor, (bcos(spawned.extra) * TICSPERFRAME) << 3,
(bsin(spawned.extra) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
setsprite((short) j, spawned.x, spawned.y, spawned.z);
spawned.backuploc();
@ -2053,7 +2055,8 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
if (plr.weapon[plr.currweapon] == 3) {
j = insertsprite(plr.sector, MISSILE);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
throwpikesprite[throwpikecnt] = j;
spawned.x = plr.x;
spawned.y = plr.y;
@ -2075,13 +2078,14 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spawned.lotag = 1024;
spawned.hitag = 0;
spawned.pal = 0;
movesprite((short) j, (bcos(spawned.extra) * TICSPERFRAME) << 3,
movesprite(spawnedactor, (bcos(spawned.extra) * TICSPERFRAME) << 3,
(bsin(spawned.extra) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
setsprite((short) j, spawned.x, spawned.y, spawned.z);
spawned.backuploc();
} else {
j = insertsprite(plr.sector, MISSILE);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
throwpikesprite[throwpikecnt] = j;
spawned.x = plr.x;
spawned.y = plr.y;
@ -2141,7 +2145,8 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
}
j = insertsprite(plr.sector, MISSILE);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
spawned.x = plr.x;
spawned.y = plr.y;
@ -2168,7 +2173,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
spawned.hitag = 0;
spawned.clipdist = 48;
movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3,
movesprite(spawnedactor, (bcos(spawned.ang) * TICSPERFRAME) << 3,
(bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
setsprite(j, spawned.x, spawned.y, spawned.z);
spawned.backuploc();
@ -2182,7 +2187,9 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
}
j = insertsprite(plr.sector, MISSILE);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
spawned.x = plr.x;
spawned.y = plr.y;
spawned.z = plr.z + (8 << 8);
@ -2211,7 +2218,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) {
// dax=bcos(spawned.ang, -6);
// day=bsin(spawned.ang, -6);
movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3,
movesprite(spawnedactor, (bcos(spawned.ang) * TICSPERFRAME) << 3,
(bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
setsprite(j, spawned.x, spawned.y, spawned.z);
spawned.backuploc();

View file

@ -196,7 +196,7 @@ void explosion2(int i, int x, int y, int z, int owner);
void trailingsmoke(DWHActor* i, boolean ball);
void icecubes(int i, int x, int y, int z, int owner);
boolean damageactor(PLAYER& plr, int hitobject, short i);
int movesprite(short spritenum, int dx, int dy, int dz, int ceildist, int flordist, int cliptype);
Collision movesprite(DWHActor*, int dx, int dy, int dz, int ceildist, int flordist, int cliptype);
void trowajavlin(int s);
void spawnhornskull(short i);
void spawnapentagram(int sn);

View file

@ -11,7 +11,7 @@ void animateobjs(PLAYER& plr) {
boolean hitdamage = false;
short osectnum = 0;
int dax, day, daz = 0, j, k;
short movestat = 0;
Collision moveStat = 0;
short startwall, endwall;
@ -29,17 +29,17 @@ void animateobjs(PLAYER& plr) {
switch (spr.extra) {
case 1:
spr.zvel += TICSPERFRAME << 3;
movestat = movesprite((short) i, (bcos(spr.ang) * TICSPERFRAME) << 3,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, spr.zvel, 4 << 8, 4 << 8, 0);
break;
case 2:
spr.zvel += TICSPERFRAME << 5;
movestat = movesprite((short) i, (bcos(spr.ang) * TICSPERFRAME) << 1,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 1,
(bsin(spr.ang) * TICSPERFRAME) << 1, spr.zvel, 4 << 8, 4 << 8, 0);
break;
case 3:
spr.zvel -= TICSPERFRAME << 5;
movestat = movesprite((short) i, (bcos(spr.ang) * TICSPERFRAME) << 2,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 2,
(bsin(spr.ang) * TICSPERFRAME) << 2, spr.zvel, 4 << 8, 4 << 8, 0);
if (spr.lotag < 0) {
spr.lotag = 30;
@ -67,7 +67,7 @@ void animateobjs(PLAYER& plr) {
daz = spr.zvel -= TICSPERFRAME << 4;
spr.ang = (short) ((spr.ang + (TICSPERFRAME << 2)) & 2047);
movesprite((short) i, (bcos(spr.ang) * TICSPERFRAME) << 3,
movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 1);
if (osectnum != spr.sectnum) {
@ -99,7 +99,7 @@ void animateobjs(PLAYER& plr) {
daz = spr.zvel += TICSPERFRAME << 4;
spr.ang = (short) ((spr.ang + (TICSPERFRAME << 2)) & 2047);
movesprite((short) i, (bcos(spr.ang) * TICSPERFRAME) << 3,
movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 1);
if (osectnum != spr.sectnum) {
@ -130,7 +130,7 @@ void animateobjs(PLAYER& plr) {
daz = 0;
spr.ang = (short) ((spr.ang + (TICSPERFRAME << 2)) & 2047);
movesprite((short) i, (bcos(spr.ang) * TICSPERFRAME) << 3,
movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 1);
if (osectnum != spr.sectnum) {
@ -295,7 +295,7 @@ void animateobjs(PLAYER& plr) {
for (k = startwall; k <= endwall; k++) {
wall[k].shade = (byte) ((wall[k].shade + j) >> 1);
}
movestat = movesprite((short) i,
moveStat = movesprite(actor,
(plr.angle.ang.bcos() << TICSPERFRAME) << 8,
(plr.angle.ang.bsin() << TICSPERFRAME) << 8, 0, 4 << 8, 4 << 8, 0);
@ -446,11 +446,11 @@ void animateobjs(PLAYER& plr) {
spr.extra = 1;
spr.lotag = 512;
} else {
movestat = movesprite((short) i,
moveStat = movesprite(actor,
(bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
SetActorPos(actor, &spr.pos);
if (movestat != 0)// moveStat.type != kHitNone)
if (moveStat.type != kHitNone)
spr.ang = (short) (krand() & 2047);
}
break;
@ -463,11 +463,11 @@ void animateobjs(PLAYER& plr) {
} else {
spr.z -= TICSPERFRAME << 4;
spr.ang = (short) ((spr.ang + (TICSPERFRAME << 2)) & 2047);
movestat = movesprite((short) i,
moveStat = movesprite(actor,
(bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
SetActorPos(actor, &spr.pos);
if (movestat != 0)// moveStat.type != kHitNone)
if (moveStat.type != kHitNone)
spr.ang = (short) (krand() & 2047);
}
break;
@ -479,18 +479,18 @@ void animateobjs(PLAYER& plr) {
DeleteActor(actor);
continue;
} else {
movestat = movesprite((short) i,
moveStat = movesprite(actor,
(bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
SetActorPos(actor, &spr.pos);
if ((movestat & 0xc000) == 16384) {// Hits a ceiling / floor
if (moveStat.type == kHitSector) {// Hits a ceiling / floor
if (i == lastbat) {
soundEngine->StopSound(CHAN_BAT);
}
DeleteActor(actor);
continue;
}
if (movestat != 0)// moveStat.type != kHitNone)
if (moveStat.type != kHitNone)
spr.ang = (short) (krand() & 2047);
}
break;
@ -716,7 +716,7 @@ void animateobjs(PLAYER& plr) {
if (spr.z < zr_florz)
daz = spr.zvel += (TICSPERFRAME << 9);
movestat = movesprite(i, (bcos(spr.ang) * TICSPERFRAME) << 3,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 0);
SetActorPos(actor, &spr.pos);
@ -727,7 +727,7 @@ void animateobjs(PLAYER& plr) {
startredflash(50);
}
if ((movestat & 0xc0000) == 16384) {
if (moveStat.type == kHitSector) {
if (sector[spr.sectnum].floorpicnum == WATER) {
makemonstersplash(SPLASHAROO, i);
}
@ -762,7 +762,7 @@ void animateobjs(PLAYER& plr) {
if (spr.z < zr_florz)
daz = spr.zvel += (TICSPERFRAME << 5);
movestat = movesprite(i, (bcos(spr.ang) * TICSPERFRAME) << 3,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 0);
SetActorPos(actor, &spr.pos);
@ -776,15 +776,15 @@ void animateobjs(PLAYER& plr) {
continue;
}
if ((movestat & 0xc000) == 16384) {
if (moveStat.type == kHitSector) {
SetNewStatus(actor, BROKENVASE);
continue;
}
if ((movestat & 0xc000) == 49152) { // Bullet hit a sprite
if (moveStat.type == kHitSprite) { // Bullet hit a sprite
if (spr.owner != movestat) {
hitdamage = damageactor(plr, movestat, i);
if (spr.owner != moveStat.actor->GetSpriteIndex()) {
hitdamage = damageactor(plr, moveStat.actor->GetSpriteIndex(), i);
if (hitdamage) {
SetNewStatus(actor, BROKENVASE);
continue;
@ -811,12 +811,12 @@ void animateobjs(PLAYER& plr) {
daz = spr.zvel += (TICSPERFRAME << 1);
// clip type was 1
movestat = movesprite(i, (bcos(spr.ang) * TICSPERFRAME) << 3,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 0);
SetActorPos(actor, &spr.pos);
if (spr.lotag < 0 || (movestat & 0xc000) == 32768) {
if (spr.lotag < 0 || moveStat.type == kHitWall) {
spr.lotag = 0;
ChangeActorStat(actor, 0);
if (spr.z < sector[spr.sectnum].floorz) {
@ -958,25 +958,25 @@ void animateobjs(PLAYER& plr) {
if (spr.picnum == THROWPIKE) {
spr.cstat = 0;
movestat = movesprite((short) i,
moveStat = movesprite(actor,
(bcos(spr.extra) * TICSPERFRAME) << 6,
(bsin(spr.extra) * TICSPERFRAME) << 6, daz, 4 << 8, 4 << 8, 1);
spr.cstat = 21;
} else {
movestat = movesprite((short) i,
moveStat = movesprite(actor,
(bcos(spr.ang) * TICSPERFRAME) << 6, // was 3
(bsin(spr.ang) * TICSPERFRAME) << 6, // was 3
daz, 4 << 8, 4 << 8, 1);
}
if (movestat != 0 && spr.picnum == MONSTERBALL)
if (moveStat.type != kHitNone && spr.picnum == MONSTERBALL)
if (spr.owner == sprite[plr.spritenum].owner) {
explosion2(i, spr.x, spr.y, spr.z, i);
} else {
explosion(i, spr.x, spr.y, spr.z, i);
}
if ((movestat & 0xc000) == 16384) { // Hits a ceiling / floor
if (moveStat.type == kHitSector) { // Hits a ceiling / floor
if (spr.picnum == THROWPIKE) {
spr.picnum++;
spr.detail = WALLPIKETYPE;
@ -986,7 +986,7 @@ void animateobjs(PLAYER& plr) {
}
DeleteActor(actor);
continue;
} else if ((movestat & 0xc000) == 32768) { // hit a wall
} else if (moveStat.type == kHitWall) { // hit a wall
if (spr.picnum == MONSTERBALL) {
if (spr.owner == sprite[plr.spritenum].owner)
@ -1004,9 +1004,9 @@ void animateobjs(PLAYER& plr) {
DeleteActor(actor);
continue;
} else if (spr.lotag < 0 && spr.picnum == PLASMA)
movestat = 1;
moveStat.type = -1;
if ((movestat & 0xc000) == 49152) { // Bullet hit a sprite
if (moveStat.type == kHitSprite) { // Bullet hit a sprite
if (spr.picnum == MONSTERBALL) {
if (spr.owner == sprite[plr.spritenum].owner)
explosion2(i, spr.x, spr.y, spr.z, i);
@ -1014,15 +1014,15 @@ void animateobjs(PLAYER& plr) {
explosion(i, spr.x, spr.y, spr.z, i);
}
if (spr.owner != movestat)
hitdamage = damageactor(plr, movestat, i);
if (spr.owner != moveStat.actor->GetSpriteIndex())
hitdamage = damageactor(plr, moveStat.actor->GetSpriteIndex(), i);
if (hitdamage) {
DeleteActor(actor);
continue;
}
}
if (movestat != 0 || spr.lotag < 0) {
if (moveStat.type != kHitNone || spr.lotag < 0) {
int pic = spr.picnum;
switch (pic) {
case PLASMA:
@ -1076,7 +1076,7 @@ void animateobjs(PLAYER& plr) {
spr.cstat = 0;
movestat = movesprite(i, (bcos(spr.extra) * TICSPERFRAME) << 6,
moveStat = movesprite(actor, (bcos(spr.extra) * TICSPERFRAME) << 6,
(bsin(spr.extra) * TICSPERFRAME) << 6, daz, 4 << 8, 4 << 8, 0);
if (spr.picnum == WALLARROW || spr.picnum == THROWHALBERD)
@ -1086,7 +1086,7 @@ void animateobjs(PLAYER& plr) {
else
spr.cstat = 0x15;
if ((movestat & 0xc000) == 16384) { // Hits a ceiling / floor
if (moveStat.type == kHitSector) { // Hits a ceiling / floor
// EG Bugfix 17 Aug 2014: Since the game thinks that a javlin hitting the
// player's pike axe is a
// floor/ceiling hit rather than a sprite hit, we'll need to check if the JAVLIN
@ -1102,7 +1102,7 @@ void animateobjs(PLAYER& plr) {
ChangeActorStat(actor, INACTIVE); // EG Note: RAF.H gives this a nice name, so use it
}
continue;
} else if ((movestat & 0xc000) == 32768) { // hit a wall
} else if (moveStat.type == kHitWall) { // hit a wall
if (spr.picnum == THROWPIKE) {
spr.picnum++;
@ -1113,10 +1113,10 @@ void animateobjs(PLAYER& plr) {
continue;
}
if ((movestat - 49152) >= 0 || (movestat & 0xc000) == 49152) { // Bullet hit a sprite
j = (movestat & 4095); // j is the spritenum that the bullet (spritenum i) hit
if (moveStat.type == kHitSprite) { // Bullet hit a sprite
j = moveStat.actor->GetSpriteIndex(); // j is the spritenum that the bullet (spritenum i) hit
hitdamage = damageactor(plr, movestat, i);
hitdamage = damageactor(plr, j, i);
if (hitdamage)
continue;
@ -1132,7 +1132,7 @@ void animateobjs(PLAYER& plr) {
}
}
if (movestat != 0) {
if (moveStat.type != kHitNone) {
DeleteActor(actor);
}
}
@ -1149,7 +1149,7 @@ void animateobjs(PLAYER& plr) {
dax = spr.xvel >> 3;
day = spr.yvel >> 3;
daz = spr.zvel -= TICSPERFRAME << 2;
movestat = movesprite(i, (bcos(spr.ang) * TICSPERFRAME) << 3,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 1);
SetActorPos(actor, &spr.pos);
if (spr.extra == 0) {
@ -1190,9 +1190,9 @@ void animateobjs(PLAYER& plr) {
yvel >>= 1;
}
movestat = movesprite((short) i, xvel, yvel, daz, 4 << 8, 4 << 8, 1);
moveStat = movesprite(actor, xvel, yvel, daz, 4 << 8, 4 << 8, 1);
if ((movestat & 0xc000) == 16384) {
if (moveStat.type == kHitSector) {
if (sector[spr.sectnum].floorpicnum == WATER || sector[spr.sectnum].floorpicnum == SLIME
|| sector[spr.sectnum].floorpicnum == FLOORMIRROR) {
if (spr.picnum == FISH)
@ -1213,7 +1213,7 @@ void animateobjs(PLAYER& plr) {
SetNewStatus(actor, BLOOD);
}
}
} else if ((movestat & 0xc000) == 32768) {
} else if (moveStat.type == kHitWall) {
if (spr.picnum >= BONECHUNK1 && spr.picnum <= BONECHUNKEND) {
DeleteActor(actor);
} else {
@ -1276,9 +1276,9 @@ void animateobjs(PLAYER& plr) {
day = 0;
daz = spr.zvel += TICSPERFRAME << 1;
daz = (((spr.zvel) * TICSPERFRAME) << 1);
movestat = movesprite(i, dax, day, daz, 4 << 8, 4 << 8, 1);
moveStat = movesprite(actor, dax, day, daz, 4 << 8, 4 << 8, 1);
if ((movestat & 0xc000) == 16384) {
if (moveStat.type == kHitSector) {
spr.lotag = 1200;
SetNewStatus(actor, BLOOD);
}
@ -1476,7 +1476,7 @@ void animateobjs(PLAYER& plr) {
dax = ((((int) spr.xvel) * TICSPERFRAME) >> 3);
day = ((((int) spr.yvel) * TICSPERFRAME) >> 3);
daz = (((int) spr.zvel) * TICSPERFRAME);
movestat = movesprite((short) i, dax, day, daz, 4 << 8, 4 << 8, 1);
moveStat = movesprite(actor, dax, day, daz, 4 << 8, 4 << 8, 1);
SetActorPos(actor, &spr.pos);
}
@ -1485,12 +1485,12 @@ void animateobjs(PLAYER& plr) {
daz = spr.zvel += TICSPERFRAME << 4;
movestat = movesprite((short) i, (bcos(spr.ang) * TICSPERFRAME) << 3,
moveStat = movesprite(actor, (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 1);
}
if (spr.lotag < 0 || movestat != 0)// moveStat.type != kHitNone)
if (spr.lotag < 0 || moveStat.type != kHitNone)
if (spr.picnum == PLASMA || spr.picnum == EXPLOSION || spr.picnum == FIREBALL
|| spr.picnum == MONSTERBALL || spr.picnum == FATSPANK
|| spr.picnum == ICECUBE) {
@ -1499,7 +1499,7 @@ void animateobjs(PLAYER& plr) {
}
if (spr.z + (8 << 8) >= sector[spr.sectnum].floorz && spr.picnum == ICECUBE
|| movestat != 0)// moveStat.type != kHitNone)
|| moveStat.type != kHitNone)
{
spr.z = sector[spr.sectnum].floorz;
ChangeActorStat(actor, 0);

View file

@ -800,7 +800,9 @@ void thesplash() {
void makeasplash(int picnum, PLAYER& plr) {
int j = insertsprite(plr.sector, MASPLASH);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
spawned.x = plr.x;
spawned.y = plr.y;
spawned.z = sector[plr.sector].floorz + (tileHeight(picnum) << 8);
@ -827,7 +829,7 @@ void makeasplash(int picnum, PLAYER& plr) {
break;
}
movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3,
movesprite(spawnedactor, (bcos(spawned.ang) * TICSPERFRAME) << 3,
(bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
spawned.backuploc();
}
@ -996,7 +998,8 @@ void warpfxsprite(int s) {
PLAYER& plr = player[pyrn];
int j = insertsprite(sprite[s].sectnum, WARPFX);
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
spawned.x = sprite[s].x;
spawned.y = sprite[s].y;
@ -1030,7 +1033,7 @@ void warpfxsprite(int s) {
int daz = (((spawned.zvel) * TICSPERFRAME) >> 3);
movesprite((short) j, (bcos(daang) * TICSPERFRAME) << 3,
movesprite(spawnedactor, (bcos(daang) * TICSPERFRAME) << 3,
(bsin(daang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 1);
spawned.backuploc();
}

View file

@ -1730,15 +1730,16 @@ boolean damageactor(PLAYER& plr, int hitobject, short const i)
return false;
}
int movesprite(short spritenum, int dx, int dy, int dz, int ceildist, int flordist, int cliptype) {
Collision movesprite(DWHActor* actor, int dx, int dy, int dz, int ceildist, int flordist, int cliptype) {
Collision coll;
int zoffs;
int retval;
int tempshort, dasectnum;
SPRITE& spr = sprite[spritenum];
SPRITE& spr = actor->s();
if (spr.statnum == MAXSTATUS)
return (-1);
return coll.setNone();
int dcliptype = 0;
switch (cliptype) {
@ -1769,7 +1770,7 @@ int movesprite(short spritenum, int dx, int dy, int dz, int ceildist, int flordi
spr.y = pos.y;
if ((dasectnum != spr.sectnum) && (dasectnum >= 0))
changespritesect(spritenum, dasectnum);
changespritesect(actor->GetSpriteIndex(), dasectnum);
// Set the blocking bit to 0 temporarly so getzrange doesn't pick up
// its own sprite
@ -1781,11 +1782,11 @@ int movesprite(short spritenum, int dx, int dy, int dz, int ceildist, int flordi
int daz = spr.z + zoffs + dz;
if ((daz <= zr_ceilz) || (daz > zr_florz)) {
if (retval != 0)
return (retval);
return (16384 | dasectnum);
return Collision(retval);
return coll.setSector(dasectnum);
}
spr.z = (daz - zoffs);
return (retval);
return Collision(retval);
}
void trowajavlin(int s) {

View file

@ -347,9 +347,9 @@ void chunksofmeat(PLAYER& plr, DWHActor* hitActor, int hitx, int hity, int hitz,
newchunk = 0;
j = insertsprite(hitsect, CHUNKOMEAT);
if(j == -1)
return;
auto& spawned = sprite[j];
auto spawnedactor = &whActors[j];
auto& spawned = spawnedactor->s();
spawned.x = hitx;
spawned.y = hity;
spawned.z = hitz;
@ -433,7 +433,7 @@ void chunksofmeat(PLAYER& plr, DWHActor* hitActor, int hitx, int hity, int hitz,
spawned.lotag = 512;
spawned.hitag = 0;
spawned.pal = 0;
movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3,
movesprite(spawnedactor, (bcos(spawned.ang) * TICSPERFRAME) << 3,
(bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
spawned.backuploc();
}