Skip to content

Commit d989e36

Browse files
committed
v1.2.2 - Fix fall/knockdown bugs, add fall height scaling
1 parent 19a34e9 commit d989e36

8 files changed

Lines changed: 50 additions & 7 deletions

File tree

DifficultyScaling/src/EasyMod.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Il2Cpp;
88
using Il2CppInterop.Runtime;
99

10-
[assembly: MelonInfo(typeof(DifficultyScaling.ModMain), "AI Limit Difficulty Scaling", "1.2.1", "CyrixJD115")]
10+
[assembly: MelonInfo(typeof(DifficultyScaling.ModMain), "AI Limit Difficulty Scaling", "1.2.2", "CyrixJD115")]
1111
[assembly: MelonGame("SenseGames", "AILIMIT")]
1212

1313
namespace DifficultyScaling;
@@ -20,6 +20,7 @@ public class ModMain : MelonMod
2020
private static float _playerDefMult = 2.0f;
2121
private static float _monsterDefMult = 0.4f;
2222
private static float _crystalMult = 1.0f;
23+
private static float _fallDeathHeightMult = 1.0f;
2324
private static bool _debug = false;
2425
private static bool _crystalScaled = false;
2526

@@ -69,10 +70,11 @@ public override void OnInitializeMelon()
6970
_playerDefMult = TomlConfig.GetFloat(cfg, "player_defense_multiplier", 2.0f);
7071
_monsterDefMult = TomlConfig.GetFloat(cfg, "monster_defense_multiplier", 0.4f);
7172
_crystalMult = TomlConfig.GetFloat(cfg, "crystal_multiplier", 1.0f);
73+
_fallDeathHeightMult = TomlConfig.GetFloat(cfg, "fall_death_height_multiplier", _playerHpMult);
7274
_debug = TomlConfig.GetBool(cfg, "debug", false);
7375

7476
MelonLogger.Msg($"{LOG} Loaded preset: {Path.GetFileName(matchedDir)}");
75-
MelonLogger.Msg($"{LOG} PlayerAtk x{_playerAttackMult} | MonsterAtk x{_monsterAttackMult} | PlayerDef x{_playerDefMult} | MonsterDef x{_monsterDefMult} | PlayerHP x{_playerHpMult} | Crystal x{_crystalMult}");
77+
MelonLogger.Msg($"{LOG} PlayerAtk x{_playerAttackMult} | MonsterAtk x{_monsterAttackMult} | PlayerDef x{_playerDefMult} | MonsterDef x{_monsterDefMult} | PlayerHP x{_playerHpMult} | Crystal x{_crystalMult} | FallHeight x{_fallDeathHeightMult}");
7678
}
7779

7880
public override void OnLateInitializeMelon()
@@ -90,10 +92,14 @@ public override void OnLateInitializeMelon()
9092
typeof(ModMain).GetMethod(nameof(MonsterDecreaseHpPrefix), BindingFlags.Static | BindingFlags.NonPublic), null),
9193
("Player.GetHpMaxAttribute", playerType.GetMethod("GetHpMaxAttribute", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, Type.EmptyTypes, null),
9294
null, typeof(ModMain).GetMethod(nameof(GetHpMaxPostfix), BindingFlags.Static | BindingFlags.NonPublic)),
95+
("Player.GetHPMax", playerType.GetMethod("GetHPMax", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, Type.EmptyTypes, null),
96+
null, typeof(ModMain).GetMethod(nameof(GetHpMaxPostfix), BindingFlags.Static | BindingFlags.NonPublic)),
9397
("Player.GetDefenseInfo", playerType.GetMethod("GetDefenseInfo", new Type[] { typeof(bool) }),
9498
null, typeof(ModMain).GetMethod(nameof(PlayerGetDefenseInfoPostfix), BindingFlags.Static | BindingFlags.NonPublic)),
9599
("Monster.GetDefenseInfo", monsterType.GetMethod("GetDefenseInfo", new Type[] { typeof(bool) }),
96100
null, typeof(ModMain).GetMethod(nameof(MonsterGetDefenseInfoPostfix), BindingFlags.Static | BindingFlags.NonPublic)),
101+
("PlayerDefine.GetDeadHigh", typeof(PlayerDefine).GetMethod("get_GetDeadHigh", BindingFlags.Public | BindingFlags.Static, null, Type.EmptyTypes, null),
102+
null, typeof(ModMain).GetMethod(nameof(GetDeadHighPostfix), BindingFlags.Static | BindingFlags.NonPublic)),
97103
};
98104

99105
int patched = 0;
@@ -145,8 +151,13 @@ public override void OnUpdate()
145151
}
146152
}
147153

148-
private static void PlayerDecreaseHpPrefix(ref float value)
154+
private static void PlayerDecreaseHpPrefix(ref float value, ActorDefine.DeadType deadType)
149155
{
156+
if (deadType == ActorDefine.DeadType.FallDead || deadType == ActorDefine.DeadType.TouchGroundDead)
157+
{
158+
if (_debug) MelonLogger.Msg($"{DBG} Player DMG {value} SKIP (deadType={deadType})");
159+
return;
160+
}
150161
if (_debug) MelonLogger.Msg($"{DBG} Player DMG {value} \u2192 {value * _monsterAttackMult} (x{_monsterAttackMult})");
151162
value *= _monsterAttackMult;
152163
}
@@ -163,6 +174,12 @@ private static void GetHpMaxPostfix(ref float __result)
163174
__result *= _playerHpMult;
164175
}
165176

