diff --git a/data/sql/updates/pending_db_world/rev_1573682333945401103.sql b/data/sql/updates/pending_db_world/rev_1573682333945401103.sql new file mode 100644 index 000000000..c4fa1329e --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1573682333945401103.sql @@ -0,0 +1,5 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1573682333945401103'); + +DELETE FROM `gameobject` WHERE `id` IN (2061,2066); +UPDATE `gameobject_template` SET `Data2` = 0, `ScriptName` = 'go_flames' WHERE `type` = 8 AND `Data2` = 2061; +UPDATE `gameobject_template` SET `Data2` = 0, `ScriptName` = 'go_heat' WHERE `type` = 8 AND `Data2` = 2066; diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 0e8319313..2fcd80856 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -1248,6 +1248,23 @@ namespace acore bool _disallowGM; }; + class AnyPlayerExactPositionInGameObjectRangeCheck + { + public: + AnyPlayerExactPositionInGameObjectRangeCheck(GameObject const* go, float range) : _go(go), _range(range) {} + bool operator()(Player* u) + { + if (!_go->IsInRange(u->GetPositionX(), u->GetPositionY(), u->GetPositionZ(), _range)) + return false; + + return true; + } + + private: + GameObject const* _go; + float _range; + }; + class NearestPlayerInObjectRangeCheck { public: diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 3cdbae441..865cf1b07 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -37,6 +37,8 @@ EndContentData */ #include "Spell.h" #include "Player.h" #include "WorldSession.h" +#include "GridNotifiersImpl.h" +#include "CellImpl.h" // Ours /*###### @@ -312,6 +314,99 @@ public: } }; +enum Flames +{ + SPELL_FLAMES = 7897 +}; + +class go_flames : public GameObjectScript +{ +public: + go_flames() : GameObjectScript("go_flames") { } + + struct go_flamesAI : public GameObjectAI + { + go_flamesAI(GameObject* gameObject) : GameObjectAI(gameObject), + timer { 0 } + { } + + void UpdateAI(uint32 diff) + { + timer += diff; + if (timer > 3000) + { + timer = 0; + std::list players; + acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f); + acore::PlayerListSearcher searcher(go, players, checker); + go->VisitNearbyWorldObject(0.3f, searcher); + + if (players.size() > 0) + { + std::list::iterator itr = players.begin(); + std::advance(itr, urand(0, players.size() - 1)); + if (Creature* trigger = go->SummonTrigger((*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), 0, 2000, true)) + trigger->CastSpell(trigger, SPELL_FLAMES); + } + } + } + + private: + uint32 timer; + }; + + GameObjectAI* GetAI(GameObject* go) const + { + return new go_flamesAI(go); + } +}; + +enum Heat +{ + SPELL_HEAT = 7902 +}; + +class go_heat : public GameObjectScript +{ +public: + go_heat() : GameObjectScript("go_heat") { } + + struct go_heatAI : public GameObjectAI + { + go_heatAI(GameObject* gameObject) : GameObjectAI(gameObject), + timer { 0 } + { } + + void UpdateAI(uint32 diff) + { + timer += diff; + if (timer > 3000) + { + timer = 0; + std::list players; + acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f); + acore::PlayerListSearcher searcher(go, players, checker); + go->VisitNearbyWorldObject(0.3f, searcher); + + if (players.size() > 0) + { + std::list::iterator itr = players.begin(); + std::advance(itr, urand(0, players.size() - 1)); + if (Creature* trigger = go->SummonTrigger((*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), 0, 2000, true)) + trigger->CastSpell(trigger, SPELL_HEAT); + } + } + } + + private: + uint32 timer; + }; + + GameObjectAI* GetAI(GameObject* go) const + { + return new go_heatAI(go); + } +}; // Theirs @@ -1178,6 +1273,8 @@ void AddSC_go_scripts() new go_ethereum_stasis(); new go_resonite_cask(); new go_tadpole_cage(); + new go_flames(); + new go_heat(); // Theirs new go_cat_figurine();