mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-02 15:36:39 +00:00
Feature #960: Add knockdown and hit recovery for creatures
This commit is contained in:
parent
9b32b1403b
commit
149d77dedf
2 changed files with 23 additions and 0 deletions
|
@ -69,6 +69,9 @@ namespace MWClass
|
||||||
fMaxFlySpeed = gmst.find("fMaxFlySpeed");
|
fMaxFlySpeed = gmst.find("fMaxFlySpeed");
|
||||||
fSwimRunBase = gmst.find("fSwimRunBase");
|
fSwimRunBase = gmst.find("fSwimRunBase");
|
||||||
fSwimRunAthleticsMult = gmst.find("fSwimRunAthleticsMult");
|
fSwimRunAthleticsMult = gmst.find("fSwimRunAthleticsMult");
|
||||||
|
fKnockDownMult = gmst.find("fKnockDownMult");
|
||||||
|
iKnockDownOddsMult = gmst.find("iKnockDownOddsMult");
|
||||||
|
iKnockDownOddsBase = gmst.find("iKnockDownOddsBase");
|
||||||
|
|
||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
|
@ -255,6 +258,19 @@ namespace MWClass
|
||||||
ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1);
|
ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for knockdown
|
||||||
|
float agilityTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() * fKnockDownMult->getFloat();
|
||||||
|
float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified()
|
||||||
|
* iKnockDownOddsMult->getInt() * 0.01 + iKnockDownOddsBase->getInt();
|
||||||
|
int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
|
||||||
|
if (ishealth && agilityTerm <= damage && knockdownTerm <= roll)
|
||||||
|
{
|
||||||
|
getCreatureStats(ptr).setKnockedDown(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
getCreatureStats(ptr).setHitRecovery(true); // Is this supposed to always occur?
|
||||||
|
|
||||||
if(ishealth)
|
if(ishealth)
|
||||||
{
|
{
|
||||||
if(damage > 0.0f)
|
if(damage > 0.0f)
|
||||||
|
@ -607,5 +623,8 @@ namespace MWClass
|
||||||
const ESM::GameSetting *Creature::fMaxFlySpeed;
|
const ESM::GameSetting *Creature::fMaxFlySpeed;
|
||||||
const ESM::GameSetting *Creature::fSwimRunBase;
|
const ESM::GameSetting *Creature::fSwimRunBase;
|
||||||
const ESM::GameSetting *Creature::fSwimRunAthleticsMult;
|
const ESM::GameSetting *Creature::fSwimRunAthleticsMult;
|
||||||
|
const ESM::GameSetting *Creature::fKnockDownMult;
|
||||||
|
const ESM::GameSetting *Creature::iKnockDownOddsMult;
|
||||||
|
const ESM::GameSetting *Creature::iKnockDownOddsBase;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,10 @@ namespace MWClass
|
||||||
static const ESM::GameSetting *fMaxFlySpeed;
|
static const ESM::GameSetting *fMaxFlySpeed;
|
||||||
static const ESM::GameSetting *fSwimRunBase;
|
static const ESM::GameSetting *fSwimRunBase;
|
||||||
static const ESM::GameSetting *fSwimRunAthleticsMult;
|
static const ESM::GameSetting *fSwimRunAthleticsMult;
|
||||||
|
static const ESM::GameSetting *fKnockDownMult;
|
||||||
|
static const ESM::GameSetting *iKnockDownOddsMult;
|
||||||
|
static const ESM::GameSetting *iKnockDownOddsBase;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue