mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-24 04:10:15 +00:00
Fix CreatureTargetted function
This commit is contained in:
parent
4c94289b1f
commit
ea21d8fec3
7 changed files with 15 additions and 21 deletions
|
@ -536,7 +536,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
|||
|
||||
case SelectWrapper::Function_CreatureTargetted:
|
||||
|
||||
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getCreatureTargetted();
|
||||
return mActor.getClass().getCreatureStats (mActor).getCreatureTargetted();
|
||||
|
||||
case SelectWrapper::Function_Werewolf:
|
||||
|
||||
|
|
|
@ -360,9 +360,9 @@ namespace MWMechanics
|
|||
return 1;
|
||||
}
|
||||
|
||||
const std::string &AiCombat::getTargetId() const
|
||||
MWWorld::Ptr AiCombat::getTarget() const
|
||||
{
|
||||
return mTarget.getRefData().getHandle();
|
||||
return mTarget;
|
||||
}
|
||||
|
||||
AiCombat *MWMechanics::AiCombat::clone() const
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace MWMechanics
|
|||
|
||||
virtual unsigned int getPriority() const;
|
||||
|
||||
const std::string &getTargetId() const;
|
||||
MWWorld::Ptr getTarget() const;
|
||||
|
||||
private:
|
||||
PathFinder mPathFinder;
|
||||
|
|
|
@ -55,13 +55,12 @@ int MWMechanics::AiSequence::getTypeId() const
|
|||
return mPackages.front()->getTypeId();
|
||||
}
|
||||
|
||||
bool MWMechanics::AiSequence::getCombatTarget(std::string &targetActorId) const
|
||||
MWWorld::Ptr MWMechanics::AiSequence::getCombatTarget() const
|
||||
{
|
||||
if (getTypeId() != AiPackage::TypeIdCombat)
|
||||
return false;
|
||||
return MWWorld::Ptr();
|
||||
const AiCombat *combat = static_cast<const AiCombat *>(mPackages.front());
|
||||
targetActorId = combat->getTargetId();
|
||||
return true;
|
||||
return combat->getTarget();
|
||||
}
|
||||
|
||||
void MWMechanics::AiSequence::stopCombat()
|
||||
|
|
|
@ -36,9 +36,8 @@ namespace MWMechanics
|
|||
int getTypeId() const;
|
||||
///< @see enum AiPackage::TypeId
|
||||
|
||||
bool getCombatTarget (std::string &targetActorId) const;
|
||||
///< Return true and assign target if combat package is currently
|
||||
/// active, return false otherwise
|
||||
MWWorld::Ptr getCombatTarget () const;
|
||||
///< Return the combat target if a combat package is active, or an empty Ptr otherwise
|
||||
|
||||
void stopCombat();
|
||||
///< Removes all combat packages until first non-combat or stack empty.
|
||||
|
|
|
@ -348,7 +348,9 @@ namespace MWMechanics
|
|||
|
||||
bool CreatureStats::getCreatureTargetted() const
|
||||
{
|
||||
return false;
|
||||
if (mAiSequence.getCombatTarget().isEmpty())
|
||||
return false;
|
||||
return mAiSequence.getCombatTarget().getTypeName() == typeid(ESM::Creature).name();
|
||||
}
|
||||
|
||||
float CreatureStats::getEvasion() const
|
||||
|
|
|
@ -412,16 +412,10 @@ namespace MWScript
|
|||
std::string testedTargetId = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
const MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(actor).getCreatureStats(actor);
|
||||
std::string currentTargetId;
|
||||
const MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
||||
|
||||
bool targetsAreEqual = false;
|
||||
if (creatureStats.getAiSequence().getCombatTarget (currentTargetId))
|
||||
{
|
||||
if (currentTargetId == testedTargetId)
|
||||
targetsAreEqual = true;
|
||||
}
|
||||
runtime.push(int(targetsAreEqual));
|
||||
MWWorld::Ptr target = creatureStats.getAiSequence().getCombatTarget();
|
||||
runtime.push(Misc::StringUtils::ciEqual(target.getCellRef().mRefID, testedTargetId));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue