fix(Core/GameObjectScript): Environmental damage of burning game objects (#2432)

This commit is contained in:
Stoabrogga
2019-12-07 08:19:24 +01:00
committed by GitHub
parent 412905843a
commit 183a15a661
3 changed files with 119 additions and 0 deletions

View File

@@ -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;

View File

@@ -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:

View File

@@ -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<Player*> players;
acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f);
acore::PlayerListSearcher<acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(go, players, checker);
go->VisitNearbyWorldObject(0.3f, searcher);
if (players.size() > 0)
{
std::list<Player*>::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<Player*> players;
acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f);
acore::PlayerListSearcher<acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(go, players, checker);
go->VisitNearbyWorldObject(0.3f, searcher);
if (players.size() > 0)
{
std::list<Player*>::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();