Welcome to WoWEmulation! I am sharing a C++ script that automatically applies a spell upon entering a zone. And removes it when leaving the defined sign.
To customize this script to your liking, you can modify the following defines:
buffid
zoneid
#include "ScriptPCH.h"
#include "Player.h"
#include "Unit.h"
// Define your buffid and zoneid here!
#define buffid 48162
#define zoneid 12
class buff_zone : public PlayerScript
{
public:
buff_zone() : PlayerScript("buff_zone") {}
void OnUpdateZone(Player* player, uint32 newZone, uint32 /*newArea*/)
{
if (newZone == zoneid) {
player->AddAura(buffid, player);
}
else {
player->RemoveAurasDueToSpell(buffid);
}
}
};
void AddSC_Buff_Zone()
{
new buff_zone();
}
If you are not sure how to add custom C++ scripts to your TrinityCore 3.3.5a server, you can visit the following link for more information and instructions: LINK