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,25 @@
|
||||
extends CharacterBody3D
|
||||
## Stand-in bull for the combat tests. As a TARGET it records hitbox callbacks (hits / knock-up);
|
||||
## as an ATTACKER it exposes the ability-state interface (is_dashing / is_rolling) the matador and
|
||||
## bear query. Ability flags default off = an ordinary charge.
|
||||
|
||||
var hits: int = 0
|
||||
var knocked_up: float = 0.0
|
||||
var dashing: bool = false
|
||||
var rolling: bool = false
|
||||
|
||||
|
||||
func take_sword_hit(_cause: String = "", _hit_pos: Vector3 = Vector3.ZERO) -> void:
|
||||
hits += 1
|
||||
|
||||
|
||||
func apply_knock_up(v: float) -> void:
|
||||
knocked_up = maxf(knocked_up, v)
|
||||
|
||||
|
||||
func is_dashing() -> bool:
|
||||
return dashing
|
||||
|
||||
|
||||
func is_rolling() -> bool:
|
||||
return rolling
|
||||
@@ -0,0 +1 @@
|
||||
uid://bamw0bnk3bfvs
|
||||
@@ -0,0 +1,98 @@
|
||||
extends SceneTree
|
||||
## Bear attack-FX test. The four attack effects (crater, smash debris, left/right claw slash)
|
||||
## live in Assets/fx/Bear_FX.glb as meshes that rest at scale 0 at Siim's baked positions. The
|
||||
## GLB carries its own AnimationPlayer whose clips scale one mesh up at its strike frame and
|
||||
## back to 0 (self-hiding) while pinning the others at 0. bear.gd fires the matching clip on
|
||||
## each strike (see _play_fx). This asserts each clip pops its own mesh, self-hides by the end,
|
||||
## and never leaves another effect on-screen — so a mis-wired trigger or a broken clip is caught
|
||||
## headlessly. Run: godot --headless --script res://tests/bear_fx_test.gd
|
||||
|
||||
var _pass := 0
|
||||
var _fail := 0
|
||||
var _fx_player: AnimationPlayer = null
|
||||
var _fx: Dictionary = {} # short name -> Node3D
|
||||
|
||||
|
||||
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 _run() -> void:
|
||||
var bear := (load("res://Bear.tscn") as PackedScene).instantiate()
|
||||
root.add_child(bear)
|
||||
await physics_frame
|
||||
|
||||
var fx_root := bear.find_child("Bear_FX", true, false)
|
||||
_ok(fx_root != null, "Bear_FX instanced in the scene")
|
||||
if fx_root == null:
|
||||
_finish()
|
||||
return
|
||||
_fx_player = fx_root.get_node_or_null("AnimationPlayer") as AnimationPlayer
|
||||
_ok(_fx_player != null, "found the Bear_FX AnimationPlayer")
|
||||
if _fx_player == null:
|
||||
_finish()
|
||||
return
|
||||
|
||||
for n: String in ["jump_smash", "smash_hit", "claw_attack_R", "claw_attack_L"]:
|
||||
_fx[n] = bear.find_child("Bear_fx_" + n, true, false)
|
||||
_ok(_fx[n] != null, "found Bear_fx_" + n)
|
||||
if _fx.values().has(null):
|
||||
_finish()
|
||||
return
|
||||
|
||||
_ok(not _vis("jump_smash") and not _vis("smash_hit")
|
||||
and not _vis("claw_attack_R") and not _vis("claw_attack_L"),
|
||||
"all FX hidden at rest (scale 0)")
|
||||
|
||||
# Each clip pops only its own mesh at the strike, then self-hides, leaving nothing stale.
|
||||
await _check_clip("Bear_fx_claw_attack_L", "claw_attack_L")
|
||||
await _check_clip("Bear_fx_claw_attack_R", "claw_attack_R")
|
||||
await _check_clip("Bear_fx_smash_hit", "smash_hit")
|
||||
await _check_clip("Bear_fx_jump_smash", "jump_smash")
|
||||
|
||||
_finish()
|
||||
|
||||
|
||||
# Play a clip to completion in real process mode (so bear.gd's animation_finished hide runs):
|
||||
# the clip's own mesh scales up somewhere in the middle, every other mesh stays hidden, and the
|
||||
# mesh is back to scale 0 once the clip has finished.
|
||||
func _check_clip(clip: String, owner_key: String) -> void:
|
||||
_fx_player.play(clip)
|
||||
_fx_player.seek(0.0, true)
|
||||
var peak := 0.0
|
||||
var others_clean := true
|
||||
var frames := 0
|
||||
while _fx_player.is_playing() and frames < 600:
|
||||
await process_frame
|
||||
frames += 1
|
||||
peak = maxf(peak, (_fx[owner_key] as Node3D).scale.length())
|
||||
for k: String in _fx.keys():
|
||||
if k != owner_key and _vis(k):
|
||||
others_clean = false
|
||||
# Hide happens on animation_finished (immediately for most, after a linger for the crater),
|
||||
# so poll a bounded window rather than assume it's gone on the very next frame.
|
||||
var settle := 0
|
||||
while _vis(owner_key) and settle < 600:
|
||||
await process_frame
|
||||
settle += 1
|
||||
_ok(peak > 0.05, clip + ": its mesh pops during the clip")
|
||||
_ok(others_clean, clip + ": no other effect shows while it plays")
|
||||
_ok(not _vis(owner_key), clip + ": hidden again after the clip ends")
|
||||
|
||||
|
||||
func _vis(n: String) -> bool:
|
||||
return (_fx[n] as Node3D).scale.length() > 0.05
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
print("Results: %d passed, %d failed" % [_pass, _fail])
|
||||
quit(1 if _fail > 0 else 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://duyfxhca4np78
|
||||
@@ -0,0 +1,121 @@
|
||||
extends SceneTree
|
||||
## Bear attack-collider test. The colliders + their motion live in BearAttackHitboxes.tscn: the
|
||||
## leap slam is a ground circle (cylinder) whose "leap_slam" clip pops it open; the overhead smash
|
||||
## is a forward box lane whose "smash_travel" clip grows it out from the bear. bear.gd fires the
|
||||
## clip, arms the knock-up shaping, and sweeps while it runs. This asserts: a bull anywhere in the
|
||||
## leap circle is mauled AND launched by default (bear_leap_ring_frac 0), while raising ring_frac
|
||||
## carves a grounded inner zone; the smash lane catches bulls near AND far as the front travels,
|
||||
## throws the further one higher, and spares anything off the lane.
|
||||
## Run: godot --headless --script res://tests/bear_hitbox_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(pos: Vector3) -> CharacterBody3D:
|
||||
var b := CharacterBody3D.new()
|
||||
b.collision_layer = 2 # PhysicsLayers.BULL — what the hitboxes mask
|
||||
b.collision_mask = 0
|
||||
b.add_to_group(&"player")
|
||||
b.set_script(load("res://tests/_fake_bull.gd"))
|
||||
var cs := CollisionShape3D.new()
|
||||
var shape := SphereShape3D.new()
|
||||
shape.radius = 0.6
|
||||
cs.shape = shape
|
||||
b.add_child(cs)
|
||||
root.add_child(b)
|
||||
b.global_position = pos
|
||||
return b
|
||||
|
||||
|
||||
# Drive one attack collider clip to completion, sweeping each physics frame like _physics_process.
|
||||
func _drive(bear: Node, fire: String) -> void:
|
||||
bear.call(fire)
|
||||
for i in 60:
|
||||
bear.call("_tick_attack_hitbox")
|
||||
await physics_frame
|
||||
if bear.get("_active_hitbox") == null:
|
||||
break
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var bear := (load("res://Bear.tscn") as PackedScene).instantiate() as Node3D
|
||||
root.add_child(bear)
|
||||
bear.set_physics_process(false) # freeze the AI; we fire the colliders ourselves
|
||||
await physics_frame
|
||||
|
||||
var leap_hb := bear.find_child("LeapSlamHitbox", true, false) as Area3D
|
||||
var smash_hb := bear.find_child("SmashHitbox", true, false) as Area3D
|
||||
_ok(leap_hb != null, "leap slam cylinder hitbox exists (from BearAttackHitboxes.tscn)")
|
||||
_ok(smash_hb != null, "overhead smash lane hitbox exists (from BearAttackHitboxes.tscn)")
|
||||
if leap_hb == null or smash_hb == null:
|
||||
_finish()
|
||||
return
|
||||
|
||||
var dp := root.get_node("/root/DP")
|
||||
var slam_r: float = (leap_hb.get_node("CollisionShape3D").shape as CylinderShape3D).radius
|
||||
var lane: float = (smash_hb.get_node("CollisionShape3D").shape as BoxShape3D).size.z
|
||||
|
||||
# ── Leap slam: by default (bear_leap_ring_frac 0) the bull is launched from ANYWHERE in the
|
||||
# circle — no safe inner spot. Off the circle is still spared.
|
||||
dp.call("set_value", "bear_leap_ring_frac", 0.0)
|
||||
var center := _make_bull(Vector3(0.0, 0.5, 0.0))
|
||||
var midring := _make_bull(Vector3(slam_r * 0.5, 0.5, 0.0))
|
||||
var outside := _make_bull(Vector3(slam_r + 3.0, 0.5, 0.0))
|
||||
await physics_frame
|
||||
await _drive(bear, "_fire_leap_hitbox")
|
||||
_ok(center.hits >= 1 and center.knocked_up > 0.0, "bull at the circle center is mauled AND launched")
|
||||
_ok(midring.hits >= 1 and midring.knocked_up > 0.0, "bull mid-circle is mauled AND launched")
|
||||
_ok(outside.hits == 0, "bull outside the slam radius is spared")
|
||||
center.queue_free()
|
||||
midring.queue_free()
|
||||
outside.queue_free()
|
||||
await physics_frame
|
||||
|
||||
# Raising ring_frac restores a grounded inner zone that only mauls (the slider still works).
|
||||
dp.call("set_value", "bear_leap_ring_frac", 0.75)
|
||||
var frac: float = dp.f("bear_leap_ring_frac")
|
||||
var inner := _make_bull(Vector3(slam_r * (frac * 0.5), 0.5, 0.0))
|
||||
var ring := _make_bull(Vector3(slam_r * (frac + (1.0 - frac) * 0.5), 0.5, 0.0))
|
||||
await physics_frame
|
||||
await _drive(bear, "_fire_leap_hitbox")
|
||||
_ok(inner.hits >= 1 and inner.knocked_up == 0.0, "raised ring_frac keeps the inner circle grounded")
|
||||
_ok(ring.knocked_up > 0.0, "raised ring_frac still launches the outer ring")
|
||||
inner.queue_free()
|
||||
ring.queue_free()
|
||||
dp.call("set_value", "bear_leap_ring_frac", 0.0)
|
||||
await physics_frame
|
||||
|
||||
# ── Overhead smash: the lane's leading edge travels the whole way, so bulls near AND far are
|
||||
# both caught as the front passes; the further one is thrown higher. Off-lane is spared.
|
||||
var near := _make_bull(Vector3(0.0, 0.5, lane * 0.2))
|
||||
var far := _make_bull(Vector3(0.0, 0.5, lane * 0.8))
|
||||
var beside := _make_bull(Vector3(lane * 0.5, 0.5, lane * 0.5))
|
||||
var behind := _make_bull(Vector3(0.0, 0.5, -3.0))
|
||||
await physics_frame
|
||||
await _drive(bear, "_begin_smash_hitbox")
|
||||
_ok(near.hits >= 1, "bull near the bear is caught as the shockwave starts")
|
||||
_ok(far.hits >= 1, "bull far down the lane is caught when the front reaches it")
|
||||
_ok(far.knocked_up > near.knocked_up, "the further hit is thrown higher")
|
||||
_ok(beside.hits == 0, "bull beside the lane is spared (a lane, not a circle)")
|
||||
_ok(behind.hits == 0, "bull behind the bear is spared")
|
||||
|
||||
_finish()
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
print("Results: %d passed, %d failed" % [_pass, _fail])
|
||||
quit(1 if _fail > 0 else 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cvweb2dnv23s
|
||||
@@ -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)
|
||||
@@ -0,0 +1 @@
|
||||
uid://o2cdiyq77u8k
|
||||
@@ -283,7 +283,7 @@ func _check_overlays() -> void:
|
||||
_note("overlay check: DP / DebugDraw autoload missing")
|
||||
return
|
||||
var flags := [
|
||||
"show_states", "show_stats", "show_collisions", "show_hitboxes", "show_bones",
|
||||
"show_states", "show_stats", "show_attacks", "show_hitboxes", "show_bones",
|
||||
"show_animation_name", "show_wireframe", "show_grid", "show_axes",
|
||||
]
|
||||
for flag: String in flags:
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
extends SceneTree
|
||||
## Charge-reliability test. A fast bull (dash ≈ 66 m/s ≈ 1.1 m/frame) moves far enough per physics
|
||||
## frame to tunnel clean through the matador's thin HitArea, so the Area's body_entered never fires
|
||||
## — "my charge goes right through them." matador.gd now sweeps the bull's actual travel (prev → now)
|
||||
## each frame and gores any matador on the path (_sweep_bull_gore), and a committed charge pierces the
|
||||
## survival roll (mat_charge_pierce). This drives a tunnelling pass whose endpoints both sit OUTSIDE
|
||||
## the gore radius — so only the swept test can catch it — and asserts: (a) the charge still connects,
|
||||
## (b) a full-speed charge gores (kills) rather than being rolled off, and (c) a slow bump at the hit
|
||||
## threshold still lets the matador roll clear.
|
||||
## Run: godot --headless --script res://tests/matador_charge_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 bull := CharacterBody3D.new()
|
||||
bull.set_script(load("res://tests/_fake_bull.gd")) # exposes is_dashing()/is_rolling()
|
||||
bull.collision_layer = 2
|
||||
bull.collision_mask = 0
|
||||
bull.add_to_group(&"player")
|
||||
var cs := CollisionShape3D.new()
|
||||
var shape := CapsuleShape3D.new()
|
||||
shape.radius = 0.75
|
||||
shape.height = 1.845
|
||||
cs.shape = shape
|
||||
bull.add_child(cs)
|
||||
root.add_child(bull)
|
||||
return bull
|
||||
|
||||
|
||||
func _make_matador(_bull: CharacterBody3D) -> CharacterBody3D:
|
||||
var mat := (load("res://Matador.tscn") as PackedScene).instantiate() as CharacterBody3D
|
||||
root.add_child(mat)
|
||||
mat.global_position = Vector3.ZERO
|
||||
mat.set_physics_process(false) # we drive the swept gore ourselves, isolated from the AI
|
||||
await physics_frame
|
||||
mat.call("_acquire_bull")
|
||||
return mat
|
||||
|
||||
|
||||
# Sweep the bull straight across the matador at `speed`: seed the previous position at from_x (too
|
||||
# far to gore), then teleport to to_x so the prev → now segment passes through the matador at x=0.
|
||||
func _charge_pass(mat: CharacterBody3D, bull: CharacterBody3D, speed: float, from_x: float, to_x: float) -> void:
|
||||
bull.global_position = Vector3(from_x, 0.0, 0.0)
|
||||
bull.velocity = Vector3(speed, 0.0, 0.0)
|
||||
mat.call("_sweep_bull_gore")
|
||||
bull.global_position = Vector3(to_x, 0.0, 0.0)
|
||||
mat.call("_sweep_bull_gore")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var dp := root.get_node("/root/DP")
|
||||
var gore_r: float = dp.f("mat_charge_gore_radius")
|
||||
var thr: float = dp.f("mat_hit_threshold")
|
||||
_ok(2.0 > gore_r, "test pass tunnels: endpoints (2 m) sit outside the gore radius (%.2f m)" % gore_r)
|
||||
|
||||
# One shared bull — matadors acquire the sole node in the "player" group, so every scenario
|
||||
# sweeps the same body (a second bull would leave later matadors reading the wrong, stale one).
|
||||
var bull := _make_bull()
|
||||
|
||||
# (a) A dash-speed pass that leaps clean over the HitArea must still connect. Force the roll so
|
||||
# the reaction is a clean, ragdoll-free state change proving detection.
|
||||
dp.call("set_value", "mat_charge_pierce", 0.0)
|
||||
dp.call("set_value", "mat_roll_chance", 1.0)
|
||||
var mat_a: CharacterBody3D = await _make_matador(bull)
|
||||
_charge_pass(mat_a, bull, 66.0, -2.0, 2.0)
|
||||
_ok(mat_a.call("ai_state_name") == "ROLL", "a dash that tunnels the HitArea still connects (matador reacts)")
|
||||
|
||||
# (b) A full-speed charge pierces the survival roll and gores — even forced roll_chance can't save it.
|
||||
dp.call("set_value", "mat_charge_pierce", 1.0)
|
||||
dp.call("set_value", "mat_roll_chance", 1.0)
|
||||
var mat_b: CharacterBody3D = await _make_matador(bull)
|
||||
_charge_pass(mat_b, bull, 66.0, -2.0, 2.0)
|
||||
_ok(mat_b.call("ai_state_name") == "RAGDOLL", "a full-speed charge pierces the roll and gores the matador")
|
||||
|
||||
# (c) The pierce only bites at speed: a slow bump at the hit threshold still lets them roll clear.
|
||||
var mat_c: CharacterBody3D = await _make_matador(bull)
|
||||
_charge_pass(mat_c, bull, thr, -2.0, 2.0)
|
||||
_ok(mat_c.call("ai_state_name") == "ROLL", "a slow bump at the threshold still rolls clear")
|
||||
|
||||
# (d) Horns-first only: a fast pass with the matador BEHIND the bull's heading (it charges away,
|
||||
# 0.5 → 3, matador at 0) doesn't gore, even though the swept path passes within reach.
|
||||
dp.call("set_value", "mat_charge_pierce", 0.0)
|
||||
dp.call("set_value", "mat_roll_chance", 1.0)
|
||||
var mat_d: CharacterBody3D = await _make_matador(bull)
|
||||
_charge_pass(mat_d, bull, 66.0, 0.5, 3.0)
|
||||
_ok(mat_d.call("ai_state_name") == "WANDER", "a charge moving away from the matador doesn't gore (horns-first)")
|
||||
|
||||
# (e) The DASH ability is a committed lunge: even the not-horns-first pass connects (is_dashing
|
||||
# bypasses the cone) AND is a guaranteed kill — roll_chance forced to 1.0 still RAGDOLLS, not rolls.
|
||||
dp.call("set_value", "mat_roll_chance", 1.0)
|
||||
dp.call("set_value", "mat_charge_pierce", 0.0)
|
||||
bull.set("dashing", true)
|
||||
var mat_e: CharacterBody3D = await _make_matador(bull)
|
||||
_charge_pass(mat_e, bull, 66.0, 0.5, 3.0)
|
||||
_ok(mat_e.call("ai_state_name") == "RAGDOLL", "a dash connect is a guaranteed kill (no survival roll)")
|
||||
bull.set("dashing", false)
|
||||
|
||||
_finish()
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
print("Results: %d passed, %d failed" % [_pass, _fail])
|
||||
quit(1 if _fail > 0 else 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://wplxv71pxkrl
|
||||
@@ -0,0 +1,67 @@
|
||||
extends SceneTree
|
||||
## Thrown-spear hit test. The bull's body sits on collision layer BULL, so a spear whose mask
|
||||
## only covered WORLD flew straight through it — every throw whiffed, even against a stationary
|
||||
## bull. This launches a spear dead-on at a still fake bull and asserts the projectile masks BULL
|
||||
## and actually lands the hit. Run: godot --headless --script res://tests/matador_spear_test.gd
|
||||
|
||||
# physics_layers.gd is pure constants (safe to preload); spear_projectile.gd references the
|
||||
# Settings autoload, whose global identifier isn't registered when a --script entry compiles its
|
||||
# preloads — so it's loaded at runtime inside _run instead, once the autoloads exist.
|
||||
const PhysicsLayers = preload("res://physics_layers.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 _run() -> void:
|
||||
# Stationary fake bull at the origin, on the BULL layer like the real one.
|
||||
var bull := CharacterBody3D.new()
|
||||
bull.collision_layer = PhysicsLayers.BULL
|
||||
bull.collision_mask = 0
|
||||
bull.add_to_group(&"player")
|
||||
bull.set_script(load("res://tests/_fake_bull.gd"))
|
||||
var bcs := CollisionShape3D.new()
|
||||
var bshape := CapsuleShape3D.new()
|
||||
bshape.radius = 0.6
|
||||
bshape.height = 1.4
|
||||
bcs.shape = bshape
|
||||
bull.add_child(bcs)
|
||||
root.add_child(bull)
|
||||
bull.global_position = Vector3.ZERO
|
||||
await physics_frame
|
||||
|
||||
# Launch a spear flat, dead-on from 3 m out; low gravity so the short flight stays level.
|
||||
var spear_script := load("res://spear_projectile.gd")
|
||||
var mesh := (load("res://Spear.tscn") as PackedScene).instantiate() as Node3D
|
||||
root.add_child(mesh)
|
||||
var origin := Vector3(0.0, 0.0, -3.0)
|
||||
var spear := spear_script.launch(root, mesh, origin, Vector3(0.0, 0.0, 12.0), 0.05) as RigidBody3D
|
||||
|
||||
_ok(spear.collision_mask & PhysicsLayers.BULL != 0, "spear masks the BULL layer (can collide with the bull)")
|
||||
|
||||
for i in 90:
|
||||
await physics_frame
|
||||
if bull.hits >= 1:
|
||||
break
|
||||
|
||||
_ok(bull.hits >= 1, "thrown spear hits a stationary bull")
|
||||
|
||||
_finish()
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
print("Results: %d passed, %d failed" % [_pass, _fail])
|
||||
quit(1 if _fail > 0 else 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dcwtku2xvxswa
|
||||
@@ -0,0 +1,101 @@
|
||||
extends SceneTree
|
||||
## Matador stab-reliability test. The matador runs in, plants at mat_stab_standoff, and its stab
|
||||
## damages off the sword's own BladeHitbox collider (armed only during the thrust) — NOT a distance
|
||||
## check. This drives the attack tick against a STATIONARY, real-sized bull placed beyond the
|
||||
## standoff and asserts it (a) gores the bull when the thrust physically reaches it, (b) lands the
|
||||
## hit during the thrust and not the wind-up/walk-up, and (c) plants at the standoff, not inside the
|
||||
## bull, and (d) keeps landing on repeat stabs from the same spot (the blade re-arms each swing).
|
||||
## Run: godot --headless --script res://tests/matador_stab_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 _run() -> void:
|
||||
var dp := root.get_node("/root/DP")
|
||||
var standoff: float = dp.f("mat_stab_standoff")
|
||||
var strike_at: float = dp.f("mat_stab_strike_at")
|
||||
|
||||
# Stationary, real-sized bull beyond the standoff — the matador runs in, plants at the standoff,
|
||||
# and its THRUST (not the walk-up) has to reach across the gap to gore it.
|
||||
var bull := CharacterBody3D.new()
|
||||
bull.collision_layer = 2
|
||||
bull.collision_mask = 0
|
||||
bull.add_to_group(&"player")
|
||||
bull.set_script(load("res://tests/_fake_bull.gd"))
|
||||
var bcs := CollisionShape3D.new()
|
||||
var bshape := CapsuleShape3D.new()
|
||||
bshape.radius = 0.75
|
||||
bshape.height = 1.845
|
||||
bcs.shape = bshape
|
||||
bull.add_child(bcs)
|
||||
root.add_child(bull)
|
||||
bull.global_position = Vector3(0.0, 0.0, standoff + 3.0)
|
||||
|
||||
var mat := (load("res://Matador.tscn") as PackedScene).instantiate() as CharacterBody3D
|
||||
root.add_child(mat) # _ready acquires the bull from the "player" group
|
||||
mat.global_position = Vector3.ZERO
|
||||
mat.set_physics_process(false) # we drive the attack tick ourselves, isolated from the AI
|
||||
await physics_frame
|
||||
mat.call("_acquire_bull") # normally done in _physics_process, which we disabled
|
||||
|
||||
_ok(mat.get("_bull") == bull, "matador acquired the bull")
|
||||
mat.call("_carry_sword", true) # actually draw into the hand so the BladeHitbox rides the thrust
|
||||
mat.call("_start_attack")
|
||||
|
||||
dp.call("set_value", "mat_stab_followup_chance", 0.0) # isolate repeat stabs from the break-off roll
|
||||
dp.call("set_value", "mat_stab_recovery", 0.0) # no recovery beat gating back-to-back stabs
|
||||
dp.call("set_value", "mat_taunt_after_hit", 0.0) # don't break off to taunt after a landed hit
|
||||
|
||||
var min_dist := 999.0
|
||||
var first_hit_phase := -1.0
|
||||
var last_hits := 0
|
||||
for i in 300: # several swings' worth of ticks (approach + repeated stabs)
|
||||
mat.call("_tick_attack", 1.0 / 60.0)
|
||||
var d := mat.global_position.distance_to(bull.global_position)
|
||||
min_dist = minf(min_dist, d)
|
||||
if bull.hits > last_hits:
|
||||
if first_hit_phase < 0.0:
|
||||
first_hit_phase = mat.call("_swing_phase") # phase on the frame the first hit landed
|
||||
last_hits = bull.hits
|
||||
await physics_frame
|
||||
|
||||
_ok(bull.hits >= 1, "the sword's thrust reaches across the standoff and gores the bull")
|
||||
_ok(first_hit_phase >= strike_at - 0.1, "hit lands in the thrust, not the wind-up (phase %.2f)" % first_hit_phase)
|
||||
_ok(bull.hits >= 2, "repeat stabs from the same spot keep landing (%d hits)" % bull.hits)
|
||||
_ok(min_dist >= standoff - 0.5, "matador plants at the standoff, not inside the bull (closest %.2f m)" % min_dist)
|
||||
|
||||
# Anti-spam: once a stab CONNECTS, a high mat_taunt_after_hit must break the matador off ATTACK
|
||||
# (into a taunt/retreat) instead of drilling the bull again. Force the roll and confirm it leaves.
|
||||
dp.call("set_value", "mat_taunt_after_hit", 1.0)
|
||||
bull.hits = 0
|
||||
mat.call("_start_attack")
|
||||
var broke_off := false
|
||||
for i in 200:
|
||||
mat.call("_tick_attack", 1.0 / 60.0)
|
||||
if mat.call("ai_state_name") != "ATTACK":
|
||||
broke_off = true
|
||||
break
|
||||
await physics_frame
|
||||
_ok(broke_off, "a landed stab breaks the matador off ATTACK (taunt/retreat), not another thrust")
|
||||
_ok(bull.hits >= 1, "the break-off only fires after the stab actually connected (%d hits)" % bull.hits)
|
||||
|
||||
_finish()
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
print("Results: %d passed, %d failed" % [_pass, _fail])
|
||||
quit(1 if _fail > 0 else 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://deueaav5qscnc
|
||||
@@ -0,0 +1,91 @@
|
||||
extends SceneTree
|
||||
## A taunting matador must answer a charge instead of posing through it: hurl a spear at a bull
|
||||
## barrelling in from range, or switch to the sword (brace/cite) to meet a closer rush. Drives
|
||||
## _tick_wander on a matador mid-taunt (_idle_timer > 0) against a bull charging straight at it and
|
||||
## asserts the state it breaks into by range; a slow / non-aimed bull leaves it taunting.
|
||||
## Run: godot --headless --script res://tests/matador_taunt_react_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.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
|
||||
|
||||
|
||||
func _make_taunting_matador(_bull: CharacterBody3D) -> CharacterBody3D:
|
||||
var mat := (load("res://Matador.tscn") as PackedScene).instantiate() as CharacterBody3D
|
||||
root.add_child(mat)
|
||||
mat.global_position = Vector3.ZERO
|
||||
mat.set_physics_process(false) # we drive _tick_wander ourselves, no brain
|
||||
await physics_frame
|
||||
mat.call("_acquire_bull")
|
||||
mat.set("_idle_timer", 5.0) # mid-taunt: standing and posturing
|
||||
mat.set("_throw_aim_cd", 0.0) # spear ready
|
||||
return mat
|
||||
|
||||
|
||||
# Park the bull at `dist` straight ahead (+Z) of the matador, charging back toward it at `speed`.
|
||||
func _charge_from(bull: CharacterBody3D, dist: float, speed: float) -> void:
|
||||
bull.global_position = Vector3(0.0, 0.0, dist)
|
||||
bull.velocity = Vector3(0.0, 0.0, -speed)
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var bull := _make_bull()
|
||||
|
||||
# (a) Far charge (10 m, past brace range but within throw range) → get the spear off.
|
||||
var mat_a: CharacterBody3D = await _make_taunting_matador(bull)
|
||||
_charge_from(bull, 10.0, 30.0)
|
||||
mat_a.call("_tick_wander", 1.0 / 60.0)
|
||||
_ok(mat_a.call("ai_state_name") == "THROW", "a taunting matador hurls a spear at a charge from range")
|
||||
|
||||
# (b) Closer rush (3 m, inside brace range) → switch to the sword and cite it.
|
||||
var mat_b: CharacterBody3D = await _make_taunting_matador(bull)
|
||||
_charge_from(bull, 3.0, 30.0)
|
||||
mat_b.call("_tick_wander", 1.0 / 60.0)
|
||||
_ok(mat_b.call("ai_state_name") == "BRACE", "a taunting matador switches to the sword for a closer rush")
|
||||
|
||||
# (c) A slow bull (below charge speed) isn't a charge — keep taunting.
|
||||
var mat_c: CharacterBody3D = await _make_taunting_matador(bull)
|
||||
_charge_from(bull, 10.0, 3.0)
|
||||
mat_c.call("_tick_wander", 1.0 / 60.0)
|
||||
_ok(mat_c.call("ai_state_name") == "WANDER", "a taunting matador ignores a slow (non-charging) bull")
|
||||
|
||||
# (d) A fast bull aimed AWAY from the matador isn't charging at it — keep taunting.
|
||||
var mat_d: CharacterBody3D = await _make_taunting_matador(bull)
|
||||
bull.global_position = Vector3(0.0, 0.0, 10.0)
|
||||
bull.velocity = Vector3(0.0, 0.0, 30.0) # heading further away, not at the matador
|
||||
mat_d.call("_tick_wander", 1.0 / 60.0)
|
||||
_ok(mat_d.call("ai_state_name") == "WANDER", "a taunting matador ignores a charge not aimed at it")
|
||||
|
||||
_finish()
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
print("Results: %d passed, %d failed" % [_pass, _fail])
|
||||
quit(1 if _fail > 0 else 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://c1r546ktiw2ka
|
||||
Reference in New Issue
Block a user