Weighted Anklet Mod Incompatibility
cheeeeeeeeeen opened this issue · 2 comments
private void MoveSpeedReduction(On.RoR2.CharacterBody.orig_RecalculateStats orig, RoR2.CharacterBody self)
{
orig(self);
var InventoryCount = GetCount(self);
if (InventoryCount > 0)
{
self.moveSpeed *= Mathf.Clamp(1 - (InventoryCount * baseMovementSpeedReductionPercentage),
movementSpeedReductionPercentageCap, 1);
}
}
This can lead to mod incompatibilities and miscalculations. This basically means weighted anklet multiplies the resulting movement speed after all item effects have been applied, where in it's more appropriate to add the multiplier before the movement speed changes are applied along with other items.
float num50 = 1f;
if (this.HasBuff(BuffIndex.Slow50))
{
num50 += 0.5f;
}
if (this.HasBuff(BuffIndex.Slow60))
{
num50 += 0.6f;
}
if (this.HasBuff(BuffIndex.Slow80))
{
num50 += 0.8f;
}
if (this.HasBuff(BuffIndex.ClayGoo))
{
num50 += 0.5f;
}
if (this.HasBuff(BuffIndex.Slow30))
{
num50 += 0.3f;
}
if (this.HasBuff(BuffIndex.Cripple))
{
num50 += 1f;
}
num48 *= num49 / num50;
if (num12 > 0)
{
num48 *= 1f - 0.05f * (float)num12;
}
this.moveSpeed = num48;
The solution is to IL this one. Weighted Anklet should insert its multiplier into num50
to properly "stack" the multipliers.
I know next to nothing about IL. I'll look into it though soon.
I know next to nothing about IL. I'll look into it though soon.
Same. I was learning, but my IL code won't work. Here is what I did though:
if (self.HasBuff(poisonBuff))
{
float baseMoveSpeed = self.baseMoveSpeed + self.levelMoveSpeed * (self.level - 1);
float flatMovementReduction = baseMoveSpeed * (1f - slowMultiplier);
orig(self);
self.moveSpeed -= flatMovementReduction;
}
else orig(self);
I used a precomputed reduction based on the base movement speed. This is more compatible with other mods.