From 98f5d4ef4a16f13e0c47cc68c934c53dae188257 Mon Sep 17 00:00:00 2001 From: e Date: Tue, 4 Sep 2012 23:04:59 -0400 Subject: [Core, Creature] Implement Creature/Pet Interrupts --- src/server/game/AI/CoreAI/CombatAI.cpp | 4 +++ src/server/game/AI/CoreAI/CombatAI.h | 1 + src/server/game/AI/CoreAI/UnitAI.h | 4 +++ src/server/game/AI/EventAI/CreatureEventAI.cpp | 6 ++++- src/server/game/Entities/Creature/Creature.cpp | 33 +++++++++++++++++++++++ src/server/game/Entities/Creature/Creature.h | 7 +++++ src/server/game/Entities/Pet/Pet.cpp | 37 ++++++++++++++++++++++++++ src/server/game/Entities/Pet/Pet.h | 1 + 8 files changed, 92 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index 7d7a27fce13..d8c0bff0d4e 100755 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -110,6 +110,10 @@ void CombatAI::UpdateAI(const uint32 diff) else DoMeleeAttackIfReady(); } +void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs) +{ + events.RescheduleEvent(spellId, msTime); +} ///////////////// //CasterAI diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h index ad98cec0779..fa31e57d780 100755 --- a/src/server/game/AI/CoreAI/CombatAI.h +++ b/src/server/game/AI/CoreAI/CombatAI.h @@ -46,6 +46,7 @@ class CombatAI : public CreatureAI void EnterCombat(Unit* who); void JustDied(Unit* killer); void UpdateAI(const uint32 diff); + void SpellInterrupted(uint32 spellId, uint32 unTimeMs); static int Permissible(const Creature*); protected: EventMap events; diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 593f0d15e18..bd3b9fa6ee9 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -241,6 +241,10 @@ class UnitAI // Called when the unit heals virtual void HealDone(Unit* /*done_to*/, uint32& /*addhealth*/) {} + + // Called when a spell is interrupted by Spell::EffectInterruptCast + // Use to reschedule next planned cast of spell. + virtual void SpellInterrupted(uint32 /*spellId*/, uint32 /*unTimeMs*/) {} void AttackStartCaster(Unit* victim, float dist); diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index aa14bc1b56e..7bb1a2c8116 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -1308,7 +1308,7 @@ bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool trigger //Silenced so we can't cast if (!triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) return false; - + //Check for power if (!triggered && me->GetPower((Powers)spell->PowerType) < spell->CalcPowerCost(me, spell->GetSchoolMask())) return false; @@ -1316,6 +1316,10 @@ bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool trigger //Unit is out of range of this spell if (!me->IsInRange(target, spell->GetMinRange(false), spell->GetMaxRange(false))) return false; + + //Spell is on cooldown + if (me->HasSpellCooldown(spell->Id)) + return false; return true; } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index afa4b62d8b0..5b0c2c871e7 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2231,6 +2231,39 @@ bool Creature::HasSpellCooldown(uint32 spell_id) const return (itr != m_CreatureSpellCooldowns.end() && itr->second > time(NULL)) || HasCategoryCooldown(spell_id); } +void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) +{ + time_t curTime = time(NULL); + for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i) + { + if (m_spells[i] == 0) + continue; + + uint32 unSpellId = m_spells[i]; + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(unSpellId); + if (!spellInfo) + { + ASSERT(spellInfo); + continue; + } + + // Not send cooldown for this spells + if (spellInfo->Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE) + continue; + + if (spellInfo->PreventionType != SPELL_PREVENTION_TYPE_SILENCE) + continue; + + if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetCreatureSpellCooldownDelay(unSpellId) < unTimeMs) + { + _AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs/IN_MILLISECONDS); + if(UnitAI *ai = GetAI()) + ai->SpellInterrupted(unSpellId, unTimeMs); + } + + } +} + bool Creature::HasSpell(uint32 spellID) const { uint8 i; diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 4dd080f8b15..d1142620bd2 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -540,6 +540,13 @@ class Creature : public Unit, public GridObject, public MapCreature void AddCreatureSpellCooldown(uint32 spellid); bool HasSpellCooldown(uint32 spell_id) const; bool HasCategoryCooldown(uint32 spell_id) const; + uint32 GetCreatureSpellCooldownDelay(uint32 spell_id) const + { + CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id); + time_t t = time(NULL); + return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0); + } + virtual void ProhibitSpellSchool(SpellSchoolMask, uint32); bool HasSpell(uint32 spellID) const; diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 17b214857db..cb5922a03c0 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -2033,3 +2033,40 @@ void Pet::SynchronizeLevelWithOwner() break; } } + +void Pet::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) +{ + WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+m_spells.size()*8); + data << uint64(GetGUID()); + data << uint8(0x0); // flags (0x1, 0x2) + time_t curTime = time(NULL); + for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + { + if (itr->second.state == PETSPELL_REMOVED) + continue; + uint32 unSpellId = itr->first; + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(unSpellId); + if (!spellInfo) + { + ASSERT(spellInfo); + continue; + } + + // Not send cooldown for this spells + if (spellInfo->Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE) + continue; + + if (spellInfo->PreventionType != SPELL_PREVENTION_TYPE_SILENCE) + continue; + + if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetCreatureSpellCooldownDelay(unSpellId) < unTimeMs) + { + data << uint32(unSpellId); + data << uint32(unTimeMs); // in m.secs + _AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs/IN_MILLISECONDS); + } + } + if(Player *owner = GetOwner()) + owner->GetSession()->SendPacket(&data); + +} \ No newline at end of file diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 3475817816d..14888e1a513 100755 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -200,6 +200,7 @@ class Pet : public Guardian bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); void CleanupActionBar(); + virtual void ProhibitSpellSchool(SpellSchoolMask, uint32); PetSpellMap m_spells; AutoSpellList m_autospells; -- cgit v1.2.3 From 89d6900f4bcfaa856032325873dc6c30eed7487b Mon Sep 17 00:00:00 2001 From: e Date: Wed, 5 Sep 2012 01:48:25 -0400 Subject: [CombatAI::SpellInterrupted] Fix Typo --- src/server/game/AI/CoreAI/CombatAI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index d8c0bff0d4e..1547b6f4513 100755 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -112,7 +112,7 @@ void CombatAI::UpdateAI(const uint32 diff) } void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs) { - events.RescheduleEvent(spellId, msTime); + events.RescheduleEvent(spellId, unTimeMs); } ///////////////// -- cgit v1.2.3 From 334c078184e313f3591b43421dc40e613f0eada4 Mon Sep 17 00:00:00 2001 From: Nay Date: Thu, 6 Sep 2012 19:09:02 +0100 Subject: Core/SmartAI: Tiny tiny optimization in an if --- src/server/game/AI/SmartScripts/SmartAI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index a7660a0a44b..7dd4053b82f 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -634,7 +634,7 @@ void SmartAI::SpellHitTarget(Unit* target, const SpellInfo* spellInfo) void SmartAI::DamageTaken(Unit* doneBy, uint32& damage) { GetScript()->ProcessEventsFor(SMART_EVENT_DAMAGED, doneBy, damage); - if ((damage >= me->GetHealth() - mInvincibilityHpLevel) && (mInvincibilityHpLevel > 0)) + if (mInvincibilityHpLevel && (damage >= me->GetHealth() - mInvincibilityHpLevel)) { damage = 0; me->SetHealth(mInvincibilityHpLevel); -- cgit v1.2.3 From 340dc33b52a7491c1e4a620cca9b4d3f2b349dc2 Mon Sep 17 00:00:00 2001 From: Nay Date: Thu, 6 Sep 2012 19:59:27 +0100 Subject: Fix some code style issues in previous PR merge --- src/server/game/AI/CoreAI/CombatAI.cpp | 1 + src/server/game/AI/CoreAI/UnitAI.h | 6 +++--- src/server/game/AI/EventAI/CreatureEventAI.cpp | 4 ++-- src/server/game/Entities/Creature/Creature.cpp | 5 ++--- src/server/game/Entities/Creature/Creature.h | 6 +++--- src/server/game/Entities/Pet/Pet.cpp | 4 ++-- src/server/game/Entities/Pet/Pet.h | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index 1547b6f4513..946fe664798 100755 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -110,6 +110,7 @@ void CombatAI::UpdateAI(const uint32 diff) else DoMeleeAttackIfReady(); } + void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs) { events.RescheduleEvent(spellId, unTimeMs); diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index bd3b9fa6ee9..e824ac0e76b 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -241,9 +241,9 @@ class UnitAI // Called when the unit heals virtual void HealDone(Unit* /*done_to*/, uint32& /*addhealth*/) {} - - // Called when a spell is interrupted by Spell::EffectInterruptCast - // Use to reschedule next planned cast of spell. + + /// Called when a spell is interrupted by Spell::EffectInterruptCast + /// Use to reschedule next planned cast of spell. virtual void SpellInterrupted(uint32 /*spellId*/, uint32 /*unTimeMs*/) {} void AttackStartCaster(Unit* victim, float dist); diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index 7bb1a2c8116..951a035628a 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -1308,7 +1308,7 @@ bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool trigger //Silenced so we can't cast if (!triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) return false; - + //Check for power if (!triggered && me->GetPower((Powers)spell->PowerType) < spell->CalcPowerCost(me, spell->GetSchoolMask())) return false; @@ -1316,7 +1316,7 @@ bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool trigger //Unit is out of range of this spell if (!me->IsInRange(target, spell->GetMinRange(false), spell->GetMaxRange(false))) return false; - + //Spell is on cooldown if (me->HasSpellCooldown(spell->Id)) return false; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 5b0c2c871e7..0b9d0b40b4a 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2238,7 +2238,7 @@ void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs { if (m_spells[i] == 0) continue; - + uint32 unSpellId = m_spells[i]; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(unSpellId); if (!spellInfo) @@ -2257,10 +2257,9 @@ void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetCreatureSpellCooldownDelay(unSpellId) < unTimeMs) { _AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs/IN_MILLISECONDS); - if(UnitAI *ai = GetAI()) + if (UnitAI* ai = GetAI()) ai->SpellInterrupted(unSpellId, unTimeMs); } - } } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index d1142620bd2..7359385cd0a 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -540,13 +540,13 @@ class Creature : public Unit, public GridObject, public MapCreature void AddCreatureSpellCooldown(uint32 spellid); bool HasSpellCooldown(uint32 spell_id) const; bool HasCategoryCooldown(uint32 spell_id) const; - uint32 GetCreatureSpellCooldownDelay(uint32 spell_id) const + uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const { - CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id); + CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId); time_t t = time(NULL); return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0); } - virtual void ProhibitSpellSchool(SpellSchoolMask, uint32); + virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); bool HasSpell(uint32 spellID) const; diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index cb5922a03c0..b2cdb56a33e 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -2066,7 +2066,7 @@ void Pet::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) _AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs/IN_MILLISECONDS); } } - if(Player *owner = GetOwner()) + + if (Player* owner = GetOwner()) owner->GetSession()->SendPacket(&data); - } \ No newline at end of file diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 14888e1a513..c0c47367240 100755 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -200,7 +200,7 @@ class Pet : public Guardian bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); void CleanupActionBar(); - virtual void ProhibitSpellSchool(SpellSchoolMask, uint32); + virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); PetSpellMap m_spells; AutoSpellList m_autospells; -- cgit v1.2.3 From aed0ecd2e4b8471fb1e8e77d4a9c992835f61f7c Mon Sep 17 00:00:00 2001 From: cyberbrest Date: Thu, 6 Sep 2012 20:03:21 +0100 Subject: Core/Conditions: Allow multiple condition for spellclick source type Currently unused in 335 but required for some 434 spellclicks --- src/server/game/Entities/Player/Player.cpp | 6 +++--- src/server/game/Entities/Unit/Unit.cpp | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 65f6588f80e..142b5939d9b 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -24502,11 +24502,11 @@ bool Player::canSeeSpellClickOn(Creature const* c) const ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(c->GetEntry(), itr->second.spellId); ConditionSourceInfo info = ConditionSourceInfo(const_cast(this), const_cast(c)); - if (!sConditionMgr->IsObjectMeetToConditions(info, conds)) - return false; + if (sConditionMgr->IsObjectMeetToConditions(info, conds)) + return true; } - return true; + return false; } void Player::BuildPlayerTalentsInfoData(WorldPacket* data) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 864c9f43dc7..55668af3679 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -16968,19 +16968,20 @@ void Unit::JumpTo(WorldObject* obj, float speedZ) bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) { + bool result = false; uint32 spellClickEntry = GetVehicleKit() ? GetVehicleKit()->GetCreatureEntry() : GetEntry(); SpellClickInfoMapBounds clickPair = sObjectMgr->GetSpellClickInfoMapBounds(spellClickEntry); for (SpellClickInfoContainer::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) { //! First check simple relations from clicker to clickee if (!itr->second.IsFitToRequirements(clicker, this)) - return false; + continue; //! Check database conditions ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(spellClickEntry, itr->second.spellId); ConditionSourceInfo info = ConditionSourceInfo(clicker, this); if (!sConditionMgr->IsObjectMeetToConditions(info, conds)) - return false; + continue; Unit* caster = (itr->second.castFlags & NPC_CLICK_CAST_CASTER_CLICKER) ? clicker : this; Unit* target = (itr->second.castFlags & NPC_CLICK_CAST_TARGET_CLICKER) ? clicker : this; @@ -17006,7 +17007,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) if (!valid) { sLog->outError(LOG_FILTER_SQL, "Spell %u specified in npc_spellclick_spells is not a valid vehicle enter aura!", itr->second.spellId); - return false; + continue; } if (IsInMap(caster)) @@ -17024,13 +17025,18 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) else Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, NULL, NULL, origCasterGUID); } + + result = true; } - Creature* creature = ToCreature(); - if (creature && creature->IsAIEnabled) - creature->AI()->OnSpellClick(clicker); + if(result) + { + Creature* creature = ToCreature(); + if (creature && creature->IsAIEnabled) + creature->AI()->OnSpellClick(clicker); + } - return true; + return result; } void Unit::EnterVehicle(Unit* base, int8 seatId) -- cgit v1.2.3 From 6f38fb1011373d5901769a4d54fcb63d93c3de8d Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Fri, 7 Sep 2012 02:21:38 +0200 Subject: Core: Fix some code style --- src/server/game/Entities/Unit/Unit.cpp | 4 ++-- src/server/scripts/Spells/spell_generic.cpp | 2 +- src/server/scripts/Spells/spell_item.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 55668af3679..3043d0fa4cd 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6728,7 +6728,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere if (!victim) return false; - // 2% of base mana + // 2% of maximum health basepoints0 = int32(victim->CountPctFromMaxHealth(2)); victim->CastCustomSpell(victim, 20267, &basepoints0, 0, 0, true, 0, triggeredByAura); return true; @@ -17029,7 +17029,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) result = true; } - if(result) + if (result) { Creature* creature = ToCreature(); if (creature && creature->IsAIEnabled) diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 27a6dac95f7..ed4148cd033 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -913,7 +913,7 @@ class spell_gen_profession_research : public SpellScriptLoader uint32 spellId = GetSpellInfo()->Id; // learn random explicit discovery recipe (if any) - if (uint32 discoveredSpellId = GetExplicitDiscoverySpell(spellId, caster->ToPlayer())) + if (uint32 discoveredSpellId = GetExplicitDiscoverySpell(spellId, caster)) caster->learnSpell(discoveredSpellId, false); caster->UpdateCraftSkill(spellId); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index a88defad1ce..0508d95a60b 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -842,7 +842,7 @@ class spell_item_book_of_glyph_mastery : public SpellScriptLoader uint32 spellId = GetSpellInfo()->Id; // learn random explicit discovery recipe (if any) - if (uint32 discoveredSpellId = GetExplicitDiscoverySpell(spellId, caster->ToPlayer())) + if (uint32 discoveredSpellId = GetExplicitDiscoverySpell(spellId, caster)) caster->learnSpell(discoveredSpellId, false); } -- cgit v1.2.3 From 5eb22e5b646fbe1774100e6b3eb7b876591e1cf6 Mon Sep 17 00:00:00 2001 From: kaelima Date: Fri, 7 Sep 2012 03:16:43 +0200 Subject: Core/Vehicles: - Send proper triggering flag when casting spellclick spells on vehicles (should not be fully triggered) - Only compute non-transport positions when not finalized. (Fixes changing seat on vehicles, or changing vehicle from vehicle) --- src/server/game/Entities/Unit/Unit.cpp | 22 +++++++++++++++------- src/server/game/Entities/Unit/Unit.h | 11 ++++++----- src/server/game/Movement/Spline/MoveSplineInit.cpp | 4 ++-- .../IcecrownCitadel/boss_the_lich_king.cpp | 6 +++--- 4 files changed, 26 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3043d0fa4cd..b9ce62e7f0d 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -405,6 +405,7 @@ void Unit::UpdateSplineMovement(uint32 t_diff) pos.m_positionY = loc.y; pos.m_positionZ = loc.z; pos.m_orientation = loc.orientation; + if (Unit* vehicle = GetVehicleBase()) { loc.x += vehicle->GetPositionX(); @@ -861,17 +862,24 @@ void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 values.AddSpellMod(SPELLVALUE_BASE_POINT1, *bp1); if (bp2) values.AddSpellMod(SPELLVALUE_BASE_POINT2, *bp2); - CastCustomSpell(spellId, values, target, triggered, castItem, triggeredByAura, originalCaster); + CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); } void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) { CustomSpellValues values; values.AddSpellMod(mod, value); - CastCustomSpell(spellId, values, target, triggered, castItem, triggeredByAura, originalCaster); + CastCustomSpell(spellId, values, target, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); +} + +void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* target, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +{ + CustomSpellValues values; + values.AddSpellMod(mod, value); + CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster); } -void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim, TriggerCastFlags triggerFlags, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) @@ -882,7 +890,7 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* SpellCastTargets targets; targets.SetUnitTarget(victim); - CastSpell(targets, spellInfo, &value, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, castItem, triggeredByAura, originalCaster); + CastSpell(targets, spellInfo, &value, triggerFlags, castItem, triggeredByAura, originalCaster); } void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem, AuraEffect const* triggeredByAura, uint64 originalCaster) @@ -17011,7 +17019,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) } if (IsInMap(caster)) - caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId+1, target, false, NULL, NULL, origCasterGUID); + caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId+1, target, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_FULL_MASK, NULL, NULL, origCasterGUID); else // This can happen during Player::_LoadAuras { int32 bp0 = seatId; @@ -17021,7 +17029,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) else { if (IsInMap(caster)) - caster->CastSpell(target, spellEntry, false, NULL, NULL, origCasterGUID); + caster->CastSpell(target, spellEntry, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_FULL_MASK, NULL, NULL, origCasterGUID); else Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, NULL, NULL, origCasterGUID); } @@ -17041,7 +17049,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) void Unit::EnterVehicle(Unit* base, int8 seatId) { - CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, seatId+1, base, false); + CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, seatId+1, base, TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE); } void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* aurApp) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 98d7bbcdcde..415d63a0c84 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1568,13 +1568,14 @@ class Unit : public WorldObject void CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem= NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem= NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem= NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* Victim = NULL, bool triggered = true, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim = NULL, bool triggered = true, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = NULL, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* victim = NULL, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); Aura* AddAura(uint32 spellId, Unit* target); Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target); void SetAuraStack(uint32 spellId, Unit* target, uint32 stack); diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index c539dd3cc39..a47c25610b0 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -71,10 +71,10 @@ namespace Movement real_position.z = unit.GetTransOffsetZ(); real_position.orientation = unit.GetTransOffsetO(); } - // there is a big chance that current position is unknown if current state is not finalized, need compute it // this also allows calculate spline position and update map position in much greater intervals - if (!move_spline.Finalized()) + // Don't compute for transport movement. The unit could be in a motion between two transports, thus having transport moveflag but is resulting in regular positions + else if (!move_spline.Finalized()) real_position = move_spline.ComputePosition(); // should i do the things that user should do? - no. diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index a8657925131..ba1a0614cdf 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -2112,7 +2112,7 @@ class spell_the_lich_king_necrotic_plague : public SpellScriptLoader CustomSpellValues values; //values.AddSpellMod(SPELLVALUE_AURA_STACK, 2); values.AddSpellMod(SPELLVALUE_MAX_TARGETS, 1); - GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, true, NULL, NULL, GetCasterGUID()); + GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, TRIGGERED_FULL_MASK, NULL, NULL, GetCasterGUID()); if (Unit* caster = GetCaster()) caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); } @@ -2204,7 +2204,7 @@ class spell_the_lich_king_necrotic_plague_jump : public SpellScriptLoader CustomSpellValues values; values.AddSpellMod(SPELLVALUE_AURA_STACK, GetStackAmount()); - GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, true, NULL, NULL, GetCasterGUID()); + GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, TRIGGERED_FULL_MASK, NULL, NULL, GetCasterGUID()); if (Unit* caster = GetCaster()) caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); } @@ -2223,7 +2223,7 @@ class spell_the_lich_king_necrotic_plague_jump : public SpellScriptLoader CustomSpellValues values; values.AddSpellMod(SPELLVALUE_AURA_STACK, GetStackAmount()); values.AddSpellMod(SPELLVALUE_BASE_POINT1, AURA_REMOVE_BY_ENEMY_SPELL); // add as marker (spell has no effect 1) - GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, true, NULL, NULL, GetCasterGUID()); + GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, NULL, TRIGGERED_FULL_MASK, NULL, NULL, GetCasterGUID()); if (Unit* caster = GetCaster()) caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); -- cgit v1.2.3 From f685e9fb2a5d6d141e40f1d5d70394dffddef744 Mon Sep 17 00:00:00 2001 From: kaelima Date: Fri, 7 Sep 2012 03:31:46 +0200 Subject: Core/Vehicle: Correction to 5eb22e5b646fbe1774100e6b3eb7b876591e1cf6. Thanks joschiwald (and slap some others) for noticing --- src/server/game/Entities/Unit/Unit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index b9ce62e7f0d..5d248b0ae87 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -17019,7 +17019,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) } if (IsInMap(caster)) - caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId+1, target, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_FULL_MASK, NULL, NULL, origCasterGUID); + caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId+1, target, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, NULL, NULL, origCasterGUID); else // This can happen during Player::_LoadAuras { int32 bp0 = seatId; @@ -17029,7 +17029,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) else { if (IsInMap(caster)) - caster->CastSpell(target, spellEntry, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_FULL_MASK, NULL, NULL, origCasterGUID); + caster->CastSpell(target, spellEntry, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, NULL, NULL, origCasterGUID); else Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, NULL, NULL, origCasterGUID); } -- cgit v1.2.3 From 6970a28f24c120c558be71e2e447fb271c999183 Mon Sep 17 00:00:00 2001 From: Aokromes Date: Fri, 7 Sep 2012 05:01:04 +0300 Subject: Scripts/Scarlet Monastery: Final boss kill credit closes #7341 When Scarlet Commander Mograine dies and High Inquisitor Whitemane appears, if she is downed very quickly, then she will not perform the ressurection on Mograine and will not stun anyone, thus Mograine wont give the achievement nor loot. She should be invincible till she has ressurected Mograine. --- .../ScarletMonastery/boss_mograine_and_whitemane.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp index 46fb62eae7f..0aad2857a45 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp @@ -283,6 +283,12 @@ public: DoScriptText(SAY_WH_KILL, me); } + void DamageTaken(Unit* /*attacker*/, uint32& damage) + { + if (!_bCanResurrectCheck && damage >= me->GetHealth()) + damage = me->GetHealth() - 1; + } + void UpdateAI(const uint32 diff) { if (!UpdateVictim()) -- cgit v1.2.3 From 21d43781acf1c60a66e4aa139324bff8d24d24d6 Mon Sep 17 00:00:00 2001 From: Nay Date: Fri, 7 Sep 2012 02:05:09 +0100 Subject: Tabs to spaces... --- src/server/game/AI/CoreAI/CombatAI.cpp | 2 +- src/server/game/Entities/Creature/Creature.cpp | 4 ++-- src/server/game/Entities/Pet/Pet.cpp | 2 +- .../Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index 946fe664798..5ab5f99310a 100755 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -111,7 +111,7 @@ void CombatAI::UpdateAI(const uint32 diff) DoMeleeAttackIfReady(); } -void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs) +void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs) { events.RescheduleEvent(spellId, unTimeMs); } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 0b9d0b40b4a..5cf81fb3847 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2231,7 +2231,7 @@ bool Creature::HasSpellCooldown(uint32 spell_id) const return (itr != m_CreatureSpellCooldowns.end() && itr->second > time(NULL)) || HasCategoryCooldown(spell_id); } -void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) +void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) { time_t curTime = time(NULL); for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i) @@ -2257,7 +2257,7 @@ void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs if ((idSchoolMask & spellInfo->GetSchoolMask()) && GetCreatureSpellCooldownDelay(unSpellId) < unTimeMs) { _AddCreatureSpellCooldown(unSpellId, curTime + unTimeMs/IN_MILLISECONDS); - if (UnitAI* ai = GetAI()) + if (UnitAI* ai = GetAI()) ai->SpellInterrupted(unSpellId, unTimeMs); } } diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index b2cdb56a33e..ead018ac620 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -2034,7 +2034,7 @@ void Pet::SynchronizeLevelWithOwner() } } -void Pet::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) +void Pet::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) { WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+m_spells.size()*8); data << uint64(GetGUID()); diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp index 156581e8cd2..233a8d82497 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp @@ -350,10 +350,10 @@ class instance_blood_furnace : public InstanceMapScript ++PrisonerCounter8; } else - return; + return; } else - return; + return; ResetPrisoner(creature); } -- cgit v1.2.3