- dudeIsMelee

This commit is contained in:
Christoph Oelckers 2021-05-06 08:45:50 +02:00
parent eb478ba580
commit c715ded287
4 changed files with 25 additions and 20 deletions

View file

@ -1095,7 +1095,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
}
else if (canWalk(pSprite) && !inDodge(pXSprite->aiState) && !inRecoil(pXSprite->aiState))
{
if (!dudeIsMelee(pXSprite))
if (!dudeIsMelee(actor))
{
if (inIdle(pXSprite->aiState) || Chance(getDodgeChance(pSprite)))
{
@ -1277,7 +1277,7 @@ void RecoilDude(DBloodActor* actor)
int rChance = getRecoilChance(pSprite);
if (pExtra->canElectrocute && pDudeExtra->teslaHit && !spriteIsUnderwater(actor, false))
{
if (Chance(rChance << 3) || (dudeIsMelee(pXSprite) && Chance(rChance << 4))) aiGenDudeNewState(actor, &genDudeRecoilTesla);
if (Chance(rChance << 3) || (dudeIsMelee(actor) && Chance(rChance << 4))) aiGenDudeNewState(actor, &genDudeRecoilTesla);
else if (pExtra->canRecoil && Chance(rChance)) aiGenDudeNewState(actor, &genDudeRecoilL);
else if (canWalk(pSprite))
{
@ -1305,7 +1305,7 @@ void RecoilDude(DBloodActor* actor)
else pXSprite->aiState->nextState = &genDudeChaseNoWalkW;
}
else if (!dudeIsMelee(pXSprite) || Chance(rChance >> 2))
else if (!dudeIsMelee(actor) || Chance(rChance >> 2))
{
if (rState == 1) pXSprite->aiState->nextState = (Chance(rChance) ? &genDudeDodgeL : &genDudeDodgeShortL);
else if (rState == 2) pXSprite->aiState->nextState = (Chance(rChance) ? &genDudeDodgeD : &genDudeDodgeShortD);

View file

@ -249,7 +249,7 @@ void genDudeAttack1(int, DBloodActor* actor)
{
dx = CosScale16(pSprite->ang); dy = SinScale16(pSprite->ang); dz = actor->dudeSlope;
// dispersal modifiers here in case if non-melee enemy
if (!dudeIsMelee(pXSprite))
if (!dudeIsMelee(actor))
{
dx += Random3(dispersion); dy += Random3(dispersion); dz += Random3(dispersion);
}
@ -770,7 +770,7 @@ static void unicultThinkChase(DBloodActor* actor)
}
int state = checkAttackState(actor);
int kAngle = (dudeIsMelee(pXSprite) || dist <= kGenDudeMaxMeleeDist) ? pDudeInfo->periphery : kGenDudeKlabsAng;
int kAngle = (dudeIsMelee(actor) || dist <= kGenDudeMaxMeleeDist) ? pDudeInfo->periphery : kGenDudeKlabsAng;
if (dist < vdist && abs(losAngle) < kAngle)
{
@ -854,7 +854,7 @@ static void unicultThinkChase(DBloodActor* actor)
switch (pHSprite->type)
{
case kDudeModernCustom: // and make dude which could be hit to dodge too
if (!dudeIsMelee(pXHSprite) && Chance(dist << 4))
if (!dudeIsMelee(hitactor) && Chance(dist << 4))
{
if (!inAttack(pXHSprite->aiState))
{
@ -1520,16 +1520,17 @@ DBloodActor* getNextIncarnation(DBloodActor* actor)
return NULL;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool dudeIsMelee(XSPRITE* pXSprite) {
return gGenDudeExtra[sprite[pXSprite->reference].index].isMelee;
bool dudeIsMelee(DBloodActor* actor)
{
return actor->genDudeExtra().isMelee;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void scaleDamage(XSPRITE* pXSprite) {
short curWeapon = gGenDudeExtra[sprite[pXSprite->reference].index].curWeapon;
@ -1772,8 +1773,10 @@ int getBaseChanceModifier(int baseChance) {
}
int getRecoilChance(spritetype* pSprite) {
XSPRITE* pXSprite = &xsprite[pSprite->extra]; int mass = getSpriteMassBySize(pSprite);
int baseChance = (!dudeIsMelee(pXSprite) ? 0x8000 : 0x4000);
auto actor = &bloodActors[pSprite->index];
XSPRITE* pXSprite = &xsprite[pSprite->extra];
int mass = getSpriteMassBySize(pSprite);
int baseChance = (!dudeIsMelee(actor) ? 0x8000 : 0x4000);
baseChance = getBaseChanceModifier(baseChance) + pXSprite->data3;
int chance = ((baseChance / mass) << 7);
@ -1781,8 +1784,10 @@ int getRecoilChance(spritetype* pSprite) {
}
int getDodgeChance(spritetype* pSprite) {
XSPRITE* pXSprite = &xsprite[pSprite->extra]; int mass = getSpriteMassBySize(pSprite);
int baseChance = (!dudeIsMelee(pXSprite) ? 0x6000 : 0x1000);
auto actor = &bloodActors[pSprite->index];
XSPRITE* pXSprite = &xsprite[pSprite->extra];
int mass = getSpriteMassBySize(pSprite);
int baseChance = (!dudeIsMelee(actor) ? 0x6000 : 0x1000);
baseChance = getBaseChanceModifier(baseChance) + pXSprite->data3;
int chance = ((baseChance / mass) << 7);

View file

@ -212,7 +212,7 @@ void genDudeTransform(spritetype* pSprite);
void dudeLeechOperate(spritetype* pSprite, XSPRITE* pXSprite, EVENT a3);
int getDodgeChance(spritetype* pSprite);
int getRecoilChance(spritetype* pSprite);
bool dudeIsMelee(XSPRITE* pXSprite);
bool dudeIsMelee(DBloodActor* pXSprite);
void updateTargetOfSlaves(spritetype* pSprite);
void updateTargetOfLeech(spritetype* pSprite);
bool canSwim(spritetype* pSprite);

View file

@ -4532,7 +4532,7 @@ bool aiFightUnitCanFly(spritetype* pDude) {
}
bool aiFightIsMeleeUnit(spritetype* pDude) {
if (pDude->type == kDudeModernCustom) return (pDude->extra >= 0 && dudeIsMelee(&xsprite[pDude->extra]));
if (pDude->type == kDudeModernCustom) return (pDude->extra >= 0 && dudeIsMelee(&bloodActors[pDude->index]));
else return (IsDudeSprite(pDude) && gDudeInfoExtra[pDude->type - kDudeBase].melee);
}