- aimove + aifly return value.

This takes care of most checks of Build collision values.
This commit is contained in:
Christoph Oelckers 2021-11-14 16:42:37 +01:00
parent 47436c58d7
commit 44c95673a1
25 changed files with 217 additions and 211 deletions

View file

@ -238,9 +238,10 @@ void aiProcess() {
i = actor->GetSpriteIndex();
short movestat = (short)movesprite((short)i, (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 = 1;
moveStat.type = -1;
}
else {
spr.z = zr_florz;
@ -267,8 +268,8 @@ void aiProcess() {
newstatus(i, CHASE);
}
}
else if (movestat != 0) {
if ((movestat & 0xc000) == 32768) { // hit a wall
else if (moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) { // hit a wall
actoruse(i);
}
newstatus(i, FINDME);
@ -436,35 +437,37 @@ void aiProcess() {
}
}
int aimove(short i) {
int ox = sprite[i].x;
int oy = sprite[i].y;
int oz = sprite[i].z;
// short osect = sprite[i].sectnum;
Collision aimove(DWHActor* actor)
{
auto& spr = actor->s();
int ox = spr.x;
int oy = spr.y;
int oz = spr.z;
// short osect = spr.sectnum;
int movestate = movesprite(i, (bcos(sprite[i].ang) * TICSPERFRAME) << 3,
(bsin(sprite[i].ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, CLIFFCLIP);
int movestate = movesprite(actor->GetSpriteIndex(), (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, CLIFFCLIP);
if (((zr_florz - oz) >> 4) > tileHeight(sprite[i].picnum) + (sprite[i].yrepeat << 2)
if (((zr_florz - oz) >> 4) > tileHeight(spr.picnum) + (spr.yrepeat << 2)
|| (movestate & kHitTypeMask) == kHitWall) {
setsprite(i, ox, oy, oz);
SetActorPos(actor, ox, oy, oz);
if ((movestate & kHitTypeMask) != kHitWall) {
if (isWh2())
sprite[i].z += WH2GRAVITYCONSTANT;
spr.z += WH2GRAVITYCONSTANT;
else
sprite[i].z += GRAVITYCONSTANT;
spr.z += GRAVITYCONSTANT;
return 16384 | zr_florhit;
}
}
sprite[i].z = zr_florz;
spr.z = zr_florz;
return movestate;
}
int aifly(DWHActor* actor) {
Collision aifly(DWHActor* actor) {
SPRITE& spr = actor->s();
int movestate = movesprite(actor->GetSpriteIndex(), (bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, CLIFFCLIP);
@ -479,9 +482,10 @@ int aifly(DWHActor* actor) {
if (spr.z - (tileHeight(spr.picnum) << 7) < zr_ceilz)
spr.z = zr_ceilz + (tileHeight(spr.picnum) << 7);
return movestate;
return Collision(movestate);
}
void aisearch(PLAYER& plr, DWHActor* actor, boolean fly) {
SPRITE& spr = actor->s();
spr.lotag -= TICSPERFRAME;
@ -493,11 +497,11 @@ void aisearch(PLAYER& plr, DWHActor* actor, boolean fly) {
short osectnum = spr.sectnum;
int movestat;
Collision moveStat;
if (fly)
movestat = aifly(actor);
moveStat = aifly(actor);
else
movestat = aimove(actor->GetSpriteIndex());
moveStat = aimove(actor);
if (checkdist(plr, actor)) {
if (plr.shadowtime > 0) {
@ -509,7 +513,7 @@ void aisearch(PLAYER& plr, DWHActor* actor, boolean fly) {
return;
}
if (movestat != 0) {
if (moveStat.type != kHitNone) {
if (cansee(plr.x, plr.y, plr.z, plr.sector, spr.x, spr.y, spr.z - (tileHeight(spr.picnum) << 7),
spr.sectnum) && spr.lotag < 0) {
spr.ang = (short)((spr.ang + 1024) & 2047);
@ -530,7 +534,7 @@ void aisearch(PLAYER& plr, DWHActor* actor, boolean fly) {
}
if (cansee(plr.x, plr.y, plr.z, plr.sector, spr.x, spr.y, spr.z - (tileHeight(spr.picnum) << 7),
spr.sectnum) && movestat == 0 && spr.lotag < 0) {
spr.sectnum) && moveStat.type == kHitNone && spr.lotag < 0) {
SetNewStatus(actor, FACE);
return;
}
@ -932,7 +936,7 @@ 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);
if (movestat != 0)
if (movestat != 0) // (moveStat.type != kHitNone)
spr.ang = (short)((spr.ang + TICSPERFRAME) & 2047);
return movestat;

View file

@ -120,8 +120,8 @@ extern Enemy enemy[MAXTYPES];
extern int checksight_ang;
void aiProcess();
int aimove(short i);
int aifly(DWHActor* i);
Collision aimove(DWHActor* actor);
Collision aifly(DWHActor* i);
void aisearch(PLAYER& plr, DWHActor* i, boolean fly);
boolean checksector6(DWHActor* i);
int checkfluid(int i, int zr_florhit);

View file

@ -155,11 +155,11 @@ static void fleedemon(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aifly(actor);
auto moveStat = aifly(actor);
if (movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
if (moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -23,7 +23,7 @@ static void chasedevil(PLAYER& plr, DWHActor* actor)
else {
checksight(plr, actor);
if (!checkdist(plr, actor)) {
if ((aimove(i) & kHitTypeMask) == kHitFloor)
if (aimove(actor).type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
@ -95,7 +95,7 @@ static void paindevil(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
}
@ -138,10 +138,10 @@ static void fleedevil(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -77,10 +77,10 @@ static void fleedragon(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);
@ -266,7 +266,7 @@ static void paindragon(PLAYER& plr, DWHActor* actor)
SPRITE& spr = actor->s();
spr.lotag -= TICSPERFRAME;
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
}

View file

@ -24,8 +24,8 @@ static void chasefatwitch(PLAYER& plr, DWHActor* actor)
else {
checksight(plr, actor);
if (!checkdist(actor, plr.x, plr.y, plr.z)) {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
@ -109,7 +109,7 @@ static void painfatwitch(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
}
@ -180,10 +180,10 @@ static void fleefatwitch(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -29,10 +29,10 @@ static void chasefish(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
auto moveStat = aimove(actor);
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -131,7 +131,7 @@ static void skirmishfish(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
if (aimove(i) != 0) {
if (aimove(actor).type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}

View file

@ -31,10 +31,10 @@ static void chasefred(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
auto moveStat = aimove(actor);
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -93,7 +93,7 @@ static void skirmishfred(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
if (aimove(i) != 0) {
if (aimove(actor).type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}
@ -231,11 +231,11 @@ static void fleefred(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
auto moveStat = aimove(actor);
if (movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
if (moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);
@ -273,7 +273,7 @@ static void painfred(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);

View file

@ -31,16 +31,16 @@ static void chasegoblin(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
return;
}
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -122,7 +122,7 @@ static void paingoblin(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
@ -170,10 +170,10 @@ static void fleegoblin(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);
@ -328,8 +328,8 @@ static void skirmishgoblin(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}
@ -415,16 +415,16 @@ static void goblinWar(PLAYER& plr, DWHActor* actor)
auto owneractor = &whActors[k];
auto ownerspr = owneractor->s();
int movehit = aimove(i);
if (movehit == 0)
auto moveStat = aimove(actor);
if (moveStat.type == kHitNone)
spr.ang = getangle(ownerspr.x - spr.x, ownerspr.y - spr.y);
else if ((movehit & kHitTypeMask) == kHitWall) {
else if (moveStat.type == kHitWall) {
spr.extra = 3;
spr.ang = (short)((spr.ang + (krand() & 256 - 128)) & 2047);
spr.lotag = 60;
}
else if ((movehit & kHitTypeMask) == kHitSprite) {
int sprnum = movehit & kHitIndexMask;
else if (moveStat.type == kHitSprite) {
int sprnum = moveStat.actor->GetSpriteIndex();
if (sprnum != k) {
spr.extra = 3;
spr.ang = (short)((spr.ang + (krand() & 256 - 128)) & 2047);
@ -497,7 +497,7 @@ static void goblinWar(PLAYER& plr, DWHActor* actor)
case 3: // flee
spr.lotag -= TICSPERFRAME;
if (aimove(i) != 0)
if (aimove(actor).type != kHitNone)
spr.ang = (short)(krand() & 2047);
processfluid(actor, zr_florhit, false);

View file

@ -48,8 +48,8 @@ static void chasegonzo(PLAYER& plr, DWHActor* actor)
int daz = spr.z;
osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
@ -61,7 +61,7 @@ static void chasegonzo(PLAYER& plr, DWHActor* actor)
spr.y = day;
spr.z = daz;
SetActorPos(actor, &spr.pos);
movestat = 1;
moveStat.type = -1; // make invalid.
if (rand() % 100 > 80 && sector[plr.sector].lotag == 25) {
SetNewStatus(actor, AMBUSH);
@ -75,7 +75,7 @@ static void chasegonzo(PLAYER& plr, DWHActor* actor)
}
if ((movestat & 0xc000) == 32768 && sector[plr.sector].lotag == 25) {
if (moveStat.type == kHitWall && sector[plr.sector].lotag == 25) {
SetNewStatus(actor, AMBUSH);
spr.z -= (getPlayerHeight() << 6);
spr.lotag = 90;
@ -84,8 +84,8 @@ static void chasegonzo(PLAYER& plr, DWHActor* actor)
return;
}
if (movestat != 0) {
if ((movestat & 4095) != plr.spritenum) {
if (moveStat.type != kHitNone) {
if (moveStat.type == kHitSprite && moveStat.actor == plr.actor()) {
int daang;
if ((krand() & 0) == 1)
daang = (spr.ang + 256) & 2047;
@ -129,16 +129,16 @@ static void chasegonzo(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
return;
}
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -231,8 +231,8 @@ static void skirmishgonzo(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}
@ -315,7 +315,7 @@ static void paingonzo(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
@ -450,11 +450,11 @@ static void fleegonzo(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
auto moveStat = aimove(actor);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -34,16 +34,16 @@ static void chasegron(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
return;
}
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -74,7 +74,7 @@ static void chasegron(PLAYER& plr, DWHActor* actor)
else {
checksight(plr, actor);
if (!checkdist(plr, actor)) {
if ((aimove(i) & kHitTypeMask) == kHitFloor)
if (aimove(actor).type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
@ -160,8 +160,8 @@ static void skirmishgron(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}
@ -243,7 +243,7 @@ static void paingron(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
@ -345,10 +345,10 @@ static void fleegron(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -165,11 +165,11 @@ static void fleeguardian(PLAYER& plr, DWHActor* actor)
if (PlayClock % 100 > 70)
trailingsmoke(actor,true);
int movestat = aifly(actor);
auto moveStat = aifly(actor);
if (movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
if (moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -30,16 +30,16 @@ static void chaseimp(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
return;
}
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -114,7 +114,7 @@ static void painimp(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
}
@ -205,11 +205,11 @@ static void fleeimp(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
auto moveStat = aimove(actor);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);
@ -291,8 +291,8 @@ static void skirmishimp(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}

View file

@ -34,8 +34,8 @@ static void chasejudy(PLAYER& plr, DWHActor* actor)
else {
checksight(plr, actor);
if (!checkdist(actor, plr.x, plr.y, plr.z)) {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
@ -119,7 +119,7 @@ static void painjudy(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
}
@ -193,10 +193,10 @@ static void fleejudy(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -24,8 +24,8 @@ static void chasekatie(PLAYER& plr, DWHActor* actor)
else {
checksight(plr, actor);
if (!checkdist(actor, plr.x, plr.y, plr.z)) {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
@ -94,7 +94,7 @@ static void painkatie(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
}
@ -167,10 +167,10 @@ static void fleekatie(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);
@ -181,7 +181,7 @@ static void fleekatie(PLAYER& plr, DWHActor* actor)
}
}
if (movestat != 0) {
if (moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}

View file

@ -33,16 +33,16 @@ static void chasekobold(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
return;
}
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -126,7 +126,7 @@ static void painkobold(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
@ -174,10 +174,10 @@ static void fleekobold(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);
@ -311,8 +311,8 @@ static void skirmishkobold(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}

View file

@ -30,16 +30,16 @@ static void chaseminotaur(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
return;
}
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -114,8 +114,8 @@ static void skirmishminotaur(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}
@ -167,7 +167,7 @@ static void painminotaur(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
@ -276,10 +276,10 @@ static void fleeminotaur(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -47,16 +47,16 @@ static void chasenewguy(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
return;
}
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -147,8 +147,8 @@ static void skirmishnewguy(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}
@ -190,7 +190,7 @@ static void painnewguy(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
}
@ -233,10 +233,10 @@ static void fleenewguy(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -38,23 +38,23 @@ static void fleerat(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
return;
}
if ((movestat & kHitTypeMask) == kHitWall) {
WALL& wal = wall[movestat & kHitIndexMask];
if (moveStat.type == kHitWall) {
WALL& wal = wall[moveStat.index];
short wallang = (short)((getangle(wall[wal.point2].x - wal.x, wall[wal.point2].y - wal.y) + 512)
& 2047);
spr.ang = (short)(krand() & 512 - 256 + wallang);
}
if ((movestat & kHitTypeMask) == kHitSprite) {
SPRITE& sp = sprite[movestat & kHitIndexMask];
spr.owner = (short)(movestat & kHitIndexMask);
if (moveStat.type == kHitSprite) {
SPRITE& sp = moveStat.actor->s();
spr.owner = moveStat.actor->GetSpriteIndex();
spr.ang = getangle(sp.x - spr.x, sp.y - spr.y);
spr.ang = (short)(((krand() & 512 - 256) + spr.ang + 1024) & 2047);
}

View file

@ -30,16 +30,16 @@ static void chaseskeleton(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
return;
}
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -154,10 +154,10 @@ static void fleeskeleton(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);
@ -315,8 +315,8 @@ static void skirmishskeleton(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}

View file

@ -22,7 +22,7 @@ static void chaseskully(PLAYER& plr, DWHActor* actor)
else {
checksight(plr, actor);
if (!checkdist(plr, actor)) {
if ((aimove(i) & kHitTypeMask) == kHitFloor)
if (aimove(actor).type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
@ -106,7 +106,7 @@ static void painskully(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
aimove(i);
aimove(actor);
processfluid(actor, zr_florhit, false);
SetActorPos(actor, &spr.pos);
}
@ -179,10 +179,10 @@ static void fleeskully(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -30,16 +30,16 @@ static void chasespider(PLAYER& plr, DWHActor* actor)
SetNewStatus(actor, FLEE);
}
else {
int movestat = aimove(i);
if ((movestat & kHitTypeMask) == kHitFloor)
auto moveStat = aimove(actor);
if (moveStat.type == kHitFloor)
{
spr.ang = (short)((spr.ang + 1024) & 2047);
SetNewStatus(actor, FLEE);
return;
}
if ((movestat & kHitTypeMask) == kHitSprite) {
if ((movestat & kHitIndexMask) != plr.spritenum) {
if (moveStat.type == kHitSprite) {
if (moveStat.actor != plr.actor()) {
short daang = (short)((spr.ang - 256) & 2047);
spr.ang = daang;
if (plr.shadowtime > 0) {
@ -114,8 +114,8 @@ static void skirmishspider(PLAYER& plr, DWHActor* actor)
if (spr.lotag < 0)
SetNewStatus(actor, FACE);
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
spr.ang = getangle(plr.x - spr.x, plr.y - spr.y);
SetNewStatus(actor, FACE);
}
@ -238,10 +238,10 @@ static void fleespider(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aimove(i);
if ((movestat & kHitTypeMask) != kHitFloor && movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
auto moveStat = aimove(actor);
if (moveStat.type != kHitFloor && moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -183,11 +183,11 @@ static void fleewillow(PLAYER& plr, DWHActor* actor)
spr.lotag -= TICSPERFRAME;
short osectnum = spr.sectnum;
int movestat = aifly(actor);
auto moveStat = aifly(actor);
if (movestat != 0) {
if ((movestat & kHitTypeMask) == kHitWall) {
int nWall = movestat & kHitIndexMask;
if (moveStat.type != kHitNone) {
if (moveStat.type == kHitWall) {
int nWall = moveStat.index;
int nx = -(wall[wall[nWall].point2].y - wall[nWall].y) >> 4;
int ny = (wall[wall[nWall].point2].x - wall[nWall].x) >> 4;
spr.ang = getangle(nx, ny);

View file

@ -23,6 +23,7 @@ struct PLAYER {
int sector;
int oldsector;
short spritenum;
DWHActor* actor() { return &whActors[spritenum]; }
boolean keytoggle;
int flags;
int weapon[MAXWEAPONS], preenchantedweapon[MAXWEAPONS];

View file

@ -450,7 +450,7 @@ void animateobjs(PLAYER& plr) {
(bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
SetActorPos(actor, &spr.pos);
if (movestat != 0)
if (movestat != 0)// moveStat.type != kHitNone)
spr.ang = (short) (krand() & 2047);
}
break;
@ -467,7 +467,7 @@ void animateobjs(PLAYER& plr) {
(bcos(spr.ang) * TICSPERFRAME) << 3,
(bsin(spr.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0);
SetActorPos(actor, &spr.pos);
if (movestat != 0)
if (movestat != 0)// moveStat.type != kHitNone)
spr.ang = (short) (krand() & 2047);
}
break;
@ -490,7 +490,7 @@ void animateobjs(PLAYER& plr) {
DeleteActor(actor);
continue;
}
if (movestat != 0)
if (movestat != 0)// moveStat.type != kHitNone)
spr.ang = (short) (krand() & 2047);
}
break;
@ -1490,7 +1490,7 @@ void animateobjs(PLAYER& plr) {
}
if (spr.lotag < 0 || movestat != 0)
if (spr.lotag < 0 || movestat != 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,8 @@ void animateobjs(PLAYER& plr) {
}
if (spr.z + (8 << 8) >= sector[spr.sectnum].floorz && spr.picnum == ICECUBE
|| movestat != 0) {
|| movestat != 0)// moveStat.type != kHitNone)
{
spr.z = sector[spr.sectnum].floorz;
ChangeActorStat(actor, 0);
if (sector[spr.sectnum].floorpicnum == WATER || sector[spr.sectnum].floorpicnum == SLIME