* Some changes to scarlet ghouls script, still needs proper core support to work 100% correctly.

* Add item script for the harvester's gift, to prevent creating more than 5 scarlet ghouls, I know this can be done in a better way, but, I couldn't figure out how.
* Add new function Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry) used to correctly count how many scarlet ghouls a player has, can probably be handy in other situations.

--HG--
branch : trunk
This commit is contained in:
Chaz Brown
2009-10-09 13:49:41 -04:00
parent a6329701e2
commit ad9eb5e89d
4 changed files with 119 additions and 14 deletions
@@ -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);
}
}
}
}
ScriptedAI::UpdateAI(diff);
}
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();
}
}
}
}
};
CreatureAI* GetAI_npc_scarlet_ghoul(Creature* pCreature)
@@ -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();
}
+12
View File
@@ -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();)
+1
View File
@@ -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);