- getRecoilChance + getDodgeChance

This commit is contained in:
Christoph Oelckers 2021-05-06 09:08:06 +02:00
parent b70368050a
commit b1f55434a2
3 changed files with 12 additions and 10 deletions

View file

@ -1097,7 +1097,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
{ {
if (!dudeIsMelee(actor)) if (!dudeIsMelee(actor))
{ {
if (inIdle(pXSprite->aiState) || Chance(getDodgeChance(pSprite))) if (inIdle(pXSprite->aiState) || Chance(getDodgeChance(actor)))
{ {
if (!spriteIsUnderwater(actor)) if (!spriteIsUnderwater(actor))
{ {
@ -1274,7 +1274,7 @@ void RecoilDude(DBloodActor* actor)
case kDudeModernCustom: case kDudeModernCustom:
{ {
GENDUDEEXTRA* pExtra = &actor->genDudeExtra(); GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
int rChance = getRecoilChance(pSprite); int rChance = getRecoilChance(actor);
if (pExtra->canElectrocute && pDudeExtra->teslaHit && !spriteIsUnderwater(actor, false)) if (pExtra->canElectrocute && pDudeExtra->teslaHit && !spriteIsUnderwater(actor, false))
{ {
if (Chance(rChance << 3) || (dudeIsMelee(actor) && Chance(rChance << 4))) aiGenDudeNewState(actor, &genDudeRecoilTesla); if (Chance(rChance << 3) || (dudeIsMelee(actor) && Chance(rChance << 4))) aiGenDudeNewState(actor, &genDudeRecoilTesla);

View file

@ -1808,9 +1808,10 @@ int getBaseChanceModifier(int baseChance)
return ((gGameOptions.nDifficulty > 0) ? baseChance - (0x0500 * gGameOptions.nDifficulty) : baseChance); return ((gGameOptions.nDifficulty > 0) ? baseChance - (0x0500 * gGameOptions.nDifficulty) : baseChance);
} }
int getRecoilChance(spritetype* pSprite) { int getRecoilChance(DBloodActor* actor)
auto actor = &bloodActors[pSprite->index]; {
XSPRITE* pXSprite = &xsprite[pSprite->extra]; auto const pSprite = &actor->s();
auto const pXSprite = &actor->x();
int mass = getSpriteMassBySize(pSprite); int mass = getSpriteMassBySize(pSprite);
int baseChance = (!dudeIsMelee(actor) ? 0x8000 : 0x4000); int baseChance = (!dudeIsMelee(actor) ? 0x8000 : 0x4000);
baseChance = getBaseChanceModifier(baseChance) + pXSprite->data3; baseChance = getBaseChanceModifier(baseChance) + pXSprite->data3;
@ -1819,9 +1820,10 @@ int getRecoilChance(spritetype* pSprite) {
return chance; return chance;
} }
int getDodgeChance(spritetype* pSprite) { int getDodgeChance(DBloodActor* actor)
auto actor = &bloodActors[pSprite->index]; {
XSPRITE* pXSprite = &xsprite[pSprite->extra]; auto const pSprite = &actor->s();
auto const pXSprite = &actor->x();
int mass = getSpriteMassBySize(pSprite); int mass = getSpriteMassBySize(pSprite);
int baseChance = (!dudeIsMelee(actor) ? 0x6000 : 0x1000); int baseChance = (!dudeIsMelee(actor) ? 0x6000 : 0x1000);
baseChance = getBaseChanceModifier(baseChance) + pXSprite->data3; baseChance = getBaseChanceModifier(baseChance) + pXSprite->data3;

View file

@ -210,8 +210,8 @@ bool doExplosion(spritetype* pSprite, int nType);
spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist); spritetype* genDudeSpawn(XSPRITE* pXSource, spritetype* pSprite, int nDist);
void genDudeTransform(spritetype* pSprite); void genDudeTransform(spritetype* pSprite);
void dudeLeechOperate(spritetype* pSprite, XSPRITE* pXSprite, EVENT a3); void dudeLeechOperate(spritetype* pSprite, XSPRITE* pXSprite, EVENT a3);
int getDodgeChance(spritetype* pSprite); int getDodgeChance(DBloodActor* pSprite);
int getRecoilChance(spritetype* pSprite); int getRecoilChance(DBloodActor* pSprite);
bool dudeIsMelee(DBloodActor* pXSprite); bool dudeIsMelee(DBloodActor* pXSprite);
void updateTargetOfSlaves(spritetype* pSprite); void updateTargetOfSlaves(spritetype* pSprite);
void updateTargetOfLeech(spritetype* pSprite); void updateTargetOfLeech(spritetype* pSprite);