mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 22:36:41 +00:00
[Client] Prevent ActorAI spam from actors starting combat in scripts
This commit is contained in:
parent
ca21bc35c2
commit
7caa6cd8fe
1 changed files with 26 additions and 2 deletions
|
@ -294,6 +294,18 @@ namespace MWScript
|
|||
MWMechanics::CreatureStats::AiSetting setting = (MWMechanics::CreatureStats::AiSetting)mIndex;
|
||||
|
||||
MWMechanics::Stat<int> stat = ptr.getClass().getCreatureStats(ptr).getAiSetting(setting);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Track the original stat value, to ensure we don't send repetitive packets to the server
|
||||
about its changes
|
||||
*/
|
||||
int initialValue = stat.getBase();
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
stat.setModified(value, 0);
|
||||
ptr.getClass().getCreatureStats(ptr).setAiSetting(setting, stat);
|
||||
|
||||
|
@ -304,7 +316,7 @@ namespace MWScript
|
|||
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)
|
||||
if (stat.getBase() != initialValue && setting == MWMechanics::CreatureStats::AI_Fight && value == 100)
|
||||
{
|
||||
mwmp::ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList();
|
||||
actorList->reset();
|
||||
|
@ -502,6 +514,18 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(targetID, true);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Track whether this actor is already in combat with its target, to ensure we don't
|
||||
send repetitive packets to the server
|
||||
*/
|
||||
bool alreadyInCombatWithTarget = actor.getClass().getCreatureStats(actor).getAiSequence().isInCombat(target);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
MWBase::Environment::get().getMechanicsManager()->startCombat(actor, target);
|
||||
|
||||
/*
|
||||
|
@ -511,7 +535,7 @@ namespace MWScript
|
|||
cell authority or not; the server can decide if it wants to comply with them by
|
||||
forwarding them to the cell authority
|
||||
*/
|
||||
if (target)
|
||||
if (target && !alreadyInCombatWithTarget)
|
||||
{
|
||||
mwmp::ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList();
|
||||
actorList->reset();
|
||||
|
|
Loading…
Reference in a new issue