- 2 more function changed to use actor parameters.

This commit is contained in:
Christoph Oelckers 2021-08-31 21:59:32 +02:00
parent 805ae48607
commit 49f75e6f51
2 changed files with 25 additions and 17 deletions

View file

@ -171,11 +171,9 @@ static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int
const MissileType* pMissile = &missileInfo[pExtra->curWeapon - kMissileBase]; const MissileType* pMissile = &missileInfo[pExtra->curWeapon - kMissileBase];
actor->dudeSlope = (fStart - ((fStart - fEnd) >> 2)) - (pMissile->clipDist << 1); actor->dudeSlope = (fStart - ((fStart - fEnd) >> 2)) - (pMissile->clipDist << 1);
} }
return true; return true;
} }
} }
return false; return false;
} }
@ -523,7 +521,7 @@ static void unicultThinkChase(DBloodActor* actor)
xvelocity = yvelocity = ClipLow(pSprite->clipdist >> 1, 1); xvelocity = yvelocity = ClipLow(pSprite->clipdist >> 1, 1);
//aiChooseDirection(actor,getangle(dx, dy)); //aiChooseDirection(actor,getangle(dx, dy));
aiGenDudeChooseDirection(pSprite, pXSprite, getangle(dx, dy), xvelocity, yvelocity); aiGenDudeChooseDirection(actor, getangle(dx, dy), xvelocity, yvelocity);
GENDUDEEXTRA* pExtra = &actor->genDudeExtra(); GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
if (!pExtra->canAttack) if (!pExtra->canAttack)
@ -1098,12 +1096,20 @@ int checkAttackState(DBloodActor* actor)
return 0; return 0;
} }
///// For gen dude //---------------------------------------------------------------------------
int getGenDudeMoveSpeed(spritetype* pSprite,int which, bool mul, bool shift) { //
//
//
//---------------------------------------------------------------------------
static int getGenDudeMoveSpeed(DBloodActor *actor,int which, bool mul, bool shift)
{
auto const pSprite = &actor->s();
auto const pXSprite = &actor->x();
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
XSPRITE* pXSprite = &xsprite[pSprite->extra];
int speed = -1; int step = 2500; int maxSpeed = 146603; int speed = -1; int step = 2500; int maxSpeed = 146603;
switch(which){ switch(which)
{
case 0: case 0:
speed = pDudeInfo->frontSpeed; speed = pDudeInfo->frontSpeed;
break; break;
@ -1120,9 +1126,8 @@ int getGenDudeMoveSpeed(spritetype* pSprite,int which, bool mul, bool shift) {
return -1; return -1;
} }
if (pXSprite->busyTime > 0) speed /=3; if (pXSprite->busyTime > 0) speed /=3;
if (speed > 0 && mul) { if (speed > 0 && mul)
{
if (pXSprite->busyTime > 0) if (pXSprite->busyTime > 0)
speed += (step * pXSprite->busyTime); speed += (step * pXSprite->busyTime);
} }
@ -1199,12 +1204,15 @@ void aiGenDudeMoveForward(DBloodActor* actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, int xvel, int yvel) { void aiGenDudeChooseDirection(DBloodActor* actor, int a3, int xvel, int yvel)
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { {
auto const pXSprite = &actor->x();
auto const pSprite = &actor->s();
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;
} }
auto actor = &bloodActors[pSprite->index];
// TO-DO: Take in account if sprite is flip-x, so enemy select correct angle // TO-DO: Take in account if sprite is flip-x, so enemy select correct angle
@ -1229,7 +1237,8 @@ void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, in
pXSprite->dodgeDir = (Chance(0x8000)) ? 1 : -1; pXSprite->dodgeDir = (Chance(0x8000)) ? 1 : -1;
if (!CanMove(actor, actor->GetTarget(), pSprite->ang + pXSprite->dodgeDir * 512, 512)) { if (!CanMove(actor, actor->GetTarget(), pSprite->ang + pXSprite->dodgeDir * 512, 512))
{
pXSprite->dodgeDir = -pXSprite->dodgeDir; pXSprite->dodgeDir = -pXSprite->dodgeDir;
if (!CanMove(actor, actor->GetTarget(), pSprite->ang + pXSprite->dodgeDir * 512, 512)) if (!CanMove(actor, actor->GetTarget(), pSprite->ang + pXSprite->dodgeDir * 512, 512))
pXSprite->dodgeDir = 0; pXSprite->dodgeDir = 0;
@ -2173,7 +2182,7 @@ bool genDudePrepare(spritetype* pSprite, int propId) {
switch (propId) { switch (propId) {
case kGenDudePropertyAll: case kGenDudePropertyAll:
case kGenDudePropertyInitVals: case kGenDudePropertyInitVals:
pExtra->moveSpeed = getGenDudeMoveSpeed(pSprite, 0, true, false); pExtra->moveSpeed = getGenDudeMoveSpeed(actor, 0, true, false);
pExtra->initVals[0] = pSprite->xrepeat; pExtra->initVals[0] = pSprite->xrepeat;
pExtra->initVals[1] = pSprite->yrepeat; pExtra->initVals[1] = pSprite->yrepeat;
pExtra->initVals[2] = pSprite->clipdist; pExtra->initVals[2] = pSprite->clipdist;

View file

@ -203,9 +203,8 @@ spritetype* leechIsDropped(spritetype* pSprite);
bool spriteIsUnderwater(spritetype* pSprite, bool oldWay = false); bool spriteIsUnderwater(spritetype* pSprite, bool oldWay = false);
bool playGenDudeSound(spritetype* pSprite, int mode); bool playGenDudeSound(spritetype* pSprite, int mode);
void aiGenDudeMoveForward(DBloodActor* actor); void aiGenDudeMoveForward(DBloodActor* actor);
void aiGenDudeChooseDirection(spritetype* pSprite, XSPRITE* pXSprite, int a3, int aXvel = -1, int aYvel = -1); void aiGenDudeChooseDirection(DBloodActor* actor, int a3, int aXvel = -1, int aYvel = -1);
void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState); void aiGenDudeNewState(DBloodActor* actor, AISTATE* pAIState);
int getGenDudeMoveSpeed(spritetype* pSprite, int which, bool mul, bool shift);
int checkAttackState(DBloodActor* actor); int checkAttackState(DBloodActor* actor);
bool doExplosion(spritetype* pSprite, int nType); bool doExplosion(spritetype* pSprite, int nType);
spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist); spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist);