Skip to content

Commit bc68d01

Browse files
authored
Scripts/Gundrak: Drakkari Colossus cleanup (TrinityCore#31275)
Drakkari Colossus implementation cleanup
1 parent 676c139 commit bc68d01

7 files changed

Lines changed: 224 additions & 152 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--
2+
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_drakkari_colossus_surge';
3+
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
4+
(54801, 'spell_drakkari_colossus_surge');
5+
6+
DELETE FROM `spawn_group` WHERE (`groupId` = '33') and (`spawnType` = '0') and (`spawnId` = '127071');
7+
DELETE FROM `spawn_group` WHERE (`groupId` = '33') and (`spawnType` = '0') and (`spawnId` = '127072');
8+
DELETE FROM `spawn_group` WHERE (`groupId` = '33') and (`spawnType` = '0') and (`spawnId` = '127073');
9+
DELETE FROM `spawn_group` WHERE (`groupId` = '33') and (`spawnType` = '0') and (`spawnId` = '127074');
10+
DELETE FROM `spawn_group` WHERE (`groupId` = '33') and (`spawnType` = '0') and (`spawnId` = '127075');
11+
12+
DELETE FROM `spawn_group_template` WHERE `groupId`=328;
13+
INSERT INTO `spawn_group_template` (`groupId`,`groupName`,`groupFlags`) VALUES
14+
(328,'Gundrak - Drakkari Colossus',4);
15+
16+
DELETE FROM `spawn_group` WHERE `groupId`=328;
17+
INSERT INTO `spawn_group` (`groupId`,`spawnType`,`spawnId`) VALUES
18+
(328,0,127071),
19+
(328,0,127072),
20+
(328,0,127073),
21+
(328,0,127074),
22+
(328,0,127075);
23+
24+
DELETE FROM `instance_spawn_groups` WHERE `spawnGroupId` =328;
25+
INSERT INTO `instance_spawn_groups` (`instanceMapId`,`bossStateId`,`bossStates`,`spawnGroupId`,`flags`) VALUES
26+
(604,1,23,328,2);

‎src/server/game/AI/ScriptedAI/ScriptedCreature.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "Cell.h"
2121
#include "CellImpl.h"
2222
#include "Containers.h"
23+
#include "CommonHelpers.h"
2324
#include "DBCStores.h"
2425
#include "GridNotifiers.h"
2526
#include "GridNotifiersImpl.h"
@@ -489,6 +490,13 @@ void ScriptedAI::SetCombatMovement(bool allowMovement)
489490
_isCombatMovementAllowed = allowMovement;
490491
}
491492

493+
void ScriptedAI::SetAggressiveStateAfter(Milliseconds timer, Creature* who/* = nullptr*/, bool startCombat/* = true*/, Creature* summoner/* = nullptr*/)
494+
{
495+
if (!who)
496+
who = me;
497+
who->m_Events.AddEvent(new Trinity::Helpers::Events::SetAggresiveStateEvent(who, startCombat, summoner->GetGUID()), who->m_Events.CalculateTime(timer));
498+
}
499+
492500
// BossAI - for instanced bosses
493501
BossAI::BossAI(Creature* creature, uint32 bossId) : ScriptedAI(creature), instance(creature->GetInstanceScript()), summons(creature), _bossId(bossId)
494502
{

‎src/server/game/AI/ScriptedAI/ScriptedCreature.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ struct TC_GAME_API ScriptedAI : public CreatureAI
246246
// return true for 25 man or 25 man heroic mode
247247
bool Is25ManRaid() const { return _difficulty & RAID_DIFFICULTY_MASK_25MAN; }
248248

249+
void SetAggressiveStateAfter(Milliseconds timer, Creature* who = nullptr, bool startCombat = true, Creature* summoner = nullptr);
250+
249251
template <class T>
250252
inline T const& DUNGEON_MODE(T const& normal5, T const& heroic10) const
251253
{

‎src/server/game/Miscellaneous/CommonHelpers.cpp‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717

1818
#include "CommonHelpers.h"
1919
#include "Common.h"
20+
#include "Creature.h"
21+
#include "CreatureAI.h"
2022
#include "Item.h"
2123
#include "ItemTemplate.h"
24+
#include "ObjectAccessor.h"
2225
#include "Player.h"
2326
#include "SharedDefines.h"
27+
#include "UnitAI.h"
2428

2529
enum PlayerSpecializationIconicSpellIds
2630
{
@@ -322,3 +326,26 @@ bool Trinity::Helpers::Entity::IsPlayerRangedAttacker(Player const* who)
322326
return (Trinity::Helpers::Entity::GetPlayerSpecialization(who) == SPEC_DRUID_BALANCE);
323327
}
324328
}
329+
330+
Trinity::Helpers::Events::SetAggresiveStateEvent::SetAggresiveStateEvent(Creature* owner, bool startCombat/* = true*/, ObjectGuid summonerGUID/* = ObjectGuid::Empty*/) : _owner(owner), _startCombat(startCombat), _summonerGUID(summonerGUID)
331+
{
332+
}
333+
334+
bool Trinity::Helpers::Events::SetAggresiveStateEvent::Execute(uint64 /*time*/, uint32 /*diff*/)
335+
{
336+
_owner->SetReactState(REACT_AGGRESSIVE);
337+
if (_startCombat)
338+
{
339+
if (Unit* currentVictim = _owner->SelectVictim())
340+
{
341+
if (_owner->IsAIEnabled())
342+
_owner->AI()->AttackStart(currentVictim);
343+
}
344+
else if (!_summonerGUID.IsEmpty())
345+
if (Creature* summoner = ObjectAccessor::GetCreature(*_owner, _summonerGUID))
346+
if (summoner->IsEngaged() && summoner->IsAIEnabled() && _owner->IsAIEnabled())
347+
if (Unit* target = summoner->AI()->SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
348+
_owner->AI()->AttackStart(target);
349+
}
350+
return true;
351+
}

‎src/server/game/Miscellaneous/CommonHelpers.h‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
#ifndef TRINITY_COMMONHELPERS_H
1919
#define TRINITY_COMMONHELPERS_H
2020

21+
#include "EventProcessor.h"
2122
#include "Define.h"
23+
#include "ObjectGuid.h"
2224

25+
class Creature;
2326
class Player;
2427

2528
namespace Trinity
@@ -33,6 +36,21 @@ namespace Trinity
3336
TC_GAME_API bool IsPlayerHealer(Player const* who);
3437
bool IsPlayerRangedAttacker(Player const* who);
3538
}
39+
namespace Events
40+
{
41+
class SetAggresiveStateEvent : public BasicEvent
42+
{
43+
public:
44+
SetAggresiveStateEvent(Creature* owner, bool startCombat = true, ObjectGuid summonerGUID = ObjectGuid::Empty);
45+
46+
bool Execute(uint64 /*time*/, uint32 /*diff*/) override;
47+
48+
private:
49+
Creature* _owner;
50+
bool const _startCombat;
51+
ObjectGuid const _summonerGUID;
52+
};
53+
}
3654
}
3755
}
3856

0 commit comments

Comments
 (0)