Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONize spell skill failure #70506

Open
Maleclypse opened this issue Dec 29, 2023 · 0 comments
Open

JSONize spell skill failure #70506

Maleclypse opened this issue Dec 29, 2023 · 0 comments
Labels
Mechanics: Enchantments / Spells Enchantments and spells Mods: Magiclysm Anything to do with the Magiclysm mod Mods: Mind Over Matter Mods: Xedra Evolved Anything to do with Xedra Evolved (P5 - Long-term) Long-term WIP, may stay on the list for a while. <Suggestion / Discussion> Talk it out before implementing

Comments

@Maleclypse
Copy link
Member

Is your feature request related to a problem? Please describe.

Long term we would like to see the different methods of spellcasting jsonized so that a multitude of methods can flourish.
The following function will need to be jsonized.

float spell::spell_fail( const Character &guy ) const
{
    if( has_flag( spell_flag::NO_FAIL ) ) {
        return 0.0f;
    }
    // formula is based on the following:
    // exponential curve
    // effective skill of 0 or less is 100% failure
    // effective skill of 8 (8 int, 0 spellcraft, 0 spell level, spell difficulty 0) is ~50% failure
    // effective skill of 30 is 0% failure
    const float effective_skill = 2 * ( get_effective_level() - get_difficulty(
                                            guy ) ) + guy.get_int() +
                                  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
    // 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

    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;
    // add an if statement in here because sufficiently large numbers will definitely overflow because of exponents
    if( effective_skill > 30.0f ) {
        return 0.0f;
    } else if( effective_skill < 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 );

    if( has_flag( spell_flag::SOMATIC ) &&
        !guy.has_flag( json_flag_SUBTLE_SPELL ) && temp_somatic_difficulty_multiplyer > 0 ) {
        // the first 20 points of encumbrance combined is ignored
@@ -1264,7 +1278,13 @@ float spell::spell_fail( const Character &guy ) const
        float concentration_loss = ( 1.0f - ( guy.get_focus() / 100.0f ) ) *
                                   temp_concentration_difficulty_multiplyer;
        fail_chance /= 1.0f - concentration_loss;
        psi_fail_chance /= 1.0f - concentration_loss;
    }

    if( has_flag( spell_flag::PSIONIC ) ) {
        return clamp( psi_fail_chance, 0.0f, 1.0f );
    }

    return clamp( fail_chance, 0.0f, 1.0f );
}

Solution you would like.

Ideally the solution would add fields that tie into the associated spell skill. If it needed to be set up with an entirely new type that would be acceptable too.

  {
    "type": "skill",
    "ident": "deduction",
    "name": { "str": "deduction" },
    "description": "Your ability to see the pattern behind a series of data points.  Allows you to ask questions that you otherwise couldn't ask and find things you might have missed otherwise.",
    "companion_industry_rank_factor": 1,
    "tags": [ "combat_skill" ],
    "time_to_attack": { "min_time": 60, "base_time": 200, "time_reduction_per_level": 14 },
    "display_category": "display_interaction",
    "sort_rank": 26500,
    "companion_skill_practice": [ { "skill": "speech", "weight": 1 }, { "skill": "devices", "weight": 1 } ]
  },

Describe alternatives you have considered.

It could follow the type: damage model where damage was jsonized.

Additional context

No response

@Maleclypse Maleclypse added <Suggestion / Discussion> Talk it out before implementing (P5 - Long-term) Long-term WIP, may stay on the list for a while. Mods: Magiclysm Anything to do with the Magiclysm mod Mechanics: Enchantments / Spells Enchantments and spells Mods: Xedra Evolved Anything to do with Xedra Evolved Mods: Mind Over Matter labels Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mechanics: Enchantments / Spells Enchantments and spells Mods: Magiclysm Anything to do with the Magiclysm mod Mods: Mind Over Matter Mods: Xedra Evolved Anything to do with Xedra Evolved (P5 - Long-term) Long-term WIP, may stay on the list for a while. <Suggestion / Discussion> Talk it out before implementing
Projects
None yet
Development

No branches or pull requests

1 participant