EverWrath/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp
Francesco Borzì 7bddd69c95
refactor(Scripts/Kalimdor): code cleanup (part 10) (#7065)
* refactor(Scripts/Kalimdor): code cleanup (part 10)

* chore(Core/zone_mulgore): delete file

* chore(Core/zone_teldrassil): remove file

* chore(Core/kalimdor_script_loader): remove mulgore and teldrassil zone

Co-authored-by: Stefano Borzì <stefanoborzi32@gmail.com>
2021-08-06 15:45:17 +02:00

326 lines
9.4 KiB
C++

/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
/* ScriptData
SDName: Dustwallow_Marsh
SD%Complete: 95
SDComment: Quest support: 11180, 558, 11126, 11142, 11174, Vendor Nat Pagle
SDCategory: Dustwallow Marsh
EndScriptData */
/* ContentData
npc_lady_jaina_proudmoore
npc_nat_pagle
npc_cassa_crimsonwing - handled by npc_taxi
EndContentData */
#include "Player.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "ScriptMgr.h"
#include "SpellScript.h"
#include "WorldSession.h"
/*######
## npc_lady_jaina_proudmoore
######*/
enum LadyJaina
{
QUEST_JAINAS_AUTOGRAPH = 558,
SPELL_JAINAS_AUTOGRAPH = 23122
};
#define GOSSIP_ITEM_JAINA "I know this is rather silly but i have a young ward who is a bit shy and would like your autograph."
class npc_lady_jaina_proudmoore : public CreatureScript
{
public:
npc_lady_jaina_proudmoore() : CreatureScript("npc_lady_jaina_proudmoore") { }
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
{
ClearGossipMenuFor(player);
if (action == GOSSIP_SENDER_INFO)
{
SendGossipMenuFor(player, 7012, creature->GetGUID());
player->CastSpell(player, SPELL_JAINAS_AUTOGRAPH, false);
}
return true;
}
bool OnGossipHello(Player* player, Creature* creature) override
{
if (creature->IsQuestGiver())
player->PrepareQuestMenu(creature->GetGUID());
if (player->GetQuestStatus(QUEST_JAINAS_AUTOGRAPH) == QUEST_STATUS_INCOMPLETE)
AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ITEM_JAINA, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO);
SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
return true;
}
};
/*######
## npc_nat_pagle
######*/
enum NatPagle
{
QUEST_NATS_MEASURING_TAPE = 8227
};
class npc_nat_pagle : public CreatureScript
{
public:
npc_nat_pagle() : CreatureScript("npc_nat_pagle") { }
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
{
ClearGossipMenuFor(player);
if (action == GOSSIP_ACTION_TRADE)
player->GetSession()->SendListInventory(creature->GetGUID());
return true;
}
bool OnGossipHello(Player* player, Creature* creature) override
{
if (creature->IsQuestGiver())
player->PrepareQuestMenu(creature->GetGUID());
if (creature->IsVendor() && player->GetQuestRewardStatus(QUEST_NATS_MEASURING_TAPE))
{
AddGossipItemFor(player, GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
SendGossipMenuFor(player, 7640, creature->GetGUID());
}
else
SendGossipMenuFor(player, 7638, creature->GetGUID());
return true;
}
};
/*######
## npc_zelfrax
######*/
Position const MovePosition = {-2967.030f, -3872.1799f, 35.620f, 0.0f};
enum Zelfrax
{
SAY_ZELFRAX1 = 0,
SAY_ZELFRAX2 = 1
};
class npc_zelfrax : public CreatureScript
{
public:
npc_zelfrax() : CreatureScript("npc_zelfrax") { }
CreatureAI* GetAI(Creature* creature) const override
{
return new npc_zelfraxAI(creature);
}
struct npc_zelfraxAI : public ScriptedAI
{
npc_zelfraxAI(Creature* creature) : ScriptedAI(creature)
{
MoveToDock();
}
void AttackStart(Unit* who) override
{
if (!who)
return;
if (me->Attack(who, true))
{
me->SetInCombatWith(who);
who->SetInCombatWith(me);
if (IsCombatMovementAllowed())
me->GetMotionMaster()->MoveChase(who);
}
}
void MovementInform(uint32 Type, uint32 /*Id*/) override
{
if (Type != POINT_MOTION_TYPE)
return;
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
SetCombatMovement(true);
if (me->IsInCombat())
if (Unit* unit = me->GetVictim())
me->GetMotionMaster()->MoveChase(unit);
}
void MoveToDock()
{
SetCombatMovement(false);
me->GetMotionMaster()->MovePoint(0, MovePosition);
Talk(SAY_ZELFRAX1);
Talk(SAY_ZELFRAX2);
}
void UpdateAI(uint32 /*Diff*/) override
{
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
};
};
enum SpellScripts
{
SPELL_OOZE_ZAP = 42489,
SPELL_OOZE_ZAP_CHANNEL_END = 42485,
SPELL_OOZE_CHANNEL_CREDIT = 42486,
SPELL_ENERGIZED = 42492,
};
class spell_ooze_zap : public SpellScriptLoader
{
public:
spell_ooze_zap() : SpellScriptLoader("spell_ooze_zap") { }
class spell_ooze_zap_SpellScript : public SpellScript
{
PrepareSpellScript(spell_ooze_zap_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_OOZE_ZAP });
}
SpellCastResult CheckRequirement()
{
if (!GetCaster()->HasAura(GetSpellInfo()->Effects[EFFECT_1].CalcValue()))
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; // This is actually correct
if (!GetExplTargetUnit())
return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (GetHitUnit())
GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_ooze_zap_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
OnCheckCast += SpellCheckCastFn(spell_ooze_zap_SpellScript::CheckRequirement);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_ooze_zap_SpellScript();
}
};
class spell_ooze_zap_channel_end : public SpellScriptLoader
{
public:
spell_ooze_zap_channel_end() : SpellScriptLoader("spell_ooze_zap_channel_end") { }
class spell_ooze_zap_channel_end_SpellScript : public SpellScript
{
PrepareSpellScript(spell_ooze_zap_channel_end_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_OOZE_ZAP_CHANNEL_END });
}
void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (Player* player = GetCaster()->ToPlayer())
player->CastSpell(player, SPELL_OOZE_CHANNEL_CREDIT, true);
Unit::Kill(GetHitUnit(), GetHitUnit());
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_ooze_zap_channel_end_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_ooze_zap_channel_end_SpellScript();
}
};
class spell_energize_aoe : public SpellScriptLoader
{
public:
spell_energize_aoe() : SpellScriptLoader("spell_energize_aoe") { }
class spell_energize_aoe_SpellScript : public SpellScript
{
PrepareSpellScript(spell_energize_aoe_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_ENERGIZED });
}
void FilterTargets(std::list<WorldObject*>& targets)
{
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end();)
{
if ((*itr)->GetTypeId() == TYPEID_PLAYER && (*itr)->ToPlayer()->GetQuestStatus(GetSpellInfo()->Effects[EFFECT_1].CalcValue()) == QUEST_STATUS_INCOMPLETE)
++itr;
else
targets.erase(itr++);
}
targets.push_back(GetCaster());
}
void HandleScript(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_energize_aoe_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_energize_aoe_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_energize_aoe_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENTRY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_energize_aoe_SpellScript();
}
};
void AddSC_dustwallow_marsh()
{
new npc_lady_jaina_proudmoore();
new npc_nat_pagle();
new npc_zelfrax();
new spell_ooze_zap();
new spell_ooze_zap_channel_end();
new spell_energize_aoe();
}