diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp | 83 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/world/item_scripts.cpp | 37 | ||||
-rw-r--r-- | src/game/Unit.cpp | 12 | ||||
-rw-r--r-- | src/game/Unit.h | 1 |
4 files changed, 119 insertions, 14 deletions
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp index a135c3654a4..42a39900bf5 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp @@ -673,6 +673,11 @@ CreatureAI* GetAI_npc_ros_dark_rider(Creature* pCreature) } // correct way: 52312 52314 52555 ... +enum SG +{ + GHOULS = 28845, + GHOSTS = 28846, +}; struct TRINITY_DLL_DECL npc_dkc1_gothikAI : public ScriptedAI { npc_dkc1_gothikAI(Creature *c) : ScriptedAI(c) {} @@ -681,7 +686,7 @@ struct TRINITY_DLL_DECL npc_dkc1_gothikAI : public ScriptedAI { ScriptedAI::MoveInLineOfSight(who); - if (who->GetEntry() == 28845 && me->IsWithinDistInMap(who, 10.0f)) + if (who->GetEntry() == GHOULS && me->IsWithinDistInMap(who, 10.0f)) { if (Unit *owner = who->GetOwner()) { @@ -690,12 +695,15 @@ struct TRINITY_DLL_DECL npc_dkc1_gothikAI : public ScriptedAI if (CAST_PLR(owner)->GetQuestStatus(12698) == QUEST_STATUS_INCOMPLETE) { //CAST_CRE(who)->CastSpell(owner, 52517, true); - CAST_PLR(owner)->KilledMonsterCredit(28845, me->GetGUID()); - CAST_CRE(who)->ForcedDespawn(); - - if (CAST_PLR(owner)->GetQuestStatus(12698) == QUEST_STATUS_COMPLETE) - owner->RemoveAllMinionsByEntry(28845); + CAST_PLR(owner)->KilledMonsterCredit(GHOULS, me->GetGUID()); } + //Todo: Creatures must not be removed, but, must instead + // stand next to Gothik and be commanded into the pit + // and dig into the ground. + CAST_CRE(who)->ForcedDespawn(); + + if (CAST_PLR(owner)->GetQuestStatus(12698) == QUEST_STATUS_COMPLETE) + owner->RemoveAllMinionsByEntry(GHOULS); } } } @@ -711,24 +719,71 @@ struct TRINITY_DLL_DECL npc_scarlet_ghoulAI : public ScriptedAI { npc_scarlet_ghoulAI(Creature *c) : ScriptedAI(c) { - me->SetReactState(REACT_DEFENSIVE); + // Ghouls should display their Birth Animation + // Crawling out of the ground + //m_creature->CastSpell(m_creature,35177,true); + //m_creature->MonsterSay("Mommy?",LANG_UNIVERSAL,0); + m_creature->SetReactState(REACT_DEFENSIVE); + } + + void FindMinions(Unit *owner) + { + std::list<Creature*> MinionList; + owner->GetAllMinionsByEntry(MinionList,GHOULS); + + if (!MinionList.empty()) + { + for(std::list<Creature*>::iterator itr = MinionList.begin(); itr != MinionList.end(); ++itr) + { + if (CAST_CRE(*itr)->GetOwner()->GetGUID() == m_creature->GetOwner()->GetGUID()) + { + if (CAST_CRE(*itr)->isInCombat() && CAST_CRE(*itr)->getAttackerForHelper()) + { + AttackStart(CAST_CRE(*itr)->getAttackerForHelper()); + } + } + } + } } void UpdateAI(const uint32 diff) { - if (Unit *owner = m_creature->GetOwner()) + if (!m_creature->isInCombat()) { - if (owner->GetTypeId() == TYPEID_PLAYER) + if (Unit *owner = m_creature->GetOwner()) { - if (CAST_PLR(owner)->GetQuestStatus(12698) != QUEST_STATUS_INCOMPLETE) + if (owner->GetTypeId() == TYPEID_PLAYER && CAST_PLR(owner)->isInCombat()) { - m_creature->ForcedDespawn(); - m_creature->GetOwner()->RemoveAllMinionsByEntry(28845); + if (CAST_PLR(owner)->getAttackerForHelper() && CAST_PLR(owner)->getAttackerForHelper()->GetEntry() == GHOSTS) + { + AttackStart(CAST_PLR(owner)->getAttackerForHelper()); + } + else + { + FindMinions(owner); + } + } + } + } + + if (!UpdateVictim()) + return; + + //ScriptedAI::UpdateAI(diff); + //Check if we have a current target + if (m_creature->getVictim()->GetEntry() == GHOSTS) + { + if (m_creature->isAttackReady()) + { + //If we are within range melee the target + if (m_creature->IsWithinMeleeRange(m_creature->getVictim())) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); } } } - ScriptedAI::UpdateAI(diff); - } + } }; CreatureAI* GetAI_npc_scarlet_ghoul(Creature* pCreature) diff --git a/src/bindings/scripts/scripts/world/item_scripts.cpp b/src/bindings/scripts/scripts/world/item_scripts.cpp index f103dc86cdc..4568c8bb1c2 100644 --- a/src/bindings/scripts/scripts/world/item_scripts.cpp +++ b/src/bindings/scripts/scripts/world/item_scripts.cpp @@ -206,6 +206,38 @@ bool ItemExpire_item_disgusting_jar(Player* pPlayer, ItemPrototype const * _Item return true; } +/*##### +# item_harvesters_gift +#####*/ +#define GHOULS 28845 +bool ItemUse_item_harvesters_gift(Player* pPlayer, Item* _Item, SpellCastTargets const& targets) +{ + std::list<Creature*> MinionList; + pPlayer->GetAllMinionsByEntry(MinionList,GHOULS); + + if (pPlayer->GetQuestStatus(12698) == QUEST_STATUS_INCOMPLETE) + { + if (!MinionList.empty()) + { + if (MinionList.size() < 5) + { + return false; + } + else + { + //This should be sent to the player as red text. + pPlayer->Say("You have created enough ghouls. Return to Gothik the Harvester at Death's Breach.",LANG_UNIVERSAL); + return true; + } + } + else return false; + } + else + { + return true; + } +} + void AddSC_item_scripts() { Script *newscript; @@ -249,5 +281,10 @@ void AddSC_item_scripts() newscript->Name="item_disgusting_jar"; newscript->pItemExpire = &ItemExpire_item_disgusting_jar; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name="item_harvesters_gift"; + newscript->pItemUse = &ItemUse_item_harvesters_gift; + newscript->RegisterSelf(); } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 09bbeec2979..02ad5bb69cb 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8703,6 +8703,18 @@ void Unit::SetMinion(Minion *minion, bool apply) } } +void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry) +{ + for(Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();) + { + Unit *unit = *itr; + ++itr; + if(unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT + && ((Creature*)unit)->isSummon()) // minion, actually + Minions.push_back((Creature*)unit); + } +} + void Unit::RemoveAllMinionsByEntry(uint32 entry) { for(Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();) diff --git a/src/game/Unit.h b/src/game/Unit.h index 2869a7fe7ab..7729233a757 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1464,6 +1464,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject Player* GetCharmerOrOwnerPlayerOrPlayerItself() const; void SetMinion(Minion *minion, bool apply); + void GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry); void RemoveAllMinionsByEntry(uint32 entry); void SetCharm(Unit* target, bool apply); Unit* GetNextRandomRaidMemberOrPet(float radius); |