Skip to content

Commit

Permalink
Feat: Dragon soul PT 1 (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
seobryn authored Sep 11, 2023
1 parent 56f3c11 commit 14c1990
Show file tree
Hide file tree
Showing 15 changed files with 5,833 additions and 2,248 deletions.
24 changes: 24 additions & 0 deletions data/sql/updates/pending_db_world/rev_1693895228883483000.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
UPDATE `creature_template` SET `ScriptName` = "boss_morchok" WHERE `entry`=55265;
UPDATE `creature_template` SET `ScriptName` = "boss_kohcrom" WHERE `entry`=57773;
UPDATE `creature_template` SET `ScriptName` = "npc_ds_earthen_vortex_vehicle" WHERE `entry`=55723;

DELETE FROM `spell_script_names` WHERE `spell_id` IN (103528, 104573, 103494, 103545, 108572, 110040, 110041, 103176, 103821, 110045, 110046, 110047, 103851, 103785, 108570, 110287, 110288);

INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(103528, 'spell_ds_target_selection'),
(104573, 'spell_ds_target_selection'),
(103494, 'spell_ds_resonating_crystal_periodic'),
(103545, 'spell_ds_resonating_crystal_explosion'),
(108572, 'spell_ds_resonating_crystal_explosion'),
(110040, 'spell_ds_resonating_crystal_explosion'),
(110041, 'spell_ds_resonating_crystal_explosion'),
(103176, 'spell_ds_falling_fragments_periodic'),
(103821, 'spell_ds_earthen_vortex_teleport'),
(110045, 'spell_ds_earthen_vortex_teleport'),
(110046, 'spell_ds_earthen_vortex_teleport'),
(110047, 'spell_ds_earthen_vortex_teleport'),
(103851, 'spell_ds_black_blood_of_the_earth_periodic'),
(103785, 'spell_ds_black_blood_of_the_earth_damage'),
(108570, 'spell_ds_black_blood_of_the_earth_damage'),
(110287, 'spell_ds_black_blood_of_the_earth_damage'),
(110288, 'spell_ds_black_blood_of_the_earth_damage');
1,155 changes: 1,155 additions & 0 deletions data/sql/updates/pending_db_world/rev_1694013706397531000.sql

Large diffs are not rendered by default.

94 changes: 50 additions & 44 deletions src/server/game/AI/CreatureAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
#include "SpellMgr.h"
#include "SpellHistory.h"
#include "TemporarySummon.h"
#include "InstanceScript.h"
#include "Vehicle.h"
#include "World.h"

//Disable CreatureAI when charmed
// Disable CreatureAI when charmed
void CreatureAI::OnCharmed(bool isNew)
{
if (isNew && !me->IsCharmed() && me->LastCharmerGUID)
Expand All @@ -56,26 +57,19 @@ void CreatureAI::OnCharmed(bool isNew)
AISpellInfoType* UnitAI::AISpellInfo;
AISpellInfoType* GetAISpellInfo(uint32 i) { return &UnitAI::AISpellInfo[i]; }

CreatureAI::CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), _negateBoundary(false), _isEngaged(false), _moveInLOSLocked(false)
{
}
CreatureAI::CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), _negateBoundary(false), _isEngaged(false), _moveInLOSLocked(false) {}

CreatureAI::~CreatureAI()
{
}
CreatureAI::~CreatureAI() {}

void CreatureAI::Talk(uint8 id, WorldObject const* whisperTarget /*= nullptr*/)
{
sCreatureTextMgr->SendChat(me, id, whisperTarget);
}
void CreatureAI::Talk(uint8 id, WorldObject const* whisperTarget /*= nullptr*/) { sCreatureTextMgr->SendChat(me, id, whisperTarget); }

void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/)
{
if (!creature)
creature = me;

Map* map = creature->GetMap();
if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated
if (!map->IsDungeon()) // use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated
{
LOG_ERROR("misc", "DoZoneInCombat call for map that isn't an instance (creature entry = %d)", creature->GetTypeId() == TYPEID_UNIT ? creature->ToCreature()->GetEntry() : 0);
return;
Expand Down Expand Up @@ -164,31 +158,31 @@ static bool ShouldFollowOnSpawn(SummonPropertiesEntry const* properties)

switch (properties->Control)
{
case SUMMON_CATEGORY_PET:
case SUMMON_CATEGORY_PET:
return true;
case SUMMON_CATEGORY_WILD:
case SUMMON_CATEGORY_ALLY:
case SUMMON_CATEGORY_UNK:
if (properties->Flags & 512)
return true;
case SUMMON_CATEGORY_WILD:
case SUMMON_CATEGORY_ALLY:
case SUMMON_CATEGORY_UNK:
if (properties->Flags & 512)
return true;

// Guides. They have their own movement
if (properties->Flags & SUMMON_PROP_FLAG_UNK14)
return false;
// Guides. They have their own movement
if (properties->Flags & SUMMON_PROP_FLAG_UNK14)
return false;

switch (SummonTitle(properties->Title))
{
case SummonTitle::Pet:
case SummonTitle::Guardian:
case SummonTitle::Runeblade:
case SummonTitle::Minion:
case SummonTitle::Companion:
return true;
default:
return false;
}
switch (SummonTitle(properties->Title))
{
case SummonTitle::Pet:
case SummonTitle::Guardian:
case SummonTitle::Runeblade:
case SummonTitle::Minion:
case SummonTitle::Companion:
return true;
default:
return false;
}
default:
return false;
}
}
void CreatureAI::JustAppeared()
Expand Down Expand Up @@ -353,22 +347,24 @@ int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) con
float spawnZ = startPosition.GetPositionZ() + BOUNDARY_VISUALIZE_SPAWN_HEIGHT;

