The description of the darkness Combat precept says "We fight better in the dark"
we have
<MeleeHitChanceOutdoorsDarkOffset>0.1</MeleeHitChanceOutdoorsDarkOffset>
<MeleeHitChanceOutdoorsLitOffset>-0.1</MeleeHitChanceOutdoorsLitOffset>
<MeleeHitChanceIndoorsDarkOffset>0.1</MeleeHitChanceIndoorsDarkOffset>
<MeleeHitChanceIndoorsLitOffset>-0.1</MeleeHitChanceIndoorsLitOffset>
<MeleeDodgeChanceOutdoorsDarkOffset>0.1</MeleeDodgeChanceOutdoorsDarkOffset>
<MeleeDodgeChanceOutdoorsLitOffset>-0.1</MeleeDodgeChanceOutdoorsLitOffset>
<MeleeDodgeChanceIndoorsDarkOffset>0.1</MeleeDodgeChanceIndoorsDarkOffset>
<MeleeDodgeChanceIndoorsLitOffset>-0.1</MeleeDodgeChanceIndoorsLitOffset>
Note both `MeleeDodgeChanceOutdoorsDarkOffset` & `MeleeHitChanceOutdoorsDarkOffset` are 0.1
The code seems to add the attacker's offset to the target's dodge chance, which implies the target dodges more often in the dark.
It feels like a debuff to fight in the dark. Is this intended behavior?
Code is attached for reference
In the function RimWorld.Verb_MeleeAttack.GetDodgechance
Pawn pawn = target.Thing as Pawn;
...
float num = pawn.GetStatValue(StatDefOf.MeleeDodgeChance);
if (ModsConfig.IdeologyActive && target.HasThing)
{
if (DarknessCombatUtility.IsOutdoorsAndLit(target.Thing))
{
num += caster.GetStatValue(StatDefOf.MeleeDodgeChanceOutdoorsLitOffset);
}
else if (DarknessCombatUtility.IsOutdoorsAndDark(target.Thing))
{
num += caster.GetStatValue(StatDefOf.MeleeDodgeChanceOutdoorsDarkOffset);
}
else if (DarknessCombatUtility.IsIndoorsAndDark(target.Thing))
{
num += caster.GetStatValue(StatDefOf.MeleeDodgeChanceIndoorsDarkOffset);
}
else if (DarknessCombatUtility.IsIndoorsAndLit(target.Thing))
{
num += caster.GetStatValue(StatDefOf.MeleeDodgeChanceIndoorsLitOffset);
}
}
You mean the problem is that it does "caster.GetStatValue" instead of getting it from the target? Good find
I've tested around with setting these values really high. Targets had 0% dodge chance in their info and my pawn had the darkness combat precept. Enemies dodged all melee attacks when I attacked in the night.
The correct behavior depends on what `MeleeDodgeChanceOutdoorsDarkOffset` is supposed to mean:
- If this is a stats that an attacker owns that would impact his target (e.g. like an aura), the value in xml should be negative (e.g. -0.1 instead of 0.1) if we want to debuff his enemy.
- If this is a stats that offsets the MeleeDodgeChance of the owner, then the game code should do `pawn.GetStatValue` rather than `caster.GetStatValue`
Either way it would be nice to add more clarity to the description of `StatDef.MeleeDodgeChanceOutdoorsDarkOffset`
I am pretty sure the "dodge" stats should not be owned by an attacker. Only the hit stat. Attacker rolls hit, attacked rolls dodge is a common perception. The precept is very likely not meant to reduce dodge from the attacked or something like that.
The problem is that the function uses the base dodge chance of the pawn and then adds the darkness dodge modifier of the attacker instead of the attacked. That makes of course no sense, since the attacked is the one dodging. The darkness precept already has a modifier for the attacker, which is the (positive) hit chance modifier. It's written correctly in game on the pawn stats but just incorrectly applied by the function.
This is not the only weird thing on the darkness combat description imo. It took me a bit to understand that the ranged modifier is just a flat offset and not something like a 125% modifier. Ingame it just says "25%" on the aim hover, where the shooter and weapon % values are depicted and those 2 work multiplicatively, but the darkness one just don't. That is rather inconsistent.
Modifiers like cover or hugging the ground still affect it like everything else though.
https://steamuserimages-a.akamaihd.net/ugc/1841409905612356992/9E4FA451FA73CB69D5994918868B60F3BF0BF5B3/
Maybe the description could be revised.
Thanks for the bug report, I've looked this over and will be referring this to the devs for review of the provided code snippets. Appreciate you taking the time to dig this deep into it!