Code:
/*######
## Quest 12027: Mr. Floppy's Perilous Adventure
######*/
enum eFloppy
{
NPC_MRFLOPPY = 26589,
NPC_HUNGRY_WORG = 26586,
NPC_RAVENOUS_WORG = 26590, //RWORG
NPC_EMILY = 26588,
QUEST_PERILOUS_ADVENTURE = 12027,
SPELL_MRFLOPPY = 47184, //vehicle aura
SAY_WORGHAGGRO1 = -1800001, //Um... I think one of those wolves is back...
SAY_WORGHAGGRO2 = -1800002, //He's going for Mr. Floppy!
SAY_WORGRAGGRO3 = -1800003, //Oh, no! Look, it's another wolf, and it's a biiiiiig one!
SAY_WORGRAGGRO4 = -1800004, //He's gonna eat Mr. Floppy! You gotta help Mr. Floppy! You just gotta!
SAY_RANDOMAGGRO = -1800005, //There's a big meanie attacking Mr. Floppy! Help!
SAY_VICTORY1 = -1800006, //Let's get out of here before more wolves find us!
SAY_VICTORY2 = -1800007, //Don't go toward the light, Mr. Floppy!
SAY_VICTORY3 = -1800008, //Mr. Floppy, you're ok! Thank you so much for saving Mr. Floppy!
SAY_VICTORY4 = -1800009, //I think I see the camp! We're almost home, Mr. Floppy! Let's go!
TEXT_EMOTE_WP1 = -1800010, //Mr. Floppy revives
TEXT_EMOTE_AGGRO = -1800011, //The Ravenous Worg chomps down on Mr. Floppy
SAY_QUEST_ACCEPT = -1800012, //Are you ready, Mr. Floppy? Stay close to me and watch out for those wolves!
SAY_QUEST_COMPLETE = -1800013 //Thank you for helping me get back to the camp. Go tell Walter that I'm safe now!
};
//emily
class npc_emily : public CreatureScript
{
public:
npc_emily() : CreatureScript("npc_emily") { }
struct npc_emilyAI : public npc_escortAI
{
npc_emilyAI(Creature* pCreature) : npc_escortAI(pCreature) { }
uint32 m_uiChatTimer;
uint64 RWORGGUID;
uint64 MrfloppyGUID;
bool Completed;
void JustSummoned(Creature* pSummoned)
{
if (Creature* Mrfloppy = GetClosestCreatureWithEntry(me, NPC_MRFLOPPY, 50.0f))
pSummoned->AI()->AttackStart(Mrfloppy);
else
pSummoned->AI()->AttackStart(me->getVictim());
}
void WaypointReached(uint32 i)
{
Player* pPlayer = GetPlayerForEscort();
if (!pPlayer)
return;
switch (i)
{
case 9:
if (Creature *Mrfloppy = GetClosestCreatureWithEntry(me, NPC_MRFLOPPY, 100.0f))
MrfloppyGUID = Mrfloppy->GetGUID();
break;
case 10:
if (Unit::GetCreature(*me, MrfloppyGUID))
{
DoScriptText(SAY_WORGHAGGRO1, me);
me->SummonCreature(NPC_HUNGRY_WORG,me->GetPositionX()+5,me->GetPositionY()+2,me->GetPositionZ()+1,3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000);
}
break;
case 11:
if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID))
Mrfloppy->GetMotionMaster()->MoveFollow(me, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
break;
case 17:
if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID))
Mrfloppy->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
DoScriptText(SAY_WORGRAGGRO3, me);
if (Creature *RWORG = me->SummonCreature(NPC_RAVENOUS_WORG,me->GetPositionX()+10,me->GetPositionY()+8,me->GetPositionZ()+2,3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000))
{
RWORG->setFaction(35);
RWORGGUID = RWORG->GetGUID();
}
break;
case 18:
if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID))
{
if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID))
RWORG->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ());
DoCast(Mrfloppy,SPELL_MRFLOPPY);
}
break;
case 19:
if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID))
{
if (Mrfloppy->HasAura(SPELL_MRFLOPPY, 0))
{
if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID))
Mrfloppy->EnterVehicle(RWORG);
}
}
break;
case 20:
if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID))
RWORG->HandleEmoteCommand(34);
break;
case 21:
if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID))
{
if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID))
{
RWORG->Kill(Mrfloppy);
Mrfloppy->ExitVehicle();
RWORG->setFaction(14);
RWORG->GetMotionMaster()->MovePoint(0, RWORG->GetPositionX()+10,RWORG->GetPositionY()+80,RWORG->GetPositionZ());
DoScriptText(SAY_VICTORY2, me);
}
}
break;
case 22:
if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID))
{
if (Mrfloppy->isDead())
{
if (Creature *RWORG = Unit::GetCreature(*me, RWORGGUID))
RWORG->DisappearAndDie();
me->GetMotionMaster()->MovePoint(0, Mrfloppy->GetPositionX(), Mrfloppy->GetPositionY(), Mrfloppy->GetPositionZ());
Mrfloppy->setDeathState(ALIVE);
Mrfloppy->GetMotionMaster()->MoveFollow(me, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
DoScriptText(SAY_VICTORY3, me);
}
}
break;
case 24:
if (pPlayer)
{
Completed = true;
pPlayer->GroupEventHappens(QUEST_PERILOUS_ADVENTURE, me);
DoScriptText(SAY_QUEST_COMPLETE, me, pPlayer);
}
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
break;
case 25:
DoScriptText(SAY_VICTORY4, me);
break;
case 27:
me->DisappearAndDie();
if (Creature *Mrfloppy = Unit::GetCreature(*me, MrfloppyGUID))
Mrfloppy->DisappearAndDie();
break;
}
}
void EnterCombat(Unit* /*Who*/)
{
DoScriptText(SAY_RANDOMAGGRO, me);
}
void Reset()
{
m_uiChatTimer = 4000;
MrfloppyGUID = 0;
RWORGGUID = 0;
}
void UpdateAI(const uint32 uiDiff)
{
npc_escortAI::UpdateAI(uiDiff);
if (HasEscortState(STATE_ESCORT_ESCORTING))
{
if (m_uiChatTimer <= uiDiff)
{
m_uiChatTimer = 12000;
}
else
m_uiChatTimer -= uiDiff;
}
}
};
bool OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* quest)
{
if (quest->GetQuestId() == QUEST_PERILOUS_ADVENTURE)
{
DoScriptText(SAY_QUEST_ACCEPT, pCreature);
if (Creature* Mrfloppy = GetClosestCreatureWithEntry(pCreature, NPC_MRFLOPPY, 180.0f))
{
Mrfloppy->GetMotionMaster()->MoveFollow(pCreature, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
}
if (npc_escortAI* pEscortAI = CAST_AI(npc_emily::npc_emilyAI, (pCreature->AI())))
pEscortAI->Start(true, false, pPlayer->GetGUID());
}
return true;
}
CreatureAI *GetAI(Creature *creature) const
{
return new npc_emilyAI(creature);
}
};
//mrfloppy
class npc_mrfloppy : public CreatureScript
{
public:
npc_mrfloppy() : CreatureScript("npc_mrfloppy") { }
struct npc_mrfloppyAI : public ScriptedAI
{
npc_mrfloppyAI(Creature *c) : ScriptedAI(c) {}
uint64 EmilyGUID;
uint64 RWORGGUID;
uint64 HWORGGUID;
void Reset() {}
void EnterCombat(Unit* Who)
{
if (Creature* Emily = GetClosestCreatureWithEntry(me, NPC_EMILY, 50.0f))
{
switch(Who->GetEntry())
{
case NPC_HUNGRY_WORG:
DoScriptText(SAY_WORGHAGGRO2, Emily);
break;
case NPC_RAVENOUS_WORG:
DoScriptText(SAY_WORGRAGGRO4, Emily);
break;
default:
DoScriptText(SAY_RANDOMAGGRO, Emily);
}
}
}
void EnterEvadeMode() {}
void MoveInLineOfSight(Unit * /*who*/) {}
void UpdateAI(const uint32 /*diff*/)
{
if (!UpdateVictim())
return;
}
};
CreatureAI *GetAI(Creature *creature) const
{
return new npc_mrfloppyAI(creature);
}
};
Well, basically I just don't understand where in that script, that it tells where to walk and stuff? Like, in Lua it'd be something like... "On time'd event, walk to X, Y and Z coords, spawn evil stuff, wait till evil stuff is dead, continue, etc." Only thing is, I see nowhere in the script where it says anything like 'Go to...' in that C++ script. Now, I've been told that Trinity C++ scripting also has a lot to do with the DB, so maybe it is something in there? Well, I've tried following the most obvious connections from the script into the DB, but I couldn't find anything :S So... Could anyone enlighten me please? :>