diff --git a/README.md b/README.md index 63de63b..a358ae9 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Godot 4 tactical RPG prototype inspired by classic turn-based Romance of the Thr - Pre-battle briefing shows the campaign chapter, chapter battle number, location, victory/defeat summary, and first-clear reward preview. - Pre-battle prep commands use compact icon buttons with active selection state and Korean hover labels for chapters, shop, talks, armory, roster, formation, and save records. - Battle, top-toolbar, and pre-battle command buttons now prefer generated high-resolution bronze/parchment icon art under `art/ui/icons`, with procedural icon drawing kept only as a fallback. +- Battle maps blend generated terrain texture tiles for plains, forests, hills, wasteland, roads, water, villages, and castles over the high-resolution battlefield backdrop. - Core UI panels now use a calmer ink/wood/jade palette with softer rounded corners and lighter button frames instead of the earlier yellow, hard-edged frame treatment. - Pre-battle Chapters overview shows story-arc progress with map thumbnail rows, compact status badges, hover details, and can open completed or current battles. - Pre-battle Save menu can write and load one manual campaign checkpoint separate from the automatic save, using compact seal-style slot rows and hover checkpoint details. @@ -129,7 +130,7 @@ Godot 4 tactical RPG prototype inspired by classic turn-based Romance of the Thr - Victory and defeat result overlay. - Dialogue portrait slot stays fixed across speaker and narration lines, with officer default image paths, optional per-line overrides, and speaker-initial or record fallback. - Initial AI-generated photorealistic officer portraits for Cao Cao, Xiahou Dun, Xiahou Yuan, Cao Ren, Dian Wei, Guo Jia, and Zhang He. -- AI-generated scenario battlefield backgrounds, opening story panels, transparent class units, transparent generic-enemy units, item icons, and toolbar UI icons live under `art/backgrounds`, `art/story`, `art/units`, `art/items`, and `art/ui/icons`. +- AI-generated scenario battlefield backgrounds, opening story panels, terrain textures, transparent class units, transparent generic-enemy units, item icons, and toolbar UI icons live under `art/backgrounds`, `art/story`, `art/terrain`, `art/units`, `art/items`, and `art/ui/icons`. - Battle HUD portrait thumbnails show the selected unit, or a hovered unit when nothing is selected. - Selected and hovered unit focus text shows combat role, movement type, current terrain move cost, terrain bonuses, core stats, and status effects. - Dialogue lines can mark speaking side for text alignment inside a fixed visual-novel-style dialogue panel with stable portrait, progress, and previous-line controls. @@ -149,7 +150,7 @@ Godot 4 tactical RPG prototype inspired by classic turn-based Romance of the Thr 2. Open this folder as a Godot project. 3. Run the project. The main scene is `res://scenes/battle_scene.tscn`. -Campaign order and chapter ranges live at `res://data/campaign/campaign.json`. Scenarios live under `res://data/scenarios/`, with reusable officers, classes, items, skills, and terrain definitions under `res://data/defs/`. Generated visual assets live under `res://art/portraits/`, `res://art/units/`, `res://art/items/`, and `res://art/backgrounds/`. Placeholder BGM and SFX live under `res://audio/`. +Campaign order and chapter ranges live at `res://data/campaign/campaign.json`. Scenarios live under `res://data/scenarios/`, with reusable officers, classes, items, skills, and terrain definitions under `res://data/defs/`. Generated visual assets live under `res://art/portraits/`, `res://art/units/`, `res://art/items/`, `res://art/terrain/`, `res://art/ui/`, and `res://art/backgrounds/`. Placeholder BGM and SFX live under `res://audio/`. Data files and item icon cutouts can be checked with `powershell -NoProfile -ExecutionPolicy Bypass -File tools\validate_data.ps1`. diff --git a/art/terrain/terrain_c.png b/art/terrain/terrain_c.png new file mode 100644 index 0000000..a9f12c7 Binary files /dev/null and b/art/terrain/terrain_c.png differ diff --git a/art/terrain/terrain_d.png b/art/terrain/terrain_d.png new file mode 100644 index 0000000..ff79b11 Binary files /dev/null and b/art/terrain/terrain_d.png differ diff --git a/art/terrain/terrain_f.png b/art/terrain/terrain_f.png new file mode 100644 index 0000000..4a1dab8 Binary files /dev/null and b/art/terrain/terrain_f.png differ diff --git a/art/terrain/terrain_g.png b/art/terrain/terrain_g.png new file mode 100644 index 0000000..30fb196 Binary files /dev/null and b/art/terrain/terrain_g.png differ diff --git a/art/terrain/terrain_h.png b/art/terrain/terrain_h.png new file mode 100644 index 0000000..aaca20b Binary files /dev/null and b/art/terrain/terrain_h.png differ diff --git a/art/terrain/terrain_r.png b/art/terrain/terrain_r.png new file mode 100644 index 0000000..2710659 Binary files /dev/null and b/art/terrain/terrain_r.png differ diff --git a/art/terrain/terrain_t.png b/art/terrain/terrain_t.png new file mode 100644 index 0000000..f057678 Binary files /dev/null and b/art/terrain/terrain_t.png differ diff --git a/art/terrain/terrain_w.png b/art/terrain/terrain_w.png new file mode 100644 index 0000000..12432a8 Binary files /dev/null and b/art/terrain/terrain_w.png differ diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 8fe3159..b2c56fa 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -62,7 +62,7 @@ Joined officers gate whether `requires_joined` player deployments are loaded at Inventory and campaign flags are copied from `CampaignState` into `BattleState` when a scenario starts. The pre-battle Chapters overview reads `CampaignState` chapter progress and can load completed or current battles without mutating the save. Briefings preview first-clear rewards, can expose `briefing.camp_conversations` through a selectable Talk menu with `briefing.camp_dialogue` as a fallback, can filter those conversations by saved campaign flags, can claim saved one-time camp conversation supply effects through `CampaignState` and refresh the loaded battle inventory copy, and show completed replay rewards as already claimed. The pre-battle Save menu can write the current campaign state to `user://campaign_manual_save.json`, and loading that checkpoint restores it into `user://campaign_save.json` before re-entering the same pending-choice, completion, or current-briefing branch as startup. Pre-battle shop stock comes from the loaded scenario's `shop.items` list plus matching `shop.conditional_items` blocks, with optional finite limits from item entries or `stock` maps, and `shop.merchant` lines are presentation-only camp flavor. Shop purchases and 50% sell-back are campaign transactions: they update saved gold, unequipped inventory, and finite-stock purchase counts immediately, write the save file, and refresh the already-loaded battle inventory before the player begins the battle. Camp conversation supply claims are also campaign transactions: they save a per-scenario conversation claim ledger and inventory immediately, then refresh the already-loaded battle inventory. Pre-battle Armory equipment changes use the same equipment rules as battle HUD equipment changes, then immediately save merged roster equipment/stat snapshots and inventory stock. Pre-battle Roster uses scenario `roster.max_units`, `roster.required_officers`, and `roster.required_units` to mark optional player deployments as sortie or reserve; reserve units remain in the candidate list but are excluded from board occupancy, drawing, selection, AI targeting, and living-unit victory checks. Non-controllable player units can act as protected escort targets: enemies can attack them and conditions can reference them, but they are skipped by player selection, Armory, Formation, counterattacks, and campaign roster progression snapshots when `persist_progression` is false. Scenario `ai_target_priority` nudges enemy movement and damage-skill scoring toward important targets such as envoys without overriding defeat bonuses or range checks, and `set_ai_target_priority` events can retune that battle-only pressure after an ambush, gate closure, or escort exposure. Pre-battle Formation uses the loaded scenario's `formation.cells` and only mutates current battle unit positions before battle-begin events fire. Destination victory cells from `unit_reaches_tile` conditions are exposed to the scene for objective overlays and tile info, and can be expressed as one `pos` or a multi-cell `cells` list; gated victory conditions can also expose the `unit_reaches_tile` event that unlocks them as the next visible objective marker. Rewarding movement events that grant items or gold can expose optional battlefield side markers and Korean tile-info labels through `when.label`, without being treated as victory objectives. Movement-triggered `unit_reaches_tile` events receive the unit that just moved, so ambushes and pickup events fire on entry rather than from units already standing on a marker; `unit_defeated` events receive the fallen unit before final victory/defeat checks, allowing named-officer reactions and last-moment reinforcements. Briefing data can append matching `briefing.conditional_lines`, and scenario events can use `when.campaign_flags` to branch dialogue, objective changes, item and gold pickups, AI target-priority shifts, and reinforcements from saved campaign choices or `when.after_event` to wait for earlier scenario beats. Consumable use can restore HP or MP, cure matching poison/seal/snare/disarm statuses, or cleanse negative stat debuffs, and in-battle item use, event pickup grants, event gold pickups, plus equipment swaps mutate only the battle copy until victory; defeats and restarts do not spend saved items, keep picked-up items or gold, or preserve in-battle gear changes. Post-battle choices write campaign `flags` only after the result-panel button is pressed; if the player reloads after rewards are saved but before selecting, the pending scenario id restores the victory choice panel without replaying rewards. The next battle button stays locked until the campaign choice save succeeds. Equipment rewards share the same `item_id -> count` inventory stock, cover weapon, armor, and accessory slots, can be equipped from the side HUD before the selected unit moves or acts, and do not appear in the consumable action menu. Named equipment currently uses the same stock model with a presentation-only rarity tag rather than unique item instances. Already completed scenarios can be replayed without granting duplicate rewards, choices, replay inventory consumption, event gold pickups, save writes, current-scenario advancement, finite-stock purchases, or camp conversation supply claims; pre-battle Shop, Armory, Roster, Formation, and Save are disabled on completed-scenario replays to avoid side effects. -The battle scene owns presentation feedback: briefing and result states use menu BGM, briefing headers combine `CampaignState` chapter ranges, campaign order, and title data with `BattleState` briefing, objective text, condition-progress text, and defeat-risk text, active battles use battle BGM and show an objective/progress/risk panel fed by `BattleState`, objective-update signals show a short HUD notice and refresh the objective panel immediately, dialogue lines can show optional cached portrait textures or speaker-initial fallback panels in an expanded visual-novel-style panel, keep the portrait slot fixed even for narration lines, mark speaking side through text alignment, and expose progress plus previous-line controls while a sequence is open, the side HUD reuses cached officer portrait textures or class sprites for the selected unit or hovered unit and formats focus text with role, movement type, facing, current terrain move cost, defense/avoid bonuses, core stats, status effects, guard-zone AI hints, and gear, board maps can draw a scenario background texture under translucent terrain overlays, connected road segments, terrain detail patterns, shoreline/castle/forest/hill edge blends, compact recovery markers for healing terrain, compact side-event markers for visible item/gold pickups, and move-attack target badges for enemies that can be struck after movement, board units render class sprite tokens or generic-enemy transparent class cutouts, team rings, facing markers, generic-enemy marks, officer pins, low-HP warning rings, HP bar color states, active support/debuff/poison/seal/snare/disarm status pips, and a scene-clocked idle stance whose intensity reacts to selected, acted, and low-HP unit state, item buttons can show optional cached item icons, hover previews are rendered as target badges from existing `BattleState` forecast APIs and include compact side/rear attack bonuses when facing matters, equipment option menus show stat/range/effect deltas, result and inventory summaries show named equipment with compact rarity tags, selected area tactics highlight their affected cells, the Threat toggle overlays enemy physical and hostile tactic reach while tile info names threat sources, estimates physical damage, and summarizes hostile tactic damage or status effects against occupied cells, log/result hooks trigger placeholder SFX, support, debuff, poison, seal, snare, disarm, objective updates, AI target-focus changes, and item/gold pickup effects use distinct feedback, `BattleState.unit_motion_requested` asks the scene to interpolate a unit's draw position during movement, `BattleState.unit_action_motion_requested` keeps its rules-facing signal shape while the scene maps attacker class ids to infantry, archer, cavalry, command, and heavy attack presentation profiles, and `BattleState.combat_feedback_requested` asks the scene to draw transient floating combat text without changing battle rules. +The battle scene owns presentation feedback: briefing and result states use menu BGM, briefing headers combine `CampaignState` chapter ranges, campaign order, and title data with `BattleState` briefing, objective text, condition-progress text, and defeat-risk text, active battles use battle BGM and show an objective/progress/risk panel fed by `BattleState`, objective-update signals show a short HUD notice and refresh the objective panel immediately, dialogue lines can show optional cached portrait textures or speaker-initial fallback panels in an expanded visual-novel-style panel, keep the portrait slot fixed even for narration lines, mark speaking side through text alignment, and expose progress plus previous-line controls while a sequence is open, the side HUD reuses cached officer portrait textures or class sprites for the selected unit or hovered unit and formats focus text with role, movement type, facing, current terrain move cost, defense/avoid bonuses, core stats, status effects, guard-zone AI hints, and gear, board maps can draw a scenario background texture under translucent terrain overlays, generated terrain texture tiles, connected road segments, terrain detail patterns, shoreline/castle/forest/hill edge blends, compact recovery markers for healing terrain, compact side-event markers for visible item/gold pickups, and move-attack target badges for enemies that can be struck after movement, board units render class sprite tokens or generic-enemy transparent class cutouts, team rings, facing markers, generic-enemy marks, officer pins, low-HP warning rings, HP bar color states, active support/debuff/poison/seal/snare/disarm status pips, and a scene-clocked idle stance whose intensity reacts to selected, acted, and low-HP unit state, item buttons can show optional cached item icons, hover previews are rendered as target badges from existing `BattleState` forecast APIs and include compact side/rear attack bonuses when facing matters, equipment option menus show stat/range/effect deltas, result and inventory summaries show named equipment with compact rarity tags, selected area tactics highlight their affected cells, the Threat toggle overlays enemy physical and hostile tactic reach while tile info names threat sources, estimates physical damage, and summarizes hostile tactic damage or status effects against occupied cells, log/result hooks trigger placeholder SFX, support, debuff, poison, seal, snare, disarm, objective updates, AI target-focus changes, and item/gold pickup effects use distinct feedback, `BattleState.unit_motion_requested` asks the scene to interpolate a unit's draw position during movement, `BattleState.unit_action_motion_requested` keeps its rules-facing signal shape while the scene maps attacker class ids to infantry, archer, cavalry, command, and heavy attack presentation profiles, and `BattleState.combat_feedback_requested` asks the scene to draw transient floating combat text without changing battle rules. Large tactical maps are presented through a fixed visible map window rather than by shrinking the whole board, including the opening chapter-one battle. `BattleScene` keeps a clamped `board_scroll_offset`, scrolls the board while the mouse is near or slightly outside the visible map edge, brightens the scrollable frame edge under the cursor, ignores board clicks outside the visible map window, and draws a small minimap plate only when the board actually exceeds the visible map view; the minimap shows terrain, unit dots, objective seals, and side-event markers, and clicking or dragging it recenters the tactical viewport, while compact maps keep the lower-right tiles unobstructed. Board-attached command panels are repositioned after map scrolling so post-move choices stay beside the moved unit. Battle start focuses the board on the deployed player group, pre-battle Formation can focus the board on the selected unit even before the battle opens, and action feedback can focus the board on off-screen cells before motion or combat effects play. diff --git a/scripts/scenes/battle_scene.gd b/scripts/scenes/battle_scene.gd index 7de202c..544fd19 100644 --- a/scripts/scenes/battle_scene.gd +++ b/scripts/scenes/battle_scene.gd @@ -29,6 +29,7 @@ const BGM_BATTLE_PATH := "res://audio/bgm/battle_loop_placeholder.wav" const TITLE_BACKGROUND_PATH := "res://art/backgrounds/title_war_camp_dawn.png" const TITLE_PORTRAIT_PATH := "res://art/portraits/cao_cao.png" const TOOLBAR_ICON_PATH_TEMPLATE := "res://art/ui/icons/toolbar_%s.png" +const TERRAIN_TEXTURE_PATH_TEMPLATE := "res://art/terrain/terrain_%s.png" const OPENING_PROLOGUE_REBELLION_PATH := "res://art/story/opening/yellow_turban_rebellion.png" const OPENING_PROLOGUE_RESOLVE_PATH := "res://art/story/opening/cao_cao_resolves.png" const OPENING_PROLOGUE_XIAHOU_DUN_PATH := "res://art/story/opening/xiahou_dun_joins.png" @@ -4366,6 +4367,7 @@ func _draw_map() -> void: var rect := _rect_for_cell(cell) var terrain_key := state.get_terrain_key(cell) draw_rect(rect, _terrain_fill_color(cell, terrain_key, has_background)) + _draw_terrain_texture(cell, rect, terrain_key, has_background) _draw_terrain_detail(cell, rect, terrain_key) _draw_terrain_edge_blend(cell, rect, terrain_key) draw_rect(rect, _map_grid_color(has_background), false, 1.0) @@ -4755,6 +4757,35 @@ func _map_grid_color(has_background: bool) -> Color: return color +func _draw_terrain_texture(cell: Vector2i, rect: Rect2, terrain_key: String, has_background: bool) -> void: + var texture := _load_terrain_texture(terrain_key) + if texture == null: + return + var modulate := _terrain_texture_modulate(cell, terrain_key, has_background) + draw_texture_rect(texture, rect.grow(-1.0), false, modulate) + + +func _load_terrain_texture(terrain_key: String) -> Texture2D: + var normalized_key := terrain_key.strip_edges().to_lower() + if normalized_key.is_empty(): + return null + return _load_art_texture(TERRAIN_TEXTURE_PATH_TEMPLATE % normalized_key) + + +func _terrain_texture_modulate(cell: Vector2i, terrain_key: String, has_background: bool) -> Color: + var alpha := 0.17 if has_background else 0.58 + if terrain_key == "W": + alpha += 0.07 if has_background else 0.10 + elif terrain_key == "C" or terrain_key == "T": + alpha += 0.08 if has_background else 0.12 + elif terrain_key == "R": + alpha += 0.05 if has_background else 0.08 + elif terrain_key == "F" or terrain_key == "H" or terrain_key == "D": + alpha += 0.03 if has_background else 0.06 + alpha *= 0.94 + _cell_noise(cell, 137) * 0.12 + return Color(1.0, 1.0, 1.0, clampf(alpha, 0.0, 0.82)) + + func _draw_terrain_detail(cell: Vector2i, rect: Rect2, terrain_key: String) -> void: if terrain_key == "G": for index in range(3): diff --git a/tools/smoke_visual_assets.gd b/tools/smoke_visual_assets.gd index bff16a2..4266903 100644 --- a/tools/smoke_visual_assets.gd +++ b/tools/smoke_visual_assets.gd @@ -92,6 +92,7 @@ func _init() -> void: var failures: Array[String] = [] _check_battle_visual_data(failures) _check_generated_toolbar_icons(failures) + _check_generated_terrain_textures(failures) _check_scene_texture_loading(failures) _check_hud_focus_text(failures) _check_ancient_ui_theme(failures) @@ -2976,6 +2977,12 @@ func _check_generated_toolbar_icons(failures: Array[String]) -> void: _check_toolbar_icon_path(failures, "res://art/ui/icons/toolbar_%s.png" % icon_kind, "toolbar icon %s" % icon_kind) +func _check_generated_terrain_textures(failures: Array[String]) -> void: + var terrain_keys := ["g", "f", "h", "d", "r", "w", "t", "c"] + for terrain_key in terrain_keys: + _check_terrain_texture_path(failures, "res://art/terrain/terrain_%s.png" % terrain_key, "terrain texture %s" % terrain_key) + + func _check_scene_texture_loading(failures: Array[String]) -> void: var scene = BattleSceneScript.new() if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"): @@ -4293,6 +4300,17 @@ func _check_terrain_and_unit_presentation(failures: Array[String]) -> void: var wasteland_fill: Color = scene._terrain_fill_color(Vector2i(0, 0), "D", true) if wasteland_fill.a <= background_fill.a: failures.append("wasteland fill should sit slightly above grass over background art") + if scene._load_terrain_texture("G") == null or scene._load_terrain_texture("T") == null or scene._load_terrain_texture("C") == null: + failures.append("battle map should load generated terrain texture assets") + var grass_texture_modulate := scene._terrain_texture_modulate(Vector2i(0, 0), "G", true) + var grass_fallback_modulate := scene._terrain_texture_modulate(Vector2i(0, 0), "G", false) + var castle_texture_modulate := scene._terrain_texture_modulate(Vector2i(20, 1), "C", true) + if grass_texture_modulate.a <= 0.0 or grass_texture_modulate.a >= 0.35: + failures.append("background terrain texture should stay subtle over high-res art: %s" % str(grass_texture_modulate)) + if grass_fallback_modulate.a <= grass_texture_modulate.a: + failures.append("fallback terrain texture should be stronger without map background") + if castle_texture_modulate.a <= grass_texture_modulate.a: + failures.append("castle terrain texture should read stronger than plain grass") if scene._terrain_edge_color("D", "G").a <= 0.0: failures.append("wasteland edge blend should be visible") if scene._terrain_edge_priority("D") <= scene._terrain_edge_priority("R"): @@ -4825,6 +4843,36 @@ func _check_toolbar_icon_path(failures: Array[String], path: String, context: St failures.append("%s icon should not keep chroma-key green pixels: %s (%d sampled)" % [context, path, green_fringe_samples]) +func _check_terrain_texture_path(failures: Array[String], path: String, context: String) -> void: + if path.is_empty(): + failures.append("%s has an empty texture path" % context) + return + if not path.begins_with("res://"): + failures.append("%s must use a res:// path: %s" % [context, path]) + return + if not FileAccess.file_exists(path): + failures.append("%s references missing texture: %s" % [context, path]) + return + var image := Image.new() + var err := image.load(path) + if err != OK: + failures.append("%s references unreadable texture: %s" % [context, path]) + return + if image.get_width() < 128 or image.get_height() < 128: + failures.append("%s should keep high-resolution terrain source pixels: %s (%dx%d)" % [context, path, image.get_width(), image.get_height()]) + return + var min_luma := 999.0 + var max_luma := -999.0 + for y in range(0, image.get_height(), 16): + for x in range(0, image.get_width(), 16): + var pixel := image.get_pixel(x, y) + var luma := pixel.r * 0.299 + pixel.g * 0.587 + pixel.b * 0.114 + min_luma = minf(min_luma, luma) + max_luma = maxf(max_luma, luma) + if max_luma - min_luma < 0.08: + failures.append("%s should contain visible generated terrain texture variation: %s" % [context, path]) + + func _check_image_path(failures: Array[String], path: String, context: String) -> void: if path.is_empty(): failures.append("%s has an empty image path" % context)