Lobby barrel-smash reward + roll/slam barrel destruction
Bull's boulder roll now homes on and ploughs through lobby barrels, and the slam shockwave bursts them within its radius. HUD tallies barrels on load and fires a confetti "WOooOoW!" + two gold bonus HP pips when the last one breaks; gates open from run state as fights are cleared. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -67,6 +67,9 @@ signal health_changed(current: int, max_hp: int)
|
||||
signal hit_taken(cause: String)
|
||||
var _max_hp: int = 10
|
||||
var _hp: int = 10
|
||||
# Bonus pips granted by lobby rewards (e.g. smashing every barrel). Tacked on top of the
|
||||
# base bar; the HUD paints these top pips yellow instead of red.
|
||||
var _bonus_hp: int = 0
|
||||
var _hit_iframes: float = 0.0
|
||||
|
||||
var _huff_player: AudioStreamPlayer = null
|
||||
@@ -93,6 +96,11 @@ func _ready() -> void:
|
||||
RigidSkin.convert_tree(self)
|
||||
_max_hp = maxi(1, int(DP.f("bull_max_hp")))
|
||||
_hp = _max_hp
|
||||
# Carry any run-long bonus pips (barrel reward) into this level so they survive the
|
||||
# scene reload between fights; the HUD paints these top pips yellow.
|
||||
_bonus_hp = Run.bonus_hp
|
||||
_max_hp += _bonus_hp
|
||||
_hp += _bonus_hp
|
||||
_cube_scale = cube_guy.scale
|
||||
_setup_hoof_dust()
|
||||
_setup_legs()
|
||||
@@ -511,6 +519,7 @@ func _tick_roll(delta: float, _steer: Vector3) -> void:
|
||||
|
||||
move_and_slide()
|
||||
_was_on_floor = is_on_floor()
|
||||
_smash_barrels_in_radius(DP.f("roll_hit_radius"))
|
||||
_roll_try_pop(speed)
|
||||
|
||||
|
||||
@@ -549,22 +558,37 @@ func _roll_try_pop(speed: float) -> bool:
|
||||
return false
|
||||
|
||||
|
||||
# Closest active matador we haven't already popped this roll, or null if none left.
|
||||
# Closest thing the roll should home on — an active matador (arena) or an intact barrel
|
||||
# (lobby) we haven't already smashed this roll. Null if nothing is left to hit.
|
||||
func _roll_pick_target() -> Node3D:
|
||||
var best: Node3D = null
|
||||
var best_d := INF
|
||||
for mat: Node in get_tree().get_nodes_in_group(&"matador"):
|
||||
if _roll_hit.has(mat) or not _mat_active(mat):
|
||||
continue
|
||||
var d: float = (mat as Node3D).global_position.distance_squared_to(global_position)
|
||||
for cand: Node3D in _roll_targets():
|
||||
var d: float = cand.global_position.distance_squared_to(global_position)
|
||||
if d < best_d:
|
||||
best_d = d
|
||||
best = mat as Node3D
|
||||
best = cand
|
||||
return best
|
||||
|
||||
|
||||
# Live roll targets: active matadors plus standing barrels, minus anything already popped.
|
||||
func _roll_targets() -> Array[Node3D]:
|
||||
var out: Array[Node3D] = []
|
||||
for mat: Node in get_tree().get_nodes_in_group(&"matador"):
|
||||
if not _roll_hit.has(mat) and _mat_active(mat):
|
||||
out.append(mat as Node3D)
|
||||
for barrel: Node in get_tree().get_nodes_in_group(&"barrel"):
|
||||
if _barrel_alive(barrel):
|
||||
out.append(barrel as Node3D)
|
||||
return out
|
||||
|
||||
|
||||
func _roll_target_valid() -> bool:
|
||||
return is_instance_valid(_roll_target) and _mat_active(_roll_target)
|
||||
if not is_instance_valid(_roll_target):
|
||||
return false
|
||||
if _roll_target.is_in_group(&"barrel"):
|
||||
return _barrel_alive(_roll_target)
|
||||
return _mat_active(_roll_target)
|
||||
|
||||
|
||||
# A matador still in play — valid, not ragdolled/consumed. Ragdolled bodies report
|
||||
@@ -573,6 +597,25 @@ func _mat_active(mat: Node) -> bool:
|
||||
return is_instance_valid(mat) and mat.has_method(&"is_active") and mat.call(&"is_active")
|
||||
|
||||
|
||||
# A lobby barrel still standing — valid and not already queued for removal by an earlier hit.
|
||||
func _barrel_alive(barrel: Node) -> bool:
|
||||
return is_instance_valid(barrel) and not barrel.is_queued_for_deletion()
|
||||
|
||||
|
||||
# Burst every barrel whose centre sits within range_m on the ground plane. Shared by the
|
||||
# boulder roll (which ploughs straight through them) and the slam shockwave. Each barrel
|
||||
# self-removes and leaves the &"barrel" group, so the HUD's clear-the-lobby tally counts it
|
||||
# exactly once.
|
||||
func _smash_barrels_in_radius(range_m: float) -> void:
|
||||
for barrel: Node in get_tree().get_nodes_in_group(&"barrel"):
|
||||
if not _barrel_alive(barrel):
|
||||
continue
|
||||
var to_b: Vector3 = (barrel as Node3D).global_position - global_position
|
||||
to_b.y = 0.0
|
||||
if to_b.length() <= range_m:
|
||||
barrel.call(&"destroy_barrel")
|
||||
|
||||
|
||||
# True while the boulder roll is live — matadors defer their charge-gore to the roll's own pop
|
||||
# (is_rolling guard in matador._take_bull_charge) so the ball pops instead of quietly goring.
|
||||
func is_rolling() -> bool:
|
||||
@@ -1084,6 +1127,7 @@ func _physics_process(delta: float) -> void:
|
||||
_play_idle()
|
||||
_spawn_slam_fx()
|
||||
_hit_matadors_radius(DP.f("slam_range"), DP.f("slam_strength"), DP.f("slam_launch_up"))
|
||||
_smash_barrels_in_radius(DP.f("slam_range"))
|
||||
|
||||
# ── Dust ──────────────────────────────────────────────────────────────────
|
||||
if flat_speed > DP.f("dust_charge_spd") and on_floor:
|
||||
@@ -1110,6 +1154,22 @@ func get_max_hp() -> int:
|
||||
return _max_hp
|
||||
|
||||
|
||||
# Bonus pips currently on the bar — the HUD colours this many top pips yellow.
|
||||
func get_bonus_hp() -> int:
|
||||
return _bonus_hp
|
||||
|
||||
|
||||
# Award extra health (from a lobby reward): grows both the cap and the current bar so the
|
||||
# new pips arrive full, and marks them as bonus so the HUD paints them yellow.
|
||||
func grant_bonus_hp(amount: int) -> void:
|
||||
if amount <= 0:
|
||||
return
|
||||
_bonus_hp += amount
|
||||
_max_hp += amount
|
||||
_hp += amount
|
||||
health_changed.emit(_hp, _max_hp)
|
||||
|
||||
|
||||
# A clean hit — thrown or swung blade — costs the bull one HP pip; the run ends only
|
||||
# when the last pip is gone. `cause` ("gored" / "thrown") tags how it happened for the
|
||||
# death notice. I-frames absorb a flurry so several blades in one pass drop one pip,
|
||||
|
||||
Reference in New Issue
Block a user