H9: Boathook swings damage players; unarmed bots brawl
- Harvest.swing traces the swing as a shot is traced (Weapons.trace, lag compensated). A player reached before terrain, a solid, a prop's grown box or a built piece takes the boathook's damage through Weapons.damage_player, so armor, the kill feed and stats count it. A level swing meets the head and takes the headshot multiplier, as a shot does. - Unarmed bots go for an opponent in view within BOT_BRAWL_METRES (6 m) and swing within BOT_SWING_METRES; inside a hut they swing back without walking in. - Tests: harvest +5 (hit, armor first, out of reach, wall between, player in front of a tree), bot brain +2 (closes in and lands hits; leaves a distant opponent alone). - test_world_replication: an unarmed bot now meets the scripted player early on seed 2, so the test gives it full armor on landing so it lives to build; all assertions unchanged. Closes #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -322,3 +322,34 @@ func test_a_bot_only_match_ends_with_a_winner_and_replays_exactly() -> void:
|
||||
var again: Dictionary = BotBatch.run_match(20261112, 10)
|
||||
assert_eq(again["state_hash"], result["state_hash"], "the same seed plays the same match")
|
||||
assert_eq(again["ticks"], result["ticks"])
|
||||
|
||||
|
||||
func test_an_unarmed_bot_closes_in_and_swings_its_boathook() -> void:
|
||||
_setup()
|
||||
var brain: BotBrain = _bot(HOME, BotBrain.HARD, FACING_X)
|
||||
var victim: SimEntity = _player(HOME + Vector3(4.5, 0.0, 0.0))
|
||||
var start: int = victim.health
|
||||
_ready_world()
|
||||
var swings: Array[int] = [0]
|
||||
for _tick: int in 6 * TICKS:
|
||||
_run(1)
|
||||
for event: Dictionary in sim.events:
|
||||
if event["type"] == "player_hit" and event["victim"] == victim.id and event["player"] == brain.player_id:
|
||||
swings[0] += 1
|
||||
if swings[0] >= 2:
|
||||
break
|
||||
assert_eq(brain.state, "brawl")
|
||||
assert_true(swings[0] >= 2, "landed boathook hits (%d)" % swings[0])
|
||||
assert_true(victim.health < start)
|
||||
var me: SimEntity = sim.entities.find(brain.player_id)
|
||||
assert_true(Vector2(me.position.x - victim.position.x, me.position.z - victim.position.z).length() < 3.0, "closed in")
|
||||
|
||||
|
||||
func test_an_unarmed_bot_leaves_a_distant_opponent_alone() -> void:
|
||||
_setup()
|
||||
var brain: BotBrain = _bot(HOME, BotBrain.HARD, FACING_X)
|
||||
var victim: SimEntity = _player(HOME + Vector3(Tuning.BOT_BRAWL_METRES + 8.0, 0.0, 0.0))
|
||||
_ready_world()
|
||||
_run(3 * TICKS)
|
||||
assert_ne(brain.state, "brawl")
|
||||
assert_eq(victim.health, Tuning.PLAYER_MAX_HEALTH)
|
||||
|
||||
Reference in New Issue
Block a user