Combat overhaul: charge/gore, bear ram, matador taunt reactions
Bull charge damage: - Tunnel-proof swept detection (prev→now segment) for matador gore and bear ram, so a 66 m/s dash no longer skips clean over the thin HitArea. - Horns-first cone (bull_gore_arc): running into an enemy only wounds it when charging roughly at it, not a sideways brush. - Dash is a committed lunge: bypasses the horns cone AND the survival roll, so a dash connect is a guaranteed kill. Cruise charges keep a speed-scaled roll (mat_charge_pierce). Roll ability defers to its own pop (is_rolling guard). Bear: - Horns-first swept ram detection (edge-triggered: one charge = one wound); a tunnelling or point-blank charge now lands where body_entered wouldn't. - Overhead smash lane extends faster (0.1s) and further (20 m). - Leap slam launches the bull from anywhere in the circle (ring_frac 0). - Removed stray-quote syntax errors that broke the script. Matador: - Collider-driven stab (BladeHitbox) with recovery beat + taunt-after-hit so it stops machine-gunning the bull. - A taunting matador answers a charge: spear from range, sword up close. Spear projectile masks the BULL layer so throws connect. Tests: matador_charge/stab/spear/taunt_react, bear_ram/hitbox/fx (+ unified _fake_bull stand-in). Trimmed verbose comments. Note: bear claw-emitter/death work is still WIP (3 bear_boss_test failures). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
extends SceneTree
|
||||
## Bear ram test. Running the bull HORNS-FIRST into the bear should wound it. The bear detects this by
|
||||
## sweeping the bull's actual travel (prev → now) against its body each frame (bear._sweep_bull_ram),
|
||||
## gated by speed (bear_hit_threshold), reach (bear_ram_reach) and a horns-first cone (bull_gore_arc),
|
||||
## and edge-triggered so one charge = one wound. This drives passes against a frozen bear and asserts:
|
||||
## a horns-first charge (even one that tunnels / starts close) wounds it once; a charge moving AWAY
|
||||
## (bear behind the horns), a pass out of reach, and a too-slow nudge all leave it unharmed.
|
||||
## Run: godot --headless --script res://tests/bear_ram_test.gd
|
||||
|
||||
var _pass := 0
|
||||
var _fail := 0
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_run.call_deferred()
|
||||
|
||||
|
||||
func _ok(c: bool, m: String) -> void:
|
||||
if c:
|
||||
_pass += 1
|
||||
print(" PASS: ", m)
|
||||
else:
|
||||
_fail += 1
|
||||
print(" FAIL: ", m)
|
||||
|
||||
|
||||
func _make_bull() -> CharacterBody3D:
|
||||
var b := CharacterBody3D.new()
|
||||
b.set_script(load("res://tests/_fake_bull.gd")) # exposes is_dashing()/is_rolling()
|
||||
b.collision_layer = 2
|
||||
b.collision_mask = 0
|
||||
b.add_to_group(&"player")
|
||||
var cs := CollisionShape3D.new()
|
||||
var shape := CapsuleShape3D.new()
|
||||
shape.radius = 0.75
|
||||
shape.height = 1.845
|
||||
cs.shape = shape
|
||||
b.add_child(cs)
|
||||
root.add_child(b)
|
||||
return b
|
||||
|
||||
|
||||
# Sweep the bull from `from` to `to` at `speed` (velocity along the travel), reseting the bear's ram
|
||||
# edge-state first so each pass is isolated. The prev → now segment is what the bear tests against.
|
||||
func _ram_pass(bear: Node, bull: CharacterBody3D, speed: float, from: Vector3, to: Vector3) -> void:
|
||||
bear.set("_bull_prev_seen", false)
|
||||
bear.set("_bull_ramming", false)
|
||||
var dir := to - from
|
||||
dir.y = 0.0
|
||||
bull.velocity = dir.normalized() * speed if dir.length() > 0.01 else Vector3.ZERO
|
||||
bull.global_position = from
|
||||
bear.call("_sweep_bull_ram")
|
||||
bull.global_position = to
|
||||
bear.call("_sweep_bull_ram")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var bull := _make_bull()
|
||||
var bear := (load("res://Bear.tscn") as PackedScene).instantiate() as Node3D
|
||||
root.add_child(bear)
|
||||
bear.global_position = Vector3.ZERO
|
||||
bear.set_physics_process(false) # freeze the AI; we drive the ram sweep ourselves
|
||||
await physics_frame
|
||||
bear.call("_acquire_bull")
|
||||
|
||||
var dp := root.get_node("/root/DP")
|
||||
var reach: float = dp.f("bear_ram_reach")
|
||||
var thr: float = dp.f("bear_hit_threshold")
|
||||
_ok(bear.get("_bull") == bull, "bear acquired the bull")
|
||||
|
||||
# (a) Horns-first charge straight through the bear — endpoints (3 m) sit outside the reach, so
|
||||
# only the swept test catches the pass-through.
|
||||
var hp0: int = bear.get("_hp")
|
||||
_ok(3.0 > reach, "test pass tunnels: endpoints (3 m) exceed the ram reach (%.2f m)" % reach)
|
||||
_ram_pass(bear, bull, 66.0, Vector3(-3, 0, 0), Vector3(3, 0, 0))
|
||||
_ok(bear.get("_hp") == hp0 - 1, "a horns-first charge wounds the bear once")
|
||||
|
||||
# (b) One charge = one wound: sweeping the same charge again without disengaging doesn't re-hit
|
||||
# mid-contact (edge-triggered). Re-seed as if the bull never left the ram — no reset.
|
||||
var hp1: int = bear.get("_hp")
|
||||
bull.velocity = Vector3(66, 0, 0)
|
||||
bull.global_position = Vector3(0.2, 0, 0) # still on top of the bear, still charging
|
||||
bear.call("_sweep_bull_ram")
|
||||
_ok(bear.get("_hp") == hp1, "a sustained charge doesn't drain the bear frame-by-frame")
|
||||
|
||||
# (c) Charging AWAY (bear behind the horns) is not a horns-first ram, even up close.
|
||||
var hp2: int = bear.get("_hp")
|
||||
_ram_pass(bear, bull, 66.0, Vector3(0.5, 0, 0), Vector3(4, 0, 0))
|
||||
_ok(bear.get("_hp") == hp2, "a charge moving away from the bear leaves it unharmed")
|
||||
|
||||
# (d) A fast pass wide of the bear (out of reach) is spared.
|
||||
_ram_pass(bear, bull, 66.0, Vector3(-3, 0, 3), Vector3(3, 0, 3))
|
||||
_ok(bear.get("_hp") == hp2, "a charge that passes wide of the bear is spared")
|
||||
|
||||
# (e) A slow nudge below the hit threshold is shrugged off.
|
||||
_ram_pass(bear, bull, thr - 1.0, Vector3(-3, 0, 0), Vector3(3, 0, 0))
|
||||
_ok(bear.get("_hp") == hp2, "a nudge below the hit threshold doesn't wound the bear")
|
||||
|
||||
# (f) The DASH ability bypasses the horns-first cone: the same charge-away pass that (c) shrugged
|
||||
# off DOES wound the bear while dashing (a committed lunge rams on contact).
|
||||
var hp3: int = bear.get("_hp")
|
||||
bull.set("dashing", true)
|
||||
_ram_pass(bear, bull, 66.0, Vector3(0.5, 0, 0), Vector3(4, 0, 0))
|
||||
_ok(bear.get("_hp") == hp3 - 1, "the dash ability rams the bear on contact even when not horns-first")
|
||||
bull.set("dashing", false)
|
||||
|
||||
_finish()
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
print("Results: %d passed, %d failed" % [_pass, _fail])
|
||||
quit(1 if _fail > 0 else 0)
|
||||
Reference in New Issue
Block a user