Hook to execute custom code on player entry or exit of any instance

I’m trying to figure out a way to attach custom code to when a player enters or exits ANY instance. Ideally when this code executes I would have the:

[ul][li]Player object for who entered/exited[/li]
[li]InstanceScript for the instance entered/exited[/li]
[/ul]
And I would like to be able to inject this code without modifying every instance’s InstanceScript. I think what I’m looking for is some way to register code with a central event queue where I could listen to player instance events but I’m totally new to the code base and I don’t have a good grasp on the flow or know if what I’m looking for exists.

The use case I’m shooting for is when a player enters or exits an instance I want to give the player a set of buffs based on the instance they entered and the number of other players in the instance giving them a higher chance of completing the instance with less than the ideal number of players or group makeup. For a simplified example lets say a player enters a 20man instance solo I would like to multiply all of the players stats by 20 but if they entered a 40man I would multiply by 40. I may also want to add a HP regeneration buff that would be equivalent to having equal level healers for 1/4 of the ideal raid size. If the instance has more than one player it would tune down the buffs to give roughly the same total effect for multiple players.

Does the current 3.3.5 core have a place to inject a hook like this?

Thanks.

You can implement a PlayerScript with this hook https://github.com/TrinityCore/TrinityCore/blob/6.x/src/server/game/Scripting/ScriptMgr.h#L734

You don’t need to access the old map - simply recalculate your values on entering the map (this also fires for non-instance maps which is good because you can ‘calculate’ the multiplier to 1 when such map is entered)

Thanks Shauren that worked perfect. I’ve got it applying and removing kings entering and exiting an instance. Now to figure out creating a custom aura.