bool boundsWarning = false;
Q.push({ 0,0 });
Q.push({0, 0});
while (!Q.empty())
{
coordinate front = Q.front();
bool hasOutOfBoundsNeighbor = false;
for (coordinate off : std::initializer_list<coordinate>{{1,0}, {0,1}, {-1,0}, {0,-1}})
for (coordinate off : std::initializer_list<coordinate>{{1, 0}, {0, 1}, {-1, 0}, {0, -1}})
{
coordinate next(front.first + off.first, front.second + off.second);
if (next.first > BOUNDARY_VISUALIZE_FAILSAFE_LIMIT || next.first < -BOUNDARY_VISUALIZE_FAILSAFE_LIMIT || next.second > BOUNDARY_VISUALIZE_FAILSAFE_LIMIT || next.second < -BOUNDARY_VISUALIZE_FAILSAFE_LIMIT)
if (next.first > BOUNDARY_VISUALIZE_FAILSAFE_LIMIT || next.first < -BOUNDARY_VISUALIZE_FAILSAFE_LIMIT || next.second > BOUNDARY_VISUALIZE_FAILSAFE_LIMIT ||
next.second < -BOUNDARY_VISUALIZE_FAILSAFE_LIMIT)
{
boundsWarning = true;
continue;
}
if (alreadyChecked.find(next) == alreadyChecked.end()) // never check a coordinate twice
{
Position nextPos(startPosition.GetPositionX() + next.first*BOUNDARY_VISUALIZE_STEP_SIZE, startPosition.GetPositionY() + next.second*BOUNDARY_VISUALIZE_STEP_SIZE, startPosition.GetPositionZ());
Position nextPos(
startPosition.GetPositionX() + next.first * BOUNDARY_VISUALIZE_STEP_SIZE, startPosition.GetPositionY() + next.second * BOUNDARY_VISUALIZE_STEP_SIZE, startPosition.GetPositionZ());
if (CheckBoundary(&nextPos))
Q.push(next);
else
Expand All @@ -378,12 +374,13 @@ int32 CreatureAI::VisualizeBoundary(uint32 duration, Unit* owner, bool fill) con
}
alreadyChecked.insert(next);
}
else
if (outOfBounds.find(next) != outOfBounds.end())
hasOutOfBoundsNeighbor = true;
else if (outOfBounds.find(next) != outOfBounds.end())
hasOutOfBoundsNeighbor = true;
}
if (fill || hasOutOfBoundsNeighbor)
if (TempSummon* point = owner->SummonCreature(BOUNDARY_VISUALIZE_CREATURE, Position(startPosition.GetPositionX() + front.first*BOUNDARY_VISUALIZE_STEP_SIZE, startPosition.GetPositionY() + front.second*BOUNDARY_VISUALIZE_STEP_SIZE, spawnZ), TEMPSUMMON_TIMED_DESPAWN, duration * IN_MILLISECONDS))
if (TempSummon* point = owner->SummonCreature(BOUNDARY_VISUALIZE_CREATURE,
Position(startPosition.GetPositionX() + front.first * BOUNDARY_VISUALIZE_STEP_SIZE, startPosition.GetPositionY() + front.second * BOUNDARY_VISUALIZE_STEP_SIZE, spawnZ),
TEMPSUMMON_TIMED_DESPAWN, duration * IN_MILLISECONDS))
{
point->SetObjectScale(BOUNDARY_VISUALIZE_CREATURE_SCALE);
point->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
Expand Down Expand Up @@ -434,10 +431,7 @@ void CreatureAI::SetBoundary(CreatureBoundary const* boundary, bool negateBounda
me->DoImmediateBoundaryCheck();
}

Creature* CreatureAI::DoSummon(uint32 entry, Position const& pos, uint32 despawnTime, TempSummonType summonType)
{
return me->SummonCreature(entry, pos, summonType, despawnTime);
}
Creature* CreatureAI::DoSummon(uint32 entry, Position const& pos, uint32 despawnTime, TempSummonType summonType) { return me->SummonCreature(entry, pos, summonType, despawnTime); }

Creature* CreatureAI::DoSummon(uint32 entry, WorldObject* obj, float radius, uint32 despawnTime, TempSummonType summonType)
{
Expand All @@ -451,3 +445,15 @@ Creature* CreatureAI::DoSummonFlyer(uint32 entry, WorldObject* obj, float flight
pos.m_positionZ += flightZ;
return me->SummonCreature(entry, pos, summonType, despawnTime);
}

void CreatureAI::AddEncounterFrame()
{
if (InstanceScript* instance = me->GetInstanceScript())
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
}

void CreatureAI::RemoveEncounterFrame()
{
if (InstanceScript* instance = me->GetInstanceScript())
instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me);
}
Loading

0 comments on commit 14c1990

Please sign in to comment.