- Remove klabs() define and replace with abs().

This commit is contained in:
Mitchell Richters 2021-01-04 23:02:00 +11:00
parent b9c2af130a
commit d460f048fa
56 changed files with 325 additions and 327 deletions

View file

@ -2665,9 +2665,9 @@ void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7,
continue; continue;
if (!CheckProximity(pSprite2, x, y, z, nSector, nDist)) if (!CheckProximity(pSprite2, x, y, z, nSector, nDist))
continue; continue;
int dx = klabs(x-pSprite2->x); int dx = abs(x-pSprite2->x);
int dy = klabs(y-pSprite2->y); int dy = abs(y-pSprite2->y);
int dz = klabs(z-pSprite2->z)>>4; int dz = abs(z-pSprite2->z)>>4;
int dist = ksqrt(dx*dx+dy*dy+dz*dz); int dist = ksqrt(dx*dx+dy*dy+dz*dz);
if (dist > nDist) if (dist > nDist)
continue; continue;
@ -2700,8 +2700,8 @@ void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7,
XSPRITE *pXSprite2 = &xsprite[pSprite2->extra]; XSPRITE *pXSprite2 = &xsprite[pSprite2->extra];
if (pXSprite2->locked) if (pXSprite2->locked)
continue; continue;
int dx = klabs(x-pSprite2->x); int dx = abs(x-pSprite2->x);
int dy = klabs(y-pSprite2->y); int dy = abs(y-pSprite2->y);
int dist = ksqrt(dx*dx+dy*dy); int dist = ksqrt(dx*dx+dy*dy);
if (dist > nDist) if (dist > nDist)
continue; continue;
@ -4411,7 +4411,7 @@ int MoveThing(spritetype *pSprite)
if (nDamage > 0) if (nDamage > 0)
actDamageSprite(nSprite, pSprite, DAMAGE_TYPE_0, nDamage); actDamageSprite(nSprite, pSprite, DAMAGE_TYPE_0, nDamage);
zvel[nSprite] = v20; zvel[nSprite] = v20;
if (velFloor[pSprite->sectnum] == 0 && klabs(zvel[nSprite]) < 0x10000) if (velFloor[pSprite->sectnum] == 0 && abs(zvel[nSprite]) < 0x10000)
{ {
zvel[nSprite] = 0; zvel[nSprite] = 0;
@ -4423,13 +4423,13 @@ int MoveThing(spritetype *pSprite)
if (zvel[nSprite] == 0 || Chance(0xA000)) sub_2AA94(&bloodActors[pXSprite->reference]); if (zvel[nSprite] == 0 || Chance(0xA000)) sub_2AA94(&bloodActors[pXSprite->reference]);
break; break;
case kThingZombieHead: case kThingZombieHead:
if (klabs(zvel[nSprite]) > 0x80000) { if (abs(zvel[nSprite]) > 0x80000) {
sfxPlay3DSound(pSprite, 607, 0, 0); sfxPlay3DSound(pSprite, 607, 0, 0);
actDamageSprite(-1, pSprite, DAMAGE_TYPE_0, 80); actDamageSprite(-1, pSprite, DAMAGE_TYPE_0, 80);
} }
break; break;
case kThingKickablePail: case kThingKickablePail:
if (klabs(zvel[nSprite]) > 0x80000) if (abs(zvel[nSprite]) > 0x80000)
sfxPlay3DSound(pSprite, 374, 0, 0); sfxPlay3DSound(pSprite, 374, 0, 0);
break; break;
} }
@ -4458,13 +4458,13 @@ int MoveThing(spritetype *pSprite)
zvel[nSprite] = MulScale(-zvel[nSprite], 0x4000, 16); zvel[nSprite] = MulScale(-zvel[nSprite], 0x4000, 16);
switch (pSprite->type) { switch (pSprite->type) {
case kThingZombieHead: case kThingZombieHead:
if (klabs(zvel[nSprite]) > 0x80000) { if (abs(zvel[nSprite]) > 0x80000) {
sfxPlay3DSound(pSprite, 607, 0, 0); sfxPlay3DSound(pSprite, 607, 0, 0);
actDamageSprite(-1, pSprite, DAMAGE_TYPE_0, 80); actDamageSprite(-1, pSprite, DAMAGE_TYPE_0, 80);
} }
break; break;
case kThingKickablePail: case kThingKickablePail:
if (klabs(zvel[nSprite]) > 0x80000) if (abs(zvel[nSprite]) > 0x80000)
sfxPlay3DSound(pSprite, 374, 0, 0); sfxPlay3DSound(pSprite, 374, 0, 0);
break; break;
} }
@ -4766,7 +4766,7 @@ void MoveDude(spritetype *pSprite)
pPlayer->posture = 1; pPlayer->posture = 1;
pXSprite->burnTime = 0; pXSprite->burnTime = 0;
pPlayer->bubbleTime = klabs(zvel[nSprite]) >> 12; pPlayer->bubbleTime = abs(zvel[nSprite]) >> 12;
evPost(nSprite, 3, 0, kCallbackPlayerBubble); evPost(nSprite, 3, 0, kCallbackPlayerBubble);
sfxPlay3DSound(pSprite, 720, -1, 0); sfxPlay3DSound(pSprite, 720, -1, 0);
} }
@ -4847,7 +4847,7 @@ void MoveDude(spritetype *pSprite)
{ {
pPlayer->changeTargetKin = 1; pPlayer->changeTargetKin = 1;
pXSprite->burnTime = 0; pXSprite->burnTime = 0;
pPlayer->bubbleTime = klabs(zvel[nSprite])>>12; pPlayer->bubbleTime = abs(zvel[nSprite])>>12;
evPost(nSprite, 3, 0, kCallbackPlayerBubble); evPost(nSprite, 3, 0, kCallbackPlayerBubble);
sfxPlay3DSound(pSprite, 720, -1, 0); sfxPlay3DSound(pSprite, 720, -1, 0);
} }
@ -4948,7 +4948,7 @@ void MoveDude(spritetype *pSprite)
if (nDamage > 0) if (nDamage > 0)
actDamageSprite(nSprite, pSprite, DAMAGE_TYPE_0, nDamage); actDamageSprite(nSprite, pSprite, DAMAGE_TYPE_0, nDamage);
zvel[nSprite] = v30; zvel[nSprite] = v30;
if (klabs(zvel[nSprite]) < 0x10000) if (abs(zvel[nSprite]) < 0x10000)
{ {
zvel[nSprite] = velFloor[pSprite->sectnum]; zvel[nSprite] = velFloor[pSprite->sectnum];

View file

@ -265,7 +265,7 @@ void aiMoveForward(DBloodActor* actor)
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
actor->xvel() += MulScale(pDudeInfo->frontSpeed, Cos(pSprite->ang), 30); actor->xvel() += MulScale(pDudeInfo->frontSpeed, Cos(pSprite->ang), 30);
actor->yvel() += MulScale(pDudeInfo->frontSpeed, Sin(pSprite->ang), 30); actor->yvel() += MulScale(pDudeInfo->frontSpeed, Sin(pSprite->ang), 30);
@ -1357,7 +1357,7 @@ void aiThinkTarget(DBloodActor* actor)
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pPlayer->nSprite); aiSetTarget(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]); aiActivateDude(&bloodActors[pXSprite->reference]);
@ -1396,7 +1396,7 @@ void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite)
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pPlayer->nSprite); aiSetTarget(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]); aiActivateDude(&bloodActors[pXSprite->reference]);

View file

@ -117,7 +117,7 @@ static void batThinkTarget(DBloodActor* actor)
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pPlayer->nSprite); aiSetTarget(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]); aiActivateDude(&bloodActors[pXSprite->reference]);
@ -153,7 +153,7 @@ static void batThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &batSearch); aiNewState(actor, &batSearch);
batThinkTarget(actor); batThinkTarget(actor);
} }
@ -191,17 +191,17 @@ static void batThinkPonder(DBloodActor* actor)
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (height2-height < 0x3000 && nDist < 0x1800 && nDist > 0xc00 && klabs(nDeltaAngle) < 85) if (height2-height < 0x3000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeUp); aiNewState(actor, &batDodgeUp);
else if (height2-height > 0x5000 && nDist < 0x1800 && nDist > 0xc00 && klabs(nDeltaAngle) < 85) else if (height2-height > 0x5000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeDown); aiNewState(actor, &batDodgeDown);
else if (height2-height < 0x2000 && nDist < 0x200 && klabs(nDeltaAngle) < 85) else if (height2-height < 0x2000 && nDist < 0x200 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeUp); aiNewState(actor, &batDodgeUp);
else if (height2-height > 0x6000 && nDist < 0x1400 && nDist > 0x800 && klabs(nDeltaAngle) < 85) else if (height2-height > 0x6000 && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeDown); aiNewState(actor, &batDodgeDown);
else if (height2-height < 0x2000 && nDist < 0x1400 && nDist > 0x800 && klabs(nDeltaAngle) < 85) else if (height2-height < 0x2000 && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batDodgeUp); aiNewState(actor, &batDodgeUp);
else if (height2-height < 0x2000 && klabs(nDeltaAngle) < 85 && nDist > 0x1400) else if (height2-height < 0x2000 && abs(nDeltaAngle) < 85 && nDist > 0x1400)
aiNewState(actor, &batDodgeUp); aiNewState(actor, &batDodgeUp);
else if (height2-height > 0x4000) else if (height2-height > 0x4000)
aiNewState(actor, &batDodgeDown); aiNewState(actor, &batDodgeDown);
@ -304,15 +304,15 @@ static void batThinkChase(DBloodActor* actor)
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
if (height2-height < 0x2000 && nDist < 0x200 && klabs(nDeltaAngle) < 85) if (height2-height < 0x2000 && nDist < 0x200 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batBite); aiNewState(actor, &batBite);
else if ((height2-height > 0x5000 || floorZ-bottom > 0x5000) && nDist < 0x1400 && nDist > 0x800 && klabs(nDeltaAngle) < 85) else if ((height2-height > 0x5000 || floorZ-bottom > 0x5000) && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &batSwoop); aiNewState(actor, &batSwoop);
else if ((height2-height < 0x3000 || floorZ-bottom < 0x3000) && klabs(nDeltaAngle) < 85) else if ((height2-height < 0x3000 || floorZ-bottom < 0x3000) && abs(nDeltaAngle) < 85)
aiNewState(actor, &batFly); aiNewState(actor, &batFly);
return; return;
} }
@ -338,7 +338,7 @@ static void batMoveForward(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
@ -371,7 +371,7 @@ static void batMoveSwoop(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang+512)&2047; pXSprite->goalAng = (pSprite->ang+512)&2047;
return; return;
@ -403,7 +403,7 @@ static void batMoveFly(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang+512)&2047; pSprite->ang = (pSprite->ang+512)&2047;
return; return;

View file

@ -125,10 +125,10 @@ void StompSeqCallback(int, DBloodActor* actor)
{ {
int top, bottom; int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
if (klabs(bottom-sector[nSector].floorz) == 0) if (abs(bottom-sector[nSector].floorz) == 0)
{ {
int dx = klabs(pSprite->x-pSprite2->x); int dx = abs(pSprite->x-pSprite2->x);
int dy = klabs(pSprite->y-pSprite2->y); int dy = abs(pSprite->y-pSprite2->y);
int nDist2 = ksqrt(dx*dx + dy*dy); int nDist2 = ksqrt(dx*dx + dy*dy);
if (nDist2 <= vc) if (nDist2 <= vc)
{ {
@ -157,8 +157,8 @@ void StompSeqCallback(int, DBloodActor* actor)
XSPRITE *pXSprite = &xsprite[pSprite2->extra]; XSPRITE *pXSprite = &xsprite[pSprite2->extra];
if (pXSprite->locked) if (pXSprite->locked)
continue; continue;
int dx = klabs(pSprite->x-pSprite2->x); int dx = abs(pSprite->x-pSprite2->x);
int dy = klabs(pSprite->y-pSprite2->y); int dy = abs(pSprite->y-pSprite2->y);
int nDist2 = ksqrt(dx*dx + dy*dy); int nDist2 = ksqrt(dx*dx + dy*dy);
if (nDist2 <= vc) if (nDist2 <= vc)
{ {
@ -209,7 +209,7 @@ static void beastThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &beastSwimSearch); aiNewState(actor, &beastSwimSearch);
@ -280,11 +280,11 @@ static void beastThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 0x1400 && nDist > 0xa00 && klabs(nDeltaAngle) < 85 && (pTarget->flags&2) if (nDist < 0x1400 && nDist > 0xa00 && abs(nDeltaAngle) < 85 && (pTarget->flags&2)
&& IsPlayerSprite(pTarget) && Chance(0x8000)) && IsPlayerSprite(pTarget) && Chance(0x8000))
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
@ -323,7 +323,7 @@ static void beastThinkChase(DBloodActor* actor)
} }
} }
} }
if (nDist < 921 && klabs(nDeltaAngle) < 28) if (nDist < 921 && abs(nDeltaAngle) < 28)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
int nXSector = sector[pSprite->sectnum].extra; int nXSector = sector[pSprite->sectnum].extra;
@ -393,7 +393,7 @@ static void beastThinkSwimGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &beastSwimSearch); aiNewState(actor, &beastSwimSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -434,10 +434,10 @@ static void beastThinkSwimChase(DBloodActor* actor)
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x400 && klabs(nDeltaAngle) < 85) if (nDist < 0x400 && abs(nDeltaAngle) < 85)
aiNewState(actor, &beastSwimSlash); aiNewState(actor, &beastSwimSlash);
else else
{ {
@ -463,7 +463,7 @@ static void beastMoveForward(DBloodActor* actor)
int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024; int nAng = ((pXSprite->goalAng+1024-pSprite->ang)&2047)-1024;
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -484,7 +484,7 @@ static void sub_628A0(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
@ -520,7 +520,7 @@ static void sub_62AE0(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang+512)&2047; pXSprite->goalAng = (pSprite->ang+512)&2047;
return; return;
@ -557,7 +557,7 @@ static void sub_62D7C(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang+512)&2047; pSprite->ang = (pSprite->ang+512)&2047;
return; return;

View file

@ -128,7 +128,7 @@ static void eelThinkTarget(DBloodActor* actor)
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->xval2 = 0; pDudeExtraE->xval2 = 0;
aiSetTarget(pXSprite, pPlayer->nSprite); aiSetTarget(pXSprite, pPlayer->nSprite);
@ -166,7 +166,7 @@ static void eelThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &eelSearch); aiNewState(actor, &eelSearch);
eelThinkTarget(actor); eelThinkTarget(actor);
} }
@ -204,17 +204,17 @@ static void eelThinkPonder(DBloodActor* actor)
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (height2-height < -0x2000 && nDist < 0x1800 && nDist > 0xc00 && klabs(nDeltaAngle) < 85) if (height2-height < -0x2000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelDodgeUp); aiNewState(actor, &eelDodgeUp);
else if (height2-height > 0xccc && nDist < 0x1800 && nDist > 0xc00 && klabs(nDeltaAngle) < 85) else if (height2-height > 0xccc && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelDodgeDown); aiNewState(actor, &eelDodgeDown);
else if (height2-height < 0xccc && nDist < 0x399 && klabs(nDeltaAngle) < 85) else if (height2-height < 0xccc && nDist < 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelDodgeUp); aiNewState(actor, &eelDodgeUp);
else if (height2-height > 0xccc && nDist < 0x1400 && nDist > 0x800 && klabs(nDeltaAngle) < 85) else if (height2-height > 0xccc && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelDodgeDown); aiNewState(actor, &eelDodgeDown);
else if (height2-height < -0x2000 && nDist < 0x1400 && nDist > 0x800 && klabs(nDeltaAngle) < 85) else if (height2-height < -0x2000 && nDist < 0x1400 && nDist > 0x800 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelDodgeUp); aiNewState(actor, &eelDodgeUp);
else if (height2-height < -0x2000 && klabs(nDeltaAngle) < 85 && nDist > 0x1400) else if (height2-height < -0x2000 && abs(nDeltaAngle) < 85 && nDist > 0x1400)
aiNewState(actor, &eelDodgeUp); aiNewState(actor, &eelDodgeUp);
else if (height2-height > 0xccc) else if (height2-height > 0xccc)
aiNewState(actor, &eelDodgeDown); aiNewState(actor, &eelDodgeDown);
@ -317,16 +317,16 @@ static void eelThinkChase(DBloodActor* actor)
GetSpriteExtents(pTarget, &top2, &bottom2); GetSpriteExtents(pTarget, &top2, &bottom2);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x399 && top2 > top && klabs(nDeltaAngle) < 85) if (nDist < 0x399 && top2 > top && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelSwoop); aiNewState(actor, &eelSwoop);
else if (nDist <= 0x399 && klabs(nDeltaAngle) < 85) else if (nDist <= 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelBite); aiNewState(actor, &eelBite);
else if (bottom2 > top && klabs(nDeltaAngle) < 85) else if (bottom2 > top && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelSwoop); aiNewState(actor, &eelSwoop);
else if (top2 < top && klabs(nDeltaAngle) < 85) else if (top2 < top && abs(nDeltaAngle) < 85)
aiNewState(actor, &eelFly); aiNewState(actor, &eelFly);
} }
} }
@ -347,7 +347,7 @@ static void eelMoveForward(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2; int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
@ -380,7 +380,7 @@ static void eelMoveSwoop(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2; int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;
@ -409,7 +409,7 @@ static void eelMoveAscend(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2; int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<26)/120)/120)<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
int dx = pXSprite->targetX-pSprite->x; int dx = pXSprite->targetX-pSprite->x;
int dy = pXSprite->targetY-pSprite->y; int dy = pXSprite->targetY-pSprite->y;

View file

@ -96,7 +96,7 @@ static void burnThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
switch (pSprite->type) switch (pSprite->type)
{ {
@ -207,10 +207,10 @@ static void burnThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x333 && klabs(nDeltaAngle) < 85) if (nDist < 0x333 && abs(nDeltaAngle) < 85)
{ {
switch (pSprite->type) switch (pSprite->type)
{ {

View file

@ -109,7 +109,7 @@ static void calebThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &tinycalebSwimSearch); aiNewState(actor, &tinycalebSwimSearch);
@ -183,11 +183,11 @@ static void calebThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 0x599 && klabs(nDeltaAngle) < 28) if (nDist < 0x599 && abs(nDeltaAngle) < 28)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
int nXSector = sector[pSprite->sectnum].extra; int nXSector = sector[pSprite->sectnum].extra;
@ -259,7 +259,7 @@ static void calebThinkSwimGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tinycalebSwimSearch); aiNewState(actor, &tinycalebSwimSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -300,10 +300,10 @@ static void calebThinkSwimChase(DBloodActor* actor)
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x400 && klabs(nDeltaAngle) < 85) if (nDist < 0x400 && abs(nDeltaAngle) < 85)
aiNewState(actor, &tinycalebSwimAttack); aiNewState(actor, &tinycalebSwimAttack);
else else
aiNewState(actor, &tinycaleb13967C); aiNewState(actor, &tinycaleb13967C);
@ -326,7 +326,7 @@ static void sub_65D04(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
@ -363,7 +363,7 @@ static void sub_65F44(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang+512)&2047; pXSprite->goalAng = (pSprite->ang+512)&2047;
return; return;
@ -400,7 +400,7 @@ static void sub_661E0(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang+512)&2047; pSprite->ang = (pSprite->ang+512)&2047;
return; return;

View file

@ -137,7 +137,7 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
{ {
int nAngle = getangle(x2-x, y2-y); int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024; int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
if (klabs(nDeltaAngle) <= tt1.at8) if (abs(nDeltaAngle) <= tt1.at8)
{ {
int tz = pSprite2->z-pSprite->z; int tz = pSprite2->z-pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
@ -222,7 +222,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
{ {
int nAngle = getangle(x2-x, y2-y); int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024; int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
if (klabs(nDeltaAngle) <= tt1.at8) if (abs(nDeltaAngle) <= tt1.at8)
{ {
DUDEINFO *pDudeInfo2 = getDudeInfo(pSprite2->type); DUDEINFO *pDudeInfo2 = getDudeInfo(pSprite2->type);
int height = (pDudeInfo2->aimHeight*pSprite2->yrepeat)<<2; int height = (pDudeInfo2->aimHeight*pSprite2->yrepeat)<<2;
@ -301,7 +301,7 @@ static void cerberusThinkTarget(DBloodActor* actor)
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
aiSetTarget(pXSprite, pPlayer->nSprite); aiSetTarget(pXSprite, pPlayer->nSprite);
@ -335,7 +335,7 @@ static void cerberusThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
switch (pSprite->type) { switch (pSprite->type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
@ -415,10 +415,10 @@ static void cerberusThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x1b00 && nDist > 0xd00 && klabs(nDeltaAngle) < 85) { if (nDist < 0x1b00 && nDist > 0xd00 && abs(nDeltaAngle) < 85) {
switch (pSprite->type) { switch (pSprite->type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberusBurn); aiNewState(actor, &cerberusBurn);
@ -429,7 +429,7 @@ static void cerberusThinkChase(DBloodActor* actor)
} }
} }
else if (nDist < 0xb00 && nDist > 0x500 && klabs(nDeltaAngle) < 85) { else if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85) {
switch (pSprite->type) { switch (pSprite->type) {
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
aiNewState(actor, &cerberus3Burn); aiNewState(actor, &cerberus3Burn);
@ -439,7 +439,7 @@ static void cerberusThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x200 && klabs(nDeltaAngle) < 85) else if (nDist < 0x200 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (pSprite->type) { switch (pSprite->type) {

View file

@ -218,7 +218,7 @@ static void cultThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 5120 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 5120 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
switch (pXSprite->medium) switch (pXSprite->medium)
{ {
@ -299,13 +299,13 @@ static void cultThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
switch (pSprite->type) { switch (pSprite->type) {
case kDudeCultistTommy: case kDudeCultistTommy:
if (nDist < 0x1e00 && nDist > 0xe00 && klabs(nDeltaAngle) < 85 && !TargetNearExplosion(pTarget) if (nDist < 0x1e00 && nDist > 0xe00 && abs(nDeltaAngle) < 85 && !TargetNearExplosion(pTarget)
&& (pTarget->flags&2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type-kDudePlayer1].isRunning && (pTarget->flags&2) && gGameOptions.nDifficulty > 2 && IsPlayerSprite(pTarget) && gPlayer[pTarget->type-kDudePlayer1].isRunning
&& Chance(0x8000)) && Chance(0x8000))
{ {
@ -328,7 +328,7 @@ static void cultThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x4600 && klabs(nDeltaAngle) < 28) else if (nDist < 0x4600 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -396,7 +396,7 @@ static void cultThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x3200 && klabs(nDeltaAngle) < 28) else if (nDist < 0x3200 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -464,7 +464,7 @@ static void cultThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x3200 && klabs(nDeltaAngle) < 28) else if (nDist < 0x3200 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -509,7 +509,7 @@ static void cultThinkChase(DBloodActor* actor)
} }
break; break;
case kDudeCultistTNT: case kDudeCultistTNT:
if (nDist < 0x2c00 && nDist > 0x1400 && klabs(nDeltaAngle) < 85 if (nDist < 0x2c00 && nDist > 0x1400 && abs(nDeltaAngle) < 85
&& (pTarget->flags&2) && IsPlayerSprite(pTarget)) && (pTarget->flags&2) && IsPlayerSprite(pTarget))
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
@ -530,7 +530,7 @@ static void cultThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x1400 && klabs(nDeltaAngle) < 85 else if (nDist < 0x1400 && abs(nDeltaAngle) < 85
&& (pTarget->flags&2) && IsPlayerSprite(pTarget)) && (pTarget->flags&2) && IsPlayerSprite(pTarget))
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
@ -576,7 +576,7 @@ static void cultThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x3200 && klabs(nDeltaAngle) < 28) else if (nDist < 0x3200 && abs(nDeltaAngle) < 28)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)

View file

@ -161,7 +161,7 @@ void BlastSSeqCallback(int, DBloodActor* actor)
{ {
int nAngle = getangle(x2-x, y2-y); int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024; int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
if (klabs(nDeltaAngle) <= tt.at8) if (abs(nDeltaAngle) <= tt.at8)
{ {
int tz = pSprite2->z-pSprite->z; int tz = pSprite2->z-pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
@ -247,7 +247,7 @@ static void gargThinkTarget(DBloodActor* actor)
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->xval2 = 0; pDudeExtraE->xval2 = 0;
aiSetTarget(pXSprite, pPlayer->nSprite); aiSetTarget(pXSprite, pPlayer->nSprite);
@ -289,7 +289,7 @@ static void gargThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gargoyleFSearch); aiNewState(actor, &gargoyleFSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -400,13 +400,13 @@ static void gargThinkChase(DBloodActor* actor)
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
switch (pSprite->type) { switch (pSprite->type) {
case kDudeGargoyleFlesh: case kDudeGargoyleFlesh:
if (nDist < 0x1800 && nDist > 0xc00 && klabs(nDeltaAngle) < 85) if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -431,7 +431,7 @@ static void gargThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x400 && klabs(nDeltaAngle) < 85) else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -461,11 +461,11 @@ static void gargThinkChase(DBloodActor* actor)
aiPlay3DSound(pSprite, 1400, AI_SFX_PRIORITY_1, -1); aiPlay3DSound(pSprite, 1400, AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &gargoyleSwoop); aiNewState(actor, &gargoyleSwoop);
} }
else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && klabs(nDeltaAngle) < 85) else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && abs(nDeltaAngle) < 85)
aiPlay3DSound(pSprite, 1400, AI_SFX_PRIORITY_1, -1); aiPlay3DSound(pSprite, 1400, AI_SFX_PRIORITY_1, -1);
break; break;
case kDudeGargoyleStone: case kDudeGargoyleStone:
if (nDist < 0x1800 && nDist > 0xc00 && klabs(nDeltaAngle) < 85) if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -490,7 +490,7 @@ static void gargThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x400 && klabs(nDeltaAngle) < 85) else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -518,7 +518,7 @@ static void gargThinkChase(DBloodActor* actor)
aiPlay3DSound(pSprite, 1450, AI_SFX_PRIORITY_1, -1); aiPlay3DSound(pSprite, 1450, AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &gargoyleSwoop); aiNewState(actor, &gargoyleSwoop);
} }
else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && klabs(nDeltaAngle) < 85) else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && abs(nDeltaAngle) < 85)
aiPlay3DSound(pSprite, 1450, AI_SFX_PRIORITY_1, -1); aiPlay3DSound(pSprite, 1450, AI_SFX_PRIORITY_1, -1);
break; break;
} }
@ -568,7 +568,7 @@ static void gargMoveForward(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
@ -605,7 +605,7 @@ static void gargMoveSlow(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang+512)&2047; pXSprite->goalAng = (pSprite->ang+512)&2047;
return; return;
@ -649,7 +649,7 @@ static void gargMoveSwoop(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang+512)&2047; pXSprite->goalAng = (pSprite->ang+512)&2047;
return; return;
@ -692,7 +692,7 @@ static void gargMoveFly(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang+512)&2047; pSprite->ang = (pSprite->ang+512)&2047;
return; return;
@ -719,7 +719,7 @@ static void gargMoveFly(DBloodActor* actor)
actor->zvel() = -t1; actor->zvel() = -t1;
break; break;
} }
klabs(actor->zvel()); abs(actor->zvel());
} }
END_BLD_NS END_BLD_NS

View file

@ -144,7 +144,7 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
{ {
int nAngle = getangle(x2-x, y2-y); int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024; int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
if (klabs(nDeltaAngle) <= tt.at8) if (abs(nDeltaAngle) <= tt.at8)
{ {
int tz = pSprite2->z-pSprite->z; int tz = pSprite2->z-pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
@ -223,7 +223,7 @@ static void ghostThinkTarget(DBloodActor* actor)
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->xval2 = 0; pDudeExtraE->xval2 = 0;
aiSetTarget(pXSprite, pPlayer->nSprite); aiSetTarget(pXSprite, pPlayer->nSprite);
@ -264,7 +264,7 @@ static void ghostThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ghostSearch); aiNewState(actor, &ghostSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -377,13 +377,13 @@ static void ghostThinkChase(DBloodActor* actor)
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); int floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
switch (pSprite->type) { switch (pSprite->type) {
case kDudePhantasm: case kDudePhantasm:
if (nDist < 0x2000 && nDist > 0x1000 && klabs(nDeltaAngle) < 85) { if (nDist < 0x2000 && nDist > 0x1000 && abs(nDeltaAngle) < 85) {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
{ {
@ -402,7 +402,7 @@ static void ghostThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x400 && klabs(nDeltaAngle) < 85) else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -427,7 +427,7 @@ static void ghostThinkChase(DBloodActor* actor)
aiPlay3DSound(pSprite, 1600, AI_SFX_PRIORITY_1, -1); aiPlay3DSound(pSprite, 1600, AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &ghostSwoop); aiNewState(actor, &ghostSwoop);
} }
else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && klabs(nDeltaAngle) < 85) else if ((height2-height < 0x2000 || floorZ-bottom < 0x2000) && abs(nDeltaAngle) < 85)
aiPlay3DSound(pSprite, 1600, AI_SFX_PRIORITY_1, -1); aiPlay3DSound(pSprite, 1600, AI_SFX_PRIORITY_1, -1);
break; break;
} }
@ -459,7 +459,7 @@ static void ghostMoveForward(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
@ -496,7 +496,7 @@ static void ghostMoveSlow(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang+512)&2047; pXSprite->goalAng = (pSprite->ang+512)&2047;
return; return;
@ -537,7 +537,7 @@ static void ghostMoveSwoop(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang+512)&2047; pXSprite->goalAng = (pSprite->ang+512)&2047;
return; return;
@ -577,7 +577,7 @@ static void ghostMoveFly(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = pDudeInfo->frontSpeed<<2; int nAccel = pDudeInfo->frontSpeed<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang+512)&2047; pSprite->ang = (pSprite->ang+512)&2047;
return; return;

View file

@ -100,7 +100,7 @@ static void gillThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
{ {
if (pXSector && pXSector->Underwater) if (pXSector && pXSector->Underwater)
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);
@ -171,11 +171,11 @@ static void gillThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10); actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 921 && klabs(nDeltaAngle) < 28) if (nDist < 921 && abs(nDeltaAngle) < 28)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;
int nXSector = sector[pSprite->sectnum].extra; int nXSector = sector[pSprite->sectnum].extra;
@ -246,7 +246,7 @@ static void gillThinkSwimGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &gillBeastSwimSearch); aiNewState(actor, &gillBeastSwimSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -287,10 +287,10 @@ static void gillThinkSwimChase(DBloodActor* actor)
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x400 && klabs(nDeltaAngle) < 85) if (nDist < 0x400 && abs(nDeltaAngle) < 85)
aiNewState(actor, &gillBeastSwimBite); aiNewState(actor, &gillBeastSwimBite);
else else
{ {
@ -318,7 +318,7 @@ static void sub_6CB00(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2; int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target == -1)
pSprite->ang = (pSprite->ang+256)&2047; pSprite->ang = (pSprite->ang+256)&2047;
@ -354,7 +354,7 @@ static void sub_6CD74(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2; int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pXSprite->goalAng = (pSprite->ang+512)&2047; pXSprite->goalAng = (pSprite->ang+512)&2047;
return; return;
@ -390,7 +390,7 @@ static void sub_6D03C(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed<<2)>>4; int nTurnRange = (pDudeInfo->angSpeed<<2)>>4;
pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047; pSprite->ang = (pSprite->ang+ClipRange(nAng, -nTurnRange, nTurnRange))&2047;
int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2; int nAccel = (pDudeInfo->frontSpeed-(((4-gGameOptions.nDifficulty)<<27)/120)/120)<<2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
{ {
pSprite->ang = (pSprite->ang+512)&2047; pSprite->ang = (pSprite->ang+512)&2047;
return; return;

View file

@ -79,7 +79,7 @@ static void handThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &handSearch); aiNewState(actor, &handSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -118,10 +118,10 @@ static void handThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x233 && klabs(nDeltaAngle) < 85 && gGameOptions.nGameType == 0) if (nDist < 0x233 && abs(nDeltaAngle) < 85 && gGameOptions.nGameType == 0)
aiNewState(actor, &handJump); aiNewState(actor, &handJump);
return; return;
} }

View file

@ -102,7 +102,7 @@ static void houndThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &houndSearch); aiNewState(actor, &houndSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -149,12 +149,12 @@ static void houndThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0xb00 && nDist > 0x500 && klabs(nDeltaAngle) < 85) if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85)
aiNewState(actor, &houndBurn); aiNewState(actor, &houndBurn);
else if(nDist < 0x266 && klabs(nDeltaAngle) < 85) else if(nDist < 0x266 && abs(nDeltaAngle) < 85)
aiNewState(actor, &houndBite); aiNewState(actor, &houndBite);
return; return;
} }

View file

@ -62,7 +62,7 @@ static void innocThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &innocentSearch); aiNewState(actor, &innocentSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -101,10 +101,10 @@ static void innocThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x666 && klabs(nDeltaAngle) < 85) if (nDist < 0x666 && abs(nDeltaAngle) < 85)
aiNewState(actor, &innocentIdle); aiNewState(actor, &innocentIdle);
return; return;
} }

View file

@ -166,7 +166,7 @@ static void aiPodMove(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) { if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery) {
switch (pSprite->type) { switch (pSprite->type) {
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:
@ -235,10 +235,10 @@ static void aiPodChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (klabs(nDeltaAngle) < 85 && pTarget->type != kDudePodGreen && pTarget->type != kDudePodFire) { if (abs(nDeltaAngle) < 85 && pTarget->type != kDudePodGreen && pTarget->type != kDudePodFire) {
switch (pSprite->type) { switch (pSprite->type) {
case kDudePodGreen: case kDudePodGreen:
case kDudePodFire: case kDudePodFire:

View file

@ -76,7 +76,7 @@ static void ratThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &ratSearch); aiNewState(actor, &ratSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -115,10 +115,10 @@ static void ratThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x399 && klabs(nDeltaAngle) < 85) if (nDist < 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &ratBite); aiNewState(actor, &ratBite);
return; return;
} }

View file

@ -160,11 +160,11 @@ void sub_71370(int, DBloodActor* actor)
spritetype *pSpawn = NULL; spritetype *pSpawn = NULL;
if (IsPlayerSprite(pTarget) && pDudeExtraE->xval2 < 10) { if (IsPlayerSprite(pTarget) && pDudeExtraE->xval2 < 10) {
if (nDist < 0x1a00 && nDist > 0x1400 && klabs(pSprite->ang-nAngle) < pDudeInfo->periphery) if (nDist < 0x1a00 && nDist > 0x1400 && abs(pSprite->ang-nAngle) < pDudeInfo->periphery)
pSpawn = actSpawnDude(pSprite, kDudeSpiderRed, pSprite->clipdist, 0); pSpawn = actSpawnDude(pSprite, kDudeSpiderRed, pSprite->clipdist, 0);
else if (nDist < 0x1400 && nDist > 0xc00 && klabs(pSprite->ang-nAngle) < pDudeInfo->periphery) else if (nDist < 0x1400 && nDist > 0xc00 && abs(pSprite->ang-nAngle) < pDudeInfo->periphery)
pSpawn = actSpawnDude(pSprite, kDudeSpiderBrown, pSprite->clipdist, 0); pSpawn = actSpawnDude(pSprite, kDudeSpiderBrown, pSprite->clipdist, 0);
else if (nDist < 0xc00 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) else if (nDist < 0xc00 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
pSpawn = actSpawnDude(pSprite, kDudeSpiderBrown, pSprite->clipdist, 0); pSpawn = actSpawnDude(pSprite, kDudeSpiderBrown, pSprite->clipdist, 0);
if (pSpawn) { if (pSpawn) {
@ -195,7 +195,7 @@ static void spidThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &spidSearch); aiNewState(actor, &spidSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -232,23 +232,23 @@ static void spidThinkChase(DBloodActor* actor)
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) { if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) { if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
switch (pSprite->type) { switch (pSprite->type) {
case kDudeSpiderRed: case kDudeSpiderRed:
if (nDist < 0x399 && klabs(nDeltaAngle) < 85) if (nDist < 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &spidBite); aiNewState(actor, &spidBite);
break; break;
case kDudeSpiderBrown: case kDudeSpiderBrown:
case kDudeSpiderBlack: case kDudeSpiderBlack:
if (nDist < 0x733 && nDist > 0x399 && klabs(nDeltaAngle) < 85) if (nDist < 0x733 && nDist > 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &spidJump); aiNewState(actor, &spidJump);
else if (nDist < 0x399 && klabs(nDeltaAngle) < 85) else if (nDist < 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &spidBite); aiNewState(actor, &spidBite);
break; break;
case kDudeSpiderMother: case kDudeSpiderMother:
if (nDist < 0x733 && nDist > 0x399 && klabs(nDeltaAngle) < 85) if (nDist < 0x733 && nDist > 0x399 && abs(nDeltaAngle) < 85)
aiNewState(actor, &spidJump); aiNewState(actor, &spidJump);
else if (Chance(0x8000)) else if (Chance(0x8000))
aiNewState(actor, &spid13A92C); aiNewState(actor, &spid13A92C);

View file

@ -119,7 +119,7 @@ void sub_71BD4(int, DBloodActor* actor)
{ {
int nAngle = getangle(x2-x, y2-y); int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024; int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
if (klabs(nDeltaAngle) <= tt.at8) if (abs(nDeltaAngle) <= tt.at8)
{ {
int tz = pSprite2->z-pSprite->z; int tz = pSprite2->z-pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
@ -198,7 +198,7 @@ void sub_720AC(int, DBloodActor* actor)
{ {
int nAngle = getangle(x2-x, y2-y); int nAngle = getangle(x2-x, y2-y);
int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024; int nDeltaAngle = ((nAngle-pSprite->ang+1024)&2047)-1024;
if (klabs(nDeltaAngle) <= tt.at8) if (abs(nDeltaAngle) <= tt.at8)
{ {
int tz = pSprite2->z-pSprite->z; int tz = pSprite2->z-pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum)) if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
@ -265,7 +265,7 @@ static void sub_725A4(DBloodActor* actor)
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
pDudeExtraE->xval1 = 0; pDudeExtraE->xval1 = 0;
aiSetTarget(pXSprite, pPlayer->nSprite); aiSetTarget(pXSprite, pPlayer->nSprite);
@ -299,7 +299,7 @@ static void sub_72850(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &tchernobogSearch); aiNewState(actor, &tchernobogSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -346,14 +346,14 @@ static void sub_72934(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x1f00 && nDist > 0xd00 && klabs(nDeltaAngle) < 85) if (nDist < 0x1f00 && nDist > 0xd00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &tcherno13AA0C); aiNewState(actor, &tcherno13AA0C);
else if (nDist < 0xd00 && nDist > 0xb00 && klabs(nDeltaAngle) < 85) else if (nDist < 0xd00 && nDist > 0xb00 && abs(nDeltaAngle) < 85)
aiNewState(actor, &tcherno13A9D4); aiNewState(actor, &tcherno13A9D4);
else if (nDist < 0xb00 && nDist > 0x500 && klabs(nDeltaAngle) < 85) else if (nDist < 0xb00 && nDist > 0x500 && abs(nDeltaAngle) < 85)
aiNewState(actor, &tcherno13A9F0); aiNewState(actor, &tcherno13A9F0);
return; return;
} }

View file

@ -401,7 +401,7 @@ static void unicultThinkGoto(DBloodActor* actor)
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
// if reached target, change to search mode // if reached target, change to search mode
if (approxDist(dx, dy) < 5120 && klabs(pSprite->ang - nAngle) < getDudeInfo(pSprite->type)->periphery) { if (approxDist(dx, dy) < 5120 && abs(pSprite->ang - nAngle) < getDudeInfo(pSprite->type)->periphery) {
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW); if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeSearchW);
else aiGenDudeNewState(pSprite, &genDudeSearchL); else aiGenDudeNewState(pSprite, &genDudeSearchL);
} }
@ -489,7 +489,7 @@ static void unicultThinkChase(DBloodActor* actor)
} }
// is the target visible? // is the target visible?
if (dist < pDudeInfo->seeDist && klabs(losAngle) <= pDudeInfo->periphery) { if (dist < pDudeInfo->seeDist && abs(losAngle) <= pDudeInfo->periphery) {
if ((gFrameClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(pSprite, false)) if ((gFrameClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(pSprite, false))
playGenDudeSound(pSprite, kGenDudeSndChasing); playGenDudeSound(pSprite, kGenDudeSndChasing);
@ -499,7 +499,7 @@ static void unicultThinkChase(DBloodActor* actor)
short curWeapon = gGenDudeExtra[pSprite->index].curWeapon; short weaponType = gGenDudeExtra[pSprite->index].weaponType; short curWeapon = gGenDudeExtra[pSprite->index].curWeapon; short weaponType = gGenDudeExtra[pSprite->index].weaponType;
spritetype* pLeech = leechIsDropped(pSprite); const VECTORDATA* meleeVector = &gVectorData[22]; spritetype* pLeech = leechIsDropped(pSprite); const VECTORDATA* meleeVector = &gVectorData[22];
if (weaponType == kGenDudeWeaponThrow) { if (weaponType == kGenDudeWeaponThrow) {
if (klabs(losAngle) < kAng15) { if (abs(losAngle) < kAng15) {
if (!gThingInfoExtra[curWeapon - kThingBase].allowThrow) { if (!gThingInfoExtra[curWeapon - kThingBase].allowThrow) {
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW); if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL); else aiGenDudeNewState(pSprite, &genDudeChaseL);
@ -659,7 +659,7 @@ static void unicultThinkChase(DBloodActor* actor)
int state = checkAttackState(&bloodActors[pXSprite->reference]); int state = checkAttackState(&bloodActors[pXSprite->reference]);
int kAngle = (dudeIsMelee(pXSprite) || dist <= kGenDudeMaxMeleeDist) ? pDudeInfo->periphery : kGenDudeKlabsAng; int kAngle = (dudeIsMelee(pXSprite) || dist <= kGenDudeMaxMeleeDist) ? pDudeInfo->periphery : kGenDudeKlabsAng;
if (dist < vdist && klabs(losAngle) < kAngle) { if (dist < vdist && abs(losAngle) < kAngle) {
if (pExtra->canWalk) { if (pExtra->canWalk) {
int objDist = -1; int targetDist = -1; int hit = -1; int objDist = -1; int targetDist = -1; int hit = -1;
if (weaponType == kGenDudeWeaponHitscan) if (weaponType == kGenDudeWeaponHitscan)
@ -992,7 +992,7 @@ void aiGenDudeMoveForward(DBloodActor* actor)
int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4; int nTurnRange = (pDudeInfo->angSpeed << 2) >> 4;
pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047; pSprite->ang = (pSprite->ang + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047;
int nAccel = pDudeInfo->frontSpeed << 2; int nAccel = pDudeInfo->frontSpeed << 2;
if (klabs(nAng) > 341) if (abs(nAng) > 341)
return; return;
if (pXSprite->target == -1) if (pXSprite->target == -1)
pSprite->ang = (pSprite->ang + 256) & 2047; pSprite->ang = (pSprite->ang + 256) & 2047;
@ -1018,7 +1018,7 @@ void aiGenDudeMoveForward(DBloodActor* actor)
pSprite->ang = ((pSprite->ang + ClipRange(dang, -maxTurn, maxTurn)) & 2047); pSprite->ang = ((pSprite->ang + ClipRange(dang, -maxTurn, maxTurn)) & 2047);
// don't move forward if trying to turn around // don't move forward if trying to turn around
if (klabs(dang) > kAng60) if (abs(dang) > kAng60)
return; return;
int sin = Sin(pSprite->ang); int sin = Sin(pSprite->ang);

View file

@ -104,7 +104,7 @@ static void zombaThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 921 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 921 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieASearch); aiNewState(actor, &zombieASearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -147,10 +147,10 @@ static void zombaThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (klabs(nDeltaAngle) <= pDudeInfo->periphery) if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x400 && klabs(nDeltaAngle) < 85) if (nDist < 0x400 && abs(nDeltaAngle) < 85)
aiNewState(actor, &zombieAHack); aiNewState(actor, &zombieAHack);
return; return;
} }
@ -195,12 +195,12 @@ static void zombaThinkPonder(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (klabs(nDeltaAngle) <= pDudeInfo->periphery) if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x400) if (nDist < 0x400)
{ {
if (klabs(nDeltaAngle) < 85) if (abs(nDeltaAngle) < 85)
{ {
sfxPlay3DSound(pSprite, 1101, 1, 0); sfxPlay3DSound(pSprite, 1101, 1, 0);
aiNewState(actor, &zombieAHack); aiNewState(actor, &zombieAHack);
@ -238,7 +238,7 @@ static void myThinkTarget(DBloodActor* actor)
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum)) if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z-((pDudeInfo->eyeHeight*pSprite->yrepeat)<<2), pSprite->sectnum))
continue; continue;
int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024; int nDeltaAngle = ((getangle(dx,dy)+1024-pSprite->ang)&2047)-1024;
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pPlayer->nSprite); aiSetTarget(pXSprite, pPlayer->nSprite);
aiActivateDude(&bloodActors[pXSprite->reference]); aiActivateDude(&bloodActors[pXSprite->reference]);

View file

@ -105,7 +105,7 @@ static void zombfThinkGoto(DBloodActor* actor)
int nAngle = getangle(dx, dy); int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy); int nDist = approxDist(dx, dy);
aiChooseDirection(pSprite, pXSprite, nAngle); aiChooseDirection(pSprite, pXSprite, nAngle);
if (nDist < 512 && klabs(pSprite->ang - nAngle) < pDudeInfo->periphery) if (nDist < 512 && abs(pSprite->ang - nAngle) < pDudeInfo->periphery)
aiNewState(actor, &zombieFSearch); aiNewState(actor, &zombieFSearch);
aiThinkTarget(actor); aiThinkTarget(actor);
} }
@ -144,10 +144,10 @@ static void zombfThinkChase(DBloodActor* actor)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2; int height = (pDudeInfo->eyeHeight*pSprite->yrepeat)<<2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
{ {
if (klabs(nDeltaAngle) <= pDudeInfo->periphery) if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
if (nDist < 0x1400 && nDist > 0xe00 && klabs(nDeltaAngle) < 85) if (nDist < 0x1400 && nDist > 0xe00 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -166,7 +166,7 @@ static void zombfThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x1400 && nDist > 0x600 && klabs(nDeltaAngle) < 85) else if (nDist < 0x1400 && nDist > 0x600 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)
@ -185,7 +185,7 @@ static void zombfThinkChase(DBloodActor* actor)
break; break;
} }
} }
else if (nDist < 0x400 && klabs(nDeltaAngle) < 85) else if (nDist < 0x400 && abs(nDeltaAngle) < 85)
{ {
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
switch (hit) switch (hit)

View file

@ -316,7 +316,7 @@ void EnemyBubble(int nSprite) // 11
spritetype *pSprite = &sprite[nSprite]; spritetype *pSprite = &sprite[nSprite];
int top, bottom; int top, bottom;
GetSpriteExtents(pSprite, &top, &bottom); GetSpriteExtents(pSprite, &top, &bottom);
for (int i = 0; i < (klabs(zvel[nSprite])>>18); i++) for (int i = 0; i < (abs(zvel[nSprite])>>18); i++)
{ {
int nDist = (pSprite->xrepeat*(tileWidth(pSprite->picnum)/2))>>2; int nDist = (pSprite->xrepeat*(tileWidth(pSprite->picnum)/2))>>2;
int nAngle = Random(2048); int nAngle = Random(2048);
@ -430,7 +430,7 @@ void fxBouncingSleeve(int nSprite) // 16
else if (zv > 0) { else if (zv > 0) {
actFloorBounceVector((int*)& xvel[nSprite], (int*)& yvel[nSprite], &zv, pSprite->sectnum, 0x9000); actFloorBounceVector((int*)& xvel[nSprite], (int*)& yvel[nSprite], &zv, pSprite->sectnum, 0x9000);
zvel[nSprite] = zv; zvel[nSprite] = zv;
if (velFloor[pSprite->sectnum] == 0 && klabs(zvel[nSprite]) < 0x20000) { if (velFloor[pSprite->sectnum] == 0 && abs(zvel[nSprite]) < 0x20000) {
sleeveStopBouncing(pSprite); sleeveStopBouncing(pSprite);
return; return;
} }

View file

@ -644,8 +644,8 @@ inline int dmulscale30r(int a, int b, int c, int d)
inline int approxDist(int dx, int dy) inline int approxDist(int dx, int dy)
{ {
dx = klabs(dx); dx = abs(dx);
dy = klabs(dy); dy = abs(dy);
if (dx > dy) if (dx > dy)
dy = (3*dy)>>3; dy = (3*dy)>>3;
else else

View file

@ -142,13 +142,13 @@ bool FindSector(int nX, int nY, int *nSector)
bool CheckProximity(spritetype *pSprite, int nX, int nY, int nZ, int nSector, int nDist) bool CheckProximity(spritetype *pSprite, int nX, int nY, int nZ, int nSector, int nDist)
{ {
assert(pSprite != NULL); assert(pSprite != NULL);
int oX = klabs(nX-pSprite->x)>>4; int oX = abs(nX-pSprite->x)>>4;
if (oX >= nDist) return 0; if (oX >= nDist) return 0;
int oY = klabs(nY-pSprite->y)>>4; int oY = abs(nY-pSprite->y)>>4;
if (oY >= nDist) return 0; if (oY >= nDist) return 0;
int oZ = klabs(nZ-pSprite->z)>>8; int oZ = abs(nZ-pSprite->z)>>8;
if (oZ >= nDist) return 0; if (oZ >= nDist) return 0;
if (approxDist(oX, oY) >= nDist) return 0; if (approxDist(oX, oY) >= nDist) return 0;
@ -166,13 +166,13 @@ bool CheckProximity(spritetype *pSprite, int nX, int nY, int nZ, int nSector, in
bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist) bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist)
{ {
int oX = klabs(nX2-nX1)>>4; int oX = abs(nX2-nX1)>>4;
if (oX >= nDist) if (oX >= nDist)
return 0; return 0;
int oY = klabs(nY2-nY1)>>4; int oY = abs(nY2-nY1)>>4;
if (oY >= nDist) if (oY >= nDist)
return 0; return 0;
int oZ = klabs(nZ2-nZ1)>>4; int oZ = abs(nZ2-nZ1)>>4;
if (oZ >= nDist) if (oZ >= nDist)
return 0; return 0;
if (approxDist(oX, oY) >= nDist) return 0; if (approxDist(oX, oY) >= nDist) return 0;
@ -810,8 +810,8 @@ int GetClosestSectors(int nSector, int x, int y, int nDist, short *pSectors, cha
if (TestBitString(sectbits, nNextSector)) if (TestBitString(sectbits, nNextSector))
continue; continue;
SetBitString(sectbits, nNextSector); SetBitString(sectbits, nNextSector);
int dx = klabs(wall[pWall->point2].x - x)>>4; int dx = abs(wall[pWall->point2].x - x)>>4;
int dy = klabs(wall[pWall->point2].y - y)>>4; int dy = abs(wall[pWall->point2].y - y)>>4;
if (dx < nDist && dy < nDist) if (dx < nDist && dy < nDist)
{ {
if (approxDist(dx, dy) < nDist) if (approxDist(dx, dy) < nDist)

View file

@ -334,12 +334,12 @@ void GibFX(spritetype *pSprite, GIBFX *pGFX, CGibPosition *pPos, CGibVelocity *p
} }
else if (dz2 > dz1 && dz1 < 0x4000) else if (dz2 > dz1 && dz1 < 0x4000)
{ {
zvel[pFX->index] = -(int)Random((klabs(pGFX->at11)<<18)/120); zvel[pFX->index] = -(int)Random((abs(pGFX->at11)<<18)/120);
} }
else else
{ {
if ((pGFX->at11<<18)/120 < 0) if ((pGFX->at11<<18)/120 < 0)
zvel[pFX->index] = -(int)Random((klabs(pGFX->at11)<<18)/120); zvel[pFX->index] = -(int)Random((abs(pGFX->at11)<<18)/120);
else else
zvel[pFX->index] = Random2((pGFX->at11<<18)/120); zvel[pFX->index] = Random2((pGFX->at11<<18)/120);
} }

View file

@ -1157,7 +1157,7 @@ void debrisMove(int listIndex) {
if ((floorHit & 0xe000) == 0xc000) { if ((floorHit & 0xe000) == 0xc000) {
if ((sprite[floorHit & 0x1fff].cstat & 0x30) == 0x20) if ((sprite[floorHit & 0x1fff].cstat & 0x30) == 0x20)
if (klabs(bottom - floorZ) < 1024) floorZ -= 1024; if (abs(bottom - floorZ) < 1024) floorZ -= 1024;
} }
if (bottom >= floorZ) { if (bottom >= floorZ) {
@ -1171,7 +1171,7 @@ void debrisMove(int listIndex) {
actFloorBounceVector((int*)&xvel[nSprite], (int*)&yvel[nSprite], (int*)&v20, pSprite->sectnum, tmpFraction); actFloorBounceVector((int*)&xvel[nSprite], (int*)&yvel[nSprite], (int*)&v20, pSprite->sectnum, tmpFraction);
zvel[nSprite] = v20; zvel[nSprite] = v20;
if (velFloor[pSprite->sectnum] == 0 && klabs(zvel[nSprite]) < 0x10000) { if (velFloor[pSprite->sectnum] == 0 && abs(zvel[nSprite]) < 0x10000) {
zvel[nSprite] = 0; zvel[nSprite] = 0;
pXDebris->physAttr &= ~kPhysFalling; pXDebris->physAttr &= ~kPhysFalling;
} }
@ -2985,7 +2985,7 @@ bool condCheckDude(XSPRITE* pXCond, int cmpOp, bool PUSH) {
var = cansee(pSpr->x, pSpr->y, pSpr->z, pSpr->sectnum, pTrgt->x, pTrgt->y, pTrgt->z - eyeAboveZ, pTrgt->sectnum); var = cansee(pSpr->x, pSpr->y, pSpr->z, pSpr->sectnum, pTrgt->x, pTrgt->y, pTrgt->z - eyeAboveZ, pTrgt->sectnum);
if (cond == 4 && var > 0) { if (cond == 4 && var > 0) {
var = ((1024 + getangle(dx, dy) - pSpr->ang) & 2047) - 1024; var = ((1024 + getangle(dx, dy) - pSpr->ang) & 2047) - 1024;
var = (klabs(var) < ((arg1 <= 0) ? pInfo->periphery : ClipHigh(arg1, 2048))); var = (abs(var) < ((arg1 <= 0) ? pInfo->periphery : ClipHigh(arg1, 2048)));
} }
break; break;
} }
@ -3494,7 +3494,7 @@ bool aiFightDudeCanSeeTarget(XSPRITE* pXDude, DUDEINFO* pDudeInfo, spritetype* p
int losAngle = ((1024 + nAngle - pDude->ang) & 2047) - 1024; int losAngle = ((1024 + nAngle - pDude->ang) & 2047) - 1024;
// is the target visible? // is the target visible?
if (klabs(losAngle) < 2048) // 360 deg periphery here*/ if (abs(losAngle) < 2048) // 360 deg periphery here*/
return true; return true;
} }

View file

@ -1175,10 +1175,10 @@ void CheckPickUp(PLAYER *pPlayer)
nNextSprite = nextspritestat[nSprite]; nNextSprite = nextspritestat[nSprite];
if (pItem->flags&32) if (pItem->flags&32)
continue; continue;
int dx = klabs(x-pItem->x)>>4; int dx = abs(x-pItem->x)>>4;
if (dx > 48) if (dx > 48)
continue; continue;
int dy = klabs(y-pItem->y)>>4; int dy = abs(y-pItem->y)>>4;
if (dy > 48) if (dy > 48)
continue; continue;
int top, bottom; int top, bottom;

View file

@ -257,7 +257,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
else else
{ {
predict.at28 = q16horiz(interpolate(predict.at28.asq16(), 0, 0x4000)); predict.at28 = q16horiz(interpolate(predict.at28.asq16(), 0, 0x4000));
if (klabs(predict.at28.asq16()) < 4) if (abs(predict.at28.asq16()) < 4)
predict.at28 = q16horiz(0); predict.at28 = q16horiz(0);
} }
predict.at2c = -predict.at24.asq16() >> 9; predict.at2c = -predict.at24.asq16() >> 9;
@ -513,7 +513,7 @@ static void fakeMoveDude(spritetype *pSprite)
{ {
actFloorBounceVector(&predict.at5c, &predict.at60, &var44, predict.at68, 0); actFloorBounceVector(&predict.at5c, &predict.at60, &var44, predict.at68, 0);
predict.at64 = var44; predict.at64 = var44;
if (klabs(predict.at64) < 0x10000) if (abs(predict.at64) < 0x10000)
{ {
predict.at64 = velFloor[predict.at68]; predict.at64 = velFloor[predict.at68];
predict.at73 &= ~4; predict.at73 &= ~4;

View file

@ -80,7 +80,7 @@ int GetWaveValue(int a, int b, int c)
case 1: case 1:
return (b>>10)*c; return (b>>10)*c;
case 2: case 2:
return (klabs(128-(b>>3))*c)>>7; return (abs(128-(b>>3))*c)>>7;
case 3: case 3:
return ((b>>3)*c)>>8; return ((b>>3)*c)>>8;
case 4: case 4:

View file

@ -34,7 +34,7 @@ int OctantTable[8] = { 5, 6, 2, 1, 4, 7, 3, 0 };
int GetOctant(int x, int y) int GetOctant(int x, int y)
{ {
int vc = klabs(x)-klabs(y); int vc = abs(x)-abs(y);
return OctantTable[7-(x<0)-(y<0)*2-(vc<0)*4]; return OctantTable[7-(x<0)-(y<0)*2-(vc<0)*4];
} }

View file

@ -219,13 +219,13 @@ void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsec
hY = hitdata.pos.y; hY = hitdata.pos.y;
int dX = hX-*pX; int dX = hX-*pX;
int dY = hY-*pY; int dY = hY-*pY;
if (klabs(vX)+klabs(vY) > klabs(dX)+klabs(dY)) if (abs(vX)+abs(vY) > abs(dX)+abs(dY))
{ {
*vsectnum = nHSector; *vsectnum = nHSector;
dX -= ksgn(vX)<<6; dX -= ksgn(vX)<<6;
dY -= ksgn(vY)<<6; dY -= ksgn(vY)<<6;
int nDist; int nDist;
if (klabs(vX) > klabs(vY)) if (abs(vX) > abs(vY))
{ {
nDist = ClipHigh(DivScale(dX,vX, 16), othercameradist); nDist = ClipHigh(DivScale(dX,vX, 16), othercameradist);
} }
@ -266,13 +266,13 @@ void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum,
hY = hitdata.pos.y; hY = hitdata.pos.y;
int dX = hX-*pX; int dX = hX-*pX;
int dY = hY-*pY; int dY = hY-*pY;
if (klabs(vX)+klabs(vY) > klabs(dX)+klabs(dY)) if (abs(vX)+abs(vY) > abs(dX)+abs(dY))
{ {
*vsectnum = nHSector; *vsectnum = nHSector;
dX -= ksgn(vX)<<6; dX -= ksgn(vX)<<6;
dY -= ksgn(vY)<<6; dY -= ksgn(vY)<<6;
int nDist; int nDist;
if (klabs(vX) > klabs(vY)) if (abs(vX) > abs(vY))
{ {
nDist = ClipHigh(DivScale(dX,vX, 16), cameradist); nDist = ClipHigh(DivScale(dX,vX, 16), cameradist);
} }

View file

@ -388,7 +388,7 @@ void UpdateAimVector(PLAYER * pPlayer)
if (lz-zRange>bottom || lz+zRange<top) if (lz-zRange>bottom || lz+zRange<top)
continue; continue;
int angle = getangle(x2-x,y2-y); int angle = getangle(x2-x,y2-y);
if (klabs(((angle-pPSprite->ang+1024)&2047)-1024) > pWeaponTrack->angleRange) if (abs(((angle-pPSprite->ang+1024)&2047)-1024) > pWeaponTrack->angleRange)
continue; continue;
if (pPlayer->aimTargetsCount < 16 && cansee(x,y,z,pPSprite->sectnum,x2,y2,z2,pSprite->sectnum)) if (pPlayer->aimTargetsCount < 16 && cansee(x,y,z,pPSprite->sectnum,x2,y2,z2,pSprite->sectnum))
pPlayer->aimTargets[pPlayer->aimTargetsCount++] = nSprite; pPlayer->aimTargets[pPlayer->aimTargetsCount++] = nSprite;
@ -440,7 +440,7 @@ void UpdateAimVector(PLAYER * pPlayer)
if (lz-zRange>bottom || lz+zRange<top) if (lz-zRange>bottom || lz+zRange<top)
continue; continue;
int angle = getangle(dx,dy); int angle = getangle(dx,dy);
if (klabs(((angle-pPSprite->ang+1024)&2047)-1024) > pWeaponTrack->thingAngle) if (abs(((angle-pPSprite->ang+1024)&2047)-1024) > pWeaponTrack->thingAngle)
continue; continue;
if (pPlayer->aimTargetsCount < 16 && cansee(x,y,z,pPSprite->sectnum,pSprite->x,pSprite->y,pSprite->z,pSprite->sectnum)) if (pPlayer->aimTargetsCount < 16 && cansee(x,y,z,pPSprite->sectnum,pSprite->x,pSprite->y,pSprite->z,pSprite->sectnum))
pPlayer->aimTargets[pPlayer->aimTargetsCount++] = nSprite; pPlayer->aimTargets[pPlayer->aimTargetsCount++] = nSprite;
@ -957,7 +957,7 @@ void WeaponUpdateState(PLAYER *pPlayer)
pPlayer->weaponQav = 42; pPlayer->weaponQav = 42;
break; break;
case 10: case 10:
if (pXSprite->height < 256 && klabs(pPlayer->swayHeight) > 768) if (pXSprite->height < 256 && abs(pPlayer->swayHeight) > 768)
pPlayer->weaponQav = 102; pPlayer->weaponQav = 102;
else else
pPlayer->weaponQav = 101; pPlayer->weaponQav = 101;

View file

@ -17,8 +17,6 @@ static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx)
return int64_t(eax) * edx / ecx; return int64_t(eax) * edx / ecx;
} }
#define klabs(x) abs(x)
static inline constexpr int ksgn(int32_t a) { return (a > 0) - (a < 0); } static inline constexpr int ksgn(int32_t a) { return (a > 0) - (a < 0); }
inline int sgn(int32_t a) { return (a > 0) - (a < 0); } inline int sgn(int32_t a) { return (a > 0) - (a < 0); }

View file

@ -261,9 +261,9 @@ static int cliptestsector(int const dasect, int const nextsect, int32_t const fl
if ((sec->floorstat|sec->ceilingstat) & 2) if ((sec->floorstat|sec->ceilingstat) & 2)
getcorrectzsofslope(dasect, pos.x, pos.y, &dacz, &daz); getcorrectzsofslope(dasect, pos.x, pos.y, &dacz, &daz);
int32_t const sec2height = klabs(daz2-dacz2); int32_t const sec2height = abs(daz2-dacz2);
return ((klabs(daz-dacz) > sec2height && // clip if the current sector is taller and the next is too small return ((abs(daz-dacz) > sec2height && // clip if the current sector is taller and the next is too small
sec2height < (ceildist+(CLIPCURBHEIGHT<<1))) || sec2height < (ceildist+(CLIPCURBHEIGHT<<1))) ||
((sec2->floorstat&1) == 0 && // parallaxed floor curbs don't clip ((sec2->floorstat&1) == 0 && // parallaxed floor curbs don't clip
@ -352,7 +352,7 @@ static inline void keepaway(int32_t *x, int32_t *y, int32_t w)
const int32_t x1 = clipit[w].x1, dx = clipit[w].x2-x1; const int32_t x1 = clipit[w].x1, dx = clipit[w].x2-x1;
const int32_t y1 = clipit[w].y1, dy = clipit[w].y2-y1; const int32_t y1 = clipit[w].y1, dy = clipit[w].y2-y1;
const int32_t ox = ksgn(-dy), oy = ksgn(dx); const int32_t ox = ksgn(-dy), oy = ksgn(dx);
char first = (klabs(dx) <= klabs(dy)); char first = (abs(dx) <= abs(dy));
do do
{ {
@ -752,7 +752,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
// I don't know if this one actually overflows or not, but I highly doubt it hurts to check // I don't know if this one actually overflows or not, but I highly doubt it hurts to check
int32_t const templl2 int32_t const templl2
= (int32_t)clamp(compat_maybe_truncate_to_int32((int64_t)(goal.x - vec.x) * clipr.x + (int64_t)(goal.y - vec.y) * clipr.y), INT32_MIN, INT32_MAX); = (int32_t)clamp(compat_maybe_truncate_to_int32((int64_t)(goal.x - vec.x) * clipr.x + (int64_t)(goal.y - vec.y) * clipr.y), INT32_MIN, INT32_MAX);
int32_t const i = (enginecompatibility_mode == ENGINECOMPATIBILITY_19950829 || (klabs(templl2)>>11) < templl) ? int32_t const i = (enginecompatibility_mode == ENGINECOMPATIBILITY_19950829 || (abs(templl2)>>11) < templl) ?
DivScaleL(templl2, templl, 20) : 0; DivScaleL(templl2, templl, 20) : 0;
goal = { MulScale(clipr.x, i, 20)+vec.x, MulScale(clipr.y, i, 20)+vec.y }; goal = { MulScale(clipr.x, i, 20)+vec.x, MulScale(clipr.y, i, 20)+vec.y };
@ -1105,7 +1105,7 @@ void getzrange(const vec3_t *pos, int16_t sectnum,
case CSTAT_SPRITE_ALIGNMENT_FACING: case CSTAT_SPRITE_ALIGNMENT_FACING:
{ {
int32_t k = walldist+(sprite[j].clipdist<<2)+1; int32_t k = walldist+(sprite[j].clipdist<<2)+1;
if ((klabs(v1.x-pos->x) <= k) && (klabs(v1.y-pos->y) <= k)) if ((abs(v1.x-pos->x) <= k) && (abs(v1.y-pos->y) <= k))
{ {
daz = sprite[j].z + spriteheightofs(j, &k, 1); daz = sprite[j].z + spriteheightofs(j, &k, 1);
daz2 = daz - k; daz2 = daz - k;
@ -1204,8 +1204,8 @@ int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in,
newpos.vec2 = { in.x + scale(vx, topt, bot), in.y + scale(vy, topt, bot) }; newpos.vec2 = { in.x + scale(vx, topt, bot), in.y + scale(vy, topt, bot) };
if (klabs(newpos.x - in.x) + klabs(newpos.y - in.y) + strictly_smaller_than_p > if (abs(newpos.x - in.x) + abs(newpos.y - in.y) + strictly_smaller_than_p >
klabs(intp->x - in.x) + klabs(intp->y - in.y)) abs(intp->x - in.x) + abs(intp->y - in.y))
return 0; return 0;
*intp = newpos; *intp = newpos;
@ -1248,7 +1248,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
if (j != 0) if (j != 0)
{ {
i = ((z - sv->z)<<8)+DMulScale(dax,sv->y-wal->y,-day,sv->x-wal->x, 15); i = ((z - sv->z)<<8)+DMulScale(dax,sv->y-wal->y,-day,sv->x-wal->x, 15);
if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j))) if (((i^j) >= 0) && ((abs(i)>>1) < abs(j)))
{ {
i = DivScale(i,j, 30); i = DivScale(i,j, 30);
x1 = sv->x + MulScale(vx,i, 30); x1 = sv->x + MulScale(vx,i, 30);
@ -1260,7 +1260,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
else if ((how*vz > 0) && (how*sv->z <= how*z)) else if ((how*vz > 0) && (how*sv->z <= how*z))
{ {
z1 = z; i = z1-sv->z; z1 = z; i = z1-sv->z;
if ((klabs(i)>>1) < vz*how) if ((abs(i)>>1) < vz*how)
{ {
i = DivScale(i,vz, 30); i = DivScale(i,vz, 30);
x1 = sv->x + MulScale(vx,i, 30); x1 = sv->x + MulScale(vx,i, 30);
@ -1268,7 +1268,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
} }
} }
if ((x1 != INT32_MAX) && (klabs(x1-sv->x)+klabs(y1-sv->y) < klabs((hit->pos.x)-sv->x)+klabs((hit->pos.y)-sv->y))) if ((x1 != INT32_MAX) && (abs(x1-sv->x)+abs(y1-sv->y) < abs((hit->pos.x)-sv->x)+abs((hit->pos.y)-sv->y)))
{ {
if (tmp==NULL) if (tmp==NULL)
{ {
@ -1361,7 +1361,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
{ {
if (vz != 0) if (vz != 0)
if ((intz <= sec->ceilingz) || (intz >= sec->floorz)) if ((intz <= sec->ceilingz) || (intz >= sec->floorz))
if (klabs(intx-sv->x)+klabs(inty-sv->y) < klabs(hit->pos.x-sv->x)+klabs(hit->pos.y-sv->y)) if (abs(intx-sv->x)+abs(inty-sv->y) < abs(hit->pos.x-sv->x)+abs(hit->pos.y-sv->y))
{ {
//x1,y1,z1 are temp variables //x1,y1,z1 are temp variables
if (vz > 0) z1 = sec->floorz; else z1 = sec->ceilingz; if (vz > 0) z1 = sec->floorz; else z1 = sec->ceilingz;
@ -1374,7 +1374,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
} }
} }
} }
else if (klabs(intx-sv->x)+klabs(inty-sv->y) >= klabs((hit->pos.x)-sv->x)+klabs((hit->pos.y)-sv->y)) else if (abs(intx-sv->x)+abs(inty-sv->y) >= abs((hit->pos.x)-sv->x)+abs((hit->pos.y)-sv->y))
continue; continue;
if (!curspr) if (!curspr)
@ -1383,14 +1383,14 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
{ {
if ((nextsector < 0) || (wal->cstat&dawalclipmask)) if ((nextsector < 0) || (wal->cstat&dawalclipmask))
{ {
if ((klabs(intx-sv->x)+klabs(inty-sv->y) < klabs(hit->pos.x-sv->x)+klabs(hit->pos.y-sv->y))) if ((abs(intx-sv->x)+abs(inty-sv->y) < abs(hit->pos.x-sv->x)+abs(hit->pos.y-sv->y)))
hit_set(hit, dasector, z, -1, intx, inty, intz); hit_set(hit, dasector, z, -1, intx, inty, intz);
continue; continue;
} }
if (intz <= sector[nextsector].ceilingz || intz >= sector[nextsector].floorz) if (intz <= sector[nextsector].ceilingz || intz >= sector[nextsector].floorz)
{ {
if ((klabs(intx-sv->x)+klabs(inty-sv->y) < klabs(hit->pos.x-sv->x)+klabs(hit->pos.y-sv->y))) if ((abs(intx-sv->x)+abs(inty-sv->y) < abs(hit->pos.x-sv->x)+abs(hit->pos.y-sv->y)))
hit_set(hit, dasector, z, -1, intx, inty, intz); hit_set(hit, dasector, z, -1, intx, inty, intz);
continue; continue;
} }
@ -1463,7 +1463,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
ucoefup16 = rintersect(sv->x,sv->y,sv->z,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz); ucoefup16 = rintersect(sv->x,sv->y,sv->z,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz);
if (ucoefup16 == -1) continue; if (ucoefup16 == -1) continue;
if (klabs(intx-sv->x)+klabs(inty-sv->y) > klabs((hit->pos.x)-sv->x)+klabs((hit->pos.y)-sv->y)) if (abs(intx-sv->x)+abs(inty-sv->y) > abs((hit->pos.x)-sv->x)+abs((hit->pos.y)-sv->y))
continue; continue;
daz = spr->z + spriteheightofs(z, &k, 1); daz = spr->z + spriteheightofs(z, &k, 1);
@ -1517,7 +1517,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
inty = sv->y+scale(intz-sv->z,vy,vz); inty = sv->y+scale(intz-sv->z,vy,vz);
} }
if (klabs(intx-sv->x)+klabs(inty-sv->y) > klabs((hit->pos.x)-sv->x)+klabs((hit->pos.y)-sv->y)) if (abs(intx-sv->x)+abs(inty-sv->y) > abs((hit->pos.x)-sv->x)+abs((hit->pos.y)-sv->y))
continue; continue;
get_floorspr_points((uspriteptr_t)spr, intx, inty, &x1, &x2, &x3, &x4, get_floorspr_points((uspriteptr_t)spr, intx, inty, &x1, &x2, &x3, &x4,

View file

@ -365,12 +365,12 @@ static inline void initksqrt(void)
root = (root+num/root)>>1; root = (root+num/root)>>1;
} while((temp-root+1) > 2); } while((temp-root+1) > 2);
temp = root*root-num; temp = root*root-num;
while (klabs(int32_t(temp-2*root+1)) < klabs(temp)) while (abs(int32_t(temp-2*root+1)) < abs(temp))
{ {
temp += 1-int(2*root); temp += 1-int(2*root);
root--; root--;
} }
while (klabs(int32_t(temp+2*root+1)) < klabs(temp)) while (abs(int32_t(temp+2*root+1)) < abs(temp))
{ {
temp += 2*root+1; temp += 2*root+1;
root++; root++;
@ -677,13 +677,13 @@ int32_t lintersect(const int32_t originX, const int32_t originY, const int32_t o
// If the point is outside of the bounds of the line segment, we know we don't have an intersection. // If the point is outside of the bounds of the line segment, we know we don't have an intersection.
// t is < 0 if (originDiffCrossLineVec^rayCrossLineVec) & signBit) // t is < 0 if (originDiffCrossLineVec^rayCrossLineVec) & signBit)
// u is < 0 if (originDiffCrossRay^rayCrossLineVec) & signBit // u is < 0 if (originDiffCrossRay^rayCrossLineVec) & signBit
// t is > 1 if klabs(originDiffCrossLineVec) > klabs(rayCrossLineVec) // t is > 1 if abs(originDiffCrossLineVec) > abs(rayCrossLineVec)
// u is > 1 if klabs(originDiffCrossRay) > klabs(rayCrossLineVec) // u is > 1 if abs(originDiffCrossRay) > abs(rayCrossLineVec)
// where int32_t u = tabledivide64(((int64_t) originDiffCrossRay) << 24L, rayCrossLineVec); // where int32_t u = tabledivide64(((int64_t) originDiffCrossRay) << 24L, rayCrossLineVec);
if (((originDiffCrossLineVec^rayCrossLineVec) & signBit) || if (((originDiffCrossLineVec^rayCrossLineVec) & signBit) ||
((originDiffCrossRay^rayCrossLineVec) & signBit) || ((originDiffCrossRay^rayCrossLineVec) & signBit) ||
klabs(originDiffCrossLineVec) > klabs(rayCrossLineVec) || abs(originDiffCrossLineVec) > abs(rayCrossLineVec) ||
klabs(originDiffCrossRay) > klabs(rayCrossLineVec)) abs(originDiffCrossRay) > abs(rayCrossLineVec))
{ {
// line segments do not overlap // line segments do not overlap
return 0; return 0;
@ -1127,8 +1127,8 @@ static inline int comparetsprites(int const k, int const l)
tspriteptr[k]->owner != tspriteptr[l]->owner) tspriteptr[k]->owner != tspriteptr[l]->owner)
return tspriteptr[k]->owner - tspriteptr[l]->owner; return tspriteptr[k]->owner - tspriteptr[l]->owner;
if (klabs(spritesxyz[k].z-globalposz) != klabs(spritesxyz[l].z-globalposz)) if (abs(spritesxyz[k].z-globalposz) != abs(spritesxyz[l].z-globalposz))
return klabs(spritesxyz[k].z-globalposz)-klabs(spritesxyz[l].z-globalposz); return abs(spritesxyz[k].z-globalposz)-abs(spritesxyz[l].z-globalposz);
return 0; return 0;
} }
@ -1179,7 +1179,7 @@ static void sortsprites(int const start, int const end)
if (!(s->cstat&128)) if (!(s->cstat&128))
spritesxyz[k].z -= (yspan>>1); spritesxyz[k].z -= (yspan>>1);
if (klabs(spritesxyz[k].z-globalposz) < (yspan>>1)) if (abs(spritesxyz[k].z-globalposz) < (yspan>>1))
spritesxyz[k].z = globalposz; spritesxyz[k].z = globalposz;
} }
} }
@ -2084,7 +2084,7 @@ int32_t getangle(int32_t xvect, int32_t yvect)
rv = 256 + ((xvect < 0) << 10); rv = 256 + ((xvect < 0) << 10);
else if (xvect == -yvect) else if (xvect == -yvect)
rv = 768 + ((xvect > 0) << 10); rv = 768 + ((xvect > 0) << 10);
else if (klabs(xvect) > klabs(yvect)) else if (abs(xvect) > abs(yvect))
rv = ((radarang[640 + scale(160, yvect, xvect)] >> 6) + ((xvect < 0) << 10)) & 2047; rv = ((radarang[640 + scale(160, yvect, xvect)] >> 6) + ((xvect < 0) << 10)) & 2047;
else rv = ((radarang[640 - scale(160, xvect, yvect)] >> 6) + 512 + ((yvect < 0) << 10)) & 2047; else rv = ((radarang[640 - scale(160, xvect, yvect)] >> 6) + 512 + ((yvect < 0) << 10)) & 2047;
@ -2105,7 +2105,7 @@ fixed_t gethiq16angle(int32_t xvect, int32_t yvect)
rv = IntToFixed(256 + ((xvect < 0) << 10)); rv = IntToFixed(256 + ((xvect < 0) << 10));
else if (xvect == -yvect) else if (xvect == -yvect)
rv = IntToFixed(768 + ((xvect > 0) << 10)); rv = IntToFixed(768 + ((xvect > 0) << 10));
else if (klabs(xvect) > klabs(yvect)) else if (abs(xvect) > abs(yvect))
rv = ((qradarang[5120 + scale(1280, yvect, xvect)] >> 6) + IntToFixed(((xvect < 0) << 10))) & 0x7FFFFFF; rv = ((qradarang[5120 + scale(1280, yvect, xvect)] >> 6) + IntToFixed(((xvect < 0) << 10))) & 0x7FFFFFF;
else rv = ((qradarang[5120 - scale(1280, xvect, yvect)] >> 6) + IntToFixed(512 + ((yvect < 0) << 10))) & 0x7FFFFFF; else rv = ((qradarang[5120 - scale(1280, xvect, yvect)] >> 6) + IntToFixed(512 + ((yvect < 0) << 10))) & 0x7FFFFFF;
@ -2561,13 +2561,13 @@ int32_t getwalldist(vec2_t const in, int const wallnum)
{ {
vec2_t closest; vec2_t closest;
getclosestpointonwall_internal(in, wallnum, &closest); getclosestpointonwall_internal(in, wallnum, &closest);
return klabs(closest.x - in.x) + klabs(closest.y - in.y); return abs(closest.x - in.x) + abs(closest.y - in.y);
} }
int32_t getwalldist(vec2_t const in, int const wallnum, vec2_t * const out) int32_t getwalldist(vec2_t const in, int const wallnum, vec2_t * const out)
{ {
getclosestpointonwall_internal(in, wallnum, out); getclosestpointonwall_internal(in, wallnum, out);
return klabs(out->x - in.x) + klabs(out->y - in.y); return abs(out->x - in.x) + abs(out->y - in.y);
} }

View file

@ -64,7 +64,7 @@ extern uint16_t sqrtable[4096], shlookup[4096+256],sqrtable_old[2048];
inline int32_t ksqrtasm_old(int32_t n) inline int32_t ksqrtasm_old(int32_t n)
{ {
uint32_t shift = 0; uint32_t shift = 0;
n = klabs((int32_t)n); n = abs((int32_t)n);
while (n >= 2048) while (n >= 2048)
{ {
n >>= 2; n >>= 2;

View file

@ -2093,7 +2093,7 @@ static void polymost_drawalls(int32_t const bunch)
if (maskingOneWay) if (maskingOneWay)
{ {
vec2_t n, pos = { globalposx, globalposy }; vec2_t n, pos = { globalposx, globalposy };
if (!polymost_getclosestpointonwall(&pos, wallnum, &n) && klabs(pos.x - n.x) + klabs(pos.y - n.y) <= 128) if (!polymost_getclosestpointonwall(&pos, wallnum, &n) && abs(pos.x - n.x) + abs(pos.y - n.y) <= 128)
break; break;
} }
@ -2903,7 +2903,7 @@ static inline int32_t polymost_findwall(tspritetype const * const tspr, vec2_t c
if ((wall[i].nextsector == -1 || ((sector[wall[i].nextsector].ceilingz > (tspr->z - ((tsiz->y * tspr->yrepeat) << 2))) || if ((wall[i].nextsector == -1 || ((sector[wall[i].nextsector].ceilingz > (tspr->z - ((tsiz->y * tspr->yrepeat) << 2))) ||
sector[wall[i].nextsector].floorz < tspr->z)) && !polymost_getclosestpointonwall((const vec2_t *) tspr, i, &n)) sector[wall[i].nextsector].floorz < tspr->z)) && !polymost_getclosestpointonwall((const vec2_t *) tspr, i, &n))
{ {
int const dst = klabs(tspr->x - n.x) + klabs(tspr->y - n.y); int const dst = abs(tspr->x - n.x) + abs(tspr->y - n.y);
if (dst <= dist) if (dst <= dist)
{ {

View file

@ -467,7 +467,7 @@ void FuncFish(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
int nHeight = GetSpriteHeight(nSprite) >> 1; int nHeight = GetSpriteHeight(nSprite) >> 1;
int z = klabs(sprite[nTarget].z - sprite[nSprite].z); int z = abs(sprite[nTarget].z - sprite[nSprite].z);
if (z <= nHeight) if (z <= nHeight)
{ {

View file

@ -310,8 +310,8 @@ int CheckCloseRange(short nPlayer, int *x, int *y, int *z, short *nSector)
int ecx = bsin(150, -3); int ecx = bsin(150, -3);
uint32_t xDiff = klabs(hitX - *x); uint32_t xDiff = abs(hitX - *x);
uint32_t yDiff = klabs(hitY - *y); uint32_t yDiff = abs(hitY - *y);
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;

View file

@ -244,15 +244,15 @@ void TintPalette(int r, int g, int b)
int nVal; int nVal;
// loc_17F49 // loc_17F49
if (klabs(r) > klabs(g)) { if (abs(r) > abs(g)) {
nVal = klabs(r); nVal = abs(r);
} }
else { else {
nVal = klabs(g); nVal = abs(g);
} }
if (nVal < klabs(b)) { if (nVal < abs(b)) {
nVal = klabs(b); nVal = abs(b);
} }
nPalDiff += nVal; nPalDiff += nVal;

View file

@ -460,8 +460,8 @@ void FuncLion(int a, int nDamage, int nRun)
if (hitwall > -1) if (hitwall > -1)
{ {
int theX = klabs(hitx - x); int theX = abs(hitx - x);
int theY = klabs(hity - y); int theY = abs(hity - y);
if ((theX + theY) < nCheckDist) if ((theX + theY) < nCheckDist)
{ {

View file

@ -705,8 +705,8 @@ int PlotCourseToSprite(int nSprite1, int nSprite2)
sprite[nSprite1].ang = GetMyAngle(x, y); sprite[nSprite1].ang = GetMyAngle(x, y);
uint32_t x2 = klabs(x); uint32_t x2 = abs(x);
uint32_t y2 = klabs(y); uint32_t y2 = abs(y);
uint32_t diff = x2 * x2 + y2 * y2; uint32_t diff = x2 * x2 + y2 * y2;
@ -751,11 +751,11 @@ int FindPlayer(int nSprite, int nDistance)
if ((sprite[nPlayerSprite].cstat & 0x101) && (!(sprite[nPlayerSprite].cstat & 0x8000))) if ((sprite[nPlayerSprite].cstat & 0x101) && (!(sprite[nPlayerSprite].cstat & 0x8000)))
{ {
int v9 = klabs(sprite[nPlayerSprite].x - x); int v9 = abs(sprite[nPlayerSprite].x - x);
if (v9 < nDistance) if (v9 < nDistance)
{ {
int v10 = klabs(sprite[nPlayerSprite].y - y); int v10 = abs(sprite[nPlayerSprite].y - y);
if (v10 < nDistance && cansee(sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].z - 7680, sprite[nPlayerSprite].sectnum, x, y, z, nSector)) if (v10 < nDistance && cansee(sprite[nPlayerSprite].x, sprite[nPlayerSprite].y, sprite[nPlayerSprite].z - 7680, sprite[nPlayerSprite].sectnum, x, y, z, nSector))
{ {
@ -867,8 +867,8 @@ void CreatePushBlock(int nSector)
for (i = 0; i < nWalls; i++) for (i = 0; i < nWalls; i++)
{ {
uint32_t xDiff = klabs(xAvg - wall[startwall + i].x); uint32_t xDiff = abs(xAvg - wall[startwall + i].x);
uint32_t yDiff = klabs(yAvg - wall[startwall + i].y); uint32_t yDiff = abs(yAvg - wall[startwall + i].y);
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
@ -1143,8 +1143,8 @@ void SetQuake(short nSprite, int nVal)
{ {
int nPlayerSprite = PlayerList[i].nSprite; int nPlayerSprite = PlayerList[i].nSprite;
uint32_t xDiff = klabs((int32_t)((sprite[nPlayerSprite].x - x) >> 8)); uint32_t xDiff = abs((int32_t)((sprite[nPlayerSprite].x - x) >> 8));
uint32_t yDiff = klabs((int32_t)((sprite[nPlayerSprite].y - y) >> 8)); uint32_t yDiff = abs((int32_t)((sprite[nPlayerSprite].y - y) >> 8));
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
@ -1205,8 +1205,8 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
int nMyAngle = GetMyAngle(sprite[nSprite2].x - sprite[nSprite].x, sprite[nSprite2].y - sprite[nSprite].y); int nMyAngle = GetMyAngle(sprite[nSprite2].x - sprite[nSprite].x, sprite[nSprite2].y - sprite[nSprite].y);
uint32_t xDiff = klabs(sprite[nSprite2].x - sprite[nSprite].x); uint32_t xDiff = abs(sprite[nSprite2].x - sprite[nSprite].x);
uint32_t yDiff = klabs(sprite[nSprite2].y - sprite[nSprite].y); uint32_t yDiff = abs(sprite[nSprite2].y - sprite[nSprite].y);
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;
@ -1221,11 +1221,11 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
int var_18 = GetMyAngle(nSqrt, ((sprite[nSprite2].z - nHeight) - sprite[nSprite].z) >> 8); int var_18 = GetMyAngle(nSqrt, ((sprite[nSprite2].z - nHeight) - sprite[nSprite].z) >> 8);
int nAngDelta = AngleDelta(sprite[nSprite].ang, nMyAngle, 1024); int nAngDelta = AngleDelta(sprite[nSprite].ang, nMyAngle, 1024);
int nAngDelta2 = klabs(nAngDelta); int nAngDelta2 = abs(nAngDelta);
if (nAngDelta2 > 63) if (nAngDelta2 > 63)
{ {
nAngDelta2 = klabs(nAngDelta >> 6); nAngDelta2 = abs(nAngDelta >> 6);
ebx /= nAngDelta2; ebx /= nAngDelta2;
@ -1234,7 +1234,7 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
} }
} }
int nAngDeltaC = klabs(nAngDelta); int nAngDeltaC = abs(nAngDelta);
if (nAngDeltaC > push1) if (nAngDeltaC > push1)
{ {
@ -1252,7 +1252,7 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
sprite[nSprite].ang = nAngle; sprite[nSprite].ang = nAngle;
int eax = klabs(bcos(sprite[nSprite].zvel)); int eax = abs(bcos(sprite[nSprite].zvel));
int x = ((bcos(nAngle) * ebx) >> 14) * eax; int x = ((bcos(nAngle) * ebx) >> 14) * eax;
int y = ((bsin(nAngle) * ebx) >> 14) * eax; int y = ((bsin(nAngle) * ebx) >> 14) * eax;

View file

@ -155,8 +155,8 @@ void CheckMummyRevive(short nMummy)
continue; continue;
} }
int x = klabs(sprite[nSprite2].x - sprite[nSprite].x) >> 8; int x = abs(sprite[nSprite2].x - sprite[nSprite].x) >> 8;
int y = klabs(sprite[nSprite2].y - sprite[nSprite].y) >> 8; int y = abs(sprite[nSprite2].y - sprite[nSprite].y) >> 8;
if (x <= 20 && y <= 20) if (x <= 20 && y <= 20)
{ {

View file

@ -168,8 +168,8 @@ void feebtag(int x, int y, int z, int nSector, short *nSprite, int nVal2, int nV
if (nStat >= 900 && !(sprite[i].cstat & 0x8000)) if (nStat >= 900 && !(sprite[i].cstat & 0x8000))
{ {
uint32_t xDiff = klabs(sprite[i].x - x); uint32_t xDiff = abs(sprite[i].x - x);
uint32_t yDiff = klabs(sprite[i].y - y); uint32_t yDiff = abs(sprite[i].y - y);
int zDiff = sprite[i].z - z; int zDiff = sprite[i].z - z;
if (zDiff < 5120 && zDiff > -25600) if (zDiff < 5120 && zDiff > -25600)

View file

@ -293,8 +293,8 @@ int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2)
int edx = ((pSprite2->z - nTileY) - pSprite->z) >> 8; int edx = ((pSprite2->z - nTileY) - pSprite->z) >> 8;
uint32_t xDiff = klabs(pSprite2->x - pSprite->x); uint32_t xDiff = abs(pSprite2->x - pSprite->x);
uint32_t yDiff = klabs(pSprite2->y - pSprite->y); uint32_t yDiff = abs(pSprite2->y - pSprite->y);
uint32_t sqrtVal = xDiff * xDiff + yDiff * yDiff; uint32_t sqrtVal = xDiff * xDiff + yDiff * yDiff;
@ -310,14 +310,14 @@ int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2)
int nAngDelta = AngleDelta(pSprite->ang, nMyAngle, 1024); int nAngDelta = AngleDelta(pSprite->ang, nMyAngle, 1024);
if (klabs(nAngDelta) > 127) if (abs(nAngDelta) > 127)
{ {
val1 /= klabs(nAngDelta>>7); val1 /= abs(nAngDelta>>7);
if (val1 < 256) if (val1 < 256)
val1 = 256; val1 = 256;
} }
if (klabs(nAngDelta) > val2) if (abs(nAngDelta) > val2)
{ {
if (nAngDelta < 0) if (nAngDelta < 0)
nAngDelta = -val2; nAngDelta = -val2;
@ -333,13 +333,13 @@ int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2)
pSprite->ang = nAngle; pSprite->ang = nAngle;
int da = pSprite->zvel; int da = pSprite->zvel;
int x = klabs(bcos(da)); int x = abs(bcos(da));
int v26 = x * ((val1 * bcos(nAngle)) >> 14); int v26 = x * ((val1 * bcos(nAngle)) >> 14);
int v27 = x * ((val1 * bsin(nAngle)) >> 14); int v27 = x * ((val1 * bsin(nAngle)) >> 14);
uint32_t xDiff = klabs((int32_t)(v26 >> 8)); uint32_t xDiff = abs((int32_t)(v26 >> 8));
uint32_t yDiff = klabs((int32_t)(v27 >> 8)); uint32_t yDiff = abs((int32_t)(v27 >> 8));
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;

View file

@ -271,8 +271,8 @@ void FuncRat(int a, int nDamage, int nRun)
return; return;
} }
int xVal = klabs(sprite[nSprite].x - sprite[nTarget].x); int xVal = abs(sprite[nSprite].x - sprite[nTarget].x);
int yVal = klabs(sprite[nSprite].y - sprite[nTarget].y); int yVal = abs(sprite[nSprite].y - sprite[nTarget].y);
if (xVal > 50 || yVal > 50) if (xVal > 50 || yVal > 50)
{ {
@ -324,8 +324,8 @@ void FuncRat(int a, int nDamage, int nRun)
MoveCreature(nSprite); MoveCreature(nSprite);
int xVal = klabs(sprite[nSprite].x - sprite[nTarget].x); int xVal = abs(sprite[nSprite].x - sprite[nTarget].x);
int yVal = klabs(sprite[nSprite].y - sprite[nTarget].y); int yVal = abs(sprite[nSprite].y - sprite[nTarget].y);
if (xVal >= 50 || yVal >= 50) if (xVal >= 50 || yVal >= 50)
{ {

View file

@ -1554,22 +1554,22 @@ int runlist_CheckRadialDamage(short nSprite)
int y = (sprite[nSprite].y - sprite[nRadialSpr].y) >> 8; int y = (sprite[nSprite].y - sprite[nRadialSpr].y) >> 8;
int z = (sprite[nSprite].z - sprite[nRadialSpr].z) >> 12; int z = (sprite[nSprite].z - sprite[nRadialSpr].z) >> 12;
if (klabs(x) > nDamageRadius) { if (abs(x) > nDamageRadius) {
return 0; return 0;
} }
if (klabs(y) > nDamageRadius) { if (abs(y) > nDamageRadius) {
return 0; return 0;
} }
if (klabs(z) > nDamageRadius) { if (abs(z) > nDamageRadius) {
return 0; return 0;
} }
int edi = 0; int edi = 0;
uint32_t xDiff = klabs(x); uint32_t xDiff = abs(x);
uint32_t yDiff = klabs(y); uint32_t yDiff = abs(y);
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;

View file

@ -142,8 +142,8 @@ int BuildSnake(short nPlayer, short zVal)
hitsect = hitData.sect; hitsect = hitData.sect;
hitsprite = hitData.sprite; hitsprite = hitData.sprite;
uint32_t xDiff = klabs(hitx - x); uint32_t xDiff = abs(hitx - x);
uint32_t yDiff = klabs(hity - y); uint32_t yDiff = abs(hity - y);
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff;

View file

@ -141,12 +141,12 @@ static void analyzesprites(double const smoothratio)
int edx = ((vcos * yval) + (xval * vsin)) >> 14; int edx = ((vcos * yval) + (xval * vsin)) >> 14;
int ebx = klabs(((vcos * xval) - (yval * vsin)) >> 14); int ebx = abs(((vcos * xval) - (yval * vsin)) >> 14);
if (!ebx) if (!ebx)
continue; continue;
edx = (klabs(edx) * 32) / ebx; edx = (abs(edx) * 32) / ebx;
if (ebx < 1000 && ebx < var_2C && edx < 10) if (ebx < 1000 && ebx < var_2C && edx < 10)
{ {
besttarget = nSprite; besttarget = nSprite;
@ -156,7 +156,7 @@ static void analyzesprites(double const smoothratio)
else if (ebx < 30000) else if (ebx < 30000)
{ {
int t = var_38 - edx; int t = var_38 - edx;
if (t > 3 || (ebx < var_2C && klabs(t) < 5)) if (t > 3 || (ebx < var_2C && abs(t) < 5))
{ {
var_38 = edx; var_38 = edx;
var_2C = ebx; var_2C = ebx;

View file

@ -571,7 +571,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang,
else else
i = TILE_APLAYERTOP; i = TILE_APLAYERTOP;
j = klabs(pp.truefz - pp.posz) >> 8; j = abs(pp.truefz - pp.posz) >> 8;
j = MulScale(czoom * (pspr->yrepeat + j), yxaspect, 16); j = MulScale(czoom * (pspr->yrepeat + j), yxaspect, 16);
if (j < 22000) j = 22000; if (j < 22000) j = 22000;

View file

@ -143,7 +143,7 @@ void fakedomovethings(void)
j = getflorzofslope(psect,myx,myy); j = getflorzofslope(psect,myx,myy);
if(clz.type == kHitSector && psectlotag == 1 && klabs(myz-j) > gs.playerheight+(16<<8) ) if(clz.type == kHitSector && psectlotag == 1 && abs(myz-j) > gs.playerheight+(16<<8) )
psectlotag = 0; psectlotag = 0;
if( p->aim_mode == 0 && myonground && psectlotag != 2 && (sector[psect].floorstat&2) ) if( p->aim_mode == 0 && myonground && psectlotag != 2 && (sector[psect].floorstat&2) )
@ -157,7 +157,7 @@ void fakedomovethings(void)
k = getflorzofslope(psect,x,y); k = getflorzofslope(psect,x,y);
if (psect == tempsect) if (psect == tempsect)
myhorizoff += MulScale(j-k,160, 16); myhorizoff += MulScale(j-k,160, 16);
else if (klabs(getflorzofslope(tempsect,x,y)-k) <= (4<<8)) else if (abs(getflorzofslope(tempsect,x,y)-k) <= (4<<8))
myhorizoff += MulScale(j-k,160, 16); myhorizoff += MulScale(j-k,160, 16);
} }
} }
@ -180,7 +180,7 @@ void fakedomovethings(void)
psectlotag = 0; psectlotag = 0;
spritebridge = 1; spritebridge = 1;
} }
if(badguy(chz.actor) && chz.actor->s.xrepeat > 24 && klabs(p->GetActor()->s.z- chz.actor->s.z) < (84<<8) ) if(badguy(chz.actor) && chz.actor->s.xrepeat > 24 && abs(p->GetActor()->s.z- chz.actor->s.z) < (84<<8) )
{ {
j = getangle(chz.actor->s.x-myx, chz.actor->s.y-myy); j = getangle(chz.actor->s.x-myx, chz.actor->s.y-myy);
myxvel -= bcos(j, 4); myxvel -= bcos(j, 4);
@ -194,7 +194,7 @@ void fakedomovethings(void)
{ {
if(p->on_warping_sector == 0) if(p->on_warping_sector == 0)
{ {
if( klabs(myz-fz) > (gs.playerheight>>1)) if( abs(myz-fz) > (gs.playerheight>>1))
myz += 348; myz += 348;
} }
clipmove(&myx,&myy,&myz,&mycursectnum,0,0,164L,(4L<<8),(4L<<8),CLIPMASK0); clipmove(&myx,&myy,&myz,&mycursectnum,0,0,164L,(4L<<8),(4L<<8),CLIPMASK0);
@ -320,7 +320,7 @@ void fakedomovethings(void)
//Smooth on the ground //Smooth on the ground
k = ((fz-(i<<8))-myz)>>1; k = ((fz-(i<<8))-myz)>>1;
if( klabs(k) < 256 ) k = 0; if( abs(k) < 256 ) k = 0;
myz += k; // ((fz-(i<<8))-myz)>>1; myz += k; // ((fz-(i<<8))-myz)>>1;
myzvel -= 768; // 412; myzvel -= 768; // 412;
if(myzvel < 0) myzvel = 0; if(myzvel < 0) myzvel = 0;

View file

@ -977,7 +977,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q16hor
hy = hitinfo.pos.y - (*ny); hy = hitinfo.pos.y - (*ny);
// If something is in the way, make pp->camera_dist lower if necessary // If something is in the way, make pp->camera_dist lower if necessary
if (klabs(vx) + klabs(vy) > klabs(hx) + klabs(hy)) if (abs(vx) + abs(vy) > abs(hx) + abs(hy))
{ {
if (hitinfo.wall >= 0) // Push you a little bit off the wall if (hitinfo.wall >= 0) // Push you a little bit off the wall
{ {
@ -987,7 +987,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q16hor
wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y); wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y);
i = vx * bsin(daang) + vy * -bcos(daang); i = vx * bsin(daang) + vy * -bcos(daang);
if (klabs(vx) > klabs(vy)) if (abs(vx) > abs(vy))
hx -= MulScale(vx, i, 28); hx -= MulScale(vx, i, 28);
else else
hy -= MulScale(vy, i, 28); hy -= MulScale(vy, i, 28);
@ -996,7 +996,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q16hor
{ {
*vsect = hitinfo.sect; *vsect = hitinfo.sect;
if (klabs(vx) > klabs(vy)) if (abs(vx) > abs(vy))
hx -= (vx >> 5); hx -= (vx >> 5);
else else
hy -= (vy >> 5); hy -= (vy >> 5);
@ -1022,7 +1022,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q16hor
daang = NORM_ANGLE(sp->ang-512); daang = NORM_ANGLE(sp->ang-512);
i = vx * bsin(daang) + vy * -bcos(daang); i = vx * bsin(daang) + vy * -bcos(daang);
if (klabs(vx) > klabs(vy)) if (abs(vx) > abs(vy))
hx -= MulScale(vx, i, 28); hx -= MulScale(vx, i, 28);
else else
hy -= MulScale(vy, i, 28); hy -= MulScale(vy, i, 28);
@ -1030,7 +1030,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q16hor
} }
if (klabs(vx) > klabs(vy)) if (abs(vx) > abs(vy))
i = IntToFixed(hx) / vx; i = IntToFixed(hx) / vx;
else else
i = IntToFixed(hy) / vy; i = IntToFixed(hy) / vy;
@ -1099,7 +1099,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q1
hy = hitinfo.pos.y - (*ny); hy = hitinfo.pos.y - (*ny);
// If something is in the way, make pp->circle_camera_dist lower if necessary // If something is in the way, make pp->circle_camera_dist lower if necessary
if (klabs(vx) + klabs(vy) > klabs(hx) + klabs(hy)) if (abs(vx) + abs(vy) > abs(hx) + abs(hy))
{ {
if (hitinfo.wall >= 0) // Push you a little bit off the wall if (hitinfo.wall >= 0) // Push you a little bit off the wall
{ {
@ -1109,7 +1109,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q1
wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y); wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y);
i = vx * bsin(daang) + vy * -bcos(daang); i = vx * bsin(daang) + vy * -bcos(daang);
if (klabs(vx) > klabs(vy)) if (abs(vx) > abs(vy))
hx -= MulScale(vx, i, 28); hx -= MulScale(vx, i, 28);
else else
hy -= MulScale(vy, i, 28); hy -= MulScale(vy, i, 28);
@ -1118,7 +1118,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q1
{ {
*vsect = hitinfo.sect; *vsect = hitinfo.sect;
if (klabs(vx) > klabs(vy)) if (abs(vx) > abs(vy))
hx -= (vx >> 5); hx -= (vx >> 5);
else else
hy -= (vy >> 5); hy -= (vy >> 5);
@ -1140,7 +1140,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q1
} }
} }
if (klabs(vx) > klabs(vy)) if (abs(vx) > abs(vy))
i = IntToFixed(hx) / vx; i = IntToFixed(hx) / vx;
else else
i = IntToFixed(hy) / vy; i = IntToFixed(hy) / vy;

View file

@ -495,8 +495,8 @@ JS_ProcessEchoSpot()
tp = &sprite[i]; tp = &sprite[i];
j = klabs(tp->x - pp->posx); j = abs(tp->x - pp->posx);
j += klabs(tp->y - pp->posy); j += abs(tp->y - pp->posy);
if (j < dist) if (j < dist)
dist = j; dist = j;
@ -569,8 +569,8 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
if (bIsWallMirror) if (bIsWallMirror)
{ {
j = klabs(wall[mirror[cnt].mirrorwall].x - tx); j = abs(wall[mirror[cnt].mirrorwall].x - tx);
j += klabs(wall[mirror[cnt].mirrorwall].y - ty); j += abs(wall[mirror[cnt].mirrorwall].y - ty);
if (j < dist) if (j < dist)
dist = j; dist = j;
} }
@ -580,8 +580,8 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
tp = &sprite[mirror[cnt].camsprite]; tp = &sprite[mirror[cnt].camsprite];
j = klabs(tp->x - tx); j = abs(tp->x - tx);
j += klabs(tp->y - ty); j += abs(tp->y - ty);
if (j < dist) if (j < dist)
dist = j; dist = j;
} }
@ -607,8 +607,8 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
midy = (wall[w].y + wall[wall[w].point2].y) / 2; midy = (wall[w].y + wall[wall[w].point2].y) / 2;
// Finish finding offsets // Finish finding offsets
tdx = klabs(midx - tx); tdx = abs(midx - tx);
tdy = klabs(midy - ty); tdy = abs(midy - ty);
if (midx >= tx) if (midx >= tx)
dx = sp->x - tdx; dx = sp->x - tdx;
@ -620,7 +620,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
else else
dy = sp->y + tdy; dy = sp->y + tdy;
tdz = klabs(tz - sp->z); tdz = abs(tz - sp->z);
if (tz >= sp->z) if (tz >= sp->z)
dz = sp->z + tdz; dz = sp->z + tdz;
else else
@ -657,7 +657,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta)); SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta));
// TAG6 = Turn radius // TAG6 = Turn radius
if (klabs(getincangle(sp->ang, SP_TAG5(sp))) >= SP_TAG6(sp)) if (abs(getincangle(sp->ang, SP_TAG5(sp))) >= SP_TAG6(sp))
{ {
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta)); SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta));
RESET_BOOL3(sp); // Reverse turn RESET_BOOL3(sp); // Reverse turn
@ -670,7 +670,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta)); SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) - oscilation_delta));
// TAG6 = Turn radius // TAG6 = Turn radius
if (klabs(getincangle(sp->ang, SP_TAG5(sp))) >= SP_TAG6(sp)) if (abs(getincangle(sp->ang, SP_TAG5(sp))) >= SP_TAG6(sp))
{ {
SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta)); SP_TAG5(sp) = NORM_ANGLE((SP_TAG5(sp) + oscilation_delta));
SET_BOOL3(sp); // Reverse turn SET_BOOL3(sp); // Reverse turn
@ -768,8 +768,8 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
if (bIsWallMirror) if (bIsWallMirror)
{ {
j = klabs(wall[mirror[cnt].mirrorwall].x - tx); j = abs(wall[mirror[cnt].mirrorwall].x - tx);
j += klabs(wall[mirror[cnt].mirrorwall].y - ty); j += abs(wall[mirror[cnt].mirrorwall].y - ty);
if (j < dist) if (j < dist)
dist = j; dist = j;
} }
@ -779,8 +779,8 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
tp = &sprite[mirror[cnt].camsprite]; tp = &sprite[mirror[cnt].camsprite];
j = klabs(tp->x - tx); j = abs(tp->x - tx);
j += klabs(tp->y - ty); j += abs(tp->y - ty);
if (j < dist) if (j < dist)
dist = j; dist = j;
} }
@ -807,8 +807,8 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
midy = (wall[w].y + wall[wall[w].point2].y) / 2; midy = (wall[w].y + wall[wall[w].point2].y) / 2;
// Finish finding offsets // Finish finding offsets
tdx = klabs(midx - tx); tdx = abs(midx - tx);
tdy = klabs(midy - ty); tdy = abs(midy - ty);
if (midx >= tx) if (midx >= tx)
dx = sp->x - tdx; dx = sp->x - tdx;
@ -820,7 +820,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
else else
dy = sp->y + tdy; dy = sp->y + tdy;
tdz = klabs(tz - sp->z); tdz = abs(tz - sp->z);
if (tz >= sp->z) if (tz >= sp->z)
dz = sp->z + tdz; dz = sp->z + tdz;
else else

View file

@ -3070,7 +3070,7 @@ void initlava(void)
for (z = 0; z < LAVASIZ; z++) for (z = 0; z < LAVASIZ; z++)
{ {
lavainc[z] = klabs((((z ^ 17) >> 4) & 7) - 4) + 12; lavainc[z] = abs((((z ^ 17) >> 4) & 7) - 4) + 12;
} }
lavanumdrops = 0; lavanumdrops = 0;

View file

@ -8899,7 +8899,7 @@ bool SlopeBounce(short SpriteNum, bool *hit_wall)
l = (dax*dax) + (day*day) + (daz*daz); l = (dax*dax) + (day*day) + (daz*daz);
// make sure divscale doesn't overflow // make sure divscale doesn't overflow
if ((klabs(k)>>14) < l) if ((abs(k)>>14) < l)
{ {
k = DivScale(k, l, 17); k = DivScale(k, l, 17);
u->xchange -= MulScale(dax, k, 16); u->xchange -= MulScale(dax, k, 16);