- rerouted all accesses to gDudeSlope.

This commit is contained in:
Christoph Oelckers 2020-11-07 16:13:03 +01:00
parent 7e78bc1c14
commit 99c0b77cf2
7 changed files with 57 additions and 40 deletions

View file

@ -293,8 +293,7 @@ static void beastThinkChase(DBloodActor* actor)
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
int nXSprite = sprite[pXSprite->reference].extra; actor->dudeSlope() = divscale(pTarget->z-pSprite->z, nDist, 10);
gDudeSlope[nXSprite] = divscale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 0x1400 && nDist > 0xa00 && klabs(nDeltaAngle) < 85 && (pTarget->flags&2) if (nDist < 0x1400 && nDist > 0xa00 && klabs(nDeltaAngle) < 85 && (pTarget->flags&2)
&& IsPlayerSprite(pTarget) && Chance(0x8000)) && IsPlayerSprite(pTarget) && Chance(0x8000))
{ {

View file

@ -196,8 +196,7 @@ static void calebThinkChase(DBloodActor* actor)
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
int nXSprite = sprite[pXSprite->reference].extra; actor->dudeSlope() = divscale(pTarget->z-pSprite->z, nDist, 10);
gDudeSlope[nXSprite] = divscale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 0x599 && klabs(nDeltaAngle) < 28) if (nDist < 0x599 && klabs(nDeltaAngle) < 28)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;

View file

@ -314,8 +314,7 @@ static void cultThinkChase(DBloodActor* actor)
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
int nXSprite = sprite[pXSprite->reference].extra; actor->dudeSlope() = divscale(pTarget->z-pSprite->z, nDist, 10);
gDudeSlope[nXSprite] = 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 && klabs(nDeltaAngle) < 85 && !TargetNearExplosion(pTarget)

View file

@ -185,8 +185,7 @@ static void gillThinkChase(DBloodActor* actor)
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery) if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery)
{ {
aiSetTarget(pXSprite, pXSprite->target); aiSetTarget(pXSprite, pXSprite->target);
int nXSprite = sprite[pXSprite->reference].extra; actor->dudeSlope() = divscale(pTarget->z-pSprite->z, nDist, 10);
gDudeSlope[nXSprite] = divscale(pTarget->z-pSprite->z, nDist, 10);
if (nDist < 921 && klabs(nDeltaAngle) < 28) if (nDist < 921 && klabs(nDeltaAngle) < 28)
{ {
XSECTOR *pXSector; XSECTOR *pXSector;

View file

@ -140,26 +140,40 @@ static void forcePunch(DBloodActor* actor)
return true; return true;
}*/ }*/
bool genDudeAdjustSlope(spritetype* pSprite, XSPRITE* pXSprite, int dist, int weaponType, int by) { static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int by = 64)
if (spriRangeIsFine(pXSprite->target)) { {
int fStart = 0; int fEnd = 0; GENDUDEEXTRA* pExtra = genDudeExtra(pSprite); spritetype* pSprite = &actor->s();
XSPRITE* pXSprite = &actor->x();
if (spriRangeIsFine(pXSprite->target))
{
int fStart = 0;
int fEnd = 0;
GENDUDEEXTRA* pExtra = genDudeExtra(pSprite);
unsigned int clipMask = (weaponType == kGenDudeWeaponMissile) ? CLIPMASK0 : CLIPMASK1; unsigned int clipMask = (weaponType == kGenDudeWeaponMissile) ? CLIPMASK0 : CLIPMASK1;
for (int i = -8191; i < 8192; i += by) {
for (int i = -8191; i < 8192; i += by)
{
HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), i, clipMask, dist); HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), i, clipMask, dist);
if (!fStart && pXSprite->target == gHitInfo.hitsprite) fStart = i; if (!fStart && pXSprite->target == gHitInfo.hitsprite) fStart = i;
else if (fStart && pXSprite->target != gHitInfo.hitsprite) { fEnd = i; break; } else if (fStart && pXSprite->target != gHitInfo.hitsprite)
{
fEnd = i;
break;
}
} }
if (fStart != fEnd) { if (fStart != fEnd)
{
if (weaponType == kGenDudeWeaponHitscan) if (weaponType == kGenDudeWeaponHitscan)
gDudeSlope[pSprite->extra] = fStart - ((fStart - fEnd) >> 2); {
else if (weaponType == kGenDudeWeaponMissile) { actor->dudeSlope() = fStart - ((fStart - fEnd) >> 2);
}
else if (weaponType == kGenDudeWeaponMissile)
{
const MissileType* pMissile = &missileInfo[pExtra->curWeapon - kMissileBase]; const MissileType* pMissile = &missileInfo[pExtra->curWeapon - kMissileBase];
gDudeSlope[pSprite->extra] = (fStart - ((fStart - fEnd) >> 2)) - (pMissile->clipDist << 1); actor->dudeSlope() = (fStart - ((fStart - fEnd) >> 2)) - (pMissile->clipDist << 1);
} }
//viewSetSystemMessage("!!!! FOUND, SLOPE %d, RANGE %d,%d", gDudeSlope[pSprite->extra], fStart, fEnd);
return true; return true;
} }
} }
@ -415,8 +429,8 @@ static void unicultThinkGoto(DBloodActor* actor)
static void unicultThinkChase(DBloodActor* actor) static void unicultThinkChase(DBloodActor* actor)
{ {
auto pXSprite = &actor->x(); auto const pXSprite = &actor->x();
auto pSprite = &actor->s(); auto const pSprite = &actor->s();
if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) return; if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) return;
else if (pXSprite->target < 0 || pXSprite->target >= kMaxSprites) { else if (pXSprite->target < 0 || pXSprite->target >= kMaxSprites) {
if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeGotoW); if(spriteIsUnderwater(pSprite,false)) aiGenDudeNewState(pSprite, &genDudeGotoW);
@ -499,7 +513,7 @@ static void unicultThinkChase(DBloodActor* actor)
if ((gFrameClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(pSprite, false)) if ((gFrameClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(pSprite, false))
playGenDudeSound(pSprite, kGenDudeSndChasing); playGenDudeSound(pSprite, kGenDudeSndChasing);
gDudeSlope[pSprite->extra] = divscale(pTarget->z - pSprite->z, dist, 10); actor->dudeSlope() = divscale(pTarget->z - pSprite->z, dist, 10);
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];
@ -668,9 +682,9 @@ static void unicultThinkChase(DBloodActor* actor)
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)
hit = HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), gDudeSlope[pSprite->extra], CLIPMASK1, dist); hit = HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope(), CLIPMASK1, dist);
else if (weaponType == kGenDudeWeaponMissile) else if (weaponType == kGenDudeWeaponMissile)
hit = HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), gDudeSlope[pSprite->extra], CLIPMASK0, dist); hit = HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope(), CLIPMASK0, dist);
if (hit >= 0) { if (hit >= 0) {
targetDist = dist - (pTarget->clipdist << 2); targetDist = dist - (pTarget->clipdist << 2);
@ -705,7 +719,7 @@ static void unicultThinkChase(DBloodActor* actor)
fallthrough__; fallthrough__;
case 2: case 2:
//if (hit == 2) viewSetSystemMessage("FLOOR HIT %d", gHitInfo.hitsect); //if (hit == 2) viewSetSystemMessage("FLOOR HIT %d", gHitInfo.hitsect);
if (weaponType != kGenDudeWeaponMissile && genDudeAdjustSlope(pSprite, pXSprite, dist, weaponType) if (weaponType != kGenDudeWeaponMissile && genDudeAdjustSlope(actor, dist, weaponType)
&& dist < (int)(6000 + Random(2000)) && pExtra->baseDispersion < kGenDudeMaxDispersion >> 1) break; && dist < (int)(6000 + Random(2000)) && pExtra->baseDispersion < kGenDudeMaxDispersion >> 1) break;
else if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW); else if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
@ -741,20 +755,26 @@ static void unicultThinkChase(DBloodActor* actor)
} }
break; break;
} }
if (pSprite->x < pHSprite->x) { if (pSprite->x < pHSprite->x)
{
if (Chance(0x9000) && pTarget->x > pHSprite->x) pXSprite->dodgeDir = -1; if (Chance(0x9000) && pTarget->x > pHSprite->x) pXSprite->dodgeDir = -1;
else pXSprite->dodgeDir = 1; else pXSprite->dodgeDir = 1;
} else { }
else
{
if (Chance(0x9000) && pTarget->x > pHSprite->x) pXSprite->dodgeDir = 1; if (Chance(0x9000) && pTarget->x > pHSprite->x) pXSprite->dodgeDir = 1;
else pXSprite->dodgeDir = -1; else pXSprite->dodgeDir = -1;
} }
} }
break; break;
default: default:
if (pSprite->x < pHSprite->x) { if (pSprite->x < pHSprite->x)
{
if (Chance(0x9000) && pTarget->x > pHSprite->x) pXSprite->dodgeDir = -1; if (Chance(0x9000) && pTarget->x > pHSprite->x) pXSprite->dodgeDir = -1;
else pXSprite->dodgeDir = 1; else pXSprite->dodgeDir = 1;
} else { }
else
{
if (Chance(0x9000) && pTarget->x > pHSprite->x) pXSprite->dodgeDir = 1; if (Chance(0x9000) && pTarget->x > pHSprite->x) pXSprite->dodgeDir = 1;
else pXSprite->dodgeDir = -1; else pXSprite->dodgeDir = -1;
} }
@ -763,17 +783,19 @@ static void unicultThinkChase(DBloodActor* actor)
return; return;
} }
break; break;
} else if (weaponType == kGenDudeWeaponHitscan && hscn) { }
if (genDudeAdjustSlope(pSprite, pXSprite, dist, weaponType)) break; else if (weaponType == kGenDudeWeaponHitscan && hscn)
VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), gDudeSlope[pSprite->extra], dist, 1); {
if (genDudeAdjustSlope(actor, dist, weaponType)) break;
VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope(), dist, 1);
if (pXSprite->target == gHitInfo.hitsprite) break; if (pXSprite->target == gHitInfo.hitsprite) break;
bool immune = nnExtIsImmune(pHSprite, gVectorData[curWeapon].dmgType); bool immune = nnExtIsImmune(pHSprite, gVectorData[curWeapon].dmgType);
if (!(pXHSprite != NULL && (!immune || (immune && pHSprite->statnum == kStatThing && pXHSprite->Vector)) && !pXHSprite->locked)) { if (!(pXHSprite != NULL && (!immune || (immune && pHSprite->statnum == kStatThing && pXHSprite->Vector)) && !pXHSprite->locked))
{
if ((approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y) <= 1500 && !blck) if ((approxDist(gHitInfo.hitx - pSprite->x, gHitInfo.hity - pSprite->y) <= 1500 && !blck)
|| (dist <= (int)(pExtra->fireDist / ClipLow(Random(4), 1)))) { || (dist <= (int)(pExtra->fireDist / ClipLow(Random(4), 1))))
{
//viewSetSystemMessage("GO CHASE"); //viewSetSystemMessage("GO CHASE");
if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW); if (spriteIsUnderwater(pSprite)) aiGenDudeNewState(pSprite, &genDudeChaseW);
else aiGenDudeNewState(pSprite, &genDudeChaseL); else aiGenDudeNewState(pSprite, &genDudeChaseL);
@ -817,7 +839,7 @@ static void unicultThinkChase(DBloodActor* actor)
case 4: case 4:
if (hit == 4 && weaponType == kGenDudeWeaponHitscan && hscn) { if (hit == 4 && weaponType == kGenDudeWeaponHitscan && hscn) {
bool masked = (pHWall->cstat & CSTAT_WALL_MASKED); bool masked = (pHWall->cstat & CSTAT_WALL_MASKED);
if (masked) VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), gDudeSlope[pSprite->extra], dist, 1); if (masked) VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), actor->dudeSlope(), dist, 1);
//viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall); //viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall);
if ((pXSprite->target != gHitInfo.hitsprite) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) { if ((pXSprite->target != gHitInfo.hitsprite) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) {

View file

@ -233,7 +233,6 @@ int getDispersionModifier(spritetype* pSprite, int minDisp, int maxDisp);
void scaleDamage(XSPRITE* pXSprite); void scaleDamage(XSPRITE* pXSprite);
bool genDudePrepare(spritetype* pSprite, int propId); bool genDudePrepare(spritetype* pSprite, int propId);
void genDudeUpdate(spritetype* pSprite); void genDudeUpdate(spritetype* pSprite);
bool genDudeAdjustSlope(spritetype* pSprite, XSPRITE* pXSprite, int dist, int weaponType, int by = 64);
void genDudePostDeath(spritetype* pSprite, DAMAGE_TYPE damageType, int damage); void genDudePostDeath(spritetype* pSprite, DAMAGE_TYPE damageType, int damage);
void aiGenDudeInitSprite(spritetype* pSprite, XSPRITE* pXSprite); void aiGenDudeInitSprite(spritetype* pSprite, XSPRITE* pXSprite);
#endif #endif

View file

@ -3040,7 +3040,7 @@ bool condCheckDude(XSPRITE* pXCond, int cmpOp, bool PUSH) {
bool condCheckSprite(XSPRITE* pXCond, int cmpOp, bool PUSH) { bool condCheckSprite(XSPRITE* pXCond, int cmpOp, bool PUSH) {
UNREFERENCED_PARAMETER(PUSH); UNREFERENCED_PARAMETER(PUSH);
auto actor = &bloodActors[pXCond->reference];
int var = -1; PLAYER* pPlayer = NULL; bool retn = false; int var = -1; PLAYER* pPlayer = NULL; bool retn = false;
int cond = pXCond->data1 - kCondSpriteBase; int arg1 = pXCond->data2; int cond = pXCond->data1 - kCondSpriteBase; int arg1 = pXCond->data2;
int arg2 = pXCond->data3; int arg3 = pXCond->data4; int arg2 = pXCond->data3; int arg3 = pXCond->data4;
@ -3094,7 +3094,7 @@ bool condCheckSprite(XSPRITE* pXCond, int cmpOp, bool PUSH) {
if ((pPlayer = getPlayerById(pSpr->type)) != NULL) if ((pPlayer = getPlayerById(pSpr->type)) != NULL)
var = HitScan(pSpr, pPlayer->zWeapon - pSpr->z, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, arg1, arg3 << 1); var = HitScan(pSpr, pPlayer->zWeapon - pSpr->z, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, arg1, arg3 << 1);
else if (IsDudeSprite(pSpr)) else if (IsDudeSprite(pSpr))
var = HitScan(pSpr, pSpr->z, CosScale16(pSpr->ang), SinScale16(pSpr->ang), gDudeSlope[pSpr->extra], arg1, arg3 << 1); var = HitScan(pSpr, pSpr->z, CosScale16(pSpr->ang), SinScale16(pSpr->ang), actor->dudeSlope(), arg1, arg3 << 1);
else else
var = HitScan(pSpr, pSpr->z, CosScale16(pSpr->ang), SinScale16(pSpr->ang), 0, arg1, arg3 << 1); var = HitScan(pSpr, pSpr->z, CosScale16(pSpr->ang), SinScale16(pSpr->ang), 0, arg1, arg3 << 1);