Skip to content

Commit

Permalink
- Changed: Allow calculation of effectiveness for both mainhand and l…
Browse files Browse the repository at this point in the history
…efthand 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.
  • Loading branch information
tolakram committed Jun 11, 2011
1 parent a65cf2f commit 4143834
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 35 deletions.
74 changes: 42 additions & 32 deletions GameServer/gameobjects/GameLiving.cs
Expand Up @@ -1999,6 +1999,7 @@ protected virtual AttackData MakeAttack(GameObject target, InventoryItem weapon,
return ad;
}


private RegionAction InterruptTimer { get; set; }

/// <summary>
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -2548,11 +2535,6 @@ protected class WeaponOnTargetAction : RegionAction
/// </summary>
protected readonly InventoryItem m_leftWeapon;

/// <summary>
/// The number of swing witch must be done by the left weapon
/// </summary>
protected readonly int m_leftHandSwingCount;

/// <summary>
/// The effectiveness of the attack
/// </summary>
Expand All @@ -2579,13 +2561,12 @@ protected class WeaponOnTargetAction : RegionAction
/// <param name="leftHandSwingCount">the left hand swing count</param>
/// <param name="leftWeapon">the left hand weapon used to attack</param>
/// <param name="target">the target of the attack</param>
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;
Expand All @@ -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
Expand Down Expand Up @@ -2633,30 +2625,30 @@ 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
}
}
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);
}
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -4400,6 +4392,24 @@ public virtual int CalculateLeftHandSwingCount()
return 0;
}

/// <summary>
/// Returns a multiplier used to reduce left hand damage
/// </summary>
/// <returns></returns>
public virtual double CalculateLeftHandEffectiveness(InventoryItem mainWeapon, InventoryItem leftWeapon)
{
return 1.0;
}

/// <summary>
/// Returns a multiplier used to reduce right hand damage
/// </summary>
/// <returns></returns>
public virtual double CalculateMainHandEffectiveness(InventoryItem mainWeapon, InventoryItem leftWeapon)
{
return 1.0;
}

/// <summary>
/// Holds visible active weapon slots
/// </summary>
Expand Down
50 changes: 47 additions & 3 deletions GameServer/gameobjects/GamePlayer.cs
Expand Up @@ -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;
}
Expand Down Expand Up @@ -3287,6 +3287,50 @@ public override int CalculateLeftHandSwingCount()
return 0;
}

/// <summary>
/// Returns a multiplier to adjust left hand damage
/// </summary>
/// <returns></returns>
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;
}

/// <summary>
/// Returns a multiplier to adjust right hand damage
/// </summary>
/// <param name="leftWeapon"></param>
/// <returns></returns>
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;
}


/// <summary>
/// returns the level of a specialization
/// if 0 is returned, the spec is non existent on player
Expand Down Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 4143834

Please sign in to comment.