Permalink
Browse files

Core/Entities: bg vehicle will also have charmer's faction (save fact…

…ion before charm and restore old faction after charm)
  • Loading branch information...
1 parent 45dc95c commit 940e52236b6e7653d4a1c72f8a82fa0f5bece11d @joschiwald joschiwald committed Jan 17, 2014
View
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2013 Trinity <http://www.trinitycore.org/>
+# Copyright (C) 2008-2014 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
@@ -23,6 +23,10 @@
#include "ObjectAccessor.h"
#include "Player.h"
+/////////////////
+// AggressorAI
+/////////////////
+
int AggressorAI::Permissible(const Creature* creature)
{
// have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight
@@ -40,26 +44,9 @@ void AggressorAI::UpdateAI(uint32 /*diff*/)
DoMeleeAttackIfReady();
}
-// some day we will delete these useless things
-int CombatAI::Permissible(const Creature* /*creature*/)
-{
- return PERMIT_BASE_NO;
-}
-
-int ArcherAI::Permissible(const Creature* /*creature*/)
-{
- return PERMIT_BASE_NO;
-}
-
-int TurretAI::Permissible(const Creature* /*creature*/)
-{
- return PERMIT_BASE_NO;
-}
-
-int VehicleAI::Permissible(const Creature* /*creature*/)
-{
- return PERMIT_BASE_NO;
-}
+/////////////////
+// CombatAI
+/////////////////
void CombatAI::InitializeAI()
{
@@ -118,7 +105,7 @@ void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs)
}
/////////////////
-//CasterAI
+// CasterAI
/////////////////
void CasterAI::InitializeAI()
@@ -182,7 +169,7 @@ void CasterAI::UpdateAI(uint32 diff)
}
//////////////
-//ArcherAI
+// ArcherAI
//////////////
ArcherAI::ArcherAI(Creature* c) : CreatureAI(c)
@@ -231,7 +218,7 @@ void ArcherAI::UpdateAI(uint32 /*diff*/)
}
//////////////
-//TurretAI
+// TurretAI
//////////////
TurretAI::TurretAI(Creature* c) : CreatureAI(c)
@@ -269,17 +256,17 @@ void TurretAI::UpdateAI(uint32 /*diff*/)
}
//////////////
-//VehicleAI
+// VehicleAI
//////////////
-VehicleAI::VehicleAI(Creature* c) : CreatureAI(c), m_IsVehicleInUse(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME)
+VehicleAI::VehicleAI(Creature* creature) : CreatureAI(creature), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME)
{
LoadConditions();
m_DoDismiss = false;
m_DismissTimer = VEHICLE_DISMISS_TIME;
}
-//NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted
+// NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted
void VehicleAI::UpdateAI(uint32 diff)
{
CheckConditions(diff);
@@ -289,32 +276,23 @@ void VehicleAI::UpdateAI(uint32 diff)
if (m_DismissTimer < diff)
{
m_DoDismiss = false;
- me->SetVisible(false);
me->DespawnOrUnsummon();
}
else
m_DismissTimer -= diff;
}
}
-void VehicleAI::Reset()
-{
- me->SetVisible(true);
-}
-
void VehicleAI::OnCharmed(bool apply)
{
- if (m_IsVehicleInUse && !apply && !conditions.empty())//was used and has conditions
+ if (!me->GetVehicleKit()->IsVehicleInUse() && !apply && !conditions.empty()) // was used and has conditions
{
- m_DoDismiss = true;//needs reset
- me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE);
- me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
+ m_DoDismiss = true; // needs reset
}
else if (apply)
- m_DoDismiss = false;//in use again
+ m_DoDismiss = false; // in use again
- m_DismissTimer = VEHICLE_DISMISS_TIME;//reset timer
- m_IsVehicleInUse = apply;
+ m_DismissTimer = VEHICLE_DISMISS_TIME; // reset timer
}
void VehicleAI::LoadConditions()
@@ -324,7 +302,7 @@ void VehicleAI::LoadConditions()
TC_LOG_DEBUG("condition", "VehicleAI::LoadConditions: loaded %u conditions", uint32(conditions.size()));
}
-void VehicleAI::CheckConditions(const uint32 diff)
+void VehicleAI::CheckConditions(uint32 diff)
{
if (m_ConditionsTimer < diff)
{
@@ -339,7 +317,7 @@ void VehicleAI::CheckConditions(const uint32 diff)
if (!sConditionMgr->IsObjectMeetToConditions(player, me, conditions))
{
player->ExitVehicle();
- return;//check other pessanger in next tick
+ return; // check other pessanger in next tick
}
}
}
@@ -47,7 +47,9 @@ class CombatAI : public CreatureAI
void JustDied(Unit* killer);
void UpdateAI(uint32 diff);
void SpellInterrupted(uint32 spellId, uint32 unTimeMs);
- static int Permissible(const Creature*);
+
+ static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
+
protected:
EventMap events;
SpellVct spells;
@@ -72,7 +74,8 @@ struct ArcherAI : public CreatureAI
void AttackStart(Unit* who);
void UpdateAI(uint32 diff);
- static int Permissible(Creature const*);
+ static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
+
protected:
float m_minRange;
};
@@ -85,29 +88,30 @@ struct TurretAI : public CreatureAI
void AttackStart(Unit* who);
void UpdateAI(uint32 diff);
- static int Permissible(Creature const*);
+ static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
+
protected:
float m_minRange;
};
#define VEHICLE_CONDITION_CHECK_TIME 1000
#define VEHICLE_DISMISS_TIME 5000
+
struct VehicleAI : public CreatureAI
{
public:
- explicit VehicleAI(Creature* c);
+ explicit VehicleAI(Creature* creature);
void UpdateAI(uint32 diff);
- static int Permissible(Creature const*);
- void Reset();
void MoveInLineOfSight(Unit*) { }
void AttackStart(Unit*) { }
void OnCharmed(bool apply);
+ static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
+
private:
- bool m_IsVehicleInUse;
void LoadConditions();
- void CheckConditions(const uint32 diff);
+ void CheckConditions(uint32 diff);
ConditionList conditions;
uint32 m_ConditionsTimer;
bool m_DoDismiss;
@@ -759,7 +759,6 @@ Player::Player(WorldSession* session): Unit(true)
m_ArmorProficiency = 0;
m_canParry = false;
m_canBlock = false;
- m_canDualWield = false;
m_canTitanGrip = false;
m_ammoDPS = 0.0f;
@@ -23769,14 +23768,18 @@ void Player::ResurectUsingRequestData()
SpawnCorpseBones();
}
-void Player::SetClientControl(Unit* target, uint8 allowMove)
+void Player::SetClientControl(Unit* target, bool allowMove)
{
WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size()+1);
data.append(target->GetPackGUID());
- data << uint8(allowMove);
+ data << uint8(allowMove ? 1 : 0);
GetSession()->SendPacket(&data);
- if (target == this)
- SetMover(this);
+
+ if (this != target)
+ SetViewpoint(target, allowMove);
+
+ if (allowMove)
+ SetMover(target);
}
void Player::SetMover(Unit* target)
@@ -2088,7 +2088,7 @@ class Player : public Unit, public GridObject<Player>
bool IsKnowHowFlyIn(uint32 mapid, uint32 zone) const;
- void SetClientControl(Unit* target, uint8 allowMove);
+ void SetClientControl(Unit* target, bool allowMove);
void SetMover(Unit* target);
Oops, something went wrong.

1 comment on commit 940e522

@2010phenix

thx man.

Please sign in to comment.