Add dash cooldown to come from player stats

This commit is contained in:
Nathan Chapman 2025-05-18 15:31:26 -06:00
parent c6cee88ab2
commit ec05aa73b5
5 changed files with 23 additions and 10 deletions

View File

@ -1,5 +1,7 @@
class_name CharacterStats extends Resource
signal level_up_notification()
class Ability:
var min_modifier: float
var max_modifier: float
@ -31,6 +33,9 @@ var xp: int = 0:
level_up()
boundary = perc_level_up_boundary()
const MIN_DASH_COOLDOWN: float = 1.5
const MAX_DASH_COOLDOWN: float = 0.5
# Damage bonus on attack
var strength: Ability = Ability.new(2.0, 12.0)
# Movement speed meters/second
@ -40,15 +45,19 @@ var endurance: Ability = Ability.new(5.0, 25.0)
# Crit chance
var agility: Ability = Ability.new(0.05, 0.25)
func get_max_hp() -> float:
return 20 + int(level * endurance.get_modifier())
func get_dash_cooldown() -> float:
return agility.percentile_lerp(MIN_DASH_COOLDOWN, MAX_DASH_COOLDOWN)
func level_up() -> void:
level += 1
strength.inc()
speed.inc()
endurance.inc()
agility.inc()
print("Leveled up!")
print(level)
printt(strength.score, speed.score, endurance.score, agility.score)
level_up_notification.emit()
func perc_level_up_boundary() -> int:
return int(50 * pow(1.2, level))

View File

@ -97,6 +97,7 @@ mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_856t6")])
texture_list = Array[Terrain3DTextureAsset]([SubResource("Terrain3DTextureAsset_0slur")])
[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_dn2un"]
energy_multiplier = 4.0
use_debanding = false
[sub_resource type="Sky" id="Sky_7iny7"]
@ -112,6 +113,7 @@ tonemap_mode = 3
tonemap_white = 6.0
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_0slur"]
auto_exposure_scale = 0.2
[node name="Level" type="Node3D"]
@ -127,6 +129,7 @@ environment = SubResource("Environment_cxs0p")
camera_attributes = SubResource("CameraAttributesPractical_0slur")
script = ExtResource("1_1jhfv")
current_time = 11.5
reflected_energy = 4.0
metadata/_custom_type_script = "uid://bmywk4wvcp0lr"
[node name="SunLight" type="DirectionalLight3D" parent="Sky3D"]
@ -220,7 +223,7 @@ clouds_cumulus_thickness = 0.0243
clouds_cumulus_coverage = 0.55
clouds_cumulus_absorption = 2.0
clouds_cumulus_noise_freq = 2.7
clouds_cumulus_intensity = 1.0
clouds_cumulus_intensity = 0.9997
clouds_cumulus_mie_intensity = 1.0
clouds_cumulus_mie_anisotropy = 0.206
clouds_cumulus_size = 0.5

View File

@ -15,7 +15,6 @@ func _physics_process(delta: float) -> void:
return
player.velocity = direction * player.stats.speed.get_modifier() * speed_multiplier
print(player.stats.speed.get_modifier())
time_remaining -= delta
if time_remaining <= 0:
direction = Vector3.ZERO
@ -33,5 +32,5 @@ func _unhandled_input(event: InputEvent) -> void:
if not direction.is_zero_approx():
player.rig.playback.travel("Dash")
particles.emitting = true
timer.start(1.0)
timer.start(player.stats.get_dash_cooldown())
time_remaining = dash_duration

View File

@ -16,6 +16,7 @@ var current_health: float:
func update_max_health(max_hp_in: float) -> void:
max_health = max_hp_in
current_health = max_health
printt("Health changed", max_health, current_health)
func take_damage(damage_in: float, is_critical: bool) -> void:
var damage = damage_in

View File

@ -1,6 +1,4 @@
extends CharacterBody3D
class_name Player
class_name Player extends CharacterBody3D
const JUMP_VELOCITY: float = 4.5
const DECAY: float = 8.0
@ -29,7 +27,10 @@ var _attack_direction: Vector3 = Vector3.ZERO
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
health_component.update_max_health(30.0)
health_component.update_max_health(stats.get_max_hp())
stats.level_up_notification.connect(
func(): health_component.update_max_health(stats.get_max_hp())
)
func _physics_process(delta: float) -> void:
frame_camera_rotation()