Skip to content

Commit

Permalink
Rewrite script for quest 'The Tome of Divinity'
Browse files Browse the repository at this point in the history
  • Loading branch information
schell244 committed Oct 23, 2024
1 parent 13c4399 commit 5360a37
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 114 deletions.
21 changes: 21 additions & 0 deletions sql/migrations/20230603091752_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
DROP PROCEDURE IF EXISTS add_migration;
delimiter ??
CREATE PROCEDURE `add_migration`()
BEGIN
DECLARE v INT DEFAULT 1;
SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20230603091752');
IF v=0 THEN
INSERT INTO `migrations` VALUES ('20230603091752');
-- Add your query below.

-- remove script_text
DELETE FROM `script_texts` WHERE `entry`= -1000187;
-- assign new script
UPDATE `creature_template` SET `script_name`='npc_tome_of_divinity' WHERE `entry` IN (6172, 6177);

-- End of migration.
END IF;
END??
delimiter ;
CALL add_migration();
DROP PROCEDURE IF EXISTS add_migration;
1 change: 0 additions & 1 deletion src/scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ set (SCRIPTS_SRCS
eastern_kingdoms/burning_steppes/molten_core/boss_sulfuron_harbinger.cpp
eastern_kingdoms/burning_steppes/molten_core/instance_molten_core.cpp
eastern_kingdoms/burning_steppes/molten_core/molten_core.cpp
eastern_kingdoms/dun_morogh/dun_morogh.cpp
eastern_kingdoms/dun_morogh/gnomeregan/boss_thermaplugg.cpp
eastern_kingdoms/dun_morogh/gnomeregan/gnomeregan.cpp
eastern_kingdoms/dun_morogh/gnomeregan/instance_gnomeregan.cpp
Expand Down
2 changes: 0 additions & 2 deletions src/scripts/ScriptLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ void AddSC_boss_omen();
void AddSC_arathi_highlands();
void AddSC_blasted_lands();
void AddSC_burning_steppes();
void AddSC_dun_morogh();
void AddSC_eastern_plaguelands();
void AddSC_elwynn_forest();
void AddSC_hillsbrad_foothills();
Expand Down Expand Up @@ -400,7 +399,6 @@ void AddScripts()
AddSC_arathi_highlands();
AddSC_blasted_lands();
AddSC_burning_steppes();
AddSC_dun_morogh();
AddSC_eastern_plaguelands();
AddSC_elwynn_forest();
AddSC_hillsbrad_foothills();
Expand Down
70 changes: 0 additions & 70 deletions src/scripts/eastern_kingdoms/dun_morogh/dun_morogh.cpp

This file was deleted.

141 changes: 100 additions & 41 deletions src/scripts/eastern_kingdoms/elwynn_forest/elwynn_forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,80 +14,139 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/* ScriptData
SDName: Elwynn_Forest
SD%Complete: 50
SDComment: Quest support: 1786
SDCategory: Elwynn Forest
EndScriptData */

/* ContentData
npc_henze_faulk
EndContentData */

#include "scriptPCH.h"

/*######
## npc_henze_faulk
######*/
// Script used by two npcs:
// https://www.wowhead.com/classic/npc=6172/henze-faulk
// https://www.wowhead.com/classic/npc=6177/narm-faulk

#define SAY_HEAL -1000187
static constexpr uint32 SAY_HEAL = 2283;
static constexpr uint32 SPELL_SYMBOL_OF_LIFE = 8593;

struct npc_henze_faulkAI : public ScriptedAI
enum State
{
uint32 lifeTimer;
bool spellHit;
STATE_RESET = 0,
STATE_JUST_REVIVED = 1,
STATE_DO_EMOTE = 2
};

npc_henze_faulkAI(Creature* pCreature) : ScriptedAI(pCreature)
struct tome_of_divinityAI : public ScriptedAI
{
explicit tome_of_divinityAI(Creature* pCreature) : ScriptedAI(pCreature)
{
Reset();
}

uint8 m_uiState{};
uint32 m_uiResetTimer{};
uint32 m_uiTalkTimer{};
uint32 m_uiEmoteTimer{};
ObjectGuid m_playerGuid{};
bool m_bSpellHit{};

void Reset() override
{
lifeTimer = 120000;
m_uiState = STATE_RESET;

m_uiResetTimer = 120000;
m_uiTalkTimer = 1000;
m_uiEmoteTimer = 1000;

m_playerGuid.Clear();

m_bSpellHit = false;

m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
m_creature->SetStandState(UNIT_STAND_STATE_DEAD); // lay down
spellHit = false;
m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
m_creature->SetDeathState(JUST_DIED);
}

void MoveInLineOfSight(Unit *who) override { }

void UpdateAI(uint32 const diff) override
void UpdateAI(uint32 const uiDiff) override
{
if (m_creature->IsStandingUp())
{
if (lifeTimer < diff)
m_creature->AI()->EnterEvadeMode();
else
lifeTimer -= diff;
switch (m_uiState)
{
case STATE_JUST_REVIVED:
{
if (m_uiTalkTimer < uiDiff)
{
if (Player* pPlayer = sObjectAccessor.FindPlayer(m_playerGuid))
{
m_creature->SetFacingToObject(pPlayer);
DoScriptText(SAY_HEAL, m_creature, pPlayer);
}

m_playerGuid.Clear();

m_uiState = STATE_DO_EMOTE;
}
else
{
m_uiTalkTimer -= uiDiff;
}

break;
}
case STATE_DO_EMOTE:
{
if (m_uiEmoteTimer < uiDiff)
{
m_creature->HandleEmote(EMOTE_ONESHOT_BOW);
m_uiState = STATE_RESET;
}
else
{
m_uiEmoteTimer -= uiDiff;
}

break;
}
case STATE_RESET: // no break
default:
{
if (m_uiResetTimer < uiDiff)
{
Reset();
}
else
{
m_uiResetTimer -= uiDiff;
}

break;
}
}
}
}

void SpellHit(SpellCaster* pCaster, SpellEntry const* pSpellEntry) override
{
if (pSpellEntry->Id == 8593 && !spellHit)
if (pSpellEntry->Id == SPELL_SYMBOL_OF_LIFE && !m_bSpellHit)
{
m_creature->SetStandState(UNIT_STAND_STATE_STAND);
m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
//m_creature->RemoveAllAuras();
DoScriptText(SAY_HEAL, m_creature, pCaster->ToUnit());
spellHit = true;

m_uiState = STATE_JUST_REVIVED;

if (Player* pPlayer = pCaster->ToPlayer())
{
m_playerGuid = pPlayer->GetObjectGuid();
m_bSpellHit = true;
}
}
}

};
CreatureAI* GetAI_npc_henze_faulk(Creature* pCreature)

CreatureAI* GetAI_tome_of_divinity(Creature* pCreature)
{
return new npc_henze_faulkAI(pCreature);
return new tome_of_divinityAI(pCreature);
}

void AddSC_elwynn_forest()
{
Script* newscript;

newscript = new Script;
newscript->Name = "npc_henze_faulk";
newscript->GetAI = &GetAI_npc_henze_faulk;
Script* newscript = new Script;
newscript->Name = "npc_tome_of_divinity";
newscript->GetAI = &GetAI_tome_of_divinity;
newscript->RegisterSelf();
}

0 comments on commit 5360a37

Please sign in to comment.