diff options
Diffstat (limited to 'src')
43 files changed, 1531 insertions, 1170 deletions
diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp index d1b2b614037..be6623c7fa3 100644 --- a/src/server/authserver/Main.cpp +++ b/src/server/authserver/Main.cpp @@ -179,24 +179,24 @@ extern int main(int argc, char** argv) Handler.register_handler(SIGTERM, &SignalTERM); #if defined(_WIN32) || defined(__linux__) - + ///- Handle affinity for multiple processors and process priority uint32 affinity = sConfigMgr->GetIntDefault("UseProcessors", 0); bool highPriority = sConfigMgr->GetBoolDefault("ProcessPriority", false); #ifdef _WIN32 // Windows - + HANDLE hProcess = GetCurrentProcess(); if (affinity > 0) { ULONG_PTR appAff; ULONG_PTR sysAff; - + if (GetProcessAffinityMask(hProcess, &appAff, &sysAff)) { // remove non accessible processors ULONG_PTR currentAffinity = affinity & appAff; - + if (!currentAffinity) TC_LOG_ERROR("server.authserver", "Processors marked in UseProcessors bitmask (hex) %x are not accessible for the authserver. Accessible processors bitmask (hex): %x", affinity, appAff); else if (SetProcessAffinityMask(hProcess, currentAffinity)) @@ -205,7 +205,7 @@ extern int main(int argc, char** argv) TC_LOG_ERROR("server.authserver", "Can't set used processors (hex): %x", currentAffinity); } } - + if (highPriority) { if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS)) @@ -213,9 +213,9 @@ extern int main(int argc, char** argv) else TC_LOG_ERROR("server.authserver", "Can't set authserver process priority class."); } - + #else // Linux - + if (affinity > 0) { cpu_set_t mask; @@ -242,7 +242,7 @@ extern int main(int argc, char** argv) else TC_LOG_INFO("server.authserver", "authserver process priority class set to %i", getpriority(PRIO_PROCESS, 0)); } - + #endif #endif diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 4cf7d34cc11..370696474ae 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1404,6 +1404,7 @@ void GameObject::Use(Unit* user) // prevent removing GO at spell cancel RemoveFromOwner(); SetOwnerGUID(player->GetGUID()); + SetSpellId(0); // prevent removing unintended auras at Unit::RemoveGameObject /// @todo find reasonable value for fishing hole search GameObject* ok = LookupFishingHoleAround(20.0f + CONTACT_DISTANCE); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index f1adae8f337..c7f36aff92b 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -689,7 +689,7 @@ Player::Player(WorldSession* session): Unit(true) m_areaUpdateId = 0; m_team = 0; - + m_needsZoneUpdate = false; m_nextSave = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE); @@ -7488,7 +7488,8 @@ void Player::UpdateArea(uint32 newArea) { SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY); pvpInfo.IsInNoPvPArea = true; - CombatStopWithPets(); + if (!duel) + CombatStopWithPets(); } else RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 94175834969..aeac9db98aa 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1676,7 +1676,7 @@ class Player : public Unit, public GridObject<Player> void UpdateZone(uint32 newZone, uint32 newArea); void UpdateArea(uint32 newArea); void SetNeedsZoneUpdate(bool needsUpdate) { m_needsZoneUpdate = needsUpdate; } - + void UpdateZoneDependentAuras(uint32 zone_id); // zones void UpdateAreaDependentAuras(uint32 area_id); // subzones @@ -2564,7 +2564,7 @@ class Player : public Unit, public GridObject<Player> bool IsAlwaysDetectableFor(WorldObject const* seer) const; uint8 m_grantableLevels; - + bool m_needsZoneUpdate; private: diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 5083e08e26f..e0c880334ea 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3385,6 +3385,7 @@ void Unit::_ApplyAura(AuraApplication * aurApp, uint8 effMask) return; aura->HandleAuraSpecificMods(aurApp, caster, true, false); + aura->HandleAuraSpecificPeriodics(aurApp, caster); // apply effects of the aura for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) @@ -8159,23 +8160,14 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg if (GetTypeId() != TYPEID_PLAYER) return false; + float averageDmg = 0; // now compute approximate weapon damage by formula from wowwiki.com - Item* item = NULL; if (procFlags & PROC_FLAG_DONE_OFFHAND_ATTACK) - item = ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + averageDmg = (GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE) + GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE)) / 2; else - item = ToPlayer()->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); - - // dunno if it's really needed but will prevent any possible crashes - if (!item) - return false; + averageDmg = (GetFloatValue(UNIT_FIELD_MINDAMAGE) + GetFloatValue(UNIT_FIELD_MAXDAMAGE)) / 2; - ItemTemplate const* weapon = item->GetTemplate(); - - float weaponDPS = weapon->getDPS(); - float attackPower = GetTotalAttackPowerValue(BASE_ATTACK) / 14.0f; - float weaponSpeed = float(weapon->Delay) / 1000.0f; - basepoints0 = int32((weaponDPS + attackPower) * weaponSpeed); + basepoints0 = int32(averageDmg); break; } // Persistent Shield (Scarab Brooch trinket) @@ -9853,39 +9845,162 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin if (Unit* owner = GetOwner()) return owner->SpellDamageBonusDone(victim, spellProto, pdamage, damagetype); - // Done total percent damage auras - float DoneTotalMod = 1.0f; float ApCoeffMod = 1.0f; int32 DoneTotal = 0; + // done scripted mod (take it from owner) + Unit const* owner = GetOwner() ? GetOwner() : this; + AuraEffectList const& mOverrideClassScript = owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) + { + if (!(*i)->IsAffectedOnSpell(spellProto)) + continue; + + switch ((*i)->GetMiscValue()) + { + case 4418: // Increased Shock Damage + case 4554: // Increased Lightning Damage + case 4555: // Improved Moonfire + case 5142: // Increased Lightning Damage + case 5147: // Improved Consecration / Libram of Resurgence + case 5148: // Idol of the Shooting Star + case 6008: // Increased Lightning Damage + case 8627: // Totem of Hex + { + DoneTotal += (*i)->GetAmount(); + break; + } + } + } + + // Custom scripted damage + switch (spellProto->SpellFamilyName) + { + case SPELLFAMILY_DEATHKNIGHT: + // Impurity (dummy effect) + if (GetTypeId() == TYPEID_PLAYER) + { + PlayerSpellMap playerSpells = ToPlayer()->GetSpellMap(); + for (PlayerSpellMap::const_iterator itr = playerSpells.begin(); itr != playerSpells.end(); ++itr) + { + if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled) + continue; + switch (itr->first) + { + case 49220: + case 49633: + case 49635: + case 49636: + case 49638: + if (SpellInfo const* proto = sSpellMgr->GetSpellInfo(itr->first)) + AddPct(ApCoeffMod, proto->Effects[0].CalcValue()); + break; + } + } + } + break; + } + + // Done fixed damage bonus auras + int32 DoneAdvertisedBenefit = SpellBaseDamageBonusDone(spellProto->GetSchoolMask()); + // Pets just add their bonus damage to their spell damage + // note that their spell damage is just gain of their own auras + if (HasUnitTypeMask(UNIT_MASK_GUARDIAN)) + DoneAdvertisedBenefit += ((Guardian*)this)->GetBonusDamage(); + + // Check for table values + float coeff = 0; + SpellBonusEntry const* bonus = sSpellMgr->GetSpellBonusData(spellProto->Id); + if (bonus) + { + if (damagetype == DOT) + { + coeff = bonus->dot_damage; + if (bonus->ap_dot_bonus > 0) + { + WeaponAttackType attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK; + float APbonus = float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS)); + APbonus += GetTotalAttackPowerValue(attType); + DoneTotal += int32(bonus->ap_dot_bonus * stack * ApCoeffMod * APbonus); + } + } + else + { + coeff = bonus->direct_damage; + if (bonus->ap_bonus > 0) + { + WeaponAttackType attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK; + float APbonus = float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS)); + APbonus += GetTotalAttackPowerValue(attType); + DoneTotal += int32(bonus->ap_bonus * stack * ApCoeffMod * APbonus); + } + } + } + // Default calculation + if (DoneAdvertisedBenefit) + { + if (!bonus || coeff < 0) + coeff = CalculateDefaultCoefficient(spellProto, damagetype) * int32(stack); + + float factorMod = CalculateLevelPenalty(spellProto) * stack; + + if (Player* modOwner = GetSpellModOwner()) + { + coeff *= 100.0f; + modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff); + coeff /= 100.0f; + } + DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod); + } + + // Done Percentage for DOT is already calculated, no need to do it again. The percentage mod is applied in Aura::HandleAuraSpecificMods. + float tmpDamage = (int32(pdamage) + DoneTotal) * (damagetype == DOT ? 1.0f : SpellDamagePctDone(victim, spellProto, damagetype)); + // apply spellmod to Done damage (flat and pct) + if (Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); + + return uint32(std::max(tmpDamage, 0.0f)); +} + +float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype) const +{ + if (!spellProto || !victim || damagetype == DIRECT_DAMAGE) + return 1.0f; + + // Some spells don't benefit from pct done mods + if (spellProto->AttributesEx6 & SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS) + return 1.0f; + + // For totems pct done mods are calculated when its calculation is run on the player in SpellDamageBonusDone. + if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsTotem()) + return 1.0f; + + // Done total percent damage auras + float DoneTotalMod = 1.0f; + // Pet damage? if (GetTypeId() == TYPEID_UNIT && !ToCreature()->IsPet()) DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank); - // Some spells don't benefit from pct done mods - if (!(spellProto->AttributesEx6 & SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS)) + AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); + for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) { - AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) - { - if (spellProto->EquippedItemClass == -1 && (*i)->GetSpellInfo()->EquippedItemClass != -1) //prevent apply mods from weapon specific case to non weapon specific spells (Example: thunder clap and two-handed weapon specialization) - continue; + if (spellProto->EquippedItemClass == -1 && (*i)->GetSpellInfo()->EquippedItemClass != -1) //prevent apply mods from weapon specific case to non weapon specific spells (Example: thunder clap and two-handed weapon specialization) + continue; - if ((*i)->GetMiscValue() & spellProto->GetSchoolMask()) - { - if ((*i)->GetSpellInfo()->EquippedItemClass == -1) - AddPct(DoneTotalMod, (*i)->GetAmount()); - else if (!((*i)->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0)) - AddPct(DoneTotalMod, (*i)->GetAmount()); - else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo())) - AddPct(DoneTotalMod, (*i)->GetAmount()); - } + if ((*i)->GetMiscValue() & spellProto->GetSchoolMask()) + { + if ((*i)->GetSpellInfo()->EquippedItemClass == -1) + AddPct(DoneTotalMod, (*i)->GetAmount()); + else if (!((*i)->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0)) + AddPct(DoneTotalMod, (*i)->GetAmount()); + else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo())) + AddPct(DoneTotalMod, (*i)->GetAmount()); } } uint32 creatureTypeMask = victim->GetCreatureTypeMask(); - // Add flat bonus from spell damage versus - DoneTotal += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS, creatureTypeMask); + AuraEffectList const& mDamageDoneVersus = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i) if (creatureTypeMask & uint32((*i)->GetMiscValue())) @@ -9899,7 +10014,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin // done scripted mod (take it from owner) Unit const* owner = GetOwner() ? GetOwner() : this; - AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + AuraEffectList const& mOverrideClassScript = owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!(*i)->IsAffectedOnSpell(spellProto)) @@ -9956,18 +10071,6 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin AddPct(DoneTotalMod, (*i)->GetAmount()); break; } - case 4418: // Increased Shock Damage - case 4554: // Increased Lightning Damage - case 4555: // Improved Moonfire - case 5142: // Increased Lightning Damage - case 5147: // Improved Consecration / Libram of Resurgence - case 5148: // Idol of the Shooting Star - case 6008: // Increased Lightning Damage - case 8627: // Totem of Hex - { - DoneTotal += (*i)->GetAmount(); - break; - } // Tundra Stalker // Merciless Combat case 7277: @@ -10133,14 +10236,14 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin break; } } - // Drain Soul - increased damage for targets under 25 % HP - if (spellProto->SpellFamilyFlags[0] & 0x00004000) - if (HasAura(100001)) - DoneTotalMod *= 4; // Shadow Bite (15% increase from each dot) if (spellProto->SpellFamilyFlags[1] & 0x00400000 && IsPet()) if (uint8 count = victim->GetDoTsByCaster(GetOwnerGUID())) AddPct(DoneTotalMod, 15 * count); + + // Drain Soul - If the target is at or below 25% health, Drain Soul causes four times the normal damage + if (spellProto->SpellFamilyFlags[0] & 0x00004000 && !victim->HealthAbovePct(25)) + DoneTotalMod *= 4; break; case SPELLFAMILY_HUNTER: // Steady Shot @@ -10155,101 +10258,15 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin if (AuraEffect* aurEff = GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 2721, 0)) AddPct(DoneTotalMod, aurEff->GetAmount()); - // Sigil of the Vengeful Heart - if (spellProto->SpellFamilyFlags[0] & 0x2000) - if (AuraEffect* aurEff = GetAuraEffect(64962, EFFECT_1)) - AddPct(DoneTotal, aurEff->GetAmount()); - // Glacier Rot if (spellProto->SpellFamilyFlags[0] & 0x2 || spellProto->SpellFamilyFlags[1] & 0x6) if (AuraEffect* aurEff = GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 196, 0)) if (victim->GetDiseasesByCaster(owner->GetGUID()) > 0) AddPct(DoneTotalMod, aurEff->GetAmount()); - - // Impurity (dummy effect) - if (GetTypeId() == TYPEID_PLAYER) - { - PlayerSpellMap playerSpells = ToPlayer()->GetSpellMap(); - for (PlayerSpellMap::const_iterator itr = playerSpells.begin(); itr != playerSpells.end(); ++itr) - { - if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled) - continue; - switch (itr->first) - { - case 49220: - case 49633: - case 49635: - case 49636: - case 49638: - { - if (SpellInfo const* proto = sSpellMgr->GetSpellInfo(itr->first)) - AddPct(ApCoeffMod, proto->Effects[0].CalcValue()); - } - break; - } - } - } break; } - // Done fixed damage bonus auras - int32 DoneAdvertisedBenefit = SpellBaseDamageBonusDone(spellProto->GetSchoolMask()); - // Pets just add their bonus damage to their spell damage - // note that their spell damage is just gain of their own auras - if (HasUnitTypeMask(UNIT_MASK_GUARDIAN)) - DoneAdvertisedBenefit += ((Guardian*)this)->GetBonusDamage(); - - // Check for table values - float coeff = 0; - SpellBonusEntry const* bonus = sSpellMgr->GetSpellBonusData(spellProto->Id); - if (bonus) - { - if (damagetype == DOT) - { - coeff = bonus->dot_damage; - if (bonus->ap_dot_bonus > 0) - { - WeaponAttackType attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK; - float APbonus = float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS)); - APbonus += GetTotalAttackPowerValue(attType); - DoneTotal += int32(bonus->ap_dot_bonus * stack * ApCoeffMod * APbonus); - } - } - else - { - coeff = bonus->direct_damage; - if (bonus->ap_bonus > 0) - { - WeaponAttackType attType = (spellProto->IsRangedWeaponSpell() && spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE) ? RANGED_ATTACK : BASE_ATTACK; - float APbonus = float(victim->GetTotalAuraModifier(attType == BASE_ATTACK ? SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS : SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS)); - APbonus += GetTotalAttackPowerValue(attType); - DoneTotal += int32(bonus->ap_bonus * stack * ApCoeffMod * APbonus); - } - } - } - // Default calculation - if (DoneAdvertisedBenefit) - { - if (!bonus || coeff < 0) - coeff = CalculateDefaultCoefficient(spellProto, damagetype) * int32(stack); - - float factorMod = CalculateLevelPenalty(spellProto) * stack; - - if (Player* modOwner = GetSpellModOwner()) - { - coeff *= 100.0f; - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff); - coeff /= 100.0f; - } - DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod); - } - - float tmpDamage = (int32(pdamage) + DoneTotal) * DoneTotalMod; - // apply spellmod to Done damage (flat and pct) - if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); - - return uint32(std::max(tmpDamage, 0.0f)); + return DoneTotalMod; } uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) const @@ -10260,7 +10277,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui int32 TakenTotal = 0; float TakenTotalMod = 1.0f; float TakenTotalCasterMod = 0.0f; - + // Mod damage from spell mechanic if (uint32 mechanicMask = spellProto->GetAllEffectsMechanicMask()) { @@ -10280,9 +10297,10 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui case 2109: if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) { - if (GetTypeId() != TYPEID_PLAYER) - continue; - float mod = ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f); + // Patch 2.4.3: The resilience required to reach the 90% damage reduction cap + // is 22.5% critical strike damage reduction, or 444 resilience. + // To calculate for 90%, we multiply the 100% by 4 (22.5% * 4 = 90%) + float mod = -1.0f * GetMeleeCritDamageReduction(400); AddPct(TakenTotalMod, std::max(mod, float((*i)->GetAmount()))); } break; @@ -10406,16 +10424,21 @@ int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) const return TakenAdvertisedBenefit; } -bool Unit::isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) const +bool Unit::IsSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) const +{ + return roll_chance_f(GetUnitSpellCriticalChance(victim, spellProto, schoolMask, attackType)); +} + +float Unit::GetUnitSpellCriticalChance(Unit* victim, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) const { //! Mobs can't crit with spells. Player Totems can //! Fire Elemental (from totem) can too - but this part is a hack and needs more research - if (IS_CREATURE_GUID(GetGUID()) && !(IsTotem() && IS_PLAYER_GUID(GetOwnerGUID())) && GetEntry() != 15438) - return false; + if (IS_CRE_OR_VEH_GUID(GetGUID()) && !(IsTotem() && IS_PLAYER_GUID(GetOwnerGUID())) && GetEntry() != 15438) + return 0.0f; // not critting spell if ((spellProto->AttributesEx2 & SPELL_ATTR2_CANT_CRIT)) - return false; + return 0.0f; float crit_chance = 0.0f; switch (spellProto->DmgClass) @@ -10431,7 +10454,7 @@ bool Unit::isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMas case 71646: // Item - Bauble of True Blood 25m break; default: - return false; + return 0.0f; } // Do not add a break here, case fallthrough is intentional! Adding a break will make above spells unable to crit. case SPELL_DAMAGE_CLASS_MAGIC: @@ -10533,7 +10556,7 @@ bool Unit::isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMas else if (spellProto->GetCategory() == 19) { if (victim->GetCreatureTypeMask() & CREATURE_TYPEMASK_DEMON_OR_UNDEAD) - return true; + return 100.0f; break; } break; @@ -10543,7 +10566,7 @@ bool Unit::isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMas { if (victim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, 0x10000000, 0, 0, GetGUID())) if (victim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE) > -100) - return true; + return 100.0f; break; } break; @@ -10591,17 +10614,14 @@ bool Unit::isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMas break; } default: - return false; + return 0.0f; } // percent done // only players use intelligence for critical chance computations if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance); - crit_chance = crit_chance > 0.0f ? crit_chance : 0.0f; - if (roll_chance_f(crit_chance)) - return true; - return false; + return crit_chance > 0.0f ? crit_chance : 0.0f; } uint32 Unit::SpellCriticalDamageBonus(SpellInfo const* spellProto, uint32 damage, Unit* victim) @@ -10685,14 +10705,8 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui if (spellProto->SpellFamilyName == SPELLFAMILY_POTION) return healamount; - float DoneTotalMod = 1.0f; int32 DoneTotal = 0; - // Healing done percent - AuraEffectList const& mHealingDonePct = GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE_PERCENT); - for (AuraEffectList::const_iterator i = mHealingDonePct.begin(); i != mHealingDonePct.end(); ++i) - AddPct(DoneTotalMod, (*i)->GetAmount()); - // done scripted mod (take it from owner) Unit const* owner = GetOwner() ? GetOwner() : this; AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); @@ -10707,43 +10721,6 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui case 3736: // Hateful Totem of the Third Wind / Increased Lesser Healing Wave / LK Arena (4/5/6) Totem of the Third Wind / Savage Totem of the Third Wind DoneTotal += (*i)->GetAmount(); break; - case 21: // Test of Faith - case 6935: - case 6918: - if (victim->HealthBelowPct(50)) - AddPct(DoneTotalMod, (*i)->GetAmount()); - break; - case 7798: // Glyph of Regrowth - { - if (victim->GetAuraEffect(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_DRUID, 0x40, 0, 0)) - AddPct(DoneTotalMod, (*i)->GetAmount()); - break; - } - case 8477: // Nourish Heal Boost - { - int32 stepPercent = (*i)->GetAmount(); - int32 modPercent = 0; - AuraApplicationMap const& victimAuras = victim->GetAppliedAuras(); - for (AuraApplicationMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr) - { - Aura const* aura = itr->second->GetBase(); - if (aura->GetCasterGUID() != GetGUID()) - continue; - SpellInfo const* m_spell = aura->GetSpellInfo(); - if (m_spell->SpellFamilyName != SPELLFAMILY_DRUID || - !(m_spell->SpellFamilyFlags[1] & 0x00000010 || m_spell->SpellFamilyFlags[0] & 0x50)) - continue; - modPercent += stepPercent * aura->GetStackAmount(); - } - AddPct(DoneTotalMod, modPercent); - break; - } - case 7871: // Glyph of Lesser Healing Wave - { - if (victim->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 0, 0x00000400, 0, GetGUID())) - AddPct(DoneTotalMod, (*i)->GetAmount()); - break; - } default: break; } @@ -10816,8 +10793,8 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui DoneTotal = 0; } - // use float as more appropriate for negative values and percent applying - float heal = float(int32(healamount) + DoneTotal) * DoneTotalMod; + // Done Percentage for DOT is already calculated, no need to do it again. The percentage mod is applied in Aura::HandleAuraSpecificMods. + float heal = float(int32(healamount) + DoneTotal) * (damagetype == DOT ? 1.0f : SpellHealingPctDone(victim, spellProto)); // apply spellmod to Done amount if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal); @@ -10825,6 +10802,77 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui return uint32(std::max(heal, 0.0f)); } +float Unit::SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const +{ + // For totems pct done mods are calculated when its calculation is run on the player in SpellHealingBonusDone. + if (GetTypeId() == TYPEID_UNIT && IsTotem()) + return 1.0f; + + // No bonus healing for potion spells + if (spellProto->SpellFamilyName == SPELLFAMILY_POTION) + return 1.0f; + + float DoneTotalMod = 1.0f; + + // Healing done percent + AuraEffectList const& mHealingDonePct = GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE_PERCENT); + for (AuraEffectList::const_iterator i = mHealingDonePct.begin(); i != mHealingDonePct.end(); ++i) + AddPct(DoneTotalMod, (*i)->GetAmount()); + + // done scripted mod (take it from owner) + Unit const* owner = GetOwner() ? GetOwner() : this; + AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) + { + if (!(*i)->IsAffectedOnSpell(spellProto)) + continue; + switch ((*i)->GetMiscValue()) + { + case 21: // Test of Faith + case 6935: + case 6918: + if (victim->HealthBelowPct(50)) + AddPct(DoneTotalMod, (*i)->GetAmount()); + break; + case 7798: // Glyph of Regrowth + { + if (victim->GetAuraEffect(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_DRUID, 0x40, 0, 0)) + AddPct(DoneTotalMod, (*i)->GetAmount()); + break; + } + case 8477: // Nourish Heal Boost + { + int32 stepPercent = (*i)->GetAmount(); + int32 modPercent = 0; + AuraApplicationMap const& victimAuras = victim->GetAppliedAuras(); + for (AuraApplicationMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr) + { + Aura const* aura = itr->second->GetBase(); + if (aura->GetCasterGUID() != GetGUID()) + continue; + SpellInfo const* m_spell = aura->GetSpellInfo(); + if (m_spell->SpellFamilyName != SPELLFAMILY_DRUID || + !(m_spell->SpellFamilyFlags[1] & 0x00000010 || m_spell->SpellFamilyFlags[0] & 0x50)) + continue; + modPercent += stepPercent * aura->GetStackAmount(); + } + AddPct(DoneTotalMod, modPercent); + break; + } + case 7871: // Glyph of Lesser Healing Wave + { + if (victim->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 0, 0x00000400, 0, GetGUID())) + AddPct(DoneTotalMod, (*i)->GetAmount()); + break; + } + default: + break; + } + } + + return DoneTotalMod; +} + uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack) const { float TakenTotalMod = 1.0f; @@ -11111,8 +11159,7 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons // Check for immune to application of harmful magical effects AuraEffectList const& immuneAuraApply = GetAuraEffectsByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL); for (AuraEffectList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) - if (spellInfo->Dispel == DISPEL_MAGIC && // Magic debuff - ((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school + if (((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school !spellInfo->IsPositiveEffect(index)) // Harmful return true; } @@ -11181,7 +11228,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType // Some spells don't benefit from pct done mods if (spellProto) - if (!(spellProto->AttributesEx6 & SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS) && !spellProto->IsRankOf(sSpellMgr->GetSpellInfo(12162))) + if (!(spellProto->AttributesEx6 & SPELL_ATTR6_NO_DONE_PCT_DAMAGE_MODS)) { AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) @@ -11364,9 +11411,10 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackT case 2109: if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) { - if (GetTypeId() != TYPEID_PLAYER) - continue; - float mod = ToPlayer()->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f); + // Patch 2.4.3: The resilience required to reach the 90% damage reduction cap + // is 22.5% critical strike damage reduction, or 444 resilience. + // To calculate for 90%, we multiply the 100% by 4 (22.5% * 4 = 90%) + float mod = -1.0f * GetMeleeCritDamageReduction(400); AddPct(TakenTotalMod, std::max(mod, float((*i)->GetAmount()))); } break; @@ -17031,12 +17079,14 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel bool turn = (GetOrientation() != orientation); bool relocated = (teleport || GetPositionX() != x || GetPositionY() != y || GetPositionZ() != z); + // TODO: Check if orientation transport offset changed instead of only global orientation if (turn) RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING); if (relocated) { - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE); + if (!GetVehicle()) + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE); // move and update visible state if need if (GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 2cce1a852cf..20c987c5105 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1972,13 +1972,15 @@ class Unit : public WorldObject Unit* GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo); Unit* GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo = NULL); - int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const; - int32 SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) const; + int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const; + int32 SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) const; uint32 SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1) const; + float SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype) const; uint32 SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1) const; - int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) const; - int32 SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const; + int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) const; + int32 SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const; uint32 SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack = 1) const; + float SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const; uint32 SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack = 1) const; uint32 MeleeDamageBonusDone(Unit* pVictim, uint32 damage, WeaponAttackType attType, SpellInfo const* spellProto = NULL); @@ -1986,7 +1988,8 @@ class Unit : public WorldObject bool isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttackType attackType = BASE_ATTACK); bool isBlockCritical(); - bool isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK) const; + bool IsSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK) const; + float GetUnitSpellCriticalChance(Unit* victim, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK) const; uint32 SpellCriticalDamageBonus(SpellInfo const* spellProto, uint32 damage, Unit* victim); uint32 SpellCriticalHealingBonus(SpellInfo const* spellProto, uint32 damage, Unit* victim); diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 278c180c380..0a797f0e008 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -235,20 +235,28 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) recvData.ReadPackedTime(unkPackedTime); recvData >> flags; - CalendarEvent calendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId, + // prevent events in the past + // To Do: properly handle timezones and remove the "- time_t(86400L)" hack + if (time_t(eventPackedTime) < (time(NULL) - time_t(86400L))) + { + recvData.rfinish(); + return; + } + + CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId, time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description); - if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) + if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement()) if (Player* creator = ObjectAccessor::FindPlayer(guid)) - calendarEvent.SetGuildId(creator->GetGuildId()); + calendarEvent->SetGuildId(creator->GetGuildId()); - if (calendarEvent.IsGuildAnnouncement()) + if (calendarEvent->IsGuildAnnouncement()) { // 946684800 is 01/01/2000 00:00:00 - default response time - CalendarInvite invite(0, calendarEvent.GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); + CalendarInvite invite(0, calendarEvent->GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); // WARNING: By passing pointer to a local variable, the underlying method(s) must NOT perform any kind // of storage of the pointer as it will lead to memory corruption - sCalendarMgr->AddInvite(&calendarEvent, &invite); + sCalendarMgr->AddInvite(calendarEvent, &invite); } else { @@ -271,15 +279,15 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) recvData >> status >> rank; // 946684800 is 01/01/2000 00:00:00 - default response time - CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent.GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), ""); - sCalendarMgr->AddInvite(&calendarEvent, invite, trans); + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), ""); + sCalendarMgr->AddInvite(calendarEvent, invite, trans); } if (inviteCount > 1) CharacterDatabase.CommitTransaction(trans); } - sCalendarMgr->AddEvent(new CalendarEvent(calendarEvent, calendarEvent.GetEventId()), CALENDAR_SENDTYPE_ADD); + sCalendarMgr->AddEvent(calendarEvent, CALENDAR_SENDTYPE_ADD); } void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) @@ -304,6 +312,14 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) recvData.ReadPackedTime(timeZoneTime); recvData >> flags; + // prevent events in the past + // To Do: properly handle timezones and remove the "- time_t(86400L)" hack + if (time_t(eventPackedTime) < (time(NULL) - time_t(86400L))) + { + recvData.rfinish(); + return; + } + TC_LOG_DEBUG("network", "CMSG_CALENDAR_UPDATE_EVENT [" UI64FMTD "] EventId [" UI64FMTD "], InviteId [" UI64FMTD "] Title %s, Description %s, type %u " "Repeatable %u, MaxInvites %u, Dungeon ID %d, Time %u " @@ -346,17 +362,25 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) uint64 guid = _player->GetGUID(); uint64 eventId; uint64 inviteId; - uint32 time; + uint32 eventTime; recvData >> eventId >> inviteId; - recvData.ReadPackedTime(time); + recvData.ReadPackedTime(eventTime); TC_LOG_DEBUG("network", "CMSG_CALENDAR_COPY_EVENT [" UI64FMTD "], EventId [" UI64FMTD - "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, time); + "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, eventTime); + + // prevent events in the past + // To Do: properly handle timezones and remove the "- time_t(86400L)" hack + if (time_t(eventTime) < (time(NULL) - time_t(86400L))) + { + recvData.rfinish(); + return; + } if (CalendarEvent* oldEvent = sCalendarMgr->GetEvent(eventId)) { CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId()); - newEvent->SetEventTime(time_t(time)); + newEvent->SetEventTime(time_t(eventTime)); sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); CalendarInviteStore invites = sCalendarMgr->GetEventInvites(eventId); diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index eae95d20610..97867e2f352 100644 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -638,8 +638,6 @@ void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket& recvData) recvData >> apply; group->SetGroupMemberFlag(guid, apply, MEMBER_FLAG_ASSISTANT); - - group->SendUpdate(); } void WorldSession::HandlePartyAssignmentOpcode(WorldPacket& recvData) diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 0ca7885b82b..3ef99cc2fc1 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -85,6 +85,18 @@ void WorldSession::HandleSwapInvItemOpcode(WorldPacket& recvData) return; } + if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, srcslot) && !CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + + if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, dstslot) && !CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot); uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot); @@ -137,6 +149,18 @@ void WorldSession::HandleSwapItem(WorldPacket& recvData) return; } + if (_player->IsBankPos(srcbag, srcslot) && !CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + + if (_player->IsBankPos(dstbag, dstslot) && !CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + _player->SwapItem(src, dst); } @@ -858,15 +882,11 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) uint64 guid; recvPacket >> guid; - // cheating protection - /* not critical if "cheated", and check skip allow by slots in bank windows open by .bank command. - Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_BANKER); - if (!creature) + if (!CanUseBank(guid)) { - TC_LOG_DEBUG("WORLD: HandleBuyBankSlotOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); + TC_LOG_DEBUG("network", "WORLD: HandleBuyBankSlotOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); return; } - */ uint32 slot = _player->GetBankBagSlotCount(); @@ -912,6 +932,12 @@ void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) recvPacket >> srcbag >> srcslot; TC_LOG_DEBUG("network", "STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot); + if (!CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleAutoBankItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) return; @@ -943,6 +969,12 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket) recvPacket >> srcbag >> srcslot; TC_LOG_DEBUG("network", "STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot); + if (!CanUseBank()) + { + TC_LOG_DEBUG("network", "WORLD: HandleAutoStoreBankItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(m_currentBankerGUID))); + return; + } + Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) return; @@ -1441,3 +1473,21 @@ void WorldSession::HandleItemTextQuery(WorldPacket& recvData ) SendPacket(&data); } + +bool WorldSession::CanUseBank(uint64 bankerGUID) const +{ + // bankerGUID parameter is optional, set to 0 by default. + if (!bankerGUID) + bankerGUID = m_currentBankerGUID; + + bool isUsingBankCommand = (bankerGUID == GetPlayer()->GetGUID() && bankerGUID == m_currentBankerGUID); + + if (!isUsingBankCommand) + { + Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(bankerGUID, UNIT_NPC_FLAG_BANKER); + if (!creature) + return false; + } + + return true; +}
\ No newline at end of file diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 11fa89d9d6b..c4ff2581e75 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -502,7 +502,7 @@ void WorldSession::HandleZoneUpdateOpcode(WorldPacket& recvData) // use server side data, but only after update the player position. See Player::UpdatePosition(). GetPlayer()->SetNeedsZoneUpdate(true); - + //GetPlayer()->SendInitWorldStates(true, newZone); } diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index 0c2eae849b8..cef414163bd 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -30,6 +30,7 @@ #include "WaypointMovementGenerator.h" #include "InstanceSaveMgr.h" #include "ObjectMgr.h" +#include "Vehicle.h" #define MOVEMENT_PACKET_TIME_DELAY 0 @@ -370,10 +371,20 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvData) mover->m_movementInfo = movementInfo; - // this is almost never true (not sure why it is sometimes, but it is), normally use mover->IsVehicle() - if (mover->GetVehicle()) + // Some vehicles allow the passenger to turn by himself + if (Vehicle* vehicle = mover->GetVehicle()) { - mover->SetOrientation(movementInfo.pos.GetOrientation()); + if (VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(mover)) + { + if (seat->m_flags & VEHICLE_SEAT_FLAG_ALLOW_TURNING) + { + if (movementInfo.pos.GetOrientation() != mover->GetOrientation()) + { + mover->SetOrientation(movementInfo.pos.GetOrientation()); + mover->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING); + } + } + } return; } @@ -496,7 +507,7 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recvData) if (GetPlayer()->IsInWorld()) { if (_player->m_mover->GetGUID() != guid) - TC_LOG_ERROR("network", "HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID()); + TC_LOG_DEBUG("network", "HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID()); } } diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index fc14797ea94..d8a518a24db 100644 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -100,6 +100,7 @@ void WorldSession::SendShowBank(uint64 guid) { WorldPacket data(SMSG_SHOW_BANK, 8); data << guid; + m_currentBankerGUID = guid; SendPacket(&data); } diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index d64f21f2028..3cc445ff81b 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -74,13 +74,13 @@ void WorldSession::HandlePetAction(WorldPacket& recvData) if (!pet) { - TC_LOG_ERROR("network", "HandlePetAction: Pet (GUID: %u) doesn't exist for player %s (GUID: %u)", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str(), GUID_LOPART(GetPlayer()->GetGUID())); + TC_LOG_DEBUG("network", "HandlePetAction: Pet (GUID: %u) doesn't exist for player %s (GUID: %u)", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str(), GUID_LOPART(GetPlayer()->GetGUID())); return; } if (pet != GetPlayer()->GetFirstControlled()) { - TC_LOG_ERROR("network", "HandlePetAction: Pet (GUID: %u) does not belong to player %s (GUID: %u)", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str(), GUID_LOPART(GetPlayer()->GetGUID())); + TC_LOG_DEBUG("network", "HandlePetAction: Pet (GUID: %u) does not belong to player %s (GUID: %u)", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str(), GUID_LOPART(GetPlayer()->GetGUID())); return; } @@ -144,7 +144,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint32 spellid CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) { - TC_LOG_ERROR("network", "WorldSession::HandlePetAction(petGuid: " UI64FMTD ", tagGuid: " UI64FMTD ", spellId: %u, flag: %u): object (GUID: %u Entry: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", + TC_LOG_DEBUG("network", "WorldSession::HandlePetAction(petGuid: " UI64FMTD ", tagGuid: " UI64FMTD ", spellId: %u, flag: %u): object (GUID: %u Entry: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", guid1, guid2, spellid, flag, pet->GetGUIDLow(), pet->GetEntry(), pet->GetTypeId()); return; } diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index eda7b8917a7..3ac31da3eb1 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -123,7 +123,8 @@ WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 isRecruiter(isARecruiter), _RBACData(NULL), expireTime(60000), // 1 min after socket loss, session is deleted - forceExit(false) + forceExit(false), + m_currentBankerGUID(0) { memset(m_Tutorials, 0, sizeof(m_Tutorials)); @@ -1245,6 +1246,12 @@ void WorldSession::InvalidateRBACData() bool WorldSession::DosProtection::EvaluateOpcode(WorldPacket& p, time_t time) const { + uint32 maxPacketCounterAllowed = GetMaxPacketCounterAllowed(p.GetOpcode()); + + // Return true if there no limit for the opcode + if (!maxPacketCounterAllowed) + return true; + PacketCounter& packetCounter = _PacketThrottlingMap[p.GetOpcode()]; if (packetCounter.lastReceiveTime != time) { @@ -1252,29 +1259,14 @@ bool WorldSession::DosProtection::EvaluateOpcode(WorldPacket& p, time_t time) co packetCounter.amountCounter = 0; } - uint32 maxPacketCounterAllowed = GetMaxPacketCounterAllowed(p.GetOpcode()); - - bool dosTriggered = false; // Check if player is flooding some packets if (++packetCounter.amountCounter > maxPacketCounterAllowed) { - dosTriggered = true; TC_LOG_WARN("network", "AntiDOS: Account %u, IP: %s, Ping: %u, Character: %s, flooding packet (opc: %s (0x%X), count: %u)", Session->GetAccountId(), Session->GetRemoteAddress().c_str(), Session->GetLatency(), Session->GetPlayerName().c_str(), opcodeTable[p.GetOpcode()].name, p.GetOpcode(), packetCounter.amountCounter); } - - // Then check if player is sending packets not allowed - if (!IsOpcodeAllowed(p.GetOpcode())) - { - dosTriggered = true; - // Opcode not allowed, let the punishment begin - TC_LOG_WARN("network", "AntiDOS: Account %u, IP: %s, sent unacceptable packet (opc: %u, size: %u)", - Session->GetAccountId(), Session->GetRemoteAddress().c_str(), p.GetOpcode(), (uint32)p.size()); - } - // Return true if everything is fine, otherwise apply the configured policy - if (!dosTriggered) return true; switch (_policy) @@ -1311,207 +1303,220 @@ uint32 WorldSession::DosProtection::GetMaxPacketCounterAllowed(uint16 opcode) co uint32 maxPacketCounterAllowed; switch (opcode) { - // These opcodes are spammed by few addons so a very high limit is required - case CMSG_QUEST_QUERY: - case CMSG_MESSAGECHAT: - case CMSG_ITEM_QUERY_SINGLE: - case CMSG_ITEM_NAME_QUERY: - case CMSG_GAMEOBJECT_QUERY: - case CMSG_NAME_QUERY: - case CMSG_PET_NAME_QUERY: - case CMSG_CREATURE_QUERY: - case CMSG_NPC_TEXT_QUERY: - case CMSG_QUESTGIVER_STATUS_QUERY: + // CPU usage sending 2000 packets/second on a 3.70 GHz 4 cores on Win x64 + // [% CPU mysqld] [%CPU worldserver RelWithDebInfo] + case CMSG_PLAYER_LOGIN: // 0 0.5 + case CMSG_NAME_QUERY: // 0 1 + case CMSG_PET_NAME_QUERY: // 0 1 + case CMSG_NPC_TEXT_QUERY: // 0 1 + case CMSG_ATTACKSTOP: // 0 1 + case CMSG_QUERY_QUESTS_COMPLETED: // 0 1 + case CMSG_QUERY_TIME: // 0 1 + case CMSG_CORPSE_MAP_POSITION_QUERY: // 0 1 + case CMSG_MOVE_TIME_SKIPPED: // 0 1 + case MSG_QUERY_NEXT_MAIL_TIME: // 0 1 + case CMSG_SETSHEATHED: // 0 1 + case MSG_RAID_TARGET_UPDATE: // 0 1 + case CMSG_PLAYER_LOGOUT: // 0 1 + case CMSG_LOGOUT_REQUEST: // 0 1 + case CMSG_PET_RENAME: // 0 1 + case CMSG_QUESTGIVER_CANCEL: // 0 1 + case CMSG_QUESTGIVER_REQUEST_REWARD: // 0 1 + case CMSG_COMPLETE_CINEMATIC: // 0 1 + case CMSG_BANKER_ACTIVATE: // 0 1 + case CMSG_BUY_BANK_SLOT: // 0 1 + case CMSG_OPT_OUT_OF_LOOT: // 0 1 + case CMSG_DUEL_ACCEPTED: // 0 1 + case CMSG_DUEL_CANCELLED: // 0 1 + case CMSG_CALENDAR_COMPLAIN: // 0 1 + case CMSG_QUEST_QUERY: // 0 1.5 + case CMSG_ITEM_QUERY_SINGLE: // 0 1.5 + case CMSG_ITEM_NAME_QUERY: // 0 1.5 + case CMSG_GAMEOBJECT_QUERY: // 0 1.5 + case CMSG_CREATURE_QUERY: // 0 1.5 + case CMSG_QUESTGIVER_STATUS_QUERY: // 0 1.5 + case CMSG_GUILD_QUERY: // 0 1.5 + case CMSG_ARENA_TEAM_QUERY: // 0 1.5 + case CMSG_TAXINODE_STATUS_QUERY: // 0 1.5 + case CMSG_TAXIQUERYAVAILABLENODES: // 0 1.5 + case CMSG_QUESTGIVER_QUERY_QUEST: // 0 1.5 + case CMSG_PAGE_TEXT_QUERY: // 0 1.5 + case MSG_QUERY_GUILD_BANK_TEXT: // 0 1.5 + case MSG_CORPSE_QUERY: // 0 1.5 + case MSG_MOVE_SET_FACING: // 0 1.5 + case CMSG_REQUEST_PARTY_MEMBER_STATS: // 0 1.5 + case CMSG_QUESTGIVER_COMPLETE_QUEST: // 0 1.5 + case CMSG_SET_ACTION_BUTTON: // 0 1.5 + case CMSG_RESET_INSTANCES: // 0 1.5 + case CMSG_HEARTH_AND_RESURRECT: // 0 1.5 + case CMSG_TOGGLE_PVP: // 0 1.5 + case CMSG_PET_ABANDON: // 0 1.5 + case CMSG_ACTIVATETAXIEXPRESS: // 0 1.5 + case CMSG_ACTIVATETAXI: // 0 1.5 + case CMSG_SELF_RES: // 0 1.5 + case CMSG_UNLEARN_SKILL: // 0 1.5 + case CMSG_EQUIPMENT_SET_SAVE: // 0 1.5 + case CMSG_DELETEEQUIPMENT_SET: // 0 1.5 + case CMSG_DISMISS_CRITTER: // 0 1.5 + case CMSG_REPOP_REQUEST: // 0 1.5 + case CMSG_GROUP_INVITE: // 0 1.5 + case CMSG_GROUP_DECLINE: // 0 1.5 + case CMSG_GROUP_ACCEPT: // 0 1.5 + case CMSG_GROUP_UNINVITE_GUID: // 0 1.5 + case CMSG_GROUP_UNINVITE: // 0 1.5 + case CMSG_GROUP_DISBAND: // 0 1.5 + case CMSG_BATTLEMASTER_JOIN_ARENA: // 0 1.5 + case CMSG_LEAVE_BATTLEFIELD: // 0 1.5 + case MSG_GUILD_BANK_LOG_QUERY: // 0 2 + case CMSG_LOGOUT_CANCEL: // 0 2 + case CMSG_REALM_SPLIT: // 0 2 + case CMSG_ALTER_APPEARANCE: // 0 2 + case CMSG_QUEST_CONFIRM_ACCEPT: // 0 2 + case MSG_GUILD_EVENT_LOG_QUERY: // 0 2.5 + case CMSG_READY_FOR_ACCOUNT_DATA_TIMES: // 0 2.5 + case CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY: // 0 2.5 + case CMSG_BEGIN_TRADE: // 0 2.5 + case CMSG_INITIATE_TRADE: // 0 3 + case CMSG_MESSAGECHAT: // 0 3.5 + case CMSG_INSPECT: // 0 3.5 + case CMSG_AREA_SPIRIT_HEALER_QUERY: // not profiled { - maxPacketCounterAllowed = 5000; + // "0" is a magic number meaning there's no limit for the opcode. + // All the opcodes above must cause little CPU usage and no sync/async database queries at all + maxPacketCounterAllowed = 0; break; } - case CMSG_ATTACKSTOP: - case CMSG_GUILD_QUERY: - case CMSG_ARENA_TEAM_QUERY: - case CMSG_TAXINODE_STATUS_QUERY: - case CMSG_TAXIQUERYAVAILABLENODES: - case CMSG_QUESTGIVER_QUERY_QUEST: - case CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY: - case CMSG_QUERY_QUESTS_COMPLETED: - case CMSG_QUEST_POI_QUERY: - case CMSG_QUERY_TIME: - case CMSG_PAGE_TEXT_QUERY: - case CMSG_PETITION_QUERY: - case CMSG_QUERY_INSPECT_ACHIEVEMENTS: - case CMSG_AREA_SPIRIT_HEALER_QUERY: - case CMSG_CORPSE_MAP_POSITION_QUERY: - case CMSG_MOVE_TIME_SKIPPED: - case CMSG_GUILD_BANK_QUERY_TAB: - case MSG_GUILD_BANK_LOG_QUERY: - case MSG_QUERY_GUILD_BANK_TEXT: - case MSG_CORPSE_QUERY: - case MSG_QUERY_NEXT_MAIL_TIME: - case MSG_GUILD_EVENT_LOG_QUERY: - case MSG_MOVE_SET_FACING: - case CMSG_INSPECT: + case CMSG_QUESTGIVER_ACCEPT_QUEST: // 0 4 + case CMSG_QUESTLOG_REMOVE_QUEST: // 0 4 + case CMSG_QUESTGIVER_CHOOSE_REWARD: // 0 4 + case CMSG_CONTACT_LIST: // 0 5 + case CMSG_LEARN_PREVIEW_TALENTS: // 0 6 + case CMSG_AUTOBANK_ITEM: // 0 6 + case CMSG_AUTOSTORE_BANK_ITEM: // 0 6 + case CMSG_WHO: // 0 7 + case CMSG_PLAYER_VEHICLE_ENTER: // 0 8 + case CMSG_LEARN_PREVIEW_TALENTS_PET: // not profiled + case MSG_MOVE_HEARTBEAT: { - maxPacketCounterAllowed = 500; + maxPacketCounterAllowed = 200; break; } - case CMSG_REQUEST_PARTY_MEMBER_STATS: - case CMSG_WHO: - case CMSG_SETSHEATHED: - case CMSG_CONTACT_LIST: - case CMSG_GUILD_SET_PUBLIC_NOTE: - case CMSG_GUILD_SET_OFFICER_NOTE: + case CMSG_GUILD_SET_PUBLIC_NOTE: // 1 2 1 async db query + case CMSG_GUILD_SET_OFFICER_NOTE: // 1 2 1 async db query + case CMSG_SET_CONTACT_NOTES: // 1 2.5 1 async db query + case CMSG_CALENDAR_GET_CALENDAR: // 0 1.5 medium upload bandwidth usage + case CMSG_GUILD_BANK_QUERY_TAB: // 0 3.5 medium upload bandwidth usage + case CMSG_QUERY_INSPECT_ACHIEVEMENTS: // 0 13 high upload bandwidth usage { maxPacketCounterAllowed = 50; break; } - case CMSG_SPELLCLICK: - case CMSG_GAMEOBJ_USE: - case CMSG_GAMEOBJ_REPORT_USE: - case MSG_RAID_TARGET_UPDATE: - case CMSG_QUESTGIVER_COMPLETE_QUEST: - case CMSG_PLAYER_VEHICLE_ENTER: - case CMSG_PETITION_SIGN: + case CMSG_QUEST_POI_QUERY: // 0 25 very high upload bandwidth usage + { + maxPacketCounterAllowed = MAX_QUEST_LOG_SIZE; + break; + } + + case CMSG_GM_REPORT_LAG: // 1 3 1 async db query + case CMSG_SPELLCLICK: // not profiled + case CMSG_GAMEOBJ_USE: // not profiled + case CMSG_GAMEOBJ_REPORT_USE: // not profiled + case CMSG_REMOVE_GLYPH: // not profiled { maxPacketCounterAllowed = 20; break; } - case CMSG_PLAYER_LOGOUT: - case CMSG_LOGOUT_REQUEST: - case CMSG_LOGOUT_CANCEL: - case CMSG_CHANGE_SEATS_ON_CONTROLLED_VEHICLE: - case CMSG_REQUEST_VEHICLE_PREV_SEAT: - case CMSG_REQUEST_VEHICLE_NEXT_SEAT: - case CMSG_REQUEST_VEHICLE_SWITCH_SEAT: - case CMSG_TOGGLE_PVP: - case CMSG_ADD_FRIEND: - case CMSG_DEL_FRIEND: - case CMSG_SET_CONTACT_NOTES: - case CMSG_RESET_INSTANCES: - case CMSG_HEARTH_AND_RESURRECT: - case CMSG_CHAR_CREATE: - case CMSG_READY_FOR_ACCOUNT_DATA_TIMES: - case CMSG_CHAR_ENUM: - case CMSG_REALM_SPLIT: - case CMSG_CHAR_DELETE: - case CMSG_PLAYER_LOGIN: - case CMSG_PET_ABANDON: - case CMSG_PET_RENAME: - case CMSG_CHAR_RENAME: - case CMSG_CHAR_CUSTOMIZE: - case CMSG_CHAR_RACE_CHANGE: - case CMSG_CHAR_FACTION_CHANGE: - case CMSG_GMTICKET_CREATE: - case CMSG_GMTICKET_UPDATETEXT: - case CMSG_GMTICKET_DELETETICKET: - case CMSG_GMSURVEY_SUBMIT: - case CMSG_GM_REPORT_LAG: - case CMSG_BUG: - case CMSG_GMRESPONSE_RESOLVE: - case CMSG_ACTIVATETAXIEXPRESS: - case CMSG_ACTIVATETAXI: - case CMSG_SELF_RES: - case CMSG_INITIATE_TRADE: - case CMSG_BEGIN_TRADE: - case CMSG_UNLEARN_SKILL: - case CMSG_DISMISS_CONTROLLED_VEHICLE: - case CMSG_REQUEST_VEHICLE_EXIT: - case CMSG_LEARN_PREVIEW_TALENTS: - case CMSG_LEARN_PREVIEW_TALENTS_PET: - case CMSG_CONTROLLER_EJECT_PASSENGER: - case CMSG_EQUIPMENT_SET_SAVE: - case CMSG_DELETEEQUIPMENT_SET: - case CMSG_REMOVE_GLYPH: - case CMSG_ALTER_APPEARANCE: - case CMSG_QUESTGIVER_ACCEPT_QUEST: - case CMSG_QUESTGIVER_CHOOSE_REWARD: - case CMSG_QUESTGIVER_REQUEST_REWARD: - case CMSG_QUESTGIVER_CANCEL: - case CMSG_QUESTLOG_REMOVE_QUEST: - case CMSG_QUEST_CONFIRM_ACCEPT: - case CMSG_DISMISS_CRITTER: - case CMSG_REPOP_REQUEST: - case CMSG_PETITION_BUY: - case CMSG_TURN_IN_PETITION: - case CMSG_COMPLETE_CINEMATIC: - case CMSG_ITEM_REFUND: - case CMSG_SOCKET_GEMS: - case CMSG_WRAP_ITEM: - case CMSG_BUY_BANK_SLOT: - case CMSG_GROUP_ACCEPT: - case CMSG_GROUP_DECLINE: - case CMSG_GROUP_UNINVITE_GUID: - case CMSG_GROUP_UNINVITE: - case CMSG_GROUP_SET_LEADER: - case CMSG_GROUP_DISBAND: - case CMSG_GROUP_RAID_CONVERT: - case CMSG_GROUP_CHANGE_SUB_GROUP: - case CMSG_GROUP_ASSISTANT_LEADER: - case CMSG_OPT_OUT_OF_LOOT: - case CMSG_BATTLEMASTER_JOIN_ARENA: - case CMSG_LEAVE_BATTLEFIELD: - case CMSG_REPORT_PVP_AFK: - case CMSG_DUEL_ACCEPTED: - case CMSG_DUEL_CANCELLED: - case CMSG_CALENDAR_GET_CALENDAR: - case CMSG_CALENDAR_ADD_EVENT: - case CMSG_CALENDAR_UPDATE_EVENT: - case CMSG_CALENDAR_REMOVE_EVENT: - case CMSG_CALENDAR_COPY_EVENT: - case CMSG_CALENDAR_EVENT_INVITE: - case CMSG_CALENDAR_EVENT_SIGNUP: - case CMSG_CALENDAR_EVENT_RSVP: - case CMSG_CALENDAR_EVENT_REMOVE_INVITE: - case CMSG_CALENDAR_EVENT_MODERATOR_STATUS: - case CMSG_CALENDAR_COMPLAIN: - case CMSG_ARENA_TEAM_INVITE: - case CMSG_ARENA_TEAM_ACCEPT: - case CMSG_ARENA_TEAM_DECLINE: - case CMSG_ARENA_TEAM_LEAVE: - case CMSG_ARENA_TEAM_DISBAND: - case CMSG_ARENA_TEAM_REMOVE: - case CMSG_ARENA_TEAM_LEADER: - case CMSG_LOOT_METHOD: - case CMSG_GUILD_INVITE: - case CMSG_GUILD_ACCEPT: - case CMSG_GUILD_DECLINE: - case CMSG_GUILD_LEAVE: - case CMSG_GUILD_DISBAND: - case CMSG_GUILD_LEADER: - case CMSG_GUILD_MOTD: - case CMSG_GUILD_RANK: - case CMSG_GUILD_ADD_RANK: - case CMSG_GUILD_DEL_RANK: - case CMSG_GUILD_INFO_TEXT: - case CMSG_GUILD_BANK_DEPOSIT_MONEY: - case CMSG_GUILD_BANK_WITHDRAW_MONEY: - case CMSG_GUILD_BANK_BUY_TAB: - case CMSG_GUILD_BANK_UPDATE_TAB: - case CMSG_SET_GUILD_BANK_TEXT: - case MSG_SAVE_GUILD_EMBLEM: - case MSG_PETITION_RENAME: - case MSG_PETITION_DECLINE: - case MSG_TALENT_WIPE_CONFIRM: - case MSG_SET_DUNGEON_DIFFICULTY: - case MSG_SET_RAID_DIFFICULTY: - case MSG_RANDOM_ROLL: - case MSG_PARTY_ASSIGNMENT: - case MSG_RAID_READY_CHECK: + case CMSG_PETITION_SIGN: // 9 4 2 sync 1 async db queries + case CMSG_TURN_IN_PETITION: // 8 5.5 2 sync db query + case CMSG_GROUP_CHANGE_SUB_GROUP: // 6 5 1 sync 1 async db queries + case CMSG_PETITION_QUERY: // 4 3.5 1 sync db query + case CMSG_CHAR_RACE_CHANGE: // 5 4 1 sync db query + case CMSG_CHAR_CUSTOMIZE: // 5 5 1 sync db query + case CMSG_CHAR_FACTION_CHANGE: // 5 5 1 sync db query + case CMSG_CHAR_DELETE: // 4 4 1 sync db query + case CMSG_DEL_FRIEND: // 7 5 1 async db query + case CMSG_ADD_FRIEND: // 6 4 1 async db query + case CMSG_CHAR_RENAME: // 5 3 1 async db query + case CMSG_GMSURVEY_SUBMIT: // 2 3 1 async db query + case CMSG_BUG: // 1 1 1 async db query + case CMSG_GROUP_SET_LEADER: // 1 2 1 async db query + case CMSG_GROUP_RAID_CONVERT: // 1 5 1 async db query + case CMSG_GROUP_ASSISTANT_LEADER: // 1 2 1 async db query + case CMSG_CALENDAR_ADD_EVENT: // 21 10 2 async db query + case CMSG_PETITION_BUY: // not profiled 1 sync 1 async db queries + case CMSG_CHANGE_SEATS_ON_CONTROLLED_VEHICLE: // not profiled + case CMSG_REQUEST_VEHICLE_PREV_SEAT: // not profiled + case CMSG_REQUEST_VEHICLE_NEXT_SEAT: // not profiled + case CMSG_REQUEST_VEHICLE_SWITCH_SEAT: // not profiled + case CMSG_DISMISS_CONTROLLED_VEHICLE: // not profiled + case CMSG_REQUEST_VEHICLE_EXIT: // not profiled + case CMSG_CONTROLLER_EJECT_PASSENGER: // not profiled + case CMSG_ITEM_REFUND: // not profiled + case CMSG_SOCKET_GEMS: // not profiled + case CMSG_WRAP_ITEM: // not profiled + case CMSG_REPORT_PVP_AFK: // not profiled { - maxPacketCounterAllowed = 3; + maxPacketCounterAllowed = 10; break; } - case CMSG_SET_ACTION_BUTTON: + case CMSG_CHAR_CREATE: // 7 5 3 async db queries + case CMSG_CHAR_ENUM: // 22 3 2 async db queries + case CMSG_GMTICKET_CREATE: // 1 25 1 async db query + case CMSG_GMTICKET_UPDATETEXT: // 0 15 1 async db query + case CMSG_GMTICKET_DELETETICKET: // 1 25 1 async db query + case CMSG_GMRESPONSE_RESOLVE: // 1 25 1 async db query + case CMSG_CALENDAR_UPDATE_EVENT: // not profiled + case CMSG_CALENDAR_REMOVE_EVENT: // not profiled + case CMSG_CALENDAR_COPY_EVENT: // not profiled + case CMSG_CALENDAR_EVENT_INVITE: // not profiled + case CMSG_CALENDAR_EVENT_SIGNUP: // not profiled + case CMSG_CALENDAR_EVENT_RSVP: // not profiled + case CMSG_CALENDAR_EVENT_REMOVE_INVITE: // not profiled + case CMSG_CALENDAR_EVENT_MODERATOR_STATUS: // not profiled + case CMSG_ARENA_TEAM_INVITE: // not profiled + case CMSG_ARENA_TEAM_ACCEPT: // not profiled + case CMSG_ARENA_TEAM_DECLINE: // not profiled + case CMSG_ARENA_TEAM_LEAVE: // not profiled + case CMSG_ARENA_TEAM_DISBAND: // not profiled + case CMSG_ARENA_TEAM_REMOVE: // not profiled + case CMSG_ARENA_TEAM_LEADER: // not profiled + case CMSG_LOOT_METHOD: // not profiled + case CMSG_GUILD_INVITE: // not profiled + case CMSG_GUILD_ACCEPT: // not profiled + case CMSG_GUILD_DECLINE: // not profiled + case CMSG_GUILD_LEAVE: // not profiled + case CMSG_GUILD_DISBAND: // not profiled + case CMSG_GUILD_LEADER: // not profiled + case CMSG_GUILD_MOTD: // not profiled + case CMSG_GUILD_RANK: // not profiled + case CMSG_GUILD_ADD_RANK: // not profiled + case CMSG_GUILD_DEL_RANK: // not profiled + case CMSG_GUILD_INFO_TEXT: // not profiled + case CMSG_GUILD_BANK_DEPOSIT_MONEY: // not profiled + case CMSG_GUILD_BANK_WITHDRAW_MONEY: // not profiled + case CMSG_GUILD_BANK_BUY_TAB: // not profiled + case CMSG_GUILD_BANK_UPDATE_TAB: // not profiled + case CMSG_SET_GUILD_BANK_TEXT: // not profiled + case MSG_SAVE_GUILD_EMBLEM: // not profiled + case MSG_PETITION_RENAME: // not profiled + case MSG_PETITION_DECLINE: // not profiled + case MSG_TALENT_WIPE_CONFIRM: // not profiled + case MSG_SET_DUNGEON_DIFFICULTY: // not profiled + case MSG_SET_RAID_DIFFICULTY: // not profiled + case MSG_RANDOM_ROLL: // not profiled + case MSG_PARTY_ASSIGNMENT: // not profiled + case MSG_RAID_READY_CHECK: // not profiled { - maxPacketCounterAllowed = MAX_ACTION_BUTTONS; + maxPacketCounterAllowed = 3; break; } - case CMSG_ITEM_REFUND_INFO: + case CMSG_ITEM_REFUND_INFO: // not profiled { maxPacketCounterAllowed = PLAYER_SLOTS_COUNT; break; diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 82125aafd6d..61d2fa6d106 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -937,7 +937,6 @@ class WorldSession public: DosProtection(WorldSession* s) : Session(s), _policy((Policy)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_POLICY)) { } bool EvaluateOpcode(WorldPacket& p, time_t time) const; - void AllowOpcode(uint16 opcode, bool allow) { _isOpcodeAllowed[opcode] = allow; } protected: enum Policy { @@ -946,22 +945,11 @@ class WorldSession POLICY_BAN, }; - bool IsOpcodeAllowed(uint16 opcode) const - { - OpcodeStatusMap::const_iterator itr = _isOpcodeAllowed.find(opcode); - if (itr == _isOpcodeAllowed.end()) - return true; // No presence in the map indicates this is the first time the opcode was sent this session, so allow - - return itr->second; - } - uint32 GetMaxPacketCounterAllowed(uint16 opcode) const; WorldSession* Session; private: - typedef std::unordered_map<uint16, bool> OpcodeStatusMap; - OpcodeStatusMap _isOpcodeAllowed; // could be bool array, but wouldn't be practical for game versions with non-linear opcodes Policy _policy; typedef std::unordered_map<uint16, PacketCounter> PacketThrottlingMap; // mark this member as "mutable" so it can be modified even in const functions @@ -975,6 +963,8 @@ class WorldSession // private trade methods void moveItems(Item* myItems[], Item* hisItems[]); + bool CanUseBank(uint64 bankerGUID = 0) const; + // logging helper void LogUnexpectedOpcode(WorldPacket* packet, const char* status, const char *reason); void LogUnprocessedTail(WorldPacket* packet); @@ -1023,6 +1013,7 @@ class WorldSession rbac::RBACData* _RBACData; uint32 expireTime; bool forceExit; + uint64 m_currentBankerGUID; WorldSession(WorldSession const& right) = delete; WorldSession& operator=(WorldSession const& right) = delete; diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index dbd687a09d8..97a2db796d5 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -380,7 +380,7 @@ AuraEffect::AuraEffect(Aura* base, uint8 effIndex, int32 *baseAmount, Unit* cast m_base(base), m_spellInfo(base->GetSpellInfo()), m_baseAmount(baseAmount ? *baseAmount : m_spellInfo->Effects[effIndex].BasePoints), m_spellmod(NULL), m_periodicTimer(0), m_tickNumber(0), m_effIndex(effIndex), -m_canBeRecalculated(true), m_isPeriodic(false) +m_canBeRecalculated(true), m_damage(0), m_critChance(0.0f), m_donePct(1.0f), m_isPeriodic(false) { CalculatePeriodic(caster, true, false); @@ -890,19 +890,15 @@ void AuraEffect::UpdatePeriodic(Unit* caster) GetBase()->CallScriptEffectUpdatePeriodicHandlers(this); } -bool AuraEffect::IsPeriodicTickCrit(Unit* target, Unit const* caster) const +bool AuraEffect::CanPeriodicTickCrit(Unit const* caster) const { ASSERT(caster); - Unit::AuraEffectList const& mPeriodicCritAuras= caster->GetAuraEffectsByType(SPELL_AURA_ABILITY_PERIODIC_CRIT); - for (Unit::AuraEffectList::const_iterator itr = mPeriodicCritAuras.begin(); itr != mPeriodicCritAuras.end(); ++itr) - { - if ((*itr)->IsAffectedOnSpell(m_spellInfo) && caster->isSpellCrit(target, m_spellInfo, m_spellInfo->GetSchoolMask())) - return true; - } + if (caster->HasAuraTypeWithAffectMask(SPELL_AURA_ABILITY_PERIODIC_CRIT, m_spellInfo)) + return true; // Rupture - since 3.3.3 can crit if (m_spellInfo->SpellIconID == 500 && m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE) - return caster->isSpellCrit(target, m_spellInfo, m_spellInfo->GetSchoolMask()); + return true; return false; } @@ -5832,15 +5828,19 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const uint32 resist = 0; CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL); - // ignore non positive values (can be result apply spellmods to aura damage - uint32 damage = std::max(GetAmount(), 0); + // AOE spells are not affected by the new periodic system. + bool isAreaAura = m_spellInfo->Effects[m_effIndex].IsAreaAuraEffect() || m_spellInfo->Effects[m_effIndex].IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA); + // ignore negative values (can be result apply spellmods to aura damage + uint32 damage = isAreaAura ? std::max(GetAmount(), 0) : m_damage; // Script Hook For HandlePeriodicDamageAurasTick -- Allow scripts to change the Damage pre class mitigation calculations - sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage); + if (isAreaAura) + sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage); if (GetAuraType() == SPELL_AURA_PERIODIC_DAMAGE) { - damage = caster->SpellDamageBonusDone(target, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()); + if (isAreaAura) + damage = caster->SpellDamageBonusDone(target, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()) * caster->SpellDamagePctDone(target, m_spellInfo, DOT); damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()); // Calculate armor mitigation @@ -5896,14 +5896,19 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const else damage = uint32(target->CountPctFromMaxHealth(damage)); - if (m_spellInfo->Effects[m_effIndex].IsTargetingArea() || m_spellInfo->Effects[m_effIndex].IsAreaAuraEffect() || m_spellInfo->Effects[m_effIndex].IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA)) - { - damage = int32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); - if (caster->GetTypeId() != TYPEID_PLAYER) - damage = int32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); - } + if (!(m_spellInfo->AttributesEx4 & SPELL_ATTR4_FIXED_DAMAGE)) + if (m_spellInfo->Effects[m_effIndex].IsTargetingArea() || isAreaAura) + { + damage = int32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); + if (caster->GetTypeId() != TYPEID_PLAYER) + damage = int32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); + } + + bool crit = false; + + if (CanPeriodicTickCrit(caster)) + crit = roll_chance_f(isAreaAura ? caster->GetUnitSpellCriticalChance(target, m_spellInfo, m_spellInfo->GetSchoolMask()) : m_critChance); - bool crit = IsPeriodicTickCrit(target, caster); if (crit) damage = caster->SpellCriticalDamageBonus(m_spellInfo, damage, target); @@ -5958,23 +5963,42 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c uint32 resist = 0; CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL); - uint32 damage = std::max(GetAmount(), 0); + bool isAreaAura = m_spellInfo->Effects[m_effIndex].IsAreaAuraEffect() || m_spellInfo->Effects[m_effIndex].IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA); + // ignore negative values (can be result apply spellmods to aura damage + uint32 damage = isAreaAura ? std::max(GetAmount(), 0) : m_damage; - damage = caster->SpellDamageBonusDone(target, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()); + if (isAreaAura) + { + // Script Hook For HandlePeriodicDamageAurasTick -- Allow scripts to change the Damage pre class mitigation calculations + sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage); + damage = caster->SpellDamageBonusDone(target, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()) * caster->SpellDamagePctDone(target, m_spellInfo, DOT); + } damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()); - bool crit = IsPeriodicTickCrit(target, caster); - if (crit) - damage = caster->SpellCriticalDamageBonus(m_spellInfo, damage, target); - // Calculate armor mitigation - if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), m_effIndex)) + if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), GetEffIndex())) { uint32 damageReductedArmor = caster->CalcArmorReducedDamage(target, damage, GetSpellInfo()); cleanDamage.mitigated_damage += damage - damageReductedArmor; damage = damageReductedArmor; } + if (!(m_spellInfo->AttributesEx4 & SPELL_ATTR4_FIXED_DAMAGE)) + if (m_spellInfo->Effects[m_effIndex].IsTargetingArea() || isAreaAura) + { + damage = int32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); + if (caster->GetTypeId() != TYPEID_PLAYER) + damage = int32(float(damage) * target->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, m_spellInfo->SchoolMask)); + } + + bool crit = false; + + if (CanPeriodicTickCrit(caster)) + crit = roll_chance_f(isAreaAura ? caster->GetUnitSpellCriticalChance(target, m_spellInfo, m_spellInfo->GetSchoolMask()) : m_critChance); + + if (crit) + damage = caster->SpellCriticalDamageBonus(m_spellInfo, damage, target); + int32 dmg = damage; if (!(GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_FIXED_DAMAGE)) caster->ApplyResilience(target, NULL, &dmg, crit, CR_CRIT_TAKEN_SPELL); @@ -6059,8 +6083,9 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const if (GetBase()->IsPermanent() && target->IsFullHealth()) return; + bool isAreaAura = m_spellInfo->Effects[m_effIndex].IsAreaAuraEffect() || m_spellInfo->Effects[m_effIndex].IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA); // ignore negative values (can be result apply spellmods to aura damage - int32 damage = std::max(m_amount, 0); + int32 damage = isAreaAura ? std::max(GetAmount(), 0) : m_damage; if (GetAuraType() == SPELL_AURA_OBS_MOD_HEALTH) { @@ -6108,12 +6133,16 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const damage += addition; } - - damage = caster->SpellHealingBonusDone(target, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()); + if (isAreaAura) + damage = caster->SpellHealingBonusDone(target, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()) * caster->SpellHealingPctDone(target, m_spellInfo); damage = target->SpellHealingBonusTaken(caster, GetSpellInfo(), damage, DOT, GetBase()->GetStackAmount()); } - bool crit = IsPeriodicTickCrit(target, caster); + bool crit = false; + + if (CanPeriodicTickCrit(caster)) + crit = roll_chance_f(isAreaAura ? caster->GetUnitSpellCriticalChance(target, m_spellInfo, m_spellInfo->GetSchoolMask()) : m_critChance); + if (crit) damage = caster->SpellCriticalHealingBonus(m_spellInfo, damage, target); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index 0887ce123e2..5eec9021291 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -70,6 +70,13 @@ class AuraEffect void HandleEffect(Unit* target, uint8 mode, bool apply); void ApplySpellMod(Unit* target, bool apply); + void SetDamage(int32 val) { m_damage = val; } + int32 GetDamage() const { return m_damage; } + void SetCritChance(float val) { m_critChance = val; } + float GetCritChance() const { return m_critChance; } + void SetDonePct(float val) { m_donePct = val; } + float GetDonePct() const { return m_donePct; } + void Update(uint32 diff, Unit* caster); void UpdatePeriodic(Unit* caster); @@ -98,6 +105,9 @@ class AuraEffect int32 const m_baseAmount; int32 m_amount; + int32 m_damage; + float m_critChance; + float m_donePct; SpellModifier* m_spellmod; @@ -109,7 +119,7 @@ class AuraEffect bool m_canBeRecalculated; bool m_isPeriodic; private: - bool IsPeriodicTickCrit(Unit* target, Unit const* caster) const; + bool CanPeriodicTickCrit(Unit const* caster) const; public: // aura effect apply/remove handlers diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 3e1763e6c5b..683059b8e99 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -746,9 +746,20 @@ void Aura::SetDuration(int32 duration, bool withMods) SetNeedClientUpdateForTargets(); } -void Aura::RefreshDuration() +void Aura::RefreshDuration(bool withMods) { - SetDuration(GetMaxDuration()); + if (withMods) + { + int32 duration = m_spellInfo->GetMaxDuration(); + // Calculate duration of periodics affected by haste. + if (GetCaster()->HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, m_spellInfo) || m_spellInfo->AttributesEx5 & SPELL_ATTR5_HASTE_AFFECT_DURATION) + duration = int32(duration * GetCaster()->GetFloatValue(UNIT_MOD_CAST_SPEED)); + + SetMaxDuration(duration); + SetDuration(duration); + } + else + SetDuration(GetMaxDuration()); if (m_spellInfo->ManaPerSecond || m_spellInfo->ManaPerSecondPerLevel) m_timeCla = 1 * IN_MILLISECONDS; @@ -825,7 +836,10 @@ void Aura::SetStackAmount(uint8 stackAmount) for (std::list<AuraApplication*>::const_iterator apptItr = applications.begin(); apptItr != applications.end(); ++apptItr) if (!(*apptItr)->GetRemoveMode()) + { HandleAuraSpecificMods(*apptItr, caster, true, true); + HandleAuraSpecificPeriodics(*apptItr, caster); + } SetNeedClientUpdateForTargets(); } @@ -1631,26 +1645,62 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b break; } break; - case SPELLFAMILY_WARLOCK: - // Drain Soul - If the target is at or below 25% health, Drain Soul causes four times the normal damage - if (GetSpellInfo()->SpellFamilyFlags[0] & 0x00004000) + } +} + +void Aura::HandleAuraSpecificPeriodics(AuraApplication const* aurApp, Unit* caster) +{ + Unit* target = aurApp->GetTarget(); + + if (!caster || aurApp->GetRemoveMode()) + return; + + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + if (!HasEffect(i)) + continue; + + if (m_spellInfo->Effects[i].IsAreaAuraEffect() || m_spellInfo->Effects[i].IsEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA)) + continue; + + switch (m_spellInfo->Effects[i].ApplyAuraName) + { + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: + case SPELL_AURA_PERIODIC_LEECH: { - if (!caster) - break; - if (apply) - { - if (target != caster && !target->HealthAbovePct(25)) - caster->CastSpell(caster, 100001, true); - } - else - { - if (target != caster) - caster->RemoveAurasDueToSpell(GetId()); - else - caster->RemoveAurasDueToSpell(100001); - } + AuraEffect* aurEff = GetEffect(i); + + // ignore non positive values (can be result apply spellmods to aura damage + uint32 damage = std::max(aurEff->GetAmount(), 0); + + // Script Hook For HandlePeriodicDamageAurasTick -- Allow scripts to change the Damage pre class mitigation calculations + sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage); + + aurEff->SetDonePct(caster->SpellDamagePctDone(target, m_spellInfo, DOT)); // Calculate done percentage first! + aurEff->SetDamage(caster->SpellDamageBonusDone(target, m_spellInfo, damage, DOT, GetStackAmount()) * aurEff->GetDonePct()); + aurEff->SetCritChance(caster->GetUnitSpellCriticalChance(target, m_spellInfo, m_spellInfo->GetSchoolMask())); + break; } - break; + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_OBS_MOD_HEALTH: + { + AuraEffect* aurEff = GetEffect(i); + + // ignore non positive values (can be result apply spellmods to aura damage + uint32 damage = std::max(aurEff->GetAmount(), 0); + + // Script Hook For HandlePeriodicDamageAurasTick -- Allow scripts to change the Damage pre class mitigation calculations + sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage); + + aurEff->SetDonePct(caster->SpellHealingPctDone(target, m_spellInfo)); // Calculate done percentage first! + aurEff->SetDamage(caster->SpellHealingBonusDone(target, m_spellInfo, damage, DOT, GetStackAmount()) * aurEff->GetDonePct()); + aurEff->SetCritChance(caster->GetUnitSpellCriticalChance(target, m_spellInfo, m_spellInfo->GetSchoolMask())); + break; + } + default: + break; + } } } diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index f62b1ff47b4..669d2a529a1 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -129,7 +129,7 @@ class Aura int32 CalcMaxDuration(Unit* caster) const; int32 GetDuration() const { return m_duration; } void SetDuration(int32 duration, bool withMods = false); - void RefreshDuration(); + void RefreshDuration(bool withMods = false); void RefreshTimers(); bool IsExpired() const { return !GetDuration();} bool IsPermanent() const { return GetMaxDuration() == -1; } @@ -190,6 +190,7 @@ class Aura void SetNeedClientUpdateForTargets() const; void HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, bool apply, bool onReapply); + void HandleAuraSpecificPeriodics(AuraApplication const* aurApp, Unit* caster); bool CanBeAppliedOn(Unit* target); bool CheckAreaTarget(Unit* target); bool CanStackWith(Aura const* existingAura) const; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index f5d90bc3612..ca170187e82 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2340,7 +2340,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) // Do healing and triggers if (m_healing > 0) { - bool crit = caster->isSpellCrit(unitTarget, m_spellInfo, m_spellSchoolMask); + bool crit = caster->IsSpellCrit(unitTarget, m_spellInfo, m_spellSchoolMask); uint32 addhealth = m_healing; if (crit) { @@ -6729,7 +6729,7 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier) } } - targetInfo.crit = m_caster->isSpellCrit(unit, m_spellInfo, m_spellSchoolMask, m_attackType); + targetInfo.crit = m_caster->IsSpellCrit(unit, m_spellInfo, m_spellSchoolMask, m_attackType); } SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& skillId, int32& reqSkillValue, int32& skillValue) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 5b68d244457..48c73cf39ca 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -1096,7 +1096,7 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/) TC_LOG_DEBUG("spells", "Spell::EffectTeleportUnits - teleport unit to %u %f %f %f %f\n", mapid, x, y, z, orientation); if (unitTarget->GetTypeId() == TYPEID_PLAYER) - unitTarget->ToPlayer()->TeleportTo(mapid, x, y, z, orientation, unitTarget == m_caster ? TELE_TO_SPELL : 0); + unitTarget->ToPlayer()->TeleportTo(mapid, x, y, z, orientation, unitTarget == m_caster ? TELE_TO_SPELL | TELE_TO_NOT_LEAVE_COMBAT : 0); else if (mapid == unitTarget->GetMapId()) unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster); else @@ -4056,15 +4056,40 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) { // Get diseases on target of spell if (m_targets.GetUnitTarget() && // Glyph of Disease - cast on unit target too to refresh aura - (m_targets.GetUnitTarget() != unitTarget || m_caster->GetAura(63334))) + (m_targets.GetUnitTarget() != unitTarget || m_caster->HasAura(63334))) { // And spread them on target // Blood Plague - if (m_targets.GetUnitTarget()->GetAura(55078)) + if (m_targets.GetUnitTarget()->HasAura(55078)) + { + AuraEffect* aurEffOld = m_targets.GetUnitTarget()->GetAura(55078)->GetEffect(0); + float donePct = aurEffOld->GetDonePct(); + float critChance = aurEffOld->GetCritChance(); + m_caster->CastSpell(unitTarget, 55078, true); + + if (unitTarget->HasAura(55078)) + if (AuraEffect* aurEffNew = unitTarget->GetAura(55078)->GetEffect(0)) + { + aurEffNew->SetCritChance(critChance); // Blood Plague can crit if caster has T9. + aurEffNew->SetDonePct(donePct); + aurEffNew->SetDamage(m_caster->SpellDamageBonusDone(unitTarget, aurEffNew->GetSpellInfo(), std::max(aurEffNew->GetAmount(), 0), DOT) * donePct); + } + } // Frost Fever - if (m_targets.GetUnitTarget()->GetAura(55095)) + if (m_targets.GetUnitTarget()->HasAura(55095)) + { + float donePct = m_targets.GetUnitTarget()->GetAura(55095)->GetEffect(0)->GetDonePct(); + m_caster->CastSpell(unitTarget, 55095, true); + + if (unitTarget->HasAura(55095)) + if (AuraEffect* aurEffNew = unitTarget->GetAura(55095)->GetEffect(0)) + { + aurEffNew->SetDonePct(donePct); + aurEffNew->SetDamage(m_caster->SpellDamageBonusDone(unitTarget, aurEffNew->GetSpellInfo(), std::max(aurEffNew->GetAmount(), 0), DOT) * donePct); + } + } } } break; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 04de93bae0c..6f56c0ebc40 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -793,14 +793,14 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellInfo const* spellProto, Spell bool hasFamilyMask = false; - /** - + /** + * @brief Check auras procced by periodics *Only damaging Dots can proc auras with PROC_FLAG_TAKEN_DAMAGE *Only Dots can proc if ONLY has PROC_FLAG_DONE_PERIODIC or PROC_FLAG_TAKEN_PERIODIC. - + *Hots can proc if ONLY has PROC_FLAG_DONE_PERIODIC and spellfamily != 0 *Only Dots can proc auras with PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG or PROC_FLAG_DONE_SPELL_NONE_DMG_CLASS_NEG @@ -815,7 +815,7 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellInfo const* spellProto, Spell * @param procFlags proc_flags of spellProc * @param procExtra proc_EX of procSpell * @param EventProcFlag proc_flags of aura to be procced - * @param spellProto SpellInfo of aura to be procced + * @param spellProto SpellInfo of aura to be procced */ @@ -824,7 +824,7 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellInfo const* spellProto, Spell return true; if (procFlags & PROC_FLAG_DONE_PERIODIC && EventProcFlag & PROC_FLAG_DONE_PERIODIC) - { + { if (procExtra & PROC_EX_INTERNAL_HOT) { if (EventProcFlag == PROC_FLAG_DONE_PERIODIC) @@ -844,7 +844,7 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellInfo const* spellProto, Spell } if (procFlags & PROC_FLAG_TAKEN_PERIODIC && EventProcFlag & PROC_FLAG_TAKEN_PERIODIC) - { + { if (procExtra & PROC_EX_INTERNAL_HOT) { /// No aura that only has PROC_FLAG_TAKEN_PERIODIC can proc from a HOT. diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_ambassador_flamelash.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_ambassador_flamelash.cpp index 4ac039e9138..3e4097daf20 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_ambassador_flamelash.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_ambassador_flamelash.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -24,64 +23,74 @@ enum Spells SPELL_FIREBLAST = 15573 }; -class boss_ambassador_flamelash : public CreatureScript +enum Events { -public: - boss_ambassador_flamelash() : CreatureScript("boss_ambassador_flamelash") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return new boss_ambassador_flamelashAI(creature); - } - - struct boss_ambassador_flamelashAI : public ScriptedAI - { - boss_ambassador_flamelashAI(Creature* creature) : ScriptedAI(creature) { } + EVENT_FIREBLAST = 1, + EVENT_SUMMON_SPIRITS = 2 +}; - uint32 FireBlast_Timer; - uint32 Spirit_Timer; +class boss_ambassador_flamelash : public CreatureScript +{ + public: + boss_ambassador_flamelash() : CreatureScript("boss_ambassador_flamelash") { } - void Reset() override + struct boss_ambassador_flamelashAI : public ScriptedAI { - FireBlast_Timer = 2000; - Spirit_Timer = 24000; - } + boss_ambassador_flamelashAI(Creature* creature) : ScriptedAI(creature) { } - void EnterCombat(Unit* /*who*/) override { } - - void SummonSpirits(Unit* victim) - { - if (Creature* Spirit = DoSpawnCreature(9178, float(irand(-9, 9)), float(irand(-9, 9)), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000)) - Spirit->AI()->AttackStart(victim); - } + void Reset() override + { + _events.Reset(); + } - void UpdateAI(uint32 diff) override - { - //Return since we have no target - if (!UpdateVictim()) - return; + void EnterCombat(Unit* /*who*/) override + { + _events.ScheduleEvent(EVENT_FIREBLAST, 2000); + _events.ScheduleEvent(EVENT_SUMMON_SPIRITS, 24000); + } - //FireBlast_Timer - if (FireBlast_Timer <= diff) + void SummonSpirit(Unit* victim) { - DoCastVictim(SPELL_FIREBLAST); - FireBlast_Timer = 7000; - } else FireBlast_Timer -= diff; + if (Creature* spirit = DoSpawnCreature(9178, frand(-9, 9), frand(-9, 9), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000)) + spirit->AI()->AttackStart(victim); + } - //Spirit_Timer - if (Spirit_Timer <= diff) + void UpdateAI(uint32 diff) override { - SummonSpirits(me->GetVictim()); - SummonSpirits(me->GetVictim()); - SummonSpirits(me->GetVictim()); - SummonSpirits(me->GetVictim()); + if (!UpdateVictim()) + return; - Spirit_Timer = 30000; - } else Spirit_Timer -= diff; + _events.Update(diff); - DoMeleeAttackIfReady(); + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_FIREBLAST: + DoCastVictim(SPELL_FIREBLAST); + _events.ScheduleEvent(EVENT_FIREBLAST, 7000); + break; + case EVENT_SUMMON_SPIRITS: + for (uint32 i = 0; i < 4; ++i) + SummonSpirit(me->GetVictim()); + _events.ScheduleEvent(EVENT_SUMMON_SPIRITS, 30000); + break; + default: + break; + } + } + + DoMeleeAttackIfReady(); + } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new boss_ambassador_flamelashAI(creature); } - }; }; void AddSC_boss_ambassador_flamelash() diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_anubshiah.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_anubshiah.cpp index fd8b77ea8d4..894b528c03c 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_anubshiah.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_anubshiah.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -21,90 +20,94 @@ enum Spells { - SPELL_SHADOWBOLT = 17228, - SPELL_CURSEOFTONGUES = 15470, - SPELL_CURSEOFWEAKNESS = 17227, - SPELL_DEMONARMOR = 11735, - SPELL_ENVELOPINGWEB = 15471 + SPELL_SHADOWBOLT = 17228, + SPELL_CURSEOFTONGUES = 15470, + SPELL_CURSEOFWEAKNESS = 17227, + SPELL_DEMONARMOR = 11735, + SPELL_ENVELOPINGWEB = 15471 }; -class boss_anubshiah : public CreatureScript +enum Events { -public: - boss_anubshiah() : CreatureScript("boss_anubshiah") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return new boss_anubshiahAI(creature); - } - - struct boss_anubshiahAI : public ScriptedAI - { - boss_anubshiahAI(Creature* creature) : ScriptedAI(creature) { } - - uint32 ShadowBolt_Timer; - uint32 CurseOfTongues_Timer; - uint32 CurseOfWeakness_Timer; - uint32 DemonArmor_Timer; - uint32 EnvelopingWeb_Timer; - - void Reset() override - { - ShadowBolt_Timer = 7000; - CurseOfTongues_Timer = 24000; - CurseOfWeakness_Timer = 12000; - DemonArmor_Timer = 3000; - EnvelopingWeb_Timer = 16000; - } + EVENT_SHADOWBOLT = 1, + EVENT_CURSE_OF_TONGUES = 2, + EVENT_CURSE_OF_WEAKNESS = 3, + EVENT_DEMON_ARMOR = 4, + EVENT_ENVELOPING_WEB = 5 +}; - void EnterCombat(Unit* /*who*/) override { } +class boss_anubshiah : public CreatureScript +{ + public: + boss_anubshiah() : CreatureScript("boss_anubshiah") { } - void UpdateAI(uint32 diff) override + struct boss_anubshiahAI : public ScriptedAI { - //Return since we have no target - if (!UpdateVictim()) - return; - - //ShadowBolt_Timer - if (ShadowBolt_Timer <= diff) - { - DoCastVictim(SPELL_SHADOWBOLT); - ShadowBolt_Timer = 7000; - } else ShadowBolt_Timer -= diff; - - //CurseOfTongues_Timer - if (CurseOfTongues_Timer <= diff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - DoCast(target, SPELL_CURSEOFTONGUES); - CurseOfTongues_Timer = 18000; - } else CurseOfTongues_Timer -= diff; + boss_anubshiahAI(Creature* creature) : ScriptedAI(creature) { } - //CurseOfWeakness_Timer - if (CurseOfWeakness_Timer <= diff) + void Reset() override { - DoCastVictim(SPELL_CURSEOFWEAKNESS); - CurseOfWeakness_Timer = 45000; - } else CurseOfWeakness_Timer -= diff; + _events.Reset(); + } - //DemonArmor_Timer - if (DemonArmor_Timer <= diff) + void EnterCombat(Unit* /*who*/) override { - DoCast(me, SPELL_DEMONARMOR); - DemonArmor_Timer = 300000; - } else DemonArmor_Timer -= diff; - - //EnvelopingWeb_Timer - if (EnvelopingWeb_Timer <= diff) + _events.ScheduleEvent(EVENT_SHADOWBOLT, 7000); + _events.ScheduleEvent(EVENT_CURSE_OF_TONGUES, 24000); + _events.ScheduleEvent(EVENT_CURSE_OF_WEAKNESS, 12000); + _events.ScheduleEvent(EVENT_DEMON_ARMOR, 3000); + _events.ScheduleEvent(EVENT_ENVELOPING_WEB, 16000); + } + + void UpdateAI(uint32 diff) override { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - DoCast(target, SPELL_ENVELOPINGWEB); - EnvelopingWeb_Timer = 12000; - } else EnvelopingWeb_Timer -= diff; - - DoMeleeAttackIfReady(); + if (!UpdateVictim()) + return; + + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_SHADOWBOLT: + DoCast(me, SPELL_SHADOWBOLT); + _events.ScheduleEvent(EVENT_SHADOWBOLT, 7000); + break; + case EVENT_CURSE_OF_TONGUES: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) + DoCast(target, SPELL_CURSEOFTONGUES); + _events.ScheduleEvent(EVENT_CURSE_OF_TONGUES, 18000); + break; + case EVENT_CURSE_OF_WEAKNESS: + DoCastVictim(SPELL_CURSEOFWEAKNESS); + _events.ScheduleEvent(EVENT_CURSE_OF_WEAKNESS, 45000); + break; + case EVENT_DEMON_ARMOR: + DoCast(me, SPELL_DEMONARMOR); + _events.ScheduleEvent(EVENT_DEMON_ARMOR, 300000); + break; + case EVENT_ENVELOPING_WEB: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) + DoCast(target, SPELL_ENVELOPINGWEB); + _events.ScheduleEvent(EVENT_ENVELOPING_WEB, 12000); + break; + default: + break; + } + } + + DoMeleeAttackIfReady(); + } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new boss_anubshiahAI(creature); } - }; }; void AddSC_boss_anubshiah() diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp index fffdf9c7514..cec29bcd4d1 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_emperor_dagran_thaurissan.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -32,89 +31,89 @@ enum Spells SPELL_AVATAROFFLAME = 15636 }; -class boss_emperor_dagran_thaurissan : public CreatureScript +enum Events { -public: - boss_emperor_dagran_thaurissan() : CreatureScript("boss_emperor_dagran_thaurissan") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return GetInstanceAI<boss_draganthaurissanAI>(creature); - } - - struct boss_draganthaurissanAI : public ScriptedAI - { - boss_draganthaurissanAI(Creature* creature) : ScriptedAI(creature) - { - instance = me->GetInstanceScript(); - } - - InstanceScript* instance; - uint32 HandOfThaurissan_Timer; - uint32 AvatarOfFlame_Timer; - //uint32 Counter; + EVENT_HANDOFTHAURISSAN = 1, + EVENT_AVATAROFFLAME = 2 +}; - void Reset() override - { - HandOfThaurissan_Timer = 4000; - AvatarOfFlame_Timer = 25000; - //Counter= 0; - } +class boss_emperor_dagran_thaurissan : public CreatureScript +{ + public: + boss_emperor_dagran_thaurissan() : CreatureScript("boss_emperor_dagran_thaurissan") { } - void EnterCombat(Unit* /*who*/) override + struct boss_draganthaurissanAI : public ScriptedAI { - Talk(SAY_AGGRO); - me->CallForHelp(VISIBLE_RANGE); - } + boss_draganthaurissanAI(Creature* creature) : ScriptedAI(creature) + { + _instance = me->GetInstanceScript(); + } - void KilledUnit(Unit* /*victim*/) override - { - Talk(SAY_SLAY); - } + void Reset() override + { + _events.Reset(); + } - void JustDied(Unit* /*killer*/) override - { - if (Creature* Moira = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_MOIRA))) + void EnterCombat(Unit* /*who*/) override { - Moira->AI()->EnterEvadeMode(); - Moira->setFaction(35); + Talk(SAY_AGGRO); + me->CallForHelp(VISIBLE_RANGE); + _events.ScheduleEvent(EVENT_HANDOFTHAURISSAN, 4000); + _events.ScheduleEvent(EVENT_AVATAROFFLAME, 25000); } - } - void UpdateAI(uint32 diff) override - { - //Return since we have no target - if (!UpdateVictim()) - return; + void KilledUnit(Unit* who) override + { + if (who->GetTypeId() == TYPEID_PLAYER) + Talk(SAY_SLAY); + } - if (HandOfThaurissan_Timer <= diff) + void JustDied(Unit* /*killer*/) override { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) - DoCast(target, SPELL_HANDOFTHAURISSAN); - - //3 Hands of Thaurissan will be cast - //if (Counter < 3) - //{ - // HandOfThaurissan_Timer = 1000; - // ++Counter; - //} - //else - //{ - HandOfThaurissan_Timer = 5000; - //Counter = 0; - //} - } else HandOfThaurissan_Timer -= diff; - - //AvatarOfFlame_Timer - if (AvatarOfFlame_Timer <= diff) + if (Creature* moira = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_MOIRA))) + { + moira->AI()->EnterEvadeMode(); + moira->setFaction(35); + } + } + + void UpdateAI(uint32 diff) override { - DoCastVictim(SPELL_AVATAROFFLAME); - AvatarOfFlame_Timer = 18000; - } else AvatarOfFlame_Timer -= diff; + if (!UpdateVictim()) + return; + + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_HANDOFTHAURISSAN: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) + DoCast(target, SPELL_HANDOFTHAURISSAN); + _events.ScheduleEvent(EVENT_HANDOFTHAURISSAN, 5000); + break; + case EVENT_AVATAROFFLAME: + DoCastVictim(SPELL_AVATAROFFLAME); + _events.ScheduleEvent(EVENT_AVATAROFFLAME, 18000); + break; + default: + break; + } + } + + DoMeleeAttackIfReady(); + } + + private: + InstanceScript* _instance; + EventMap _events; + }; - DoMeleeAttackIfReady(); + CreatureAI* GetAI(Creature* creature) const override + { + return GetInstanceAI<boss_draganthaurissanAI>(creature); } - }; }; void AddSC_boss_draganthaurissan() diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_general_angerforge.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_general_angerforge.cpp index 34ce2276a54..d5b8d1deadd 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_general_angerforge.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_general_angerforge.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -26,101 +25,113 @@ enum Spells SPELL_CLEAVE = 20691 }; -class boss_general_angerforge : public CreatureScript +enum Events { -public: - boss_general_angerforge() : CreatureScript("boss_general_angerforge") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return new boss_general_angerforgeAI(creature); - } - - struct boss_general_angerforgeAI : public ScriptedAI - { - boss_general_angerforgeAI(Creature* creature) : ScriptedAI(creature) { } - - uint32 MightyBlow_Timer; - uint32 HamString_Timer; - uint32 Cleave_Timer; - uint32 Adds_Timer; - bool Medics; - - void Reset() override - { - MightyBlow_Timer = 8000; - HamString_Timer = 12000; - Cleave_Timer = 16000; - Adds_Timer = 0; - Medics = false; - } - - void EnterCombat(Unit* /*who*/) override { } + EVENT_MIGHTYBLOW = 1, + EVENT_HAMSTRING = 2, + EVENT_CLEAVE = 3, + EVENT_MEDIC = 4, + EVENT_ADDS = 5 +}; - void SummonAdds(Unit* victim) - { - if (Creature* SummonedAdd = DoSpawnCreature(8901, float(irand(-14, 14)), float(irand(-14, 14)), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000)) - SummonedAdd->AI()->AttackStart(victim); - } +enum Phases +{ + PHASE_ONE = 1, + PHASE_TWO = 2 +}; - void SummonMedics(Unit* victim) - { - if (Creature* SummonedMedic = DoSpawnCreature(8894, float(irand(-9, 9)), float(irand(-9, 9)), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000)) - SummonedMedic->AI()->AttackStart(victim); - } +class boss_general_angerforge : public CreatureScript +{ + public: + boss_general_angerforge() : CreatureScript("boss_general_angerforge") { } - void UpdateAI(uint32 diff) override + struct boss_general_angerforgeAI : public ScriptedAI { - //Return since we have no target - if (!UpdateVictim()) - return; + boss_general_angerforgeAI(Creature* creature) : ScriptedAI(creature) { } - //MightyBlow_Timer - if (MightyBlow_Timer <= diff) + void Reset() override { - DoCastVictim(SPELL_MIGHTYBLOW); - MightyBlow_Timer = 18000; - } else MightyBlow_Timer -= diff; + _events.Reset(); + } - //HamString_Timer - if (HamString_Timer <= diff) + void EnterCombat(Unit* /*who*/) override { - DoCastVictim(SPELL_HAMSTRING); - HamString_Timer = 15000; - } else HamString_Timer -= diff; + _events.SetPhase(PHASE_ONE); + _events.ScheduleEvent(EVENT_MIGHTYBLOW, 8000); + _events.ScheduleEvent(EVENT_HAMSTRING, 12000); + _events.ScheduleEvent(EVENT_CLEAVE, 16000); + } - //Cleave_Timer - if (Cleave_Timer <= diff) + void DamageTaken(Unit* /*attacker*/, uint32& damage) override { - DoCastVictim(SPELL_CLEAVE); - Cleave_Timer = 9000; - } else Cleave_Timer -= diff; + if (me->HealthBelowPctDamaged(20, damage) && _events.IsInPhase(PHASE_ONE)) + { + _events.SetPhase(PHASE_TWO); + _events.ScheduleEvent(EVENT_MEDIC, 0, 0, PHASE_TWO); + _events.ScheduleEvent(EVENT_ADDS, 0, 0, PHASE_TWO); + } + } - //Adds_Timer - if (HealthBelowPct(21)) + void SummonAdd(Unit* victim) { - if (Adds_Timer <= diff) - { - // summon 3 Adds every 25s - SummonAdds(me->GetVictim()); - SummonAdds(me->GetVictim()); - SummonAdds(me->GetVictim()); + if (Creature* SummonedAdd = DoSpawnCreature(8901, float(irand(-14, 14)), float(irand(-14, 14)), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000)) + SummonedAdd->AI()->AttackStart(victim); + } - Adds_Timer = 25000; - } else Adds_Timer -= diff; + void SummonMedic(Unit* victim) + { + if (Creature* SummonedMedic = DoSpawnCreature(8894, float(irand(-9, 9)), float(irand(-9, 9)), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000)) + SummonedMedic->AI()->AttackStart(victim); } - //Summon Medics - if (!Medics && HealthBelowPct(21)) + void UpdateAI(uint32 diff) override { - SummonMedics(me->GetVictim()); - SummonMedics(me->GetVictim()); - Medics = true; + if (!UpdateVictim()) + return; + + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_MIGHTYBLOW: + DoCastVictim(SPELL_MIGHTYBLOW); + _events.ScheduleEvent(EVENT_MIGHTYBLOW, 18000); + break; + case EVENT_HAMSTRING: + DoCastVictim(SPELL_HAMSTRING); + _events.ScheduleEvent(EVENT_HAMSTRING, 15000); + break; + case EVENT_CLEAVE: + DoCastVictim(SPELL_CLEAVE); + _events.ScheduleEvent(EVENT_CLEAVE, 9000); + break; + case EVENT_MEDIC: + for (uint8 i = 0; i < 2; ++i) + SummonMedic(me->GetVictim()); + break; + case EVENT_ADDS: + for (uint8 i = 0; i < 3; ++i) + SummonAdd(me->GetVictim()); + _events.ScheduleEvent(EVENT_ADDS, 25000, 0, PHASE_TWO); + break; + default: + break; + } + } + + DoMeleeAttackIfReady(); } - DoMeleeAttackIfReady(); + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new boss_general_angerforgeAI(creature); } - }; }; void AddSC_boss_general_angerforge() diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_gorosh_the_dervish.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_gorosh_the_dervish.cpp index b5998576f24..e9034e17d83 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_gorosh_the_dervish.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_gorosh_the_dervish.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -25,56 +24,67 @@ enum Spells SPELL_MORTALSTRIKE = 24573 }; +enum Events +{ + EVENT_WHIRLWIND = 1, + EVENT_MORTALSTRIKE = 2 +}; + class boss_gorosh_the_dervish : public CreatureScript { -public: - boss_gorosh_the_dervish() : CreatureScript("boss_gorosh_the_dervish") { } + public: + boss_gorosh_the_dervish() : CreatureScript("boss_gorosh_the_dervish") { } - CreatureAI* GetAI(Creature* creature) const override - { - return new boss_gorosh_the_dervishAI(creature); - } + struct boss_gorosh_the_dervishAI : public ScriptedAI + { + boss_gorosh_the_dervishAI(Creature* creature) : ScriptedAI(creature) { } - struct boss_gorosh_the_dervishAI : public ScriptedAI - { - boss_gorosh_the_dervishAI(Creature* creature) : ScriptedAI(creature) { } + void Reset() override + { + _events.Reset(); + } - uint32 WhirlWind_Timer; - uint32 MortalStrike_Timer; + void EnterCombat(Unit* /*who*/) override + { + _events.ScheduleEvent(EVENT_WHIRLWIND, 12000); + _events.ScheduleEvent(EVENT_MORTALSTRIKE, 22000); + } - void Reset() override - { - WhirlWind_Timer = 12000; - MortalStrike_Timer = 22000; - } + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - void EnterCombat(Unit* /*who*/) override - { - } + _events.Update(diff); - void UpdateAI(uint32 diff) override - { - //Return since we have no target - if (!UpdateVictim()) - return; + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_WHIRLWIND: + DoCast(me, SPELL_WHIRLWIND); + _events.ScheduleEvent(EVENT_WHIRLWIND, 15000); + break; + case EVENT_MORTALSTRIKE: + DoCastVictim(SPELL_MORTALSTRIKE); + _events.ScheduleEvent(EVENT_MORTALSTRIKE, 15000); + break; + default: + break; + } + } - //WhirlWind_Timer - if (WhirlWind_Timer <= diff) - { - DoCast(me, SPELL_WHIRLWIND); - WhirlWind_Timer = 15000; - } else WhirlWind_Timer -= diff; + DoMeleeAttackIfReady(); + } - //MortalStrike_Timer - if (MortalStrike_Timer <= diff) - { - DoCastVictim(SPELL_MORTALSTRIKE); - MortalStrike_Timer = 15000; - } else MortalStrike_Timer -= diff; + private: + EventMap _events; + }; - DoMeleeAttackIfReady(); + CreatureAI* GetAI(Creature* creature) const override + { + return new boss_gorosh_the_dervishAI(creature); } - }; }; void AddSC_boss_gorosh_the_dervish() diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_grizzle.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_grizzle.cpp index c4277c2447e..f53fd0f65b3 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_grizzle.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_grizzle.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -26,59 +25,83 @@ enum Grizzle EMOTE_FRENZY_KILL = 0 }; -class boss_grizzle : public CreatureScript +enum Events { -public: - boss_grizzle() : CreatureScript("boss_grizzle") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return new boss_grizzleAI(creature); - } + EVENT_GROUNDTREMOR = 1, + EVENT_FRENZY = 2 +}; - struct boss_grizzleAI : public ScriptedAI - { - boss_grizzleAI(Creature* creature) : ScriptedAI(creature) { } +enum Phases +{ + PHASE_ONE = 1, + PHASE_TWO = 2 +}; - uint32 GroundTremor_Timer; - uint32 Frenzy_Timer; +class boss_grizzle : public CreatureScript +{ + public: + boss_grizzle() : CreatureScript("boss_grizzle") { } - void Reset() override + struct boss_grizzleAI : public ScriptedAI { - GroundTremor_Timer = 12000; - Frenzy_Timer =0; - } + boss_grizzleAI(Creature* creature) : ScriptedAI(creature) { } - void EnterCombat(Unit* /*who*/) override { } + void Reset() override + { + _events.Reset(); + } - void UpdateAI(uint32 diff) override - { - //Return since we have no target - if (!UpdateVictim()) - return; + void EnterCombat(Unit* /*who*/) override + { + _events.SetPhase(PHASE_ONE); + _events.ScheduleEvent(EVENT_GROUNDTREMOR, 12000); + } - //GroundTremor_Timer - if (GroundTremor_Timer <= diff) + void DamageTaken(Unit* /*attacker*/, uint32& damage) override { - DoCastVictim(SPELL_GROUNDTREMOR); - GroundTremor_Timer = 8000; - } else GroundTremor_Timer -= diff; + if (me->HealthBelowPctDamaged(50, damage) && _events.IsInPhase(PHASE_ONE)) + { + _events.SetPhase(PHASE_TWO); + _events.ScheduleEvent(EVENT_FRENZY, 0, 0, PHASE_TWO); + } + } - //Frenzy_Timer - if (HealthBelowPct(51)) + void UpdateAI(uint32 diff) override { - if (Frenzy_Timer <= diff) + if (!UpdateVictim()) + return; + + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) { - DoCast(me, SPELL_FRENZY); - Talk(EMOTE_FRENZY_KILL); + switch (eventId) + { + case EVENT_GROUNDTREMOR: + DoCastVictim(SPELL_GROUNDTREMOR); + _events.ScheduleEvent(EVENT_GROUNDTREMOR, 8000); + break; + case EVENT_FRENZY: + DoCast(me, SPELL_FRENZY); + Talk(EMOTE_FRENZY_KILL); + _events.ScheduleEvent(EVENT_FRENZY, 15000, 0, PHASE_TWO); + break; + default: + break; + } + } - Frenzy_Timer = 15000; - } else Frenzy_Timer -= diff; + DoMeleeAttackIfReady(); } - DoMeleeAttackIfReady(); + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new boss_grizzleAI(creature); } - }; }; void AddSC_boss_grizzle() diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_high_interrogator_gerstahn.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_high_interrogator_gerstahn.cpp index 6aa89aa491d..c41ddf9d98b 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_high_interrogator_gerstahn.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_high_interrogator_gerstahn.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -27,74 +26,81 @@ enum Spells SPELL_SHADOWSHIELD = 22417 }; -class boss_high_interrogator_gerstahn : public CreatureScript +enum Events { -public: - boss_high_interrogator_gerstahn() : CreatureScript("boss_high_interrogator_gerstahn") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return new boss_high_interrogator_gerstahnAI(creature); - } - - struct boss_high_interrogator_gerstahnAI : public ScriptedAI - { - boss_high_interrogator_gerstahnAI(Creature* creature) : ScriptedAI(creature) { } - - uint32 ShadowWordPain_Timer; - uint32 ManaBurn_Timer; - uint32 PsychicScream_Timer; - uint32 ShadowShield_Timer; - - void Reset() override - { - ShadowWordPain_Timer = 4000; - ManaBurn_Timer = 14000; - PsychicScream_Timer = 32000; - ShadowShield_Timer = 8000; - } + EVENT_SHADOW_WORD_PAIN = 1, + EVENT_MANABURN = 2, + EVENT_PSYCHIC_SCREAM = 3, + EVENT_SHADOWSHIELD = 4 +}; - void EnterCombat(Unit* /*who*/) override { } +class boss_high_interrogator_gerstahn : public CreatureScript +{ + public: + boss_high_interrogator_gerstahn() : CreatureScript("boss_high_interrogator_gerstahn") { } - void UpdateAI(uint32 diff) override + struct boss_high_interrogator_gerstahnAI : public ScriptedAI { - //Return since we have no target - if (!UpdateVictim()) - return; + boss_high_interrogator_gerstahnAI(Creature* creature) : ScriptedAI(creature) { } - //ShadowWordPain_Timer - if (ShadowWordPain_Timer <= diff) + void Reset() override { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - DoCast(target, SPELL_SHADOWWORDPAIN); - ShadowWordPain_Timer = 7000; - } else ShadowWordPain_Timer -= diff; + _events.Reset(); + } - //ManaBurn_Timer - if (ManaBurn_Timer <= diff) + void EnterCombat(Unit* /*who*/) override { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - DoCast(target, SPELL_MANABURN); - ManaBurn_Timer = 10000; - } else ManaBurn_Timer -= diff; + _events.ScheduleEvent(EVENT_SHADOW_WORD_PAIN, 4000); + _events.ScheduleEvent(EVENT_MANABURN, 14000); + _events.ScheduleEvent(EVENT_PSYCHIC_SCREAM, 32000); + _events.ScheduleEvent(EVENT_SHADOWSHIELD, 8000); + } - //PsychicScream_Timer - if (PsychicScream_Timer <= diff) + void UpdateAI(uint32 diff) override { - DoCastVictim(SPELL_PSYCHICSCREAM); - PsychicScream_Timer = 30000; - } else PsychicScream_Timer -= diff; + if (!UpdateVictim()) + return; - //ShadowShield_Timer - if (ShadowShield_Timer <= diff) - { - DoCast(me, SPELL_SHADOWSHIELD); - ShadowShield_Timer = 25000; - } else ShadowShield_Timer -= diff; + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_SHADOW_WORD_PAIN: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true)) + DoCast(target, SPELL_SHADOWWORDPAIN); + _events.ScheduleEvent(EVENT_SHADOW_WORD_PAIN, 7000); + break; + case EVENT_PSYCHIC_SCREAM: + DoCastVictim(SPELL_PSYCHICSCREAM); + _events.ScheduleEvent(EVENT_PSYCHIC_SCREAM, 30000); + break; + case EVENT_MANABURN: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true)) + DoCast(target, SPELL_MANABURN); + _events.ScheduleEvent(EVENT_MANABURN, 10000); + break; + case EVENT_SHADOWSHIELD: + DoCast(me, SPELL_SHADOWSHIELD); + _events.ScheduleEvent(EVENT_SHADOWSHIELD, 25000); + break; + default: + break; + } + } - DoMeleeAttackIfReady(); + DoMeleeAttackIfReady(); + } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new boss_high_interrogator_gerstahnAI(creature); } - }; }; void AddSC_boss_high_interrogator_gerstahn() diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_magmus.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_magmus.cpp index 4cf968ad3b7..e6bbbaa73a9 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_magmus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_magmus.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -18,75 +17,96 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "blackrock_depths.h" enum Spells { - SPELL_FIERYBURST = 13900, - SPELL_WARSTOMP = 24375 + SPELL_FIERYBURST = 13900, + SPELL_WARSTOMP = 24375 }; -enum Misc +enum Events { - DATA_THRONE_DOOR = 24 // not id or guid of doors but number of enum in blackrock_depths.h + EVENT_FIERY_BURST = 1, + EVENT_WARSTOMP = 2 }; -class boss_magmus : public CreatureScript +enum Phases { -public: - boss_magmus() : CreatureScript("boss_magmus") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return new boss_magmusAI(creature); - } - - struct boss_magmusAI : public ScriptedAI - { - boss_magmusAI(Creature* creature) : ScriptedAI(creature) { } + PHASE_ONE = 1, + PHASE_TWO = 2 +}; - uint32 FieryBurst_Timer; - uint32 WarStomp_Timer; +class boss_magmus : public CreatureScript +{ + public: + boss_magmus() : CreatureScript("boss_magmus") { } - void Reset() override + struct boss_magmusAI : public ScriptedAI { - FieryBurst_Timer = 5000; - WarStomp_Timer =0; - } + boss_magmusAI(Creature* creature) : ScriptedAI(creature) { } - void EnterCombat(Unit* /*who*/) override { } + void Reset() override + { + _events.Reset(); + } - void UpdateAI(uint32 diff) override - { - //Return since we have no target - if (!UpdateVictim()) - return; + void EnterCombat(Unit* /*who*/) override + { + _events.SetPhase(PHASE_ONE); + _events.ScheduleEvent(EVENT_FIERY_BURST, 5000); + } - //FieryBurst_Timer - if (FieryBurst_Timer <= diff) + void DamageTaken(Unit* /*attacker*/, uint32& damage) override { - DoCastVictim(SPELL_FIERYBURST); - FieryBurst_Timer = 6000; - } else FieryBurst_Timer -= diff; + if (me->HealthBelowPctDamaged(50, damage) && _events.IsInPhase(PHASE_ONE)) + { + _events.SetPhase(PHASE_TWO); + _events.ScheduleEvent(EVENT_WARSTOMP, 0, 0, PHASE_TWO); + } + } - //WarStomp_Timer - if (HealthBelowPct(51)) + void UpdateAI(uint32 diff) override { - if (WarStomp_Timer <= diff) + if (!UpdateVictim()) + return; + + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) { - DoCastVictim(SPELL_WARSTOMP); - WarStomp_Timer = 8000; - } else WarStomp_Timer -= diff; + switch (eventId) + { + case EVENT_FIERY_BURST: + DoCastVictim(SPELL_FIERYBURST); + _events.ScheduleEvent(EVENT_FIERY_BURST, 6000); + break; + case EVENT_WARSTOMP: + DoCastVictim(SPELL_WARSTOMP); + _events.ScheduleEvent(EVENT_WARSTOMP, 8000, 0, PHASE_TWO); + break; + default: + break; + } + } + + DoMeleeAttackIfReady(); } - DoMeleeAttackIfReady(); - } - // When he die open door to last chamber - void JustDied(Unit* killer) override + void JustDied(Unit* /*killer*/) override + { + if (InstanceScript* instance = me->GetInstanceScript()) + instance->HandleGameObject(instance->GetData64(DATA_THRONE_DOOR), true); + } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override { - if (InstanceScript* instance = killer->GetInstanceScript()) - instance->HandleGameObject(instance->GetData64(DATA_THRONE_DOOR), true); + return new boss_magmusAI(creature); } - }; }; void AddSC_boss_magmus() diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_moira_bronzebeard.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_moira_bronzebeard.cpp index 98f5f75ae3f..8342bef682b 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_moira_bronzebeard.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_moira_bronzebeard.cpp @@ -1,6 +1,5 @@ /* * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> * * 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 @@ -29,63 +28,73 @@ enum Spells SPELL_SMITE = 10934 }; -class boss_moira_bronzebeard : public CreatureScript +enum Events { -public: - boss_moira_bronzebeard() : CreatureScript("boss_moira_bronzebeard") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return new boss_moira_bronzebeardAI(creature); - } - - struct boss_moira_bronzebeardAI : public ScriptedAI - { - boss_moira_bronzebeardAI(Creature* creature) : ScriptedAI(creature) { } - - uint32 Heal_Timer; - uint32 MindBlast_Timer; - uint32 ShadowWordPain_Timer; - uint32 Smite_Timer; - - void Reset() override - { - Heal_Timer = 12000; //These times are probably wrong - MindBlast_Timer = 16000; - ShadowWordPain_Timer = 2000; - Smite_Timer = 8000; - } + EVENT_MINDBLAST = 1, + EVENT_SHADOW_WORD_PAIN = 2, + EVENT_SMITE = 3, + EVENT_HEAL = 4 // not used atm +}; - void EnterCombat(Unit* /*who*/) override { } +class boss_moira_bronzebeard : public CreatureScript +{ + public: + boss_moira_bronzebeard() : CreatureScript("boss_moira_bronzebeard") { } - void UpdateAI(uint32 diff) override + struct boss_moira_bronzebeardAI : public ScriptedAI { - //Return since we have no target - if (!UpdateVictim()) - return; + boss_moira_bronzebeardAI(Creature* creature) : ScriptedAI(creature) { } - //MindBlast_Timer - if (MindBlast_Timer <= diff) + void Reset() override { - DoCastVictim(SPELL_MINDBLAST); - MindBlast_Timer = 14000; - } else MindBlast_Timer -= diff; + _events.Reset(); + } - //ShadowWordPain_Timer - if (ShadowWordPain_Timer <= diff) + void EnterCombat(Unit* /*who*/) override { - DoCastVictim(SPELL_SHADOWWORDPAIN); - ShadowWordPain_Timer = 18000; - } else ShadowWordPain_Timer -= diff; + //_events.ScheduleEvent(EVENT_HEAL, 12000); // not used atm // These times are probably wrong + _events.ScheduleEvent(EVENT_MINDBLAST, 16000); + _events.ScheduleEvent(EVENT_SHADOW_WORD_PAIN, 2000); + _events.ScheduleEvent(EVENT_SMITE, 8000); + } - //Smite_Timer - if (Smite_Timer <= diff) + void UpdateAI(uint32 diff) override { - DoCastVictim(SPELL_SMITE); - Smite_Timer = 10000; - } else Smite_Timer -= diff; + if (!UpdateVictim()) + return; + + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_MINDBLAST: + DoCastVictim(SPELL_MINDBLAST); + _events.ScheduleEvent(EVENT_MINDBLAST, 14000); + break; + case EVENT_SHADOW_WORD_PAIN: + DoCastVictim(SPELL_SHADOWWORDPAIN); + _events.ScheduleEvent(EVENT_SHADOW_WORD_PAIN, 18000); + break; + case EVENT_SMITE: + DoCastVictim(SPELL_SMITE); + _events.ScheduleEvent(EVENT_SMITE, 10000); + break; + default: + break; + } + } + } + + private: + EventMap _events; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new boss_moira_bronzebeardAI(creature); } - }; }; void AddSC_boss_moira_bronzebeard() diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp index cbcafa32a89..83464c12230 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp @@ -24,18 +24,24 @@ enum Spells { - SPELL_SMELT_DARK_IRON = 14891, - SPELL_LEARN_SMELT = 14894, + SPELL_SMELT_DARK_IRON = 14891, + SPELL_LEARN_SMELT = 14894, }; enum Quests { - QUEST_SPECTRAL_CHALICE = 4083 + QUEST_SPECTRAL_CHALICE = 4083 }; enum Misc { - DATA_SKILLPOINT_MIN = 230 + DATA_SKILLPOINT_MIN = 230 +}; + +enum Phases +{ + PHASE_ONE = 1, + PHASE_TWO = 2 }; #define GOSSIP_ITEM_TEACH_1 "Teach me the art of smelting dark iron" @@ -99,149 +105,151 @@ enum DoomrelSpells SPELL_SUMMON_VOIDWALKERS = 15092 }; +enum DoomrelEvents +{ + EVENT_SHADOW_BOLT_VOLLEY = 1, + EVENT_IMMOLATE = 2, + EVENT_CURSE_OF_WEAKNESS = 3, + EVENT_DEMONARMOR = 4, + EVENT_SUMMON_VOIDWALKERS = 5 +}; + #define GOSSIP_ITEM_CHALLENGE "Your bondage is at an end, Doom'rel. I challenge you!" #define GOSSIP_SELECT_DOOMREL "[PH] Continue..." class boss_doomrel : public CreatureScript { -public: - boss_doomrel() : CreatureScript("boss_doomrel") { } + public: + boss_doomrel() : CreatureScript("boss_doomrel") { } - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override - { - player->PlayerTalkClass->ClearMenus(); - switch (action) + bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_DOOMREL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(2605, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->CLOSE_GOSSIP_MENU(); - //start event here - creature->setFaction(FACTION_HOSTILE); - creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - creature->AI()->AttackStart(player); - InstanceScript* instance = creature->GetInstanceScript(); - if (instance) - instance->SetData64(DATA_EVENSTARTER, player->GetGUID()); - break; + player->PlayerTalkClass->ClearMenus(); + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT_DOOMREL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(2605, creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->CLOSE_GOSSIP_MENU(); + //start event here + creature->setFaction(FACTION_HOSTILE); + creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); + creature->AI()->AttackStart(player); + InstanceScript* instance = creature->GetInstanceScript(); + if (instance) + instance->SetData64(DATA_EVENSTARTER, player->GetGUID()); + break; + } + return true; } - return true; - } - - bool OnGossipHello(Player* player, Creature* creature) override - { - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_CHALLENGE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(2601, creature->GetGUID()); - return true; - } - - CreatureAI* GetAI(Creature* creature) const override - { - return GetInstanceAI<boss_doomrelAI>(creature); - } - - struct boss_doomrelAI : public ScriptedAI - { - boss_doomrelAI(Creature* creature) : ScriptedAI(creature) + bool OnGossipHello(Player* player, Creature* creature) override { - instance = creature->GetInstanceScript(); - } + player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_CHALLENGE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(2601, creature->GetGUID()); - InstanceScript* instance; - uint32 ShadowVolley_Timer; - uint32 Immolate_Timer; - uint32 CurseOfWeakness_Timer; - uint32 DemonArmor_Timer; - bool Voidwalkers; + return true; + } - void Reset() override + struct boss_doomrelAI : public ScriptedAI { - ShadowVolley_Timer = 10000; - Immolate_Timer = 18000; - CurseOfWeakness_Timer = 5000; - DemonArmor_Timer = 16000; - Voidwalkers = false; + boss_doomrelAI(Creature* creature) : ScriptedAI(creature) + { + _instance = creature->GetInstanceScript(); + } - me->setFaction(FACTION_FRIEND); + void Reset() override + { + _voidwalkers = false; - // was set before event start, so set again - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); + me->setFaction(FACTION_FRIEND); - if (instance->GetData(DATA_GHOSTKILL) >= 7) - me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); - else - me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - } + // was set before event start, so set again + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - void EnterCombat(Unit* /*who*/) override - { - } - - void EnterEvadeMode() override - { - me->RemoveAllAuras(); - me->DeleteThreatList(); - me->CombatStop(true); - me->LoadCreaturesAddon(); - if (me->IsAlive()) - me->GetMotionMaster()->MoveTargetedHome(); - me->SetLootRecipient(NULL); - instance->SetData64(DATA_EVENSTARTER, 0); - } - - void JustDied(Unit* /*killer*/) override - { - instance->SetData(DATA_GHOSTKILL, 1); - } + if (_instance->GetData(DATA_GHOSTKILL) >= 7) + me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); + else + me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void EnterCombat(Unit* /*who*/) override + { + _events.ScheduleEvent(EVENT_SHADOW_BOLT_VOLLEY, 10000); + _events.ScheduleEvent(EVENT_IMMOLATE, 18000); + _events.ScheduleEvent(EVENT_CURSE_OF_WEAKNESS, 5000); + _events.ScheduleEvent(EVENT_DEMONARMOR, 16000); + } - //ShadowVolley_Timer - if (ShadowVolley_Timer <= diff) + void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override { - DoCastVictim(SPELL_SHADOWBOLTVOLLEY); - ShadowVolley_Timer = 12000; - } else ShadowVolley_Timer -= diff; + if (!_voidwalkers && !HealthAbovePct(50)) + { + DoCastVictim(SPELL_SUMMON_VOIDWALKERS, true); + _voidwalkers = true; + } + } - //Immolate_Timer - if (Immolate_Timer <= diff) + void EnterEvadeMode() override { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - DoCast(target, SPELL_IMMOLATE); + ScriptedAI::EnterEvadeMode(); - Immolate_Timer = 25000; - } else Immolate_Timer -= diff; + _instance->SetData64(DATA_EVENSTARTER, 0); + } - //CurseOfWeakness_Timer - if (CurseOfWeakness_Timer <= diff) + void JustDied(Unit* /*killer*/) override { - DoCastVictim(SPELL_CURSEOFWEAKNESS); - CurseOfWeakness_Timer = 45000; - } else CurseOfWeakness_Timer -= diff; + _instance->SetData(DATA_GHOSTKILL, 1); + } - //DemonArmor_Timer - if (DemonArmor_Timer <= diff) + void UpdateAI(uint32 diff) override { - DoCast(me, SPELL_DEMONARMOR); - DemonArmor_Timer = 300000; - } else DemonArmor_Timer -= diff; + if (!UpdateVictim()) + return; - //Summon Voidwalkers - if (!Voidwalkers && HealthBelowPct(51)) - { - DoCastVictim(SPELL_SUMMON_VOIDWALKERS, true); - Voidwalkers = true; + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_SHADOW_BOLT_VOLLEY: + DoCastVictim(SPELL_SHADOWBOLTVOLLEY); + _events.ScheduleEvent(EVENT_SHADOW_BOLT_VOLLEY, 12000); + break; + case EVENT_IMMOLATE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true)) + DoCast(target, SPELL_IMMOLATE); + _events.ScheduleEvent(EVENT_IMMOLATE, 25000); + break; + case EVENT_CURSE_OF_WEAKNESS: + DoCastVictim(SPELL_CURSEOFWEAKNESS); + _events.ScheduleEvent(EVENT_CURSE_OF_WEAKNESS, 45000); + break; + case EVENT_DEMONARMOR: + DoCast(me, SPELL_DEMONARMOR); + _events.ScheduleEvent(EVENT_DEMONARMOR, 300000); + break; + default: + break; + } + } + + DoMeleeAttackIfReady(); } - DoMeleeAttackIfReady(); + private: + InstanceScript* _instance; + EventMap _events; + bool _voidwalkers; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetInstanceAI<boss_doomrelAI>(creature); } - }; }; void AddSC_boss_tomb_of_seven() diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp index ccdd92ae4ba..4303026ba64 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp @@ -1100,7 +1100,7 @@ class npc_jaina_or_sylvanas_escape_hor : public CreatureScript Talk(SAY_JAINA_ESCAPE_9); if (Transport* gunship = ObjectAccessor::GetTransport(*me, _instance->GetData64(DATA_GUNSHIP))) gunship->EnableMovement(true); - _instance->SetBossState(DATA_THE_LICH_KING_ESCAPE, DONE); + _instance->SetBossState(DATA_THE_LICH_KING_ESCAPE, DONE); break; case EVENT_ESCAPE_17: if (_instance->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE) @@ -1139,7 +1139,7 @@ class npc_the_lich_king_escape_hor : public CreatureScript struct npc_the_lich_king_escape_horAI : public ScriptedAI { - npc_the_lich_king_escape_horAI(Creature* creature) : ScriptedAI(creature) + npc_the_lich_king_escape_horAI(Creature* creature) : ScriptedAI(creature) { _instance = me->GetInstanceScript(); _instance->SetBossState(DATA_THE_LICH_KING_ESCAPE, NOT_STARTED); @@ -1248,12 +1248,12 @@ class npc_the_lich_king_escape_hor : public CreatureScript _events.ScheduleEvent(EVENT_ESCAPE_SUMMON_WITCH_DOCTOR, 66000); _events.ScheduleEvent(EVENT_ESCAPE_SUMMON_LUMBERING_ABOMINATION, 14000); Talk(SAY_LK_ESCAPE_ICEWALL_SUMMONED_4); - break; + break; default: break; } } - + void EnterEvadeMode() override { if (_despawn) diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index 116beb3d081..cfcc05a625c 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -1813,7 +1813,6 @@ public: enum ZuluhedChains { - QUEST_ZULUHED = 10866, NPC_KARYNAKU = 22112, }; @@ -1828,9 +1827,9 @@ class spell_unlocking_zuluheds_chains : public SpellScriptLoader void HandleAfterHit() { - if (GetCaster()->GetTypeId() == TYPEID_PLAYER) - if (Creature* karynaku = GetCaster()->FindNearestCreature(NPC_KARYNAKU, 15.0f)) - GetCaster()->ToPlayer()->KilledMonsterCredit(NPC_KARYNAKU, karynaku->GetGUID()); + if (Player* caster = GetCaster()->ToPlayer()) + if (Creature* karynaku = caster->FindNearestCreature(NPC_KARYNAKU, 15.0f)) + caster->KilledMonsterCredit(NPC_KARYNAKU, karynaku->GetGUID()); } void Register() override diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 725312eafce..c3f994135aa 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -202,16 +202,21 @@ class spell_hun_chimera_shot : public SpellScriptLoader flag96 familyFlag = aura->GetSpellInfo()->SpellFamilyFlags; if (!(familyFlag[1] & 0x00000080 || familyFlag[0] & 0x0000C000)) continue; - if (AuraEffect const* aurEff = aura->GetEffect(0)) + if (AuraEffect* aurEff = aura->GetEffect(0)) { // Serpent Sting - Instantly deals 40% of the damage done by your Serpent Sting. if (familyFlag[0] & 0x4000) { int32 TickCount = aurEff->GetTotalTicks(); spellId = SPELL_HUNTER_CHIMERA_SHOT_SERPENT; - basePoint = caster->SpellDamageBonusDone(unitTarget, aura->GetSpellInfo(), aurEff->GetAmount(), DOT, aura->GetStackAmount()); + basePoint = aurEff->GetDamage(); ApplyPct(basePoint, TickCount * 40); basePoint = unitTarget->SpellDamageBonusTaken(caster, aura->GetSpellInfo(), basePoint, DOT, aura->GetStackAmount()); + + // Recalculate bonus damage on roll. + uint32 damage = std::max(aurEff->GetAmount(), 0); + sScriptMgr->ModifyPeriodicDamageAurasTick(unitTarget, caster, damage); + aurEff->SetDamage(caster->SpellDamageBonusDone(unitTarget, aurEff->GetSpellInfo(), damage, DOT) * aurEff->GetDonePct()); } // Viper Sting - Instantly restores mana to you equal to 60% of the total amount drained by your Viper Sting. else if (familyFlag[1] & 0x00000080) diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index dea67b5222d..76781e0fdc2 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -531,10 +531,17 @@ class spell_pri_pain_and_suffering_proc : public SpellScriptLoader void HandleEffectScriptEffect(SpellEffIndex /*effIndex*/) { + Unit* caster = GetCaster(); // Refresh Shadow Word: Pain on target - if (Unit* unitTarget = GetHitUnit()) - if (AuraEffect* aur = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x8000, 0, 0, GetCaster()->GetGUID())) + if (Unit* target = GetHitUnit()) + if (AuraEffect* aur = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x8000, 0, 0, caster->GetGUID())) + { + uint32 damage = std::max(aur->GetAmount(), 0); + sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage); + aur->SetDamage(caster->SpellDamageBonusDone(target, aur->GetSpellInfo(), damage, DOT) * aur->GetDonePct()); + aur->CalculatePeriodic(caster, false, false); aur->GetBase()->RefreshDuration(); + } } void Register() override diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 18979d24ecb..3f935077b22 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -405,10 +405,17 @@ class spell_warl_everlasting_affliction : public SpellScriptLoader void HandleScriptEffect(SpellEffIndex /*effIndex*/) { - if (Unit* unitTarget = GetHitUnit()) + Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) // Refresh corruption on target - if (AuraEffect* aur = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x2, 0, 0, GetCaster()->GetGUID())) - aur->GetBase()->RefreshDuration(); + if (AuraEffect* aur = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x2, 0, 0, caster->GetGUID())) + { + uint32 damage = std::max(aur->GetAmount(), 0); + sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage); + aur->SetDamage(caster->SpellDamageBonusDone(target, aur->GetSpellInfo(), damage, DOT) * aur->GetDonePct()); + aur->CalculatePeriodic(caster, false, false); + aur->GetBase()->RefreshDuration(true); + } } void Register() override diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index fd1c785cf50..40d939c6394 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -36,7 +36,7 @@ enum WarriorSpells SPELL_WARRIOR_DEEP_WOUNDS_RANK_1 = 12162, SPELL_WARRIOR_DEEP_WOUNDS_RANK_2 = 12850, SPELL_WARRIOR_DEEP_WOUNDS_RANK_3 = 12868, - SPELL_WARRIOR_DEEP_WOUNDS_RANK_PERIODIC = 12721, + SPELL_WARRIOR_DEEP_WOUNDS_PERIODIC = 12721, SPELL_WARRIOR_EXECUTE = 20647, SPELL_WARRIOR_GLYPH_OF_EXECUTION = 58367, SPELL_WARRIOR_GLYPH_OF_VIGILANCE = 63326, @@ -268,23 +268,18 @@ class spell_warr_deep_wounds : public SpellScriptLoader Unit* caster = GetCaster(); if (Unit* target = GetHitUnit()) { - // apply percent damage mods - damage = caster->SpellDamageBonusDone(target, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE); - ApplyPct(damage, 16 * GetSpellInfo()->GetRank()); - damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE); - - SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(SPELL_WARRIOR_DEEP_WOUNDS_RANK_PERIODIC); + SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(SPELL_WARRIOR_DEEP_WOUNDS_PERIODIC); uint32 ticks = spellInfo->GetDuration() / spellInfo->Effects[EFFECT_0].Amplitude; // Add remaining ticks to damage done - if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_WARRIOR_DEEP_WOUNDS_RANK_PERIODIC, EFFECT_0, caster->GetGUID())) - damage += aurEff->GetAmount() * (ticks - aurEff->GetTickNumber()); + if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_WARRIOR_DEEP_WOUNDS_PERIODIC, EFFECT_0, caster->GetGUID())) + damage += aurEff->GetDamage() * (ticks - aurEff->GetTickNumber()); damage /= ticks; - caster->CastCustomSpell(target, SPELL_WARRIOR_DEEP_WOUNDS_RANK_PERIODIC, &damage, NULL, NULL, true); + caster->CastCustomSpell(target, SPELL_WARRIOR_DEEP_WOUNDS_PERIODIC, &damage, NULL, NULL, true); } } diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h index 3665a388854..9c56c75bf71 100644 --- a/src/server/shared/Database/DatabaseWorkerPool.h +++ b/src/server/shared/Database/DatabaseWorkerPool.h @@ -99,7 +99,7 @@ class DatabaseWorkerPool (_connectionCount[IDX_SYNCH] + _connectionCount[IDX_ASYNC])); else TC_LOG_ERROR("sql.driver", "DatabasePool %s NOT opened. There were errors opening the MySQL connections. Check your SQLDriverLogFile " - "for specific errors.", GetDatabaseName()); + "for specific errors. Read wiki at http://collab.kpsn.org/display/tc/TrinityCore+Home", GetDatabaseName()); return res; } diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp index 3b6bd3d2cc8..81825c9055b 100644 --- a/src/server/shared/Debugging/WheatyExceptionReport.cpp +++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp @@ -45,7 +45,7 @@ inline LPTSTR ErrorMessage(DWORD dw) sprintf(msgBuf, "Unknown error: %u", dw); return msgBuf; } - + } //============================== Global Variables ============================= diff --git a/src/server/shared/Debugging/WheatyExceptionReport.h b/src/server/shared/Debugging/WheatyExceptionReport.h index f6d6b7f4b9e..e1cc3050929 100644 --- a/src/server/shared/Debugging/WheatyExceptionReport.h +++ b/src/server/shared/Debugging/WheatyExceptionReport.h @@ -83,7 +83,7 @@ struct SymbolPair bool operator<(const SymbolPair& other) const { - return _offset < other._offset || + return _offset < other._offset || (_offset == other._offset && _type < other._type); } diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 9f766a72d19..11e835566e9 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -382,18 +382,18 @@ class ByteBuffer return *this; } - uint8 * contents() - { + uint8 * contents() + { if (_storage.empty()) throw ByteBufferException(); - return &_storage[0]; + return &_storage[0]; } - const uint8 *contents() const - { + const uint8 *contents() const + { if (_storage.empty()) throw ByteBufferException(); - return &_storage[0]; + return &_storage[0]; } size_t size() const { return _storage.size(); } diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp index c5424374f5a..6e4214603cb 100644 --- a/src/server/worldserver/Master.cpp +++ b/src/server/worldserver/Master.cpp @@ -201,24 +201,24 @@ int Master::Run() ACE_Based::Thread rarThread(new RARunnable); #if defined(_WIN32) || defined(__linux__) - + ///- Handle affinity for multiple processors and process priority uint32 affinity = sConfigMgr->GetIntDefault("UseProcessors", 0); bool highPriority = sConfigMgr->GetBoolDefault("ProcessPriority", false); #ifdef _WIN32 // Windows - + HANDLE hProcess = GetCurrentProcess(); - + if (affinity > 0) { ULONG_PTR appAff; ULONG_PTR sysAff; - + if (GetProcessAffinityMask(hProcess, &appAff, &sysAff)) { ULONG_PTR currentAffinity = affinity & appAff; // remove non accessible processors - + if (!currentAffinity) TC_LOG_ERROR("server.worldserver", "Processors marked in UseProcessors bitmask (hex) %x are not accessible for the worldserver. Accessible processors bitmask (hex): %x", affinity, appAff); else if (SetProcessAffinityMask(hProcess, currentAffinity)) @@ -227,7 +227,7 @@ int Master::Run() TC_LOG_ERROR("server.worldserver", "Can't set used processors (hex): %x", currentAffinity); } } - + if (highPriority) { if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS)) @@ -235,9 +235,9 @@ int Master::Run() else TC_LOG_ERROR("server.worldserver", "Can't set worldserver process priority class."); } - + #else // Linux - + if (affinity > 0) { cpu_set_t mask; @@ -264,7 +264,7 @@ int Master::Run() else TC_LOG_INFO("server.worldserver", "worldserver process priority class set to %i", getpriority(PRIO_PROCESS, 0)); } - + #endif #endif |