From 502fa46e9e762597397e363d6f0fb6eb5e109c21 Mon Sep 17 00:00:00 2001 From: Standing-Storm <120433252+Standing-Storm@users.noreply.github.com> Date: Sat, 30 Dec 2023 21:08:07 -0600 Subject: [PATCH] [MoM] Psi equation fixes (#70536) * Initial commit * Initial commit * Update src/magic.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fixes --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../MindOverMatter/powers/biokinesis.json | 1 + .../MindOverMatter/powers/photokinesis.json | 1 + .../MindOverMatter/powers/pyrokinesis.json | 3 +++ .../MindOverMatter/powers/telekinesis.json | 2 ++ src/magic.cpp | 20 ++++++++++--------- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/data/mods/MindOverMatter/powers/biokinesis.json b/data/mods/MindOverMatter/powers/biokinesis.json index acdf0c71a8ca3..9b2c19d326e12 100644 --- a/data/mods/MindOverMatter/powers/biokinesis.json +++ b/data/mods/MindOverMatter/powers/biokinesis.json @@ -304,6 +304,7 @@ "teachable": false, "valid_targets": [ "self" ], "spell_class": "BIOKINETIC", + "skill": "metaphysics", "flags": [ "PSIONIC", "CONCENTRATE", "SILENT", "NO_HANDS", "NO_LEGS", "NO_EXPLOSION_SFX", "RANDOM_DURATION" ], "difficulty": 5, "max_level": { "math": [ "int_to_level(1)" ] }, diff --git a/data/mods/MindOverMatter/powers/photokinesis.json b/data/mods/MindOverMatter/powers/photokinesis.json index 0e847d73b1949..5df55d4edce5a 100644 --- a/data/mods/MindOverMatter/powers/photokinesis.json +++ b/data/mods/MindOverMatter/powers/photokinesis.json @@ -498,6 +498,7 @@ "teachable": false, "valid_targets": [ "self" ], "spell_class": "PHOTOKINETIC", + "skill": "metaphysics", "flags": [ "PSIONIC", "CONCENTRATE", "SILENT", "NO_HANDS", "NO_LEGS", "NO_EXPLOSION_SFX" ], "difficulty": 5, "max_level": { "math": [ "int_to_level(1)" ] }, diff --git a/data/mods/MindOverMatter/powers/pyrokinesis.json b/data/mods/MindOverMatter/powers/pyrokinesis.json index 838742384a818..ba8d4b7662a24 100644 --- a/data/mods/MindOverMatter/powers/pyrokinesis.json +++ b/data/mods/MindOverMatter/powers/pyrokinesis.json @@ -141,6 +141,7 @@ "teachable": false, "valid_targets": [ "self" ], "spell_class": "PYROKINETIC", + "skill": "metaphysics", "flags": [ "PSIONIC", "CONCENTRATE", "SILENT", "NO_HANDS", "NO_LEGS", "NO_EXPLOSION_SFX", "RANDOM_DURATION" ], "difficulty": 3, "max_level": { "math": [ "int_to_level(1)" ] }, @@ -342,6 +343,7 @@ "teachable": false, "valid_targets": [ "self" ], "spell_class": "PYROKINETIC", + "skill": "metaphysics", "flags": [ "PSIONIC", "CONCENTRATE", "SILENT", "NO_HANDS", "NO_LEGS", "RANDOM_DURATION", "NO_EXPLOSION_SFX" ], "difficulty": 5, "max_level": { "math": [ "int_to_level(1)" ] }, @@ -380,6 +382,7 @@ "teachable": false, "valid_targets": [ "self" ], "spell_class": "PYROKINETIC", + "skill": "metaphysics", "flags": [ "PSIONIC", "CONCENTRATE", "SILENT", "NO_HANDS", "NO_LEGS", "RANDOM_DURATION", "NO_EXPLOSION_SFX" ], "difficulty": 6, "max_level": { "math": [ "int_to_level(1)" ] }, diff --git a/data/mods/MindOverMatter/powers/telekinesis.json b/data/mods/MindOverMatter/powers/telekinesis.json index af55b75f11a8a..1344050c648f9 100644 --- a/data/mods/MindOverMatter/powers/telekinesis.json +++ b/data/mods/MindOverMatter/powers/telekinesis.json @@ -254,6 +254,7 @@ "teachable": false, "valid_targets": [ "self" ], "spell_class": "TELEKINETIC", + "skill": "metaphysics", "flags": [ "PSIONIC", "CONCENTRATE", @@ -379,6 +380,7 @@ "teachable": false, "valid_targets": [ "self" ], "spell_class": "TELEKINETIC", + "skill": "metaphysics", "flags": [ "PSIONIC", "CONCENTRATE", "SILENT", "NO_HANDS", "NO_LEGS", "NO_EXPLOSION_SFX" ], "difficulty": 6, "max_level": { "math": [ "int_to_level(1)" ] }, diff --git a/src/magic.cpp b/src/magic.cpp index 2e57e3f05fa8d..d015f3170af13 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -1236,24 +1236,26 @@ float spell::spell_fail( const Character &guy ) const guy.get_skill_level( skill() ); // skill for psi powers downplays power level and is much more based on level and intelligence - // Int 8, Metaphysics 2, level 1 , difficulty 1 is effective level 26.5 + // and goes up to 40 max--effective skill of 10 is 50% failure, effective skill of 40 is 0% + // Int 8, Metaphysics 2, level 1, difficulty 1 is effective level 26.5 // Int 10, Metaphysics 5, level 4, difficulty 5 is effective level 27 - // Int 12, Metaphysics 8, level 7, difficulty 10 is clamped at effective level 33.5 + // Int 12, Metaphysics 8, level 7, difficulty 10 is effective level 33.5 + const float two_thirds_power_level = static_cast( get_effective_level() ) / + static_cast + ( 1.5 ); - const float half_power_level = static_cast( get_effective_level() ) / static_cast - ( 2 ); - - const float psi_effective_skill = 2 * ( ( guy.get_skill_level( skill() ) * 2 ) - get_difficulty( - guy ) ) + ( guy.get_int() * 1.5 ) + half_power_level; + const float psi_effective_skill = 2 * ( ( guy.get_skill_level( skill() ) * 2 ) - get_difficulty( + guy ) ) + ( guy.get_int() * 1.5 ) + two_thirds_power_level; // add an if statement in here because sufficiently large numbers will definitely overflow because of exponents - if( effective_skill > 30.0f ) { + if( ( effective_skill > 30.0f && !has_flag( spell_flag::PSIONIC ) ) || + ( psi_effective_skill > 40.0f && has_flag( spell_flag::PSIONIC ) ) ) { return 0.0f; } else if( ( effective_skill || psi_effective_skill ) < 0.0f ) { return 1.0f; } float fail_chance = std::pow( ( effective_skill - 30.0f ) / 30.0f, 2 ); - float psi_fail_chance = std::pow( ( psi_effective_skill - 30.0f ) / 30.0f, 2 ); + float psi_fail_chance = std::pow( ( psi_effective_skill - 40.0f ) / 40.0f, 2 ); if( has_flag( spell_flag::SOMATIC ) && !guy.has_flag( json_flag_SUBTLE_SPELL ) && temp_somatic_difficulty_multiplyer > 0 ) {