Make getWeaponDrawn return 1 only when the weapon is attached (bug #4816)

pull/3228/head
Alexei Kotov 2 years ago
parent 28d6159b86
commit d458894868

@ -2,6 +2,7 @@
------
Bug #4127: Weapon animation looks choppy
Bug #4816: GetWeaponDrawn returns 1 before weapon is attached
Bug #5057: Weapon swing sound plays at same pitch whether it hits or misses
Bug #5129: Stuttering animation on Centurion Archer
Bug #5977: Fatigueless NPCs' corpse underwater changes animation on game load

@ -465,6 +465,7 @@ public:
const osg::Node* getNode(const std::string& name) const;
virtual bool useShieldAnimations() const { return false; }
virtual bool getWeaponsShown() const { return false; }
virtual void showWeapons(bool showWeapon) {}
virtual bool getCarriedLeftShown() const { return false; }
virtual void showCarriedLeft(bool show) {}

@ -30,6 +30,7 @@ namespace MWRender
void equipmentChanged() override { updateParts(); }
bool getWeaponsShown() const override { return mShowWeapons; }
void showWeapons(bool showWeapon) override;
bool getCarriedLeftShown() const override { return mShowCarriedLeft; }

@ -135,6 +135,7 @@ public:
/// to indicate the facing orientation of the character.
void setPitchFactor(float factor) override { mPitchFactor = factor; }
bool getWeaponsShown() const override { return mShowWeapons; }
void showWeapons(bool showWeapon) override;
bool updateCarriedLeftVisible(const int weaptype) const override;

@ -47,6 +47,8 @@
#include "../mwmechanics/spellcasting.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "../mwrender/animation.hpp"
#include "interpretercontext.hpp"
#include "ref.hpp"
@ -781,9 +783,21 @@ namespace MWScript
void execute (Interpreter::Runtime& runtime) override
{
MWWorld::Ptr ptr = R()(runtime);
auto& cls = ptr.getClass();
if (!cls.hasInventoryStore(ptr) && !cls.isBipedal(ptr))
{
runtime.push(0);
return;
}
if (cls.getCreatureStats(ptr).getDrawState () != MWMechanics::DrawState::Weapon)
{
runtime.push(0);
return;
}
runtime.push((ptr.getClass().hasInventoryStore(ptr) || ptr.getClass().isBipedal(ptr)) &&
ptr.getClass().getCreatureStats (ptr).getDrawState () == MWMechanics::DrawState::Weapon);
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(ptr);
runtime.push(anim && anim->getWeaponsShown());
}
};

Loading…
Cancel
Save