Display combat win rate - #59
Open
bingyu-893 wants to merge 60 commits into
Open
Conversation
…te application of counter rules. - Introduced a new boolean to manage terrain skipping based on the context of the call, preventing stale data issues from previous computations.
- support dynamic district types - Add details of terrain types to config file
-turn off some features in default.c3x_config.ini -Actually, the line endings are already LF, but in my last commit I made a typo.
This reverts commit 56f08f9.
- Added a new condition to counter_rule that checks the combat_experience of the unit. - This allows for more dynamic and challenging combat scenarios based on the unit's experience level.
-Defensive_bombard and defensive units AT_DEATH now use the correct combat animation.
-Apply unit counter rules directly to defender selection, including army member selection, and rank defenders by combat win chance with current HP and cost as tie-breakers. This keeps cases like damaged low-HP defenders from being chosen over stronger healthy units. -Keep the displayed top defender synchronized with the actual combat defender, including during defensive bombard and death animations. Clear stale combat display overrides after combat, respect excluded units during animation rendering, and preserve normal retreat/start-combat animation behavior.
- add self-bombard/enemy-bombard counter rule percentages - apply bombard strength modifiers to bombard odds and defensive bombard selection - make bombard target selection/display respect bombard counters - prioritize normal combat counter display before bombard counter display outside bombard mode - document new counter rule options and display behavior
# Conflicts: # civ_prog_objects.csv # default.c3x_config.ini # injected_code.c
Restore master-side district, leader, aerodrome, movement, disembark, pedia stats, and quick-build guard logic that had been accidentally removed or rewritten in the unit counter PR. Also revert unrelated config churn for AI patrol, natural wonders, and battle-created unit documentation while preserving the unit counter and bombard counter changes.
-now the hud will show winrate rather than odds -hud will not be hidden behind the war log
-Add WinrateBackground.pcx as the backdrop for the combat odds HUD. -The win rate can be displayed to two decimal places
-- The winrate background size has been adjusted to better fit the new UI layout. -- Additionally, the ignore_terrain now has been set to ingore all defensive bonuses
# Conflicts: # TEST_INJECTED_CODE_COMPILE.bat # default.c3x_config.ini # fix_line_endings.py # injected_code.c
-Removed duplicate auto_zoom_city_screen_for_large_work_areas boolean config entry -The death animation in patch_Fighter_damage_by_db_in_main_loop now calls patch_Animator_play_one_shot_unit_animation -The section on win-chance, HP and cost comparisons in patch_Fighter_prefer_first_defender_1 has been temporarily disabled using `#if 0`.
Use the base visible-unit logic under the counter defender-selection context so normal combat previews match the defender chosen by Fighter_begin. Pass null defenders into the base fight path where safe so the original defender-selection rules, including HP and tie handling, remain authoritative. Keep post-combat and animation display overrides synchronized with the selected defender, and add debug output showing both the preview result and the actual defender. Also route bombard preview display through counter-aware target selection with a base-game fallback so bombard targets stay on top before the action is confirmed.
Simplify unit counter defender selection so C3X no longer reimplements king priority or adjusted-strength comparison in Fighter_prefer_first_defender_1. Instead, compute counter-adjusted strengths and delegate the final defender choice back to the base game logic. Rename the counter rule flag from ignore_terrain to ignore_defensive_bonuses internally and document ignore-defensive-bonuses as the preferred config token, while keeping ignore-terrain as a compatibility alias. Also account for ignored defensive bonuses during defender selection by folding normal defensive bonuses into non-ignored candidates when needed, keeping selection behavior aligned with actual combat odds.
-Drop the temporary defender-selection and display debug buffers, popup output, and related helper functions used while diagnosing unit counter combat display issues. -Also remove the debug-only source reporting from bombard preview selection, leaving the runtime defender selection and display behavior unchanged.
…er unit selection.
Bug 1 (wrong unit): an army displayed a different member than the one actually fighting. Bug 2 (missing HP bar): the HP bar and army indicator sometimes vanished during combat. - Combat: display the containing army (the engine only draws the HP bar and army indicator for the tile's top unit, fixing Bug 2) while pointing army_top_defender_id at the real combatant so the correct sprite renders (Bug 1). Face the shown member toward its opponent to avoid a flicker. - Attacker: in Fighter_begin, set the attacking army's top defender to the counter-selected member before the animation, so it no longer swaps units when the attack starts. - Aiming: in find_visible_unit, preview the would-be attacker when aiming at an adjacent enemy, fixing armies that hadn't yet fought. Add face_unit_toward and tiles_adjacent_for_attack helpers.
# Conflicts: # civ_prog_objects.csv # default.c3x_config.ini
-Mouse-hover previews are no longer permitted during combat animations; instead, the army_top_defender_id of the attacking army is used to prevent the display state from interfering with the actual animation when hovering over A or attacking via the keyboard with B. -Correct the order of the clamp parameters in the army attacker selection to prevent the remaining HP from being incorrectly set to 0.
-Rename the documented config keys to unit_groups and counter_rules while keeping the singular names accepted for compatibility. Remove the custom adjacency and facing helpers in favor of existing map logic, and align counter-rule river crossing checks with the base game's defender-tile behavior. -Also narrow bombard defender previews so units with normal direct attacks do not use bombard-specific defender selection just because a bombard command is available.
…ne mismatched line ending
- add off, compact, and detailed display modes - show cumulative counter effects in the detailed HUD - share counter evaluation between combat logic and HUD - only apply ignore-defensive-bonuses on forward matches - add localized labels and a detailed panel background - update default configuration and changelog
- Bombard damage chance now calls patch_Fighter_get_odds_for_bombardment, so terrain, city/fortress, fortification, army, and counter-rule bonuses are reflected in the displayed damage rate. - Attack HUD defender selection now uses the existing counter-aware selection path (find_counter_base_visible_defender_against) instead of the custom lowest-win-chance heuristic, matching the actual defender the game would use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements a real-time combat win rate display (inspired by Civilization IV) that dynamically computes and displays combat win probabilities directly in the UI.
Key Features & Implementation
Combat Display Modes:
Compact(Default): Displays only the final calculated win rate for a clean, minimal UI.Detailed: Shows the win rate alongside the attacker and defender combat modifiers. To prevent screen clutter, it only displays the final effective modifier and whether defensive bonuses are ignored, rather than listing every individual modifier.Bombardment Hit Chance:
Displays the probability of dealing at least 1 HP of damage.
Design note: Rate-of-fire distributions were intentionally simplified to keep the tooltip readable and avoid cluttering the interface.
UI Behavior
Currently, the odds display box remains persistent on the screen while targeting/active. I initially tested having the overlay appear strictly when hovering over an enemy unit. However, during actual playtesting, the constant pop-in and UI flickering felt visually disruptive.
Do you prefer the persistent box, or would you rather stick to hover-only? Or alternatively, should I expose this as a user-configurable toggle in the settings/config?