diff --git a/classes/warrior.tres b/classes/warrior.tres index 246b0b2..01169ad 100644 --- a/classes/warrior.tres +++ b/classes/warrior.tres @@ -15,3 +15,5 @@ stamina_per_level = 2.5 unarmed_min_damage = 2 unarmed_max_damage = 4 unarmed_attack_speed = 1.8 +resource_type = 2 +base_resource = 100 diff --git a/player.gd b/player.gd index d1fe86a..b62d315 100644 --- a/player.gd +++ b/player.gd @@ -87,6 +87,11 @@ var max_mana: int: var current_mana: int: get: return current_resource +# Wut-Verfall +const RAGE_DECAY_DELAY: float = 5.0 # Sekunden nach letztem Kampfkontakt +const RAGE_DECAY_RATE: float = 10.0 # Wut pro Sekunde Verfall +var _rage_decay_timer: float = 0.0 + # ═══════════════════════════════════════════════════════════════ # EQUIPMENT # ═══════════════════════════════════════════════════════════════ @@ -413,6 +418,7 @@ func take_damage(amount: int): var effective = max(1, amount - int(armor * 0.1)) current_hp = clamp(current_hp - effective, 0, max_hp) hud.update_health(current_hp, max_hp) + _gain_rage(15) if current_hp <= 0: die() @@ -424,6 +430,31 @@ func restore_mana(amount: int): current_resource = clamp(current_resource + amount, 0, max_resource) hud.update_resource(current_resource, max_resource, get_resource_name()) +func _gain_rage(amount: int): + if character_class == null or character_class.resource_type != CharacterClass.ResourceType.RAGE: + return + current_resource = clamp(current_resource + amount, 0, max_resource) + _rage_decay_timer = RAGE_DECAY_DELAY + hud.update_resource(current_resource, max_resource, get_resource_name()) + +func _spend_rage(amount: int) -> bool: + if current_resource < amount: + return false + current_resource -= amount + hud.update_resource(current_resource, max_resource, get_resource_name()) + return true + +func _update_rage_decay(delta: float): + if character_class == null or character_class.resource_type != CharacterClass.ResourceType.RAGE: + return + if current_resource <= 0: + return + if _rage_decay_timer > 0.0: + _rage_decay_timer -= delta + return + current_resource = max(0, current_resource - int(RAGE_DECAY_RATE * delta)) + hud.update_resource(current_resource, max_resource, get_resource_name()) + func die(): if is_dead: return @@ -632,6 +663,7 @@ func _do_heavy_strike(): return var damage = randi_range(10, 15) + int(strength * 0.5) target.take_damage(damage) + _gain_rage(20) skill_cooldowns["heavy_strike"] = HEAVY_STRIKE_COOLDOWN trigger_global_cooldown() start_autoattack() @@ -957,6 +989,9 @@ func _physics_process(delta): if is_dead: return + # ── Wut-Verfall ─────────────────────────────────────────── + _update_rage_decay(delta) + # ── Cooldowns herunterzählen ────────────────────────────── var gcd_was_active = global_cooldown > 0 if global_cooldown > 0: