Merge [SD2]

r1356 Move HasFollowState() to public and move related Add/RemoveFollowState() to private (not intended that script can alter state directly)
r1357 Add faint and revive for npc_ringo

--HG--
branch : trunk
This commit is contained in:
Kudlaty
2009-08-20 22:37:19 +02:00
parent f7bc620f4f
commit 2ea8cbb4f1
2 changed files with 64 additions and 5 deletions

View File

@@ -43,16 +43,17 @@ class TRINITY_DLL_DECL FollowerAI : public ScriptedAI
void SetFollowPaused(bool bPaused); //if special event require follow mode to hold/resume during the follow
protected:
bool HasFollowState(uint32 uiFollowState) { return (m_uiFollowState & uiFollowState); }
void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; }
void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; }
protected:
void SetFollowComplete(bool bWithEndEvent = false);
Player* GetLeaderForFollower();
private:
void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; }
void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; }
uint64 m_uiLeaderGUID;
uint32 m_uiUpdateFollowTimer;
uint32 m_uiFollowState;

View File

@@ -168,11 +168,11 @@ enum
FACTION_ESCORTEE = 113
};
//Script not fully complete. Need more development of followerAI to accomplish misc tasks.
struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
{
npc_ringoAI(Creature* pCreature) : FollowerAI(pCreature) { }
uint32 m_uiFaintTimer;
uint32 m_uiEndEventProgress;
uint32 m_uiEndEventTimer;
@@ -180,6 +180,7 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
void Reset()
{
m_uiFaintTimer = urand(30000, 60000);
m_uiEndEventProgress = 0;
m_uiEndEventTimer = 1000;
pSpraggle = NULL;
@@ -205,6 +206,49 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
}
}
void SpellHit(Unit* pCaster, const SpellEntry* pSpell)
{
if (HasFollowState(STATE_FOLLOW_INPROGRESS | STATE_FOLLOW_PAUSED) && pSpell->Id == SPELL_REVIVE_RINGO)
ClearFaint();
}
void SetFaint()
{
if (!HasFollowState(STATE_FOLLOW_POSTEVENT))
{
SetFollowPaused(true);
switch(rand()%4)
{
case 0: DoScriptText(SAY_FAINT_1, m_creature); break;
case 1: DoScriptText(SAY_FAINT_2, m_creature); break;
case 2: DoScriptText(SAY_FAINT_3, m_creature); break;
case 3: DoScriptText(SAY_FAINT_4, m_creature); break;
}
}
//what does actually happen here? Emote? Aura?
m_creature->SetStandState(UNIT_STAND_STATE_SLEEP);
}
void ClearFaint()
{
m_creature->SetStandState(UNIT_STAND_STATE_STAND);
if (HasFollowState(STATE_FOLLOW_POSTEVENT))
return;
switch(rand()%4)
{
case 0: DoScriptText(SAY_WAKE_1, m_creature); break;
case 1: DoScriptText(SAY_WAKE_2, m_creature); break;
case 2: DoScriptText(SAY_WAKE_3, m_creature); break;
case 3: DoScriptText(SAY_WAKE_4, m_creature); break;
}
SetFollowPaused(false);
}
void UpdateFollowerAI(const uint32 uiDiff)
{
if (!UpdateVictim())
@@ -215,7 +259,6 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
{
if (!pSpraggle || !pSpraggle->isAlive())
{
m_uiEndEventTimer = 1000;
SetFollowComplete();
return;
}
@@ -236,10 +279,12 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
break;
case 4:
DoScriptText(EMOTE_RIN_END_4, m_creature);
SetFaint();
m_uiEndEventTimer = 9000;
break;
case 5:
DoScriptText(EMOTE_RIN_END_5, m_creature);
ClearFaint();
m_uiEndEventTimer = 1000;
break;
case 6:
@@ -264,6 +309,19 @@ struct TRINITY_DLL_DECL npc_ringoAI : public FollowerAI
else
m_uiEndEventTimer -= uiDiff;
}
else if (HasFollowState(STATE_FOLLOW_INPROGRESS))
{
if (!HasFollowState(STATE_FOLLOW_PAUSED))
{
if (m_uiFaintTimer < uiDiff)
{
SetFaint();
m_uiFaintTimer = urand(60000, 120000);
}
else
m_uiFaintTimer -= uiDiff;
}
}
return;
}