177+
private static void GetDeadHighPostfix(ref float __result)
178+
{
179+
if (_debug) MelonLogger.Msg($"{DBG} FallDeadHigh {__result} \u2192 {__result * _fallDeathHeightMult} (x{_fallDeathHeightMult})");
180+
__result *= _fallDeathHeightMult;
181+
}
182+
166183
private static void PlayerGetDefenseInfoPostfix(ref DefenseInfo __result)
167184
{
168185
__result.nPhysicsDamageReductionRate *= _playerDefMult;
@@ -172,8 +189,6 @@ private static void PlayerGetDefenseInfoPostfix(ref DefenseInfo __result)
172189
__result.nPoisonsDamageReductionRate *= _playerDefMult;
173190
__result.nPunctureDamageReductionRate *= _playerDefMult;
174191
__result.nInfectDamageReductionRate *= _playerDefMult;
175-
__result.nGetHitConfidenceReductionRate *= _playerDefMult;
176-
__result.MaxHp *= _playerDefMult;
177192
if (_debug) MelonLogger.Msg($"{DBG} Player Def scaled x{_playerDefMult}");
178193
}
179194

@@ -186,8 +201,6 @@ private static void MonsterGetDefenseInfoPostfix(ref DefenseInfo __result)
186201
__result.nPoisonsDamageReductionRate *= _monsterDefMult;
187202
__result.nPunctureDamageReductionRate *= _monsterDefMult;
188203
__result.nInfectDamageReductionRate *= _monsterDefMult;
189-
__result.nGetHitConfidenceReductionRate *= _monsterDefMult;
190-
__result.MaxHp *= _monsterDefMult;
191204
if (_debug) MelonLogger.Msg($"{DBG} Monster Def scaled x{_monsterDefMult}");
192205
}
193206
}

DifficultyScaling_cfg/Difficulty/00_custom/scaling.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ player_attack_multiplier = 1.0
1111
player_defense_multiplier = 1.0
1212
player_hp_multiplier = 1.0
1313

14+
# === Fall Damage Scaling ===
15+
# Scales the height threshold before fall death triggers (base: 20 units).
16+
# Does NOT affect the 15-second void-fall timer (falling into pits with no floor).
17+
fall_death_height_multiplier = 1.0
18+
1419
# === Economy Scaling ===
1520
crystal_multiplier = 1.0
1621

DifficultyScaling_cfg/Difficulty/01_story/scaling.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ player_attack_multiplier = 1.5
99
player_defense_multiplier = 1.2
1010
player_hp_multiplier = 1.5
1111

12+
# === Fall Damage Scaling ===
13+
# Scales the height threshold before fall death triggers (base: 20 units).
14+
# Does NOT affect the 15-second void-fall timer (falling into pits with no floor).
15+
fall_death_height_multiplier = 1.5
16+
1217
# === Economy Scaling ===
1318
crystal_multiplier = 1.5
1419

DifficultyScaling_cfg/Difficulty/02_easy/scaling.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ player_attack_multiplier = 1.2
99
player_defense_multiplier = 1.2
1010
player_hp_multiplier = 1.35
1111

12+
# === Fall Damage Scaling ===
13+
# Scales the height threshold before fall death triggers (base: 20 units).
14+
# Does NOT affect the 15-second void-fall timer (falling into pits with no floor).
15+
fall_death_height_multiplier = 1.35
16+
1217
# === Economy Scaling ===
1318
crystal_multiplier = 1.3
1419

DifficultyScaling_cfg/Difficulty/03_normal/scaling.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ player_attack_multiplier = 1.1
99
player_defense_multiplier = 1.1
1010
player_hp_multiplier = 1.2
1111

12+
# === Fall Damage Scaling ===
13+
# Scales the height threshold before fall death triggers (base: 20 units).
14+
# Does NOT affect the 15-second void-fall timer (falling into pits with no floor).
15+
fall_death_height_multiplier = 1.2
16+
1217
# === Economy Scaling ===
1318
crystal_multiplier = 1.15
1419

DifficultyScaling_cfg/Difficulty/04_adept/scaling.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ player_attack_multiplier = 1.0
1010
player_defense_multiplier = 1.0
1111
player_hp_multiplier = 1.0
1212

13+
# === Fall Damage Scaling ===
14+
# Scales the height threshold before fall death triggers (base: 20 units).
15+
# Does NOT affect the 15-second void-fall timer (falling into pits with no floor).
16+
fall_death_height_multiplier = 1.0
17+
1318
# === Economy Scaling ===
1419
crystal_multiplier = 1.0
1520

DifficultyScaling_cfg/Difficulty/05_hard/scaling.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ player_attack_multiplier = 0.9
99
player_defense_multiplier = 0.9
1010
player_hp_multiplier = 0.9
1111

12+
# === Fall Damage Scaling ===
13+
# Scales the height threshold before fall death triggers (base: 20 units).
14+
# Does NOT affect the 15-second void-fall timer (falling into pits with no floor).
15+
fall_death_height_multiplier = 1.0
16+
1217
# === Economy Scaling ===
1318
crystal_multiplier = 0.95
1419

9.91 KB
Binary file not shown.

0 commit comments

Comments
 (0)