aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-09-01 00:17:39 -0500
committermegamage <none@none>2009-09-01 00:17:39 -0500
commit33a0155281ca0ffb01cf47cddd690249c134ad89 (patch)
treebb016d3c03b5aa07a5e212e7e6590685559dc1c6
parent83ea85f9e46bbda023fb5d540c08faa10fc980ed (diff)
*Allow pet to have combo points.
--HG-- branch : trunk
-rw-r--r--src/game/Player.cpp10
-rw-r--r--src/game/Player.h7
-rw-r--r--src/game/Spell.cpp17
-rw-r--r--src/game/SpellAuras.cpp2
-rw-r--r--src/game/SpellEffects.cpp4
-rw-r--r--src/game/Unit.cpp21
-rw-r--r--src/game/Unit.h3
-rw-r--r--src/game/Wintergrasp.cpp10
8 files changed, 49 insertions, 25 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index b5d04c40741..215a1644134 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -463,6 +463,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
//m_unit_movement_flags = 0;
m_mover = this;
+ m_movedPlayer = this;
m_seer = this;
m_contestedPvPTimer = 0;
@@ -19172,7 +19173,14 @@ void Player::SendComboPoints()
Unit *combotarget = ObjectAccessor::GetUnit(*this, m_comboTarget);
if (combotarget)
{
- WorldPacket data(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1);
+ WorldPacket data;
+ if(m_mover != this)
+ {
+ data.Initialize(SMSG_PET_UPDATE_COMBO_POINTS, m_mover->GetPackGUID().size()+combotarget->GetPackGUID().size()+1);
+ data.append(m_mover->GetPackGUID());
+ }
+ else
+ data.Initialize(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1);
data.append(combotarget->GetPackGUID());
data << uint8(m_comboPoints);
GetSession()->SendPacket(&data);
diff --git a/src/game/Player.h b/src/game/Player.h
index 31bcadcf3f0..81616f279db 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -2062,7 +2062,12 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetClientControl(Unit* target, uint8 allowMove);
- void SetMover(Unit* target) { m_mover = target; }
+ void SetMover(Unit* target)
+ {
+ m_mover->m_movedPlayer = NULL;
+ m_mover = target;
+ m_mover->m_movedPlayer = this;
+ }
void SetSeer(WorldObject *target) { m_seer = target; }
void SetViewpoint(WorldObject *target, bool apply);
WorldObject* GetViewpoint() const;
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index a7fd33405c6..2f0b3a33a9f 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -2675,7 +2675,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect* triggeredByAura
prepareDataForTriggerSystem(triggeredByAura);
// Set combo point requirement
- if (m_IsTriggeredSpell || m_CastItem || m_caster->GetTypeId()!=TYPEID_PLAYER)
+ if (m_IsTriggeredSpell || m_CastItem || !m_caster->m_movedPlayer)
m_needComboPoints = false;
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
@@ -3173,13 +3173,16 @@ void Spell::_handle_immediate_phase()
void Spell::_handle_finish_phase()
{
- // Take for real after all targets are processed
- if (m_needComboPoints)
- ((Player*)m_caster)->ClearComboPoints();
+ if(m_caster->m_movedPlayer)
+ {
+ // Take for real after all targets are processed
+ if (m_needComboPoints)
+ m_caster->m_movedPlayer->ClearComboPoints();
- // Real add combo points from effects
- if (m_caster->GetTypeId()==TYPEID_PLAYER)
- ((Player*)m_caster)->GainSpellComboPoints(m_comboPointGain);
+ // Real add combo points from effects
+ if (m_comboPointGain)
+ m_caster->m_movedPlayer->GainSpellComboPoints(m_comboPointGain);
+ }
// spell log
if(m_needSpellLog)
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 7970d8a6e1a..4311a0c208e 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -5524,7 +5524,7 @@ void AuraEffect::HandleAuraAllowFlight(bool apply, bool Real, bool /*changeAmoun
if(m_target->GetTypeId() == TYPEID_UNIT)
m_target->SetFlying(apply);
- if(Player *plr = m_target->GetMoverSource())
+ if(Player *plr = m_target->m_movedPlayer)
{
// allow fly
WorldPacket data;
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 8629c544b28..f3a79fdb96f 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -5737,13 +5737,13 @@ void Spell::EffectAddComboPoints(uint32 /*i*/)
if(!unitTarget)
return;
- if(m_caster->GetTypeId() != TYPEID_PLAYER)
+ if(!m_caster->m_movedPlayer)
return;
if(damage <= 0)
return;
- ((Player*)m_caster)->AddComboPoints(unitTarget, damage, this);
+ m_caster->m_movedPlayer->AddComboPoints(unitTarget, damage, this);
}
void Spell::EffectDuel(uint32 i)
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index a109da3860f..783af94ed47 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -94,6 +94,7 @@ Unit::Unit()
, m_NotifyListPos(-1), m_Notified(false), IsAIEnabled(false), NeedChangeAI(false)
, i_AI(NULL), i_disabledAI(NULL), m_removedAurasCount(0), m_vehicle(NULL), m_transport(NULL)
, m_ControlledByPlayer(false), m_procDeep(0), m_unitTypeMask(UNIT_MASK_NONE), m_vehicleKit(NULL)
+, m_movedPlayer(NULL)
{
m_objectType |= TYPEMASK_UNIT;
m_objectTypeId = TYPEID_UNIT;
@@ -8921,6 +8922,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
return nearMembers[randTarget];
}
+/*
Player * Unit::GetMoverSource() const
{
if(GetTypeId() == TYPEID_PLAYER && ((Player*)this)->m_mover == this)
@@ -8930,6 +8932,7 @@ Player * Unit::GetMoverSource() const
return (Player*)charmer;
return NULL;
}
+*/
//only called in Player::SetSeer
void Unit::AddPlayerToVision(Player* plr)
@@ -11340,10 +11343,6 @@ Unit* Creature::SelectVictim()
int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 effBasePoints, Unit const* /*target*/)
{
- Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL;
-
- uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0;
-
int32 level = int32(getLevel());
if (level > (int32)spellProto->maxLevel && spellProto->maxLevel > 0)
level = (int32)spellProto->maxLevel;
@@ -11355,7 +11354,6 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
float randomPointsPerLevel = spellProto->EffectDicePerLevel[effect_index];
int32 basePoints = int32(effBasePoints + level * basePointsPerLevel);
int32 randomPoints = int32(spellProto->EffectDieSides[effect_index] + level * randomPointsPerLevel);
- float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index];
// range can have possitive and negative values, so order its for irand
int32 randvalue = int32(spellProto->EffectBaseDice[effect_index]) >= randomPoints
@@ -11364,8 +11362,11 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
int32 value = basePoints + randvalue;
//random damage
- if(comboDamage != 0 && unitPlayer /*&& target && (target->GetGUID() == unitPlayer->GetComboTarget())*/)
- value += (int32)(comboDamage * comboPoints);
+ //if(comboDamage != 0 && unitPlayer /*&& target && (target->GetGUID() == unitPlayer->GetComboTarget())*/)
+ if(m_movedPlayer)
+ if(uint8 comboPoints = m_movedPlayer->GetComboPoints())
+ if(float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index])
+ value += (int32)(comboDamage * comboPoints);
if(Player* modOwner = GetSpellModOwner())
{
@@ -11400,16 +11401,14 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
int32 Unit::CalcSpellDuration(SpellEntry const* spellProto)
{
- Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL;
-
- uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0;
+ uint8 comboPoints = m_movedPlayer ? m_movedPlayer->GetComboPoints() : 0;
int32 minduration = GetSpellDuration(spellProto);
int32 maxduration = GetSpellMaxDuration(spellProto);
int32 duration;
- if( minduration != -1 && minduration != maxduration )
+ if(comboPoints && minduration != -1 && minduration != maxduration)
duration = minduration + int32((maxduration - minduration) * comboPoints / 5);
else
duration = minduration;
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 608dffcccd9..914129bda07 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1458,7 +1458,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
CharmInfo* InitCharmInfo();
void DeleteCharmInfo();
void UpdateCharmAI();
- Player * GetMoverSource() const;
+ //Player * GetMoverSource() const;
+ Player *m_movedPlayer;
SharedVisionList const& GetSharedVisionList() { return m_sharedVision; }
void AddPlayerToVision(Player* plr);
void RemovePlayerFromVision(Player* plr);
diff --git a/src/game/Wintergrasp.cpp b/src/game/Wintergrasp.cpp
index fa387f8d926..1fdeaae5f00 100644
--- a/src/game/Wintergrasp.cpp
+++ b/src/game/Wintergrasp.cpp
@@ -140,7 +140,9 @@ bool OPvPWintergrasp::SetupOutdoorPvP()
TeamId teamId = x > POS_X_CENTER ? m_defender : OTHER_TEAM(m_defender);
m_buildingStates[guid] = new BuildingState((*poi)->worldState, teamId, m_defender != TEAM_ALLIANCE);
if((*poi)->id == 2246)
+ {
m_gate = m_buildingStates[guid];
+ }
areaPOIs.erase(poi);
//disable for now
@@ -229,6 +231,12 @@ bool OPvPWintergrasp::SetupOutdoorPvP()
}while(result->NextRow());
delete result;
+ if(!m_gate)
+ {
+ sLog.outError("Cannot find wintergrasp fortress gate!");
+ return false;
+ }
+
// Load Graveyard
GraveYardMap::const_iterator graveLow = objmgr.mGraveYardMap.lower_bound(ZONE_WINTERGRASP);
GraveYardMap::const_iterator graveUp = objmgr.mGraveYardMap.upper_bound(ZONE_WINTERGRASP);
@@ -286,7 +294,7 @@ void OPvPWintergrasp::ProcessEvent(GameObject *obj, uint32 eventId)
{
if(eventId == 19982)
{
- if(m_wartime && m_gate->damageState == DAMAGE_DESTROYED)
+ if(m_wartime && m_gate && m_gate->damageState == DAMAGE_DESTROYED)
{
m_changeDefender = true;
m_timer = 0;