First Commit
This commit is contained in:
15
modules/mod-auto-resurrect/src/AR_loader.cpp
Normal file
15
modules/mod-auto-resurrect/src/AR_loader.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
*/
|
||||
|
||||
// From SC
|
||||
void AddAutoResurrectScripts();
|
||||
|
||||
// Add all
|
||||
// cf. the naming convention https://github.com/azerothcore/azerothcore-wotlk/blob/master/doc/changelog/master.md#how-to-upgrade-4
|
||||
// additionally replace all '-' in the module folder name with '_' here
|
||||
void Addmod_auto_resurrectScripts()
|
||||
{
|
||||
AddAutoResurrectScripts();
|
||||
}
|
||||
|
||||
78
modules/mod-auto-resurrect/src/mod_auto_resurrect.cpp
Normal file
78
modules/mod-auto-resurrect/src/mod_auto_resurrect.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
*/
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "Player.h"
|
||||
#include "Config.h"
|
||||
#include "Chat.h"
|
||||
|
||||
// Add player scripts
|
||||
class AutoResurrect : public PlayerScript
|
||||
{
|
||||
public:
|
||||
AutoResurrect() : PlayerScript("AutoResurrect") { }
|
||||
std::map<int, const AreaTriggerTeleport*> playerLocation = {};
|
||||
|
||||
void DebugLog(Player* player, std::string log) {
|
||||
if (sConfigMgr->GetOption<bool>("AutoResurrect.Enable", false) && sConfigMgr->GetOption<bool>("AutoResurrect.Notification", false)) {
|
||||
ChatHandler(player->GetSession()).SendSysMessage(log);
|
||||
}
|
||||
}
|
||||
|
||||
void OnPlayerLogin(Player* player) override
|
||||
{
|
||||
if (sConfigMgr->GetOption<bool>("AutoResurrect.Enable", false) && sConfigMgr->GetOption<bool>("AutoResurrect.Notification", false))
|
||||
{
|
||||
DebugLog(player, "Auto Resurrect module enabled");
|
||||
}
|
||||
}
|
||||
|
||||
void OnPlayerReleasedGhost(Player* player) override {
|
||||
if (!sConfigMgr->GetOption<bool>("AutoResurrect.Enable", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map* map = player->GetMap();
|
||||
|
||||
bool dungeons = sConfigMgr->GetOption<bool>("AutoResurrect.Dungeon", false);
|
||||
bool heroics = sConfigMgr->GetOption<bool>("AutoResurrect.HeroicDungeon", false);
|
||||
bool raids = sConfigMgr->GetOption<bool>("AutoResurrect.Raid", false);
|
||||
bool heroicRaids = sConfigMgr->GetOption<bool>("AutoResurrect.HeroicRaid", false);
|
||||
|
||||
if ((dungeons && !map->IsHeroic() && map->IsDungeon()) ||
|
||||
(heroics && map->IsHeroic() && map->IsDungeon()) ||
|
||||
(raids && !map->IsHeroic() && map->IsRaid()) ||
|
||||
(heroicRaids && map->IsHeroic() && map->IsRaid())) {
|
||||
AreaTriggerTeleport const* at = sObjectMgr->GetMapEntranceTrigger(player->GetMapId());
|
||||
playerLocation[player->GetGUID()] = at;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPlayerMapChanged(Player* player) override {
|
||||
if (!sConfigMgr->GetOption<bool>("AutoResurrect.Enable", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerLocation.count(player->GetGUID())) {
|
||||
return;
|
||||
}
|
||||
|
||||
AreaTriggerTeleport const* at = playerLocation[player->GetGUID()];
|
||||
if (at == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
player->ResurrectPlayer(1.0f);
|
||||
player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation);
|
||||
player->SaveToDB(false, false);
|
||||
|
||||
playerLocation[player->GetGUID()] = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
// Add all scripts in one
|
||||
void AddAutoResurrectScripts()
|
||||
{
|
||||
new AutoResurrect();
|
||||
}
|
||||
Reference in New Issue
Block a user