From 6d43c8d63df27162e76aed2b16e8da82baf24d0a Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 14 Jul 2018 02:55:38 +0300 Subject: [PATCH] [Client] Send ActorAI with combat when an NPC's fight is set to 100 --- apps/openmw/mwscript/aiextensions.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index b240f9781..a259aafe5 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -297,6 +297,25 @@ namespace MWScript MWMechanics::Stat stat = ptr.getClass().getCreatureStats(ptr).getAiSetting(setting); stat.setModified(value, 0); ptr.getClass().getCreatureStats(ptr).setAiSetting(setting, stat); + + /* + Start of tes3mp addition + + Setting an actor's AI_Fight to 100 is equivalent to starting combat with the local player, + so send a combat packet regardless of whether we're the cell authority or not; the server + can decide if it wants to comply with them by forwarding them to the cell authority + */ + if (setting == MWMechanics::CreatureStats::AI_Fight && value == 100) + { + mwmp::ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList(); + actorList->reset(); + actorList->cell = *ptr.getCell()->getCell(); + actorList->addAiActor(ptr, MWBase::Environment::get().getWorld()->getPlayerPtr(), mwmp::BaseActorList::COMBAT); + actorList->sendAiActors(); + } + /* + End of tes3mp addition + */ } };