UI and inventory system, fix bug that makes you shoot yourself, rebalancing

This commit is contained in:
ToasterPanic 2026-05-18 10:41:07 -04:00
parent a45e1e6db7
commit ce45a74635
11 changed files with 219 additions and 17 deletions

View file

@ -130,6 +130,26 @@ limbo_console_search_history={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":82,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
hotbar_item_1={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":49,"key_label":0,"unicode":49,"location":0,"echo":false,"script":null)
]
}
hotbar_item_2={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":50,"key_label":0,"unicode":50,"location":0,"echo":false,"script":null)
]
}
hotbar_item_3={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":51,"key_label":0,"unicode":51,"location":0,"echo":false,"script":null)
]
}
hotbar_item_4={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":52,"key_label":0,"unicode":52,"location":0,"echo":false,"script":null)
]
}
[layer_names]

View file

@ -38,7 +38,7 @@ height = 1.0
[sub_resource type="Environment" id="Environment_uwrxv"]
background_mode = 1
background_color = Color(0.15027824, 1.627421e-05, 0.15027693, 1)
background_color = Color(0.38, 0.152, 0.37240002, 1)
tonemap_mode = 2
volumetric_fog_enabled = true
adjustment_enabled = true
@ -405,3 +405,41 @@ pixel_size = 0.05
double_sided = false
texture = ExtResource("14_trtic")
script = ExtResource("16_ca42v")
[node name="UI" type="CanvasLayer" parent="." unique_id=201561869]
[node name="Hotbar" type="HBoxContainer" parent="UI" unique_id=1186915077]
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -64.0
offset_right = 512.0
grow_vertical = 0
[node name="Items" type="HBoxContainer" parent="UI/Hotbar" unique_id=1114341919]
layout_mode = 2
[node name="Bars" type="VBoxContainer" parent="UI/Hotbar" unique_id=555590510]
layout_mode = 2
[node name="Health" type="HBoxContainer" parent="UI/Hotbar/Bars" unique_id=517829452]
custom_minimum_size = Vector2(256, 32)
layout_mode = 2
[node name="Bar" type="ProgressBar" parent="UI/Hotbar/Bars/Health" unique_id=979273960]
custom_minimum_size = Vector2(0, 32)
layout_mode = 2
size_flags_horizontal = 3
value = 50.0
[node name="Stamina" type="HBoxContainer" parent="UI/Hotbar/Bars" unique_id=1972898781]
custom_minimum_size = Vector2(256, 32)
layout_mode = 2
[node name="ProgressBar" type="ProgressBar" parent="UI/Hotbar/Bars/Stamina" unique_id=1170118064]
custom_minimum_size = Vector2(0, 32)
layout_mode = 2
size_flags_horizontal = 3
show_percentage = false
indeterminate = true
editor_preview_indeterminate = false

View file

@ -0,0 +1,34 @@
[gd_scene format=3 uid="uid://de2iv6o4kw2ce"]
[ext_resource type="Texture2D" uid="uid://da6u1yfpby21d" path="res://textures/ui/charging.png" id="1_f7n08"]
[ext_resource type="Script" uid="uid://cc1ow7x0nug4a" path="res://scripts/ui/hotbar_item_button.gd" id="1_srjjs"]
[ext_resource type="Texture2D" uid="uid://d1abd236mlb6" path="res://textures/weapons/inhands/basic_hammer.png" id="2_xhibd"]
[node name="ItemButton" type="Button" unique_id=1888094213]
custom_minimum_size = Vector2(64, 64)
script = ExtResource("1_srjjs")
[node name="Sprite" type="TextureRect" parent="." unique_id=511065380]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("2_xhibd")
stretch_mode = 5
[node name="Cooldown" type="TextureProgressBar" parent="." unique_id=258783393]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
step = 0.01
value = 100.0
fill_mode = 4
nine_patch_stretch = true
texture_progress = ExtResource("1_f7n08")
tint_progress = Color(1, 1, 1, 0.4627451)

View file

