Adds monster and start of combat menu
parent
8c835b408a
commit
dcb3966d54
@ -1,53 +0,0 @@
|
||||
|
||||
class_name Combatant
|
||||
extends Node
|
||||
|
||||
## This class/component represents anything that can particpate in combat
|
||||
##
|
||||
## This class is responsible for things like combat animations,
|
||||
## tracking combat stats, executing combat actions, etc.
|
||||
## Anything that can take a turn in combat needs to use this component:
|
||||
## Player characters, enemys, allies, neutral units, etc.
|
||||
|
||||
signal damaged(damaged_combatant: Combatant, source: DamageSource, final_amount: int)
|
||||
|
||||
@export var combat_stats: CombatStats
|
||||
@export var actions: Array[CombatAction] = []
|
||||
|
||||
# current state
|
||||
var hp: int = 0 # Health Points
|
||||
var ps: int = 0 # Physical Stamina
|
||||
var ms: int = 0 # Mental Stamina
|
||||
var atb: float = 0 # ATB Timer - counts down, turn is ready at 0
|
||||
|
||||
func is_defeated():
|
||||
|
||||
# TODO: add checks for status conditions
|
||||
# that cause this combantant to be
|
||||
# considered defeated (like stone)
|
||||
return hp <= 0
|
||||
|
||||
func is_turn_ready():
|
||||
return atb <= 0
|
||||
|
||||
func tick_atb(delta):
|
||||
if atb <= 0:
|
||||
return
|
||||
|
||||
atb -= delta
|
||||
|
||||
func take_damage(source: DamageSource):
|
||||
|
||||
# TODO: Apply stats and status to adjust the incoming damage amount
|
||||
|
||||
var final_amount = source.amount
|
||||
|
||||
if source.element == DamageSource.Element.PHYSICAL:
|
||||
final_amount -= combat_stats.constitution
|
||||
|
||||
if source.type == DamageSource.Type.MAGIC:
|
||||
final_amount -= combat_stats.willpower
|
||||
|
||||
hp -= final_amount
|
||||
|
||||
damaged.emit(self, source, final_amount)
|
||||
@ -0,0 +1,67 @@
|
||||
|
||||
class_name Combatant
|
||||
extends Node2D
|
||||
|
||||
## This class/component represents anything that can particpate in combat
|
||||
##
|
||||
## This class is responsible for things like combat animations,
|
||||
## tracking combat stats, executing combat actions, etc.
|
||||
## Anything that can take a turn in combat needs to use this component:
|
||||
## Player characters, enemys, allies, neutral units, etc.
|
||||
|
||||
signal damaged(damaged_combatant: Combatant, source: DamageSource, final_amount: int)
|
||||
|
||||
@export var combat_stats: CombatStats
|
||||
@export var actions: Array[CombatAction] = []
|
||||
@export var is_player_driven = true
|
||||
|
||||
var next_action: CombatAction = null
|
||||
|
||||
# current state
|
||||
var hp: int = 0 # Health Points
|
||||
var ps: int = 0 # Physical Stamina
|
||||
var ms: int = 0 # Mental Stamina
|
||||
var atb: float = 0 # ATB Timer - counts down, turn is ready at 0
|
||||
|
||||
func init_combat():
|
||||
print("Initing Combatant")
|
||||
|
||||
if !is_player_driven:
|
||||
$"Combat Menu".visible = false
|
||||
pass
|
||||
|
||||
func is_defeated():
|
||||
|
||||
# TODO: add checks for status conditions
|
||||
# that cause this combantant to be
|
||||
# considered defeated (like stone)
|
||||
return hp <= 0
|
||||
|
||||
func is_turn_ready():
|
||||
return atb <= 0
|
||||
|
||||
func process_tick(delta, _team: CombatTeam):
|
||||
if atb > 0:
|
||||
atb -= delta
|
||||
|
||||
# TODO: handle input
|
||||
|
||||
|
||||
func take_damage(source: DamageSource):
|
||||
|
||||
# TODO: Apply stats and status to adjust the incoming damage amount
|
||||
|
||||
var final_amount = source.amount
|
||||
|
||||
if source.element == DamageSource.Element.PHYSICAL:
|
||||
final_amount -= combat_stats.constitution
|
||||
|
||||
if source.type == DamageSource.Type.MAGIC:
|
||||
final_amount -= combat_stats.willpower
|
||||
|
||||
hp -= final_amount
|
||||
|
||||
damaged.emit(self, source, final_amount)
|
||||
|
||||
func on_action_clicked(btn):
|
||||
print("Action Clicked: %s" % btn.text)
|
||||
@ -0,0 +1,38 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://4glu7reewmf3"]
|
||||
|
||||
[ext_resource type="Script" path="res://systems/combat/combatant/combatant.gd" id="1_7ynxf"]
|
||||
|
||||
[node name="Combatant" type="Node2D"]
|
||||
script = ExtResource("1_7ynxf")
|
||||
|
||||
[node name="Combat Menu" type="Control" parent="."]
|
||||
texture_filter = 2
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Combat Menu"]
|
||||
layout_mode = 2
|
||||
offset_right = 44.0
|
||||
offset_bottom = 48.0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Combat Menu/PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 2
|
||||
theme_override_constants/margin_top = 2
|
||||
theme_override_constants/margin_right = 2
|
||||
theme_override_constants/margin_bottom = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Combat Menu/PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="BtnAttack" type="Button" parent="Combat Menu/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 10
|
||||
text = "Attack"
|
||||
|
||||
[node name="BtnDefend" type="Button" parent="Combat Menu/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 10
|
||||
text = "Defend"
|
||||
Loading…
Reference in New Issue