-
Notifications
You must be signed in to change notification settings - Fork 287
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
Enchantment/relic cleanup 2 #400
Conversation
1. Fix final value being out of bounds in some places. 2. Changed the formula for combining multiple enchantments to produce more easily predictable results. 3. Remove dead code
src/magic_enchantment.cpp
Outdated
|
||
guy.mod_num_dodges_bonus( get_value_add( enchant_vals::mod::BONUS_DODGE ) ); | ||
guy.mod_num_dodges_bonus( mult_bonus( enchant_vals::mod::BONUS_DODGE, guy.get_num_dodges_base() ) ); | ||
guy.mod_num_dodges_bonus( calc_bonus( enchant_vals::mod::BONUS_DODGE, guy.get_num_dodges_base() ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"BONUS_DODGE"
is another unfortunate name. It sounds like bonus to the ability to dodge, but actually adds dodge attempts before penalty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is it should've been BONUS_DODGES
, which would've conveyed the intended effect.
@@ -419,12 +419,12 @@ void Character::melee_attack( Creature &t, bool allow_special, const matec_id &f | |||
} | |||
item &cur_weapon = allow_unarmed ? used_weapon() : weapon; | |||
|
|||
if( cur_weapon.attack_time() > attack_speed( cur_weapon ) * 20 ) { | |||
if( cur_weapon.attack_cost() > attack_cost( cur_weapon ) * 20 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really changed here, but that sure is a puzzling line.
I'm getting test failures in the new tests, all of them off with the character getting +1 in a stat or speed.
Big block
Platform:
Building with:
|
Turns out JSON Parsing I guess I'll just limit minimum multiplicative bonus to some reasonable amount (0.00001 should be more than enough). |
src/creature.cpp
Outdated
|
||
void Creature::clear_effects_for_testing() | ||
{ | ||
effects->clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to exist? It may be a bug in how I designed effect removal if it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea, it was me checking if effects were correctly removed (they seem to)
"add": 13.37, | ||
// Additive bonus. Optional integer number, default is 0. | ||
// May be ignored for some values. | ||
"add": 13, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch there - most of the code pretty clearly tries to imply that it's a double
, by using double
s to accumulate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually thought about converting it to double
, but there doesn't seem to be any use cases to warrant that (yet?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, it would work if multiple effects had subtle effects that only make sense when added together.
But it sounds like UI trouble to even try.
Purpose of change
Makes it so bonuses don't affect each other in weird ways, but rather are
calculated based on same baseline and then applied simultaneously.
Describe alternatives you've considered
Porting the code from DDA repo, but after encountering various merge conflicts, bugs (like CleverRaven#47450) and lack of tests, decided writing everything from scratch would save time on bugfixing later.
Testing
Unit tests; tried relics with these enchantments in-game.
Additional context
Using
process_turn()
is likely to collect a lot of global state related failures, but I'd rather keep it, as it makes the tests work close to the "real thing".