--HG--
branch : trunk
This commit is contained in:
Machiavelli
2009-08-28 01:57:29 +02:00
16 changed files with 148 additions and 85 deletions
+10 -2
View File
@@ -1706,8 +1706,16 @@ bool Creature::canStartAttack(Unit const* who, bool force) const
// TODO: should switch to range attack
return false;
if(!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who) + m_CombatDistance)))
return false;
if(!force)
{
if(who->isInCombat())
if(Unit *victim = who->getAttackerForHelper())
if(IsWithinDistInMap(victim, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS)))
force = true;
if(!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who) + m_CombatDistance)))
return false;
}
if(!canCreatureAttack(who, force))
return false;
+4 -5
View File
@@ -110,11 +110,10 @@ void CreatureAI::MoveInLineOfSight(Unit *who)
if(me->canStartAttack(who, false))
AttackStart(who);
else if(who->getVictim() && me->IsFriendlyTo(who)
&& me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
//&& me->canStartAttack(who->getVictim(), true))
&& me->canStartAttack(who->getVictim(), false)) // TODO: if we use true, it will not attack it when it arrives
me->GetMotionMaster()->MoveChase(who->getVictim());
//else if(who->getVictim() && me->IsFriendlyTo(who)
// && me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
// && me->canStartAttack(who->getVictim(), true)) // TODO: if we use true, it will not attack it when it arrives
// me->GetMotionMaster()->MoveChase(who->getVictim());
}
void CreatureAI::SelectNearestTarget(Unit *who)
+6 -7
View File
@@ -53,7 +53,7 @@ void DynamicObject::RemoveFromWorld()
///- Remove the dynamicObject from the accessor
if(IsInWorld())
{
if(m_effIndex == 4)
if(m_isWorldObject)
{
if(Unit *caster = GetCaster())
{
@@ -70,7 +70,7 @@ void DynamicObject::RemoveFromWorld()
}
}
bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius )
bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effMask, float x, float y, float z, int32 duration, float radius, bool active)
{
SetMap(caster->GetMap());
@@ -78,7 +78,7 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32
if(!IsPositionValid())
{
sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY());
sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effMask,GetPositionX(),GetPositionY());
return false;
}
@@ -97,12 +97,11 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32
m_aliveDuration = duration;
m_radius = radius;
m_effIndex = effIndex;
m_effMask = effMask;
m_spellId = spellId;
m_updateTimer = 0;
if(m_effIndex == 4)
m_isWorldObject = true;
m_isWorldObject = active;
return true;
}
@@ -129,7 +128,7 @@ void DynamicObject::Update(uint32 p_time)
else
deleteThis = true;
if(m_effIndex < 4)
if(m_effMask)
{
if(m_updateTimer < p_time)
{
+5 -3
View File
@@ -35,11 +35,13 @@ class DynamicObject : public WorldObject
void AddToWorld();
void RemoveFromWorld();
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius);
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effMask, float x, float y, float z, int32 duration, float radius, bool active);
void Update(uint32 p_time);
void Delete();
uint32 GetSpellId() const { return m_spellId; }
uint32 GetEffIndex() const { return m_effIndex; }
uint32 GetEffectMask() const { return m_effMask; }
void AddEffect(uint32 effIndex) { m_effMask |= (1<<effIndex); }
bool HasEffect(uint32 effIndex) const { return m_effMask & (1<<effIndex); }
uint32 GetDuration() const { return m_aliveDuration; }
uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
Unit* GetCaster() const;
@@ -59,7 +61,7 @@ class DynamicObject : public WorldObject
GridReference<DynamicObject> &GetGridRef() { return m_gridRef; }
protected:
uint32 m_spellId;
uint32 m_effIndex;
uint32 m_effMask;
int32 m_aliveDuration;
uint32 m_updateTimer;
time_t m_nextThinkTime;
+15 -6
View File
@@ -178,8 +178,16 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
if (i_dynobject.IsAffecting(target))
return;
uint32 eff_index = i_dynobject.GetEffIndex();
if(target->HasAuraEffect(i_dynobject.GetSpellId(), eff_index, i_check->GetGUID()))
if(target->HasAura(i_dynobject.GetSpellId(), i_check->GetGUID()))
return;
uint32 eff_index = 0;
for(; eff_index < MAX_SPELL_EFFECTS; ++eff_index)
if(i_dynobject.HasEffect(eff_index))
break;
if(eff_index == MAX_SPELL_EFFECTS)
return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId());
@@ -207,11 +215,12 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
// Check target immune to spell or aura
if (target->IsImmunedToSpell(spellInfo) || target->IsImmunedToSpellEffect(spellInfo, eff_index))
return;
// Apply PersistentAreaAura on target
if(Aura *aur = target->AddAuraEffect(spellInfo, eff_index, &i_dynobject, i_dynobject.GetCaster()))
aur->SetAuraDuration(i_dynobject.GetDuration());
i_dynobject.AddAffected(target);
// Apply PersistentAreaAura on target
Aura *aur = new Aura(spellInfo, i_dynobject.GetEffectMask(), target, &i_dynobject, i_check);
aur->SetAuraDuration(i_dynobject.GetDuration());
if(target->AddAura(aur, true))
i_dynobject.AddAffected(target);
}
template<>
+4 -18
View File
@@ -450,6 +450,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
m_preCastSpell = 0;
m_triggeredByAuraSpell = NULL;
m_spellAura = NULL;
m_spellDynObj = NULL;
//Auto Shot & Shoot (wand)
m_autoRepeat = IsAutoRepeatRangedSpell(m_spellInfo);
@@ -4487,17 +4488,6 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_BAD_TARGETS;
}
}
// Some special spells with non-caster only mode
// Fire Shield
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK &&
m_spellInfo->SpellIconID == 16)
return SPELL_FAILED_BAD_TARGETS;
// Focus Magic (main spell)
if (m_spellInfo->Id == 54646)
return SPELL_FAILED_BAD_TARGETS;
}
// check pet presents
@@ -6048,13 +6038,9 @@ void Spell::DelayedChannel()
}
}
for(int j = 0; j < 3; ++j)
{
// partially interrupt persistent area auras
DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, j);
if(dynObj)
dynObj->Delay(delaytime);
}
// partially interrupt persistent area auras
if(DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id))
dynObj->Delay(delaytime);
SendChannelUpdate(m_timer);
}
+2
View File
@@ -27,6 +27,7 @@
class Unit;
class Player;
class GameObject;
class DynamicObject;
class Aura;
enum SpellCastTargetFlags
@@ -555,6 +556,7 @@ class Spell
GameObject* gameObjTarget;
int32 damage;
Aura * m_spellAura; // only used in DoAllEffectOnTarget
DynamicObject *m_spellDynObj; // only used in DoAllEffectOnTarget
// this is set in Spell Hit, but used in Apply Aura handler
DiminishingLevels m_diminishLevel;
+49 -5
View File
@@ -1006,14 +1006,59 @@ void Aura::HandleAuraSpecificMods(bool apply)
}
}
}
// Sprint (skip non player casted spells by category)
else if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_ROGUE)
{
// Sprint (skip non player casted spells by category)
if(GetSpellProto()->SpellFamilyFlags[0] & 0x40 && GetSpellProto()->Category == 44)
// in official maybe there is only one icon?
if(m_target->HasAura(58039)) // Glyph of Blurred Speed
m_target->CastSpell(m_target, 61922, true); // Sprint (waterwalk)
}
else if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT)
{
// Frost Fever and Blood Plague
if(GetSpellProto()->SpellFamilyFlags[2] & 0x2)
{
// Can't proc on self
if (GetCasterGUID() == m_target->GetGUID())
return;
Unit * caster = GetCaster();
if (!caster)
return;
AuraEffect * aurEff = NULL;
// Ebon Plaguebringer / Crypt Fever
Unit::AuraEffectList const& TalentAuras = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for(Unit::AuraEffectList::const_iterator itr = TalentAuras.begin(); itr != TalentAuras.end(); ++itr)
{
if ((*itr)->GetMiscValue() == 7282)
{
aurEff = *itr;
// Ebon Plaguebringer - end search if found
if ((*itr)->GetSpellProto()->SpellIconID == 1766)
break;
}
}
if (aurEff)
{
uint32 spellId = 0;
switch (aurEff->GetId())
{
// Ebon Plague
case 51161: spellId = 51735; break;
case 51160: spellId = 51734; break;
case 51099: spellId = 51726; break;
// Crypt Fever
case 49632: spellId = 50510; break;
case 49631: spellId = 50509; break;
case 49032: spellId = 50508; break;
default:
sLog.outError("Unknown rank of Crypt Fever/Ebon Plague %d", aurEff->GetId());
}
caster->CastSpell(m_target, spellId, true, 0, GetPartAura(0));
}
}
}
else
{
switch(GetId())
@@ -1809,21 +1854,20 @@ bool Aura::CanBeSaved() const
bool Aura::IsPersistent() const
{
return IS_DYNAMICOBJECT_GUID(m_sourceGuid);
/*
for(uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if(m_partAuras[i] && m_partAuras[i]->IsPersistent())
return true;
}
return false;
*/
}
bool Aura::IsAreaAura() const
{
for(uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if(m_partAuras[i] && m_partAuras[i]->IsAreaAura())
return true;
}
return false;
}
+10 -2
View File
@@ -2926,6 +2926,13 @@ void Spell::EffectCreateRandomItem(uint32 i)
void Spell::EffectPersistentAA(uint32 i)
{
if(m_spellDynObj)
{
assert(ObjectAccessor::GetObjectInWorld(m_spellDynObj->GetGUID(), (DynamicObject*)NULL) == m_spellDynObj);
m_spellDynObj->AddEffect(i);
return;
}
float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if(Player* modOwner = m_originalCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius);
@@ -2933,7 +2940,7 @@ void Spell::EffectPersistentAA(uint32 i)
Unit *caster = m_caster->GetEntry() == WORLD_TRIGGER ? m_originalCaster : m_caster;
int32 duration = GetSpellDuration(m_spellInfo);
DynamicObject* dynObj = new DynamicObject;
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius))
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, 1<<i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius, false))
{
delete dynObj;
return;
@@ -2941,6 +2948,7 @@ void Spell::EffectPersistentAA(uint32 i)
dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee);
caster->AddDynObject(dynObj);
dynObj->GetMap()->Add(dynObj);
m_spellDynObj = dynObj;
}
void Spell::EffectEnergize(uint32 i)
@@ -3718,7 +3726,7 @@ void Spell::EffectAddFarsight(uint32 i)
float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
int32 duration = GetSpellDuration(m_spellInfo);
DynamicObject* dynObj = new DynamicObject;
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, 4, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius))
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, 0, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius, true))
{
delete dynObj;
return;
+26 -28
View File
@@ -4109,6 +4109,10 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
++m_removedAurasCount;
if(Aur->IsPersistent())
if(DynamicObject *dynObj = ObjectAccessor::GetObjectInWorld(Aur->GetSourceGUID(), (DynamicObject*)NULL))
dynObj->RemoveAffected(this);
Aur->UnregisterSingleCastAura();
if(Aur->GetSpellProto()->AuraInterruptFlags)
@@ -4428,24 +4432,6 @@ void Unit::RemoveAllDynObjects()
}
}
DynamicObject * Unit::GetDynObject(uint32 spellId, uint32 effIndex)
{
for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
{
DynamicObject* dynObj = GetMap()->GetDynamicObject(*i);
if(!dynObj)
{
i = m_dynObjGUIDs.erase(i);
continue;
}
if (dynObj->GetSpellId() == spellId && dynObj->GetEffIndex() == effIndex)
return dynObj;
++i;
}
return NULL;
}
DynamicObject * Unit::GetDynObject(uint32 spellId)
{
for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
@@ -14489,17 +14475,12 @@ void Unit::HandleAuraEffect(AuraEffect * aureff, bool apply)
{
if (!aureff->IsApplied())
return;
aureff->SetApplied(false);
// remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order)
m_modAuras[aureff->GetAuraName()].remove(aureff);
aureff->ApplyModifier(false, true);
Unit * caster = aureff->GetParentAura()->GetCaster();
if(caster && aureff->IsPersistent())
{
DynamicObject *dynObj = caster->GetDynObject(aureff->GetId(), aureff->GetEffIndex());
if (dynObj)
dynObj->RemoveAffected(this);
}
// Remove all triggered by aura spells vs unlimited duration
aureff->CleanupTriggeredSpells();
}
@@ -14844,8 +14825,9 @@ void Unit::ExitVehicle()
BuildHeartBeatMsg(&data);
SendMessageToSet(&data, false);
if(vehicle->GetBase()->GetOwnerGUID() == GetGUID())
vehicle->Dismiss();
if(vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
if(((Minion*)vehicle->GetBase())->GetOwner() == this)
vehicle->Dismiss();
}
void Unit::BuildMovementPacket(ByteBuffer *data) const
@@ -15069,22 +15051,38 @@ void Unit::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker
ModifyPower(POWER_RAGE, uint32(addRage*10));
}
void Unit::OutDebugInfo()
void Unit::OutDebugInfo() const
{
sLog.outError("Unit::OutDebugInfo");
sLog.outString("GUID "UI64FMTD", entry %u, type %u, name %s", GetGUID(), GetEntry(), (uint32)GetTypeId(), GetName());
sLog.outString("OwnerGUID "UI64FMTD", MinionGUID "UI64FMTD", CharmerGUID "UI64FMTD", CharmedGUID "UI64FMTD, GetOwnerGUID(), GetMinionGUID(), GetCharmerGUID(), GetCharmGUID());
sLog.outString("In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask);
sLog.outStringInLine("Summon Slot: ");
for(uint32 i = 0; i < MAX_SUMMON_SLOT; ++i)
sLog.outStringInLine(UI64FMTD", ", m_SummonSlot[i]);
sLog.outString();
sLog.outStringInLine("Controlled List: ");
for(ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
sLog.outStringInLine(UI64FMTD", ", (*itr)->GetGUID());
sLog.outString();
sLog.outStringInLine("Aura List: ");
for(AuraMap::const_iterator itr = m_Auras.begin(); itr != m_Auras.end(); ++itr)
sLog.outStringInLine("%u, ", itr->first);
sLog.outString();
if(IsVehicle())
{
sLog.outStringInLine("Passenger List: ");
for(SeatMap::iterator itr = GetVehicleKit()->m_Seats.begin(); itr != GetVehicleKit()->m_Seats.end(); ++itr)
if(Unit *passenger = itr->second.passenger)
sLog.outStringInLine(UI64FMTD", ", passenger->GetGUID());
sLog.outString();
}
if(GetVehicle())
sLog.outString("On vehicle %u.", GetVehicleBase()->GetEntry());
}
+2 -3
View File
@@ -1101,7 +1101,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
{
m_attackers.erase(pAttacker);
}
Unit * getAttackerForHelper() // If someone wants to help, who to give them
Unit * getAttackerForHelper() const // If someone wants to help, who to give them
{
if (getVictim() != NULL)
return getVictim();
@@ -1688,7 +1688,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void setTransForm(uint32 spellid) { m_transform = spellid;}
uint32 getTransForm() const { return m_transform;}
DynamicObject* GetDynObject(uint32 spellId, uint32 effIndex);
DynamicObject* GetDynObject(uint32 spellId);
void AddDynObject(DynamicObject* dynObj);
void RemoveDynObject(uint32 spellid);
@@ -1869,7 +1868,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
virtual float GetFollowAngle() const { return M_PI/2; }
void OutDebugInfo();
void OutDebugInfo() const;
virtual bool isBeingLoaded() const { return false;}
protected:
explicit Unit ();