Skip to content

Commit

Permalink
New script for quest Deeprun Rat Roundup.
Browse files Browse the repository at this point in the history
  • Loading branch information
ratkosrb committed Oct 6, 2024
1 parent 8e31f1e commit 08d3581
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 117 deletions.
46 changes: 46 additions & 0 deletions sql/migrations/20241006212745_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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`='20241006212745');
IF v = 0 THEN
INSERT INTO `migrations` VALUES ('20241006212745');
-- Add your query below.


-- 13017: Source's Entry Is 13017
INSERT INTO `conditions` (`condition_entry`, `type`, `value1`, `value2`, `value3`, `value4`, `flags`) VALUES (13017, 16, 13017, 0, 0, 0, 0);

-- Define targets for Monty Bashes Rats (DND).
REPLACE INTO `spell_script_target` (`entry`, `type`, `targetEntry`, `conditionId`, `inverseEffectMask`, `build_min`, `build_max`) VALUES (21052, 1, 13017, 0, 0, 0, 5875);

-- Correct rat respawn time.
UPDATE `creature` SET `spawntimesecsmin`=5, `spawntimesecsmax`=5 WHERE `id`=13016;

-- Events list for Deeprun Rat
DELETE FROM `creature_ai_events` WHERE `creature_id`=13016;
INSERT INTO `creature_ai_events` (`id`, `creature_id`, `condition_id`, `event_type`, `event_inverse_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action1_script`, `action2_script`, `action3_script`, `comment`) VALUES
(1301601, 13016, 0, 8, 0, 100, 1, 21050, -1, 60000, 60000, 1301601, 0, 0, 'Deeprun Rat - Follow Player on Hit by Rat Catcher\'s Flute Dummy Spell'),
(1301602, 13016, 13017, 21, 0, 100, 0, 0, 0, 0, 0, 1301602, 0, 0, 'Deeprun Rat - Despawn on Reached Home while Enthralled'),
(1301603, 13016, 0, 8, 0, 100, 1, 21052, -1, 60000, 60000, 1301602, 0, 0, 'Deeprun Rat - Despawn on Hit By Spell Monty Bashes Rats (DND)');
DELETE FROM `creature_ai_scripts` WHERE `id`=1301601;
INSERT INTO `creature_ai_scripts` (`id`, `delay`, `priority`, `command`, `datalong`, `datalong2`, `datalong3`, `datalong4`, `target_param1`, `target_param2`, `target_type`, `data_flags`, `dataint`, `dataint2`, `dataint3`, `dataint4`, `x`, `y`, `z`, `o`, `condition_id`, `comments`) VALUES
(1301601, 0, 0, 15, 21051, 2, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Deeprun Rat - Cast Spell Melodious Rapture Visual (DND)'),
(1301601, 0, 1, 27, 13017, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Deeprun Rat - Update Entry to Enthralled Deeprun Rat'),
(1301601, 0, 2, 8, 13017, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Deeprun Rat - Kill Credit for Enthralled Deeprun Rat'),
(1301601, 0, 3, 20, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, -1, 0, 'Deeprun Rat - Follow Player'),
(1301601, 0, 4, 18, 600000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Deeprun Rat - Despawn in 10 minutes');
DELETE FROM `creature_ai_scripts` WHERE `id`=1301602;
INSERT INTO `creature_ai_scripts` (`id`, `delay`, `priority`, `command`, `datalong`, `datalong2`, `datalong3`, `datalong4`, `target_param1`, `target_param2`, `target_type`, `data_flags`, `dataint`, `dataint2`, `dataint3`, `dataint4`, `x`, `y`, `z`, `o`, `condition_id`, `comments`) VALUES
(1301602, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Deeprun Rat - Despawn');
UPDATE `creature_template` SET `ai_name`='EventAI', `script_name`='' WHERE `entry`=13016;
UPDATE `quest_template` SET `ReqSpellCast1`=0 WHERE `entry`=6661;


-- End of migration.
END IF;
END??
DELIMITER ;
CALL add_migration();
DROP PROCEDURE IF EXISTS add_migration;
2 changes: 1 addition & 1 deletion src/game/Maps/ScriptCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ bool Map::ScriptCommand_SetMovementType(ScriptInfo const& script, WorldObject* s
break;
case FOLLOW_MOTION_TYPE:
if (pTarget)
pSource->GetMotionMaster()->MoveFollow(pTarget, script.x, script.o);
pSource->GetMotionMaster()->MoveFollow(pTarget, script.x, script.o < 0 ? frand(0, 2 * M_PI_F) : script.o);
break;
case CHARGE_MOTION_TYPE:
if (pTarget)
Expand Down
5 changes: 5 additions & 0 deletions src/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6306,6 +6306,11 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_casterUnit && m_casterUnit->HasAura(18172))
return SPELL_FAILED_ITEM_NOT_READY;
}
else if (m_spellInfo->Id == 21050) // Melodious Rapture
{
if (!m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetEntry() != 13016)
return SPELL_FAILED_BAD_TARGETS;
}
else if (m_spellInfo->IsFitToFamilyMask<CF_WARLOCK_LIFE_TAP>() && m_casterUnit)
{
float cost = m_currentBasePoints[EFFECT_INDEX_0];
Expand Down
15 changes: 15 additions & 0 deletions src/game/Spells/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,10 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
return;
}
case 16739: // Orb of Deception (before patch 1.7)
{
return HandleAuraTransform(apply, Real);
}
case 21051: // Melodious Rapture Visual (DND)
case 21827: // Frostwolf Aura DND
case 21863: // Alterac Ram Aura DND
{
Expand Down Expand Up @@ -6705,6 +6708,18 @@ void Aura::PeriodicDummyTick()
}
return;
}
case 21051: // Melodious Rapture Visual (DND)
{
if (Creature* pRat = target->ToCreature())
{
if (pRat->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE)
{
// lost track of player
pRat->DespawnOrUnsummon(1);
}
}
return;
}
case 21827: // Frostwolf Aura DND
case 21863: // Alterac Ram Aura DND
{
Expand Down
116 changes: 0 additions & 116 deletions src/scripts/world/npcs_special.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,117 +686,6 @@ CreatureAI* GetAI_npc_steam_tonk(Creature* pCreature)
return new npc_steam_tonkAI(pCreature);
}

/*
* Rat of the depths
*/

enum
{
QUEST_CHASSE_AU_RAT = 6661,
SPELL_EXTASE_MELODIEUSE = 21050,
SPELL_EXTASE_MELO_VISU = 21051,
SPELL_MONTY_FRAPPE_RATS = 21052,
NPC_RAT_PROFONDEURS = 13016,
NPC_RAT_ENSORCELE = 13017,
NPC_MONTY = 12997,
};

struct rat_des_profondeursAI : public ScriptedAI
{
rat_des_profondeursAI(Creature* pCreature) : ScriptedAI(pCreature)
{
Reset();
}

ObjectGuid m_FollowingPlayerGuid;
uint32 QuestFinishCheck_Timer;

void Reset() override
{
QuestFinishCheck_Timer = 0;
}

void UpdateAI(uint32 const uiDiff) override
{
if (!m_FollowingPlayerGuid)
return;
Player* pPlayer = m_creature->GetMap()->GetPlayer(m_FollowingPlayerGuid);
if (!pPlayer || !pPlayer->IsInWorld() ||
(pPlayer->GetQuestStatus(QUEST_CHASSE_AU_RAT) != QUEST_STATUS_INCOMPLETE && pPlayer->GetQuestStatus(QUEST_CHASSE_AU_RAT) != QUEST_STATUS_COMPLETE))
{
m_FollowingPlayerGuid.Clear();
m_creature->RemoveAurasDueToSpell(SPELL_EXTASE_MELO_VISU);
m_creature->UpdateEntry(NPC_RAT_PROFONDEURS);
m_creature->DisappearAndDie();
return;
}
// La quete est-elle terminee ?
if (QuestFinishCheck_Timer < uiDiff)
{
Creature* pMonty = m_creature->FindNearestCreature(NPC_MONTY, 20.0f, true);
if (!pMonty || pPlayer->GetQuestStatus(QUEST_CHASSE_AU_RAT) != QUEST_STATUS_COMPLETE)
{
QuestFinishCheck_Timer = 5000;
return;
}
// Quete finie.
pPlayer->GroupEventHappens(QUEST_CHASSE_AU_RAT, m_creature); // Complete la quete
pMonty->CastSpell(m_creature, SPELL_MONTY_FRAPPE_RATS, true); // Monty frappe le rat
// Et on ".die" les autres rats.
std::list<Creature*> pCreaList;
m_creature->GetCreatureListWithEntryInGrid(pCreaList, NPC_RAT_ENSORCELE, 100.0f);
for (const auto& pCreature : pCreaList)
{
if (pCreature->AI()->GetData(0) == m_FollowingPlayerGuid.GetCounter())
pCreature->DisappearAndDie();
}
}
else
QuestFinishCheck_Timer -= uiDiff;
}

void SpellHit(SpellCaster* pCaster, SpellEntry const* pSpellInfo) override
{
// Ce rat est deja pris !
if (!m_FollowingPlayerGuid.IsEmpty())
return;
if (!pSpellInfo || pSpellInfo->Id != SPELL_EXTASE_MELODIEUSE)
return;
Player* pCasterPlayer = pCaster->ToPlayer();
if (!pCasterPlayer)
return;
if (pCasterPlayer->GetQuestStatus(QUEST_CHASSE_AU_RAT) != QUEST_STATUS_INCOMPLETE)
return;
m_FollowingPlayerGuid = pCasterPlayer->GetObjectGuid();
m_creature->UpdateEntry(NPC_RAT_ENSORCELE);
m_creature->CastSpell(m_creature, SPELL_EXTASE_MELO_VISU, true);
m_creature->GetMotionMaster()->Clear(false);
m_creature->GetMotionMaster()->MoveFollow(pCasterPlayer, 1.0f, M_PI_F);
pCasterPlayer->RewardPlayerAndGroupAtCast(m_creature, SPELL_EXTASE_MELODIEUSE);
}

void JustDied(Unit* pKiller) override
{
if (!m_FollowingPlayerGuid)
return;
Player* pQuestPlayer = m_creature->GetMap()->GetPlayer(m_FollowingPlayerGuid);
if (!pQuestPlayer || !pQuestPlayer->IsInWorld())
return;
pQuestPlayer->FailQuest(QUEST_CHASSE_AU_RAT);
m_FollowingPlayerGuid.Clear();
}

uint32 GetData(uint32 dataType) override
{
return dataType == 0 ? m_FollowingPlayerGuid.GetCounter() : 0;
}
};

CreatureAI* GetAI_rat_des_profondeurs(Creature* pCreature)
{
return new rat_des_profondeursAI(pCreature);
}

/*######
## npc_felhound_minion
######*/
Expand Down Expand Up @@ -2447,11 +2336,6 @@ void AddSC_npcs_special()
newscript->GetAI = &GetAI_npc_steam_tonk;
newscript->RegisterSelf();

newscript = new Script;
newscript->Name = "rat_des_profondeurs";
newscript->GetAI = &GetAI_rat_des_profondeurs;
newscript->RegisterSelf();

newscript = new Script;
newscript->Name = "npc_felhound_minion";
newscript->GetAI = &GetAI_npc_felhound_minion;
Expand Down

0 comments on commit 08d3581

Please sign in to comment.