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

feat(balance): uncanny dodge can now actually roll to dodge bullets #4125

Merged
merged 6 commits into from
Jun 24, 2024

Conversation

chaosvolt
Copy link
Member

@chaosvolt chaosvolt commented Jan 18, 2024

Purpose of change

closes #4139

This finally makes the description for Uncanny Dodge CBM no longer misleading. This now allows you to actually dodge bullets when shot at while using it. In exchange however it no longer works flawlessly 100% of the time, instead it will either dodge based on your skill, falling back on a limited number of dodges per turn based on dodges per turn.

Describe the solution

C++ changes:

  1. In character_functions.cpp, changed try_uncanny_dodge so that it no longer moves you around, and instead performs a two-part check. First, checks the user's effective dodge level (including effects of encumbrance, mutations, etc) so that dodge skill actually matters for this, and if so the attack is dodged completely for free. If not, you only get a dodge if you have dodges left that turn, if not then you take a hit as you would if out of power. Moving around was found to be less than ideal during further testing, as it jitters you around erratically and negates an entire burst of enemy fire when it triggers, preventing the "can overwhelm the user with more dakka" concept from working right.
  2. In ranged.cpp, set Creature::ranged_target_size so that a character triggering a successful application of Uncanny Dodge returns as being impossible to hit. The main consequence of this is that, based on your dodging ability, you can now indeed dodge bullets and not just specific hardcoded monster attacks.

JSON changes:

  1. Reworded description of Uncanny Dodge to hint that dodging ability affects this, and added an enchantment designed to grant a bonus to effective dodge.
  2. Defined enchantment and an enchantment mutation, that makes it so having Uncanny Dodge active grants a +2 bonus to effective dodge rating. This is since the CBM doesn't actually give you any hardcoded benefit in melee, and so you get a slight advantage when rolling to dodge incoming fire. It uses a (hidden from player display) mutation instead of value because BONUS_DODGE actually grants bonus dodge attempts like martial art buffs, enchantment values can't directly mess with effective dodge currently.
  3. Also updated description of item form for consistency.

Describe alternatives you've considered

  1. Keeping the 100% chance of success when faced with all ranged attacks, making Uncanny Dodge full-on Matrix mode so long as the target has power.
  2. Changing BONUS_DODGE so it applies to effective dodge and not dodge attempts, so we don't have to use the hacky solution of a hidden mutation.
  3. Merging feat(balance): uncanny dodge can now ninja roll to dodge bullets #4139 instead. I really didn't like the idea of magic ninja smoke as a hack for limiting dodges in an area, and it turns out move-dodge itself completely negates moar dakka anyway so it's not ideal in my opinion. The RNG factor that was the primary flaw in this PR should be less of an issue now that skill is only checked for the sake of seeing if the player gets to dodge for free, and will always dodge so long as they have dodges that turn (meaning you can overwhelm Uncanny Dodge with burst fire or other overwhelming force, but bonus dodges from martial arts also benefit it).

Testing

  1. Checked affected JSON files for syntax and lint errors.
  2. Compiled and load-tested.
  3. Debugged myself up with a CBM setup to run Uncanny Dodge.
  4. Checked @ screen, activating the CBM has dodge go from 3.0/0 to 5.0/0.
  5. Spawned a turret and let it shoot me, correct messages occur and if I fail the roll repeatedly under burst fire I take hits.
  6. Checked affected C++ files for astyle.

Additional context

image

DDA's workaround for this problem was to just remove the mention of dodging bullets from the CBM description, PR done by @sonphantrung: CleverRaven/Cataclysm-DDA#59733

Checklist

@github-actions github-actions bot added src changes related to source code. JSON related to game datas in JSON format. labels Jan 18, 2024
@@ -602,7 +602,7 @@ bool try_uncanny_dodge( Character &who )
bool is_u = who.is_avatar();
bool seen = is_u || get_player_character().sees( who );
std::optional<tripoint> adjacent = pick_safe_adjacent_tile( who );
if( adjacent ) {
if( adjacent && x_in_y( who.get_dodge(), 10 ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way you don't get to just dodge infinite bullets for free

I think it's a bit unfair, as

  • dodging consumes huge amount of electric charges
  • you may waste huge amount of electric charges and still fail
  • it introduces rng to uncanny dodge, which taints Creature::ranged_target_size. this might make debugging it harder.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As already written it was already set up so if you had no space to dodge it would automatically fail and waste charges, so only real break with consistency is it becoming based on your dodge skill.

@@ -532,6 +532,9 @@ static double occupied_tile_fraction( m_size target_size )

double Creature::ranged_target_size() const
{
if( const_cast<Creature &>( *this ).uncanny_dodge() ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should avoid using const_cast because this breaks the promise that Creature::ranged_target_size() const will never modify itself (hence const).

we should probably separate uncanny_dodge into "check if it's possible to uncanny dodge" and "actually do uncanny dodge".

@chaosvolt
Copy link
Member Author

After some discussion about it on the discord last night and thinking on it, closing in favor of #4139

@chaosvolt chaosvolt closed this Jan 20, 2024
@chaosvolt
Copy link
Member Author

Aight, after some tinkering with it, I eventually decided it's maybe reasonable to reopen this and see which is a better method. The new method no longer just lets you get hit purely based off RNG, instead:

  1. Effective dodge rating is used to determine if you get to dodge a special attack or ranged attack at no penalty. Rigged such that a basic character has a 50% chance to succeed here at zero skill but no encumbrance, could nerf it if desired though.
  2. If the roll fails, then dodge anyway but doing so burns one of your dodges for that turn. This is fine if you're not also getting attacked in melee or taking multiple shots that turn, but if you are...
  3. If you're out of bonus dodges that turn, you get hit outright, dodge skill or no (since get_dodge will return zero if you're out of dodges).

Idea is that the bionic lets you casually wade through individual shots so long as that's all you're dealing with, but taking on a whole firing squad or mixing it up with enemies in melee while being shot at requires higher skill to pull off, and more dakka can potentially overwhelm you. But as a benefit, it pairs well with any martial arts, enchantments, etc that grant bonus dodges by giving you increased breathing room if those rolls fail.

@chaosvolt chaosvolt reopened this Jun 23, 2024
Copy link
Contributor

autofix-ci bot commented Jun 23, 2024

Autofix has formatted code style violation in this PR.

I edit commits locally (e.g: git, github desktop) and want to keep autofix
  1. Run git pull. this will merge the automated commit into your local copy of the PR branch.
  2. Continue working.
I do not want the automated commit
  1. Format your code locally, then commit it.
  2. Run git push --force to force push your branch. This will overwrite the automated commit on remote with your local one.
  3. Continue working.

If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT.

@chaosvolt chaosvolt requested review from Coolthulhu and scarf005 June 24, 2024 07:31
Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like to revisit on physically dodging with cool vfx but that's for another day...

@chaosvolt chaosvolt merged commit 8c0dd4a into cataclysmbnteam:main Jun 24, 2024
13 checks passed
@chaosvolt chaosvolt deleted the this-is-a-touhou-game-now branch June 24, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSON related to game datas in JSON format. src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants