Merge branch 'master' into 4.x
Conflicts: src/server/authserver/Server/AuthSocket.cpp src/server/game/Entities/Object/Object.cpp src/server/game/Entities/Player/Player.cpp src/server/game/Entities/Unit/Unit.cpp src/server/game/Handlers/AuctionHouseHandler.cpp src/server/game/Handlers/CharacterHandler.cpp src/server/game/Handlers/MovementHandler.cpp src/server/game/Miscellaneous/SharedDefines.h src/server/game/Spells/Spell.cpp src/server/game/Spells/SpellEffects.cpp
This commit is contained in:
commit
37b66384f3
491 files changed
+15328
-4368
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
|
||||
# Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
|
||||
# Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
|
||||
@@ -209,7 +209,7 @@ AuthSocket::~AuthSocket(void) {}
|
||||
// Accept the connection and set the s random value for SRP6
|
||||
void AuthSocket::OnAccept(void)
|
||||
{
|
||||
sLog->outBasic("Accepting connection from '%s'", socket().get_remote_address().c_str());
|
||||
sLog->outBasic("'%s:%d' Accepting connection", socket().getRemoteAddress().c_str(), socket().getRemotePort());
|
||||
}
|
||||
|
||||
void AuthSocket::OnClose(void)
|
||||
@@ -247,7 +247,7 @@ void AuthSocket::OnRead()
|
||||
// Report unknown packets in the error log
|
||||
if (i == AUTH_TOTAL_COMMANDS)
|
||||
{
|
||||
sLog->outError("[Auth] got unknown packet from '%s'", socket().get_remote_address().c_str());
|
||||
sLog->outError("[Auth] got unknown packet from '%s'", socket().getRemoteAddress().c_str());
|
||||
socket().shutdown();
|
||||
return;
|
||||
}
|
||||
@@ -349,14 +349,14 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
// Verify that this IP is not in the ip_banned table
|
||||
LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS));
|
||||
|
||||
const std::string& ip_address = socket().get_remote_address();
|
||||
const std::string& ip_address = socket().getRemoteAddress();
|
||||
PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED);
|
||||
stmt->setString(0, ip_address);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
if (result)
|
||||
{
|
||||
pkt << uint8(WOW_FAIL_BANNED);
|
||||
sLog->outBasic("[AuthChallenge] Banned ip %s tried to login!", ip_address.c_str());
|
||||
pkt << (uint8)WOW_FAIL_BANNED;
|
||||
sLog->outBasic("'%s:%d' [AuthChallenge] Banned ip tries to login!",socket().getRemoteAddress().c_str(), socket().getRemotePort());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -402,13 +402,13 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
{
|
||||
if ((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64())
|
||||
{
|
||||
pkt << uint8(WOW_FAIL_BANNED);
|
||||
sLog->outBasic("[AuthChallenge] Banned account %s tried to login!", _login.c_str());
|
||||
pkt << (uint8)WOW_FAIL_BANNED;
|
||||
sLog->outBasic("'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
|
||||
}
|
||||
else
|
||||
{
|
||||
pkt << uint8(WOW_FAIL_SUSPENDED);
|
||||
sLog->outBasic("[AuthChallenge] Temporarily banned account %s tried to login!", _login.c_str());
|
||||
pkt << (uint8)WOW_FAIL_SUSPENDED;
|
||||
sLog->outBasic("'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -483,7 +483,9 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
for (int i = 0; i < 4; ++i)
|
||||
_localizationName[i] = ch->country[4-i-1];
|
||||
|
||||
sLog->outBasic("[AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", _login.c_str (), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName));
|
||||
sLog->outBasic("'%s:%d' [AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", socket().getRemoteAddress().c_str(), socket().getRemotePort(),
|
||||
_login.c_str (), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -584,7 +586,7 @@ bool AuthSocket::_HandleLogonProof()
|
||||
// Check if SRP6 results match (password is correct), else send an error
|
||||
if (!memcmp(M.AsByteArray(), lp.M1, 20))
|
||||
{
|
||||
sLog->outBasic("User '%s' successfully authenticated", _login.c_str());
|
||||
sLog->outBasic("'%s:%d' User '%s' successfully authenticated", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
|
||||
|
||||
// Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
|
||||
// No SQL injection (escaped user name) and IP address as received by socket
|
||||
@@ -592,7 +594,7 @@ bool AuthSocket::_HandleLogonProof()
|
||||
|
||||
PreparedStatement *stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF);
|
||||
stmt->setString(0, K_hex);
|
||||
stmt->setString(1, socket().get_remote_address().c_str());
|
||||
stmt->setString(1, socket().getRemoteAddress().c_str());
|
||||
stmt->setUInt32(2, GetLocaleByName(_localizationName));
|
||||
stmt->setString(3, _login);
|
||||
LoginDatabase.Execute(stmt);
|
||||
@@ -620,7 +622,7 @@ bool AuthSocket::_HandleLogonProof()
|
||||
char data[4] = { AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0 };
|
||||
socket().send(data, sizeof(data));
|
||||
|
||||
sLog->outBasic("[AuthChallenge] account %s tried to login with wrong password!", _login.c_str());
|
||||
sLog->outBasic("'%s:%d' [AuthChallenge] account %s tried to login with invalid password!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
|
||||
|
||||
uint32 MaxWrongPassCount = ConfigMgr::GetIntDefault("WrongPass.MaxCount", 0);
|
||||
if (MaxWrongPassCount > 0)
|
||||
@@ -650,17 +652,18 @@ bool AuthSocket::_HandleLogonProof()
|
||||
stmt->setUInt32(1, WrongPassBanTime);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
sLog->outBasic("[AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
|
||||
_login.c_str(), WrongPassBanTime, failed_logins);
|
||||
sLog->outBasic("'%s:%d' [AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
|
||||
socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str(), WrongPassBanTime, failed_logins);
|
||||
}
|
||||
else
|
||||
{
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_IP_AUTO_BANNED);
|
||||
stmt->setString(0, socket().get_remote_address());
|
||||
stmt->setString(0, socket().getRemoteAddress());
|
||||
stmt->setUInt32(1, WrongPassBanTime);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
sLog->outBasic("[AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times", socket().get_remote_address().c_str(), WrongPassBanTime, _login.c_str(), failed_logins);
|
||||
sLog->outBasic("'%s:%d' [AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times",
|
||||
socket().getRemoteAddress().c_str(), socket().getRemotePort(), socket().getRemoteAddress().c_str(), WrongPassBanTime, _login.c_str(), failed_logins);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -712,7 +715,7 @@ bool AuthSocket::_HandleReconnectChallenge()
|
||||
// Stop if the account is not found
|
||||
if (!result)
|
||||
{
|
||||
sLog->outError("[ERROR] user %s tried to login and we cannot find his session key in the database.", _login.c_str());
|
||||
sLog->outError("'%s:%d' [ERROR] user %s tried to login and we cannot find his session key in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
|
||||
socket().shutdown();
|
||||
return false;
|
||||
}
|
||||
@@ -771,7 +774,7 @@ bool AuthSocket::_HandleReconnectProof()
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog->outError("[ERROR] user %s tried to login, but session invalid.", _login.c_str());
|
||||
sLog->outError("'%s:%d' [ERROR] user %s tried to login, but session is invalid.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
|
||||
socket().shutdown();
|
||||
return false;
|
||||
}
|
||||
@@ -793,7 +796,7 @@ bool AuthSocket::_HandleRealmList()
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
if (!result)
|
||||
{
|
||||
sLog->outError("[ERROR] user %s tried to login and we cannot find him in the database.", _login.c_str());
|
||||
sLog->outError("'%s:%d' [ERROR] user %s tried to login but we cannot find him in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
|
||||
socket().shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ RealmSocket::Session::Session(void) {}
|
||||
|
||||
RealmSocket::Session::~Session(void) { }
|
||||
|
||||
RealmSocket::RealmSocket(void) : input_buffer_(4096), session_(NULL), remote_address_()
|
||||
RealmSocket::RealmSocket(void) : input_buffer_(4096), session_(NULL), _remoteAddress()
|
||||
{
|
||||
reference_counting_policy().value(ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
|
||||
|
||||
@@ -63,7 +63,8 @@ int RealmSocket::open(void * arg)
|
||||
return -1;
|
||||
}
|
||||
|
||||
remote_address_ = addr.get_host_addr();
|
||||
_remoteAddress = addr.get_host_addr();
|
||||
_remotePort = addr.get_port_number();
|
||||
|
||||
// Register with ACE Reactor
|
||||
if (Base::open(arg) == -1)
|
||||
@@ -89,9 +90,14 @@ int RealmSocket::close(int)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const std::string& RealmSocket::get_remote_address(void) const
|
||||
const std::string& RealmSocket::getRemoteAddress(void) const
|
||||
{
|
||||
return remote_address_;
|
||||
return _remoteAddress;
|
||||
}
|
||||
|
||||
const uint16 RealmSocket::getRemotePort(void) const
|
||||
{
|
||||
return _remotePort;
|
||||
}
|
||||
|
||||
size_t RealmSocket::recv_len(void) const
|
||||
|
||||
@@ -52,7 +52,9 @@ public:
|
||||
|
||||
bool send(const char *buf, size_t len);
|
||||
|
||||
const std::string& get_remote_address(void) const;
|
||||
const std::string& getRemoteAddress(void) const;
|
||||
|
||||
const uint16 getRemotePort(void) const;
|
||||
|
||||
virtual int open(void *);
|
||||
|
||||
@@ -70,7 +72,8 @@ private:
|
||||
|
||||
ACE_Message_Block input_buffer_;
|
||||
Session* session_;
|
||||
std::string remote_address_;
|
||||
std::string _remoteAddress;
|
||||
uint16 _remotePort;
|
||||
};
|
||||
|
||||
#endif /* __REALMSOCKET_H__ */
|
||||
@@ -50,6 +50,7 @@ class GameObjectAI
|
||||
virtual void Destroyed(Player* /*player*/, uint32 /*eventId*/) {}
|
||||
virtual void SetData(uint32 /*id*/, uint32 /*value*/) {}
|
||||
virtual void OnGameEvent(bool /*start*/, uint16 /*eventId*/) {}
|
||||
virtual void OnStateChanged(uint32 /*state*/, Unit* /*unit*/) { }
|
||||
};
|
||||
|
||||
class NullGameObjectAI : public GameObjectAI
|
||||
|
||||
@@ -115,8 +115,8 @@ void GuardAI::EnterEvadeMode()
|
||||
me->CombatStop(true);
|
||||
i_state = STATE_NORMAL;
|
||||
|
||||
// Remove TargetedMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
|
||||
// Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
|
||||
me->GetMotionMaster()->MoveTargetedHome();
|
||||
}
|
||||
|
||||
|
||||
@@ -417,10 +417,9 @@ void PetAI::MovementInform(uint32 moveType, uint32 data)
|
||||
me->GetMotionMaster()->Clear();
|
||||
me->GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case TARGETED_MOTION_TYPE:
|
||||
case FOLLOW_MOTION_TYPE:
|
||||
{
|
||||
// If data is owner's GUIDLow then we've reached follow point,
|
||||
// otherwise we're probably chasing a creature
|
||||
@@ -430,11 +429,9 @@ void PetAI::MovementInform(uint32 moveType, uint32 data)
|
||||
me->GetCharmInfo()->SetIsReturning(false);
|
||||
me->GetCharmInfo()->SetIsFollowing(true);
|
||||
me->GetCharmInfo()->SetIsCommandAttack(false);
|
||||
me->AddUnitState(UNIT_STAT_FOLLOW);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
||||
//Melee current victim if flag not set
|
||||
if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM))
|
||||
{
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
|
||||
{
|
||||
m_AttackDistance = 0.0f;
|
||||
m_AttackAngle = 0.0f;
|
||||
@@ -483,7 +483,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
||||
me->GetMotionMaster()->MoveChase(me->getVictim(), m_AttackDistance, m_AttackAngle);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -595,7 +594,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
||||
me->ClearUnitState(UNIT_STAT_MELEE_ATTACKING);
|
||||
me->SendMeleeAttackStop(victim);
|
||||
}
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
|
||||
me->GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
||||
/* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* Thanks to the original authors: ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
|
||||
*
|
||||
@@ -298,7 +298,8 @@ void ScriptedAI::DoModifyThreatPercent(Unit* unit, int32 pct)
|
||||
void ScriptedAI::DoTeleportTo(float x, float y, float z, uint32 time)
|
||||
{
|
||||
me->Relocate(x, y, z);
|
||||
me->SendMonsterMove(x, y, z, time);
|
||||
float speed = me->GetDistance(x, y, z) / ((float)time * 0.001f);
|
||||
me->MonsterMoveWithSpeed(x, y, z, speed);
|
||||
}
|
||||
|
||||
void ScriptedAI::DoTeleportTo(const float position[4])
|
||||
|
||||
@@ -167,7 +167,7 @@ void FollowerAI::EnterEvadeMode()
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: FollowerAI left combat, returning to CombatStartPosition.");
|
||||
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
|
||||
{
|
||||
float fPosX, fPosY, fPosZ;
|
||||
me->GetPosition(fPosX, fPosY, fPosZ);
|
||||
@@ -176,7 +176,7 @@ void FollowerAI::EnterEvadeMode()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
|
||||
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
|
||||
me->GetMotionMaster()->MoveTargetedHome();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
||||
/* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* Thanks to the original authors: ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
|
||||
*
|
||||
|
||||
@@ -46,7 +46,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
|
||||
|
||||
// spawn in run mode
|
||||
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
mRun = true;
|
||||
mRun = false;
|
||||
|
||||
me->GetPosition(&mLastOOCPos);
|
||||
|
||||
@@ -89,7 +89,7 @@ void SmartAI::UpdateDespawn(const uint32 diff)
|
||||
void SmartAI::Reset()
|
||||
{
|
||||
if (!HasEscortState(SMART_ESCORT_ESCORTING))//dont mess up escort movement after combat
|
||||
SetRun(true);
|
||||
SetRun(mRun);
|
||||
GetScript()->OnReset();
|
||||
}
|
||||
|
||||
@@ -433,24 +433,13 @@ void SmartAI::MovementInform(uint32 MovementType, uint32 Data)
|
||||
|
||||
void SmartAI::RemoveAuras()
|
||||
{
|
||||
// Only loop throught the applied auras, because here is where all auras on the current unit are stored
|
||||
Unit::AuraApplicationMap appliedAuras = me->GetAppliedAuras();
|
||||
for (Unit::AuraApplicationMap::iterator iter = appliedAuras.begin(); iter != appliedAuras.end();)
|
||||
for (Unit::AuraApplicationMap::iterator iter = appliedAuras.begin(); iter != appliedAuras.end(); ++iter)
|
||||
{
|
||||
Aura const* aura = iter->second->GetBase();
|
||||
if (!aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE) && !(iter->second->GetTarget() == me && aura->GetCaster() == me))
|
||||
me->_UnapplyAura(iter, AURA_REMOVE_BY_DEFAULT);
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
|
||||
Unit::AuraMap ownedAuras = me->GetOwnedAuras();
|
||||
for (Unit::AuraMap::iterator iter = ownedAuras.begin(); iter != ownedAuras.end();)
|
||||
{
|
||||
Aura* aura = iter->second;
|
||||
if (!aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE))
|
||||
me->RemoveOwnedAura(iter, AURA_REMOVE_BY_DEFAULT);
|
||||
else
|
||||
++iter;
|
||||
if (!aura->GetSpellInfo()->IsPassive() && !aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE) && aura->GetCaster() != me)
|
||||
me->RemoveAurasDueToSpell(aura->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -948,6 +937,11 @@ void SmartGameObjectAI::OnGameEvent(bool start, uint16 eventId)
|
||||
GetScript()->ProcessEventsFor(start ? SMART_EVENT_GAME_EVENT_START : SMART_EVENT_GAME_EVENT_END, NULL, eventId);
|
||||
}
|
||||
|
||||
void SmartGameObjectAI::OnStateChanged(uint32 state, Unit* unit)
|
||||
{
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_GO_STATE_CHANGED, unit, state);
|
||||
}
|
||||
|
||||
class SmartTrigger : public AreaTriggerScript
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -253,6 +253,7 @@ public:
|
||||
void SetData(uint32 id, uint32 value);
|
||||
void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker);
|
||||
void OnGameEvent(bool start, uint16 eventId);
|
||||
void OnStateChanged(uint32 state, Unit* unit);
|
||||
|
||||
protected:
|
||||
GameObject* const go;
|
||||
|
||||
@@ -51,7 +51,6 @@ SmartScript::SmartScript()
|
||||
mTemplate = SMARTAI_TEMPLATE_BASIC;
|
||||
meOrigGUID = 0;
|
||||
goOrigGUID = 0;
|
||||
mResumeActionList = true;
|
||||
mLastInvoker = 0;
|
||||
}
|
||||
|
||||
@@ -78,22 +77,6 @@ void SmartScript::OnReset()
|
||||
|
||||
void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob)
|
||||
{
|
||||
if (e == SMART_EVENT_AGGRO)
|
||||
{
|
||||
if (!mResumeActionList)
|
||||
mTimedActionList.clear();//clear action list if it is not resumable
|
||||
else
|
||||
{
|
||||
for (SmartAIEventList::iterator itr = mTimedActionList.begin(); itr != mTimedActionList.end(); ++itr)
|
||||
{
|
||||
if (itr->enableTimed)
|
||||
{
|
||||
InitTimer((*itr));//re-init the currently enabled timer, so it restarts the timer when resumed
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i)
|
||||
{
|
||||
SMART_EVENT eventType = SMART_EVENT((*i).GetEventType());
|
||||
@@ -101,7 +84,20 @@ void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint3
|
||||
continue;
|
||||
|
||||
if (eventType == e/* && (!(*i).event.event_phase_mask || IsInPhase((*i).event.event_phase_mask)) && !((*i).event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE && (*i).runOnce)*/)
|
||||
ProcessEvent(*i, unit, var0, var1, bvar, spell, gob);
|
||||
{
|
||||
bool meets = true;
|
||||
if (unit)
|
||||
{
|
||||
if (Player* player = unit->ToPlayer())
|
||||
{
|
||||
ConditionList conds = sConditionMgr->GetConditionsForSmartEvent((*i).entryOrGuid, (*i).event_id, (*i).source_type);
|
||||
meets = sConditionMgr->IsPlayerMeetToConditions(player, conds);
|
||||
}
|
||||
}
|
||||
|
||||
if (meets)
|
||||
ProcessEvent(*i, unit, var0, var1, bvar, spell, gob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,15 +115,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (unit)
|
||||
mLastInvoker = unit->GetGUID();
|
||||
|
||||
if (e.link && e.link != e.event_id)
|
||||
{
|
||||
SmartScriptHolder linked = FindLinkedEvent(e.link);
|
||||
if (linked.GetActionType() && linked.GetEventType() == SMART_EVENT_LINK)
|
||||
ProcessEvent(linked, unit, var0, var1, bvar, spell, gob);
|
||||
else
|
||||
sLog->outErrorDb("SmartScript::ProcessAction: Entry %d SourceType %u, Event %u, Link Event %u not found or invalid, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.link);
|
||||
}
|
||||
|
||||
if (Unit* tempInvoker = GetLastInvoker())
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: Invoker: %s (guidlow: %u)", tempInvoker->GetName(), tempInvoker->GetGUIDLow());
|
||||
|
||||
@@ -136,7 +123,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_TALK:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
Creature* talker = me;
|
||||
@@ -274,7 +261,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -317,7 +304,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -336,7 +323,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -357,7 +344,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_SET_REACT_STATE:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
me->SetReactState(ReactStates(e.action.react.state));
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SET_REACT_STATE: Creature guidLow %u set reactstate %u",
|
||||
@@ -368,7 +355,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
uint32 emotes[SMART_ACTION_PARAM_COUNT];
|
||||
emotes[0] = e.action.randomEmote.emote1;
|
||||
@@ -405,7 +392,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_THREAT_ALL_PCT:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
std::list<HostileReference*> const& threatList = me->getThreatManager().getThreatList();
|
||||
for (std::list<HostileReference*>::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
|
||||
@@ -422,11 +409,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_THREAT_SINGLE_PCT:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -445,7 +432,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -463,11 +450,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_SEND_CASTCREATUREORGO:
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -485,11 +472,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_CAST:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -511,11 +498,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
Unit* tempLastInvoker = GetLastInvoker();
|
||||
if (!tempLastInvoker)
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -537,7 +524,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -556,7 +543,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -564,7 +551,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
// Activate
|
||||
(*itr)->ToGameObject()->SetLootState(GO_READY);
|
||||
(*itr)->ToGameObject()->UseDoorOrButton();
|
||||
(*itr)->ToGameObject()->UseDoorOrButton(0, false, unit);
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject %u (entry: %u) activated",
|
||||
(*itr)->GetGUIDLow(), (*itr)->GetEntry());
|
||||
}
|
||||
@@ -577,7 +564,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -596,7 +583,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -615,7 +602,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -634,7 +621,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -652,7 +639,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_AUTO_ATTACK:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
CAST_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack ? true : false);
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: %u bool on = %u",
|
||||
@@ -662,7 +649,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_ALLOW_COMBAT_MOVEMENT:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
bool move = e.action.combatMove.move ? true : false;
|
||||
CAST_AI(SmartAI, me->AI())->SetCombatMove(move);
|
||||
@@ -673,7 +660,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_SET_EVENT_PHASE:
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
return;
|
||||
break;
|
||||
|
||||
SetPhase(e.action.setEventPhase.phase);
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SET_EVENT_PHASE: Creature %u set event phase %u",
|
||||
@@ -683,7 +670,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_INC_EVENT_PHASE:
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
return;
|
||||
break;
|
||||
|
||||
IncPhase(e.action.incEventPhase.inc);
|
||||
DecPhase(e.action.incEventPhase.dec);
|
||||
@@ -694,7 +681,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_EVADE:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
me->AI()->EnterEvadeMode();
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_EVADE: Creature %u EnterEvadeMode", me->GetGUIDLow());
|
||||
@@ -703,7 +690,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_FLEE_FOR_ASSIST:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
me->DoFleeToGetAssistance();
|
||||
if (e.action.flee.withEmote)
|
||||
@@ -724,11 +711,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_CALL_CASTEDCREATUREORGO:
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -747,7 +734,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -765,11 +752,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_FOLLOW:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -788,7 +775,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_RANDOM_PHASE:
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
return;
|
||||
break;
|
||||
|
||||
uint32 phases[SMART_ACTION_PARAM_COUNT];
|
||||
phases[0] = e.action.randomPhase.phase1;
|
||||
@@ -817,7 +804,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_RANDOM_PHASE_RANGE:
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
return;
|
||||
break;
|
||||
|
||||
uint32 phase = urand(e.action.randomPhaseRange.phaseMin, e.action.randomPhaseRange.phaseMax);
|
||||
SetPhase(phase);
|
||||
@@ -837,7 +824,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -866,13 +853,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
obj = unit;
|
||||
|
||||
if (!obj)
|
||||
return;
|
||||
break;
|
||||
|
||||
InstanceScript* instance = obj->GetInstanceScript();
|
||||
if (!instance)
|
||||
{
|
||||
sLog->outErrorDb("SmartScript: Event %u attempt to set instance data without instance script. EntryOrGuid %d", e.GetEventType(), e.entryOrGuid);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
instance->SetData(e.action.setInstanceData.field, e.action.setInstanceData.data);
|
||||
@@ -887,18 +874,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
obj = unit;
|
||||
|
||||
if (!obj)
|
||||
return;
|
||||
break;
|
||||
|
||||
InstanceScript* instance = obj->GetInstanceScript();
|
||||
if (!instance)
|
||||
{
|
||||
sLog->outErrorDb("SmartScript: Event %u attempt to set instance data without instance script. EntryOrGuid %d", e.GetEventType(), e.entryOrGuid);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
instance->SetData64(e.action.setInstanceData64.field, targets->front()->GetGUID());
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_SET_INST_DATA64: Field: %u, data: "UI64FMTD,
|
||||
@@ -910,7 +897,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_UPDATE_TEMPLATE:
|
||||
{
|
||||
if (!me || me->GetEntry() == e.action.updateTemplate.creature)
|
||||
return;
|
||||
break;
|
||||
|
||||
me->UpdateEntry(e.action.updateTemplate.creature, e.action.updateTemplate.team ? HORDE : ALLIANCE);
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_UPDATE_TEMPLATE: Creature %u, Template: %u, Team: %u",
|
||||
@@ -957,7 +944,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_FORCE_DESPAWN:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
CAST_AI(SmartAI, me->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1);//next tick
|
||||
CAST_AI(SmartAI, me->AI())->StartDespawn();
|
||||
@@ -973,7 +960,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1003,7 +990,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_SET_INVINCIBILITY_HP_LEVEL:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
if (e.action.invincHP.percent)
|
||||
mInvinceabilityHpLevel = me->CountPctFromMaxHealth(e.action.invincHP.percent);
|
||||
@@ -1015,7 +1002,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1031,7 +1018,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_MOVE_FORWARD:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
float x, y, z;
|
||||
me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, (float)e.action.moveRandom.distance);
|
||||
@@ -1053,11 +1040,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_ATTACK_START:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1092,7 +1079,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
|
||||
if (e.GetTargetType() != SMART_TARGET_POSITION)
|
||||
return;
|
||||
break;
|
||||
|
||||
if (Creature* summon = GetBaseObject()->SummonCreature(e.action.summonCreature.creature, e.target.x, e.target.y, e.target.z, e.target.o, (TempSummonType)e.action.summonCreature.type, e.action.summonCreature.duration))
|
||||
if (unit && e.action.summonCreature.attackInvoker)
|
||||
@@ -1102,7 +1089,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_SUMMON_GO:
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
return;
|
||||
break;
|
||||
|
||||
float x, y, z, o;
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
@@ -1121,7 +1108,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
|
||||
if (e.GetTargetType() != SMART_TARGET_POSITION)
|
||||
return;
|
||||
break;
|
||||
|
||||
GetBaseObject()->SummonGameObject(e.action.summonGO.entry, e.target.x, e.target.y, e.target.z, e.target.o, 0, 0, 0, 0, e.action.summonGO.despawnTime);
|
||||
break;
|
||||
@@ -1130,7 +1117,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1152,7 +1139,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1169,7 +1156,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1199,7 +1186,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1215,7 +1202,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_SET_FLY:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
CAST_AI(SmartAI, me->AI())->SetFly(e.action.setFly.fly ? true : false);
|
||||
break;
|
||||
@@ -1223,7 +1210,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_SET_RUN:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
CAST_AI(SmartAI, me->AI())->SetRun(e.action.setRun.run ? true : false);
|
||||
break;
|
||||
@@ -1231,7 +1218,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_SET_SWIM:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
CAST_AI(SmartAI, me->AI())->SetSwim(e.action.setSwim.swim ? true : false);
|
||||
break;
|
||||
@@ -1239,7 +1226,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_WP_START:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
bool run = e.action.wpStart.run ? true : false;
|
||||
uint32 entry = e.action.wpStart.pathID;
|
||||
@@ -1258,7 +1245,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_WP_PAUSE:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
uint32 delay = e.action.wpPause.delay;
|
||||
CAST_AI(SmartAI, me->AI())->PausePath(delay, e.GetEventType() == SMART_EVENT_WAYPOINT_REACHED ? false : true);
|
||||
@@ -1267,7 +1254,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_WP_STOP:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
uint32 DespawnTime = e.action.wpStop.despawnTime;
|
||||
uint32 quest = e.action.wpStop.quest;
|
||||
@@ -1278,7 +1265,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_WP_RESUME:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
CAST_AI(SmartAI, me->AI())->ResumePath();
|
||||
break;
|
||||
@@ -1286,15 +1273,15 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_SET_ORIENTATION:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (e.GetTargetType() == SMART_TARGET_SELF)
|
||||
me->SetFacing(me->GetHomePosition().GetOrientation(), NULL);
|
||||
me->SetFacingTo(me->GetHomePosition().GetOrientation());
|
||||
else if (e.GetTargetType() == SMART_TARGET_POSITION)
|
||||
me->SetFacing(e.target.o, NULL);
|
||||
me->SetFacingTo(e.target.o);
|
||||
else if (targets && !targets->empty())
|
||||
me->SetFacing(0, (*targets->begin()));
|
||||
me->SetFacingToObject(*targets->begin());
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
@@ -1303,7 +1290,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1319,7 +1306,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_MOVE_TO_POS:
|
||||
{
|
||||
if (!IsSmart())
|
||||
return;
|
||||
break;
|
||||
|
||||
WorldObject* target = NULL;
|
||||
|
||||
@@ -1331,7 +1318,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
target = targets->front();
|
||||
}
|
||||
@@ -1346,7 +1333,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1363,7 +1350,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsPlayer(*itr))
|
||||
@@ -1376,7 +1363,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1453,7 +1440,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1493,7 +1480,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (e.GetTargetType() == SMART_TARGET_NONE)
|
||||
{
|
||||
sLog->outErrorDb("SmartScript: Entry %d SourceType %u Event %u Action %u is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
@@ -1521,7 +1508,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
@@ -1534,7 +1521,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
@@ -1547,7 +1534,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
@@ -1560,13 +1547,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* casters = GetTargets(CreateEvent(SMART_EVENT_UPDATE_IC, 0, 0, 0, 0, 0, SMART_ACTION_NONE, 0, 0, 0, 0, 0, 0, (SMARTAI_TARGETS)e.action.cast.targetType, e.action.cast.targetParam1, e.action.cast.targetParam2, e.action.cast.targetParam3, 0), unit);
|
||||
if (!casters)
|
||||
return;
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
{
|
||||
delete casters; // casters already validated, delete now
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
for (ObjectList::const_iterator itr = casters->begin(); itr != casters->end(); ++itr)
|
||||
@@ -1610,7 +1597,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (e.GetTargetType() == SMART_TARGET_NONE)
|
||||
{
|
||||
sLog->outErrorDb("SmartScript: Entry %d SourceType %u Event %u Action %u is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
@@ -1640,7 +1627,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (e.GetTargetType() == SMART_TARGET_NONE)
|
||||
{
|
||||
sLog->outErrorDb("SmartScript: Entry %d SourceType %u Event %u Action %u is using TARGET_NONE(0) for Script9 target. Please correct target_type in database.", e.entryOrGuid, e.GetScriptType(), e.GetEventType(), e.GetActionType());
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
@@ -1668,7 +1655,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsPlayer(*itr))
|
||||
@@ -1681,7 +1668,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -1701,7 +1688,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
(*itr)->ToUnit()->SetByteFlag(UNIT_FIELD_BYTES_1, 0, e.action.setunitByte.byte1);
|
||||
@@ -1713,7 +1700,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
@@ -1726,7 +1713,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
@@ -1739,7 +1726,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsGameObject(*itr))
|
||||
@@ -1752,7 +1739,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
@@ -1765,7 +1752,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
@@ -1778,7 +1765,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
@@ -1790,24 +1777,65 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_JUMP_TO_POS:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
break;
|
||||
|
||||
me->GetMotionMaster()->Clear();
|
||||
me->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
|
||||
// TODO: Resume path when reached jump location
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_GO_SET_LOOT_STATE:
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
|
||||
if (!targets)
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsGameObject(*itr))
|
||||
(*itr)->ToGameObject()->SetLootState((LootState)e.action.setGoLootState.state);
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_SEND_TARGET_TO_TARGET:
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
if (IsCreature(*itr))
|
||||
{
|
||||
if (SmartAI* ai = CAST_AI(SmartAI, (*itr)->ToCreature()->AI()))
|
||||
ai->GetScript()->StoreTargetList(GetTargetList(e.action.sendTargetToTarget.id), e.action.sendTargetToTarget.id);
|
||||
else
|
||||
sLog->outErrorDb("SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartAI, skipping");
|
||||
}
|
||||
else if (IsGameObject(*itr))
|
||||
{
|
||||
if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, (*itr)->ToGameObject()->AI()))
|
||||
ai->GetScript()->StoreTargetList(GetTargetList(e.action.sendTargetToTarget.id), e.action.sendTargetToTarget.id);
|
||||
else
|
||||
sLog->outErrorDb("SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartGameObjectAI, skipping");
|
||||
}
|
||||
}
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_SEND_GOSSIP_MENU:
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
return;
|
||||
break;
|
||||
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId %d, gossipNpcTextId %d",
|
||||
e.action.sendGossipMenu.gossipMenuId, e.action.sendGossipMenu.gossipNpcTextId);
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (Player* player = (*itr)->ToPlayer())
|
||||
@@ -1827,6 +1855,15 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
sLog->outErrorDb("SmartScript::ProcessAction: Unhandled Action type %u", e.GetActionType());
|
||||
break;
|
||||
}
|
||||
|
||||
if (e.link && e.link != e.event_id)
|
||||
{
|
||||
SmartScriptHolder linked = FindLinkedEvent(e.link);
|
||||
if (linked.GetActionType() && linked.GetEventType() == SMART_EVENT_LINK)
|
||||
ProcessEvent(linked, unit, var0, var1, bvar, spell, gob);
|
||||
else
|
||||
sLog->outErrorDb("SmartScript::ProcessAction: Entry %d SourceType %u, Event %u, Link Event %u not found or invalid, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.link);
|
||||
}
|
||||
}
|
||||
|
||||
void SmartScript::InstallTemplate(SmartScriptHolder const& e)
|
||||
@@ -2619,6 +2656,13 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
ProcessAction(e, NULL, var0);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_GO_STATE_CHANGED:
|
||||
{
|
||||
if (e.event.goStateChanged.state != var0)
|
||||
return;
|
||||
ProcessAction(e, unit, var0, var1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sLog->outErrorDb("SmartScript::ProcessEvent: Unhandled Event type %u", e.GetEventType());
|
||||
break;
|
||||
@@ -3017,7 +3061,6 @@ void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry)
|
||||
i->event.type = SMART_EVENT_UPDATE_IC;
|
||||
else if (e.action.timedActionList.timerType > 1)
|
||||
i->event.type = SMART_EVENT_UPDATE;
|
||||
mResumeActionList = e.action.timedActionList.dontResume ? false : true;
|
||||
InitTimer((*i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,6 @@ class SmartScript
|
||||
SmartAIEventList mEvents;
|
||||
SmartAIEventList mInstallEvents;
|
||||
SmartAIEventList mTimedActionList;
|
||||
bool mResumeActionList;
|
||||
Creature* me;
|
||||
uint64 meOrigGUID;
|
||||
GameObject* go;
|
||||
|
||||
@@ -282,6 +282,7 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e)
|
||||
case SMART_TARGET_HOSTILE_RANDOM:
|
||||
case SMART_TARGET_HOSTILE_RANDOM_NOT_TOP:
|
||||
case SMART_TARGET_ACTION_INVOKER:
|
||||
case SMART_TARGET_INVOKER_PARTY:
|
||||
case SMART_TARGET_POSITION:
|
||||
case SMART_TARGET_NONE:
|
||||
case SMART_TARGET_ACTION_INVOKER_VEHICLE:
|
||||
@@ -478,6 +479,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_GO_STATE_CHANGED:
|
||||
case SMART_EVENT_TIMED_EVENT_TRIGGERED:
|
||||
case SMART_EVENT_INSTANCE_PLAYER_ENTER:
|
||||
case SMART_EVENT_TRANSPORT_RELOCATE:
|
||||
@@ -800,6 +802,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_ACTION_REMOVE_DYNAMIC_FLAG:
|
||||
case SMART_ACTION_JUMP_TO_POS:
|
||||
case SMART_ACTION_SEND_GOSSIP_MENU:
|
||||
case SMART_ACTION_GO_SET_LOOT_STATE:
|
||||
case SMART_ACTION_SEND_TARGET_TO_TARGET:
|
||||
break;
|
||||
default:
|
||||
sLog->outErrorDb("SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);
|
||||
|
||||
@@ -155,8 +155,9 @@ enum SMART_EVENT
|
||||
SMART_EVENT_IS_BEHIND_TARGET = 67, //1 // cooldownMin, CooldownMax
|
||||
SMART_EVENT_GAME_EVENT_START = 68, //1 // game_event.Entry
|
||||
SMART_EVENT_GAME_EVENT_END = 69, //1 // game_event.Entry
|
||||
SMART_EVENT_GO_STATE_CHANGED = 70, // go state
|
||||
|
||||
SMART_EVENT_END = 70,
|
||||
SMART_EVENT_END = 71,
|
||||
};
|
||||
|
||||
struct SmartEvent
|
||||
@@ -346,6 +347,11 @@ struct SmartEvent
|
||||
uint32 gameEventId;
|
||||
} gameEvent;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 state;
|
||||
} goStateChanged;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 param1;
|
||||
@@ -467,8 +473,10 @@ enum SMART_ACTION
|
||||
SMART_ACTION_REMOVE_DYNAMIC_FLAG = 96, // Flags
|
||||
SMART_ACTION_JUMP_TO_POS = 97, // speedXY, speedZ, targetX, targetY, targetZ
|
||||
SMART_ACTION_SEND_GOSSIP_MENU = 98, // menuId, optionId
|
||||
SMART_ACTION_GO_SET_LOOT_STATE = 99, // state
|
||||
SMART_ACTION_SEND_TARGET_TO_TARGET = 100, // id
|
||||
|
||||
SMART_ACTION_END = 99,
|
||||
SMART_ACTION_END = 101,
|
||||
};
|
||||
|
||||
struct SmartAction
|
||||
@@ -825,7 +833,6 @@ struct SmartAction
|
||||
struct
|
||||
{
|
||||
uint32 id;
|
||||
uint32 dontResume;
|
||||
uint32 timerType;
|
||||
} timedActionList;
|
||||
|
||||
@@ -873,6 +880,16 @@ struct SmartAction
|
||||
uint32 gossipNpcTextId;
|
||||
} sendGossipMenu;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 state;
|
||||
} setGoLootState;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 id;
|
||||
} sendTargetToTarget;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 param1;
|
||||
@@ -1139,6 +1156,7 @@ const uint32 SmartAIEventMask[SMART_EVENT_END][2] =
|
||||
{SMART_EVENT_IS_BEHIND_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_GAME_EVENT_START, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_GAME_EVENT_END, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_GO_STATE_CHANGED, SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -771,6 +771,7 @@ void Battleground::EndBattleground(uint32 winner)
|
||||
}
|
||||
}
|
||||
|
||||
uint8 aliveWinners = GetAlivePlayersCountByTeam(winner);
|
||||
for (BattlegroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
|
||||
{
|
||||
uint32 team = itr->second.Team;
|
||||
@@ -796,6 +797,10 @@ void Battleground::EndBattleground(uint32 winner)
|
||||
if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
|
||||
player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
|
||||
|
||||
// Last standing - Rated 5v5 arena & be solely alive player
|
||||
if (team == winner && isArena() && isRated() && GetArenaType() == ARENA_TYPE_5v5 && aliveWinners == 1 && player->isAlive())
|
||||
player->CastSpell(player, SPELL_THE_LAST_STANDING, true);
|
||||
|
||||
if (!player->isAlive())
|
||||
{
|
||||
player->ResurrectPlayer(1.0f);
|
||||
@@ -898,19 +903,6 @@ uint32 Battleground::GetBonusHonorFromKill(uint32 kills) const
|
||||
return Trinity::Honor::hk_honor_at_level(maxLevel, float(kills));
|
||||
}
|
||||
|
||||
uint32 Battleground::GetBattlemasterEntry() const
|
||||
{
|
||||
switch (GetTypeID(true))
|
||||
{
|
||||
case BATTLEGROUND_AV: return 15972;
|
||||
case BATTLEGROUND_WS: return 14623;
|
||||
case BATTLEGROUND_AB: return 14879;
|
||||
case BATTLEGROUND_EY: return 22516;
|
||||
case BATTLEGROUND_NA: return 20200;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Battleground::BlockMovement(Player* player)
|
||||
{
|
||||
player->SetClientControl(player, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave()
|
||||
|
||||
@@ -98,7 +98,8 @@ enum BattlegroundSpells
|
||||
SPELL_RECENTLY_DROPPED_FLAG = 42792, // Recently Dropped Flag
|
||||
SPELL_AURA_PLAYER_INACTIVE = 43681, // Inactive
|
||||
SPELL_HONORABLE_DEFENDER_25Y = 68652, // +50% honor when standing at a capture point that you control, 25yards radius (added in 3.2)
|
||||
SPELL_HONORABLE_DEFENDER_60Y = 66157 // +50% honor when standing at a capture point that you control, 60yards radius (added in 3.2), probably for 40+ player battlegrounds
|
||||
SPELL_HONORABLE_DEFENDER_60Y = 66157, // +50% honor when standing at a capture point that you control, 60yards radius (added in 3.2), probably for 40+ player battlegrounds
|
||||
SPELL_THE_LAST_STANDING = 26549, // Arena achievement related
|
||||
};
|
||||
|
||||
enum BattlegroundTimeIntervals
|
||||
@@ -360,7 +361,6 @@ class Battleground
|
||||
uint8 GetArenaType() const { return m_ArenaType; }
|
||||
uint8 GetWinner() const { return m_Winner; }
|
||||
uint32 GetScriptId() const { return ScriptId; }
|
||||
uint32 GetBattlemasterEntry() const;
|
||||
uint32 GetBonusHonorFromKill(uint32 kills) const;
|
||||
bool IsRandom() const { return m_IsRandom; }
|
||||
|
||||
|
||||
@@ -202,6 +202,9 @@ void BattlegroundAB::StartingEventOpenDoors()
|
||||
}
|
||||
DoorOpen(BG_AB_OBJECT_GATE_A);
|
||||
DoorOpen(BG_AB_OBJECT_GATE_H);
|
||||
|
||||
// Achievement: Let's Get This Done
|
||||
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, AB_EVENT_START_BATTLE);
|
||||
}
|
||||
|
||||
void BattlegroundAB::AddPlayer(Player* player)
|
||||
|
||||
@@ -181,6 +181,8 @@ enum BG_AB_Objectives
|
||||
#define BG_AB_NotABBGWeekendReputationTicks 200
|
||||
#define BG_AB_ABBGWeekendReputationTicks 150
|
||||
|
||||
#define AB_EVENT_START_BATTLE 9158 // Achievement: Let's Get This Done
|
||||
|
||||
// x, y, z, o
|
||||
const float BG_AB_NodePositions[BG_AB_DYNAMIC_NODES_COUNT][4] = {
|
||||
{1166.785f, 1200.132f, -56.70859f, 0.9075713f}, // stables
|
||||
|
||||
@@ -420,6 +420,9 @@ void BattlegroundAV::StartingEventOpenDoors()
|
||||
|
||||
DoorOpen(BG_AV_OBJECT_DOOR_H);
|
||||
DoorOpen(BG_AV_OBJECT_DOOR_A);
|
||||
|
||||
// Achievement: The Alterac Blitz
|
||||
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, AV_EVENT_START_BATTLE);
|
||||
}
|
||||
|
||||
void BattlegroundAV::AddPlayer(Player* player)
|
||||
|
||||
@@ -50,6 +50,8 @@ class Battleground;
|
||||
#define BG_AV_KILL_SURVIVING_CAPTAIN 2
|
||||
#define BG_AV_REP_SURVIVING_CAPTAIN 125
|
||||
|
||||
#define AV_EVENT_START_BATTLE 9166 // Achievement: The Alterac Blitz
|
||||
|
||||
enum BG_AV_Sounds
|
||||
{ //TODO: get out if there comes a sound when neutral team captures mine
|
||||
|
||||
|
||||
@@ -120,6 +120,9 @@ void BattlegroundEY::StartingEventOpenDoors()
|
||||
uint8 buff = urand(0, 2);
|
||||
SpawnBGObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + buff + i * 3, RESPAWN_IMMEDIATELY);
|
||||
}
|
||||
|
||||
// Achievement: Flurry
|
||||
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, EY_EVENT_START_BATTLE);
|
||||
}
|
||||
|
||||
void BattlegroundEY::AddPoints(uint32 Team, uint32 Points)
|
||||
@@ -193,7 +196,6 @@ void BattlegroundEY::CheckSomeoneLeftPoint()
|
||||
//move not existed player to "free space" - this will cause many error showing in log, but it is a very important bug
|
||||
m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]);
|
||||
m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j);
|
||||
++j;
|
||||
continue;
|
||||
}
|
||||
if (!player->CanCaptureTowerPoint() || !player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS))
|
||||
|
||||
@@ -220,6 +220,8 @@ enum EYBattlegroundObjectTypes
|
||||
#define BG_EY_NotEYWeekendHonorTicks 330
|
||||
#define BG_EY_EYWeekendHonorTicks 200
|
||||
|
||||
#define EY_EVENT_START_BATTLE 13180 // Achievement: Flurry
|
||||
|
||||
enum BG_EY_Score
|
||||
{
|
||||
BG_EY_WARNING_NEAR_VICTORY_SCORE = 1400,
|
||||
|
||||
@@ -30,6 +30,7 @@ file(GLOB_RECURSE sources_Globals Globals/*.cpp Globals/*.h)
|
||||
file(GLOB_RECURSE sources_Grids Grids/*.cpp Grids/*.h)
|
||||
file(GLOB_RECURSE sources_Groups Groups/*.cpp Groups/*.h)
|
||||
file(GLOB_RECURSE sources_Guilds Guilds/*.cpp Guilds/*.h)
|
||||
file(GLOB_RECURSE sources_Handlers Handlers/*.cpp Server/*.h)
|
||||
file(GLOB_RECURSE sources_Instances Instances/*.cpp Instances/*.h)
|
||||
file(GLOB_RECURSE sources_Loot Loot/*.cpp Loot/*.h)
|
||||
file(GLOB_RECURSE sources_Mails Mails/*.cpp Mails/*.h)
|
||||
@@ -79,6 +80,7 @@ set(game_STAT_SRCS
|
||||
${sources_Grids}
|
||||
${sources_Groups}
|
||||
${sources_Guilds}
|
||||
${sources_Handlers}
|
||||
${sources_Instances}
|
||||
${sources_Loot}
|
||||
${sources_Mails}
|
||||
@@ -102,6 +104,7 @@ set(game_STAT_SRCS
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
|
||||
${CMAKE_SOURCE_DIR}/dep/mersennetwister
|
||||
${CMAKE_SOURCE_DIR}/dep/SFMT
|
||||
${CMAKE_SOURCE_DIR}/dep/zlib
|
||||
@@ -114,12 +117,10 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Database
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/DataStores
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Debugging
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/CountedReference
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Packets
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Policies
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Threading
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Utilities
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
@@ -164,12 +165,14 @@ include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Grids
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Groups
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Guilds
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Handlers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Instances
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Loot
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Mails
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Maps
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Miscellaneous
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Movement
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Movement/Spline
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Movement/MovementGenerators
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Movement/Waypoints
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/OutdoorPvP
|
||||
@@ -179,7 +182,6 @@ include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Reputation
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Scripting
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Server/Protocol
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Server/Protocol/Handlers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Server
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Skills
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Spells
|
||||
|
||||
@@ -332,8 +332,8 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
QueryResult result = LoginDatabase.PQuery("SELECT a.username, aa.gmlevel, a.email, a.last_ip, a.last_login, a.mutetime "
|
||||
"FROM account a "
|
||||
"LEFT JOIN account_access aa "
|
||||
"ON (a.id = aa.id) "
|
||||
"WHERE a.id = '%u'", accId);
|
||||
"ON (a.id = aa.id AND (aa.RealmID = -1 OR aa.RealmID = %u)) "
|
||||
"WHERE a.id = '%u'", realmID, accId);
|
||||
if (result)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
@@ -714,19 +714,20 @@ bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)
|
||||
char* limit_str;
|
||||
|
||||
Player *chr = getSelectedPlayer();
|
||||
if (chr == NULL)
|
||||
if (!*args)
|
||||
{
|
||||
if (!*args)
|
||||
// NULL only if used from console
|
||||
if (!chr || chr == GetSession()->GetPlayer())
|
||||
return false;
|
||||
|
||||
ip = strtok ((char*)args, " ");
|
||||
limit_str = strtok (NULL, " ");
|
||||
limit = limit_str ? atoi (limit_str) : -1;
|
||||
ip = chr->GetSession()->GetRemoteAddress();
|
||||
limit = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ip = chr->GetSession()->GetRemoteAddress();
|
||||
limit = -1;
|
||||
ip = strtok ((char*)args, " ");
|
||||
limit_str = strtok (NULL, " ");
|
||||
limit = limit_str ? atoi (limit_str) : -1;
|
||||
}
|
||||
|
||||
LoginDatabase.EscapeString(ip);
|
||||
|
||||
@@ -3690,6 +3690,9 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
|
||||
PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUIDLow());
|
||||
|
||||
MotionMaster* mm = unit->GetMotionMaster();
|
||||
float x,y,z;
|
||||
mm->GetDestination(x,y,z);
|
||||
|
||||
for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
|
||||
{
|
||||
MovementGenerator* mg = mm->GetMotionSlot(i);
|
||||
@@ -3705,48 +3708,55 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
|
||||
case WAYPOINT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_WAYPOINT); break;
|
||||
case ANIMAL_RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM); break;
|
||||
case CONFUSED_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_CONFUSED); break;
|
||||
case TARGETED_MOTION_TYPE:
|
||||
case CHASE_MOTION_TYPE:
|
||||
{
|
||||
Unit* target = NULL;
|
||||
if (unit->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
TargetedMovementGenerator<Player> const* mgen = static_cast<TargetedMovementGenerator<Player> const*>(mg);
|
||||
Unit* target = mgen->GetTarget();
|
||||
if (target)
|
||||
PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER, target->GetName(), target->GetGUIDLow());
|
||||
else
|
||||
SendSysMessage(LANG_MOVEGENS_TARGETED_NULL);
|
||||
}
|
||||
target = static_cast<ChaseMovementGenerator<Player> const*>(mg)->GetTarget();
|
||||
else
|
||||
{
|
||||
TargetedMovementGenerator<Creature> const* mgen = static_cast<TargetedMovementGenerator<Creature> const*>(mg);
|
||||
Unit* target = mgen->GetTarget();
|
||||
if (target)
|
||||
PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE, target->GetName(), target->GetGUIDLow());
|
||||
else
|
||||
SendSysMessage(LANG_MOVEGENS_TARGETED_NULL);
|
||||
}
|
||||
target = static_cast<ChaseMovementGenerator<Creature> const*>(mg)->GetTarget();
|
||||
|
||||
if (!target)
|
||||
SendSysMessage(LANG_MOVEGENS_CHASE_NULL);
|
||||
else if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow());
|
||||
else
|
||||
PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow());
|
||||
break;
|
||||
}
|
||||
case FOLLOW_MOTION_TYPE:
|
||||
{
|
||||
Unit* target = NULL;
|
||||
if (unit->GetTypeId() == TYPEID_PLAYER)
|
||||
target = static_cast<FollowMovementGenerator<Player> const*>(mg)->GetTarget();
|
||||
else
|
||||
target = static_cast<FollowMovementGenerator<Creature> const*>(mg)->GetTarget();
|
||||
|
||||
if (!target)
|
||||
SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL);
|
||||
else if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow());
|
||||
else
|
||||
PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow());
|
||||
break;
|
||||
}
|
||||
case HOME_MOTION_TYPE:
|
||||
{
|
||||
if (unit->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
float x, y, z;
|
||||
mg->GetDestination(x, y, z);
|
||||
PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z);
|
||||
}
|
||||
else
|
||||
SendSysMessage(LANG_MOVEGENS_HOME_PLAYER);
|
||||
break;
|
||||
}
|
||||
case FLIGHT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FLIGHT); break;
|
||||
case POINT_MOTION_TYPE:
|
||||
{
|
||||
float x, y, z;
|
||||
mg->GetDestination(x, y, z);
|
||||
PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z);
|
||||
break;
|
||||
}
|
||||
case FLEEING_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FEAR); break;
|
||||
case DISTRACT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_DISTRACT); break;
|
||||
case EFFECT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_EFFECT); break;
|
||||
default:
|
||||
PSendSysMessage(LANG_MOVEGENS_UNKNOWN, mg->GetMovementGeneratorType());
|
||||
break;
|
||||
@@ -4038,19 +4048,14 @@ bool ChatHandler::HandleComeToMeCommand(const char *args)
|
||||
if (!newFlagStr)
|
||||
return false;
|
||||
|
||||
uint32 newFlags = (uint32)strtoul(newFlagStr, NULL, 0);
|
||||
|
||||
Creature* caster = getSelectedCreature();
|
||||
if (!caster)
|
||||
{
|
||||
m_session->GetPlayer()->SetUnitMovementFlags(newFlags);
|
||||
SendSysMessage(LANG_SELECT_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
caster->SetUnitMovementFlags(newFlags);
|
||||
|
||||
Player* player = m_session->GetPlayer();
|
||||
|
||||
caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
|
||||
|
||||
@@ -63,7 +63,7 @@ bool Condition::Meets(Player* player, Unit* invoker)
|
||||
case CONDITION_REPUTATION_RANK:
|
||||
{
|
||||
if (FactionEntry const* faction = sFactionStore.LookupEntry(mConditionValue1))
|
||||
condMeets = uint32(player->GetReputationMgr().GetRank(faction)) == mConditionValue2;
|
||||
condMeets = (mConditionValue2 & (1 << player->GetReputationMgr().GetRank(faction)));
|
||||
break;
|
||||
}
|
||||
case CONDITION_ACHIEVEMENT:
|
||||
@@ -73,10 +73,10 @@ bool Condition::Meets(Player* player, Unit* invoker)
|
||||
condMeets = player->GetTeam() == mConditionValue1;
|
||||
break;
|
||||
case CONDITION_CLASS:
|
||||
condMeets = player->getClass() == mConditionValue1;
|
||||
condMeets = player->getClassMask() & mConditionValue1;
|
||||
break;
|
||||
case CONDITION_RACE:
|
||||
condMeets = player->getRace() == mConditionValue1;
|
||||
condMeets = player->getRaceMask() & mConditionValue1;
|
||||
break;
|
||||
case CONDITION_SKILL:
|
||||
condMeets = player->HasSkill(mConditionValue1) && player->GetBaseSkillValue(mConditionValue1) >= mConditionValue2;
|
||||
@@ -243,33 +243,33 @@ ConditionMgr::~ConditionMgr()
|
||||
ConditionList ConditionMgr::GetConditionReferences(uint32 refId)
|
||||
{
|
||||
ConditionList conditions;
|
||||
ConditionReferenceMap::const_iterator ref = m_ConditionReferenceMap.find(refId);
|
||||
if (ref != m_ConditionReferenceMap.end())
|
||||
ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
|
||||
if (ref != ConditionReferenceStore.end())
|
||||
conditions = (*ref).second;
|
||||
return conditions;
|
||||
}
|
||||
|
||||
bool ConditionMgr::IsPlayerMeetToConditionList(Player* player, ConditionList const& conditions, Unit* invoker /*= NULL*/)
|
||||
{
|
||||
std::map<uint32, bool> ElseGroupMap;
|
||||
std::map<uint32, bool> ElseGroupStore;
|
||||
for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_CONDITIONSYS, "ConditionMgr::IsPlayerMeetToConditionList condType: %u val1: %u", (*i)->mConditionType, (*i)->mConditionValue1);
|
||||
if ((*i)->isLoaded())
|
||||
{
|
||||
std::map<uint32, bool>::const_iterator itr = ElseGroupMap.find((*i)->mElseGroup);
|
||||
if (itr == ElseGroupMap.end())
|
||||
ElseGroupMap[(*i)->mElseGroup] = true;
|
||||
std::map<uint32, bool>::const_iterator itr = ElseGroupStore.find((*i)->mElseGroup);
|
||||
if (itr == ElseGroupStore.end())
|
||||
ElseGroupStore[(*i)->mElseGroup] = true;
|
||||
else if (!(*itr).second)
|
||||
continue;
|
||||
|
||||
if ((*i)->mReferenceId)//handle reference
|
||||
{
|
||||
ConditionReferenceMap::const_iterator ref = m_ConditionReferenceMap.find((*i)->mReferenceId);
|
||||
if (ref != m_ConditionReferenceMap.end())
|
||||
ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->mReferenceId);
|
||||
if (ref != ConditionReferenceStore.end())
|
||||
{
|
||||
if (!IsPlayerMeetToConditionList(player, (*ref).second, invoker))
|
||||
ElseGroupMap[(*i)->mElseGroup] = false;
|
||||
ElseGroupStore[(*i)->mElseGroup] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -281,11 +281,11 @@ bool ConditionMgr::IsPlayerMeetToConditionList(Player* player, ConditionList con
|
||||
else //handle normal condition
|
||||
{
|
||||
if (!(*i)->Meets(player, invoker))
|
||||
ElseGroupMap[(*i)->mElseGroup] = false;
|
||||
ElseGroupStore[(*i)->mElseGroup] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (std::map<uint32, bool>::const_iterator i = ElseGroupMap.begin(); i != ElseGroupMap.end(); ++i)
|
||||
for (std::map<uint32, bool>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i)
|
||||
if (i->second)
|
||||
return true;
|
||||
|
||||
@@ -309,19 +309,19 @@ bool ConditionMgr::IsPlayerMeetToConditions(Player* player, ConditionList const&
|
||||
return result;
|
||||
}
|
||||
|
||||
ConditionList ConditionMgr::GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry)
|
||||
ConditionList ConditionMgr::GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry)
|
||||
{
|
||||
ConditionList spellCond;
|
||||
if (sType > CONDITION_SOURCE_TYPE_NONE && sType < CONDITION_SOURCE_TYPE_MAX)
|
||||
if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
|
||||
{
|
||||
ConditionMap::const_iterator itr = m_ConditionMap.find(sType);
|
||||
if (itr != m_ConditionMap.end())
|
||||
ConditionContainer::const_iterator itr = ConditionStore.find(sourceType);
|
||||
if (itr != ConditionStore.end())
|
||||
{
|
||||
ConditionTypeMap::const_iterator i = (*itr).second.find(uEntry);
|
||||
ConditionTypeContainer::const_iterator i = (*itr).second.find(entry);
|
||||
if (i != (*itr).second.end())
|
||||
{
|
||||
spellCond = (*i).second;
|
||||
sLog->outDebug(LOG_FILTER_CONDITIONSYS, "GetConditionsForNotGroupedEntry: found conditions for type %u and entry %u", uint32(sType), uEntry);
|
||||
sLog->outDebug(LOG_FILTER_CONDITIONSYS, "GetConditionsForNotGroupedEntry: found conditions for type %u and entry %u", uint32(sourceType), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,10 +331,10 @@ ConditionList ConditionMgr::GetConditionsForNotGroupedEntry(ConditionSourceType
|
||||
ConditionList ConditionMgr::GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID)
|
||||
{
|
||||
ConditionList cond;
|
||||
VehicleSpellConditionMap::const_iterator itr = m_VehicleSpellConditions.find(creatureID);
|
||||
if (itr != m_VehicleSpellConditions.end())
|
||||
VehicleSpellConditionContainer::const_iterator itr = VehicleSpellConditionStore.find(creatureID);
|
||||
if (itr != VehicleSpellConditionStore.end())
|
||||
{
|
||||
ConditionTypeMap::const_iterator i = (*itr).second.find(spellID);
|
||||
ConditionTypeContainer::const_iterator i = (*itr).second.find(spellID);
|
||||
if (i != (*itr).second.end())
|
||||
{
|
||||
cond = (*i).second;
|
||||
@@ -344,6 +344,22 @@ ConditionList ConditionMgr::GetConditionsForVehicleSpell(uint32 creatureID, uint
|
||||
return cond;
|
||||
}
|
||||
|
||||
ConditionList ConditionMgr::GetConditionsForSmartEvent(uint32 entry, uint32 eventId, uint32 sourceType)
|
||||
{
|
||||
ConditionList cond;
|
||||
SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entry, sourceType));
|
||||
if (itr != SmartEventConditionStore.end())
|
||||
{
|
||||
ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1);
|
||||
if (i != (*itr).second.end())
|
||||
{
|
||||
cond = (*i).second;
|
||||
sLog->outDebug(LOG_FILTER_CONDITIONSYS, "GetConditionsForSmartEvent: found conditions for Smart Event entry %u event_id %u", entry, eventId);
|
||||
}
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
void ConditionMgr::LoadConditions(bool isReload)
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
@@ -374,7 +390,7 @@ void ConditionMgr::LoadConditions(bool isReload)
|
||||
sObjectMgr->LoadGossipMenuItems();
|
||||
}
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, ElseGroup, ConditionTypeOrReference, "
|
||||
QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, "
|
||||
" ConditionValue1, ConditionValue2, ConditionValue3, ErrorTextId, ScriptName FROM conditions");
|
||||
|
||||
if (!result)
|
||||
@@ -395,13 +411,14 @@ void ConditionMgr::LoadConditions(bool isReload)
|
||||
int32 iSourceTypeOrReferenceId = fields[0].GetInt32();
|
||||
cond->mSourceGroup = fields[1].GetUInt32();
|
||||
cond->mSourceEntry = fields[2].GetUInt32();
|
||||
cond->mElseGroup = fields[3].GetUInt32();
|
||||
int32 iConditionTypeOrReference = fields[4].GetInt32();
|
||||
cond->mConditionValue1 = fields[5].GetUInt32();
|
||||
cond->mConditionValue2 = fields[6].GetUInt32();
|
||||
cond->mConditionValue3 = fields[7].GetUInt32();
|
||||
cond->ErrorTextd = fields[8].GetUInt32();
|
||||
cond->mScriptId = sObjectMgr->GetScriptId(fields[9].GetCString());
|
||||
cond->mSourceId = fields[3].GetUInt32();
|
||||
cond->mElseGroup = fields[4].GetUInt32();
|
||||
int32 iConditionTypeOrReference = fields[5].GetInt32();
|
||||
cond->mConditionValue1 = fields[6].GetUInt32();
|
||||
cond->mConditionValue2 = fields[7].GetUInt32();
|
||||
cond->mConditionValue3 = fields[8].GetUInt32();
|
||||
cond->ErrorTextd = fields[9].GetUInt32();
|
||||
cond->mScriptId = sObjectMgr->GetScriptId(fields[10].GetCString());
|
||||
|
||||
if (iConditionTypeOrReference >= 0)
|
||||
cond->mConditionType = ConditionType(iConditionTypeOrReference);
|
||||
@@ -440,12 +457,12 @@ void ConditionMgr::LoadConditions(bool isReload)
|
||||
if (iSourceTypeOrReferenceId < 0)//it is a reference template
|
||||
{
|
||||
uint32 uRefId = abs(iSourceTypeOrReferenceId);
|
||||
if (m_ConditionReferenceMap.find(uRefId) == m_ConditionReferenceMap.end())//make sure we have a list for our conditions, based on reference id
|
||||
if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end())//make sure we have a list for our conditions, based on reference id
|
||||
{
|
||||
ConditionList mCondList;
|
||||
m_ConditionReferenceMap[uRefId] = mCondList;
|
||||
ConditionReferenceStore[uRefId] = mCondList;
|
||||
}
|
||||
m_ConditionReferenceMap[uRefId].push_back(cond);//add to reference storage
|
||||
ConditionReferenceStore[uRefId].push_back(cond);//add to reference storage
|
||||
count++;
|
||||
continue;
|
||||
}//end of reference templates
|
||||
@@ -468,83 +485,102 @@ void ConditionMgr::LoadConditions(bool isReload)
|
||||
}
|
||||
else if (cond->mSourceGroup)
|
||||
{
|
||||
bool bIsDone = false;
|
||||
bool valid = false;
|
||||
//handle grouped conditions
|
||||
switch (cond->mSourceType)
|
||||
{
|
||||
case CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Creature.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Creature.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Disenchant.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Disenchant.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Fishing.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Fishing.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Gameobject.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Gameobject.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Item.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Item.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Mail.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Mail.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Milling.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Milling.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Pickpocketing.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Pickpocketing.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Prospecting.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Prospecting.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Reference.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Reference.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Skinning.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Skinning.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE:
|
||||
bIsDone = addToLootTemplate(cond, LootTemplates_Spell.GetLootForConditionFill(cond->mSourceGroup));
|
||||
valid = addToLootTemplate(cond, LootTemplates_Spell.GetLootForConditionFill(cond->mSourceGroup));
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
|
||||
bIsDone = addToGossipMenus(cond);
|
||||
valid = addToGossipMenus(cond);
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
||||
bIsDone = addToGossipMenuItems(cond);
|
||||
valid = addToGossipMenuItems(cond);
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_VEHICLE_SPELL:
|
||||
{
|
||||
//if no list for vehicle create one
|
||||
if (m_VehicleSpellConditions.find(cond->mSourceGroup) == m_VehicleSpellConditions.end())
|
||||
if (VehicleSpellConditionStore.find(cond->mSourceGroup) == VehicleSpellConditionStore.end())
|
||||
{
|
||||
ConditionTypeMap cmap;
|
||||
m_VehicleSpellConditions[cond->mSourceGroup] = cmap;
|
||||
ConditionTypeContainer cmap;
|
||||
VehicleSpellConditionStore[cond->mSourceGroup] = cmap;
|
||||
}
|
||||
//if no list for vehicle's spell create one
|
||||
if (m_VehicleSpellConditions[cond->mSourceGroup].find(cond->mSourceEntry) == m_VehicleSpellConditions[cond->mSourceGroup].end())
|
||||
if (VehicleSpellConditionStore[cond->mSourceGroup].find(cond->mSourceEntry) == VehicleSpellConditionStore[cond->mSourceGroup].end())
|
||||
{
|
||||
ConditionList clist;
|
||||
m_VehicleSpellConditions[cond->mSourceGroup][cond->mSourceEntry] = clist;
|
||||
VehicleSpellConditionStore[cond->mSourceGroup][cond->mSourceEntry] = clist;
|
||||
}
|
||||
m_VehicleSpellConditions[cond->mSourceGroup][cond->mSourceEntry].push_back(cond);
|
||||
bIsDone = true;
|
||||
VehicleSpellConditionStore[cond->mSourceGroup][cond->mSourceEntry].push_back(cond);
|
||||
valid = true;
|
||||
++count;
|
||||
continue; // do not add to m_AllocatedMemory to avoid double deleting
|
||||
}
|
||||
case CONDITION_SOURCE_TYPE_SMART_EVENT:
|
||||
{
|
||||
// If the entry does not exist, create a new list
|
||||
std::pair<uint32, uint32> key = std::make_pair(cond->mSourceEntry, cond->mSourceId);
|
||||
if (SmartEventConditionStore.find(key) == SmartEventConditionStore.end())
|
||||
{
|
||||
ConditionTypeContainer cmap;
|
||||
SmartEventConditionStore[key] = cmap;
|
||||
}
|
||||
if (SmartEventConditionStore[key].find(cond->mSourceGroup) == SmartEventConditionStore[key].end())
|
||||
{
|
||||
ConditionList clist;
|
||||
SmartEventConditionStore[key][cond->mSourceGroup] = clist;
|
||||
}
|
||||
SmartEventConditionStore[key][cond->mSourceGroup].push_back(cond);
|
||||
valid = true;
|
||||
++count;
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bIsDone)
|
||||
if (!valid)
|
||||
{
|
||||
sLog->outErrorDb("Not handled grouped condition, SourceGroup %u", cond->mSourceGroup);
|
||||
delete cond;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AllocatedMemory.push_back(cond);
|
||||
AllocatedMemoryStore.push_back(cond);
|
||||
++count;
|
||||
}
|
||||
continue;
|
||||
@@ -552,21 +588,21 @@ void ConditionMgr::LoadConditions(bool isReload)
|
||||
|
||||
//handle not grouped conditions
|
||||
//make sure we have a storage list for our SourceType
|
||||
if (m_ConditionMap.find(cond->mSourceType) == m_ConditionMap.end())
|
||||
if (ConditionStore.find(cond->mSourceType) == ConditionStore.end())
|
||||
{
|
||||
ConditionTypeMap mTypeMap;
|
||||
m_ConditionMap[cond->mSourceType] = mTypeMap;//add new empty list for SourceType
|
||||
ConditionTypeContainer mTypeMap;
|
||||
ConditionStore[cond->mSourceType] = mTypeMap;//add new empty list for SourceType
|
||||
}
|
||||
|
||||
//make sure we have a condition list for our SourceType's entry
|
||||
if (m_ConditionMap[cond->mSourceType].find(cond->mSourceEntry) == m_ConditionMap[cond->mSourceType].end())
|
||||
if (ConditionStore[cond->mSourceType].find(cond->mSourceEntry) == ConditionStore[cond->mSourceType].end())
|
||||
{
|
||||
ConditionList mCondList;
|
||||
m_ConditionMap[cond->mSourceType][cond->mSourceEntry] = mCondList;
|
||||
ConditionStore[cond->mSourceType][cond->mSourceEntry] = mCondList;
|
||||
}
|
||||
|
||||
//add new Condition to storage based on Type/Entry
|
||||
m_ConditionMap[cond->mSourceType][cond->mSourceEntry].push_back(cond);
|
||||
ConditionStore[cond->mSourceType][cond->mSourceEntry].push_back(cond);
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
@@ -1004,6 +1040,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
||||
case CONDITION_SOURCE_TYPE_SMART_EVENT:
|
||||
case CONDITION_SOURCE_TYPE_NONE:
|
||||
default:
|
||||
break;
|
||||
@@ -1180,9 +1217,9 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
||||
}
|
||||
case CONDITION_CLASS:
|
||||
{
|
||||
if (cond->mConditionValue1 >= MAX_CLASSES)
|
||||
if (!(cond->mConditionValue1 & CLASSMASK_ALL_PLAYABLE))
|
||||
{
|
||||
sLog->outErrorDb("Class condition has non existing class (%u), skipped", cond->mConditionValue1);
|
||||
sLog->outErrorDb("Class condition has non existing classmask (%u), skipped", cond->mConditionValue1 & ~CLASSMASK_ALL_PLAYABLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1192,9 +1229,9 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
||||
}
|
||||
case CONDITION_RACE:
|
||||
{
|
||||
if (cond->mConditionValue1 >= MAX_RACES)
|
||||
if (!(cond->mConditionValue1 & RACEMASK_ALL_PLAYABLE))
|
||||
{
|
||||
sLog->outErrorDb("Race condition has non existing race (%u), skipped", cond->mConditionValue1);
|
||||
sLog->outErrorDb("Race condition has non existing racemask (%u), skipped", cond->mConditionValue1 & ~RACEMASK_ALL_PLAYABLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1375,18 +1412,18 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
||||
|
||||
void ConditionMgr::Clean()
|
||||
{
|
||||
for (ConditionReferenceMap::iterator itr = m_ConditionReferenceMap.begin(); itr != m_ConditionReferenceMap.end(); ++itr)
|
||||
for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
|
||||
{
|
||||
for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
delete *it;
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
m_ConditionReferenceMap.clear();
|
||||
ConditionReferenceStore.clear();
|
||||
|
||||
for (ConditionMap::iterator itr = m_ConditionMap.begin(); itr != m_ConditionMap.end(); ++itr)
|
||||
for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
|
||||
{
|
||||
for (ConditionTypeMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
{
|
||||
for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||
delete *i;
|
||||
@@ -1395,11 +1432,11 @@ void ConditionMgr::Clean()
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
m_ConditionMap.clear();
|
||||
ConditionStore.clear();
|
||||
|
||||
for (VehicleSpellConditionMap::iterator itr = m_VehicleSpellConditions.begin(); itr != m_VehicleSpellConditions.end(); ++itr)
|
||||
for (VehicleSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
|
||||
{
|
||||
for (ConditionTypeMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
{
|
||||
for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||
delete *i;
|
||||
@@ -1408,11 +1445,24 @@ void ConditionMgr::Clean()
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
m_VehicleSpellConditions.clear();
|
||||
VehicleSpellConditionStore.clear();
|
||||
|
||||
for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
|
||||
{
|
||||
for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||
{
|
||||
for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||
delete *i;
|
||||
it->second.clear();
|
||||
}
|
||||
itr->second.clear();
|
||||
}
|
||||
|
||||
SmartEventConditionStore.clear();
|
||||
|
||||
// this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
|
||||
for (std::list<Condition*>::const_iterator itr = m_AllocatedMemory.begin(); itr != m_AllocatedMemory.end(); ++itr)
|
||||
for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr)
|
||||
delete *itr;
|
||||
|
||||
m_AllocatedMemory.clear();
|
||||
AllocatedMemoryStore.clear();
|
||||
}
|
||||
@@ -96,7 +96,8 @@ enum ConditionSourceType
|
||||
CONDITION_SOURCE_TYPE_QUEST_ACCEPT = 19, //DONE
|
||||
CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK = 20, //DONE
|
||||
CONDITION_SOURCE_TYPE_VEHICLE_SPELL = 21, //DONE
|
||||
CONDITION_SOURCE_TYPE_MAX = 22//MAX
|
||||
CONDITION_SOURCE_TYPE_SMART_EVENT = 22, //DONE
|
||||
CONDITION_SOURCE_TYPE_MAX = 23 //MAX
|
||||
};
|
||||
|
||||
struct Condition
|
||||
@@ -104,6 +105,7 @@ struct Condition
|
||||
ConditionSourceType mSourceType; //SourceTypeOrReferenceId
|
||||
uint32 mSourceGroup;
|
||||
uint32 mSourceEntry;
|
||||
uint32 mSourceId; // So far, only used in CONDITION_SOURCE_TYPE_SMART_EVENT
|
||||
uint32 mElseGroup;
|
||||
ConditionType mConditionType; //ConditionTypeOrReference
|
||||
uint32 mConditionValue1;
|
||||
@@ -133,11 +135,12 @@ struct Condition
|
||||
};
|
||||
|
||||
typedef std::list<Condition*> ConditionList;
|
||||
typedef std::map<uint32, ConditionList> ConditionTypeMap;
|
||||
typedef std::map<ConditionSourceType, ConditionTypeMap> ConditionMap;
|
||||
typedef std::map<uint32, ConditionTypeMap> VehicleSpellConditionMap;
|
||||
typedef std::map<uint32, ConditionList> ConditionTypeContainer;
|
||||
typedef std::map<ConditionSourceType, ConditionTypeContainer> ConditionContainer;
|
||||
typedef std::map<uint32, ConditionTypeContainer> VehicleSpellConditionContainer;
|
||||
typedef std::map<std::pair<uint32, uint32 /*SAI source_type*/>, ConditionTypeContainer> SmartEventConditionContainer;
|
||||
|
||||
typedef std::map<uint32, ConditionList> ConditionReferenceMap;//only used for references
|
||||
typedef std::map<uint32, ConditionList> ConditionReferenceContainer;//only used for references
|
||||
|
||||
class ConditionMgr
|
||||
{
|
||||
@@ -153,7 +156,8 @@ class ConditionMgr
|
||||
ConditionList GetConditionReferences(uint32 refId);
|
||||
|
||||
bool IsPlayerMeetToConditions(Player* player, ConditionList const& conditions, Unit* invoker = NULL);
|
||||
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry);
|
||||
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry);
|
||||
ConditionList GetConditionsForSmartEvent(uint32 entry, uint32 eventId, uint32 sourceType);
|
||||
ConditionList GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID);
|
||||
|
||||
private:
|
||||
@@ -179,15 +183,17 @@ class ConditionMgr
|
||||
sourceType == CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE ||
|
||||
sourceType == CONDITION_SOURCE_TYPE_GOSSIP_MENU ||
|
||||
sourceType == CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION ||
|
||||
sourceType == CONDITION_SOURCE_TYPE_VEHICLE_SPELL);
|
||||
sourceType == CONDITION_SOURCE_TYPE_VEHICLE_SPELL ||
|
||||
sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
|
||||
}
|
||||
|
||||
void Clean(); // free up resources
|
||||
std::list<Condition*> m_AllocatedMemory; // some garbage collection :)
|
||||
std::list<Condition*> AllocatedMemoryStore; // some garbage collection :)
|
||||
|
||||
ConditionMap m_ConditionMap;
|
||||
ConditionReferenceMap m_ConditionReferenceMap;
|
||||
VehicleSpellConditionMap m_VehicleSpellConditions;
|
||||
ConditionContainer ConditionStore;
|
||||
ConditionReferenceContainer ConditionReferenceStore;
|
||||
VehicleSpellConditionContainer VehicleSpellConditionStore;
|
||||
SmartEventConditionContainer SmartEventConditionStore;
|
||||
};
|
||||
|
||||
#define sConditionMgr ACE_Singleton<ConditionMgr, ACE_Null_Mutex>::instance()
|
||||
|
||||
@@ -72,6 +72,54 @@ LFGMgr::~LFGMgr()
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
void LFGMgr::_LoadFromDB(Field* fields, uint64 guid)
|
||||
{
|
||||
if (!fields)
|
||||
return;
|
||||
|
||||
if (!IS_GROUP(guid))
|
||||
return;
|
||||
|
||||
uint32 dungeon = fields[16].GetUInt32();
|
||||
|
||||
uint8 state = fields[17].GetUInt8();
|
||||
|
||||
if (!dungeon || !state)
|
||||
return;
|
||||
|
||||
SetDungeon(guid, dungeon);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case LFG_STATE_DUNGEON:
|
||||
case LFG_STATE_FINISHED_DUNGEON:
|
||||
SetState(guid, (LfgState)state);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LFGMgr::_SaveToDB(uint64 guid, uint32 db_guid)
|
||||
{
|
||||
if (!IS_GROUP(guid))
|
||||
return;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
|
||||
|
||||
stmt->setUInt32(0, db_guid);
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_LFG_DATA);
|
||||
stmt->setUInt32(0, db_guid);
|
||||
|
||||
stmt->setUInt32(1, GetDungeon(guid));
|
||||
stmt->setUInt32(2, GetState(guid));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
/// Load rewards for completing dungeons
|
||||
void LFGMgr::LoadRewards()
|
||||
{
|
||||
@@ -245,7 +293,8 @@ void LFGMgr::Update(uint32 diff)
|
||||
UpdateProposal(m_lfgProposalId, guid, true);
|
||||
}
|
||||
else
|
||||
currentQueue.push_back(frontguid); // Lfg group not found, add this group to the queue.
|
||||
if (std::find(currentQueue.begin(), currentQueue.end(), frontguid) == currentQueue.end()) //already in queue?
|
||||
currentQueue.push_back(frontguid); // Lfg group not found, add this group to the queue.
|
||||
firstNew.clear();
|
||||
}
|
||||
}
|
||||
@@ -382,7 +431,10 @@ void LFGMgr::InitializeLockedDungeons(Player* player)
|
||||
else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player))
|
||||
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
|
||||
else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && player->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty)))
|
||||
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
|
||||
{
|
||||
if (!player->GetGroup() || !player->GetGroup()->isLFGGroup() || GetDungeon(player->GetGroup()->GetGUID(), true) != dungeon->ID || GetState(player->GetGroup()->GetGUID()) != LFG_STATE_DUNGEON)
|
||||
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
|
||||
}
|
||||
else if (dungeon->minlevel > level)
|
||||
locktype = LFG_LOCKSTATUS_TOO_LOW_LEVEL;
|
||||
else if (dungeon->maxlevel < level)
|
||||
@@ -431,7 +483,7 @@ void LFGMgr::InitializeLockedDungeons(Player* player)
|
||||
void LFGMgr::Join(Player* player, uint8 roles, const LfgDungeonSet& selectedDungeons, const std::string& comment)
|
||||
{
|
||||
if (!player || !player->GetSession() || selectedDungeons.empty())
|
||||
return;
|
||||
return;
|
||||
|
||||
Group* grp = player->GetGroup();
|
||||
uint64 guid = player->GetGUID();
|
||||
@@ -808,7 +860,7 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
|
||||
{
|
||||
uint64 guid = (*it);
|
||||
LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid);
|
||||
if (itQueue == m_QueueInfoMap.end())
|
||||
if (itQueue == m_QueueInfoMap.end() || GetState(guid) != LFG_STATE_QUEUED)
|
||||
{
|
||||
sLog->outError("LFGMgr::CheckCompatibility: [" UI64FMTD "] is not queued but listed as queued!", (*it));
|
||||
RemoveFromQueue(guid);
|
||||
@@ -923,6 +975,42 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
|
||||
if (numPlayers != MAXGROUPSIZE)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::CheckCompatibility: (%s) Compatibles but not match. Players(%u)", strGuids.c_str(), numPlayers);
|
||||
uint8 Tanks_Needed = LFG_TANKS_NEEDED;
|
||||
uint8 Healers_Needed = LFG_HEALERS_NEEDED;
|
||||
uint8 Dps_Needed = LFG_DPS_NEEDED;
|
||||
for (LfgQueueInfoMap::const_iterator itQueue = pqInfoMap.begin(); itQueue != pqInfoMap.end(); ++itQueue)
|
||||
{
|
||||
LfgQueueInfo* queue = itQueue->second;
|
||||
for (LfgRolesMap::const_iterator itPlayer = queue->roles.begin(); itPlayer != queue->roles.end(); ++itPlayer)
|
||||
{
|
||||
uint8 roles = itPlayer->second;
|
||||
if ((roles & ROLE_TANK) && Tanks_Needed > 0)
|
||||
--Tanks_Needed;
|
||||
else if ((roles & ROLE_HEALER) && Healers_Needed > 0)
|
||||
--Healers_Needed;
|
||||
else if ((roles & ROLE_DAMAGE) && Dps_Needed > 0)
|
||||
--Dps_Needed;
|
||||
}
|
||||
}
|
||||
for (PlayerSet::const_iterator itPlayers = players.begin(); itPlayers != players.end(); ++itPlayers)
|
||||
{
|
||||
for (LfgQueueInfoMap::const_iterator itQueue = pqInfoMap.begin(); itQueue != pqInfoMap.end(); ++itQueue)
|
||||
{
|
||||
LfgQueueInfo* queue = itQueue->second;
|
||||
if (!queue)
|
||||
continue;
|
||||
|
||||
for (LfgRolesMap::const_iterator itPlayer = queue->roles.begin(); itPlayer != queue->roles.end(); ++itPlayer)
|
||||
{
|
||||
if (*itPlayers == ObjectAccessor::FindPlayer(itPlayer->first))
|
||||
{
|
||||
queue->tanks = Tanks_Needed;
|
||||
queue->healers = Healers_Needed;
|
||||
queue->dps = Dps_Needed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::CheckCompatibility: (%s) MATCH! Group formed", strGuids.c_str());
|
||||
@@ -1078,6 +1166,11 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /*
|
||||
}
|
||||
|
||||
m_QueueInfoMap[gguid] = pqInfo;
|
||||
if(GetState(gguid) != LFG_STATE_NONE)
|
||||
{
|
||||
LfgGuidList& currentQueue = m_currentQueue[team];
|
||||
currentQueue.push_front(gguid);
|
||||
}
|
||||
AddToQueue(gguid, team);
|
||||
}
|
||||
|
||||
@@ -1384,6 +1477,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_teleport.push_back(pguid);
|
||||
grp->SetLfgRoles(pguid, pProposal->players[pguid]->role);
|
||||
SetState(pguid, LFG_STATE_DUNGEON);
|
||||
}
|
||||
@@ -1395,6 +1489,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
|
||||
uint64 gguid = grp->GetGUID();
|
||||
SetDungeon(gguid, dungeon->Entry());
|
||||
SetState(gguid, LFG_STATE_DUNGEON);
|
||||
_SaveToDB(gguid, grp->GetDbStoreId());
|
||||
|
||||
// Remove players/groups from Queue
|
||||
for (LfgGuidList::const_iterator it = pProposal->queues.begin(); it != pProposal->queues.end(); ++it)
|
||||
@@ -1509,7 +1604,9 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
|
||||
for (LfgGuidList::const_iterator it = pProposal->queues.begin(); it != pProposal->queues.end(); ++it)
|
||||
{
|
||||
uint64 guid = *it;
|
||||
AddToQueue(guid, team);
|
||||
LfgGuidList& currentQueue = m_currentQueue[team];
|
||||
currentQueue.push_front(guid); //Add GUID for high priority
|
||||
AddToQueue(guid, team); //We have to add each GUID in newQueue to check for a new groups
|
||||
}
|
||||
|
||||
delete pProposal;
|
||||
@@ -1921,6 +2018,16 @@ const std::string& LFGMgr::GetComment(uint64 guid)
|
||||
return m_Players[guid].GetComment();
|
||||
}
|
||||
|
||||
bool LFGMgr::IsTeleported(uint64 pguid)
|
||||
{
|
||||
if (std::find(m_teleport.begin(), m_teleport.end(), pguid) != m_teleport.end())
|
||||
{
|
||||
m_teleport.remove(pguid);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const LfgDungeonSet& LFGMgr::GetSelectedDungeons(uint64 guid)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetSelectedDungeons: [" UI64FMTD "]", guid);
|
||||
|
||||
@@ -287,6 +287,9 @@ class LFGMgr
|
||||
|
||||
void InitializeLockedDungeons(Player* player);
|
||||
|
||||
void _LoadFromDB(Field* fields, uint64 guid);
|
||||
void _SaveToDB(uint64 guid, uint32 db_guid);
|
||||
|
||||
void SetComment(uint64 guid, const std::string& comment);
|
||||
const LfgLockMap& GetLockedDungeons(uint64 guid);
|
||||
LfgState GetState(uint64 guid);
|
||||
@@ -298,7 +301,9 @@ class LFGMgr
|
||||
void RemoveGroupData(uint64 guid);
|
||||
uint8 GetKicksLeft(uint64 gguid);
|
||||
uint8 GetVotesNeeded(uint64 gguid);
|
||||
bool IsTeleported(uint64 pguid);
|
||||
void SetRoles(uint64 guid, uint8 roles);
|
||||
void SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons);
|
||||
|
||||
private:
|
||||
|
||||
@@ -306,10 +311,8 @@ class LFGMgr
|
||||
const std::string& GetComment(uint64 gguid);
|
||||
void RestoreState(uint64 guid);
|
||||
void SetDungeon(uint64 guid, uint32 dungeon);
|
||||
void SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons);
|
||||
void SetLockedDungeons(uint64 guid, const LfgLockMap& lock);
|
||||
void DecreaseKicksLeft(uint64 guid);
|
||||
void NoExiste(uint8 lala);
|
||||
|
||||
// Queue
|
||||
void AddToQueue(uint64 guid, uint8 queueId);
|
||||
@@ -352,6 +355,7 @@ class LFGMgr
|
||||
LfgGuidListMap m_currentQueue; ///< Ordered list. Used to find groups
|
||||
LfgGuidListMap m_newToQueue; ///< New groups to add to queue
|
||||
LfgCompatibleMap m_CompatibleMap; ///< Compatible dungeons
|
||||
LfgGuidList m_teleport; ///< Players being teleported
|
||||
// Rolecheck - Proposal - Vote Kicks
|
||||
LfgRoleCheckMap m_RoleChecks; ///< Current Role checks
|
||||
LfgProposalMap m_Proposals; ///< Current Proposals
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "Vehicle.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "Group.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "MoveSpline.h"
|
||||
// apply implementation of the singletons
|
||||
|
||||
TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
|
||||
@@ -143,7 +145,7 @@ m_PlayerDamageReq(0), m_lootMoney(0), m_lootRecipient(0), m_lootRecipientGroup(0
|
||||
m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE),
|
||||
m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_AlreadyCallAssistance(false),
|
||||
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
|
||||
m_creatureInfo(NULL), m_creatureData(NULL), m_formation(NULL)
|
||||
m_creatureInfo(NULL), m_creatureData(NULL), m_formation(NULL), m_path_id(0)
|
||||
{
|
||||
m_regenTimer = CREATURE_REGEN_INTERVAL;
|
||||
m_valuesCount = UNIT_END;
|
||||
@@ -332,6 +334,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData* data
|
||||
SetSpeed(MOVE_FLIGHT, 1.0f); // using 1.0 rate
|
||||
|
||||
SetFloatValue(OBJECT_FIELD_SCALE_X, cinfo->scale);
|
||||
SetLevitate(canFly());
|
||||
|
||||
// checked at loading
|
||||
m_defaultMovementType = MovementGeneratorType(cinfo->MovementType);
|
||||
@@ -435,6 +438,17 @@ void Creature::Update(uint32 diff)
|
||||
m_vehicleKit->Reset();
|
||||
}
|
||||
|
||||
if (IsInWater())
|
||||
{
|
||||
if (canSwim())
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (canWalk())
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
}
|
||||
|
||||
switch (m_deathState)
|
||||
{
|
||||
case JUST_ALIVED:
|
||||
@@ -472,9 +486,7 @@ void Creature::Update(uint32 diff)
|
||||
}
|
||||
case CORPSE:
|
||||
{
|
||||
m_Events.Update(diff);
|
||||
_UpdateSpells(diff);
|
||||
|
||||
Unit::Update(diff);
|
||||
// deathstate changed on spells update, prevent problems
|
||||
if (m_deathState != CORPSE)
|
||||
break;
|
||||
@@ -565,9 +577,6 @@ void Creature::Update(uint32 diff)
|
||||
m_regenTimer = CREATURE_REGEN_INTERVAL;
|
||||
break;
|
||||
}
|
||||
case DEAD_FALLING:
|
||||
GetMotionMaster()->UpdateMotion(diff);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -715,7 +724,7 @@ void Creature::Motion_Initialize()
|
||||
i_motionMaster.Initialize();
|
||||
}
|
||||
else if (m_formation->isFormed())
|
||||
i_motionMaster.MoveIdle(MOTION_SLOT_IDLE); //wait the order of leader
|
||||
i_motionMaster.MoveIdle(); //wait the order of leader
|
||||
else
|
||||
i_motionMaster.Initialize();
|
||||
}
|
||||
@@ -945,7 +954,8 @@ void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint3
|
||||
|
||||
m_startMove = getMSTime();
|
||||
m_moveTime = time;*/
|
||||
SendMonsterMove(x, y, z, time);
|
||||
float speed = GetDistance(x, y, z) / ((float)time * 0.001f);
|
||||
MonsterMoveWithSpeed(x, y, z, speed);
|
||||
}
|
||||
|
||||
Player* Creature::GetLootRecipient() const
|
||||
@@ -1507,8 +1517,8 @@ void Creature::setDeathState(DeathState s)
|
||||
if (m_formation && m_formation->getLeader() == this)
|
||||
m_formation->FormationReset(true);
|
||||
|
||||
if ((canFly() || IsFlying()) && FallGround())
|
||||
return;
|
||||
if ((canFly() || IsFlying()))
|
||||
i_motionMaster.MoveFall();
|
||||
|
||||
Unit::setDeathState(CORPSE);
|
||||
}
|
||||
@@ -1520,7 +1530,7 @@ void Creature::setDeathState(DeathState s)
|
||||
SetLootRecipient(NULL);
|
||||
ResetPlayerDamageReq();
|
||||
CreatureTemplate const* cinfo = GetCreatureInfo();
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
SetWalk(true);
|
||||
if (GetCreatureInfo()->InhabitType & INHABIT_AIR)
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING);
|
||||
if (GetCreatureInfo()->InhabitType & INHABIT_WATER)
|
||||
@@ -1536,24 +1546,6 @@ void Creature::setDeathState(DeathState s)
|
||||
}
|
||||
}
|
||||
|
||||
bool Creature::FallGround()
|
||||
{
|
||||
// Let's abort after we called this function one time
|
||||
if (getDeathState() == DEAD_FALLING)
|
||||
return false;
|
||||
|
||||
float x, y, z;
|
||||
GetPosition(x, y, z);
|
||||
// use larger distance for vmap height search than in most other cases
|
||||
float ground_Z = GetMap()->GetHeight(x, y, z, true, MAX_FALL_DISTANCE);
|
||||
if (fabs(ground_Z - z) < 0.1f)
|
||||
return false;
|
||||
|
||||
GetMotionMaster()->MoveFall(ground_Z, EVENT_FALL_GROUND);
|
||||
Unit::setDeathState(DEAD_FALLING);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Creature::Respawn(bool force)
|
||||
{
|
||||
DestroyForNearbyPlayers();
|
||||
@@ -2417,3 +2409,25 @@ bool Creature::IsDungeonBoss() const
|
||||
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry());
|
||||
return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS);
|
||||
}
|
||||
|
||||
void Creature::SetWalk(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
else
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
WorldPacket data(enable ? SMSG_MOVE_SPLINE_SET_WALK_MODE : SMSG_MOVE_SPLINE_SET_RUN_MODE, 9);
|
||||
data.append(GetPackGUID());
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void Creature::SetLevitate(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
|
||||
else
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
|
||||
WorldPacket data(enable ? SMSG_MOVE_SPLINE_DISABLE_GRAVITY : SMSG_MOVE_SPLINE_ENABLE_GRAVITY, 9);
|
||||
data.append(GetPackGUID());
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
@@ -522,6 +522,9 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
|
||||
CreatureAI* AI() const { return (CreatureAI*)i_AI; }
|
||||
|
||||
void SetWalk(bool enable);
|
||||
void SetLevitate(bool enable);
|
||||
|
||||
uint32 GetShieldBlockValue() const //dunno mob block value
|
||||
{
|
||||
return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
|
||||
@@ -575,7 +578,6 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
const char* GetNameForLocaleIdx(LocaleConstant locale_idx) const;
|
||||
|
||||
void setDeathState(DeathState s); // override virtual Unit::setDeathState
|
||||
bool FallGround();
|
||||
|
||||
bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false); }
|
||||
bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true);
|
||||
|
||||
@@ -203,7 +203,7 @@ void CreatureGroup::FormationReset(bool dismiss)
|
||||
if (dismiss)
|
||||
itr->first->GetMotionMaster()->Initialize();
|
||||
else
|
||||
itr->first->GetMotionMaster()->MoveIdle(MOTION_SLOT_IDLE);
|
||||
itr->first->GetMotionMaster()->MoveIdle();
|
||||
sLog->outDebug(LOG_FILTER_UNITS, "Set %s movement for member GUID: %u", dismiss ? "default" : "idle", itr->first->GetGUIDLow());
|
||||
}
|
||||
}
|
||||
@@ -212,10 +212,12 @@ void CreatureGroup::FormationReset(bool dismiss)
|
||||
|
||||
void CreatureGroup::LeaderMoveTo(float x, float y, float z)
|
||||
{
|
||||
//! To do: This should probably get its own movement generator or use WaypointMovementGenerator.
|
||||
//! If the leader's path is known, member's path can be plotted as well using formation offsets.
|
||||
if (!m_leader)
|
||||
return;
|
||||
|
||||
float pathangle = atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x);
|
||||
float pathangle = atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x);
|
||||
|
||||
for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
|
||||
{
|
||||
|
||||
@@ -974,7 +974,7 @@ void GameObject::ResetDoorOrButton()
|
||||
m_cooldownTime = 0;
|
||||
}
|
||||
|
||||
void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */)
|
||||
void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */, Unit* user /*=NULL*/)
|
||||
{
|
||||
if (m_lootState != GO_READY)
|
||||
return;
|
||||
@@ -983,7 +983,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
|
||||
time_to_restore = GetGOInfo()->GetAutoCloseTime();
|
||||
|
||||
SwitchDoorOrButton(true, alternative);
|
||||
SetLootState(GO_ACTIVATED);
|
||||
SetLootState(GO_ACTIVATED, user);
|
||||
|
||||
m_cooldownTime = time(NULL) + time_to_restore;
|
||||
}
|
||||
@@ -1053,7 +1053,7 @@ void GameObject::Use(Unit* user)
|
||||
case GAMEOBJECT_TYPE_DOOR: //0
|
||||
case GAMEOBJECT_TYPE_BUTTON: //1
|
||||
//doors/buttons never really despawn, only reset to default state/flags
|
||||
UseDoorOrButton();
|
||||
UseDoorOrButton(0, false, user);
|
||||
|
||||
// activate script
|
||||
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
|
||||
@@ -1206,7 +1206,7 @@ void GameObject::Use(Unit* user)
|
||||
TriggeringLinkedGameObject(trapEntry, user);
|
||||
|
||||
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||
SetLootState(GO_ACTIVATED);
|
||||
SetLootState(GO_ACTIVATED, user);
|
||||
|
||||
// this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
|
||||
if (info->goober.customAnim)
|
||||
@@ -1864,3 +1864,9 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameObject::SetLootState(LootState s, Unit* unit)
|
||||
{
|
||||
m_lootState = s;
|
||||
AI()->OnStateChanged(s, unit);
|
||||
}
|
||||
@@ -714,7 +714,8 @@ class GameObject : public WorldObject, public GridObject<GameObject>
|
||||
void Use(Unit* user);
|
||||
|
||||
LootState getLootState() const { return m_lootState; }
|
||||
void SetLootState(LootState s) { m_lootState = s; }
|
||||
// Note: unit is only used when s = GO_ACTIVATED
|
||||
void SetLootState(LootState s, Unit* unit = NULL);
|
||||
|
||||
uint16 GetLootMode() { return m_LootMode; }
|
||||
bool HasLootMode(uint16 lootMode) { return m_LootMode & lootMode; }
|
||||
@@ -748,7 +749,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>
|
||||
bool hasQuest(uint32 quest_id) const;
|
||||
bool hasInvolvedQuest(uint32 quest_id) const;
|
||||
bool ActivateToQuest(Player* target) const;
|
||||
void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false);
|
||||
void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false, Unit* user = NULL);
|
||||
// 0 = use `gameobject`.`spawntimesecs`
|
||||
void ResetDoorOrButton();
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "TemporarySummon.h"
|
||||
#include "Totem.h"
|
||||
#include "OutdoorPvPMgr.h"
|
||||
#include "MovementPacketBuilder.h"
|
||||
|
||||
uint32 GuidHigh2TypeId(uint32 guid_hi)
|
||||
{
|
||||
@@ -309,65 +310,9 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const
|
||||
*data << self->GetSpeed(MOVE_TURN_RATE);
|
||||
*data << self->GetSpeed(MOVE_PITCH_RATE);
|
||||
|
||||
Player const* player = ToPlayer();
|
||||
|
||||
// 0x08000000
|
||||
if (player && player->isInFlight())
|
||||
{
|
||||
uint32 flags3 = SPLINEFLAG_GLIDE;
|
||||
|
||||
*data << uint32(flags3); // splines flag
|
||||
|
||||
if (flags3 & 0x00004000) // FinalOrientation
|
||||
{
|
||||
*data << (float)0;
|
||||
}
|
||||
else if (flags3 & 0x00001000) // FinalOrientation
|
||||
{
|
||||
*data << (float)0;
|
||||
*data << (float)0;
|
||||
*data << (float)0;
|
||||
}
|
||||
else if (flags3 & 0x00002000) // FinalTarget
|
||||
{
|
||||
*data << uint64(0);
|
||||
}
|
||||
|
||||
FlightPathMovementGenerator *fmg = (FlightPathMovementGenerator*)(player->GetMotionMaster()->top());
|
||||
TaxiPathNodeList const& path = fmg->GetPath();
|
||||
|
||||
float x, y, z;
|
||||
player->GetPosition(x, y, z);
|
||||
|
||||
uint32 inflighttime = uint32(path.GetPassedLength(fmg->GetCurrentNode(), x, y, z) * 32);
|
||||
uint32 traveltime = uint32(path.GetTotalLength() * 32);
|
||||
|
||||
*data << uint32(inflighttime); // passed move time?
|
||||
*data << uint32(traveltime); // full move time?
|
||||
*data << uint32(0); // ticks count?
|
||||
|
||||
*data << float(0); // added in 3.1
|
||||
*data << float(0); // added in 3.1
|
||||
*data << float(0); // added in 3.1
|
||||
|
||||
*data << uint32(0); // added in 3.1
|
||||
|
||||
uint32 poscount = uint32(path.size());
|
||||
*data << uint32(poscount); // points count
|
||||
|
||||
for (uint32 i = 0; i < poscount; ++i)
|
||||
{
|
||||
*data << float(path[i].x);
|
||||
*data << float(path[i].y);
|
||||
*data << float(path[i].z);
|
||||
}
|
||||
|
||||
*data << uint8(0); // added in 3.0.8
|
||||
|
||||
*data << float(path[poscount-1].x);
|
||||
*data << float(path[poscount-1].y);
|
||||
*data << float(path[poscount-1].z);
|
||||
}
|
||||
if (self->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_SPLINE_ENABLED))
|
||||
Movement::PacketBuilder::WriteCreate(*self->movespline, *data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1549,6 +1494,70 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
|
||||
z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface
|
||||
}
|
||||
|
||||
void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
|
||||
{
|
||||
switch (GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
{
|
||||
// non fly unit don't must be in air
|
||||
// non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast
|
||||
if (!((Creature const*)this)->canFly())
|
||||
{
|
||||
bool canSwim = ((Creature const*)this)->canSwim();
|
||||
float ground_z = z;
|
||||
float max_z = canSwim
|
||||
? GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK))
|
||||
: ((ground_z = GetBaseMap()->GetHeight(x, y, z, true)));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPEID_PLAYER:
|
||||
{
|
||||
// for server controlled moves playr work same as creature (but it can always swim)
|
||||
if (!((Player const*)this)->canFly())
|
||||
{
|
||||
float ground_z = z;
|
||||
float max_z = GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
{
|
||||
if (z > max_z)
|
||||
z = max_z;
|
||||
else if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
|
||||
if(ground_z > INVALID_HEIGHT)
|
||||
z = ground_z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Position::IsPositionValid() const
|
||||
{
|
||||
return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation);
|
||||
@@ -1987,7 +1996,8 @@ void Unit::BuildHeartBeatMsg(WorldPacket* data) const
|
||||
|
||||
void WorldObject::SendMessageToSet(WorldPacket* data, bool self)
|
||||
{
|
||||
SendMessageToSetInRange(data, GetVisibilityRange(), self);
|
||||
if (IsInWorld())
|
||||
SendMessageToSetInRange(data, GetVisibilityRange(), self);
|
||||
}
|
||||
|
||||
void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/)
|
||||
@@ -2475,7 +2485,7 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float
|
||||
{
|
||||
GetNearPoint2D(x, y, distance2d+searcher_size, absAngle);
|
||||
z = GetPositionZ();
|
||||
UpdateGroundPositionZ(x, y, z);
|
||||
UpdateAllowedPositionZ(x, y, z);
|
||||
|
||||
/*
|
||||
// if detection disabled, return first point
|
||||
|
||||
@@ -497,7 +497,9 @@ struct MovementInfo
|
||||
}
|
||||
|
||||
uint32 GetMovementFlags() { return flags; }
|
||||
void SetMovementFlags(uint32 flag) { flags = flag; }
|
||||
void AddMovementFlag(uint32 flag) { flags |= flag; }
|
||||
void RemoveMovementFlag(uint32 flag) { flags &= ~flag; }
|
||||
bool HasMovementFlag(uint32 flag) const { return flags & flag; }
|
||||
|
||||
uint16 GetExtraMovementFlags() { return flags2; }
|
||||
@@ -615,6 +617,7 @@ class WorldObject : public Object, public WorldLocation
|
||||
return (m_valuesCount > UNIT_FIELD_COMBATREACH) ? m_floatValues[UNIT_FIELD_COMBATREACH] : DEFAULT_WORLD_OBJECT_SIZE;
|
||||
}
|
||||
void UpdateGroundPositionZ(float x, float y, float &z) const;
|
||||
void UpdateAllowedPositionZ(float x, float y, float &z) const;
|
||||
|
||||
void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const;
|
||||
void GetRandomPoint(const Position &srcPos, float distance, Position &pos) const
|
||||
|
||||
@@ -297,15 +297,24 @@ Item* TradeData::GetItem(TradeSlots slot) const
|
||||
return m_items[slot] ? m_player->GetItemByGuid(m_items[slot]) : NULL;
|
||||
}
|
||||
|
||||
bool TradeData::HasItem(uint64 item_guid) const
|
||||
bool TradeData::HasItem(uint64 itemGuid) const
|
||||
{
|
||||
for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i)
|
||||
if (m_items[i] == item_guid)
|
||||
if (m_items[i] == itemGuid)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
TradeSlots TradeData::GetTradeSlotForItem(uint64 itemGuid) const
|
||||
{
|
||||
for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i)
|
||||
if (m_items[i] == itemGuid)
|
||||
return TradeSlots(i);
|
||||
|
||||
return TRADE_SLOT_INVALID;
|
||||
}
|
||||
|
||||
Item* TradeData::GetSpellCastItem() const
|
||||
{
|
||||
return m_spellCastItem ? m_player->GetItemByGuid(m_spellCastItem) : NULL;
|
||||
@@ -2179,6 +2188,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
|
||||
// reset movement flags at teleport, because player will continue move with these flags after teleport
|
||||
SetUnitMovementFlags(0);
|
||||
DisableSpline();
|
||||
|
||||
if (m_transport)
|
||||
{
|
||||
@@ -2387,9 +2397,14 @@ bool Player::TeleportToBGEntryPoint()
|
||||
if (m_bgData.joinPos.m_mapId == MAPID_INVALID)
|
||||
return false;
|
||||
|
||||
Group* group = GetGroup();
|
||||
if (group && group->isLFGGroup() && group->GetMembersCount() == 1)
|
||||
group->Disband();
|
||||
else
|
||||
ScheduleDelayedOperation(DELAYED_BG_GROUP_RESTORE);
|
||||
|
||||
ScheduleDelayedOperation(DELAYED_BG_MOUNT_RESTORE);
|
||||
ScheduleDelayedOperation(DELAYED_BG_TAXI_RESTORE);
|
||||
ScheduleDelayedOperation(DELAYED_BG_GROUP_RESTORE);
|
||||
return TeleportTo(m_bgData.joinPos);
|
||||
}
|
||||
|
||||
@@ -5240,43 +5255,10 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* FallMode = 0 implies that the player is dying, or already dead, and the proper death state will be set.
|
||||
* = 1 simply causes the player to plummet towards the ground, and not suffer any damage.
|
||||
* = 2 causes the player to plummet towards the ground, and causes falling damage, regardless
|
||||
* of any auras that might of prevented fall damage.
|
||||
*/
|
||||
bool Player::FallGround(uint8 FallMode)
|
||||
{
|
||||
// Let's abort after we called this function one time
|
||||
if (getDeathState() == DEAD_FALLING && FallMode == 0)
|
||||
return false;
|
||||
|
||||
float x, y, z;
|
||||
GetPosition(x, y, z);
|
||||
float ground_Z = GetMap()->GetHeight(x, y, z);
|
||||
float z_diff = 0.0f;
|
||||
if ((z_diff = fabs(ground_Z - z)) < 0.1f)
|
||||
return false;
|
||||
|
||||
GetMotionMaster()->MoveFall(ground_Z, EVENT_FALL_GROUND);
|
||||
|
||||
// Below formula for falling damage is from Player::HandleFall
|
||||
if (FallMode == 2 && z_diff >= 14.57f)
|
||||
{
|
||||
uint32 damage = std::min(GetMaxHealth(), (uint32)((0.018f * z_diff - 0.2426f) * GetMaxHealth() * sWorld->getRate(RATE_DAMAGE_FALL)));
|
||||
if (damage)
|
||||
EnvironmentalDamage(DAMAGE_FALL, damage);
|
||||
}
|
||||
else if (FallMode == 0)
|
||||
Unit::setDeathState(DEAD_FALLING);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Player::KillPlayer()
|
||||
{
|
||||
if (IsFlying() && !GetTransport())
|
||||
FallGround();
|
||||
i_motionMaster.MoveFall();
|
||||
|
||||
SetMovement(MOVE_ROOT);
|
||||
|
||||
@@ -7614,6 +7596,22 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
|
||||
SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange...
|
||||
}
|
||||
|
||||
// group update
|
||||
if (GetGroup())
|
||||
{
|
||||
SetGroupUpdateFlag(GROUP_UPDATE_FULL);
|
||||
Group* grp = GetGroup();
|
||||
if (GetSession() && grp->isLFGGroup() && sLFGMgr->IsTeleported(GetGUID()))
|
||||
{
|
||||
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
Player* tempplr = itr->getSource();
|
||||
if (tempplr)
|
||||
GetSession()->SendNameQueryOpcode(tempplr->GetGUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_zoneUpdateId = newZone;
|
||||
m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL;
|
||||
|
||||
@@ -7701,10 +7699,6 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
|
||||
// recent client version not send leave/join channel packets for built-in local channels
|
||||
UpdateLocalChannels(newZone);
|
||||
|
||||
// group update
|
||||
if (GetGroup())
|
||||
SetGroupUpdateFlag(GROUP_UPDATE_FULL);
|
||||
|
||||
UpdateZoneDependentAuras(newZone);
|
||||
}
|
||||
|
||||
@@ -8856,7 +8850,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
|
||||
}
|
||||
}
|
||||
|
||||
go->SetLootState(GO_ACTIVATED);
|
||||
go->SetLootState(GO_ACTIVATED, this);
|
||||
}
|
||||
|
||||
if (go->getLootState() == GO_ACTIVATED)
|
||||
@@ -11955,6 +11949,93 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
|
||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
}
|
||||
|
||||
InventoryResult Player::CanRollForItemInLFG(ItemTemplate const* proto, WorldObject const* lootedObject) const
|
||||
{
|
||||
LfgDungeonSet const& dungeons = sLFGMgr->GetSelectedDungeons(GetGUID());
|
||||
if (dungeons.empty())
|
||||
return EQUIP_ERR_OK; // not using LFG
|
||||
|
||||
if (!GetGroup() || !GetGroup()->isLFGGroup())
|
||||
return EQUIP_ERR_OK; // not in LFG group
|
||||
|
||||
// check if looted object is inside the lfg dungeon
|
||||
bool lootedObjectInDungeon = false;
|
||||
Map const* map = lootedObject->GetMap();
|
||||
if (uint32 dungeonId = sLFGMgr->GetDungeon(GetGroup()->GetGUID(), true))
|
||||
if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId))
|
||||
if (dungeon->map == map->GetId() && dungeon->difficulty == map->GetDifficulty())
|
||||
lootedObjectInDungeon = true;
|
||||
|
||||
if (!lootedObjectInDungeon)
|
||||
return EQUIP_ERR_OK;
|
||||
|
||||
if (!proto)
|
||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
// Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player
|
||||
|
||||
const static uint32 item_weapon_skills[MAX_ITEM_SUBCLASS_WEAPON] =
|
||||
{
|
||||
SKILL_AXES, SKILL_2H_AXES, SKILL_BOWS, SKILL_GUNS, SKILL_MACES,
|
||||
SKILL_2H_MACES, SKILL_POLEARMS, SKILL_SWORDS, SKILL_2H_SWORDS, 0,
|
||||
SKILL_STAVES, 0, 0, SKILL_FIST_WEAPONS, 0,
|
||||
SKILL_DAGGERS, SKILL_THROWN, SKILL_ASSASSINATION, SKILL_CROSSBOWS, SKILL_WANDS,
|
||||
SKILL_FISHING
|
||||
}; //Copy from function Item::GetSkill()
|
||||
|
||||
if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getRaceMask()) == 0)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if (proto->RequiredSpell != 0 && !HasSpell(proto->RequiredSpell))
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
|
||||
if (proto->RequiredSkill != 0)
|
||||
{
|
||||
if (!GetSkillValue(proto->RequiredSkill))
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
else if (GetSkillValue(proto->RequiredSkill) < proto->RequiredSkillRank)
|
||||
return EQUIP_ERR_CANT_EQUIP_SKILL;
|
||||
}
|
||||
|
||||
uint8 _class = getClass();
|
||||
|
||||
if (proto->Class == ITEM_CLASS_WEAPON && GetSkillValue(item_weapon_skills[proto->SubClass]) == 0)
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
|
||||
if (proto->Class == ITEM_CLASS_ARMOR && proto->SubClass > ITEM_SUBCLASS_ARMOR_MISCELLANEOUS && proto->SubClass < ITEM_SUBCLASS_ARMOR_BUCKLER && proto->InventoryType != INVTYPE_CLOAK)
|
||||
{
|
||||
if (_class == CLASS_WARRIOR || _class == CLASS_PALADIN || _class == CLASS_DEATH_KNIGHT)
|
||||
{
|
||||
if (getLevel() < 40)
|
||||
{
|
||||
if (proto->SubClass != ITEM_SUBCLASS_ARMOR_MAIL)
|
||||
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
||||
}
|
||||
else if (proto->SubClass != ITEM_SUBCLASS_ARMOR_PLATE)
|
||||
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
||||
}
|
||||
else if (_class == CLASS_HUNTER || _class == CLASS_SHAMAN)
|
||||
{
|
||||
if (getLevel() < 40)
|
||||
{
|
||||
if (proto->SubClass != ITEM_SUBCLASS_ARMOR_LEATHER)
|
||||
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
||||
}
|
||||
else if (proto->SubClass != ITEM_SUBCLASS_ARMOR_MAIL)
|
||||
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
||||
}
|
||||
|
||||
if (_class == CLASS_ROGUE || _class == CLASS_DRUID)
|
||||
if (proto->SubClass != ITEM_SUBCLASS_ARMOR_LEATHER)
|
||||
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
||||
|
||||
if (_class == CLASS_MAGE || _class == CLASS_PRIEST || _class == CLASS_WARLOCK)
|
||||
if (proto->SubClass != ITEM_SUBCLASS_ARMOR_CLOTH)
|
||||
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
|
||||
}
|
||||
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId)
|
||||
{
|
||||
AllowedLooterSet allowedLooters;
|
||||
@@ -12797,6 +12878,14 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
|
||||
return;
|
||||
}
|
||||
|
||||
//! If trading
|
||||
if (TradeData* tradeData = GetTradeData())
|
||||
{
|
||||
//! If current item is in trade window (only possible with packet spoofing - silent return)
|
||||
if (tradeData->GetTradeSlotForItem(pSrcItem->GetGUID()) != TRADE_SLOT_INVALID)
|
||||
return;
|
||||
}
|
||||
|
||||
sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: SplitItem bag = %u, slot = %u, item = %u, count = %u", dstbag, dstslot, pSrcItem->GetEntry(), count);
|
||||
Item* pNewItem = pSrcItem->CloneItem(count, this);
|
||||
if (!pNewItem)
|
||||
@@ -12825,7 +12914,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
|
||||
pSrcItem->SetState(ITEM_CHANGED, this);
|
||||
StoreItem(dest, pNewItem, true);
|
||||
}
|
||||
else if (IsBankPos (dst))
|
||||
else if (IsBankPos(dst))
|
||||
{
|
||||
// change item amount before check (for unique max count check)
|
||||
pSrcItem->SetCount(pSrcItem->GetCount() - count);
|
||||
@@ -12845,7 +12934,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count)
|
||||
pSrcItem->SetState(ITEM_CHANGED, this);
|
||||
BankItem(dest, pNewItem, true);
|
||||
}
|
||||
else if (IsEquipmentPos (dst))
|
||||
else if (IsEquipmentPos(dst))
|
||||
{
|
||||
// change item amount before check (for unique max count check), provide space for splitted items
|
||||
pSrcItem->SetCount(pSrcItem->GetCount() - count);
|
||||
@@ -14055,6 +14144,10 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
|
||||
PrepareQuestMenu(source->GetGUID());
|
||||
}
|
||||
|
||||
if (source->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
if (source->ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER)
|
||||
PrepareQuestMenu(source->GetGUID());
|
||||
|
||||
for (GossipMenuItemsMap::const_iterator itr = menuItemBounds.first; itr != menuItemBounds.second; ++itr)
|
||||
{
|
||||
bool canTalk = true;
|
||||
@@ -14140,11 +14233,6 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
|
||||
|
||||
switch (itr->second.OptionType)
|
||||
{
|
||||
case GOSSIP_OPTION_QUESTGIVER:
|
||||
if (go->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER)
|
||||
PrepareQuestMenu(source->GetGUID());
|
||||
canTalk = false;
|
||||
break;
|
||||
case GOSSIP_OPTION_GOSSIP:
|
||||
if (go->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER && go->GetGoType() != GAMEOBJECT_TYPE_GOOBER)
|
||||
canTalk = false;
|
||||
@@ -16751,6 +16839,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
_LoadInstanceTimeRestrictions(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADINSTANCELOCKTIMES));
|
||||
_LoadBGData(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADBGDATA));
|
||||
|
||||
GetSession()->SetPlayer(this);
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
|
||||
if (!mapEntry || !IsPositionValid())
|
||||
{
|
||||
@@ -21577,8 +21666,6 @@ void Player::SendInitialVisiblePackets(Unit* target)
|
||||
SendAurasForTarget(target);
|
||||
if (target->isAlive())
|
||||
{
|
||||
if (target->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE)
|
||||
target->SendMonsterMoveWithSpeedToCurrentDestination(this);
|
||||
if (target->HasUnitState(UNIT_STAT_MELEE_ATTACKING) && target->getVictim())
|
||||
target->SendMeleeAttackStart(target->getVictim());
|
||||
}
|
||||
@@ -21836,7 +21923,9 @@ void Player::SendInitialPacketsBeforeAddToMap()
|
||||
// SMSG_PET_GUIDS
|
||||
// SMSG_UPDATE_WORLD_STATE
|
||||
// SMSG_POWER_UPDATE
|
||||
|
||||
SendCurrencies();
|
||||
SetMover(this);
|
||||
}
|
||||
|
||||
void Player::SendInitialPacketsAfterAddToMap()
|
||||
|
||||
@@ -290,13 +290,14 @@ struct PvPInfo
|
||||
|
||||
struct DuelInfo
|
||||
{
|
||||
DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {}
|
||||
DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0), isMounted(false) {}
|
||||
|
||||
Player* initiator;
|
||||
Player* opponent;
|
||||
time_t startTimer;
|
||||
time_t startTime;
|
||||
time_t outOfBound;
|
||||
bool isMounted;
|
||||
};
|
||||
|
||||
struct Areas
|
||||
@@ -702,7 +703,8 @@ enum TradeSlots
|
||||
{
|
||||
TRADE_SLOT_COUNT = 7,
|
||||
TRADE_SLOT_TRADED_COUNT = 6,
|
||||
TRADE_SLOT_NONTRADED = 6
|
||||
TRADE_SLOT_NONTRADED = 6,
|
||||
TRADE_SLOT_INVALID = -1,
|
||||
};
|
||||
|
||||
enum TransferAbortReason
|
||||
@@ -1013,7 +1015,8 @@ class TradeData
|
||||
TradeData* GetTraderData() const;
|
||||
|
||||
Item* GetItem(TradeSlots slot) const;
|
||||
bool HasItem(uint64 item_guid) const;
|
||||
bool HasItem(uint64 itemGuid) const;
|
||||
TradeSlots GetTradeSlotForItem(uint64 itemGuid) const;
|
||||
void SetItem(TradeSlots slot, Item* item);
|
||||
|
||||
uint32 GetSpell() const { return m_spell; }
|
||||
@@ -1333,6 +1336,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
bool HasItemTotemCategory(uint32 TotemCategory) const;
|
||||
InventoryResult CanUseItem(ItemTemplate const* pItem) const;
|
||||
InventoryResult CanUseAmmo(uint32 item) const;
|
||||
InventoryResult CanRollForItemInLFG(ItemTemplate const* item, WorldObject const* lootedObject) const;
|
||||
Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0);
|
||||
Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet &allowedLooters);
|
||||
Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update);
|
||||
@@ -2046,7 +2050,6 @@ class Player : public Unit, public GridObject<Player>
|
||||
Corpse* GetCorpse() const;
|
||||
void SpawnCorpseBones();
|
||||
void CreateCorpse();
|
||||
bool FallGround(uint8 FallMode = 0);
|
||||
void KillPlayer();
|
||||
uint32 GetResurrectionSpellId();
|
||||
void ResurrectPlayer(float restore_percent, bool applySickness = false);
|
||||
|
||||
@@ -45,16 +45,16 @@
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "CellImpl.h"
|
||||
#include "Path.h"
|
||||
#include "CreatureGroups.h"
|
||||
#include "PetAI.h"
|
||||
#include "PassiveAI.h"
|
||||
#include "Traveller.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Vehicle.h"
|
||||
#include "Transport.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "MoveSpline.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@@ -62,9 +62,9 @@ float baseMoveSpeed[MAX_MOVE_TYPE] =
|
||||
{
|
||||
2.5f, // MOVE_WALK
|
||||
7.0f, // MOVE_RUN
|
||||
2.5f, // MOVE_RUN_BACK
|
||||
4.5f, // MOVE_RUN_BACK
|
||||
4.722222f, // MOVE_SWIM
|
||||
4.5f, // MOVE_SWIM_BACK
|
||||
2.5f, // MOVE_SWIM_BACK
|
||||
3.141594f, // MOVE_TURN_RATE
|
||||
7.0f, // MOVE_FLIGHT
|
||||
4.5f, // MOVE_FLIGHT_BACK
|
||||
@@ -73,9 +73,9 @@ float baseMoveSpeed[MAX_MOVE_TYPE] =
|
||||
float playerBaseMoveSpeed[MAX_MOVE_TYPE] = {
|
||||
2.5f, // MOVE_WALK
|
||||
7.0f, // MOVE_RUN
|
||||
2.5f, // MOVE_RUN_BACK
|
||||
4.5f, // MOVE_RUN_BACK
|
||||
4.722222f, // MOVE_SWIM
|
||||
4.5f, // MOVE_SWIM_BACK
|
||||
2.5f, // MOVE_SWIM_BACK
|
||||
3.141594f, // MOVE_TURN_RATE
|
||||
7.0f, // MOVE_FLIGHT
|
||||
4.5f, // MOVE_FLIGHT_BACK
|
||||
@@ -148,7 +148,7 @@ Unit::Unit(bool isWorldObject): WorldObject(isWorldObject),
|
||||
m_movedPlayer(NULL), m_lastSanctuaryTime(0), IsAIEnabled(false), NeedChangeAI(false),
|
||||
m_ControlledByPlayer(false), i_AI(NULL), i_disabledAI(NULL), m_procDeep(0),
|
||||
m_removedAurasCount(0), i_motionMaster(this), m_ThreatManager(this), m_vehicle(NULL),
|
||||
m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this)
|
||||
m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this), movespline(new Movement::MoveSpline())
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4355)
|
||||
@@ -280,6 +280,7 @@ Unit::~Unit()
|
||||
|
||||
delete m_charmInfo;
|
||||
delete m_vehicleKit;
|
||||
delete movespline;
|
||||
|
||||
ASSERT(!m_duringRemoveFromWorld);
|
||||
ASSERT(!m_attacking);
|
||||
@@ -346,6 +347,7 @@ void Unit::Update(uint32 p_time)
|
||||
ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, HealthAbovePct(75));
|
||||
}
|
||||
|
||||
UpdateSplineMovement(p_time);
|
||||
i_motionMaster.UpdateMotion(p_time);
|
||||
}
|
||||
|
||||
@@ -357,151 +359,46 @@ bool Unit::haveOffhandWeapon() const
|
||||
return m_canDualWield;
|
||||
}
|
||||
|
||||
void Unit::SendMonsterMoveWithSpeedToCurrentDestination(Player* player)
|
||||
void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed)
|
||||
{
|
||||
float x, y, z;
|
||||
if (GetMotionMaster()->GetDestination(x, y, z))
|
||||
SendMonsterMoveWithSpeed(x, y, z, 0, player);
|
||||
Movement::MoveSplineInit init(*this);
|
||||
init.MoveTo(x,y,z);
|
||||
init.SetVelocity(speed);
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime, Player* player)
|
||||
void Unit::UpdateSplineMovement(uint32 t_diff)
|
||||
{
|
||||
if (!transitTime)
|
||||
enum{
|
||||
POSITION_UPDATE_DELAY = 400,
|
||||
};
|
||||
|
||||
if (movespline->Finalized())
|
||||
return;
|
||||
|
||||
movespline->updateState(t_diff);
|
||||
bool arrived = movespline->Finalized();
|
||||
|
||||
if (arrived)
|
||||
DisableSpline();
|
||||
|
||||
m_movesplineTimer.Update(t_diff);
|
||||
if (m_movesplineTimer.Passed() || arrived)
|
||||
{
|
||||
m_movesplineTimer.Reset(POSITION_UPDATE_DELAY);
|
||||
Movement::Location loc = movespline->ComputePosition();
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
Traveller<Player> traveller(*(Player*)this);
|
||||
transitTime = traveller.GetTotalTrevelTimeTo(x, y, z);
|
||||
}
|
||||
((Player*)this)->UpdatePosition(loc.x,loc.y,loc.z,loc.orientation);
|
||||
else
|
||||
{
|
||||
Traveller<Creature> traveller(*ToCreature());
|
||||
transitTime = traveller.GetTotalTrevelTimeTo(x, y, z);
|
||||
}
|
||||
GetMap()->CreatureRelocation((Creature*)this,loc.x,loc.y,loc.z,loc.orientation);
|
||||
}
|
||||
//float orientation = (float)atan2((double)dy, (double)dx);
|
||||
SendMonsterMove(x, y, z, transitTime, player);
|
||||
}
|
||||
|
||||
void Unit::SetFacing(float ori, WorldObject* obj)
|
||||
void Unit::DisableSpline()
|
||||
{
|
||||
SetOrientation(obj ? GetAngle(obj) : ori);
|
||||
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, (1+12+4+1+(obj ? 8 : 4)+4+4+4+12+GetPackGUID().size()));
|
||||
data.append(GetPackGUID());
|
||||
data << uint8(0); // unk
|
||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||
data << getMSTime();
|
||||
if (obj)
|
||||
{
|
||||
data << uint8(SPLINETYPE_FACING_TARGET);
|
||||
data << uint64(obj->GetGUID());
|
||||
}
|
||||
else
|
||||
{
|
||||
data << uint8(SPLINETYPE_FACING_ANGLE);
|
||||
data << ori;
|
||||
}
|
||||
data << uint32(SPLINEFLAG_NONE);
|
||||
data << uint32(0); // move time 0
|
||||
data << uint32(1); // one point
|
||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void Unit::SendMonsterStop(bool on_death)
|
||||
{
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, (17 + GetPackGUID().size()));
|
||||
data.append(GetPackGUID());
|
||||
data << uint8(0); // new in 3.1
|
||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||
data << getMSTime();
|
||||
|
||||
if (on_death == true)
|
||||
{
|
||||
data << uint8(0);
|
||||
data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? SPLINEFLAG_FLYING : SPLINEFLAG_WALKING);
|
||||
data << uint32(0); // Time in between points
|
||||
data << uint32(1); // 1 single waypoint
|
||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||
}
|
||||
else
|
||||
data << uint8(1);
|
||||
|
||||
SendMessageToSet(&data, true);
|
||||
|
||||
ClearUnitState(UNIT_STAT_MOVE);
|
||||
}
|
||||
|
||||
void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player)
|
||||
{
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, 1+12+4+1+4+4+4+12+GetPackGUID().size());
|
||||
data.append(GetPackGUID());
|
||||
|
||||
data << uint8(0); // new in 3.1
|
||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||
data << getMSTime();
|
||||
|
||||
data << uint8(0);
|
||||
data << uint32((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) ? SPLINEFLAG_FLYING : SPLINEFLAG_WALKING);
|
||||
data << Time; // Time in between points
|
||||
data << uint32(1); // 1 single waypoint
|
||||
data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B
|
||||
|
||||
if (player)
|
||||
player->GetSession()->SendPacket(&data);
|
||||
else
|
||||
SendMessageToSet(&data, true);
|
||||
|
||||
AddUnitState(UNIT_STAT_MOVE);
|
||||
}
|
||||
|
||||
void Unit::SendMonsterMove(MonsterMoveData const& moveData, Player* player)
|
||||
{
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, GetPackGUID().size() + 1 + 12 + 4 + 1 + 4 + 8 + 4 + 4 + 12);
|
||||
data.append(GetPackGUID());
|
||||
|
||||
data << uint8(0); // new in 3.1
|
||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||
data << getMSTime();
|
||||
|
||||
data << uint8(0);
|
||||
data << moveData.SplineFlag;
|
||||
|
||||
if (moveData.SplineFlag & SPLINEFLAG_ANIMATIONTIER)
|
||||
{
|
||||
data << uint8(moveData.AnimationState);
|
||||
data << uint32(0);
|
||||
}
|
||||
|
||||
data << moveData.Time;
|
||||
|
||||
if (moveData.SplineFlag & SPLINEFLAG_TRAJECTORY)
|
||||
{
|
||||
data << moveData.SpeedZ;
|
||||
data << uint32(0); // walk time after jump
|
||||
}
|
||||
|
||||
data << uint32(1); // waypoint count
|
||||
data << moveData.DestLocation.GetPositionX();
|
||||
data << moveData.DestLocation.GetPositionY();
|
||||
data << moveData.DestLocation.GetPositionZ();
|
||||
|
||||
if (player)
|
||||
player->GetSession()->SendPacket(&data);
|
||||
else
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 MoveFlags, uint32 time, float speedZ, Player* player)
|
||||
{
|
||||
MonsterMoveData data;
|
||||
data.DestLocation.Relocate(NewPosX, NewPosY, NewPosZ);
|
||||
data.SplineFlag = MoveFlags;
|
||||
data.Time = time;
|
||||
data.SpeedZ = speedZ;
|
||||
|
||||
SendMonsterMove(data, player);
|
||||
m_movementInfo.RemoveMovementFlag(MovementFlags(MOVEMENTFLAG_SPLINE_ENABLED|MOVEMENTFLAG_FORWARD));
|
||||
movespline->_Interrupt();
|
||||
}
|
||||
|
||||
void Unit::SendMonsterMoveExitVehicle(Position const* newPos)
|
||||
@@ -731,6 +628,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
|
||||
|
||||
// duel ends when player has 1 or less hp
|
||||
bool duel_hasEnded = false;
|
||||
bool duel_wasMounted = false;
|
||||
if (victim->GetTypeId() == TYPEID_PLAYER && victim->ToPlayer()->duel && damage >= (health-1))
|
||||
{
|
||||
// prevent kill only if killed in duel and killed by opponent or opponent controlled creature
|
||||
@@ -739,6 +637,20 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
|
||||
|
||||
duel_hasEnded = true;
|
||||
}
|
||||
else if (victim->IsVehicle() && damage >= (health-1) && victim->GetCharmer() && victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
Player* victimRider = victim->GetCharmer()->ToPlayer();
|
||||
|
||||
if (victimRider && victimRider->duel && victimRider->duel->isMounted)
|
||||
{
|
||||
// prevent kill only if killed in duel and killed by opponent or opponent controlled creature
|
||||
if (victimRider->duel->opponent == this || victimRider->duel->opponent->GetGUID() == GetCharmerGUID())
|
||||
damage = health - 1;
|
||||
|
||||
duel_wasMounted = true;
|
||||
duel_hasEnded = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER && this != victim)
|
||||
{
|
||||
@@ -848,8 +760,18 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
|
||||
// last damage from duel opponent
|
||||
if (duel_hasEnded)
|
||||
{
|
||||
ASSERT(victim->GetTypeId() == TYPEID_PLAYER);
|
||||
Player* he = victim->ToPlayer();
|
||||
Player* he;
|
||||
|
||||
if (duel_wasMounted)
|
||||
{
|
||||
ASSERT(victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER);
|
||||
he = victim->GetCharmer()->ToPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(victim->GetTypeId() == TYPEID_PLAYER);
|
||||
he = victim->ToPlayer();
|
||||
}
|
||||
|
||||
ASSERT(he->duel);
|
||||
|
||||
@@ -2226,12 +2148,12 @@ void Unit::SendMeleeAttackStart(Unit* victim)
|
||||
|
||||
void Unit::SendMeleeAttackStop(Unit* victim)
|
||||
{
|
||||
WorldPacket data(SMSG_ATTACKSTOP, (8+8+4)); // we guess size
|
||||
WorldPacket data(SMSG_ATTACKSTOP, (8+8+4));
|
||||
data.append(GetPackGUID());
|
||||
data.append(victim ? victim->GetPackGUID() : 0); // can be 0x00...
|
||||
data << uint32(0); // can be 0x1
|
||||
SendMessageToSet(&data, true);
|
||||
sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTART");
|
||||
sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTOP");
|
||||
|
||||
if (victim)
|
||||
sLog->outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow());
|
||||
@@ -3115,17 +3037,6 @@ bool Unit::isInBackInMap(Unit const* target, float distance, float arc) const
|
||||
return IsWithinDistInMap(target, distance) && !HasInArc(2 * M_PI - arc, target);
|
||||
}
|
||||
|
||||
void Unit::SetFacingToObject(WorldObject* pObject)
|
||||
{
|
||||
// update orientation at server
|
||||
SetOrientation(GetAngle(pObject));
|
||||
|
||||
// and client
|
||||
WorldPacket data;
|
||||
BuildHeartBeatMsg(&data);
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
|
||||
bool Unit::isInAccessiblePlaceFor(Creature const* c) const
|
||||
{
|
||||
if (IsInWater())
|
||||
@@ -7191,6 +7102,8 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
return false;
|
||||
basepoints0 = CalculatePctN(int32(damage), triggerAmount);
|
||||
triggered_spell_id = 58879;
|
||||
// Cast on spirit wolf
|
||||
CastCustomSpell(this, triggered_spell_id, &basepoints0, NULL, NULL, true, NULL, triggeredByAura);
|
||||
break;
|
||||
}
|
||||
// Shaman T8 Elemental 4P Bonus
|
||||
@@ -8947,18 +8860,17 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
|
||||
// Maelstrom Weapon
|
||||
case 53817:
|
||||
{
|
||||
// Item - Shaman T10 Enhancement 4P Bonus
|
||||
if (AuraEffect const* aurEff = GetAuraEffect(70832, 0))
|
||||
if (Aura const* maelstrom = GetAura(53817))
|
||||
if ((maelstrom->GetStackAmount() == maelstrom->GetSpellInfo()->StackAmount) && roll_chance_i(aurEff->GetAmount()))
|
||||
CastSpell(this, 70831, true, castItem, triggeredByAura);
|
||||
|
||||
// has rank dependant proc chance, ignore too often cases
|
||||
// PPM = 2.5 * (rank of talent),
|
||||
uint32 rank = auraSpellInfo->GetRank();
|
||||
// 5 rank -> 100% 4 rank -> 80% and etc from full rate
|
||||
if (!roll_chance_i(20*rank))
|
||||
return false;
|
||||
// Item - Shaman T10 Enhancement 4P Bonus
|
||||
if (AuraEffect const* aurEff = GetAuraEffect(70832, 0))
|
||||
if (Aura const* maelstrom = GetAura(53817))
|
||||
if ((maelstrom->GetStackAmount() == maelstrom->GetSpellInfo()->StackAmount - 1) && roll_chance_i(aurEff->GetAmount()))
|
||||
CastSpell(this, 70831, true, castItem, triggeredByAura);
|
||||
break;
|
||||
}
|
||||
// Astral Shift
|
||||
@@ -13150,7 +13062,7 @@ void Unit::setDeathState(DeathState s)
|
||||
ClearDiminishings();
|
||||
GetMotionMaster()->Clear(false);
|
||||
GetMotionMaster()->MoveIdle();
|
||||
SendMonsterStop(true);
|
||||
StopMoving();
|
||||
// without this when removing IncreaseMaxHealth aura player may stuck with 1 hp
|
||||
// do not why since in IncreaseMaxHealth currenthealth is checked
|
||||
SetHealth(0);
|
||||
@@ -13969,7 +13881,7 @@ void Unit::SetHealth(uint32 val)
|
||||
{
|
||||
if (getDeathState() == JUST_DIED)
|
||||
val = 0;
|
||||
else if (GetTypeId() == TYPEID_PLAYER && (getDeathState() == DEAD || getDeathState() == DEAD_FALLING))
|
||||
else if (GetTypeId() == TYPEID_PLAYER && getDeathState() == DEAD)
|
||||
val = 1;
|
||||
else
|
||||
{
|
||||
@@ -15145,22 +15057,20 @@ void Unit::StopMoving()
|
||||
{
|
||||
ClearUnitState(UNIT_STAT_MOVING);
|
||||
|
||||
// send explicit stop packet
|
||||
// rely on vmaps here because for example stormwind is in air
|
||||
//float z = sMapMgr->GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true);
|
||||
//if (fabs(GetPositionZ() - z) < 2.0f)
|
||||
// Relocate(GetPositionX(), GetPositionY(), z);
|
||||
//Relocate(GetPositionX(), GetPositionY(), GetPositionZ());
|
||||
// not need send any packets if not in world
|
||||
if (!IsInWorld())
|
||||
return;
|
||||
|
||||
if (!(GetUnitMovementFlags() & MOVEMENTFLAG_ONTRANSPORT))
|
||||
SendMonsterStop();
|
||||
Movement::MoveSplineInit init(*this);
|
||||
init.SetFacing(GetOrientation());
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
void Unit::SendMovementFlagUpdate()
|
||||
{
|
||||
WorldPacket data;
|
||||
BuildHeartBeatMsg(&data);
|
||||
SendMessageToSet(&data, false);
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
bool Unit::IsSitState() const
|
||||
@@ -16426,6 +16336,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
case CHARM_TYPE_VEHICLE:
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
charmer->ToPlayer()->SetClientControl(this, 1);
|
||||
charmer->ToPlayer()->SetMover(this);
|
||||
charmer->ToPlayer()->SetViewpoint(this, true);
|
||||
charmer->ToPlayer()->VehicleSpellInitialize();
|
||||
break;
|
||||
@@ -16434,6 +16345,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
charmer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
|
||||
charmer->ToPlayer()->SetClientControl(this, 1);
|
||||
charmer->ToPlayer()->SetMover(this);
|
||||
charmer->ToPlayer()->SetViewpoint(this, true);
|
||||
charmer->ToPlayer()->PossessSpellInitialize();
|
||||
break;
|
||||
@@ -16724,7 +16636,7 @@ void Unit::GetRaidMember(std::list<Unit*> &nearMembers, float radius)
|
||||
if (owner->isAlive() && (owner == this || IsWithinDistInMap(owner, radius)))
|
||||
nearMembers.push_back(owner);
|
||||
if (Guardian* pet = owner->GetGuardianPet())
|
||||
if (pet->isAlive() && (pet == this && IsWithinDistInMap(pet, radius)))
|
||||
if (pet->isAlive() && (pet == this || IsWithinDistInMap(pet, radius)))
|
||||
nearMembers.push_back(pet);
|
||||
}
|
||||
}
|
||||
@@ -16761,7 +16673,7 @@ void Unit::GetPartyMemberInDist(std::list<Unit*> &TagUnitMap, float radius)
|
||||
if (owner->isAlive() && (owner == this || IsWithinDistInMap(owner, radius)))
|
||||
TagUnitMap.push_back(owner);
|
||||
if (Guardian* pet = owner->GetGuardianPet())
|
||||
if (pet->isAlive() && (pet == this && IsWithinDistInMap(pet, radius)))
|
||||
if (pet->isAlive() && (pet == this || IsWithinDistInMap(pet, radius)))
|
||||
TagUnitMap.push_back(pet);
|
||||
}
|
||||
}
|
||||
@@ -17568,6 +17480,10 @@ void Unit::_ExitVehicle(Position const* exitPosition)
|
||||
|
||||
m_vehicle->RemovePassenger(this);
|
||||
|
||||
// If player is on mouted duel and exits the mount should immediatly lose the duel
|
||||
if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->duel && ToPlayer()->duel->isMounted)
|
||||
ToPlayer()->DuelComplete(DUEL_FLED);
|
||||
|
||||
// This should be done before dismiss, because there may be some aura removal
|
||||
Vehicle* vehicle = m_vehicle;
|
||||
m_vehicle = NULL;
|
||||
@@ -17599,7 +17515,7 @@ void Unit::_ExitVehicle(Position const* exitPosition)
|
||||
|
||||
WorldPacket data2;
|
||||
BuildHeartBeatMsg(&data2);
|
||||
SendMessageToSet(&data2, false);
|
||||
SendMessageToSet(&data2, true);
|
||||
|
||||
if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
|
||||
if (((Minion*)vehicle->GetBase())->GetOwner() == this)
|
||||
@@ -17729,13 +17645,13 @@ void Unit::SetFlying(bool apply)
|
||||
|
||||
void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/)
|
||||
{
|
||||
DisableSpline();
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
ToPlayer()->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0));
|
||||
else
|
||||
{
|
||||
// FIXME: this interrupts spell visual
|
||||
DestroyForNearbyPlayers();
|
||||
UpdatePosition(x, y, z, orientation, true);
|
||||
SendMovementFlagUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18017,3 +17933,26 @@ bool CharmInfo::IsReturning()
|
||||
{
|
||||
return m_isReturning;
|
||||
}
|
||||
|
||||
void Unit::SetInFront(Unit const* target)
|
||||
{
|
||||
if (!HasUnitState(UNIT_STAT_CANNOT_TURN))
|
||||
SetOrientation(GetAngle(target));
|
||||
}
|
||||
|
||||
void Unit::SetFacingTo(float ori)
|
||||
{
|
||||
Movement::MoveSplineInit init(*this);
|
||||
init.SetFacing(ori);
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
void Unit::SetFacingToObject(WorldObject* pObject)
|
||||
{
|
||||
// never face when already moving
|
||||
if (!IsStopped())
|
||||
return;
|
||||
|
||||
// TODO: figure out under what conditions creature will move towards object instead of facing it where it currently is.
|
||||
SetFacingTo(GetAngle(pObject));
|
||||
}
|
||||
@@ -465,7 +465,6 @@ enum DeathState
|
||||
CORPSE = 2,
|
||||
DEAD = 3,
|
||||
JUST_ALIVED = 4,
|
||||
DEAD_FALLING= 5
|
||||
};
|
||||
|
||||
enum UnitState
|
||||
@@ -493,13 +492,22 @@ enum UnitState
|
||||
UNIT_STAT_MOVE = 0x00100000,
|
||||
UNIT_STAT_ROTATING = 0x00200000,
|
||||
UNIT_STAT_EVADE = 0x00400000,
|
||||
UNIT_STAT_ROAMING_MOVE = 0x00800000,
|
||||
UNIT_STAT_CONFUSED_MOVE = 0x01000000,
|
||||
UNIT_STAT_FLEEING_MOVE = 0x02000000,
|
||||
UNIT_STAT_CHASE_MOVE = 0x04000000,
|
||||
UNIT_STAT_FOLLOW_MOVE = 0x08000000,
|
||||
UNIT_STAT_UNATTACKABLE = (UNIT_STAT_IN_FLIGHT | UNIT_STAT_ONVEHICLE),
|
||||
UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE),
|
||||
//UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE),
|
||||
// for real move using movegen check and stop (except unstoppable flight)
|
||||
UNIT_STAT_MOVING = UNIT_STAT_ROAMING_MOVE | UNIT_STAT_CONFUSED_MOVE | UNIT_STAT_FLEEING_MOVE| UNIT_STAT_CHASE_MOVE | UNIT_STAT_FOLLOW_MOVE ,
|
||||
UNIT_STAT_CONTROLLED = (UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING),
|
||||
UNIT_STAT_LOST_CONTROL = (UNIT_STAT_CONTROLLED | UNIT_STAT_JUMPING | UNIT_STAT_CHARGING),
|
||||
UNIT_STAT_SIGHTLESS = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_EVADE),
|
||||
UNIT_STAT_CANNOT_AUTOATTACK = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_CASTING),
|
||||
UNIT_STAT_CANNOT_TURN = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_ROTATING),
|
||||
// stay by different reasons
|
||||
UNIT_STAT_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED | UNIT_STAT_DISTRACTED,
|
||||
UNIT_STAT_ALL_STATE = 0xffffffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT)
|
||||
};
|
||||
|
||||
@@ -719,59 +727,18 @@ enum MovementFlags2
|
||||
MOVEMENTFLAG2_UNK15 = 0x00004000,
|
||||
MOVEMENTFLAG2_UNK16 = 0x00008000,
|
||||
};
|
||||
|
||||
enum SplineFlags
|
||||
{
|
||||
SPLINEFLAG_NONE = 0x00000000,
|
||||
SPLINEFLAG_FORWARD = 0x00000001,
|
||||
SPLINEFLAG_BACKWARD = 0x00000002,
|
||||
SPLINEFLAG_STRAFE_LEFT = 0x00000004,
|
||||
SPLINEFLAG_STRAFE_RIGHT = 0x00000008,
|
||||
SPLINEFLAG_LEFT = 0x00000010,
|
||||
SPLINEFLAG_RIGHT = 0x00000020,
|
||||
SPLINEFLAG_PITCH_UP = 0x00000040,
|
||||
SPLINEFLAG_PITCH_DOWN = 0x00000080,
|
||||
SPLINEFLAG_DONE = 0x00000100,
|
||||
SPLINEFLAG_FALLING = 0x00000200,
|
||||
SPLINEFLAG_NO_SPLINE = 0x00000400,
|
||||
SPLINEFLAG_TRAJECTORY = 0x00000800,
|
||||
SPLINEFLAG_WALKING = 0x00001000,
|
||||
SPLINEFLAG_FLYING = 0x00002000,
|
||||
SPLINEFLAG_KNOCKBACK = 0x00004000,
|
||||
SPLINEFLAG_FINAL_POINT = 0x00008000,
|
||||
SPLINEFLAG_FINAL_TARGET = 0x00010000,
|
||||
SPLINEFLAG_FINAL_FACING = 0x00020000,
|
||||
SPLINEFLAG_CATMULL_ROM = 0x00040000,
|
||||
SPLINEFLAG_UNKNOWN20 = 0x00080000,
|
||||
SPLINEFLAG_UNKNOWN21 = 0x00100000,
|
||||
SPLINEFLAG_ANIMATIONTIER = 0x00200000,
|
||||
SPLINEFLAG_UNKNOWN23 = 0x00400000,
|
||||
SPLINEFLAG_TRANSPORT = 0x00800000,
|
||||
SPLINEFLAG_EXIT_VEHICLE = 0x01000000,
|
||||
SPLINEFLAG_UNKNOWN26 = 0x02000000,
|
||||
SPLINEFLAG_UNKNOWN27 = 0x04000000,
|
||||
SPLINEFLAG_UNKNOWN28 = 0x08000000,
|
||||
SPLINEFLAG_UNKNOWN29 = 0x10000000,
|
||||
SPLINEFLAG_ANIMATION = 0x20000000,
|
||||
SPLINEFLAG_UNKNOWN31 = 0x40000000,
|
||||
SPLINEFLAG_UNKNOWN32 = 0x80000000,
|
||||
|
||||
SPLINEFLAG_GLIDE = SPLINEFLAG_WALKING | SPLINEFLAG_FLYING,
|
||||
};
|
||||
|
||||
enum SplineMode
|
||||
{
|
||||
SPLINEMODE_LINEAR = 0,
|
||||
SPLINEMODE_CATMULL_ROM = 1,
|
||||
SPLINEMODE_BEZIER3 = 2
|
||||
SPLINEFLAG_WALKMODE = 0x00001000,
|
||||
SPLINEFLAG_FLYING = 0x00002000,
|
||||
SPLINEFLAG_TRANSPORT = 0x00800000,
|
||||
SPLINEFLAG_EXIT_VEHICLE = 0x01000000,
|
||||
};
|
||||
|
||||
enum SplineType
|
||||
{
|
||||
SPLINETYPE_NORMAL = 0,
|
||||
SPLINETYPE_STOP = 1,
|
||||
SPLINETYPE_FACING_SPOT = 2,
|
||||
SPLINETYPE_FACING_TARGET = 3,
|
||||
SPLINETYPE_FACING_ANGLE = 4
|
||||
SPLINETYPE_FACING_ANGLE = 4,
|
||||
};
|
||||
|
||||
enum UnitTypeMask
|
||||
@@ -789,6 +756,10 @@ enum UnitTypeMask
|
||||
UNIT_MASK_ACCESSORY = 0x00000200,
|
||||
};
|
||||
|
||||
namespace Movement{
|
||||
class MoveSpline;
|
||||
}
|
||||
|
||||
enum DiminishingLevels
|
||||
{
|
||||
DIMINISHING_LEVEL_1 = 0,
|
||||
@@ -1631,20 +1602,18 @@ class Unit : public WorldObject
|
||||
void JumpTo(float speedXY, float speedZ, bool forward = true);
|
||||
void JumpTo(WorldObject* obj, float speedZ);
|
||||
|
||||
void SetFacing(float ori, WorldObject* obj = NULL);
|
||||
void SendMonsterStop(bool on_death = false);
|
||||
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player = NULL);
|
||||
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 MoveFlags, uint32 time, float speedZ, Player* player = NULL);
|
||||
void SendMonsterMove(MonsterMoveData const& moveData, Player* receiver = NULL);
|
||||
void MonsterMoveWithSpeed(float x, float y, float z, float speed);
|
||||
//void SetFacing(float ori, WorldObject* obj = NULL);
|
||||
void SendMonsterMoveExitVehicle(Position const* newPos);
|
||||
//void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
|
||||
void SendMonsterMoveTransport(Unit* vehicleOwner);
|
||||
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
|
||||
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
|
||||
void SendMovementFlagUpdate();
|
||||
bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_LEVITATING);}
|
||||
bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING);}
|
||||
|
||||
template<typename PathElem, typename PathNode>
|
||||
void SendMonsterMoveByPath(Path<PathElem, PathNode> const& path, uint32 start, uint32 end);
|
||||
void SetInFront(Unit const* target);
|
||||
void SetFacingTo(float ori);
|
||||
void SetFacingToObject(WorldObject* pObject);
|
||||
|
||||
void SendChangeCurrentVictimOpcode(HostileReference* pHostileReference);
|
||||
void SendClearThreatListOpcode();
|
||||
@@ -1954,13 +1923,7 @@ class Unit : public WorldObject
|
||||
void SetBaseWeaponDamage(WeaponAttackType attType, WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; }
|
||||
|
||||
bool isInFrontInMap(Unit const* target, float distance, float arc = M_PI) const;
|
||||
void SetInFront(Unit const* target)
|
||||
{
|
||||
if (!HasUnitState(UNIT_STAT_CANNOT_TURN))
|
||||
SetOrientation(GetAngle(target));
|
||||
}
|
||||
bool isInBackInMap(Unit const* target, float distance, float arc = M_PI) const;
|
||||
void SetFacingToObject(WorldObject* pObject);
|
||||
|
||||
// Visibility system
|
||||
bool IsVisible() const { return (m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM) > SEC_PLAYER) ? false : true; }
|
||||
@@ -2235,6 +2198,9 @@ class Unit : public WorldObject
|
||||
SetUInt64Value(UNIT_FIELD_TARGET, 0);
|
||||
}
|
||||
|
||||
// Movement info
|
||||
Movement::MoveSpline * movespline;
|
||||
|
||||
protected:
|
||||
explicit Unit (bool isWorldObject);
|
||||
|
||||
@@ -2306,6 +2272,8 @@ class Unit : public WorldObject
|
||||
|
||||
bool IsAlwaysVisibleFor(WorldObject const* seer) const;
|
||||
bool IsAlwaysDetectableFor(WorldObject const* seer) const;
|
||||
|
||||
void DisableSpline();
|
||||
private:
|
||||
bool IsTriggeredAtSpellProcEvent(Unit* pVictim, Aura* aura, SpellInfo const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const* & spellProcEvent);
|
||||
bool HandleDummyAuraProc(Unit* pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
|
||||
@@ -2319,6 +2287,8 @@ class Unit : public WorldObject
|
||||
bool HandleAuraRaidProcFromChargeWithValue(AuraEffect* triggeredByAura);
|
||||
bool HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura);
|
||||
|
||||
void UpdateSplineMovement(uint32 t_diff);
|
||||
|
||||
// player or player's pet
|
||||
float GetCombatRatingReduction(CombatRating cr) const;
|
||||
uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const;
|
||||
@@ -2333,6 +2303,7 @@ class Unit : public WorldObject
|
||||
uint32 m_state; // Even derived shouldn't modify
|
||||
uint32 m_CombatTimer;
|
||||
uint32 m_lastManaUse; // msecs
|
||||
TimeTrackerSmall m_movesplineTimer;
|
||||
|
||||
Diminishing m_Diminishing;
|
||||
// Manage all Units that are threatened by us
|
||||
@@ -2385,31 +2356,4 @@ namespace Trinity
|
||||
const bool m_ascending;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Elem, typename Node>
|
||||
inline void Unit::SendMonsterMoveByPath(Path<Elem, Node> const& path, uint32 start, uint32 end)
|
||||
{
|
||||
uint32 traveltime = uint32(path.GetTotalLength(start, end) * 32);
|
||||
uint32 pathSize = end - start;
|
||||
WorldPacket data(SMSG_MONSTER_MOVE, (GetPackGUID().size()+1+4+4+4+4+1+4+4+4+pathSize*4*3));
|
||||
data.append(GetPackGUID());
|
||||
data << uint8(0);
|
||||
data << GetPositionX();
|
||||
data << GetPositionY();
|
||||
data << GetPositionZ();
|
||||
data << uint32(getMSTime());
|
||||
data << uint8(0);
|
||||
data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight()) ? (SPLINEFLAG_FLYING|SPLINEFLAG_WALKING) : SPLINEFLAG_WALKING);
|
||||
data << uint32(traveltime);
|
||||
data << uint32(pathSize);
|
||||
|
||||
for (uint32 i = start; i < end; ++i)
|
||||
{
|
||||
data << float(path[i].x);
|
||||
data << float(path[i].y);
|
||||
data << float(path[i].z);
|
||||
}
|
||||
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
#endif
|
||||
@@ -8762,7 +8762,7 @@ void ObjectMgr::CheckScripts(ScriptsType type, std::set<int32>& ids)
|
||||
case SCRIPT_COMMAND_TALK:
|
||||
{
|
||||
if (!GetTrinityStringLocale (itrM->second.Talk.TextID))
|
||||
sLog->outErrorDb("Table `db_script_string` not has string id %u used db script (ID: %u)", itrM->second.Talk.TextID, itrMM->first);
|
||||
sLog->outErrorDb("Table `%s` references invalid text id %u from `db_script_string`, script id: %u.", GetScriptsTableNameByType(type).c_str(), itrM->second.Talk.TextID, itrMM->first);
|
||||
|
||||
if (ids.find(itrM->second.Talk.TextID) != ids.end())
|
||||
ids.erase(itrM->second.Talk.TextID);
|
||||
|
||||
@@ -190,6 +190,9 @@ void Group::LoadGroupFromDB(Field* fields)
|
||||
m_raidDifficulty = RAID_DIFFICULTY_10MAN_NORMAL;
|
||||
else
|
||||
m_raidDifficulty = Difficulty(r_diff);
|
||||
|
||||
if (m_groupType & GROUPTYPE_LFG)
|
||||
sLFGMgr->_LoadFromDB(fields, GetGUID());
|
||||
}
|
||||
|
||||
void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles)
|
||||
@@ -200,7 +203,9 @@ void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup,
|
||||
// skip non-existed member
|
||||
if (!sObjectMgr->GetPlayerNameByGUID(member.guid, member.name))
|
||||
{
|
||||
CharacterDatabase.PQuery("DELETE FROM group_member WHERE memberGuid=%u", guidLow);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER);
|
||||
stmt->setUInt32(0, guidLow);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -211,6 +216,14 @@ void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup,
|
||||
m_memberSlots.push_back(member);
|
||||
|
||||
SubGroupCounterIncrease(subgroup);
|
||||
|
||||
if (isLFGGroup())
|
||||
{
|
||||
LfgDungeonSet Dungeons;
|
||||
Dungeons.insert(sLFGMgr->GetDungeon(GetGUID()));
|
||||
sLFGMgr->SetSelectedDungeons(member.guid, Dungeons);
|
||||
sLFGMgr->SetState(member.guid, sLFGMgr->GetState(GetGUID()));
|
||||
}
|
||||
}
|
||||
|
||||
void Group::ConvertToLFG()
|
||||
@@ -472,7 +485,7 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod &method /*= GROUP_REMOV
|
||||
return m_memberSlots.size();
|
||||
|
||||
// remove member and change leader (if need) only if strong more 2 members _before_ member remove (BG allow 1 member group)
|
||||
if (GetMembersCount() > (isBGGroup() ? 1u : 2u))
|
||||
if (GetMembersCount() > ((isBGGroup() || isLFGGroup()) ? 1u : 2u))
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
if (player)
|
||||
@@ -516,6 +529,8 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod &method /*= GROUP_REMOV
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
DelinkMember(guid);
|
||||
|
||||
// Reevaluate group enchanter if the leaving player had enchanting skill or the player is offline
|
||||
if ((player && player->GetSkillValue(SKILL_ENCHANTING)) || !player)
|
||||
ResetMaxEnchantingLevel();
|
||||
@@ -566,6 +581,20 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod &method /*= GROUP_REMOV
|
||||
|
||||
SendUpdate();
|
||||
|
||||
if (isLFGGroup() && GetMembersCount() == 1)
|
||||
{
|
||||
Player* Leader = ObjectAccessor::FindPlayer(GetLeaderGUID());
|
||||
LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(sLFGMgr->GetDungeon(GetGUID()));
|
||||
if ((Leader && dungeon && Leader->isAlive() && Leader->GetMapId() != dungeon->map) || !dungeon)
|
||||
{
|
||||
Disband();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_memberMgr.getSize() < ((isLFGGroup() || isBGGroup()) ? 1u : 2u))
|
||||
Disband();
|
||||
|
||||
return true;
|
||||
}
|
||||
// If group size before player removal <= 2 then disband it
|
||||
@@ -705,6 +734,10 @@ void Group::Disband(bool hideDestroy /* = false */)
|
||||
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, NULL);
|
||||
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, NULL);
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
|
||||
stmt->setUInt32(0, m_dbStoreId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
sGroupMgr->FreeGroupDbStoreId(this);
|
||||
}
|
||||
|
||||
@@ -741,6 +774,28 @@ void Group::SendLootStartRoll(uint32 countDown, uint32 mapid, const Roll &r)
|
||||
}
|
||||
}
|
||||
|
||||
void Group::SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, bool canNeed, Roll const& r)
|
||||
{
|
||||
if (!p || !p->GetSession())
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1 ));
|
||||
data << uint64(r.itemGUID); // guid of rolled item
|
||||
data << uint32(mapId); // 3.3.3 mapid
|
||||
data << uint32(r.totalPlayersRolling); // maybe the number of players rolling for it???
|
||||
data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
|
||||
data << uint32(r.itemRandomSuffix); // randomSuffix
|
||||
data << uint32(r.itemRandomPropId); // item random property ID
|
||||
data << uint32(r.itemCount); // items in stack
|
||||
data << uint32(countDown); // the countdown time to choose "need" or "greed"
|
||||
uint8 voteMask = r.rollVoteMask;
|
||||
if (!canNeed)
|
||||
voteMask &= ~ROLL_FLAG_TYPE_NEED;
|
||||
data << uint8(voteMask); // roll type mask
|
||||
|
||||
p->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void Group::SendLootRoll(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r)
|
||||
{
|
||||
WorldPacket data(SMSG_LOOT_ROLL, (8+4+8+4+4+4+1+1+1));
|
||||
@@ -919,11 +974,11 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject)
|
||||
}
|
||||
}
|
||||
|
||||
void Group::NeedBeforeGreed(Loot* loot, WorldObject* pLootedObject)
|
||||
void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
|
||||
{
|
||||
ItemTemplate const* item;
|
||||
uint8 itemSlot = 0;
|
||||
for (std::vector<LootItem>::iterator i=loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot)
|
||||
for (std::vector<LootItem>::iterator i = loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot)
|
||||
{
|
||||
if (i->freeforall)
|
||||
continue;
|
||||
@@ -934,7 +989,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* pLootedObject)
|
||||
if (item->Quality >= uint32(m_lootThreshold))
|
||||
{
|
||||
uint64 newitemGUID = MAKE_NEW_GUID(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), 0, HIGHGUID_ITEM);
|
||||
Roll* r=new Roll(newitemGUID, *i);
|
||||
Roll* r = new Roll(newitemGUID, *i);
|
||||
|
||||
for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
@@ -943,21 +998,17 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* pLootedObject)
|
||||
continue;
|
||||
|
||||
bool allowedForPlayer = i->AllowedForPlayer(playerToRoll);
|
||||
if (playerToRoll->CanUseItem(item) == EQUIP_ERR_OK && allowedForPlayer)
|
||||
if (allowedForPlayer && playerToRoll->IsWithinDistInMap(lootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false))
|
||||
{
|
||||
if (playerToRoll->IsWithinDistInMap(pLootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false))
|
||||
r->totalPlayersRolling++;
|
||||
if (playerToRoll->GetPassOnGroupLoot())
|
||||
{
|
||||
r->totalPlayersRolling++;
|
||||
|
||||
if (playerToRoll->GetPassOnGroupLoot())
|
||||
{
|
||||
r->playerVote[playerToRoll->GetGUID()] = PASS;
|
||||
r->totalPass++;
|
||||
// can't broadcast the pass now. need to wait until all rolling players are known.
|
||||
}
|
||||
else
|
||||
r->playerVote[playerToRoll->GetGUID()] = NOT_EMITED_YET;
|
||||
r->playerVote[playerToRoll->GetGUID()] = PASS;
|
||||
r->totalPass++;
|
||||
// can't broadcast the pass now. need to wait until all rolling players are known.
|
||||
}
|
||||
else
|
||||
r->playerVote[playerToRoll->GetGUID()] = NOT_EMITED_YET;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -973,29 +1024,31 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* pLootedObject)
|
||||
|
||||
loot->items[itemSlot].is_blocked = true;
|
||||
|
||||
// If there is any "auto pass", broadcast the pass now.
|
||||
if (r->totalPass)
|
||||
//Broadcast Pass and Send Rollstart
|
||||
for (Roll::PlayerVote::const_iterator itr = r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
|
||||
{
|
||||
for (Roll::PlayerVote::const_iterator itr=r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
|
||||
{
|
||||
Player* p = ObjectAccessor::FindPlayer(itr->first);
|
||||
if (!p || !p->GetSession())
|
||||
continue;
|
||||
Player* p = ObjectAccessor::FindPlayer(itr->first);
|
||||
if (!p || !p->GetSession())
|
||||
continue;
|
||||
|
||||
if (itr->second == PASS)
|
||||
SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r);
|
||||
}
|
||||
if (itr->second == PASS)
|
||||
SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r);
|
||||
else
|
||||
SendLootStartRollToPlayer(60000, lootedObject->GetMapId(), p, p->CanRollForItemInLFG(item, lootedObject) == EQUIP_ERR_OK, *r);
|
||||
}
|
||||
|
||||
SendLootStartRoll(60000, pLootedObject->GetMapId(), *r);
|
||||
|
||||
RollId.push_back(r);
|
||||
|
||||
if (Creature* creature = pLootedObject->ToCreature())
|
||||
if (Creature* creature = lootedObject->ToCreature())
|
||||
{
|
||||
creature->m_groupLootTimer = 60000;
|
||||
creature->lootingGroupLowGUID = GetLowGUID();
|
||||
}
|
||||
else if (GameObject* go = lootedObject->ToGameObject())
|
||||
{
|
||||
go->m_groupLootTimer = 60000;
|
||||
go->lootingGroupLowGUID = GetLowGUID();
|
||||
}
|
||||
}
|
||||
else
|
||||
delete r;
|
||||
@@ -1274,9 +1327,7 @@ void Group::SendTargetIconList(WorldSession* session)
|
||||
void Group::SendUpdate()
|
||||
{
|
||||
for (member_witerator witr = m_memberSlots.begin(); witr != m_memberSlots.end(); ++witr)
|
||||
{
|
||||
SendUpdateToPlayer(witr->guid, &(*witr));
|
||||
}
|
||||
}
|
||||
|
||||
void Group::SendUpdateToPlayer(uint64 playerGUID, MemberSlot* slot)
|
||||
@@ -2149,8 +2200,19 @@ void Group::LinkMember(GroupReference* pRef)
|
||||
m_memberMgr.insertFirst(pRef);
|
||||
}
|
||||
|
||||
void Group::DelinkMember(GroupReference* /*pRef*/) const
|
||||
void Group::DelinkMember(uint64 guid)
|
||||
{
|
||||
GroupReference* ref = m_memberMgr.getFirst();
|
||||
while (ref)
|
||||
{
|
||||
GroupReference* nextRef = ref->next();
|
||||
if (ref->getSource()->GetGUID() == guid)
|
||||
{
|
||||
ref->unlink();
|
||||
break;
|
||||
}
|
||||
ref = nextRef;
|
||||
}
|
||||
}
|
||||
|
||||
Group::BoundInstancesMap& Group::GetBoundInstances(Difficulty difficulty)
|
||||
|
||||
@@ -276,6 +276,7 @@ class Group
|
||||
|
||||
bool isRollLootActive() const;
|
||||
void SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r);
|
||||
void SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, bool canNeed, Roll const& r);
|
||||
void SendLootRoll(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r);
|
||||
void SendLootRollWon(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r);
|
||||
void SendLootAllPassed(uint32 NumberOfPlayers, const Roll &r);
|
||||
@@ -292,7 +293,7 @@ class Group
|
||||
void ResetMaxEnchantingLevel();
|
||||
|
||||
void LinkMember(GroupReference* pRef);
|
||||
void DelinkMember(GroupReference* /*pRef*/) const;
|
||||
void DelinkMember(uint64 guid);
|
||||
|
||||
InstanceGroupBind* BindToInstance(InstanceSave* save, bool permanent, bool load = false);
|
||||
void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false);
|
||||
|
||||
@@ -119,10 +119,10 @@ void GroupMgr::LoadGroups()
|
||||
// Delete all groups with less than 2 members
|
||||
CharacterDatabase.DirectExecute("DELETE FROM groups WHERE guid NOT IN (SELECT guid FROM group_member GROUP BY guid HAVING COUNT(guid) > 1)");
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT leaderGuid, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6"
|
||||
// 10 11 12 13 14 15
|
||||
", icon7, icon8, groupType, difficulty, raiddifficulty, guid FROM groups ORDER BY guid ASC");
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT g.leaderGuid, g.lootMethod, g.looterGuid, g.lootThreshold, g.icon1, g.icon2, g.icon3, g.icon4, g.icon5, g.icon6"
|
||||
// 10 11 12 13 14 15 16 17
|
||||
", g.icon7, g.icon8, g.groupType, g.difficulty, g.raiddifficulty, g.guid, lfg.dungeon, lfg.state FROM groups g LEFT JOIN lfg_data lfg ON lfg.guid = g.guid ORDER BY g.guid ASC");
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 group definitions. DB table `groups` is empty!");
|
||||
|
||||
@@ -28,12 +28,12 @@ void GroupReference::targetObjectBuildLink()
|
||||
void GroupReference::targetObjectDestroyLink()
|
||||
{
|
||||
// called from unlink()
|
||||
getTarget()->DelinkMember(this);
|
||||
//getTarget()->DelinkMember(this);
|
||||
}
|
||||
|
||||
void GroupReference::sourceObjectDestroyLink()
|
||||
{
|
||||
// called from invalidate()
|
||||
getTarget()->DelinkMember(this);
|
||||
//getTarget()->DelinkMember(this);
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+14
-4
@@ -43,6 +43,7 @@
|
||||
#include "Battleground.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "DBCStores.h"
|
||||
#include "LFGMgr.h"
|
||||
|
||||
class LoginQueryHolder : public SQLQueryHolder
|
||||
{
|
||||
@@ -196,7 +197,7 @@ bool LoginQueryHolder::Initialize()
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_INSTANCELOCKTIMES);
|
||||
stmt->setUInt32(0, m_accountId);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADINSTANCELOCKTIMES, stmt);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -872,6 +873,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
|
||||
// "GetAccountId() == db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
|
||||
if (!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder))
|
||||
{
|
||||
SetPlayer(NULL);
|
||||
KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
|
||||
delete pCurrChar; // delete it manually
|
||||
delete holder; // delete all unprocessed queries
|
||||
@@ -880,9 +882,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
|
||||
}
|
||||
|
||||
pCurrChar->GetMotionMaster()->Initialize();
|
||||
|
||||
SetPlayer(pCurrChar);
|
||||
|
||||
pCurrChar->SendDungeonDifficulty(false);
|
||||
|
||||
WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
|
||||
@@ -992,6 +991,17 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
|
||||
}
|
||||
}
|
||||
|
||||
if (Group* group = pCurrChar->GetGroup())
|
||||
{
|
||||
if (group->isLFGGroup())
|
||||
{
|
||||
LfgDungeonSet Dungeons;
|
||||
Dungeons.insert(sLFGMgr->GetDungeon(group->GetGUID()));
|
||||
sLFGMgr->SetSelectedDungeons(pCurrChar->GetGUID(), Dungeons);
|
||||
sLFGMgr->SetState(pCurrChar->GetGUID(), sLFGMgr->GetState(group->GetGUID()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid())
|
||||
{
|
||||
AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId());
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-1
@@ -50,7 +50,8 @@ void BuildPartyLockDungeonBlock(WorldPacket& data, const LfgLockPartyMap& lockMa
|
||||
void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data)
|
||||
{
|
||||
if (!sWorld->getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE) ||
|
||||
(GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID()))
|
||||
(GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID() &&
|
||||
(GetPlayer()->GetGroup()->GetMembersCount() == MAXGROUPSIZE || !GetPlayer()->GetGroup()->isLFGGroup())))
|
||||
{
|
||||
recv_data.rfinish();
|
||||
return;
|
||||
+1
-1
@@ -324,7 +324,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
|
||||
else
|
||||
{
|
||||
// not fully looted object
|
||||
go->SetLootState(GO_ACTIVATED);
|
||||
go->SetLootState(GO_ACTIVATED, player);
|
||||
|
||||
// if the round robin player release, reset it.
|
||||
if (player->GetGUID() == loot->roundRobinPlayer)
|
||||
File renamed without changes.
+7
-1
@@ -160,7 +160,8 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
|
||||
else
|
||||
{
|
||||
go->AI()->GossipSelect(_player, menuId, gossipListId);
|
||||
sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
|
||||
if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
|
||||
_player->OnGossipSelect(go, gossipListId, menuId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,6 +170,11 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_WHO Message");
|
||||
|
||||
time_t now = time(NULL);
|
||||
if (now - timeLastWhoCommand < 5)
|
||||
return;
|
||||
else timeLastWhoCommand = now;
|
||||
|
||||
uint32 matchcount = 0;
|
||||
|
||||
uint32 level_min, level_max, racemask, classmask, zones_count, str_count;
|
||||
+1
-12
@@ -479,19 +479,8 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data)
|
||||
|
||||
if (GetPlayer()->IsInWorld())
|
||||
{
|
||||
if (Unit* mover = ObjectAccessor::GetUnit(*GetPlayer(), guid))
|
||||
{
|
||||
GetPlayer()->SetMover(mover);
|
||||
if (mover != GetPlayer() && mover->canFly())
|
||||
{
|
||||
GetPlayer()->SendSetFlyPacket(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_player->m_mover->GetGUID() != guid)
|
||||
sLog->outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID());
|
||||
GetPlayer()->SetMover(GetPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
+1
@@ -160,6 +160,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
|
||||
case COMMAND_STAY: //flat=1792 //STAY
|
||||
pet->AttackStop();
|
||||
pet->InterruptNonMeleeSpells(false);
|
||||
pet->GetMotionMaster()->Clear(false);
|
||||
pet->GetMotionMaster()->MoveIdle();
|
||||
charmInfo->SetCommandState(COMMAND_STAY);
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-1
@@ -27,7 +27,6 @@
|
||||
#include "UpdateMask.h"
|
||||
#include "Path.h"
|
||||
#include "WaypointMovementGenerator.h"
|
||||
#include "DestinationHolderImp.h"
|
||||
|
||||
void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -532,8 +532,8 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
|
||||
|
||||
if (iMap && iMap->IsDungeon())
|
||||
((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
|
||||
else
|
||||
sObjectMgr->DeleteRespawnTimeForInstance(instanceId); // even if map is not loaded
|
||||
|
||||
sObjectMgr->DeleteRespawnTimeForInstance(instanceId); // even if map is not loaded
|
||||
|
||||
// Free up the instance id and allow it to be reused
|
||||
sMapMgr->FreeInstanceId(instanceId);
|
||||
|
||||
@@ -302,21 +302,21 @@ void InstanceScript::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData)
|
||||
}
|
||||
|
||||
// Send Notify to all players in instance
|
||||
void InstanceScript::DoSendNotifyToInstance(const char *format, ...)
|
||||
void InstanceScript::DoSendNotifyToInstance(char const* format, ...)
|
||||
{
|
||||
InstanceMap::PlayerList const &PlayerList = instance->GetPlayers();
|
||||
InstanceMap::PlayerList const& players = instance->GetPlayers();
|
||||
|
||||
if (!PlayerList.isEmpty())
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
{
|
||||
if (Player* player = i->getSource())
|
||||
if (WorldSession* pSession = player->GetSession())
|
||||
pSession->SendNotification(format, ap);
|
||||
}
|
||||
char buff[1024];
|
||||
vsnprintf(buff, 1024, format, ap);
|
||||
va_end(ap);
|
||||
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
|
||||
if (Player* player = i->getSource())
|
||||
if (WorldSession* session = player->GetSession())
|
||||
session->SendNotification(buff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1539,6 +1539,24 @@ inline GridMap* Map::GetGrid(float x, float y)
|
||||
return GridMaps[gx][gy];
|
||||
}
|
||||
|
||||
float Map::GetWaterOrGroundLevel(float x, float y, float z, float* ground /*= NULL*/, bool swim /*= false*/) const
|
||||
{
|
||||
if (const_cast<Map*>(this)->GetGrid(x, y))
|
||||
{
|
||||
// we need ground level (including grid height version) for proper return water level in point
|
||||
float ground_z = GetHeight(x, y, z, true, 50.0f);
|
||||
if (ground)
|
||||
*ground = ground_z;
|
||||
|
||||
LiquidData liquid_status;
|
||||
|
||||
ZLiquidStatus res = getLiquidStatus(x, y, ground_z, MAP_ALL_LIQUIDS, &liquid_status);
|
||||
return res ? ( swim ? liquid_status.level - 2.0f : liquid_status.level) : ground_z;
|
||||
}
|
||||
|
||||
return VMAP_INVALID_HEIGHT_VALUE;
|
||||
}
|
||||
|
||||
float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const
|
||||
{
|
||||
// find raw .map surface under Z coordinates
|
||||
|
||||
@@ -424,6 +424,8 @@ class Map : public GridRefManager<NGridType>
|
||||
|
||||
InstanceMap* ToInstanceMap(){ if (IsDungeon()) return reinterpret_cast<InstanceMap*>(this); else return NULL; }
|
||||
const InstanceMap* ToInstanceMap() const { if (IsDungeon()) return (const InstanceMap*)((InstanceMap*)this); else return NULL; }
|
||||
float GetWaterOrGroundLevel(float x, float y, float z, float* ground = NULL, bool swim = false) const;
|
||||
|
||||
private:
|
||||
void LoadMapAndVMap(int gx, int gy);
|
||||
void LoadVMap(int gx, int gy);
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "GridDefines.h"
|
||||
#include "MapInstanced.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "DestinationHolderImp.h"
|
||||
#include "Config.h"
|
||||
#include "World.h"
|
||||
#include "CellImpl.h"
|
||||
|
||||
@@ -492,9 +492,9 @@ enum TrinityStrings
|
||||
LANG_MOVEGENS_WAYPOINT = 529,
|
||||
LANG_MOVEGENS_ANIMAL_RANDOM = 530,
|
||||
LANG_MOVEGENS_CONFUSED = 531,
|
||||
LANG_MOVEGENS_TARGETED_PLAYER = 532,
|
||||
LANG_MOVEGENS_TARGETED_CREATURE = 533,
|
||||
LANG_MOVEGENS_TARGETED_NULL = 534,
|
||||
LANG_MOVEGENS_CHASE_PLAYER = 532,
|
||||
LANG_MOVEGENS_CHASE_CREATURE = 533,
|
||||
LANG_MOVEGENS_CHASE_NULL = 534,
|
||||
LANG_MOVEGENS_HOME_CREATURE = 535,
|
||||
LANG_MOVEGENS_HOME_PLAYER = 536,
|
||||
LANG_MOVEGENS_FLIGHT = 537,
|
||||
@@ -807,7 +807,11 @@ enum TrinityStrings
|
||||
LANG_CHAR_NOT_BANNED = 1136,
|
||||
LANG_DEV_ON = 1137,
|
||||
LANG_DEV_OFF = 1138,
|
||||
// Room for more level 3 1139-1199 not used
|
||||
LANG_MOVEGENS_FOLLOW_PLAYER = 1139,
|
||||
LANG_MOVEGENS_FOLLOW_CREATURE = 1140,
|
||||
LANG_MOVEGENS_FOLLOW_NULL = 1141,
|
||||
LANG_MOVEGENS_EFFECT = 1142,
|
||||
// Room for more level 3 1143-1199 not used
|
||||
|
||||
// Debug commands
|
||||
LANG_CINEMATIC_NOT_EXIST = 1200,
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "DestinationHolder.h"
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TRINITY_DESTINATION_HOLDER_H
|
||||
#define TRINITY_DESTINATION_HOLDER_H
|
||||
|
||||
#include "Define.h"
|
||||
#include "Timer.h"
|
||||
|
||||
class WorldObject;
|
||||
class Map;
|
||||
|
||||
#define TRAVELLER_UPDATE_INTERVAL 300
|
||||
|
||||
template<typename TRAVELLER>
|
||||
class DestinationHolder
|
||||
{
|
||||
TimeTrackerSmall i_tracker;
|
||||
uint32 i_totalTravelTime;
|
||||
uint32 i_timeElapsed;
|
||||
bool i_destSet;
|
||||
float i_fromX, i_fromY, i_fromZ;
|
||||
float i_destX, i_destY, i_destZ;
|
||||
|
||||
public:
|
||||
DestinationHolder() : i_tracker(TRAVELLER_UPDATE_INTERVAL), i_totalTravelTime(0), i_timeElapsed(0),
|
||||
i_destSet(false), i_fromX(0), i_fromY(0), i_fromZ(0), i_destX(0), i_destY(0), i_destZ(0) {}
|
||||
|
||||
uint32 SetDestination(TRAVELLER &traveller, float dest_x, float dest_y, float dest_z, bool sendMove = true);
|
||||
void GetDestination(float &x, float &y, float &z) const { x = i_destX; y = i_destY; z = i_destZ; }
|
||||
bool UpdateExpired(void) const { return i_tracker.Passed(); }
|
||||
void ResetUpdate(uint32 t = TRAVELLER_UPDATE_INTERVAL) { i_tracker.Reset(t); }
|
||||
uint32 GetTotalTravelTime(void) const { return i_totalTravelTime; }
|
||||
void IncreaseTravelTime(uint32 increment) { i_totalTravelTime += increment; }
|
||||
void ResetTravelTime() { i_totalTravelTime = 0; }
|
||||
bool HasDestination(void) const { return i_destSet; }
|
||||
float GetDestinationDiff(float x, float y, float z) const;
|
||||
bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); }
|
||||
bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool micro_movement=false);
|
||||
uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true);
|
||||
void GetLocationNow(const Map* map, float &x, float &y, float &z, bool is3D = false) const;
|
||||
void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement
|
||||
float GetDistance3dFromDestSq(const WorldObject &obj) const;
|
||||
|
||||
private:
|
||||
void _findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,215 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TRINITY_DESTINATIONHOLDERIMP_H
|
||||
#define TRINITY_DESTINATIONHOLDERIMP_H
|
||||
|
||||
#include "MapManager.h"
|
||||
#include "DestinationHolder.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
template<typename TRAVELLER>
|
||||
void
|
||||
DestinationHolder<TRAVELLER>::_findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y)
|
||||
{
|
||||
/* given the point (x1, y1) and (x2, y2).. need to find the point (x, y) on the same line
|
||||
* such that the distance from (x, y) to (x2, y2) is offset.
|
||||
* Let the distance of p1 to p2 = d.. then the ratio of offset/d = (x2-x)/(x2-x1)
|
||||
* hence x = x2 - (offset/d)*(x2-x1)
|
||||
* like wise offset/d = (y2-y)/(y2-y1);
|
||||
*/
|
||||
if (offset == 0)
|
||||
{
|
||||
x = x2;
|
||||
y = y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
double x_diff = double(x2 - x1);
|
||||
double y_diff = double(y2 - y1);
|
||||
double distance_d = (double)((x_diff*x_diff) + (y_diff * y_diff));
|
||||
if (distance_d == 0)
|
||||
{
|
||||
x = x2;
|
||||
y = y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
distance_d = ::sqrt(distance_d); // starting distance
|
||||
double distance_ratio = (double)(distance_d - offset)/(double)distance_d;
|
||||
// line above has revised formula which is more correct, I think
|
||||
x = (float)(x1 + (distance_ratio*x_diff));
|
||||
y = (float)(y1 + (distance_ratio*y_diff));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename TRAVELLER>
|
||||
uint32
|
||||
DestinationHolder<TRAVELLER>::SetDestination(TRAVELLER &traveller, float dest_x, float dest_y, float dest_z, bool sendMove)
|
||||
{
|
||||
i_destSet = true;
|
||||
i_destX = dest_x;
|
||||
i_destY = dest_y;
|
||||
i_destZ = dest_z;
|
||||
|
||||
return StartTravel(traveller, sendMove);
|
||||
}
|
||||
|
||||
template<typename TRAVELLER>
|
||||
uint32
|
||||
DestinationHolder<TRAVELLER>::StartTravel(TRAVELLER &traveller, bool sendMove)
|
||||
{
|
||||
if (!i_destSet) return 0;
|
||||
|
||||
i_fromX = traveller.GetPositionX();
|
||||
i_fromY = traveller.GetPositionY();
|
||||
i_fromZ = traveller.GetPositionZ();
|
||||
|
||||
i_totalTravelTime = traveller.GetTotalTrevelTimeTo(i_destX, i_destY, i_destZ);
|
||||
i_timeElapsed = 0;
|
||||
if (sendMove)
|
||||
traveller.MoveTo(i_destX, i_destY, i_destZ, i_totalTravelTime);
|
||||
return i_totalTravelTime;
|
||||
}
|
||||
|
||||
template<typename TRAVELLER>
|
||||
bool
|
||||
DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool micro_movement)
|
||||
{
|
||||
i_timeElapsed += diff;
|
||||
|
||||
// Update every TRAVELLER_UPDATE_INTERVAL
|
||||
i_tracker.Update(diff);
|
||||
if (!i_tracker.Passed())
|
||||
return false;
|
||||
else
|
||||
ResetUpdate();
|
||||
|
||||
if (!i_destSet) return true;
|
||||
|
||||
float x, y, z;
|
||||
if (!micro_movement)
|
||||
GetLocationNowNoMicroMovement(x, y, z);
|
||||
else
|
||||
{
|
||||
if (!traveller.GetTraveller().HasUnitState(UNIT_STAT_MOVING | UNIT_STAT_IN_FLIGHT))
|
||||
return true;
|
||||
|
||||
if (traveller.GetTraveller().HasUnitState(UNIT_STAT_IN_FLIGHT))
|
||||
GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, true); // Should reposition Object with right Coord, so I can bypass some Grid Relocation
|
||||
else
|
||||
GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, false);
|
||||
|
||||
// Change movement computation to micro movement based on last tick coords, this makes system work
|
||||
// even on multiple floors zones without hugh vmaps usage ;)
|
||||
|
||||
// Take care of underrun of uint32
|
||||
if (i_totalTravelTime >= i_timeElapsed)
|
||||
i_totalTravelTime -= i_timeElapsed; // Consider only the remaining part
|
||||
else
|
||||
i_totalTravelTime = 0;
|
||||
|
||||
i_timeElapsed = 0;
|
||||
i_fromX = x; // and change origine
|
||||
i_fromY = y; // then I take into account only micro movement
|
||||
i_fromZ = z;
|
||||
}
|
||||
|
||||
if (traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y || traveller.GetTraveller().GetPositionZ() != z)
|
||||
{
|
||||
float ori = traveller.GetTraveller().GetAngle(x, y);
|
||||
traveller.Relocation(x, y, z, ori);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename TRAVELLER>
|
||||
void
|
||||
DestinationHolder<TRAVELLER>::GetLocationNow(const Map* map, float &x, float &y, float &z, bool is3D) const
|
||||
{
|
||||
if (HasArrived())
|
||||
{
|
||||
x = i_destX;
|
||||
y = i_destY;
|
||||
z = i_destZ;
|
||||
}
|
||||
else if (HasDestination())
|
||||
{
|
||||
double percent_passed = (double)i_timeElapsed / (double)i_totalTravelTime;
|
||||
const float distanceX = (float)((i_destX - i_fromX) * percent_passed);
|
||||
const float distanceY = (float)((i_destY - i_fromY) * percent_passed);
|
||||
const float distanceZ = (float)((i_destZ - i_fromZ) * percent_passed);
|
||||
x = i_fromX + distanceX;
|
||||
y = i_fromY + distanceY;
|
||||
float z2 = i_fromZ + distanceZ;
|
||||
// All that is not finished but previous code neither... Traveller need be able to swim.
|
||||
if (is3D)
|
||||
z = z2;
|
||||
else
|
||||
{
|
||||
//That part is good for mob Walking on the floor. But the floor is not always what we thought.
|
||||
z = map->GetHeight(x, y, i_fromZ, false); // Disable cave check
|
||||
const float groundDist = sqrt(distanceX*distanceX + distanceY*distanceY);
|
||||
const float zDist = fabs(i_fromZ - z) + 0.000001f;
|
||||
const float slope = groundDist / zDist;
|
||||
if (slope < 1.0f) // This prevents the ground returned by GetHeight to be used when in cave
|
||||
z = z2; // a climb or jump of more than 45 is denied
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename TRAVELLER>
|
||||
float
|
||||
DestinationHolder<TRAVELLER>::GetDistance3dFromDestSq(const WorldObject &obj) const
|
||||
{
|
||||
float x, y, z;
|
||||
obj.GetPosition(x, y, z);
|
||||
return (i_destX-x)*(i_destX-x)+(i_destY-y)*(i_destY-y)+(i_destZ-z)*(i_destZ-z);
|
||||
}
|
||||
|
||||
template<typename TRAVELLER>
|
||||
float
|
||||
DestinationHolder<TRAVELLER>::GetDestinationDiff(float x, float y, float z) const
|
||||
{
|
||||
return sqrt(((x-i_destX)*(x-i_destX)) + ((y-i_destY)*(y-i_destY)) + ((z-i_destZ)*(z-i_destZ)));
|
||||
}
|
||||
|
||||
template<typename TRAVELLER>
|
||||
void
|
||||
DestinationHolder<TRAVELLER>::GetLocationNowNoMicroMovement(float &x, float &y, float &z) const
|
||||
{
|
||||
if (HasArrived())
|
||||
{
|
||||
x = i_destX;
|
||||
y = i_destY;
|
||||
z = i_destZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
double percent_passed = (double)i_timeElapsed / (double)i_totalTravelTime;
|
||||
x = (float)(i_fromX + ((i_destX - i_fromX) * percent_passed));
|
||||
y = (float)(i_fromY + ((i_destY - i_fromY) * percent_passed));
|
||||
z = (float)(i_fromZ + ((i_destZ - i_fromZ) * percent_passed));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "MotionMaster.h"
|
||||
#include "CreatureAISelector.h"
|
||||
#include "Creature.h"
|
||||
#include "Traveller.h"
|
||||
|
||||
#include "ConfusedMovementGenerator.h"
|
||||
#include "FleeingMovementGenerator.h"
|
||||
@@ -29,7 +28,8 @@
|
||||
#include "TargetedMovementGenerator.h"
|
||||
#include "WaypointMovementGenerator.h"
|
||||
#include "RandomMovementGenerator.h"
|
||||
|
||||
#include "MoveSpline.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include <cassert>
|
||||
|
||||
inline bool isStatic(MovementGenerator *mv)
|
||||
@@ -175,12 +175,11 @@ void MotionMaster::DelayedExpire()
|
||||
--i_top;
|
||||
}
|
||||
|
||||
void MotionMaster::MoveIdle(MovementSlot slot)
|
||||
void MotionMaster::MoveIdle()
|
||||
{
|
||||
//if (empty() || !isStatic(top()))
|
||||
// push(&si_idleMovement);
|
||||
if (!isStatic(Impl[slot]))
|
||||
Mutate(&si_idleMovement, slot);
|
||||
//! Should be preceded by MovementExpired or Clear if there's an overlying movementgenerator active
|
||||
if (empty() || !isStatic(top()))
|
||||
Mutate(&si_idleMovement, MOTION_SLOT_IDLE);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveRandom(float spawndist)
|
||||
@@ -194,16 +193,23 @@ void MotionMaster::MoveRandom(float spawndist)
|
||||
|
||||
void MotionMaster::MoveTargetedHome()
|
||||
{
|
||||
//if (i_owner->HasUnitState(UNIT_STAT_FLEEING))
|
||||
// return;
|
||||
|
||||
Clear(false);
|
||||
|
||||
if (i_owner->GetTypeId() == TYPEID_UNIT)
|
||||
if (i_owner->GetTypeId()==TYPEID_UNIT && !((Creature*)i_owner)->GetCharmerOrOwnerGUID())
|
||||
{
|
||||
sLog->outStaticDebug("Creature (Entry: %u GUID: %u) targeted home", i_owner->GetEntry(), i_owner->GetGUIDLow());
|
||||
Mutate(new HomeMovementGenerator<Creature>(), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
else if (i_owner->GetTypeId()==TYPEID_UNIT && ((Creature*)i_owner)->GetCharmerOrOwnerGUID())
|
||||
{
|
||||
sLog->outStaticDebug("Pet or controlled creature (Entry: %u GUID: %u) targeting home", i_owner->GetEntry(), i_owner->GetGUIDLow() );
|
||||
Unit *target = ((Creature*)i_owner)->GetCharmerOrOwner();
|
||||
if (target)
|
||||
{
|
||||
sLog->outStaticDebug("Following %s (GUID: %u)", target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature", target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : ((Creature*)target)->GetDBTableGUIDLow() );
|
||||
Mutate(new FollowMovementGenerator<Creature>(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog->outError("Player (GUID: %u) attempt targeted home", i_owner->GetGUIDLow());
|
||||
@@ -231,14 +237,14 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle)
|
||||
if (!target || target == i_owner || i_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
i_owner->ClearUnitState(UNIT_STAT_FOLLOW);
|
||||
//i_owner->ClearUnitState(UNIT_STAT_FOLLOW);
|
||||
if (i_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
sLog->outStaticDebug("Player (GUID: %u) chase to %s (GUID: %u)",
|
||||
i_owner->GetGUIDLow(),
|
||||
target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature",
|
||||
target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow());
|
||||
Mutate(new TargetedMovementGenerator<Player>(*target, dist, angle), MOTION_SLOT_ACTIVE);
|
||||
Mutate(new ChaseMovementGenerator<Player>(*target,dist,angle), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -246,7 +252,7 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle)
|
||||
i_owner->GetEntry(), i_owner->GetGUIDLow(),
|
||||
target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature",
|
||||
target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow());
|
||||
Mutate(new TargetedMovementGenerator<Creature>(*target, dist, angle), MOTION_SLOT_ACTIVE);
|
||||
Mutate(new ChaseMovementGenerator<Creature>(*target,dist,angle), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,13 +262,13 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlo
|
||||
if (!target || target == i_owner || i_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
i_owner->AddUnitState(UNIT_STAT_FOLLOW);
|
||||
//i_owner->AddUnitState(UNIT_STAT_FOLLOW);
|
||||
if (i_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
sLog->outStaticDebug("Player (GUID: %u) follow to %s (GUID: %u)", i_owner->GetGUIDLow(),
|
||||
target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature",
|
||||
target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow());
|
||||
Mutate(new TargetedMovementGenerator<Player>(*target, dist, angle), slot);
|
||||
Mutate(new FollowMovementGenerator<Player>(*target,dist,angle), slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -270,7 +276,7 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlo
|
||||
i_owner->GetEntry(), i_owner->GetGUIDLow(),
|
||||
target->GetTypeId() == TYPEID_PLAYER ? "player" : "creature",
|
||||
target->GetTypeId() == TYPEID_PLAYER ? target->GetGUIDLow() : target->ToCreature()->GetDBTableGUIDLow());
|
||||
Mutate(new TargetedMovementGenerator<Creature>(*target, dist, angle), slot);
|
||||
Mutate(new FollowMovementGenerator<Creature>(*target,dist,angle), slot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,54 +297,32 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z)
|
||||
|
||||
void MotionMaster::MoveLand(uint32 id, Position const& pos, float speed)
|
||||
{
|
||||
if (i_owner->GetTypeId() != TYPEID_UNIT)
|
||||
return;
|
||||
|
||||
uint32 moveFlag = SPLINEFLAG_FLYING | SPLINEFLAG_ANIMATIONTIER;
|
||||
uint32 moveTime = uint32(i_owner->GetExactDist(&pos) / speed) * IN_MILLISECONDS;
|
||||
|
||||
// CHARGING state makes the unit use m_TempSpeed and JUMPING prevents sending movement packet in PointMovementGenerator
|
||||
i_owner->AddUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING);
|
||||
i_owner->m_TempSpeed = speed;
|
||||
|
||||
float x, y, z;
|
||||
pos.GetPosition(x, y, z);
|
||||
|
||||
sLog->outStaticDebug("Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", i_owner->GetEntry(), id, x, y, z);
|
||||
Mutate(new PointMovementGenerator<Creature>(id, x, y, z), MOTION_SLOT_ACTIVE);
|
||||
|
||||
MonsterMoveData data;
|
||||
data.DestLocation.Relocate(pos);
|
||||
data.SplineFlag = moveFlag;
|
||||
data.Time = moveTime;
|
||||
data.AnimationState = ANIMATION_ON_GROUND;
|
||||
|
||||
i_owner->SendMonsterMove(data);
|
||||
Movement::MoveSplineInit init(*i_owner);
|
||||
init.MoveTo(x,y,z);
|
||||
init.SetVelocity(speed);
|
||||
init.SetAnimation(Movement::ToGround);
|
||||
init.Launch();
|
||||
Mutate(new EffectMovementGenerator(id), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, float speed)
|
||||
{
|
||||
if (i_owner->GetTypeId() != TYPEID_UNIT)
|
||||
return;
|
||||
|
||||
uint32 moveFlag = SPLINEFLAG_FLYING | SPLINEFLAG_ANIMATIONTIER;
|
||||
uint32 moveTime = uint32(i_owner->GetExactDist(&pos) / speed) * IN_MILLISECONDS;
|
||||
|
||||
// CHARGING state makes the unit use m_TempSpeed and JUMPING prevents sending movement packet in PointMovementGenerator
|
||||
i_owner->AddUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING);
|
||||
i_owner->m_TempSpeed = speed;
|
||||
|
||||
float x, y, z;
|
||||
pos.GetPosition(x, y, z);
|
||||
|
||||
sLog->outStaticDebug("Creature (Entry: %u) landing point (ID: %u X: %f Y: %f Z: %f)", i_owner->GetEntry(), id, x, y, z);
|
||||
Mutate(new PointMovementGenerator<Creature>(id, x, y, z), MOTION_SLOT_ACTIVE);
|
||||
|
||||
MonsterMoveData data;
|
||||
data.DestLocation.Relocate(pos);
|
||||
data.SplineFlag = moveFlag;
|
||||
data.Time = moveTime;
|
||||
data.AnimationState = ANIMATION_FLYING;
|
||||
|
||||
i_owner->SendMonsterMove(data);
|
||||
Movement::MoveSplineInit init(*i_owner);
|
||||
init.MoveTo(x,y,z);
|
||||
init.SetVelocity(speed);
|
||||
init.SetAnimation(Movement::ToFly);
|
||||
init.Launch();
|
||||
Mutate(new EffectMovementGenerator(id), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ)
|
||||
@@ -348,7 +332,9 @@ void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, floa
|
||||
return;
|
||||
|
||||
float x, y, z;
|
||||
float dist = speedXY * speedZ * 0.1f;
|
||||
float moveTimeHalf = speedZ / Movement::gravity;
|
||||
float dist = 2 * moveTimeHalf * speedXY;
|
||||
|
||||
i_owner->GetNearPoint(i_owner, x, y, z, i_owner->GetObjectSize(), dist, i_owner->GetAngle(srcX, srcY) + M_PI);
|
||||
MoveJump(x, y, z, speedXY, speedZ);
|
||||
}
|
||||
@@ -360,35 +346,51 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ)
|
||||
return;
|
||||
|
||||
float x, y, z;
|
||||
float dist = speedXY * speedZ * 0.1f;
|
||||
|
||||
float moveTimeHalf = speedZ / Movement::gravity;
|
||||
float dist = 2 * moveTimeHalf * speedXY;
|
||||
i_owner->GetClosePoint(x, y, z, i_owner->GetObjectSize(), dist, angle);
|
||||
MoveJump(x, y, z, speedXY, speedZ);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ)
|
||||
void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id)
|
||||
{
|
||||
uint32 moveFlag = SPLINEFLAG_TRAJECTORY | SPLINEFLAG_WALKING;
|
||||
uint32 time = uint32(speedZ * 100);
|
||||
sLog->outStaticDebug("Unit (GUID: %u) jump to point (X: %f Y: %f Z: %f)", i_owner->GetGUIDLow(), x, y, z);
|
||||
|
||||
// Instantly interrupt non melee spells being casted
|
||||
if (i_owner->IsNonMeleeSpellCasted(true))
|
||||
i_owner->InterruptNonMeleeSpells(true);
|
||||
float moveTimeHalf = speedZ / Movement::gravity;
|
||||
float max_height = -Movement::computeFallElevation(moveTimeHalf,false,-speedZ);
|
||||
|
||||
i_owner->AddUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING);
|
||||
i_owner->m_TempSpeed = speedXY;
|
||||
Movement::MoveSplineInit init(*i_owner);
|
||||
init.MoveTo(x,y,z);
|
||||
init.SetParabolic(max_height,0);
|
||||
init.SetVelocity(speedXY);
|
||||
init.Launch();
|
||||
if (i_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
sLog->outStaticDebug("Player (GUID: %u) jump to point (X: %f Y: %f Z: %f)", i_owner->GetGUIDLow(), x, y, z);
|
||||
Mutate(new PointMovementGenerator<Player>(0, x, y, z), MOTION_SLOT_CONTROLLED);
|
||||
}
|
||||
Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED);
|
||||
else
|
||||
Mutate(new EffectMovementGenerator(id), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveFall(uint32 id/*=0*/)
|
||||
{
|
||||
// use larger distance for vmap height search than in most other cases
|
||||
float tz = i_owner->GetMap()->GetHeight(i_owner->GetPositionX(), i_owner->GetPositionY(), i_owner->GetPositionZ(), true, MAX_FALL_DISTANCE);
|
||||
if (tz <= INVALID_HEIGHT)
|
||||
{
|
||||
sLog->outStaticDebug("Creature (Entry: %u GUID: %u) jump to point (X: %f Y: %f Z: %f)",
|
||||
i_owner->GetEntry(), i_owner->GetGUIDLow(), x, y, z);
|
||||
Mutate(new PointMovementGenerator<Creature>(0, x, y, z), MOTION_SLOT_CONTROLLED);
|
||||
sLog->outStaticDebug("MotionMaster::MoveFall: unable retrive a proper height at map %u (x: %f, y: %f, z: %f).",
|
||||
i_owner->GetMap()->GetId(), i_owner->GetPositionX(), i_owner->GetPositionX(), i_owner->GetPositionZ());
|
||||
return;
|
||||
}
|
||||
|
||||
i_owner->SendMonsterMove(x, y, z, moveFlag, time, speedZ);
|
||||
// Abort too if the ground is very near
|
||||
if (fabs(i_owner->GetPositionZ() - tz) < 0.1f)
|
||||
return;
|
||||
|
||||
Movement::MoveSplineInit init(*i_owner);
|
||||
init.MoveTo(i_owner->GetPositionX(),i_owner->GetPositionY(),tz);
|
||||
init.SetFall();
|
||||
init.Launch();
|
||||
Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id)
|
||||
@@ -396,29 +398,19 @@ void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id)
|
||||
if (Impl[MOTION_SLOT_CONTROLLED] && Impl[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE)
|
||||
return;
|
||||
|
||||
i_owner->AddUnitState(UNIT_STAT_CHARGING);
|
||||
i_owner->m_TempSpeed = speed;
|
||||
if (i_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
sLog->outStaticDebug("Player (GUID: %u) charge point (X: %f Y: %f Z: %f)", i_owner->GetGUIDLow(), x, y, z);
|
||||
Mutate(new PointMovementGenerator<Player>(id, x, y, z), MOTION_SLOT_CONTROLLED);
|
||||
Mutate(new PointMovementGenerator<Player>(id, x, y, z, speed), MOTION_SLOT_CONTROLLED);
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog->outStaticDebug("Creature (Entry: %u GUID: %u) charge point (X: %f Y: %f Z: %f)",
|
||||
i_owner->GetEntry(), i_owner->GetGUIDLow(), x, y, z);
|
||||
Mutate(new PointMovementGenerator<Creature>(id, x, y, z), MOTION_SLOT_CONTROLLED);
|
||||
Mutate(new PointMovementGenerator<Creature>(id, x, y, z, speed), MOTION_SLOT_CONTROLLED);
|
||||
}
|
||||
}
|
||||
|
||||
void MotionMaster::MoveFall(float z, uint32 id)
|
||||
{
|
||||
i_owner->SetFlying(false);
|
||||
i_owner->SendMovementFlagUpdate();
|
||||
//AddUnitMovementFlag(MOVEMENTFLAG_FALLING);
|
||||
MoveCharge(i_owner->GetPositionX(), i_owner->GetPositionY(), z, SPEED_CHARGE, id);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveSeekAssistance(float x, float y, float z)
|
||||
{
|
||||
if (i_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -562,7 +554,7 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable)
|
||||
|
||||
//i_owner->GetTypeId() == TYPEID_PLAYER ?
|
||||
//Mutate(new WaypointMovementGenerator<Player>(path_id, repeatable)):
|
||||
Mutate(new WaypointMovementGenerator<Creature>(path_id, repeatable), MOTION_SLOT_IDLE);
|
||||
Mutate(new WaypointMovementGenerator<Creature>(path_id, repeatable), MOTION_SLOT_IDLE);
|
||||
|
||||
sLog->outStaticDebug("%s (GUID: %u) start moving over path(Id:%u, repeatable: %s)",
|
||||
i_owner->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature",
|
||||
@@ -633,8 +625,12 @@ void MotionMaster::DelayedDelete(_Ty curr)
|
||||
|
||||
bool MotionMaster::GetDestination(float &x, float &y, float &z)
|
||||
{
|
||||
if (empty())
|
||||
if (i_owner->movespline->Finalized())
|
||||
return false;
|
||||
|
||||
return top()->GetDestination(x, y, z);
|
||||
const G3D::Vector3& dest = i_owner->movespline->FinalDestination();
|
||||
x = dest.x;
|
||||
y = dest.y;
|
||||
z = dest.z;
|
||||
return true;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ enum MovementGeneratorType
|
||||
MAX_DB_MOTION_TYPE = 3, // *** this and below motion types can't be set in DB.
|
||||
ANIMAL_RANDOM_MOTION_TYPE = MAX_DB_MOTION_TYPE, // AnimalRandomMovementGenerator.h
|
||||
CONFUSED_MOTION_TYPE = 4, // ConfusedMovementGenerator.h
|
||||
TARGETED_MOTION_TYPE = 5, // TargetedMovementGenerator.h
|
||||
CHASE_MOTION_TYPE = 5, // TargetedMovementGenerator.h
|
||||
HOME_MOTION_TYPE = 6, // HomeMovementGenerator.h
|
||||
FLIGHT_MOTION_TYPE = 7, // WaypointMovementGenerator.h
|
||||
POINT_MOTION_TYPE = 8, // PointMovementGenerator.h
|
||||
@@ -48,8 +48,10 @@ enum MovementGeneratorType
|
||||
ASSISTANCE_MOTION_TYPE= 11, // PointMovementGenerator.h (first part of flee for assistance)
|
||||
ASSISTANCE_DISTRACT_MOTION_TYPE = 12, // IdleMovementGenerator.h (second part of flee for assistance)
|
||||
TIMED_FLEEING_MOTION_TYPE = 13, // FleeingMovementGenerator.h (alt.second part of flee for assistance)
|
||||
ROTATE_MOTION_TYPE = 14,
|
||||
NULL_MOTION_TYPE = 15,
|
||||
FOLLOW_MOTION_TYPE = 14,
|
||||
ROTATE_MOTION_TYPE = 15,
|
||||
EFFECT_MOTION_TYPE = 16,
|
||||
NULL_MOTION_TYPE = 17,
|
||||
};
|
||||
|
||||
enum MovementSlot
|
||||
@@ -86,7 +88,6 @@ class MotionMaster //: private std::stack<MovementGenerator *>
|
||||
typedef std::vector<_Ty> ExpireList;
|
||||
int i_top;
|
||||
|
||||
bool empty() const { return (i_top < 0); }
|
||||
void pop() { Impl[i_top] = NULL; --i_top; }
|
||||
void push(_Ty _Val) { ++i_top; Impl[i_top] = _Val; }
|
||||
|
||||
@@ -107,6 +108,7 @@ class MotionMaster //: private std::stack<MovementGenerator *>
|
||||
void Initialize();
|
||||
void InitDefault();
|
||||
|
||||
bool empty() const { return (i_top < 0); }
|
||||
int size() const { return i_top + 1; }
|
||||
_Ty top() const { return Impl[i_top]; }
|
||||
_Ty GetMotionSlot(int slot) const { return Impl[slot]; }
|
||||
@@ -142,7 +144,7 @@ class MotionMaster //: private std::stack<MovementGenerator *>
|
||||
DirectExpire(reset);
|
||||
}
|
||||
|
||||
void MoveIdle(MovementSlot slot = MOTION_SLOT_ACTIVE);
|
||||
void MoveIdle();
|
||||
void MoveTargetedHome();
|
||||
void MoveRandom(float spawndist = 0.0f);
|
||||
void MoveFollow(Unit* target, float dist, float angle, MovementSlot slot = MOTION_SLOT_ACTIVE);
|
||||
@@ -158,10 +160,11 @@ class MotionMaster //: private std::stack<MovementGenerator *>
|
||||
void MoveTakeoff(uint32 id, Position const& pos, float speed);
|
||||
|
||||
void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE);
|
||||
void MoveFall(float z, uint32 id = 0);
|
||||
void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ);
|
||||
void MoveJumpTo(float angle, float speedXY, float speedZ);
|
||||
void MoveJump(float x, float y, float z, float speedXY, float speedZ);
|
||||
void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id = 0);
|
||||
void MoveFall(uint32 id = 0);
|
||||
|
||||
void MoveSeekAssistance(float x, float y, float z);
|
||||
void MoveSeekAssistanceDistract(uint32 timer);
|
||||
void MoveTaxiFlight(uint32 path, uint32 pathnode);
|
||||
|
||||
@@ -21,4 +21,3 @@
|
||||
MovementGenerator::~MovementGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,8 +43,6 @@ class MovementGenerator
|
||||
virtual MovementGeneratorType GetMovementGeneratorType() = 0;
|
||||
|
||||
virtual void unitSpeedChanged() { }
|
||||
|
||||
virtual bool GetDestination(float& /*x*/, float& /*y*/, float& /*z*/) const { return false; }
|
||||
};
|
||||
|
||||
template<class T, class D>
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
|
||||
#include "Creature.h"
|
||||
#include "MapManager.h"
|
||||
#include "Opcodes.h"
|
||||
#include "ConfusedMovementGenerator.h"
|
||||
#include "DestinationHolderImp.h"
|
||||
#include "VMapFactory.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "Player.h"
|
||||
|
||||
#ifdef MAP_BASED_RAND_GEN
|
||||
#define rand_norm() unit.rand_norm()
|
||||
@@ -31,8 +32,8 @@
|
||||
template<class T>
|
||||
void ConfusedMovementGenerator<T>::Initialize(T &unit)
|
||||
{
|
||||
float const wanderDistance = 4;
|
||||
float x, y, z;
|
||||
const float wander_distance=4;
|
||||
float x,y,z;
|
||||
x = unit.GetPositionX();
|
||||
y = unit.GetPositionY();
|
||||
z = unit.GetPositionZ();
|
||||
@@ -44,52 +45,33 @@ void ConfusedMovementGenerator<T>::Initialize(T &unit)
|
||||
bool is_water_ok, is_land_ok;
|
||||
_InitSpecific(unit, is_water_ok, is_land_ok);
|
||||
|
||||
for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx)
|
||||
for (uint8 idx = 0; idx < MAX_CONF_WAYPOINTS + 1; ++idx)
|
||||
{
|
||||
float wanderX = x + wanderDistance * (float)rand_norm() - wanderDistance/2;
|
||||
float wanderY = y + wanderDistance * (float)rand_norm() - wanderDistance/2;
|
||||
Trinity::NormalizeMapCoord(wanderX);
|
||||
Trinity::NormalizeMapCoord(wanderY);
|
||||
const float wanderX=wander_distance*(float)rand_norm() - wander_distance/2;
|
||||
const float wanderY=wander_distance*(float)rand_norm() - wander_distance/2;
|
||||
|
||||
float new_z = map->GetHeight(wanderX, wanderY, z, true);
|
||||
if (new_z > INVALID_HEIGHT && unit.IsWithinLOS(wanderX, wanderY, new_z))
|
||||
{
|
||||
// Don't move in water if we're not already in
|
||||
// Don't move on land if we're not already on it either
|
||||
bool is_water_now = map->IsInWater(x, y, z);
|
||||
bool is_water_next = map->IsInWater(wanderX, wanderY, new_z);
|
||||
if ((is_water_now && !is_water_next && !is_land_ok) || (!is_water_now && is_water_next && !is_water_ok))
|
||||
{
|
||||
i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x; // Back to previous location
|
||||
i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y;
|
||||
i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx-1][2] : z;
|
||||
continue;
|
||||
}
|
||||
i_waypoints[idx][0] = x + wanderX;
|
||||
i_waypoints[idx][1] = y + wanderY;
|
||||
|
||||
// Taken from FleeingMovementGenerator
|
||||
if (!(new_z - z) || wanderDistance / fabs(new_z - z) > 1.0f)
|
||||
{
|
||||
i_waypoints[idx][0] = wanderX;
|
||||
i_waypoints[idx][1] = wanderY;
|
||||
i_waypoints[idx][2] = new_z;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else // Back to previous location
|
||||
// prevent invalid coordinates generation
|
||||
Trinity::NormalizeMapCoord(i_waypoints[idx][0]);
|
||||
Trinity::NormalizeMapCoord(i_waypoints[idx][1]);
|
||||
|
||||
bool is_water = map->IsInWater(i_waypoints[idx][0],i_waypoints[idx][1],z);
|
||||
// if generated wrong path just ignore
|
||||
if ((is_water && !is_water_ok) || (!is_water && !is_land_ok))
|
||||
{
|
||||
i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x;
|
||||
i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y;
|
||||
i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx-1][2] : z;
|
||||
continue;
|
||||
}
|
||||
|
||||
unit.UpdateAllowedPositionZ(i_waypoints[idx][0], i_waypoints[idx][1], z);
|
||||
i_waypoints[idx][2] = z;
|
||||
}
|
||||
|
||||
unit.SetTarget(0);
|
||||
unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
unit.CastStop();
|
||||
unit.StopMoving();
|
||||
unit.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); // Should actually be splineflag
|
||||
unit.AddUnitState(UNIT_STAT_CONFUSED);
|
||||
unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
unit.AddUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
|
||||
}
|
||||
|
||||
template<>
|
||||
@@ -111,69 +93,70 @@ void ConfusedMovementGenerator<T>::Reset(T &unit)
|
||||
{
|
||||
i_nextMove = 1;
|
||||
i_nextMoveTime.Reset(0);
|
||||
i_destinationHolder.ResetUpdate();
|
||||
unit.StopMoving();
|
||||
unit.AddUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff)
|
||||
bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
|
||||
{
|
||||
if (!&unit)
|
||||
return true;
|
||||
|
||||
if (unit.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED))
|
||||
return true;
|
||||
|
||||
if (i_nextMoveTime.Passed())
|
||||
{
|
||||
// currently moving, update location
|
||||
Traveller<T> traveller(unit);
|
||||
if (i_destinationHolder.UpdateTraveller(traveller, diff))
|
||||
{
|
||||
if (i_destinationHolder.HasArrived())
|
||||
{
|
||||
// arrived, stop and wait a bit
|
||||
unit.ClearUnitState(UNIT_STAT_MOVE);
|
||||
unit.AddUnitState(UNIT_STAT_CONFUSED_MOVE);
|
||||
|
||||
i_nextMove = urand(1, MAX_CONF_WAYPOINTS);
|
||||
i_nextMoveTime.Reset(urand(100, 1000));
|
||||
}
|
||||
if (unit.movespline->Finalized())
|
||||
{
|
||||
i_nextMove = urand(1,MAX_CONF_WAYPOINTS);
|
||||
i_nextMoveTime.Reset(urand(0, 1500-1)); // TODO: check the minimum reset time, should be probably higher
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// waiting for next move
|
||||
i_nextMoveTime.Update(diff);
|
||||
if (i_nextMoveTime.Passed())
|
||||
if(i_nextMoveTime.Passed() )
|
||||
{
|
||||
// start moving
|
||||
ASSERT(i_nextMove <= MAX_CONF_WAYPOINTS);
|
||||
const float x = i_waypoints[i_nextMove][0];
|
||||
const float y = i_waypoints[i_nextMove][1];
|
||||
const float z = i_waypoints[i_nextMove][2];
|
||||
Traveller<T> traveller(unit);
|
||||
i_destinationHolder.SetDestination(traveller, x, y, z);
|
||||
unit.AddUnitState(UNIT_STAT_CONFUSED_MOVE);
|
||||
|
||||
ASSERT( i_nextMove <= MAX_CONF_WAYPOINTS );
|
||||
float x = i_waypoints[i_nextMove][0];
|
||||
float y = i_waypoints[i_nextMove][1];
|
||||
float z = i_waypoints[i_nextMove][2];
|
||||
Movement::MoveSplineInit init(unit);
|
||||
init.MoveTo(x, y, z);
|
||||
init.SetWalk(true);
|
||||
init.Launch();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void ConfusedMovementGenerator<T>::Finalize(T &unit)
|
||||
template<>
|
||||
void ConfusedMovementGenerator<Player>::Finalize(Player &unit)
|
||||
{
|
||||
unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
unit.ClearUnitState(UNIT_STAT_CONFUSED);
|
||||
unit.ClearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
|
||||
}
|
||||
|
||||
if (unit.GetTypeId() == TYPEID_UNIT && unit.getVictim())
|
||||
template<>
|
||||
void ConfusedMovementGenerator<Creature>::Finalize(Creature &unit)
|
||||
{
|
||||
unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
unit.ClearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
|
||||
if (unit.getVictim())
|
||||
unit.SetTarget(unit.getVictim()->GetGUID());
|
||||
}
|
||||
|
||||
template void ConfusedMovementGenerator<Player>::Initialize(Player &player);
|
||||
template void ConfusedMovementGenerator<Creature>::Initialize(Creature &creature);
|
||||
template void ConfusedMovementGenerator<Player>::Finalize(Player &player);
|
||||
template void ConfusedMovementGenerator<Creature>::Finalize(Creature &creature);
|
||||
template void ConfusedMovementGenerator<Player>::Reset(Player &player);
|
||||
template void ConfusedMovementGenerator<Creature>::Reset(Creature &creature);
|
||||
template bool ConfusedMovementGenerator<Player>::Update(Player &player, const uint32 diff);
|
||||
template bool ConfusedMovementGenerator<Creature>::Update(Creature &creature, const uint32 diff);
|
||||
template bool ConfusedMovementGenerator<Player>::Update(Player &player, const uint32 &diff);
|
||||
template bool ConfusedMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff);
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
#define TRINITY_CONFUSEDGENERATOR_H
|
||||
|
||||
#include "MovementGenerator.h"
|
||||
#include "DestinationHolder.h"
|
||||
#include "Traveller.h"
|
||||
#include "Timer.h"
|
||||
|
||||
#define MAX_CONF_WAYPOINTS 24
|
||||
|
||||
@@ -35,21 +34,13 @@ class ConfusedMovementGenerator
|
||||
void Initialize(T &);
|
||||
void Finalize(T &);
|
||||
void Reset(T &);
|
||||
bool Update(T &, const uint32);
|
||||
|
||||
bool GetDestination(float &x, float &y, float &z) const
|
||||
{
|
||||
if (i_destinationHolder.HasArrived()) return false;
|
||||
i_destinationHolder.GetDestination(x, y, z);
|
||||
return true;
|
||||
}
|
||||
bool Update(T &, const uint32 &);
|
||||
|
||||
MovementGeneratorType GetMovementGeneratorType() { return CONFUSED_MOTION_TYPE; }
|
||||
private:
|
||||
void _InitSpecific(T &, bool &, bool &);
|
||||
TimeTracker i_nextMoveTime;
|
||||
float i_waypoints[MAX_CONF_WAYPOINTS+1][3];
|
||||
DestinationHolder< Traveller<T> > i_destinationHolder;
|
||||
uint32 i_nextMove;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
#include "CreatureAI.h"
|
||||
#include "MapManager.h"
|
||||
#include "FleeingMovementGenerator.h"
|
||||
#include "DestinationHolderImp.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "MoveSpline.h"
|
||||
|
||||
#define MIN_QUIET_DISTANCE 28.0f
|
||||
#define MAX_QUIET_DISTANCE 43.0f
|
||||
@@ -43,25 +44,12 @@ FleeingMovementGenerator<T>::_setTargetLocation(T &owner)
|
||||
if (!_getPoint(owner, x, y, z))
|
||||
return;
|
||||
|
||||
owner.AddUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING);
|
||||
Traveller<T> traveller(owner);
|
||||
i_destinationHolder.SetDestination(traveller, x, y, z);
|
||||
}
|
||||
owner.AddUnitState(UNIT_STAT_FLEEING_MOVE);
|
||||
|
||||
template<>
|
||||
bool FleeingMovementGenerator<Creature>::GetDestination(float &x, float &y, float &z) const
|
||||
{
|
||||
if (i_destinationHolder.HasArrived())
|
||||
return false;
|
||||
|
||||
i_destinationHolder.GetDestination(x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
bool FleeingMovementGenerator<Player>::GetDestination(float & /*x*/, float & /*y*/, float & /*z*/) const
|
||||
{
|
||||
return false;
|
||||
Movement::MoveSplineInit init(owner);
|
||||
init.MoveTo(x,y,z);
|
||||
init.SetWalk(false);
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@@ -75,10 +63,10 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z)
|
||||
y = owner.GetPositionY();
|
||||
z = owner.GetPositionZ();
|
||||
|
||||
float temp_x, temp_y, angle = 0;
|
||||
float temp_x, temp_y, angle;
|
||||
const Map* _map = owner.GetBaseMap();
|
||||
//primitive path-finding
|
||||
for (uint8 i = 0; i < 18; ++i)
|
||||
for(uint8 i = 0; i < 18; ++i)
|
||||
{
|
||||
if (i_only_forward && i > 2)
|
||||
break;
|
||||
@@ -143,11 +131,11 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z)
|
||||
distance /= 4;
|
||||
break;
|
||||
case 15:
|
||||
angle = i_cur_angle + static_cast<float>(M_PI*3/4);
|
||||
angle = i_cur_angle + static_cast<float>(3*M_PI/4);
|
||||
distance /= 2;
|
||||
break;
|
||||
case 16:
|
||||
angle = i_cur_angle - static_cast<float>(M_PI*3/4);
|
||||
angle = i_cur_angle - static_cast<float>(3*M_PI/4);
|
||||
distance /= 2;
|
||||
break;
|
||||
case 17:
|
||||
@@ -161,9 +149,9 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z)
|
||||
Trinity::NormalizeMapCoord(temp_y);
|
||||
if (owner.IsWithinLOS(temp_x, temp_y, z))
|
||||
{
|
||||
bool is_water_now = _map->IsInWater(x, y, z);
|
||||
bool is_water_now = _map->IsInWater(x,y,z);
|
||||
|
||||
if (is_water_now && _map->IsInWater(temp_x, temp_y, z))
|
||||
if (is_water_now && _map->IsInWater(temp_x,temp_y,z))
|
||||
{
|
||||
x = temp_x;
|
||||
y = temp_y;
|
||||
@@ -181,8 +169,8 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z)
|
||||
|
||||
if (!(new_z - z) || distance / fabs(new_z - z) > 1.0f)
|
||||
{
|
||||
float new_z_left = _map->GetHeight(temp_x + (float)(cos(angle+M_PI/2)), temp_y + (float)(sin(angle+M_PI/2)), z, true);
|
||||
float new_z_right = _map->GetHeight(temp_x + (float)(cos(angle-M_PI/2)), temp_y + (float)(sin(angle-M_PI/2)), z, true);
|
||||
float new_z_left = _map->GetHeight(temp_x + 1.0f*cos(angle+static_cast<float>(M_PI/2)),temp_y + 1.0f*sin(angle+static_cast<float>(M_PI/2)),z,true);
|
||||
float new_z_right = _map->GetHeight(temp_x + 1.0f*cos(angle-static_cast<float>(M_PI/2)),temp_y + 1.0f*sin(angle-static_cast<float>(M_PI/2)),z,true);
|
||||
if (fabs(new_z_left - new_z) < 1.2f && fabs(new_z_right - new_z) < 1.2f)
|
||||
{
|
||||
x = temp_x;
|
||||
@@ -194,7 +182,7 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z)
|
||||
}
|
||||
}
|
||||
i_to_distance_from_caster = 0.0f;
|
||||
i_nextCheckTime.Reset(urand(500, 1000));
|
||||
i_nextCheckTime.Reset( urand(500,1000) );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -213,12 +201,12 @@ FleeingMovementGenerator<T>::_setMoveData(T &owner)
|
||||
(i_last_distance_from_caster < i_to_distance_from_caster && cur_dist_xyz > i_to_distance_from_caster) ||
|
||||
// if we reach bigger distance
|
||||
(cur_dist_xyz > MAX_QUIET_DISTANCE) || // if we are too far
|
||||
(i_last_distance_from_caster > MIN_QUIET_DISTANCE && cur_dist_xyz < MIN_QUIET_DISTANCE))
|
||||
(i_last_distance_from_caster > MIN_QUIET_DISTANCE && cur_dist_xyz < MIN_QUIET_DISTANCE) )
|
||||
// if we leave 'quiet zone'
|
||||
{
|
||||
// we are very far or too close, stopping
|
||||
i_to_distance_from_caster = 0.0f;
|
||||
i_nextCheckTime.Reset(urand(500, 1000));
|
||||
i_nextCheckTime.Reset( urand(500,1000) );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -232,9 +220,7 @@ FleeingMovementGenerator<T>::_setMoveData(T &owner)
|
||||
float cur_dist;
|
||||
float angle_to_caster;
|
||||
|
||||
Unit* fright = ObjectAccessor::GetUnit(owner, i_frightGUID);
|
||||
|
||||
if (fright)
|
||||
if (Unit* fright = ObjectAccessor::GetUnit(owner, i_frightGUID))
|
||||
{
|
||||
cur_dist = fright->GetDistance(&owner);
|
||||
if (cur_dist < cur_dist_xyz)
|
||||
@@ -284,7 +270,7 @@ FleeingMovementGenerator<T>::_setMoveData(T &owner)
|
||||
i_to_distance_from_caster = MIN_QUIET_DISTANCE + 2.5f + (float)rand_norm()*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE - 2.5f);
|
||||
}
|
||||
|
||||
int8 sign = rand_norm() > 0.5f ? 1 : -1;
|
||||
int8 sign = (float)rand_norm() > 0.5f ? 1 : -1;
|
||||
i_cur_angle = sign*angle + angle_to_caster;
|
||||
|
||||
// current distance
|
||||
@@ -300,14 +286,12 @@ FleeingMovementGenerator<T>::Initialize(T &owner)
|
||||
if (!&owner)
|
||||
return;
|
||||
|
||||
_Init(owner);
|
||||
owner.CastStop();
|
||||
owner.AddUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING);
|
||||
owner.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner.SetTarget(0);
|
||||
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
owner.AddUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
|
||||
|
||||
if (Unit* fright = ObjectAccessor::GetUnit(owner, i_frightGUID))
|
||||
_Init(owner);
|
||||
|
||||
if (Unit *fright = ObjectAccessor::GetUnit(owner, i_frightGUID))
|
||||
{
|
||||
i_caster_x = fright->GetPositionX();
|
||||
i_caster_y = fright->GetPositionY();
|
||||
@@ -334,6 +318,7 @@ FleeingMovementGenerator<Creature>::_Init(Creature &owner)
|
||||
if (!&owner)
|
||||
return;
|
||||
|
||||
//owner.SetTargetGuid(ObjectGuid());
|
||||
is_water_ok = owner.canSwim();
|
||||
is_land_ok = owner.canWalk();
|
||||
}
|
||||
@@ -346,51 +331,44 @@ FleeingMovementGenerator<Player>::_Init(Player &)
|
||||
is_land_ok = true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void
|
||||
FleeingMovementGenerator<T>::Finalize(T &owner)
|
||||
template<>
|
||||
void FleeingMovementGenerator<Player>::Finalize(Player &owner)
|
||||
{
|
||||
owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner.ClearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING);
|
||||
if (owner.GetTypeId() == TYPEID_UNIT && owner.getVictim())
|
||||
owner.ClearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
|
||||
}
|
||||
|
||||
template<>
|
||||
void FleeingMovementGenerator<Creature>::Finalize(Creature &owner)
|
||||
{
|
||||
owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner.ClearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
|
||||
if (owner.getVictim())
|
||||
owner.SetTarget(owner.getVictim()->GetGUID());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void
|
||||
FleeingMovementGenerator<T>::Reset(T &owner)
|
||||
void FleeingMovementGenerator<T>::Reset(T &owner)
|
||||
{
|
||||
Initialize(owner);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool
|
||||
FleeingMovementGenerator<T>::Update(T &owner, const uint32 time_diff)
|
||||
FleeingMovementGenerator<T>::Update(T &owner, const uint32 &time_diff)
|
||||
{
|
||||
if (!&owner || !owner.isAlive())
|
||||
return false;
|
||||
if (owner.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED))
|
||||
{
|
||||
owner.ClearUnitState(UNIT_STAT_FLEEING_MOVE);
|
||||
return true;
|
||||
|
||||
Traveller<T> traveller(owner);
|
||||
}
|
||||
|
||||
i_nextCheckTime.Update(time_diff);
|
||||
|
||||
if ((owner.IsStopped() && !i_destinationHolder.HasArrived()) || !i_destinationHolder.HasDestination())
|
||||
{
|
||||
if (i_nextCheckTime.Passed() && owner.movespline->Finalized())
|
||||
_setTargetLocation(owner);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (i_destinationHolder.UpdateTraveller(traveller, time_diff))
|
||||
{
|
||||
i_destinationHolder.ResetUpdate(50);
|
||||
if (i_nextCheckTime.Passed() && i_destinationHolder.HasArrived())
|
||||
{
|
||||
_setTargetLocation(owner);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -402,17 +380,15 @@ template bool FleeingMovementGenerator<Player>::_getPoint(Player &, float &, flo
|
||||
template bool FleeingMovementGenerator<Creature>::_getPoint(Creature &, float &, float &, float &);
|
||||
template void FleeingMovementGenerator<Player>::_setTargetLocation(Player &);
|
||||
template void FleeingMovementGenerator<Creature>::_setTargetLocation(Creature &);
|
||||
template void FleeingMovementGenerator<Player>::Finalize(Player &);
|
||||
template void FleeingMovementGenerator<Creature>::Finalize(Creature &);
|
||||
template void FleeingMovementGenerator<Player>::Reset(Player &);
|
||||
template void FleeingMovementGenerator<Creature>::Reset(Creature &);
|
||||
template bool FleeingMovementGenerator<Player>::Update(Player &, const uint32);
|
||||
template bool FleeingMovementGenerator<Creature>::Update(Creature &, const uint32);
|
||||
template bool FleeingMovementGenerator<Player>::Update(Player &, const uint32 &);
|
||||
template bool FleeingMovementGenerator<Creature>::Update(Creature &, const uint32 &);
|
||||
|
||||
void TimedFleeingMovementGenerator::Finalize(Unit &owner)
|
||||
{
|
||||
owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner.ClearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING);
|
||||
owner.ClearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
|
||||
if (Unit* victim = owner.getVictim())
|
||||
{
|
||||
if (owner.isAlive())
|
||||
@@ -429,13 +405,20 @@ bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32 time_diff)
|
||||
return false;
|
||||
|
||||
if (owner.HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED))
|
||||
{
|
||||
owner.ClearUnitState(UNIT_STAT_FLEEING_MOVE);
|
||||
return true;
|
||||
}
|
||||
|
||||
i_totalFleeTime.Update(time_diff);
|
||||
if (i_totalFleeTime.Passed())
|
||||
return false;
|
||||
|
||||
// This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, const uint32) version
|
||||
i_totalFleeTime.Update(time_diff);
|
||||
if (i_totalFleeTime.Passed())
|
||||
return false;
|
||||
|
||||
// This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, const uint32 &) version
|
||||
// This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly
|
||||
return MovementGeneratorMedium< Creature, FleeingMovementGenerator<Creature> >::Update(owner, time_diff);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#define TRINITY_FLEEINGMOVEMENTGENERATOR_H
|
||||
|
||||
#include "MovementGenerator.h"
|
||||
#include "DestinationHolder.h"
|
||||
#include "Traveller.h"
|
||||
|
||||
template<class T>
|
||||
class FleeingMovementGenerator
|
||||
@@ -33,8 +31,7 @@ class FleeingMovementGenerator
|
||||
void Initialize(T &);
|
||||
void Finalize(T &);
|
||||
void Reset(T &);
|
||||
bool Update(T &, const uint32);
|
||||
bool GetDestination(float &x, float &y, float &z) const;
|
||||
bool Update(T &, const uint32 &);
|
||||
|
||||
MovementGeneratorType GetMovementGeneratorType() { return FLEEING_MOTION_TYPE; }
|
||||
|
||||
@@ -56,8 +53,6 @@ class FleeingMovementGenerator
|
||||
float i_cur_angle;
|
||||
uint64 i_frightGUID;
|
||||
TimeTracker i_nextCheckTime;
|
||||
|
||||
DestinationHolder< Traveller<T> > i_destinationHolder;
|
||||
};
|
||||
|
||||
class TimedFleeingMovementGenerator
|
||||
|
||||
Loaded 100 of 491 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user