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

Refactor aiming UI and its target selection / aim preservation #39785

Merged
merged 48 commits into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
dd72c80
Use separate functions for modes & derive relevant info from arguments
olanti-p Apr 17, 2020
d8bfb43
Pass arguments as class members
olanti-p Apr 17, 2020
949a0f5
Remove duplicate code for window creation, input context setup, setti…
olanti-p Apr 17, 2020
6a0b030
Deduplicate checks fired when npc/monster has been selected as target
olanti-p Apr 17, 2020
3529ad7
Consolidate movement of aim point and center of view
olanti-p Apr 18, 2020
7965e6d
Cache critter under cursor; deduplicate 'set_as_target';
olanti-p Apr 18, 2020
5764f04
Deduplicate and refine 'confirm_non_enemy_target'
olanti-p Apr 18, 2020
e5e1475
Deduplicate and refine target cycling
olanti-p Apr 18, 2020
74cbe45
Extract some variables used by FIRE and SPELL modes
olanti-p Apr 18, 2020
64e9345
Refactor how penalty from moving aim point applies to current aim
olanti-p Apr 18, 2020
b677379
Deduplicate event loop
olanti-p Apr 19, 2020
1625c61
Deduplicate terrain drawing; fix cursor-related visual bug.
olanti-p Apr 19, 2020
fc74251
Refactor drawing of window base and list of controls
olanti-p Apr 19, 2020
304a542
Break up and reorganize rendering of panels inside aiming window
olanti-p Apr 19, 2020
6516d41
Re-implement reloading guns from aiming UI
olanti-p Apr 20, 2020
7a0d7fb
Handle empty gun modes and gun modes with different range
olanti-p Apr 20, 2020
b67a646
Some minor improvements & cleanup
olanti-p Apr 20, 2020
6a0e7b7
Refactored display of vehicle turrets in range;
olanti-p Apr 20, 2020
69c2ec9
Keep 'snap-to-target' state across turns
olanti-p Apr 20, 2020
e5dee87
Refactor target selection; save aim when killing target
olanti-p Apr 20, 2020
7bb5020
Remove old comments
olanti-p Apr 20, 2020
46f2157
Extract window creation and input context setup into function
olanti-p Apr 20, 2020
eca972b
Replace enum TARGET_MODE_* with enum class TargetMode
olanti-p Apr 20, 2020
f394840
Show info about creatures only if player can see them
olanti-p Apr 20, 2020
117918c
Merge branch 'master' into target_ui-as-class
olanti-p Apr 20, 2020
dc93ba3
Update list of targets when range changes
olanti-p Apr 21, 2020
82342c3
Prevent an exploit when firing from monster list
olanti-p Apr 21, 2020
5907ca0
Remove debug output
olanti-p Apr 21, 2020
ca0ea7c
Disable switching aim mode when you can't aim/shoot
olanti-p Apr 21, 2020
80097f3
For compact version, draw over bottom border
olanti-p Apr 21, 2020
a6d5eb2
Invalidate aim point when moving
olanti-p Apr 21, 2020
0a61cb2
Fix player's sprite disappearing when changing Z levels
olanti-p Apr 21, 2020
3e8d092
Appease clang-tidy
olanti-p Apr 21, 2020
b97c960
Merge branch 'master' into target_ui-as-class
olanti-p Apr 21, 2020
1bd24b0
Fix incorrect usage of ui_adaptor::disable_uis_below
olanti-p Apr 22, 2020
9acbb8b
Update src/ranged.cpp
olanti-p Apr 22, 2020
53a4cf4
When extremely short on space, collapse blank lines reserved for target.
olanti-p Apr 22, 2020
661a841
Merge commit 'd1c39eb0d81c202e7a7b69d57988d2c2d9242fa5' into target_u…
olanti-p Apr 30, 2020
1197d21
Migrate '[?] show help' from master
olanti-p Apr 30, 2020
584f058
Dynamically shrink list of controls
olanti-p May 1, 2020
7a6b3d7
Migrate the rest of the changes from master
olanti-p May 1, 2020
327846c
Merge branch 'master' into target_ui-as-class
olanti-p May 1, 2020
7ec443b
Some positioning-related fixes
olanti-p May 1, 2020
d452cac
Remove a duplicate check
olanti-p May 1, 2020
dc64250
Better comments
olanti-p May 1, 2020
5ec7c37
Don't re-confirm attack when aim-and-fire takes multiple turns
olanti-p May 1, 2020
a3073c6
Fix regression related to aim point not snapping to nearest target wh…
olanti-p May 1, 2020
42a145d
Appease clang-tidy
olanti-p May 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Appease clang-tidy
  • Loading branch information
olanti-p committed Apr 21, 2020
commit 3e8d0920fcc6bed99cdeaa101e8bcbecaea924c5
21 changes: 8 additions & 13 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2507,18 +2507,13 @@ bool target_ui::action_aim_and_shoot( player &pc, const std::string &action )
do_aim( pc, relevant ? *relevant : null_item_reference(), min_recoil );
} while( pc.moves > 0 && pc.recoil > aim_threshold && pc.recoil - sight_dispersion > min_recoil );

if( pc.recoil <= aim_threshold ||
pc.recoil - sight_dispersion == min_recoil ||
// if no critter is at dst then sight dispersion does not apply,
// so it would lock into an infinite loop
( !g->critter_at( dst ) && pc.recoil == min_recoil ) ) {
// If we made it under the aim threshold, go ahead and fire.
// Also fire if we're at our best aim level already.
return true;
} else {
// We've run out of moves
return false;
}
// If we made it under the aim threshold, go ahead and fire.
// Also fire if we're at our best aim level already.
// If no critter is at dst then sight dispersion does not apply,
// so it would lock into an infinite loop.
bool done_aiming = pc.recoil <= aim_threshold || pc.recoil - sight_dispersion == min_recoil ||
( !g->critter_at( dst ) && pc.recoil == min_recoil );
return done_aiming;
}

void target_ui::draw( player &pc )
Expand Down Expand Up @@ -2731,7 +2726,7 @@ void target_ui::panel_gun_info( int &text_y )
{
gun_mode m = relevant->gun_current_mode();
std::string mode_name = m.tname();
std::string gunmod_name = "";
std::string gunmod_name;
if( m.target != relevant ) {
// Gun mode comes from a gunmod, not base gun. Add gunmod's name
gunmod_name = m->tname() + " ";
Expand Down
2 changes: 1 addition & 1 deletion src/ranged.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ trajectory mode_turrets( player &pc, vehicle &veh, const std::vector<vehicle_par
/** Casting a spell */
trajectory mode_spell( player &pc, spell &casting, bool no_fail, bool no_mana );
trajectory mode_spell( player &pc, spell_id sp, bool no_fail, bool no_mana );
}
} // namespace target_handler

int range_with_even_chance_of_good_hit( int dispersion );

Expand Down