Files
Bullosseum/tests/matador_charge_test.gd
T
richard 7b6a141767 Reorganize the codebase into role-based folders (snake_case)
Move the 40-odd root-level scripts and scenes into a tree that groups by role,
per the approved roadmap (WS2/WS3): actors/{player,matador,bear}, systems/{combat,
fx,input,debug,render,crowd,config}, ui/, props/ (was tscn_s/). Rename the shell
scene.tscn -> levels/game_shell.tscn and every PascalCase scene to snake_case
(Player.tscn -> player.tscn, MainMenu.tscn -> main_menu.tscn, etc.) so the
case-insensitive web/macOS filesystems can't alias two files together.

Done as a scripted move: each file travels with its .uid; every quoted res:// path
across scenes, scripts, .tres, and project.godot's 9 autoloads is rewritten; the
.godot uid/class cache is rebuilt from scratch. Scenes still resolve by uid, so the
rewrite is belt-and-suspenders. Lint globs (run_tests.sh + both CI workflows) now
walk the new dirs; an orphan animation_tree.gd.uid and 7 pre-existing trailing-
whitespace lints (barrel/torch, never covered by the old root-only glob) are cleaned.

Full suite green on both sides. Asset consolidation (Assets/Animations/fonts ->
art/) is deferred — moving imported .glb/.png/.ttf is safer done in the editor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017KoYBYQgRyY1zDHXMsXY3V
2026-09-06 00:04:41 +03:00

119 lines
5.1 KiB
GDScript

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://actors/matador/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)