@@ -1343,11 +1343,6 @@ float spell::spell_fail( const Character &guy ) const
1343
1343
if ( has_flag ( spell_flag::NO_FAIL ) ) {
1344
1344
return 0 .0f ;
1345
1345
}
1346
- if ( type->magic_type .has_value () &&
1347
- type->magic_type .value ()->failure_chance_formula_id .has_value () ) {
1348
- const_dialogue d ( get_const_talker_for ( guy ), nullptr );
1349
- return type->magic_type .value ()->failure_chance_formula_id .value ()->eval ( d );
1350
- }
1351
1346
1352
1347
const bool is_psi = has_flag ( spell_flag::PSIONIC );
1353
1348
@@ -1390,15 +1385,26 @@ float spell::spell_fail( const Character &guy ) const
1390
1385
static_cast <float >( 45 ) );
1391
1386
}
1392
1387
}
1388
+ bool has_type_fail_chance = type->magic_type .has_value () &&
1389
+ type->magic_type .value ()->failure_chance_formula_id .has_value ();
1393
1390
// add an if statement in here because sufficiently large numbers will definitely overflow because of exponents
1394
- if ( ( effective_skill > 30 .0f && !is_psi ) || ( psi_effective_skill > 40 .0f && is_psi ) ) {
1395
- return 0 .0f ;
1396
- } else if ( ( effective_skill < 0 .0f && !is_psi ) || ( psi_effective_skill < 0 .0f && is_psi ) ) {
1397
- return 1 .0f ;
1391
+ if ( !has_type_fail_chance ) {
1392
+ if ( ( effective_skill > 30 .0f && !is_psi ) || ( psi_effective_skill > 40 .0f && is_psi ) ) {
1393
+ return 0 .0f ;
1394
+ } else if ( ( effective_skill < 0 .0f && !is_psi ) || ( psi_effective_skill < 0 .0f && is_psi ) ) {
1395
+ return 1 .0f ;
1396
+ }
1398
1397
}
1399
1398
1400
- float fail_chance = std::pow ( ( effective_skill - 30 .0f ) / 30 .0f , 2 );
1401
- float psi_fail_chance = std::pow ( ( psi_effective_skill - 40 .0f ) / 40 .0f , 2 );
1399
+ float fail_chance = 0 ;
1400
+ if ( has_type_fail_chance ) {
1401
+ const_dialogue d ( get_const_talker_for ( guy ), nullptr );
1402
+ fail_chance = type->magic_type .value ()->failure_chance_formula_id .value ()->eval ( d );
1403
+ } else if ( is_psi ) {
1404
+ fail_chance = std::pow ( ( psi_effective_skill - 40 .0f ) / 40 .0f , 2 );
1405
+ } else {
1406
+ fail_chance = std::pow ( ( effective_skill - 30 .0f ) / 30 .0f , 2 );
1407
+ }
1402
1408
1403
1409
if ( !is_psi ) {
1404
1410
if ( has_flag ( spell_flag::SOMATIC ) &&
@@ -1429,10 +1435,9 @@ float spell::spell_fail( const Character &guy ) const
1429
1435
return 1 .0f ;
1430
1436
}
1431
1437
fail_chance /= 1 .0f - concentration_loss;
1432
- psi_fail_chance /= 1 .0f - concentration_loss;
1433
1438
}
1434
1439
1435
- return clamp ( is_psi ? psi_fail_chance : fail_chance, 0 .0f , 1 .0f );
1440
+ return clamp ( fail_chance, 0 .0f , 1 .0f );
1436
1441
}
1437
1442
1438
1443
std::string spell::colorized_fail_percent ( const Character &guy ) const
0 commit comments