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

Formula of spell failure not sensible #39952

Closed
martinrhan opened this issue Apr 27, 2020 · 2 comments
Closed

Formula of spell failure not sensible #39952

martinrhan opened this issue Apr 27, 2020 · 2 comments

Comments

@martinrhan
Copy link
Contributor

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

I read the document of Magiclysm and found the formula of spell failure not sensible.
the formula is:
( ( ( ( spell_level - spell_difficulty ) * 2 + intelligence + spellcraft_skill ) - 30 ) / 30 ) ^ 2
I can understand that ( ( spell_level - spell_difficulty ) * 2 + intelligence + spellcraft_skill ) = the accumulated ability to cast the spell and when it get to 30, the spell is not possible to be failed.
However, when that value grows further, the failure changce get to more than 0 again and when it is 60 it will not be possible to get the spell successfuly casted.
It dosen't make any sense that when I get into a very experienced and skilled degree I become less capable to cast the spell.

Describe the solution you'd like

I have figured out another formula
(1- ( ( spell_level - spell_difficulty ) * 2 + intelligence + spellcraft_skill ) / 30 )
if negative, change it to 0.
then squre it.

@martinrhan
Copy link
Contributor Author

just checked it out in the game. I edited my character's spellcraft skill to 80, and all the spell's failure chance is 0. That means the document is wrong. It need to be updated

@KorGgenT
Copy link
Member

see

Cataclysm-DDA/src/magic.cpp

Lines 732 to 740 in 5926e6e

const float effective_skill = 2 * ( get_level() - get_difficulty() ) + guy.get_int() +
guy.get_skill_level( skill() );
// 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 ) {
return 1.0f;
}
float fail_chance = std::pow( ( effective_skill - 30.0f ) / 30.0f, 2 );

if you would like to update the documentation such that it is explicit about failure chance reaching 0, go ahead, though i see no need to update the formula to something similar enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants