[Client] Enable AI for LocalActors

0.6.1
David Cernat 8 years ago
parent 0d766a7a04
commit d4a12856ee

@ -1131,7 +1131,18 @@ namespace MWMechanics
return; // for now abort update of the old cell when cell changes by teleportation magic effect return; // for now abort update of the old cell when cell changes by teleportation magic effect
// a better solution might be to apply cell changes at the end of the frame // a better solution might be to apply cell changes at the end of the frame
} }
if (MWBase::Environment::get().getMechanicsManager()->isAIActive() && inProcessingRange) /*
Start of tes3mp change (major)
Allow AI processing when LiveCellRefBase's isLocalActor set to true
*/
//if (MWBase::Environment::get().getMechanicsManager()->isAIActive() && inProcessingRange)
if ((MWBase::Environment::get().getMechanicsManager()->isAIActive() || actor.getBase()->isLocalActor)
&& inProcessingRange)
/*
End of tes3mp change (major)
*/
{ {
if (timerUpdateAITargets == 0) if (timerUpdateAITargets == 0)
{ {

@ -54,11 +54,23 @@ void Cell::initializeLocalActors()
std::string mapIndex = generateMapIndex(ptr); std::string mapIndex = generateMapIndex(ptr);
localActors[mapIndex] = new LocalActor(); localActors[mapIndex] = new LocalActor();
localActors[mapIndex]->cell = esmCell; localActors[mapIndex]->cell = esmCell;
ptr.getBase()->isLocalActor = true;
localActors[mapIndex]->setPtr(ptr); localActors[mapIndex]->setPtr(ptr);
LOG_APPEND(Log::LOG_INFO, "- Initialized LocalActor %s", mapIndex.c_str()); LOG_APPEND(Log::LOG_INFO, "- Initialized LocalActor %s", mapIndex.c_str());
} }
} }
void Cell::uninitializeLocalActors()
{
for (std::map<std::string, LocalActor *>::iterator it = localActors.begin(); it != localActors.end(); ++it)
{
LocalActor *actor = it->second;
actor->getPtr().getBase()->isLocalActor = false;
}
localActors.clear();
}
std::string Cell::generateMapIndex(MWWorld::Ptr ptr) std::string Cell::generateMapIndex(MWWorld::Ptr ptr)
{ {
std::string mapIndex = ""; std::string mapIndex = "";

@ -16,6 +16,7 @@ namespace mwmp
void update(); void update();
void initializeLocalActors(); void initializeLocalActors();
void uninitializeLocalActors();
std::string generateMapIndex(MWWorld::Ptr ptr); std::string generateMapIndex(MWWorld::Ptr ptr);

@ -30,6 +30,7 @@ void CellController::update()
if (!MWBase::Environment::get().getWorld()->isCellActive(mpCell->getCellStore())) if (!MWBase::Environment::get().getWorld()->isCellActive(mpCell->getCellStore()))
{ {
mpCell->uninitializeLocalActors();
it = cellsActive.erase(it); it = cellsActive.erase(it);
} }
else else

@ -14,7 +14,16 @@
MWWorld::LiveCellRefBase::LiveCellRefBase(const std::string& type, const ESM::CellRef &cref) MWWorld::LiveCellRefBase::LiveCellRefBase(const std::string& type, const ESM::CellRef &cref)
: mClass(&Class::get(type)), mRef(cref), mData(cref) : mClass(&Class::get(type)), mRef(cref), mData(cref)
{ {
/*
Start of tes3mp addition
Set default values for tes3mp-only booleans
*/
canChangeCell = true; canChangeCell = true;
isLocalActor = false;
/*
End of tes3mp addition
*/
} }
void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state) void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)

@ -38,6 +38,17 @@ namespace MWWorld
End of tes3mp addition End of tes3mp addition
*/ */
/*
Start of tes3mp addition
Useful boolean for quickly establishing which creatures and NPCs should be
processed locally by the player
*/
bool isLocalActor;
/*
End of tes3mp addition
*/
/** runtime-data */ /** runtime-data */
RefData mData; RefData mData;

Loading…
Cancel
Save