mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-17 17:24:33 +00:00
feat(Core/WorldState): improved WorldState scripting (#20141)
* implement world state script
based on
0b87ca9d9e
Co-authored-by: killerwife <killerwife@gmail.com>
* refactor to use onleave and onenter instead of spell_area
allows players to right click remove adal's buff
* add MapMgr.h
* refactor: use condition enum instead of uint32, prefix WORLD_STATE where needed
* remove lock from WorldState::Update
sWorldState->Update() is only called from World::Update
* remove unsafe SmartAI action of setWorldState
---------
Co-authored-by: killerwife <killerwife@gmail.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "ScriptedGossip.h"
|
||||
#include "SpellScript.h"
|
||||
#include "SpellScriptLoader.h"
|
||||
#include "WorldState.h"
|
||||
|
||||
enum q10935Exorcism
|
||||
{
|
||||
@@ -602,6 +603,26 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct go_magtheridons_head : public GameObjectAI
|
||||
{
|
||||
go_magtheridons_head(GameObject* gameObject) : GameObjectAI(gameObject) { }
|
||||
|
||||
void InitializeAI() override
|
||||
{
|
||||
me->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); // spawn head on spike
|
||||
me->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
|
||||
sWorldState->HandleExternalEvent(WORLD_STATE_CUSTOM_EVENT_ON_MAGTHERIDON_HEAD_SPAWN, me->GetPositionX() > 0.f ? TEAM_HORDE : TEAM_ALLIANCE);
|
||||
}
|
||||
|
||||
void OnStateChanged(uint32 state, Unit* /*unit*/) override
|
||||
{
|
||||
if (state == GO_JUST_DEACTIVATED)
|
||||
{
|
||||
sWorldState->HandleExternalEvent(WORLD_STATE_CUSTOM_EVENT_ON_MAGTHERIDON_HEAD_DESPAWN, me->GetPositionX() > 0.f ? TEAM_HORDE : TEAM_ALLIANCE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_hellfire_peninsula()
|
||||
{
|
||||
// Ours
|
||||
@@ -615,4 +636,5 @@ void AddSC_hellfire_peninsula()
|
||||
new go_beacon();
|
||||
|
||||
RegisterCreatureAI(npc_magister_aledis);
|
||||
RegisterGameObjectAI(go_magtheridons_head);
|
||||
}
|
||||
|
||||
@@ -554,26 +554,6 @@ class spell_gen_rallying_cry_of_the_dragonslayer : public SpellScript
|
||||
}
|
||||
};
|
||||
|
||||
// 39953 - A'dal's Song of Battle
|
||||
class spell_gen_adals_song_of_battle : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_gen_adals_song_of_battle);
|
||||
|
||||
void SelectTarget(std::list<WorldObject*>& targets)
|
||||
{
|
||||
targets.clear();
|
||||
Map::PlayerList const& pList = GetCaster()->GetMap()->GetPlayers();
|
||||
for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
|
||||
if (itr->GetSource()->GetZoneId() == 3703 /*Shattrath*/)
|
||||
targets.push_back(itr->GetSource());
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_gen_adals_song_of_battle::SelectTarget, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ALLY);
|
||||
}
|
||||
};
|
||||
|
||||
/* 15366 - Songflower Serenade
|
||||
22888 - Rallying Cry of the Dragonslayer */
|
||||
class spell_gen_disabled_above_63 : public AuraScript
|
||||
@@ -5336,7 +5316,6 @@ void AddSC_generic_spell_scripts()
|
||||
RegisterSpellScript(spell_pet_hit_expertise_scalling);
|
||||
RegisterSpellScript(spell_gen_grow_flower_patch);
|
||||
RegisterSpellScript(spell_gen_rallying_cry_of_the_dragonslayer);
|
||||
RegisterSpellScript(spell_gen_adals_song_of_battle);
|
||||
RegisterSpellScript(spell_gen_disabled_above_63);
|
||||
RegisterSpellScript(spell_gen_black_magic_enchant);
|
||||
RegisterSpellScript(spell_gen_area_aura_select_players);
|
||||
|
||||
68
src/server/scripts/World/transport_zeppelin.h
Normal file
68
src/server/scripts/World/transport_zeppelin.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is part of the AzerothCore 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 Affero General Public License as published by the
|
||||
* Free Software Foundation; either version 3 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 Affero 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/>.
|
||||
*/
|
||||
|
||||
enum ZeppelinEvent
|
||||
{
|
||||
EVENT_UC_FROM_GROMGOL_ARRIVAL = 15312,
|
||||
EVENT_GROMGOL_FROM_UC_ARRIVAL = 15314,
|
||||
EVENT_OG_FROM_UC_ARRIVAL = 15318,
|
||||
EVENT_UC_FROM_OG_ARRIVAL = 15320,
|
||||
EVENT_OG_FROM_GROMGOL_ARRIVAL = 15322,
|
||||
EVENT_GROMGOL_FROM_OG_ARRIVAL = 15324,
|
||||
EVENT_WK_ARRIVAL = 15431,
|
||||
EVENT_VL_FROM_UC_ARRIVAL = 19126,
|
||||
EVENT_UC_FROM_VL_ARRIVAL = 19127,
|
||||
EVENT_OG_FROM_BT_ARRIVAL = 19137,
|
||||
EVENT_BT_FROM_OG_ARRIVAL = 19139,
|
||||
EVENT_OG_FROM_TB_ARRIVAL = 21868,
|
||||
EVENT_TB_FROM_OG_ARRIVAL = 21870,
|
||||
EVENT_OG_TO_GROMGOL_DEPARTURE = 15323,
|
||||
EVENT_GROMGOL_TO_OG_DEPARTURE = 15325,
|
||||
EVENT_OG_TO_UC_DEPARTURE = 15319,
|
||||
EVENT_UC_TO_OG_DEPARTURE = 15321,
|
||||
EVENT_UC_TO_GROMGOL_DEPARTURE = 15313,
|
||||
EVENT_GROMGOL_TO_UC_DEPARTURE = 15315,
|
||||
};
|
||||
|
||||
enum ZeppelinMaster
|
||||
{
|
||||
NPC_NEZRAZ = 3149,
|
||||
NPC_HINDENBURG = 3150,
|
||||
NPC_FREZZA = 9564,
|
||||
NPC_ZAPETTA = 9566,
|
||||
NPC_SNURK_BUCKSQUICK = 12136,
|
||||
NPC_SQUIBBY_OVERSPECK = 12137,
|
||||
NPC_HARROWMEISER = 23823,
|
||||
NPC_GREEB_RAMROCKET = 26537,
|
||||
NPC_NARGO_SCREWBORE = 26538,
|
||||
NPC_MEEFI_FARTHROTTLE = 26539,
|
||||
NPC_DRENK_SPANNERSPARK = 26540,
|
||||
NPC_ZELLI_HOTNOZZLE = 34765,
|
||||
NPC_KRENDLE_BIGPOCKETS = 34766,
|
||||
};
|
||||
|
||||
const float SEARCH_RANGE_ZEPPELIN_MASTER = 32.0f;
|
||||
|
||||
enum ZeppelinPassenger
|
||||
{
|
||||
// The Thundercaller
|
||||
NPC_SKY_CAPTAIN_CLOUDKICKER = 25077,
|
||||
NPC_CHIEF_OFFICER_COPPERNUT = 25070,
|
||||
// The Purple Princess
|
||||
NPC_SKY_CAPTAIN_CABLELAMP = 25105,
|
||||
NPC_WATCHER_UMJIN = 25107,
|
||||
};
|
||||
109
src/server/scripts/World/transport_zeppelins.cpp
Normal file
109
src/server/scripts/World/transport_zeppelins.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* This file is part of the AzerothCore 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 Affero General Public License as published by the
|
||||
* Free Software Foundation; either version 3 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 Affero 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 "GameObjectAI.h"
|
||||
#include "GameObjectScript.h"
|
||||
#include "WorldState.h"
|
||||
#include "transport_zeppelin.h"
|
||||
|
||||
// 175080 The Iron Eagle - Grom'gol to Orgrimmar
|
||||
struct go_transport_the_iron_eagle : GameObjectAI
|
||||
{
|
||||
go_transport_the_iron_eagle(GameObject *object) : GameObjectAI(object) { };
|
||||
|
||||
void EventInform(uint32 eventId) override
|
||||
{
|
||||
sWorldState->HandleConditionStateChange(WORLD_STATE_CONDITION_THE_IRON_EAGLE, static_cast<WorldStateConditionState>(eventId));
|
||||
switch (eventId)
|
||||
{
|
||||
case EVENT_GROMGOL_FROM_OG_ARRIVAL:
|
||||
if (Creature *creature = me->FindNearestCreature(NPC_NEZRAZ, SEARCH_RANGE_ZEPPELIN_MASTER))
|
||||
creature->AI()->Talk(0);
|
||||
break;
|
||||
case EVENT_OG_FROM_GROMGOL_ARRIVAL:
|
||||
if (Creature *creature = me->FindNearestCreature(NPC_SNURK_BUCKSQUICK, 150.0f))
|
||||
creature->AI()->Talk(0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 164871 The Thundercaller - Undercity to Orgrimmar
|
||||
struct go_transport_the_thundercaller : GameObjectAI
|
||||
{
|
||||
go_transport_the_thundercaller(GameObject *object) : GameObjectAI(object) { };
|
||||
|
||||
void EventInform(uint32 eventId) override
|
||||
{
|
||||
sWorldState->HandleConditionStateChange(WORLD_STATE_CONDITION_THE_THUNDERCALLER, static_cast<WorldStateConditionState>(eventId));
|
||||
switch (eventId)
|
||||
{
|
||||
case EVENT_OG_FROM_UC_ARRIVAL:
|
||||
if (Creature *creature = me->FindNearestCreature(NPC_FREZZA, SEARCH_RANGE_ZEPPELIN_MASTER))
|
||||
creature->AI()->Talk(0);
|
||||
break;
|
||||
case EVENT_UC_FROM_OG_ARRIVAL:
|
||||
if (Creature *creature = me->FindNearestCreature(NPC_ZAPETTA, SEARCH_RANGE_ZEPPELIN_MASTER))
|
||||
creature->AI()->Talk(0);
|
||||
break;
|
||||
case EVENT_OG_TO_UC_DEPARTURE:
|
||||
break;
|
||||
case EVENT_UC_TO_OG_DEPARTURE:
|
||||
if (Creature *creature = me->FindNearestCreature(NPC_ZAPETTA, SEARCH_RANGE_ZEPPELIN_MASTER))
|
||||
creature->AI()->Talk(1);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 176495 The Purple Princess - Grom'Gol to Undercity
|
||||
struct go_transport_the_purple_princess : GameObjectAI
|
||||
{
|
||||
go_transport_the_purple_princess(GameObject *object) : GameObjectAI(object) { };
|
||||
|
||||
void EventInform(uint32 eventId) override
|
||||
{
|
||||
sWorldState->HandleConditionStateChange(WORLD_STATE_CONDITION_THE_PURPLE_PRINCESS, static_cast<WorldStateConditionState>(eventId));
|
||||
switch (eventId)
|
||||
{
|
||||
case EVENT_GROMGOL_FROM_UC_ARRIVAL:
|
||||
if (Creature *creature = me->FindNearestCreature(NPC_SQUIBBY_OVERSPECK, SEARCH_RANGE_ZEPPELIN_MASTER))
|
||||
creature->AI()->Talk(0);
|
||||
break;
|
||||
case EVENT_UC_FROM_GROMGOL_ARRIVAL:
|
||||
if (Creature *creature = me->FindNearestCreature(NPC_HINDENBURG, SEARCH_RANGE_ZEPPELIN_MASTER))
|
||||
creature->AI()->Talk(0);
|
||||
break;
|
||||
case EVENT_UC_TO_GROMGOL_DEPARTURE:
|
||||
case EVENT_GROMGOL_TO_UC_DEPARTURE:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_transport_zeppelins()
|
||||
{
|
||||
RegisterGameObjectAI(go_transport_the_iron_eagle);
|
||||
RegisterGameObjectAI(go_transport_the_thundercaller);
|
||||
RegisterGameObjectAI(go_transport_the_purple_princess);
|
||||
}
|
||||
@@ -32,6 +32,7 @@ void AddSC_action_ip_logger(); // location: scripts\World\action_ip_logger.cpp
|
||||
void AddSC_player_scripts();
|
||||
void AddSC_npc_stave_of_ancients();
|
||||
void AddSC_server_mail();
|
||||
void AddSC_transport_zeppelins();
|
||||
|
||||
// The name of this function should match:
|
||||
// void Add${NameOfDirectory}Scripts()
|
||||
@@ -53,4 +54,5 @@ void AddWorldScripts()
|
||||
AddSC_player_scripts();
|
||||
AddSC_npc_stave_of_ancients();
|
||||
AddSC_server_mail();
|
||||
AddSC_transport_zeppelins();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user