mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 21:45:33 +00:00
Remove a redundant function
This commit is contained in:
parent
71bc22401f
commit
7f66339790
7 changed files with 10 additions and 60 deletions
|
@ -394,8 +394,10 @@ namespace MWClass
|
||||||
damage = scaleDamage(damage, attacker, ptr);
|
damage = scaleDamage(damage, attacker, ptr);
|
||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, "Health Damage", 1.0f, 1.0f);
|
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, "Health Damage", 1.0f, 1.0f);
|
||||||
float health = getCreatureStats(ptr).getHealth().getCurrent() - damage;
|
|
||||||
setActorHealth(ptr, health, attacker);
|
MWMechanics::DynamicStat<float> health(getCreatureStats(ptr).getHealth());
|
||||||
|
health.setCurrent(health.getCurrent() - damage);
|
||||||
|
getCreatureStats(ptr).setHealth(health);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -430,26 +432,6 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::setActorHealth(const MWWorld::Ptr& ptr, float health, const MWWorld::Ptr& attacker) const
|
|
||||||
{
|
|
||||||
MWMechanics::CreatureStats &crstats = getCreatureStats(ptr);
|
|
||||||
bool wasDead = crstats.isDead();
|
|
||||||
|
|
||||||
MWMechanics::DynamicStat<float> stat(crstats.getHealth());
|
|
||||||
stat.setCurrent(health);
|
|
||||||
crstats.setHealth(stat);
|
|
||||||
|
|
||||||
if(!wasDead && crstats.isDead())
|
|
||||||
{
|
|
||||||
// actor was just killed
|
|
||||||
}
|
|
||||||
else if(wasDead && !crstats.isDead())
|
|
||||||
{
|
|
||||||
// actor was just resurrected
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Creature::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Creature::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,8 +72,6 @@ namespace MWClass
|
||||||
|
|
||||||
virtual void onHit(const MWWorld::Ptr &ptr, float damage, bool ishealth, const MWWorld::Ptr &object, const MWWorld::Ptr &attacker, bool successful) const;
|
virtual void onHit(const MWWorld::Ptr &ptr, float damage, bool ishealth, const MWWorld::Ptr &object, const MWWorld::Ptr &attacker, bool successful) const;
|
||||||
|
|
||||||
virtual void setActorHealth(const MWWorld::Ptr& ptr, float health, const MWWorld::Ptr& attacker) const;
|
|
||||||
|
|
||||||
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
|
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const;
|
const MWWorld::Ptr& actor) const;
|
||||||
///< Generate action for activation
|
///< Generate action for activation
|
||||||
|
|
|
@ -733,8 +733,9 @@ namespace MWClass
|
||||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
MWBase::Environment::get().getWindowManager()->activateHitOverlay();
|
MWBase::Environment::get().getWindowManager()->activateHitOverlay();
|
||||||
}
|
}
|
||||||
float health = getCreatureStats(ptr).getHealth().getCurrent() - damage;
|
MWMechanics::DynamicStat<float> health(getCreatureStats(ptr).getHealth());
|
||||||
setActorHealth(ptr, health, attacker);
|
health.setCurrent(health.getCurrent() - damage);
|
||||||
|
getCreatureStats(ptr).setHealth(health);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -779,26 +780,6 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Npc::setActorHealth(const MWWorld::Ptr& ptr, float health, const MWWorld::Ptr& attacker) const
|
|
||||||
{
|
|
||||||
MWMechanics::CreatureStats &crstats = getCreatureStats(ptr);
|
|
||||||
bool wasDead = crstats.isDead();
|
|
||||||
|
|
||||||
MWMechanics::DynamicStat<float> stat(crstats.getHealth());
|
|
||||||
stat.setCurrent(health);
|
|
||||||
crstats.setHealth(stat);
|
|
||||||
|
|
||||||
if(!wasDead && crstats.isDead())
|
|
||||||
{
|
|
||||||
// actor was just killed
|
|
||||||
}
|
|
||||||
else if(wasDead && !crstats.isDead())
|
|
||||||
{
|
|
||||||
// actor was just resurrected
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Npc::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Npc::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,8 +87,6 @@ namespace MWClass
|
||||||
|
|
||||||
virtual void block(const MWWorld::Ptr &ptr) const;
|
virtual void block(const MWWorld::Ptr &ptr) const;
|
||||||
|
|
||||||
virtual void setActorHealth(const MWWorld::Ptr& ptr, float health, const MWWorld::Ptr& attacker) const;
|
|
||||||
|
|
||||||
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
|
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const;
|
const MWWorld::Ptr& actor) const;
|
||||||
///< Generate action for activation
|
///< Generate action for activation
|
||||||
|
|
|
@ -699,7 +699,9 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
// If drowning, apply 3 points of damage per second
|
// If drowning, apply 3 points of damage per second
|
||||||
static const float fSuffocationDamage = world->getStore().get<ESM::GameSetting>().find("fSuffocationDamage")->getFloat();
|
static const float fSuffocationDamage = world->getStore().get<ESM::GameSetting>().find("fSuffocationDamage")->getFloat();
|
||||||
ptr.getClass().setActorHealth(ptr, stats.getHealth().getCurrent() - fSuffocationDamage*duration);
|
DynamicStat<float> health = stats.getHealth();
|
||||||
|
health.setCurrent(health.getCurrent() - fSuffocationDamage*duration);
|
||||||
|
stats.setHealth(health);
|
||||||
|
|
||||||
// Play a drowning sound
|
// Play a drowning sound
|
||||||
MWBase::SoundManager *sndmgr = MWBase::Environment::get().getSoundManager();
|
MWBase::SoundManager *sndmgr = MWBase::Environment::get().getSoundManager();
|
||||||
|
|
|
@ -109,11 +109,6 @@ namespace MWWorld
|
||||||
throw std::runtime_error("class cannot be hit");
|
throw std::runtime_error("class cannot be hit");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Class::setActorHealth(const Ptr& ptr, float health, const Ptr& attacker) const
|
|
||||||
{
|
|
||||||
throw std::runtime_error("class does not have actor health");
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor) const
|
boost::shared_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor) const
|
||||||
{
|
{
|
||||||
return boost::shared_ptr<Action> (new NullAction);
|
return boost::shared_ptr<Action> (new NullAction);
|
||||||
|
|
|
@ -136,12 +136,6 @@ namespace MWWorld
|
||||||
///< Play the appropriate sound for a blocked attack, depending on the currently equipped shield
|
///< Play the appropriate sound for a blocked attack, depending on the currently equipped shield
|
||||||
/// (default implementation: throw an exception)
|
/// (default implementation: throw an exception)
|
||||||
|
|
||||||
virtual void setActorHealth(const Ptr& ptr, float health, const Ptr& attacker=Ptr()) const;
|
|
||||||
///< Sets a new current health value for the actor, optionally specifying the object causing
|
|
||||||
/// the change. Use this instead of using CreatureStats directly as this will make sure the
|
|
||||||
/// correct dialog and actor states are properly handled when being hurt or healed.
|
|
||||||
/// (default implementation: throw an exception)
|
|
||||||
|
|
||||||
virtual boost::shared_ptr<Action> activate (const Ptr& ptr, const Ptr& actor) const;
|
virtual boost::shared_ptr<Action> activate (const Ptr& ptr, const Ptr& actor) const;
|
||||||
///< Generate action for activation (default implementation: return a null action).
|
///< Generate action for activation (default implementation: return a null action).
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue