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