Hey Tirlititi,
sorry if I ask your help again.
I'm exploring the possibilities offered by Memoria engine and trying to mod Alternate Fantasy to allow summons + normal attacks with ultimate weapons to break the damage limit, using support abilities as described here:
https://github.com/Albeoris/Memoria/wiki/Supporting-ability-features
However, in order to keep some balance I would like to reduce the damage exceeding 9999, actually I used this formula to halve damage between 10.000-15.000 and reduce to 1/4 the damage above 15.000:
Code: [Select]
Code:
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;
I made this work by rewriting a part of Memoria SBattlecalculator.cs in Alternate Fantasy Commonscript.cs to bypass the normal CalcPhysicalHpDamage() function. The result is not very linear (I actually haven't a 100% awareness of what I copy-pasted) but actually seems to work as intended without major bugs:
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; 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(); if (_v.Caster.Weapon == (RegularItem)15) //I still have to add other final weapons { _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; } }}
However I couldn't find a way to handle critical strikes, which double the final damage regardless of my efforts.
Commonscript.cs of Alternate fantasy doesn't contain a call for the "_v.TryCriticalHit()" function, unlike vanilla "baseweaponscript.cs", that is only coded in SBattleCalculator.cs and seems to be applied after the damage calculation (if I end my function setting targethpdamage to a fix "100", a critical strike inflicts "200" damage).
What I would like to do is to calculate the *2 damage of critical hits
before my damage reduction formula, so that a 5000x2 critical is handled normally but a 10000x2 one deals way lesser damage.
There is any way to do this?
A BIG thank you in advance
