--HG--
branch : trunk
This commit is contained in:
maximius
2009-08-10 16:12:23 -07:00
6 changed files with 127 additions and 118 deletions

View File

@@ -96,7 +96,7 @@ UPDATE `creature_template` SET `ScriptName`='npc_snake_trap_serpents' WHERE `ent
UPDATE `creature_template` SET `ScriptName`='npc_unworthy_initiate' WHERE `entry` IN (29519,29520,29565,29566,29567);
UPDATE `creature_template` SET `ScriptName`='npc_unworthy_initiate_anchor' WHERE `entry`=29521;
UPDATE `creature_template` SET `ScriptName`='npc_kingdom_of_dalaran_quests' WHERE `entry` IN (29169,23729,26673,27158,29158,29161,26471,29155,29159,29160,29162);
UPDATE `creature_template` SET `ScriptName`='npc_taxi' WHERE `entry` IN (17435, 23413, 18725, 19401, 19409, 20235, 25059, 25236, 20903, 20162, 29154, 23415, 27575, 26443, 26949, 23816);
UPDATE `creature_template` SET `ScriptName`='npc_taxi' WHERE `entry` IN (17435, 23413, 18725, 19401, 19409, 20235, 25059, 25236, 20903, 20162, 29154, 23415, 27575, 26443, 26949, 23816, 23704);
UPDATE `creature_template` SET `ScriptName`='npc_death_knight_initiate' WHERE `entry`=28406;
UPDATE `creature_template` SET `ScriptName`='npc_salanar_the_horseman' WHERE `entry` IN (28653, 28788);
UPDATE `creature_template` SET `ScriptName`='npc_dark_rider_of_acherus' WHERE `entry` =28654;
@@ -985,6 +985,7 @@ UPDATE `creature_template` SET `ScriptName`='mob_rotting_forest_rager' WHERE `en
UPDATE `creature_template` SET `ScriptName`='npc_floon' WHERE `entry`=18588;
UPDATE `creature_template` SET `ScriptName`='npc_isla_starmane' WHERE `entry`=18760;
UPDATE `creature_template` SET `ScriptName`='mob_unkor_the_ruthless' WHERE `entry`=18262;
UPDATE `creature_template` SET `ScriptName`='npc_slim' WHERE `entry`=19679;
/* THOUSAND NEEDLES */
UPDATE `creature_template` SET `ScriptName`='npc_swiftmountain' WHERE `entry`=10427;

View File

@@ -0,0 +1,2 @@
UPDATE `creature_template` SET `ScriptName`='npc_slim' WHERE `entry`=19679;
UPDATE `creature_template` SET `ScriptName`='npc_taxi' WHERE `entry` = 23704;

View File

@@ -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 (IsBeingEscorted && !m_creature->getVictim() && m_uiWPWaitTimer && !m_bIsReturning)
{
if (WaitTimer <= diff)
{
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);
//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);
//TODO: add option to set instant respawn? Then use db respawn value as default
m_creature->Respawn();
return;
}
else
{
debug_log("TSCR: EscortAI reached end of waypoints with Despawn off");
return;
}
}
//Continue with waypoints
if( !IsOnHold )
{
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");
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;
}
}
//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->Respawn();
m_creature->GetMotionMaster()->Clear(true);
//Restore original NpcFlags
m_creature->SetUInt32Value(UNIT_NPC_FLAGS, m_uiNpcFlags);
IsBeingEscorted = false;
WaitTimer = 0;
return;
}
else
{
debug_log("TSCR: EscortAI reached end of waypoints with Despawn off");
IsBeingEscorted = false;
WaitTimer = 0;
return;
}
}
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;
m_bIsActiveAttacker = bIsActiveAttacker;
m_bCanDefendSelf = bCanDefendSelf;
m_bIsRunning = bRun;
PlayerGUID = uiPlayerGUID;
//store original NpcFlags
m_uiNpcFlags = m_creature->GetUInt32Value(UNIT_NPC_FLAGS);
//disable npcflags
m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
//remove them if any
if (m_uiNpcFlags)
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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();
}