#!/usr/bin/env bash
# Task #52 respawn cycle: A (BT_GOTO+AUTOFIRE) kills B.  B's master dies ->
# its death transition dispatches VehicleDead(-1) to B's BTPlayer -> death
# bookkeeping, playerVehicle severed, +5s re-post -> engine drop-zone hunt ->
# DropZoneReply -> CreatePlayerVehicle (a NEW mech; the wreck stays).
# Watch B's log for the [death]/[score] cycle + the second vehicle create.
set -x
cd /c/git/bt411/content || exit 1
rm -f mp_a.log mp_b.log

# B first + stationary target; death/score logs armed on BOTH.
BT_LOG=mp_b.log BT_AFFINITY=0x2 BT_MP_LOG=1 BT_MP_NET=1 BT_DEATH_LOG=1 BT_SCORE_LOG=1 \
  ../build/Debug/btl4.exe -egg MP.EGG -net 1601 &
sleep 2
BT_LOG=mp_a.log BT_AFFINITY=0x1 BT_GOTO="enemy" BT_AUTOFIRE=1 BT_MP_LOG=1 BT_GOTO_LOG=1 BT_DEATH_LOG=1 BT_SCORE_LOG=1 \
  ../build/Debug/btl4.exe -egg MP.EGG -net 1501 &
sleep 4
python ../tools/btconsole.py MP.EGG 127.0.0.1:1501 127.0.0.1:1601 &
PC=$!
# long window: walk + kill (~40-60s) + 5s respawn + settle
sleep 100
kill $PC 2>/dev/null
taskkill //F //IM btl4.exe 2>/dev/null
taskkill //F //IM python.exe 2>/dev/null
echo "=== DONE ==="
