S
ste459
Guest
Thanks for your kind reply.
(and your math expression is written way better than mine ;D )
For some reason I can't made this code to work, I entered it and at the beginning and called it with the line: CommonScript.TryCriticalHitAdjusted(_v); but I always get an error from Compiler because commonscript.cs does not contain a definition for TryCriticalHitAdjusted.
My commonscript.cs file looks like that (but I tried to insert the code in different positions with the same result):
Code: [Select]
Sorry if I bother you again, I have no programming experience and maybe I got lost in a trivial problem.
Another question, does this code replaces the "standard" critical hit function? I already tried before to emulate the critical hit function (in a much more basic manner) and I ended with 2 different kind of criticals, one triggered by my function plus the standard *2 one
Thanks again!!
(and your math expression is written way better than mine ;D )
For some reason I can't made this code to work, I entered it and at the beginning and called it with the line: CommonScript.TryCriticalHitAdjusted(_v); but I always get an error from Compiler because commonscript.cs does not contain a definition for TryCriticalHitAdjusted.
My commonscript.cs file looks like that (but I tried to insert the code in different positions with the same result):
Code: [Select]
Code:
using System;using Memoria.Data;namespace Memoria.Scripts.Battle{ public static class CommonScript { public const String InfoMessageColor = "[00FFFF]"; public const String GoodMessageColor = "[00FFFF]"; public const String BadMessageColor = "[FF4040]"; } public abstract class BaseWeaponScript : IBattleScript { private readonly BattleCalculator _v; private readonly CalcAttackBonus _bonus; private readonly Boolean _drain; public static void TryCriticalHitAdjusted(BattleCalculator _v) { Int32 quarterWill = _v.Caster.Data.elem.wpr >> 2; if (quarterWill != 0 && (GameRandom.Next16() % quarterWill) + _v.Caster.Data.critical_rate_deal_bonus + _v.Target.Data.critical_rate_receive_bonus > GameRandom.Next16() % 100) { _v.Target.HpDamage = (Int32)(_v.Target.HpDamage / 4f + Math.Min(15000, _v.Target.HpDamage) / 4f + Math.Min(10000, _v.Target.HpDamage) / 2f); // Do the same for "_v.Target.MpDamage"; apparently you don't use "_v.Context.Attack" in your situation when the critical strike triggers _v.Target.Flags |= CalcFlag.Critical; } } protected BaseWeaponScript(BattleCalculator v, CalcAttackBonus bonus, Boolean drain = false) { _v = v; _bonus = bonus; _drain = drain; } public virtual void Perform() { if (_drain && (!_v.IsCasterNotTarget() || !_v.Target.CanBeAttacked())) return; _v.PhysicalAccuracy(); if (!_v.TryPhysicalHit()) return; if (_bonus != CalcAttackBonus.Level) _v.WeaponPhysicalParams(_bonus); else { Int32 baseDamage = GameRandom.Next16() % (1 + (_v.Caster.Level + _v.Caster.Strength >> 3)); _v.Context.AttackPower = _v.Caster.WeaponPower; _v.Target.SetPhysicalDefense(); if (_v.Caster.Weapon == (RegularItem)256) { _v.Context.AttackPower += 3 * _v.Caster.Level / 4; if (_v.Target.IsPlayer && _v.Target.PlayerIndex == CharacterId.Garnet) _v.Target.Flags |= CalcFlag.HpRecovery; } else { _v.Context.AttackPower += _v.Caster.Level / 2; } _v.Context.Attack = _v.Caster.Strength + baseDamage; } if (_v.Caster.IsUnderAnyStatus(BattleStatus.Mini)) _v.Context.Attack = 1; if (_v.Caster.IsUnderAnyStatus(BattleStatus.Berserk)) ++_v.Context.DamageModifierCount; if (_v.Caster.IsUnderAnyStatus(BattleStatus.Trance)) ++_v.Context.DamageModifierCount; if (_v.Target.IsUnderAnyStatus(BattleStatus.Defend)) --_v.Context.DamageModifierCount; if (_v.Target.IsUnderAnyStatus(BattleStatus.Protect)) --_v.Context.DamageModifierCount; if (_v.Target.IsUnderAnyStatus(BattleStatus.Sleep)) ++_v.Context.DamageModifierCount; if (_v.Target.IsUnderAnyStatus(BattleStatus.Mini)) ++_v.Context.DamageModifierCount; if (_drain) _v.PrepareHpDraining(); CommonScript.TryCriticalHitAdjusted(_v); if (_v.Caster.Weapon == (RegularItem)15) { _v.CalcDamageCommon(); _v.Target.HpDamage = _v.Context.EnsureAttack * _v.Context.EnsurePowerDifference; if (_v.Target.Flags != 0) { Single modifier_factor = 1.0f; Single modifier_bonus = 0.5f; Byte modifier_index = 0; if (_v.Caster.IsUnderAnyStatus(BattleStatus.Trance) && _v.Caster.PlayerIndex == CharacterId.Steiner) modifier_bonus = 1.0f; while (_v.Context.DamageModifierCount > 0) { modifier_factor += modifier_bonus; modifier_index++; if (modifier_index >= 2) { modifier_bonus *= 0.5f; modifier_index = 0; } --_v.Context.DamageModifierCount; } while (_v.Context.DamageModifierCount < 0) { modifier_factor *= 0.5f; ++_v.Context.DamageModifierCount; } if ((_v.Target.Flags & CalcFlag.HpAlteration) != 0) { _v.Target.HpDamage = (Int32)Math.Round(modifier_factor * _v.Target.HpDamage); if ((_v.Target.HpDamage > 9999) && (_v.Target.HpDamage < 15001)) _v.Target.HpDamage = 9999 + (_v.Target.HpDamage - 9999) / 2; if (_v.Target.HpDamage > 15000) _v.Target.HpDamage = 12500 + (_v.Target.HpDamage - 15000) / 4; if ((_v.Target.Flags & CalcFlag.HpRecovery) != 0) { _v.Target.HpDamage = btl_para.SetRecover(_v.Target, (UInt32)_v.Target.HpDamage); _v.Target.FaceTheEnemy(); } } } } else { _v.CalcPhysicalHpDamage(); } if (_drain) _v.Caster.HpDamage = _v.Target.HpDamage; } }}
Another question, does this code replaces the "standard" critical hit function? I already tried before to emulate the critical hit function (in a much more basic manner) and I ended with 2 different kind of criticals, one triggered by my function plus the standard *2 one
Thanks again!!
Last edited: