[Client] Allow AiActivate to be used with specific Ptrs, not just refIds

0.6.3
David Cernat 7 years ago
parent 00c13ae96c
commit c984fc0881

@ -18,6 +18,20 @@ namespace MWMechanics
{ {
} }
/*
Start of tes3mp addition
Allow AiActivate to be initialized using a Ptr instead of a refId
*/
AiActivate::AiActivate(MWWorld::Ptr object)
: mObjectId("")
{
mObjectPtr = object;
}
/*
End of tes3mp addition
*/
AiActivate *MWMechanics::AiActivate::clone() const AiActivate *MWMechanics::AiActivate::clone() const
{ {
return new AiActivate(*this); return new AiActivate(*this);
@ -25,7 +39,15 @@ namespace MWMechanics
bool AiActivate::execute(const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) bool AiActivate::execute(const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{ {
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow /*
Start of tes3mp change (major)
Only search for an object based on its refId if we haven't provided a specific object already
*/
const MWWorld::Ptr target = mObjectId.empty() ? mObjectPtr : MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false);
/*
End of tes3mp change (major)
*/
actor.getClass().getCreatureStats(actor).setDrawState(DrawState_Nothing); actor.getClass().getCreatureStats(actor).setDrawState(DrawState_Nothing);

@ -3,6 +3,16 @@
#include "aipackage.hpp" #include "aipackage.hpp"
/*
Start of tes3mp addition
Include additional headers for multiplayer purposes
*/
#include "../mwworld/ptr.hpp"
/*
End of tes3mp addition
*/
#include <string> #include <string>
#include "pathfinding.hpp" #include "pathfinding.hpp"
@ -26,6 +36,17 @@ namespace MWMechanics
/** \param objectId Reference to object to activate **/ /** \param objectId Reference to object to activate **/
AiActivate(const std::string &objectId); AiActivate(const std::string &objectId);
/*
Start of tes3mp addition
Make it possible to initialize an AiActivate package with a specific Ptr
as the target, allowing for more fine-tuned activation of objects
*/
AiActivate(MWWorld::Ptr object);
/*
End of tes3mp addition
*/
AiActivate(const ESM::AiSequence::AiActivate* activate); AiActivate(const ESM::AiSequence::AiActivate* activate);
virtual AiActivate *clone() const; virtual AiActivate *clone() const;
@ -36,6 +57,16 @@ namespace MWMechanics
private: private:
std::string mObjectId; std::string mObjectId;
/*
Start of tes3mp addition
Track the object associated with this AiActivate package
*/
MWWorld::Ptr mObjectPtr;
/*
End of tes3mp addition
*/
}; };
} }
#endif // GAME_MWMECHANICS_AIACTIVATE_H #endif // GAME_MWMECHANICS_AIACTIVATE_H

Loading…
Cancel
Save