Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Various Bug fixes #163

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ data_*/

# VS Code
.vscode/

haldric.dmg
3 changes: 1 addition & 2 deletions ai/ActionAI.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extends AI
class_name ActionAI
extends AI

signal attacks_finished()
signal scouting_finished()
Expand Down
1 change: 0 additions & 1 deletion ai/SimpleAI.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extends AI
class_name SimpleAI

enum State { NONE, RECRUIT, CAPTURE_VILLAGES, ATTACK, RETREAT }
enum UnitState { NONE, HEAL, SCOUT, ATTACK, STANDBY }
Expand Down
17 changes: 2 additions & 15 deletions data/advancements/Default.tscn
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion data/terrain.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
34 changes: 16 additions & 18 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -553,7 +548,6 @@ _global_script_class_icons={
"AI": "",
"Ability": "",
"AbilityHeal": "",
"ActionAI": "",
"ActionButton": "",
"ActionDialogue": "",
"AdvancemenOption": "",
Expand All @@ -576,6 +570,7 @@ _global_script_class_icons={
"Commander": "",
"CreateUnitCommand": "",
"DebugDraw": "",
"DefaultAdvancement": "",
"DefenseType": "",
"Dialogue": "",
"Dialogues": "",
Expand All @@ -584,7 +579,6 @@ _global_script_class_icons={
"Effect": "",
"EffectAttribute": "",
"EffectDamage": "",
"EffectUnitType": "",
"Events": "",
"FactionData": "",
"FactionSelectionPlayerEntry": "",
Expand Down Expand Up @@ -617,7 +611,6 @@ _global_script_class_icons={
"Selector": "",
"Side": "",
"SideUI": "",
"SimpleAI": "",
"Skill": "",
"SkillButton": "",
"SkillDamage": "",
Expand Down Expand Up @@ -656,6 +649,7 @@ _global_script_class_icons={
"UnitRecallInfo": "",
"UnitRecruitInfo": "",
"UnitType": "",
"UnitTypeAdvancement": "",
"UnitUI": "",
"WeaponSpecial": ""
}
Expand Down Expand Up @@ -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={
Expand Down
2 changes: 2 additions & 0 deletions source/data/ScenarioData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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;
7 changes: 7 additions & 0 deletions source/game/Game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion source/global/Console.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
5 changes: 1 addition & 4 deletions source/global/Data.gd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func scan() -> void:
_load_scenarios()
_load_ais()


func add_terrain(terrain: TerrainData) -> void:
terrains[terrain.code] = terrain

Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions source/global/Loader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions source/interface/game/advancement/UnitAdvancementInfo.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions source/menu/ScenarioSelectionMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions source/scenario/Combat.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 10 additions & 6 deletions source/scenario/Scenario.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions source/unit/Unit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -161,9 +160,7 @@ func reset() -> void:


func restore() -> void:
actions.fill()
health.fill()
moves.fill()
experience.empty()


Expand Down
4 changes: 1 addition & 3 deletions source/unit/advancement/Advancement.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
7 changes: 7 additions & 0 deletions source/unit/advancement/DefaultAdvancement.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends Advancement
class_name DefaultAdvancement

func execute(unit) -> void:
unit.health.maximum += 3
unit.experience.maximum *= 1.2
.execute(unit)
11 changes: 11 additions & 0 deletions source/unit/advancement/UnitTypeAdvancement.gd
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 0 additions & 11 deletions source/unit/effect/EffectUnitType.gd

This file was deleted.

6 changes: 2 additions & 4 deletions source/unit/unit_type/UnitType.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down