@ -130,7 +130,7 @@ func _physics_process(delta: float) -> void:
if (player.global_position - global_position).length() < 1:
state = STATE_CHARGE_ATTACK
state_timer = 0.5
state_timer = 0.7
$DreamerBody/Animator.set("parameters/charge_weapon/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
elif state == STATE_CHARGE_ATTACK:

View file

@ -1,5 +1,7 @@
extends Node3D
var update_ui_timer = 0.1
@onready var player = $Player
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@ -8,4 +10,27 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
update_ui_timer -= delta
if update_ui_timer <= 0:
update_ui_timer = 0.1
$UI/Hotbar/Bars/Health/Bar.value = player.health
var item_buttons = $UI/Hotbar/Items.get_children()
var i = 0
for n in player.slots:
if item_buttons.size() <= i:
var button = preload("res://scenes/ui/item_button.tscn").instantiate()
button.weapon = player.slots[i]
button.player = player
$UI/Hotbar/Items.add_child(button)
button.started = true
elif item_buttons[i].weapon != player.slots[i]:
item_buttons[i].weapon = player.slots[i]
i += 1

View file

@ -16,8 +16,12 @@ var health = 100
var slots = [
{
"id": "basic_sword",
"cooldown_time": 0,
}
"cooldown": 0,
},
{
"id": "basic_handcannon",
"cooldown": 0,
},
]
var combo_hits = 0
@ -30,6 +34,7 @@ var dodging = false
var dodge_timer = 0.0
var dodge_direction = null
var current_slot = 0
var current_weapon = "basic_sword"
enum {
@ -50,7 +55,7 @@ func hit_me():
health -= 10
func get_my_weapon_info(value: String):
return get_weapon_info(current_weapon, value)
return get_weapon_info(current_weapon.id, value)
func get_weapon_info(weapon: String, value: String):
if value in Global.weapons[weapon]:
@ -64,14 +69,21 @@ func on_hit(hitter: Node3D = null) -> void:
knockback_time = 0.25
velocity += hitter.global_position.direction_to(global_position) * 8
velocity.y = 0
func give_weapon(weapon_name: String = "basic_sword") -> void:
pass
func set_weapon(weapon_name: String = "basic_sword") -> void:
current_weapon = weapon_name
$DreamerBody.set_inhand(current_weapon)
func set_weapon_from_slot(slot: int) -> void:
current_slot = slot
set_weapon(slots[slot])
var range = get_weapon_info(current_weapon, "range")
func set_weapon(weapon_data: Dictionary) -> void:
current_weapon = weapon_data
$DreamerBody.set_inhand(weapon_data.id)
var range = get_weapon_info(weapon_data.id, "range")
if not range: range = 1
var width = get_weapon_info(current_weapon, "width")
var width = get_weapon_info(weapon_data.id, "width")
if not width: width = 1
$HitCollision/Shape.shape.size = Vector3(range, 1.0, width)
@ -93,7 +105,7 @@ func _ready() -> void:
LimboConsole.register_command(hit_me)
LimboConsole.register_command(set_weapon)
LimboConsole.register_command(dps)
set_weapon(current_weapon)
set_weapon_from_slot(0)
func _process(delta: float) -> void:
@ -108,8 +120,16 @@ func _process(delta: float) -> void:
$DreamerBody/Animator.set("parameters/hit/blend_amount", 1.0)
else:
$DreamerBody/Animator.set("parameters/hit/blend_amount", 0.0)
var i = 0
while i < slots.size():
if ("cooldown" in slots[i]) and (slots[i].cooldown > 0): slots[i].cooldown -= delta
if Input.is_action_just_pressed("hotbar_item_" + str(i + 1)):
set_weapon_from_slot(i)
i += 1
#func _physics_process(delta: float) -> void:
$DreamerBody.look_at(game.get_node("PlayerCamera").global_position)
$DreamerBody.rotation.x = 0
face_rotation = $DreamerBody.rotation.y
@ -199,7 +219,7 @@ func _process(delta: float) -> void:
$DreamerBody/Animator.set("parameters/dodge/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
if (Input.is_action_just_pressed("attack") or queue_swing) and (not dodging):
if (Input.is_action_just_pressed("attack") or queue_swing) and (not dodging) and (current_weapon.cooldown <= 0):
if swing_timer > 0:
if swing_timer < 0.1:
queue_swing = true
@ -302,6 +322,8 @@ func _process(delta: float) -> void:
damage_text.global_position = body.global_position
damage_text.get_node("Label").text = str(floor(damage))
if get_my_weapon_info("recharge_time"):
current_weapon.cooldown = get_my_weapon_info("recharge_time")
if dodging and (knockback_time <= 0):
velocity.x = dodge_direction.x * 6
velocity.z = dodge_direction.z * 6

View file

@ -8,11 +8,12 @@ func pow() -> void:
$Hit.force_raycast_update()
var hit = $Hit.get_collider()
if not hit:
if hit and hit.name == "Player":
pass
elif not hit:
print("hit nothing")
break
if "health" in hit:
elif "health" in hit:
hit.health -= 100
if "on_knockback" in hit: hit.on_knockback()
print(hit.name, hit.health)

View file

@ -0,0 +1,21 @@
extends Button
var weapon = null
var player = null
var started = false
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if !started: return
$Sprite.texture = load("res://textures/weapons/inhands/" + weapon.id + ".png")
if weapon.cooldown > 0:
$Cooldown.visible = true
$Cooldown.max_value = Global.weapons[weapon.id].recharge_time
$Cooldown.value = weapon.cooldown
else:
$Cooldown.visible = false
if player.current_weapon == weapon: modulate.v = 1.0
else: modulate.v = 0.5

View file

@ -0,0 +1 @@
uid://cc1ow7x0nug4a

BIN
textures/ui/charging.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://da6u1yfpby21d"
path="res://.godot/imported/charging.png-5a4e89bce3f9306181e683ad28bc21b6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/ui/charging.png"
dest_files=["res://.godot/imported/charging.png-5a4e89bce3f9306181e683ad28bc21b6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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