From 414383409958469d7cae745d55a6f390de41a80c Mon Sep 17 00:00:00 2001 From: tolakram Date: Sat, 11 Jun 2011 15:08:47 +0000 Subject: [PATCH] - Changed: Allow calculation of effectiveness for both mainhand and lefthand weapons. Needed for Left Axe. - Changed: Left Axe effectiveness adjustments are only done when player is wielding a left axe. This will be needed if new left axe equations, which adjust mainhand and lefthand damage independently, are used. - Bugfix: Mauler Fist Wraps is now used to calculate dual wield chance for Maulers. --- GameServer/gameobjects/GameLiving.cs | 74 ++++++++++++++++------------ GameServer/gameobjects/GamePlayer.cs | 50 +++++++++++++++++-- 2 files changed, 89 insertions(+), 35 deletions(-) diff --git a/GameServer/gameobjects/GameLiving.cs b/GameServer/gameobjects/GameLiving.cs index d0ec70f4..af90cf1f 100644 --- a/GameServer/gameobjects/GameLiving.cs +++ b/GameServer/gameobjects/GameLiving.cs @@ -1999,6 +1999,7 @@ protected virtual AttackData MakeAttack(GameObject target, InventoryItem weapon, return ad; } + private RegionAction InterruptTimer { get; set; } /// @@ -2400,20 +2401,6 @@ protected override void OnTick() } interruptDuration = owner.AttackSpeed(attackWeapon); - // calculate LA damage reduction - if (owner is GamePlayer) - { - if (owner.CanUseLefthandedWeapon && leftWeapon != null && leftWeapon.Object_Type != (int)eObjectType.Shield - && attackWeapon != null && (attackWeapon.Item_Type == Slot.RIGHTHAND || attackWeapon.Item_Type == Slot.LEFTHAND)) - { - leftHandSwingCount = owner.CalculateLeftHandSwingCount(); - - int LASpec = ((GamePlayer)owner).GetModifiedSpecLevel(Specs.Left_Axe); - if (LASpec > 0) - effectiveness *= 0.625 + 0.0034 * LASpec; - } - } - // Damage is doubled on sitting players // but only with melee weapons; arrows and magic does normal damage. if (attackTarget is GamePlayer && ((GamePlayer)attackTarget).IsSitting) @@ -2433,7 +2420,7 @@ protected override void OnTick() return; } - new WeaponOnTargetAction(owner, attackTarget, attackWeapon, leftWeapon, leftHandSwingCount, effectiveness, interruptDuration, combatStyle).Start(ticksToTarget); // really start the attack + new WeaponOnTargetAction(owner, attackTarget, attackWeapon, leftWeapon, effectiveness, interruptDuration, combatStyle).Start(ticksToTarget); // really start the attack //Are we inactive? if (owner.ObjectState != eObjectState.Active) @@ -2548,11 +2535,6 @@ protected class WeaponOnTargetAction : RegionAction /// protected readonly InventoryItem m_leftWeapon; - /// - /// The number of swing witch must be done by the left weapon - /// - protected readonly int m_leftHandSwingCount; - /// /// The effectiveness of the attack /// @@ -2579,13 +2561,12 @@ protected class WeaponOnTargetAction : RegionAction /// the left hand swing count /// the left hand weapon used to attack /// the target of the attack - public WeaponOnTargetAction(GameLiving owner, GameObject target, InventoryItem attackWeapon, InventoryItem leftWeapon, int leftHandSwingCount, double effectiveness, int interruptDuration, Style combatStyle) + public WeaponOnTargetAction(GameLiving owner, GameObject target, InventoryItem attackWeapon, InventoryItem leftWeapon, double effectiveness, int interruptDuration, Style combatStyle) : base(owner) { m_target = target; m_attackWeapon = attackWeapon; m_leftWeapon = leftWeapon; - m_leftHandSwingCount = leftHandSwingCount; m_effectiveness = effectiveness; m_interruptDuration = interruptDuration; m_combatStyle = combatStyle; @@ -2598,11 +2579,22 @@ protected override void OnTick() { GameLiving owner = (GameLiving)m_actionSource; Style style = m_combatStyle; - int leftHandSwingCount = m_leftHandSwingCount; + int leftHandSwingCount = 0; AttackData mainHandAD = null; AttackData leftHandAD = null; InventoryItem mainWeapon = m_attackWeapon; InventoryItem leftWeapon = m_leftWeapon; + double leftHandEffectiveness = m_effectiveness; + double mainHandEffectiveness = m_effectiveness; + + mainHandEffectiveness *= owner.CalculateMainHandEffectiveness(mainWeapon, leftWeapon); + leftHandEffectiveness *= owner.CalculateLeftHandEffectiveness(mainWeapon, leftWeapon); + + if (owner.CanUseLefthandedWeapon && leftWeapon != null && leftWeapon.Object_Type != (int)eObjectType.Shield + && mainWeapon != null && (mainWeapon.Item_Type == Slot.RIGHTHAND || mainWeapon.Item_Type == Slot.LEFTHAND)) + { + leftHandSwingCount = owner.CalculateLeftHandSwingCount(); + } // CMH // 1.89 @@ -2633,13 +2625,13 @@ protected override void OnTick() || leftWeapon.Object_Type == (int)eObjectType.Shield) { // no left hand used, all is simple here - mainHandAD = owner.MakeAttack(m_target, mainWeapon, style, m_effectiveness, m_interruptDuration, false); + mainHandAD = owner.MakeAttack(m_target, mainWeapon, style, mainHandEffectiveness, m_interruptDuration, false); leftHandSwingCount = 0; } else if (leftHandSwingCount > 0) { // both hands are used for attack - mainHandAD = owner.MakeAttack(m_target, mainWeapon, style, m_effectiveness, m_interruptDuration, true); + mainHandAD = owner.MakeAttack(m_target, mainWeapon, style, mainHandEffectiveness, m_interruptDuration, true); if (style == null) { mainHandAD.AnimationId = -2; // virtual code for both weapons swing animation @@ -2647,16 +2639,16 @@ protected override void OnTick() } else { - // one of two hands is used for attack if no style + // one of two hands is used for attack if no style, treated as a main hand attack if (style == null && Util.Chance(50)) { mainWeapon = leftWeapon; - mainHandAD = owner.MakeAttack(m_target, mainWeapon, style, m_effectiveness, m_interruptDuration, true); + mainHandAD = owner.MakeAttack(m_target, mainWeapon, style, mainHandEffectiveness, m_interruptDuration, true); mainHandAD.AnimationId = -1; // virtual code for left weapons swing animation } else { - mainHandAD = owner.MakeAttack(m_target, mainWeapon, style, m_effectiveness, m_interruptDuration, true); + mainHandAD = owner.MakeAttack(m_target, mainWeapon, style, mainHandEffectiveness, m_interruptDuration, true); } } @@ -2739,9 +2731,9 @@ protected override void OnTick() // Savage swings - main,left,main,left. if ( i % 2 == 0 ) - leftHandAD = owner.MakeAttack( m_target, leftWeapon, null, m_effectiveness, m_interruptDuration, true ); + leftHandAD = owner.MakeAttack( m_target, leftWeapon, null, leftHandEffectiveness, m_interruptDuration, true ); else - leftHandAD = owner.MakeAttack( m_target, mainWeapon, null, m_effectiveness, m_interruptDuration, true ); + leftHandAD = owner.MakeAttack(m_target, mainWeapon, null, leftHandEffectiveness, m_interruptDuration, true); //Notify the target of our attack (sends damage messages, should be before damage) if (leftHandAD.Target != null) @@ -2805,7 +2797,7 @@ protected override void OnTick() { if (brain.GetAggroAmountForLiving(npc) > 0) { - new WeaponOnTargetAction(owner, npc, mainWeapon, leftWeapon, leftHandSwingCount, 1, owner.AttackSpeed(mainWeapon, leftWeapon), style); + new WeaponOnTargetAction(owner, npc, mainWeapon, leftWeapon, 1.0, owner.AttackSpeed(mainWeapon, leftWeapon), style); hit = true; break; } @@ -2818,7 +2810,7 @@ protected override void OnTick() { if (brain.GetAggroAmountForLiving(player) > 0) { - new WeaponOnTargetAction(owner, player, mainWeapon, leftWeapon, leftHandSwingCount, 1, owner.AttackSpeed(mainWeapon, leftWeapon), style); + new WeaponOnTargetAction(owner, player, mainWeapon, leftWeapon, 1.0, owner.AttackSpeed(mainWeapon, leftWeapon), style); hit = true; break; } @@ -4400,6 +4392,24 @@ public virtual int CalculateLeftHandSwingCount() return 0; } + /// + /// Returns a multiplier used to reduce left hand damage + /// + /// + public virtual double CalculateLeftHandEffectiveness(InventoryItem mainWeapon, InventoryItem leftWeapon) + { + return 1.0; + } + + /// + /// Returns a multiplier used to reduce right hand damage + /// + /// + public virtual double CalculateMainHandEffectiveness(InventoryItem mainWeapon, InventoryItem leftWeapon) + { + return 1.0; + } + /// /// Holds visible active weapon slots /// diff --git a/GameServer/gameobjects/GamePlayer.cs b/GameServer/gameobjects/GamePlayer.cs index 3706d00f..a91c289f 100644 --- a/GameServer/gameobjects/GamePlayer.cs +++ b/GameServer/gameobjects/GamePlayer.cs @@ -3252,9 +3252,9 @@ public override int CalculateLeftHandSwingCount() if (GetBaseSpecLevel(Specs.Left_Axe) > 0) return 1; // always use left axe - // DW/FW chance int specLevel = Math.Max(GetModifiedSpecLevel(Specs.Celtic_Dual), GetModifiedSpecLevel(Specs.Dual_Wield)); - if (specLevel > 0 || GetBaseSpecLevel(Specs.Fist_Wraps) > 0) + specLevel = Math.Max(specLevel, GetModifiedSpecLevel(Specs.Fist_Wraps)); + if (specLevel > 0) { return Util.Chance(25 + (specLevel - 1) * 68 / 100) ? 1 : 0; } @@ -3287,6 +3287,50 @@ public override int CalculateLeftHandSwingCount() return 0; } + /// + /// Returns a multiplier to adjust left hand damage + /// + /// + public override double CalculateLeftHandEffectiveness(InventoryItem mainWeapon, InventoryItem leftWeapon) + { + double effectiveness = 1.0; + + if (CanUseLefthandedWeapon && leftWeapon != null && leftWeapon.Object_Type == (int)eObjectType.LeftAxe && mainWeapon != null && + (mainWeapon.Item_Type == Slot.RIGHTHAND || mainWeapon.Item_Type == Slot.LEFTHAND)) + { + int LASpec = GetModifiedSpecLevel(Specs.Left_Axe); + if (LASpec > 0) + { + effectiveness = 0.625 + 0.0034 * LASpec; + } + } + + return effectiveness; + } + + /// + /// Returns a multiplier to adjust right hand damage + /// + /// + /// + public override double CalculateMainHandEffectiveness(InventoryItem mainWeapon, InventoryItem leftWeapon) + { + double effectiveness = 1.0; + + if (CanUseLefthandedWeapon && leftWeapon != null && leftWeapon.Object_Type == (int)eObjectType.LeftAxe && mainWeapon != null && + (mainWeapon.Item_Type == Slot.RIGHTHAND || mainWeapon.Item_Type == Slot.LEFTHAND)) + { + int LASpec = GetModifiedSpecLevel(Specs.Left_Axe); + if (LASpec > 0) + { + effectiveness = 0.625 + 0.0034 * LASpec; + } + } + + return effectiveness; + } + + /// /// returns the level of a specialization /// if 0 is returned, the spec is non existent on player @@ -6475,7 +6519,7 @@ protected override AttackData MakeAttack(GameObject target, InventoryItem weapon { effectiveness *= 2; } - new WeaponOnTargetAction(this, obj as GameObject, attackWeapon, leftWeapon, CalculateLeftHandSwingCount(), effectiveness, AttackSpeed(attackWeapon), null).Start(1); // really start the attack + new WeaponOnTargetAction(this, obj as GameObject, attackWeapon, leftWeapon, effectiveness, AttackSpeed(attackWeapon), null).Start(1); // really start the attack } } }