Files
Bullosseum/tests/matador_spear_test.gd
T
richard 5c1e881a53 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>
2026-09-03 01:01:42 +03:00

68 lines
2.2 KiB
GDScript

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)