Scripts/Draenor: Implemented Garrison V1 Alliance enter/exit (#29550)

This commit is contained in:
Naddley
2024-01-05 18:43:22 +01:00
committed by GitHub
parent 70d0eaf4f8
commit 1e4e2d953a
3 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AreaTrigger.h"
#include "AreaTriggerAI.h"
#include "Garrison.h"
#include "Map.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Unit.h"
// XX - Garrison enter AreaTrigger
struct at_garrison_enter : AreaTriggerAI
{
at_garrison_enter(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { }
void OnInitialize() override
{
at->setActive(true); // has to be active, otherwise the at is no longer updated before we are able to leave it
}
void OnUnitEnter(Unit* unit) override
{
Player* player = unit->ToPlayer();
if (!player)
return;
Garrison* garrison = player->GetGarrison();
if (!garrison)
return;
garrison->Enter();
}
};
// XX - Garrison exit AreaTrigger
struct at_garrison_exit : AreaTriggerAI
{
at_garrison_exit(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { }
void OnInitialize() override
{
at->setActive(true); // has to be active, otherwise the at is no longer updated before we are able to leave it
}
void OnUnitExit(Unit* unit) override
{
Player* player = unit->ToPlayer();
if (!player)
return;
Garrison* garrison = player->GetGarrison();
if (!garrison)
return;
garrison->Leave();
}
};
void AddSC_garrison_generic()
{
// AreaTrigger
RegisterAreaTriggerAI(at_garrison_enter);
RegisterAreaTriggerAI(at_garrison_exit);
}

View File

@@ -18,6 +18,7 @@
// This is where scripts' loading functions should be declared:
void AddSC_assault_on_the_dark_portal();
void AddSC_draenor_shadowmoon_valley();
void AddSC_garrison_generic();
// The name of this function should match:
// void Add${NameOfDirectory}Scripts()
@@ -25,4 +26,5 @@ void AddDraenorScripts()
{
AddSC_assault_on_the_dark_portal();
AddSC_draenor_shadowmoon_valley();
AddSC_garrison_generic();
}