Skip to content

Commit

Permalink
[MoM] Psi equation fixes (#70536)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Standing-Storm and github-actions[bot] authored Dec 31, 2023
1 parent d010952 commit 502fa46
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions data/mods/MindOverMatter/powers/biokinesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)" ] },
Expand Down
1 change: 1 addition & 0 deletions data/mods/MindOverMatter/powers/photokinesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)" ] },
Expand Down
3 changes: 3 additions & 0 deletions data/mods/MindOverMatter/powers/pyrokinesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)" ] },
Expand Down Expand Up @@ -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)" ] },
Expand Down Expand Up @@ -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)" ] },
Expand Down
2 changes: 2 additions & 0 deletions data/mods/MindOverMatter/powers/telekinesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
"teachable": false,
"valid_targets": [ "self" ],
"spell_class": "TELEKINETIC",
"skill": "metaphysics",
"flags": [
"PSIONIC",
"CONCENTRATE",
Expand Down Expand Up @@ -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)" ] },
Expand Down
20 changes: 11 additions & 9 deletions src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>( get_effective_level() ) /
static_cast<float>
( 1.5 );

const float half_power_level = static_cast<float>( get_effective_level() ) / static_cast<float>
( 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 ) {
Expand Down

0 comments on commit 502fa46

Please sign in to comment.