This commit is contained in:
2026-01-11 19:32:12 -06:00
parent 6ecbc33cc2
commit 561ab5a983
19 changed files with 245 additions and 203 deletions

View File

@@ -5,40 +5,72 @@ enum Status {
DEAD,
}
enum FighterTeam {
PLAYER,
ENEMY
}
enum FighterController {
PLAYER,
AI
}
# Health
var health:int
var maxHealth:int
var mp:int
var maxMp:int
var status:Status = Status.NORMAL
var status:Status
var attack:int = 10
var defense:int = 5
var speed:int = 5
var magic:int = 5
var luck:int = 1
# Identity
var team:FighterTeam
var controller:FighterController
func _init(
maxHealth:int = 100,
maxMp:int = 50,
) -> void:
self.maxHealth = maxHealth
self.health = maxHealth
self.maxMp = maxMp
self.mp = maxMp
# Stats
var attack:int
var defense:int
var speed:int
var magic:int
var luck:int
# Equipment
# Signals
signal healthChanged(difference:int)
signal mpChanged(difference:int)
signal statusChanged(oldStatus:Status, newStatus:Status)
func _init(params:Dictionary) -> void:
self.maxHealth = params.get('max_health', 100)
self.maxMp = params.get('max_mp', 50)
self.attack = params.get('attack', 10)
self.defense = params.get('defense', 5)
self.speed = params.get('speed', 5)
self.magic = params.get('magic', 5)
self.luck = params.get('luck', 1)
self.team = params.get('team', FighterTeam.ENEMY)
self.controller = params.get('controller', FighterController.PLAYER)
self.health = self.maxHealth
self.mp = self.maxMp
func damage(amount:int) -> void:
assert(amount > 0)
if status == Status.DEAD:
return
health = max(health - amount, 0)
healthChanged.emit(-amount)
if health == 0:
var oldStatus = status
status = Status.DEAD
statusChanged.emit(oldStatus, status)
func heal(amount:int) -> void:
assert(amount > 0)
if status == Status.DEAD:
return
health = min(health + amount, maxHealth)
healthChanged.emit(amount)
func revive(health:int) -> void:
assert(health > 0)
@@ -47,14 +79,18 @@ func revive(health:int) -> void:
health = min(health, maxHealth)
status = Status.NORMAL
self.health = health
statusChanged.emit(Status.DEAD, Status.NORMAL)
healthChanged.emit(health)
func mpConsume(amount:int) -> void:
assert(amount > 0)
mp = max(mp - amount, 0)
mpChanged.emit(-amount)
func mpRestore(amount:int) -> void:
assert(amount > 0)
mp = min(mp + amount, maxMp)
mpChanged.emit(amount)
func isCrit() -> bool:
# 10% chance of a crit

View File

@@ -1,15 +1,26 @@
class_name BattleFighterScene extends Node3D
var fighter:BattleFighter
@export var battlePosition:BattleSingleton.BattlePosition = BattleSingleton.BattlePosition.LEFT_MIDDLE_FRONT
func _ready() -> void:
self.visible = false
if fighter:
setFighter(fighter)
func _getFighter() -> BattleFighter:
return BATTLE.getFighterAtPosition(self.battlePosition)
func _updateFighter() -> void:
var fighter = _getFighter()
if fighter == null:
self.visible = false
return
func setFighter(fighter:BattleFighter) -> void:
print("Setting fighter: %s" % fighter)
# Set up the visual representation of the fighter here
self.fighter = fighter
self.visible = true
pass
func _enter_tree() -> void:
BATTLE.battleFightersChanged.connect(onFightersChanged)
self._updateFighter()
func _exit_tree() -> void:
BATTLE.battleFightersChanged.disconnect(onFightersChanged)
func onFightersChanged() -> void:
_updateFighter()

View File

@@ -1,6 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://d1xyb0hdf1yeh"]
[gd_scene load_steps=5 format=3 uid="uid://d1xyb0hdf1yeh"]
[ext_resource type="Script" uid="uid://bgycdhsouwhwt" path="res://battle/fighter/BattleFighterScene.gd" id="1_veb1i"]
[ext_resource type="SpriteFrames" uid="uid://cqqkm34a46ri6" path="res://battle/fighter/idk/green_dragon_frames.tres" id="2_e55p4"]
[sub_resource type="BoxMesh" id="BoxMesh_veb1i"]
@@ -12,5 +13,11 @@ script = ExtResource("1_veb1i")
metadata/_custom_type_script = "uid://bgycdhsouwhwt"
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
visible = false
mesh = SubResource("BoxMesh_veb1i")
surface_material_override/0 = SubResource("StandardMaterial3D_e55p4")
[node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="."]
sprite_frames = ExtResource("2_e55p4")
animation = &"idle"
frame_progress = 0.746159

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ivi4wtsktmns"
path.s3tc="res://.godot/imported/DAGRONS5.png-68b2402a87bd4c48daaac1f8405a1e4d.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://battle/fighter/idk/DAGRONS5.png"
dest_files=["res://.godot/imported/DAGRONS5.png-68b2402a87bd4c48daaac1f8405a1e4d.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,7 @@
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://cucnk4a46odta"]
[ext_resource type="Texture2D" uid="uid://ivi4wtsktmns" path="res://battle/fighter/idk/DAGRONS5.png" id="1_s00hx"]
[resource]
atlas = ExtResource("1_s00hx")
region = Rect2(16, 45.6621, 66, 83.3379)

View File

@@ -0,0 +1,19 @@
[gd_resource type="SpriteFrames" load_steps=2 format=3 uid="uid://cqqkm34a46ri6"]
[ext_resource type="Texture2D" uid="uid://cucnk4a46odta" path="res://battle/fighter/idk/green_dragon.tres" id="1_vtgsa"]
[resource]
animations = [{
"frames": [],
"loop": true,
"name": &"attack",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": ExtResource("1_vtgsa")
}],
"loop": true,
"name": &"idle",
"speed": 5.0
}]