BattletechModders / CBTBehaviorsEnhanced

Applies Classic BattleTech behaviors to the HBS BattleTech Game
MIT License
5 stars 6 forks source link

Injury fraction calculation is wrong #112

Closed IceRaptor closed 2 years ago

IceRaptor commented 2 years ago

BlueWinds, Lady of Light (Mechs) — Yesterday at 11:13 AM Yeah, it seems to weigh injuring the enemy pilot heavily and self damage not very much. FrostRaptor — Yesterday at 11:24 AM Yeah, it's just the straight sum of damage to the attacker. Charges are pretty light on attacker damage in general. That's why the selfEvasionDamage is weighted at 30 (6 pips of lost defense) whereas self damage is only 10 Knockdown utility is driven by Mod.Config.Melee.AI.PilotInjuryMultiUtility largely BlueWinds, Lady of Light (Mechs) — Yesterday at 11:33 AM What's injuryFraction? FrostRaptor — Yesterday at 11:36 AM float knockdownUtility = 0f; if (targetMech != null && targetMech.pilot != null && AttackHelper.WillKnockdownTarget(meleeAttack.TargetInstability, targetMech, meleeAttack.OnTargetMechHitForceUnsteady)) { float centerTorsoArmorAndStructure = targetMech.GetMaxArmor(ArmorLocation.CenterTorso) + targetMech.GetMaxStructure(ChassisLocations.CenterTorso); if (AttackHelper.WillInjuriesKillTarget(targetMech, 1)) { knockdownUtility = centerTorsoArmorAndStructure Mod.Config.Melee.AI.PilotInjuryMultiUtility; Mod.AILog.Info?.Write($" Adding {knockdownUtility} virtual damage to EV from " + $"centerTorsoArmorAndStructure: {centerTorsoArmorAndStructure} x injuryMultiUtility: {Mod.Config.Melee.AI.PilotInjuryMultiUtility}"); } else { // Attack won't kill, so only apply a fraction equal to the totalHeath float injuryFraction = (targetMech.pilot.TotalHealth - 1) - (targetMech.pilot.Injuries + 1); knockdownUtility = (centerTorsoArmorAndStructure Mod.Config.Melee.AI.PilotInjuryMultiUtility) / injuryFraction; Mod.AILog.Info?.Write($" Adding {knockdownUtility} virtual damage to EV from " + $"(centerTorsoArmorAndStructure: {centerTorsoArmorAndStructure} x injuryMultiUtility: {Mod.Config.Melee.AI.PilotInjuryMultiUtility}) " + $"/ injuryFraction: {injuryFraction}"); } } It's my attempt to fractionalize the total damage as a percentage of health lost Since 3-5 injuries kill, each injury is worth a large fraction of the CT armor & structure put together i.e. why burn through 600 armor+structure if you can just knock them over 3 times? BlueWinds, Lady of Light (Mechs) — Yesterday at 11:39 AM Why are you subtracting 1 from totalhealth and adding 1 to injuries? Reducing that equation, you have ((totalHealth - injuries) - 2). So if I have 3 health and 0 injuries, the fraction is 1. If I have 3 health and one injury, the fraction is... 0? FrostRaptor — Yesterday at 11:41 AM Probably because I'm bad at math? 😛 BlueWinds, Lady of Light (Mechs) — Yesterday at 11:42 AM I think the equation you'd want there is (totalHealth - injuries). So you'd get: 3 health, 0 injuries = 3. Injurie weighted at 1/3rd CT health. 3 health, 2 injuries (almost dead!) = 1. Injury weighted at full CT health. FrostRaptor — Yesterday at 11:43 AM I know I did totalHealth - 1 to reflect 'not a kill' BlueWinds, Lady of Light (Mechs) — Yesterday at 11:43 AM And you'd never get a 0 for your denominator, because injuries never equal health. I don't think you want to subtract anything (other than injuries), because then you can end up with 0 in the denominator and a divide by 0 error. I'm not quite following how the -1 reflects "not a kill"? FrostRaptor — Yesterday at 11:45 AM I don't know. I'm trying to remember if this was purposeful, or just another case where my brain did bad math I think what I was thinking... is varying the divisor used by the amount of injuries needed to finish a kill. injuryFraction is actually the divisor used in: (centerTorsoArmorAndStructure * Mod.Config.Melee.AI.PilotInjuryMultiUtility) / injuryFraction; With the idea being that against a target with bonusHealth of +3 (totalHealth = 6) and no injuries, you'd end up with a smaller divisor than if the knockdown was closer to a kill I.e. weight a knockdown that leaves the target with 1 health much higher than a knockdown that leaves it with 5 So I think just me being bad at math? Thank you for questioning it @BlueWinds, Lady of Light (Mechs) . I'll get this fixed

IceRaptor commented 2 years ago

Fixed in 0.8.12