diff --git a/.gitignore b/.gitignore index b7052d36..3a67e9b0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ data_*/ # VS Code .vscode/ + +haldric.dmg diff --git a/ai/ActionAI.gd b/ai/ActionAI.gd index 862b7ebe..89c67a69 100644 --- a/ai/ActionAI.gd +++ b/ai/ActionAI.gd @@ -1,5 +1,4 @@ -extends AI -class_name ActionAI +extends AI signal attacks_finished() signal scouting_finished() diff --git a/ai/SimpleAI.gd b/ai/SimpleAI.gd index dbba36b1..8891bbb2 100644 --- a/ai/SimpleAI.gd +++ b/ai/SimpleAI.gd @@ -1,5 +1,4 @@ extends AI -class_name SimpleAI enum State { NONE, RECRUIT, CAPTURE_VILLAGES, ATTACK, RETREAT } enum UnitState { NONE, HEAL, SCOUT, ATTACK, STANDBY } diff --git a/data/advancements/Default.tscn b/data/advancements/Default.tscn index 25f9d926..b9f5ce02 100644 --- a/data/advancements/Default.tscn +++ b/data/advancements/Default.tscn @@ -1,19 +1,6 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=2 format=2] -[ext_resource path="res://source/unit/effect/EffectAttribute.gd" type="Script" id=1] -[ext_resource path="res://source/unit/advancement/Advancement.gd" type="Script" id=2] +[ext_resource path="res://source/unit/advancement/DefaultAdvancement.gd" type="Script" id=1] [node name="Default" type="Node"] -script = ExtResource( 2 ) -alias = "Default" -description = "+ 3 HP -+ 20 % XP" - -[node name="Health" type="Node" parent="."] -script = ExtResource( 1 ) -add = 3 - -[node name="Experience" type="Node" parent="."] script = ExtResource( 1 ) -attribute = "experience" -multiply = 1.2 diff --git a/data/terrain.gd b/data/terrain.gd index 8f280d66..1b164e43 100644 --- a/data/terrain.gd +++ b/data/terrain.gd @@ -16,7 +16,7 @@ func _load() -> void: new_base("Snow", "Aa", -40, ["frozen"], "frozen/snow") new_base("Swamp", "Ss", -90, ["swamp"], "swamp/water") new_base("Water", "Ww", -100, ["deep_water"], "water/animated") - new_base("Coastal Reef", "Wwrg", -100, ["water"], "water/animated") + new_base("Coastal Reef", "Wwrg", -100, ["coastal_reef"], "water/animated") new_base("Mud", "Sm", -110, ["swamp"], "swamp/mud") new_base("Mountains", "Mm", 200, ["mountains"], "mountains/basic", Vector2(-56, -68)) diff --git a/project.godot b/project.godot index 6096aebf..eb866bb3 100644 --- a/project.godot +++ b/project.godot @@ -24,11 +24,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://source/unit/ability/AbilityHeal.gd" }, { -"base": "AI", -"class": "ActionAI", -"language": "GDScript", -"path": "res://ai/ActionAI.gd" -}, { "base": "Control", "class": "ActionButton", "language": "GDScript", @@ -139,6 +134,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://source/global/DebugDraw.gd" }, { +"base": "Advancement", +"class": "DefaultAdvancement", +"language": "GDScript", +"path": "res://source/unit/advancement/DefaultAdvancement.gd" +}, { "base": "Node", "class": "DefenseType", "language": "GDScript", @@ -179,11 +179,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://source/unit/effect/EffectDamage.gd" }, { -"base": "Effect", -"class": "EffectUnitType", -"language": "GDScript", -"path": "res://source/unit/effect/EffectUnitType.gd" -}, { "base": "Reference", "class": "Events", "language": "GDScript", @@ -344,11 +339,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://source/interface/game/SideUI.gd" }, { -"base": "AI", -"class": "SimpleAI", -"language": "GDScript", -"path": "res://ai/SimpleAI.gd" -}, { "base": "Node", "class": "Skill", "language": "GDScript", @@ -539,6 +529,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://source/unit/unit_type/UnitType.gd" }, { +"base": "Advancement", +"class": "UnitTypeAdvancement", +"language": "GDScript", +"path": "res://source/unit/advancement/UnitTypeAdvancement.gd" +}, { "base": "Control", "class": "UnitUI", "language": "GDScript", @@ -553,7 +548,6 @@ _global_script_class_icons={ "AI": "", "Ability": "", "AbilityHeal": "", -"ActionAI": "", "ActionButton": "", "ActionDialogue": "", "AdvancemenOption": "", @@ -576,6 +570,7 @@ _global_script_class_icons={ "Commander": "", "CreateUnitCommand": "", "DebugDraw": "", +"DefaultAdvancement": "", "DefenseType": "", "Dialogue": "", "Dialogues": "", @@ -584,7 +579,6 @@ _global_script_class_icons={ "Effect": "", "EffectAttribute": "", "EffectDamage": "", -"EffectUnitType": "", "Events": "", "FactionData": "", "FactionSelectionPlayerEntry": "", @@ -617,7 +611,6 @@ _global_script_class_icons={ "Selector": "", "Side": "", "SideUI": "", -"SimpleAI": "", "Skill": "", "SkillButton": "", "SkillDamage": "", @@ -656,6 +649,7 @@ _global_script_class_icons={ "UnitRecallInfo": "", "UnitRecruitInfo": "", "UnitType": "", +"UnitTypeAdvancement": "", "UnitUI": "", "WeaponSpecial": "" } @@ -685,6 +679,10 @@ window/dpi/allow_hidpi=true window/stretch/mode="2d" window/stretch/aspect="expand" +[gui] + +theme/use_hidpi=true + [importer_defaults] texture={ diff --git a/source/data/ScenarioData.gd b/source/data/ScenarioData.gd index 68ba2a7d..20c10057 100644 --- a/source/data/ScenarioData.gd +++ b/source/data/ScenarioData.gd @@ -8,4 +8,6 @@ export var alias := "" export var scene : PackedScene = null export var map : Resource = null +export var show = true + export (ScenarioType) var type := ScenarioType.SCENARIO; diff --git a/source/game/Game.gd b/source/game/Game.gd index 4495655d..b3701f54 100644 --- a/source/game/Game.gd +++ b/source/game/Game.gd @@ -48,6 +48,9 @@ func _unhandled_input(event: InputEvent) -> void: if scenario.current_side.can_recruit(): UI.show_recall_dialogue(scenario.current_side, null) + elif event.is_action_pressed("end_turn") and scenario.done: + scenario.end_scenario() + elif event.is_action_pressed("end_turn") and not selected_unit and not scenario.is_side_moving: scenario.end_turn() @@ -198,6 +201,10 @@ func _on_GameUI_end_turn_pressed() -> void: if scenario.is_side_moving: return + if scenario.done: + scenario.end_scenario() + return + _set_selected_unit(null) scenario.end_turn() diff --git a/source/global/Console.gd b/source/global/Console.gd index e2766363..31859aec 100644 --- a/source/global/Console.gd +++ b/source/global/Console.gd @@ -27,7 +27,7 @@ func warn(text: String) -> void: func _add_line(text: String) -> void: lines.append(text) - if lines.size() > 12: + if lines.size() > 24: lines.pop_front() diff --git a/source/global/Data.gd b/source/global/Data.gd index acbc1326..e663fba1 100644 --- a/source/global/Data.gd +++ b/source/global/Data.gd @@ -32,7 +32,6 @@ func scan() -> void: _load_scenarios() _load_ais() - func add_terrain(terrain: TerrainData) -> void: terrains[terrain.code] = terrain @@ -102,9 +101,7 @@ func _load_scenarios() -> void: func _load_ais() -> void: - AIs.clear() - - for file_data in Loader.load_dir("res://ai", [ "gd" ]): + for file_data in Loader.load_dir("res://ai", [ "gd", "gdc" ]): AIs[file_data.id] = file_data.data print(AIs) diff --git a/source/global/Loader.gd b/source/global/Loader.gd index c196444e..a2ce65ab 100644 --- a/source/global/Loader.gd +++ b/source/global/Loader.gd @@ -29,6 +29,7 @@ static func _get_directory_data(path: String, directory_data: Array, extentions: elif directory.current_is_dir(): directory_data = _get_directory_data(directory.get_current_dir() + "/" + sub_path, directory_data, extentions, load_resource) else: + sub_path = sub_path.replace(".import", "") if not extentions.has(sub_path.get_extension()): continue diff --git a/source/interface/game/advancement/UnitAdvancementInfo.gd b/source/interface/game/advancement/UnitAdvancementInfo.gd index 326f30d4..46baf1ec 100644 --- a/source/interface/game/advancement/UnitAdvancementInfo.gd +++ b/source/interface/game/advancement/UnitAdvancementInfo.gd @@ -13,9 +13,6 @@ onready var skills := $MarginContainer/VBoxContainer/Skills func update_info(unit: Unit, advancement: Advancement) -> void: clear() - advancement.execute(unit) - unit.restore() - unit_type_label.text = unit.type.alias health_label.text = "HP: %d" % unit.type.health moves_label.text = "MP: %d" % unit.type.moves diff --git a/source/menu/ScenarioSelectionMenu.gd b/source/menu/ScenarioSelectionMenu.gd index 67e9f94a..8c785a31 100644 --- a/source/menu/ScenarioSelectionMenu.gd +++ b/source/menu/ScenarioSelectionMenu.gd @@ -6,12 +6,12 @@ onready var buttons := $CenterContainer/VBoxContainer func _ready() -> void: for key in Data.scenarios: var scenario : ScenarioData = Data.scenarios[key] - - var button = Button.new() - button.rect_min_size = Vector2(200, 60) - button.connect("pressed", self, "_on_Scenario_selected", [ scenario ]) - button.text = scenario.alias - buttons.add_child(button) + if scenario.show: + var button = Button.new() + button.rect_min_size = Vector2(200, 60) + button.connect("pressed", self, "_on_Scenario_selected", [ scenario ]) + button.text = scenario.alias + buttons.add_child(button) func _on_Scenario_selected(scenario: ScenarioData) -> void: diff --git a/source/scenario/Combat.gd b/source/scenario/Combat.gd index 831c80fc..2cbfa2ff 100644 --- a/source/scenario/Combat.gd +++ b/source/scenario/Combat.gd @@ -61,8 +61,11 @@ func start(attacker: CombatContext, defender: CombatContext) -> void: queue_free() return - attacker.unit.grant_experience(defender.unit.type.level) - defender.unit.grant_experience(attacker.unit.type.level) + var defender_level = defender.unit.type.level + var attacker_level = attacker.unit.type.level + + attacker.unit.grant_experience(defender_level) + defender.unit.grant_experience(attacker_level) emit_signal("finished") queue_free() diff --git a/source/scenario/Scenario.gd b/source/scenario/Scenario.gd index e57f7833..18f4a969 100644 --- a/source/scenario/Scenario.gd +++ b/source/scenario/Scenario.gd @@ -34,6 +34,8 @@ onready var unit_container := YSort.new() export (String) var next_scenario := ""; +var turn_num := 0 +var done := false func _ready() -> void: if Engine.editor_hint: @@ -131,7 +133,6 @@ func recruit(unit_type_id: String, loc: Location = null) -> void: unit.restore() place_unit(unit, loc) - unit.suspend() get_tree().call_group("SideUI", "update_info", current_side) @@ -360,10 +361,11 @@ func _load_sides() -> void: if (Campaign.selected_scenario.type == ScenarioData.ScenarioType.SCENARIO): side.set_faction(Campaign.selected_sides[side.number - 1]) create_unit(side.number, side.leader, side.start_position.x, side.start_position.y, true) - var ai = Data.AIs[side.ai].new() - add_child(ai) - ai.initialize(side) - AIs[side] = ai + if (side.controller == Side.Controller.AI): + var ai = Data.AIs[side.ai].new() + add_child(ai) + ai.initialize(side) + AIs[side] = ai current_side = get_side(1) @@ -411,7 +413,7 @@ func _turn_refresh_abilities() -> void: ability.execute(loc) for effect in loc.unit.get_effects(): - effect.execute(loc) + effect.execute(loc.unit) func _grab_village(loc: Location) -> void: @@ -458,6 +460,8 @@ func victory() -> void: Console.write("Side %d won!" % current_side.number) + +func end_scenario(): if (next_scenario): var next = Data.scenarios[next_scenario] Campaign.selected_scenario = next diff --git a/source/unit/Unit.gd b/source/unit/Unit.gd index cce0fc2b..336e6642 100644 --- a/source/unit/Unit.gd +++ b/source/unit/Unit.gd @@ -63,7 +63,6 @@ func advance(advancement: Advancement, silent := false) -> void: yield(tween, "tween_all_completed") advancement.execute(self) - restore() _tween_advancement_out() yield(tween, "tween_all_completed") @@ -161,9 +160,7 @@ func reset() -> void: func restore() -> void: - actions.fill() health.fill() - moves.fill() experience.empty() diff --git a/source/unit/advancement/Advancement.gd b/source/unit/advancement/Advancement.gd index fe296030..eea696ea 100644 --- a/source/unit/advancement/Advancement.gd +++ b/source/unit/advancement/Advancement.gd @@ -20,7 +20,5 @@ export(Array, NodePath) var exclude := [] func execute(unit) -> void: - for effect in get_children(): - effect.execute(unit) if restore_unit: - unit.reset() + unit.restore() diff --git a/source/unit/advancement/DefaultAdvancement.gd b/source/unit/advancement/DefaultAdvancement.gd new file mode 100644 index 00000000..3a6c8257 --- /dev/null +++ b/source/unit/advancement/DefaultAdvancement.gd @@ -0,0 +1,7 @@ +extends Advancement +class_name DefaultAdvancement + +func execute(unit) -> void: + unit.health.maximum += 3 + unit.experience.maximum *= 1.2 + .execute(unit) diff --git a/source/unit/advancement/UnitTypeAdvancement.gd b/source/unit/advancement/UnitTypeAdvancement.gd new file mode 100644 index 00000000..f4f3194c --- /dev/null +++ b/source/unit/advancement/UnitTypeAdvancement.gd @@ -0,0 +1,11 @@ +extends Advancement +class_name UnitTypeAdvancement + +export(PackedScene) var type : PackedScene = null + +func execute(unit) -> void: + var unit_type = type.instance() as UnitType + + if unit_type: + unit.set_type(unit_type) + .execute(unit) diff --git a/source/unit/effect/EffectUnitType.gd b/source/unit/effect/EffectUnitType.gd deleted file mode 100644 index c03fd34d..00000000 --- a/source/unit/effect/EffectUnitType.gd +++ /dev/null @@ -1,11 +0,0 @@ -extends Effect -class_name EffectUnitType - -export(PackedScene) var type : PackedScene = null - - -func _execute(unit) -> void: - var unit_type := type.instance() as UnitType - - if unit_type: - unit.set_type(unit_type) diff --git a/source/unit/unit_type/UnitType.gd b/source/unit/unit_type/UnitType.gd index af07911f..8430ea08 100644 --- a/source/unit/unit_type/UnitType.gd +++ b/source/unit/unit_type/UnitType.gd @@ -39,13 +39,11 @@ onready var sprite := $Sprite func _ready() -> void: for id in advances_to: - var advancement = Advancement.new() - var effect = load(UNIT_TYPE_EFFECT).new() # cyclic dependency hack var unit_type = Data.units[id] + var advancement = load("res://source/unit/advancement/UnitTypeAdvancement.gd").new() + advancement.type = unit_type advancements.add_child(advancement) - advancement.add_child(effect) advancement.alias = id - effect.type = unit_type func _enter_tree() -> void: