OpenPerpetuum / PerpetuumServer

The Open Perpetuum Project's fork of the Perpetuum Standalone Server
https://openperpetuum.com
Other
44 stars 21 forks source link

Optimize first time vs. refresh aggro calls from NPCEvent handler #430

Open MikeJeffers opened 2 years ago

MikeJeffers commented 2 years ago

This: https://github.com/OpenPerpetuum/PerpetuumServer/blob/Development/src/Perpetuum/Services/EventServices/EventProcessors/NpcSpawnEventHandlers/NpcReinforcementSpawner.cs#L115-L124 Gets called every update from here: https://github.com/OpenPerpetuum/PerpetuumServer/blob/Development/src/Perpetuum/Services/EventServices/EventProcessors/NpcSpawnEventHandlers/NpcReinforcementSpawner.cs#L62-L77 Where the update is debounced messages from onDamage to a Boss npc. However, this eventually calls into code that further communicates aggro to all NPC's in the @group of the npc the threat was added to.

Basically this is a N^3 maybe 4 loop of threat adding that can get out of hand with larger wave spawns and larger player groups on the threat manager of the boss.

Spreading the aggro once on spawn is good, refreshing the aggro to the wave-npcs when the boss is attacked (but maybe the wave-spawned NPCs have since dropped aggro on some player) is good. But worst case this is doing a lot of redundant threat increasing when it may not be necessary.

Test carefully to ensure aggro on waves is not lost completely and players can evade the waves and attack the boss directly.