Page 1 of 1

[accepted] BladeBarrier Fix!

PostPosted: Thu Mar 12, 2009 7:00 am
by LifeFlight
While I don't like hardcoding values into scripts, it seemed that the best course of action in this instance was to hardcode the 90% parry rate into the GameLiving.cs code. So I have removed the augmentations to parrychance in the BladeBarrierEffect.cs code, since it is not needed.

I don't know about how y'all feel about comments, but I feel comments make the world of difference and should be used when necessary, so I added comments to my work.

Tested and worked: However, feel free to comment as I enjoy criticism.

EDIT: I don't know if it makes a difference, but it seems the patch's are pasting all weird, so I'm going to upload the files in addition to the code snippets below.

http://lifeflight.utpdr.com/contribute/GameLiving.patch
http://lifeflight.utpdr.com/contribute/ ... fect.patch

For GameLiving.cs
Code: Select all
Index: GameLiving.cs
===================================================================
--- GameLiving.cs (revision 1563)
+++ GameLiving.cs (working copy)
@@ -3244,27 +3244,40 @@
//Also, before this comparison happens, the game looks to see if your opponent is in your forward arc – to determine that arc, make a 120 degree angle, and put yourself at the point.
if (ad.IsMeleeAttack)
{
+ BladeBarrierEffect BladeBarrier = null;
+
double parryChance = 0;
+
if (player != null)
{
- if (IsObjectInFront(ad.Attacker, 120))
+ //BladeBarrier overwrites all parrying, 90% chance to parry any attack, does not consider other bonuses to parry
+ BladeBarrier = (BladeBarrierEffect)player.EffectList.GetOfType(typeof(BladeBarrierEffect));
+ //They still need an active weapon to parry with BladeBarrier
+ if (BladeBarrier != null && (AttackWeapon != null))
+ {
+ parryChance = 0.90;
+ }
+ else if (IsObjectInFront(ad.Attacker, 120))
{
if ((player.HasSpecialization(Specs.Parry) || parry != null) && (AttackWeapon != null))
parryChance = GetModified(eProperty.ParryChance);
}
- else if (player.EffectList.GetOfType(typeof(BladeBarrierEffect)) != null)
- parryChance = GetModified(eProperty.ParryChance);
}
else if (this is GameNPC && IsObjectInFront(ad.Attacker, 120))
parryChance = GetModified(eProperty.ParryChance);

- if (parryChance > 0 && !ad.Target.IsStunned && !ad.Target.IsSitting)
+ //If BladeBarrier is up, do not adjust the parry chance.
+ if (BladeBarrier != null && !ad.Target.IsStunned && !ad.Target.IsSitting)
+ {
+ if (Util.ChanceDouble(parryChance))
+ return eAttackResult.Parried;
+ }
+ else if (parryChance > 0 && !ad.Target.IsStunned && !ad.Target.IsSitting)
{
parryChance *= 0.001;
parryChance += 0.05 * attackerConLevel;
if (parryChance < 0.01) parryChance = 0.01;
if (parryChance > 0.99) parryChance = 0.99;
-
if (m_attackers.Count > 1) parryChance /= m_attackers.Count / 2;
if (Util.ChanceDouble(parryChance))
return eAttackResult.Parried;
@@ -6297,4 +6310,4 @@
m_maxEndurance = 1;
}
}
-}
\ No newline at end of file
+}

And for BladeBarrierEffect.cs: Since the parry chance is hard coded there is no need to augment the players ParryChance.
Code: Select all
Index: BladeBarrierEffect.cs
===================================================================
--- BladeBarrierEffect.cs (revision 1563)
+++ BladeBarrierEffect.cs (working copy)
@@ -26,7 +26,8 @@
{
p.Out.SendSpellEffectAnimation(target, target, 7055, 0, false, 1);
}
- m_owner.BuffBonusCategory4[(int)eProperty.ParryChance] += 90;
+ //Commented out for removal: Parry Chance for BladeBarrier is hardcoded in GameLiving.cs in the CalculateEnemyAttackResult method
+ //m_owner.BuffBonusCategory4[(int)eProperty.ParryChance] += 90;
GameEventMgr.AddHandler(target, GameLivingEvent.AttackFinished, new DOLEventHandler(attackEventHandler));

}
@@ -58,7 +59,8 @@

public override void Stop()
{
- m_owner.BuffBonusCategory4[(int)eProperty.ParryChance] -= 90;
+ //Commented out for removal
+ //m_owner.BuffBonusCategory4[(int)eProperty.ParryChance] -= 90;
base.Stop();
}

Re: BladeBarrier Fix!

PostPosted: Thu Mar 12, 2009 8:13 am
by Graveen
Accepted, soon in SVN, thank you

Re: [accepted] BladeBarrier Fix!

PostPosted: Thu Mar 12, 2009 5:19 pm
by Dunnerholl
in my personal opinion, instead of //Commented out for removal just delete the damn thing :) or in half of a year someone will find it, think why its not removed yet and not dare to remove it :)

Re: [accepted] BladeBarrier Fix!

PostPosted: Thu Mar 12, 2009 6:36 pm
by LifeFlight
Yeah, I agree, But i've noticed that it's been done in the revisions so I figured I would just follow that example.