Try and cook dodge timings
This commit is contained in:
@@ -22,7 +22,8 @@ namespace BanquetForCyka {
|
|||||||
public static ConfigEntry<bool> debugLevelUpEntry;
|
public static ConfigEntry<bool> debugLevelUpEntry;
|
||||||
|
|
||||||
public static ExpressionConfigEntry xpMultiplier;
|
public static ExpressionConfigEntry xpMultiplier;
|
||||||
public static ExpressionConfigEntry dodgeWindow;
|
public static ExpressionConfigEntry dodgeWindowTotal;
|
||||||
|
public static ExpressionConfigEntry dodgeWindowPerfect;
|
||||||
public static ExpressionConfigEntry levelUpStatEntry;
|
public static ExpressionConfigEntry levelUpStatEntry;
|
||||||
public static ExpressionConfigEntry levelUpSkillEntry;
|
public static ExpressionConfigEntry levelUpSkillEntry;
|
||||||
|
|
||||||
@@ -37,8 +38,13 @@ namespace BanquetForCyka {
|
|||||||
xpMultiplier = new ExpressionConfigEntry(
|
xpMultiplier = new ExpressionConfigEntry(
|
||||||
Config, "General", "XP Multiplier", "v*1",
|
Config, "General", "XP Multiplier", "v*1",
|
||||||
"XP Multiplier expression. Use 'v' to represent the original value.", debugXp);
|
"XP Multiplier expression. Use 'v' to represent the original value.", debugXp);
|
||||||
dodgeWindow = new ExpressionConfigEntry(Config, "General", "Dodge Window", "v*1",
|
dodgeWindowTotal = new ExpressionConfigEntry(
|
||||||
"Dodge Window expression. Use 'v' to represent the original value.",
|
Config, "General", "Dodge Window Total", "v*1",
|
||||||
|
"Total dodge window duration expression. Use 'v' to represent the original value (20).",
|
||||||
|
debugDodgeWindow);
|
||||||
|
dodgeWindowPerfect = new ExpressionConfigEntry(
|
||||||
|
Config, "General", "Dodge Window Perfect", "v*1",
|
||||||
|
"Perfect dodge window percentage expression. Use 'v' to represent the original value (0.25).",
|
||||||
debugDodgeWindow);
|
debugDodgeWindow);
|
||||||
levelUpStatEntry = new ExpressionConfigEntry(
|
levelUpStatEntry = new ExpressionConfigEntry(
|
||||||
Config, "General", "Level Up Stat Entry", "v*1",
|
Config, "General", "Level Up Stat Entry", "v*1",
|
||||||
@@ -72,12 +78,38 @@ namespace BanquetForCyka {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Actions), "DodgeCalculation")]
|
[HarmonyPatch(typeof(Actions), "DodgeCalculation")]
|
||||||
public class Actions_DodgeCalculation {
|
public class Actions_DodgeCalculation_Transpiler {
|
||||||
public static void Postfix(ref float __result) {
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
|
||||||
Main.LogDebug("Original dodge window: " + __result, Main.debugDodgeWindow);
|
var codes = new List<CodeInstruction>(instructions);
|
||||||
float result = Main.dodgeWindow.Evaluate(__result);
|
|
||||||
__result = result;
|
// Find the ldc.r4 20 instruction
|
||||||
Main.LogDebug("Modified dodge window: " + __result, Main.debugDodgeWindow);
|
for (int i = 0; i < codes.Count; i++) {
|
||||||
|
if (codes[i].opcode == OpCodes.Ldc_R4 && (float)codes[i].operand == 20f) {
|
||||||
|
// Replace with our expression evaluation
|
||||||
|
codes[i] = new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(Main), "dodgeWindowTotal"));
|
||||||
|
codes.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_R4, 20f));
|
||||||
|
codes.Insert(i + 2,
|
||||||
|
new CodeInstruction(OpCodes.Callvirt,
|
||||||
|
AccessTools.Method(typeof(ExpressionConfigEntry), "Evaluate")));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the ldc.r4 0.25 instruction
|
||||||
|
for (int i = 0; i < codes.Count; i++) {
|
||||||
|
if (codes[i].opcode == OpCodes.Ldc_R4 && (float)codes[i].operand == 0.25f) {
|
||||||
|
// Replace with our expression evaluation
|
||||||
|
codes[i] =
|
||||||
|
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(Main), "dodgeWindowPerfect"));
|
||||||
|
codes.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_R4, 0.25f));
|
||||||
|
codes.Insert(i + 2,
|
||||||
|
new CodeInstruction(OpCodes.Callvirt,
|
||||||
|
AccessTools.Method(typeof(ExpressionConfigEntry), "Evaluate")));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return codes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user