aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/scripts/npc/npc_escortAI.cpp157
-rw-r--r--src/bindings/scripts/scripts/npc/npc_escortAI.h31
-rw-r--r--src/bindings/scripts/scripts/npc/npc_taxi.cpp8
-rw-r--r--src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp36
4 files changed, 119 insertions, 113 deletions
diff --git a/src/bindings/scripts/scripts/npc/npc_escortAI.cpp b/src/bindings/scripts/scripts/npc/npc_escortAI.cpp
index 5e9dd7e3141..d8a6cdf1c21 100644
--- a/src/bindings/scripts/scripts/npc/npc_escortAI.cpp
+++ b/src/bindings/scripts/scripts/npc/npc_escortAI.cpp
@@ -20,22 +20,22 @@ void npc_escortAI::AttackStart(Unit *who)
if (!who)
return;
- if (IsBeingEscorted && !Defend)
+ if (IsBeingEscorted && !m_bCanDefendSelf)
return;
if(m_creature->Attack(who, true) )
{
- if(CombatMovement)
- {
+ if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
m_creature->GetMotionMaster()->MovementExpired();
+
+ if(CombatMovement)
m_creature->GetMotionMaster()->MoveChase(who);
- }
}
}
void npc_escortAI::MoveInLineOfSight(Unit *who)
{
- if (IsBeingEscorted && !Attack)
+ if (IsBeingEscorted && !m_bIsActiveAttacker)
return;
ScriptedAI::MoveInLineOfSight(who);
@@ -47,8 +47,7 @@ void npc_escortAI::JustRespawned()
IsOnHold = false;
CombatMovement = true;
- //Re-Enable questgiver flag
- m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
+ m_uiWPWaitTimer = 0;
Reset();
}
@@ -69,7 +68,7 @@ void npc_escortAI::EnterEvadeMode()
if (IsBeingEscorted)
{
- Returning = true;
+ m_bIsReturning = true;
ReturnToLastPoint();
debug_log("TSCR: EscortAI has left combat and is now returning to last point");
}
@@ -82,75 +81,45 @@ void npc_escortAI::EnterEvadeMode()
void npc_escortAI::UpdateAI(const uint32 diff)
{
//Waypoint Updating
- if (IsBeingEscorted && !m_creature->isInCombat() && WaitTimer && !Returning)
- {
- if (WaitTimer <= diff)
+ if (IsBeingEscorted && !m_creature->getVictim() && m_uiWPWaitTimer && !m_bIsReturning)
{
- if (ReconnectWP)
+ if (m_uiWPWaitTimer <= diff)
{
- //Correct movement speed
- if (bIsRunning && m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
- m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
- else if (!bIsRunning && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
- m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
-
- //Continue with waypoints
- if( !IsOnHold )
+ //End of the line, Despawn self then immediatly respawn
+ if (CurrentWP == WaypointList.end())
{
- if (CurrentWP != WaypointList.end())
- {
- m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
- debug_log("TSCR: EscortAI Reconnect WP is: %u, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
-
- WaitTimer = 0;
- ReconnectWP = false;
- return;
- }
- else
- debug_log("TSCR: EscortAI Reconnected to end of WP list");
- }
- }
+ if(DespawnAtEnd)
+ {
+ debug_log("TSCR: EscortAI reached end of waypoints");
- //End of the line, Despawn self then immediatly respawn
- if (CurrentWP == WaypointList.end())
- {
- if(DespawnAtEnd)
- {
- debug_log("TSCR: EscortAI reached end of waypoints");
+ m_creature->setDeathState(JUST_DIED);
- m_creature->setDeathState(JUST_DIED);
- m_creature->Respawn();
- m_creature->GetMotionMaster()->Clear(true);
+ //TODO: add option to set instant respawn? Then use db respawn value as default
+ m_creature->Respawn();
- //Restore original NpcFlags
- m_creature->SetUInt32Value(UNIT_NPC_FLAGS, m_uiNpcFlags);
+ return;
+ }
+ else
+ {
+ debug_log("TSCR: EscortAI reached end of waypoints with Despawn off");
- IsBeingEscorted = false;
- WaitTimer = 0;
- return;
+ return;
+ }
}
- else
+
+ if( !IsOnHold )
{
- debug_log("TSCR: EscortAI reached end of waypoints with Despawn off");
- IsBeingEscorted = false;
- WaitTimer = 0;
- return;
+ m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
+ debug_log("TSCR: EscortAI Next WP is: %u, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
+ m_uiWPWaitTimer = 0;
}
- }
-
- if( !IsOnHold )
- {
- m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
- debug_log("TSCR: EscortAI Next WP is: %u, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
- WaitTimer = 0;
- }
- }else WaitTimer -= diff;
+ }else m_uiWPWaitTimer -= diff;
}
//Check if player or any member of his group is within range
- if (IsBeingEscorted && PlayerGUID && !m_creature->getVictim() && !m_creature->IsInEvadeMode())
+ if (IsBeingEscorted && PlayerGUID && !m_creature->getVictim() && !m_bIsReturning)
{
- if (PlayerTimer < diff)
+ if (m_uiPlayerCheckTimer < diff)
{
bool bIsMaxRangeExceeded = true;
@@ -178,22 +147,19 @@ void npc_escortAI::UpdateAI(const uint32 diff)
if (DespawnAtFar && bIsMaxRangeExceeded)
{
- JustDied(m_creature);
- IsBeingEscorted = false;
-
debug_log("TSCR: EscortAI Evaded back to spawn point because player/group was to far away or not found");
+ JustDied(m_creature);
m_creature->setDeathState(JUST_DIED);
//TODO: add option to set instant respawn? Then use db respawn value as default
m_creature->Respawn();
- //Restore original NpcFlags
- m_creature->SetUInt32Value(UNIT_NPC_FLAGS, m_creature->GetCreatureInfo()->npcflag);
+ return;
}
- PlayerTimer = 1000;
- }else PlayerTimer -= diff;
+ m_uiPlayerCheckTimer = 1000;
+ }else m_uiPlayerCheckTimer -= diff;
}
if(CanMelee && UpdateVictim())
@@ -205,15 +171,20 @@ void npc_escortAI::MovementInform(uint32 type, uint32 id)
if (type != POINT_MOTION_TYPE || !IsBeingEscorted)
return;
- //Original position reached, continue waypoint movement
+ //Combat start position reached, continue waypoint movement
if (id == WP_LAST_POINT)
{
debug_log("TSCR: EscortAI has returned to original position before combat");
- ReconnectWP = true;
- Returning = false;
- if(!WaitTimer)
- WaitTimer = 1;
+ if (m_bIsRunning && m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
+ m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+ else if (!m_bIsRunning && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
+ m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
+
+ m_bIsReturning = false;
+
+ if (!m_uiWPWaitTimer)
+ m_uiWPWaitTimer = 1;
}
else
{
@@ -229,7 +200,7 @@ void npc_escortAI::MovementInform(uint32 type, uint32 id)
//Call WP function
WaypointReached(CurrentWP->id);
- WaitTimer = CurrentWP->WaitTimeMs + 1;
+ m_uiWPWaitTimer = CurrentWP->WaitTimeMs + 1;
++CurrentWP;
}
@@ -281,24 +252,24 @@ void npc_escortAI::SetRun(bool bRun)
{
if (bRun)
{
- if (!bIsRunning)
+ if (!m_bIsRunning)
m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
else
debug_log("TSCR: EscortAI attempt to set run mode, but is already running.");
}
else
{
- if (bIsRunning)
+ if (m_bIsRunning)
m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
else
debug_log("TSCR: EscortAI attempt to set walk mode, but is already walking.");
}
- bIsRunning = bRun;
+ m_bIsRunning = bRun;
}
-void npc_escortAI::Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID)
+void npc_escortAI::Start(bool bIsActiveAttacker, bool bCanDefendSelf, bool bRun, uint64 uiPlayerGUID)
{
- if (m_creature->isInCombat())
+ if (m_creature->getVictim())
{
debug_log("TSCR ERROR: EscortAI attempt to Start while in combat");
return;
@@ -323,24 +294,20 @@ void npc_escortAI::Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID)
debug_log("TSCR: EscortAI start with WAYPOINT_MOTION_TYPE, changed to MoveIdle.");
}
- Attack = bAttack;
- Defend = bDefend;
- bIsRunning = bRun;
- PlayerGUID = pGUID;
-
- //store original NpcFlags
- m_uiNpcFlags = m_creature->GetUInt32Value(UNIT_NPC_FLAGS);
+ m_bIsActiveAttacker = bIsActiveAttacker;
+ m_bCanDefendSelf = bCanDefendSelf;
+ m_bIsRunning = bRun;
+ PlayerGUID = uiPlayerGUID;
- //remove them if any
- if (m_uiNpcFlags)
- m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
+ //disable npcflags
+ m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
- debug_log("TSCR: EscortAI started with %d waypoints. Attack = %d, Defend = %d, Run = %d, PlayerGUID = %d", WaypointList.size(), Attack, Defend, bIsRunning, PlayerGUID);
+ debug_log("TSCR: EscortAI started with %d waypoints. ActiveAttacker = %d, Defend = %d, Run = %d, PlayerGUID = %d", WaypointList.size(), m_bIsActiveAttacker, m_bCanDefendSelf, m_bIsRunning, PlayerGUID);
CurrentWP = WaypointList.begin();
//Set initial speed
- if (bIsRunning)
+ if (m_bIsRunning)
m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
else
m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
@@ -349,8 +316,4 @@ void npc_escortAI::Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID)
m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
debug_log("TSCR: EscortAI Next WP is: %d, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
IsBeingEscorted = true;
- ReconnectWP = false;
- Returning = false;
- IsOnHold = false;
- CombatMovement = true;
}
diff --git a/src/bindings/scripts/scripts/npc/npc_escortAI.h b/src/bindings/scripts/scripts/npc/npc_escortAI.h
index fc848665f3b..efe9ef5f922 100644
--- a/src/bindings/scripts/scripts/npc/npc_escortAI.h
+++ b/src/bindings/scripts/scripts/npc/npc_escortAI.h
@@ -30,14 +30,15 @@ struct Escort_Waypoint
struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
{
public:
+ explicit npc_escortAI(Creature* pCreature) : ScriptedAI(pCreature),
+ IsBeingEscorted(false), IsOnHold(false), PlayerGUID(0), MaxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE), CanMelee(true), m_uiPlayerCheckTimer(1000), m_uiWPWaitTimer(0),
+ m_bIsReturning(false), m_bIsActiveAttacker(true), m_bCanDefendSelf(true), m_bIsRunning(false), DespawnAtEnd(true), DespawnAtFar(true) {}
+ ~npc_escortAI() {}
// Pure Virtual Functions
virtual void WaypointReached(uint32) = 0;
// CreatureAI functions
- npc_escortAI(Creature *c) : ScriptedAI(c), IsBeingEscorted(false), PlayerTimer(1000), MaxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE), CanMelee(true), DespawnAtEnd(true), DespawnAtFar(true)
- {}
-
void AttackStart(Unit* who);
void MoveInLineOfSight(Unit* who);
@@ -57,7 +58,7 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
void FillPointMovementListForCreature();
- void Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID = 0);
+ void Start(bool bIsActiveAttacker = true, bool bCanDefendSelf = true, bool bRun = false, uint64 uiPlayerGUID = 0);
void SetRun(bool bRun = true);
void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
@@ -68,11 +69,11 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
void SetCanMelee(bool usemelee) { CanMelee = usemelee; }
void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; }
void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; }
- bool GetAttack() { return Attack; }//used in EnterEvadeMode override
+ bool GetAttack() { return m_bIsActiveAttacker; }//used in EnterEvadeMode override
bool GetIsBeingEscorted() { return IsBeingEscorted; }//used in EnterEvadeMode override
- void SetReturning(bool returning) { Returning = returning; }//used in EnterEvadeMode override
- void SetCanAttack(bool attack) { Attack = attack; }
- void SetCanDefend(bool defend) { Defend = defend; }
+ void SetReturning(bool returning) { m_bIsReturning = returning; }//used in EnterEvadeMode override
+ void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; }
+ void SetCanDefend(bool defend) { m_bCanDefendSelf = defend; }
uint64 GetEventStarterGUID() { return PlayerGUID; }
// EscortAI variables
@@ -82,19 +83,17 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
bool IsOnHold;
private:
- uint32 WaitTimer;
- uint32 PlayerTimer;
- uint32 m_uiNpcFlags;
+ uint32 m_uiWPWaitTimer;
+ uint32 m_uiPlayerCheckTimer;
float MaxPlayerDistance;
std::list<Escort_Waypoint> WaypointList;
std::list<Escort_Waypoint>::iterator CurrentWP;
- bool Attack;
- bool Defend;
- bool Returning;
- bool ReconnectWP;
- bool bIsRunning;
+ bool m_bIsActiveAttacker; //possible obsolete, and should be determined with db only (civilian)
+ bool m_bCanDefendSelf; //rarely used, is true in 99%
+ bool m_bIsReturning; //in use when creature leave combat, and are returning to combat start position
+ bool m_bIsRunning; //all creatures are walking by default (has flag MOVEMENTFLAG_WALK)
bool CanMelee;
bool DespawnAtEnd;
bool DespawnAtFar;
diff --git a/src/bindings/scripts/scripts/npc/npc_taxi.cpp b/src/bindings/scripts/scripts/npc/npc_taxi.cpp
index 0ba1e456215..f38f756d394 100644
--- a/src/bindings/scripts/scripts/npc/npc_taxi.cpp
+++ b/src/bindings/scripts/scripts/npc/npc_taxi.cpp
@@ -123,6 +123,10 @@ bool GossipHello_npc_taxi(Player *player, Creature *_Creature)
if (player->GetQuestStatus(11170) == QUEST_STATUS_INCOMPLETE)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "I need to commandeer a riding bat for special assignment for us.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 24);
break;
+ case 23704: // Dustwallow Marsh - Cassa Crimsonwing
+ if (player->GetQuestStatus(11142) == QUEST_STATUS_INCOMPLETE)
+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT,"<Ride the gryphons to Survey Alcaz Island>",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+25);
+ break;
}
player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID());
@@ -237,6 +241,10 @@ bool GossipSelect_npc_taxi(Player *player, Creature *_Creature, uint32 sender, u
player->CLOSE_GOSSIP_MENU();
player->ActivateTaxiPathTo(738);
break;
+ case GOSSIP_ACTION_INFO_DEF + 25:
+ player->CLOSE_GOSSIP_MENU();
+ player->CastSpell(player,42295,true);
+ break;
}
return true;
diff --git a/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp b/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp
index 75bc9d3045e..26cefa35289 100644
--- a/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp
+++ b/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp
@@ -28,6 +28,7 @@ mob_rotting_forest_rager
mob_netherweb_victim
npc_floon
npc_isla_starmane
+npc_slim
EndContentData */
#include "precompiled.h"
@@ -582,6 +583,36 @@ bool GossipSelect_go_skull_pile(Player *player, GameObject* _GO, uint32 sender,
return true;
}
+/*######
+## npc_slim
+######*/
+
+enum
+{
+ FACTION_CONSORTIUM = 933
+};
+
+bool GossipHello_npc_slim(Player* pPlayer, Creature* pCreature)
+{
+ if (pCreature->isVendor() && pPlayer->GetReputationRank(FACTION_CONSORTIUM) >= REP_FRIENDLY)
+ {
+ pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
+ pPlayer->SEND_GOSSIP_MENU(9896, pCreature->GetGUID());
+ }
+ else
+ pPlayer->SEND_GOSSIP_MENU(9895, pCreature->GetGUID());
+
+ return true;
+}
+
+bool GossipSelect_npc_slim(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
+{
+ if (uiAction == GOSSIP_ACTION_TRADE)
+ pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
+
+ return true;
+}
+
void AddSC_terokkar_forest()
{
Script *newscript;
@@ -630,5 +661,10 @@ void AddSC_terokkar_forest()
newscript->GetAI = &GetAI_npc_skywingAI;
newscript->RegisterSelf();
+ newscript = new Script;
+ newscript->Name = "npc_slim";
+ newscript->pGossipHello = &GossipHello_npc_slim;
+ newscript->pGossipSelect = &GossipSelect_npc_slim;
+ newscript->RegisterSelf();
}