Try and cook dodge timings
This commit is contained in:
@@ -22,7 +22,8 @@ namespace BanquetForCyka {
|
||||
public static ConfigEntry<bool> debugLevelUpEntry;
|
||||
|
||||
public static ExpressionConfigEntry xpMultiplier;
|
||||
public static ExpressionConfigEntry dodgeWindow;
|
||||
public static ExpressionConfigEntry dodgeWindowTotal;
|
||||
public static ExpressionConfigEntry dodgeWindowPerfect;
|
||||
public static ExpressionConfigEntry levelUpStatEntry;
|
||||
public static ExpressionConfigEntry levelUpSkillEntry;
|
||||
|
||||
@@ -37,9 +38,14 @@ namespace BanquetForCyka {
|
||||
xpMultiplier = new ExpressionConfigEntry(
|
||||
Config, "General", "XP Multiplier", "v*1",
|
||||
"XP Multiplier expression. Use 'v' to represent the original value.", debugXp);
|
||||
dodgeWindow = new ExpressionConfigEntry(Config, "General", "Dodge Window", "v*1",
|
||||
"Dodge Window expression. Use 'v' to represent the original value.",
|
||||
debugDodgeWindow);
|
||||
dodgeWindowTotal = new ExpressionConfigEntry(
|
||||
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);
|
||||
levelUpStatEntry = new ExpressionConfigEntry(
|
||||
Config, "General", "Level Up Stat Entry", "v*1",
|
||||
"Stat Entry expression. Use 'v' to represent the original value.", debugStatEntry);
|
||||
@@ -72,12 +78,38 @@ namespace BanquetForCyka {
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Actions), "DodgeCalculation")]
|
||||
public class Actions_DodgeCalculation {
|
||||
public static void Postfix(ref float __result) {
|
||||
Main.LogDebug("Original dodge window: " + __result, Main.debugDodgeWindow);
|
||||
float result = Main.dodgeWindow.Evaluate(__result);
|
||||
__result = result;
|
||||
Main.LogDebug("Modified dodge window: " + __result, Main.debugDodgeWindow);
|
||||
public class Actions_DodgeCalculation_Transpiler {
|
||||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
|
||||
var codes = new List<CodeInstruction>(instructions);
|
||||
|
||||
// Find the ldc.r4 20 instruction
|
||||
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