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:
+21
-1
@@ -9,7 +9,8 @@
|
||||
## it reacts, how far it sees and how steady its aim is.
|
||||
##
|
||||
## Each tick, in order of urgency: get to ground the coming tide will leave dry; fight
|
||||
## a visible opponent if armed; use a bandage or armor when nobody is in view; pick up
|
||||
## a visible opponent if armed, or go for one within Tuning.BOT_BRAWL_METRES with the
|
||||
## boathook if not; use a bandage or armor when nobody is in view; pick up
|
||||
## useful items and open chests; walk to the next loot marker; otherwise wander the safe
|
||||
## ground, which is where everyone ends up.
|
||||
class_name BotBrain
|
||||
@@ -116,6 +117,9 @@ func think(sim: Simulation, grid: NavGrid, world: BotWorld) -> PlayerCommand:
|
||||
var selection: int = _weapon_slot + 1 if armed else Simulation.BOATHOOK_SLOT
|
||||
var buttons: int = 0
|
||||
var fighting: bool = target != null and target_visible and armed and not me.swimming
|
||||
# Inside a hut or loft too: someone beating on you there gets a swing back.
|
||||
var brawling: bool = (target != null and target_visible and not armed and not me.swimming
|
||||
and not _fleeing and distance <= Tuning.BOT_BRAWL_METRES)
|
||||
var interact: bool = false
|
||||
var walk: bool = true
|
||||
|
||||
@@ -134,6 +138,9 @@ func think(sim: Simulation, grid: NavGrid, world: BotWorld) -> PlayerCommand:
|
||||
elif fighting:
|
||||
state = "fight"
|
||||
_stop()
|
||||
elif brawling:
|
||||
state = "brawl"
|
||||
_stop()
|
||||
elif target != null and armed:
|
||||
state = "chase"
|
||||
_go(_last_seen, 3.0)
|
||||
@@ -191,6 +198,19 @@ func think(sim: Simulation, grid: NavGrid, world: BotWorld) -> PlayerCommand:
|
||||
buttons |= PlayerCommand.BUTTON_FIRE
|
||||
if distance > 10.0:
|
||||
buttons |= PlayerCommand.BUTTON_AIM
|
||||
elif brawling:
|
||||
# No gun: walk in and swing the boathook.
|
||||
var aim: Vector2 = _aim_at(me, target, ItemCatalog.boathook())
|
||||
yaw = aim.x
|
||||
pitch = aim.y
|
||||
var to: Vector2 = Vector2(target.position.x - me.position.x, target.position.z - me.position.z)
|
||||
var gap: float = to.length()
|
||||
if _stage == OUTSIDE:
|
||||
direction = to / gap if gap > Tuning.PLAYER_RADIUS * 2.0 + 0.6 else Vector2.ZERO
|
||||
buttons &= ~PlayerCommand.BUTTON_SPRINT
|
||||
var reach: float = Harvest.eye(me).distance_to(target.position + Vector3(0.0, Movement.body_height(target) * 0.62, 0.0))
|
||||
if reach <= Tuning.BOT_SWING_METRES and sim.tick - _acquired_tick >= _reaction_ticks:
|
||||
buttons |= PlayerCommand.BUTTON_FIRE
|
||||
elif armed and state != "heal" and me.reload_ticks == 0:
|
||||
# Nobody in view: top up the magazine.
|
||||
var def: ItemDef = ItemCatalog.get_def(me.slot_items[_weapon_slot])
|
||||
|
||||
Reference in New Issue
Block a user