mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 08:50:55 +00:00
- reformatting commit
This commit is contained in:
parent
6f8a5ee2d2
commit
bbe49eee7c
1 changed files with 117 additions and 37 deletions
|
@ -113,6 +113,12 @@ short gCustomDudeDebrisPics[6] = {
|
||||||
|
|
||||||
GENDUDEEXTRA gGenDudeExtra[kMaxSprites]; // savegame handling in ai.cpp
|
GENDUDEEXTRA gGenDudeExtra[kMaxSprites]; // savegame handling in ai.cpp
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
static void forcePunch(DBloodActor* actor)
|
static void forcePunch(DBloodActor* actor)
|
||||||
{
|
{
|
||||||
auto pXSprite = &actor->x();
|
auto pXSprite = &actor->x();
|
||||||
|
@ -126,7 +132,13 @@ static void forcePunch(DBloodActor* actor)
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int by = 64)
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int by = 64)
|
||||||
{
|
{
|
||||||
spritetype* pSprite = &actor->s();
|
spritetype* pSprite = &actor->s();
|
||||||
XSPRITE* pXSprite = &actor->x();
|
XSPRITE* pXSprite = &actor->x();
|
||||||
|
@ -179,10 +191,16 @@ void genDudeUpdate(spritetype* pSprite) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void punchCallback(int, DBloodActor* actor)
|
void punchCallback(int, DBloodActor* actor)
|
||||||
{
|
{
|
||||||
XSPRITE* pXSprite = &actor->x();
|
auto const pXSprite = &actor->x();
|
||||||
spritetype* pSprite = &actor->s();
|
auto const pSprite = &actor->s();
|
||||||
auto const target = actor->GetTarget();
|
auto const target = actor->GetTarget();
|
||||||
if (target != nullptr)
|
if (target != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -190,7 +208,7 @@ void punchCallback(int, DBloodActor* actor)
|
||||||
int nZOffset2 = 0;
|
int nZOffset2 = 0;
|
||||||
|
|
||||||
|
|
||||||
spritetype* pTarget = &target->s();
|
auto const pTarget = &target->s();
|
||||||
if(target->IsDudeActor())
|
if(target->IsDudeActor())
|
||||||
nZOffset2 = getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat << 2;
|
nZOffset2 = getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat << 2;
|
||||||
|
|
||||||
|
@ -205,10 +223,16 @@ void punchCallback(int, DBloodActor* actor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void genDudeAttack1(int, DBloodActor* actor)
|
void genDudeAttack1(int, DBloodActor* actor)
|
||||||
{
|
{
|
||||||
XSPRITE* pXSprite = &actor->x();
|
auto const pXSprite = &actor->x();
|
||||||
spritetype* pSprite = &actor->s();
|
auto const pSprite = &actor->s();
|
||||||
|
|
||||||
if (pXSprite->target_i < 0) return;
|
if (pXSprite->target_i < 0) return;
|
||||||
|
|
||||||
|
@ -220,23 +244,25 @@ void genDudeAttack1(int, DBloodActor* actor)
|
||||||
if (inDuck(pXSprite->aiState))
|
if (inDuck(pXSprite->aiState))
|
||||||
dispersion = ClipLow(dispersion >> 1, kGenDudeMinDispesion);
|
dispersion = ClipLow(dispersion >> 1, kGenDudeMinDispesion);
|
||||||
|
|
||||||
if (pExtra->weaponType == kGenDudeWeaponHitscan) {
|
if (pExtra->weaponType == kGenDudeWeaponHitscan)
|
||||||
|
{
|
||||||
dx = CosScale16(pSprite->ang); dy = SinScale16(pSprite->ang); dz = actor->dudeSlope;
|
dx = CosScale16(pSprite->ang); dy = SinScale16(pSprite->ang); dz = actor->dudeSlope;
|
||||||
// dispersal modifiers here in case if non-melee enemy
|
// dispersal modifiers here in case if non-melee enemy
|
||||||
if (!dudeIsMelee(pXSprite)) {
|
if (!dudeIsMelee(pXSprite))
|
||||||
|
{
|
||||||
dx += Random3(dispersion); dy += Random3(dispersion); dz += Random3(dispersion);
|
dx += Random3(dispersion); dy += Random3(dispersion); dz += Random3(dispersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
actFireVector(actor, 0, 0, dx, dy, dz,(VECTOR_TYPE)pExtra->curWeapon);
|
actFireVector(actor, 0, 0, dx, dy, dz,(VECTOR_TYPE)pExtra->curWeapon);
|
||||||
if (!playGenDudeSound(pSprite, kGenDudeSndAttackNormal))
|
if (!playGenDudeSound(pSprite, kGenDudeSndAttackNormal))
|
||||||
sfxPlayVectorSound(pSprite, pExtra->curWeapon);
|
sfxPlayVectorSound(pSprite, pExtra->curWeapon);
|
||||||
|
}
|
||||||
} else if (pExtra->weaponType == kGenDudeWeaponSummon) {
|
else if (pExtra->weaponType == kGenDudeWeaponSummon)
|
||||||
|
{
|
||||||
DBloodActor* spawned = nullptr;
|
DBloodActor* spawned = nullptr;
|
||||||
int dist = pSprite->clipdist << 4;
|
int dist = pSprite->clipdist << 4;
|
||||||
if (pExtra->slaveCount <= gGameOptions.nDifficulty) {
|
if (pExtra->slaveCount <= gGameOptions.nDifficulty)
|
||||||
|
{
|
||||||
if ((spawned = actSpawnDude(actor, pExtra->curWeapon, dist + Random(dist), 0)) != NULL)
|
if ((spawned = actSpawnDude(actor, pExtra->curWeapon, dist + Random(dist), 0)) != NULL)
|
||||||
{
|
{
|
||||||
spritetype* pSpawned = &spawned->s();
|
spritetype* pSpawned = &spawned->s();
|
||||||
|
@ -254,9 +280,9 @@ void genDudeAttack1(int, DBloodActor* actor)
|
||||||
sfxPlay3DSoundCP(pSprite, 379, 1, 0, 0x10000 - Random3(0x3000));
|
sfxPlay3DSoundCP(pSprite, 379, 1, 0, 0x10000 - Random3(0x3000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (pExtra->weaponType == kGenDudeWeaponMissile) {
|
else if (pExtra->weaponType == kGenDudeWeaponMissile)
|
||||||
|
{
|
||||||
dx = CosScale16(pSprite->ang); dy = SinScale16(pSprite->ang); dz = actor->dudeSlope;
|
dx = CosScale16(pSprite->ang); dy = SinScale16(pSprite->ang); dz = actor->dudeSlope;
|
||||||
|
|
||||||
// dispersal modifiers here
|
// dispersal modifiers here
|
||||||
|
@ -268,6 +294,12 @@ void genDudeAttack1(int, DBloodActor* actor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void ThrowCallback1(int, DBloodActor* actor)
|
void ThrowCallback1(int, DBloodActor* actor)
|
||||||
{
|
{
|
||||||
ThrowThing(actor, true);
|
ThrowThing(actor, true);
|
||||||
|
@ -381,6 +413,12 @@ static void ThrowThing(DBloodActor* actor, bool impact)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
static void unicultThinkSearch(DBloodActor* actor)
|
static void unicultThinkSearch(DBloodActor* actor)
|
||||||
{
|
{
|
||||||
auto pXSprite = &actor->x();
|
auto pXSprite = &actor->x();
|
||||||
|
@ -391,11 +429,18 @@ static void unicultThinkSearch(DBloodActor* actor)
|
||||||
aiLookForTarget(actor);
|
aiLookForTarget(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
static void unicultThinkGoto(DBloodActor* actor)
|
static void unicultThinkGoto(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)) {
|
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax))
|
||||||
|
{
|
||||||
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
|
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -414,6 +459,12 @@ static void unicultThinkGoto(DBloodActor* actor)
|
||||||
aiThinkTarget(actor);
|
aiThinkTarget(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
static void unicultThinkChase(DBloodActor* actor)
|
static void unicultThinkChase(DBloodActor* actor)
|
||||||
{
|
{
|
||||||
auto const pXSprite = &actor->x();
|
auto const pXSprite = &actor->x();
|
||||||
|
@ -470,7 +521,8 @@ static void unicultThinkChase(DBloodActor* actor)
|
||||||
aiGenDudeChooseDirection(pSprite, pXSprite, getangle(dx, dy), xvelocity, yvelocity);
|
aiGenDudeChooseDirection(pSprite, pXSprite, getangle(dx, dy), xvelocity, yvelocity);
|
||||||
|
|
||||||
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index];
|
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index];
|
||||||
if (!pExtra->canAttack) {
|
if (!pExtra->canAttack)
|
||||||
|
{
|
||||||
if (pExtra->canWalk) aiSetTarget(actor, actor); // targeting self???
|
if (pExtra->canWalk) aiSetTarget(actor, actor); // targeting self???
|
||||||
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeGotoW);
|
if (spriteIsUnderwater(pSprite, false)) aiGenDudeNewState(pSprite, &genDudeGotoW);
|
||||||
else aiGenDudeNewState(pSprite, &genDudeGotoL);
|
else aiGenDudeNewState(pSprite, &genDudeGotoL);
|
||||||
|
@ -506,11 +558,16 @@ static void unicultThinkChase(DBloodActor* actor)
|
||||||
|
|
||||||
actor->dudeSlope = 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;
|
||||||
spritetype* pLeech = leechIsDropped(pSprite); const VECTORDATA* meleeVector = &gVectorData[22];
|
short weaponType = gGenDudeExtra[pSprite->index].weaponType;
|
||||||
if (weaponType == kGenDudeWeaponThrow) {
|
spritetype* pLeech = leechIsDropped(pSprite);
|
||||||
if (abs(losAngle) < kAng15) {
|
const VECTORDATA* meleeVector = &gVectorData[22];
|
||||||
if (!gThingInfoExtra[curWeapon - kThingBase].allowThrow) {
|
if (weaponType == kGenDudeWeaponThrow)
|
||||||
|
{
|
||||||
|
if (abs(losAngle) < kAng15)
|
||||||
|
{
|
||||||
|
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);
|
||||||
return;
|
return;
|
||||||
|
@ -526,10 +583,15 @@ static void unicultThinkChase(DBloodActor* actor)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (dist > 4072 && dist <= 11072 && !spriteIsUnderwater(pSprite, false) && pSprite->owner != (kMaxSprites - 1)) {
|
}
|
||||||
switch (curWeapon) {
|
else if (dist > 4072 && dist <= 11072 && !spriteIsUnderwater(pSprite, false) && pSprite->owner != (kMaxSprites - 1))
|
||||||
case kModernThingEnemyLifeLeech: {
|
{
|
||||||
if (pLeech == NULL) {
|
switch (curWeapon)
|
||||||
|
{
|
||||||
|
case kModernThingEnemyLifeLeech:
|
||||||
|
{
|
||||||
|
if (pLeech == NULL)
|
||||||
|
{
|
||||||
aiGenDudeNewState(pSprite, &genDudeThrow2);
|
aiGenDudeNewState(pSprite, &genDudeThrow2);
|
||||||
genDudeThrow2.nextState = &genDudeDodgeShortL;
|
genDudeThrow2.nextState = &genDudeDodgeShortL;
|
||||||
return;
|
return;
|
||||||
|
@ -604,8 +666,11 @@ static void unicultThinkChase(DBloodActor* actor)
|
||||||
{
|
{
|
||||||
aiSetTarget(actor, pSprite->x, pSprite->y, pSprite->z);
|
aiSetTarget(actor, pSprite->x, pSprite->y, pSprite->z);
|
||||||
return;
|
return;
|
||||||
} else if (gGenDudeExtra[pSprite->index].slaveCount > gGameOptions.nDifficulty || dist < meleeVector->maxDist) {
|
}
|
||||||
if (dist <= meleeVector->maxDist) {
|
else if (gGenDudeExtra[pSprite->index].slaveCount > gGameOptions.nDifficulty || dist < meleeVector->maxDist)
|
||||||
|
{
|
||||||
|
if (dist <= meleeVector->maxDist)
|
||||||
|
{
|
||||||
aiGenDudeNewState(pSprite, &genDudePunch);
|
aiGenDudeNewState(pSprite, &genDudePunch);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1009,8 +1074,8 @@ void aiGenDudeMoveForward(DBloodActor* actor)
|
||||||
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index];
|
GENDUDEEXTRA* pExtra = &gGenDudeExtra[pSprite->index];
|
||||||
int maxTurn = pDudeInfo->angSpeed * 4 >> 4;
|
int maxTurn = pDudeInfo->angSpeed * 4 >> 4;
|
||||||
|
|
||||||
|
if (pExtra->canFly)
|
||||||
if (pExtra->canFly) {
|
{
|
||||||
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;
|
||||||
|
@ -1036,7 +1101,9 @@ void aiGenDudeMoveForward(DBloodActor* actor)
|
||||||
t1 += nAccel >> 1;
|
t1 += nAccel >> 1;
|
||||||
xvel[pSprite->index] = DMulScale(t1, nCos, t2, nSin, 30);
|
xvel[pSprite->index] = DMulScale(t1, nCos, t2, nSin, 30);
|
||||||
yvel[pSprite->index] = DMulScale(t1, nSin, -t2, nCos, 30);
|
yvel[pSprite->index] = DMulScale(t1, nSin, -t2, nCos, 30);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
int dang = ((kAng180 + pXSprite->goalAng - pSprite->ang) & 2047) - kAng180;
|
int dang = ((kAng180 + pXSprite->goalAng - pSprite->ang) & 2047) - kAng180;
|
||||||
pSprite->ang = ((pSprite->ang + ClipRange(dang, -maxTurn, maxTurn)) & 2047);
|
pSprite->ang = ((pSprite->ang + ClipRange(dang, -maxTurn, maxTurn)) & 2047);
|
||||||
|
|
||||||
|
@ -1053,6 +1120,12 @@ void aiGenDudeMoveForward(DBloodActor* actor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, int xvel, int yvel) {
|
void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, int xvel, int yvel) {
|
||||||
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
|
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
|
||||||
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
|
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
|
||||||
|
@ -1130,7 +1203,8 @@ void aiGenDudeNewState(spritetype* pSprite, AISTATE* pAIState) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gGenDudeExtra[pSprite->index].canRecoil) {
|
if (!gGenDudeExtra[pSprite->index].canRecoil)
|
||||||
|
{
|
||||||
if (pAIState == &genDudeRecoilL || pAIState == &genDudeRecoilD) pAIState = &genDudeIdleL;
|
if (pAIState == &genDudeRecoilL || pAIState == &genDudeRecoilD) pAIState = &genDudeIdleL;
|
||||||
else if (pAIState == &genDudeRecoilW) pAIState = &genDudeIdleW;
|
else if (pAIState == &genDudeRecoilW) pAIState = &genDudeIdleW;
|
||||||
}
|
}
|
||||||
|
@ -1138,7 +1212,8 @@ void aiGenDudeNewState(spritetype* pSprite, AISTATE* pAIState) {
|
||||||
pXSprite->stateTimer = pAIState->stateTicks; pXSprite->aiState = pAIState;
|
pXSprite->stateTimer = pAIState->stateTicks; pXSprite->aiState = pAIState;
|
||||||
|
|
||||||
int stateSeq = pXSprite->data2 + pAIState->seqId;
|
int stateSeq = pXSprite->data2 + pAIState->seqId;
|
||||||
if (pAIState->seqId >= 0 && getSequence(stateSeq)) {
|
if (pAIState->seqId >= 0 && getSequence(stateSeq))
|
||||||
|
{
|
||||||
seqSpawn(stateSeq, 3, pSprite->extra, pAIState->funcId);
|
seqSpawn(stateSeq, 3, pSprite->extra, pAIState->funcId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1146,7 +1221,12 @@ void aiGenDudeNewState(spritetype* pSprite, AISTATE* pAIState) {
|
||||||
pAIState->enterFunc(&bloodActors[pXSprite->reference]);
|
pAIState->enterFunc(&bloodActors[pXSprite->reference]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool playGenDudeSound(spritetype* pSprite, int mode) {
|
bool playGenDudeSound(spritetype* pSprite, int mode) {
|
||||||
|
|
||||||
if (mode < kGenDudeSndTargetSpot || mode >= kGenDudeSndMax) return false;
|
if (mode < kGenDudeSndTargetSpot || mode >= kGenDudeSndMax) return false;
|
||||||
|
|
Loading…
Reference in a new issue