B6: Weapon framework and damage model
Weapons fire from the server's own copy of the shooter's eye and look, at the weapon's fire rate, from the loaded magazine. An empty trigger pull or the reload button starts a reload of the weapon's reload time from carried ammunition; switching slots cancels it. Each shot is one or more pellets scattered evenly inside a spread cone from the "weapons" stream. Spread is the hip spread (smaller when aiming), plus bloom that builds in sustained fire, plus a moving or airborne penalty. Hitscan pellets trace at once in 16 m segments; projectile weapons (the whaler's longgun and line thrower) spawn entities that fly under gravity and trace each tick. A trace stops at the first of terrain, a solid (built pieces and props take the damage) or another player's body. Players lose armor first, then health; the top of the body takes the weapon's headshot multiplier; and damage falls off linearly from range_full to range_max. Stats come from ItemDef, so adding a weapon is a Tuning entry only. Closes #20 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,8 @@ var drop: Drop = null
|
||||
|
||||
## Items lying in the world, as entity IDs in ascending order. See Inventory.
|
||||
var pickups: Array[int] = []
|
||||
## Shots in flight, as entity IDs in ascending order. See Weapons.
|
||||
var projectiles: Array[int] = []
|
||||
|
||||
## What happened during the last step(): harvests, destroyed props, placed pieces.
|
||||
## Each is a Dictionary with a "type". Cleared at the start of every step.
|
||||
@@ -130,6 +132,7 @@ func step() -> void:
|
||||
_ride(player, command)
|
||||
else:
|
||||
_apply_command(player, command)
|
||||
Weapons.advance_projectiles(self)
|
||||
_check_eliminations()
|
||||
if drop != null and not drop.finished and drop.is_over(tick + 1):
|
||||
# The end of the route: everyone still aboard goes over the side.
|
||||
@@ -158,6 +161,7 @@ func _apply_command(player: SimEntity, command: PlayerCommand) -> void:
|
||||
Water.update(player, sea_level, drown_dps, sprinting)
|
||||
if player.action_cooldown > 0:
|
||||
player.action_cooldown -= 1
|
||||
Weapons.update(player)
|
||||
var held: int = command.buttons if command != null else 0
|
||||
var pressed: int = held & ~player.prev_buttons
|
||||
player.prev_buttons = held
|
||||
@@ -168,6 +172,8 @@ func _apply_command(player: SimEntity, command: PlayerCommand) -> void:
|
||||
Inventory.interact(self, player)
|
||||
if pressed & PlayerCommand.BUTTON_DROP:
|
||||
Inventory.drop_held(self, player)
|
||||
if command != null and command.is_pressed(PlayerCommand.BUTTON_RELOAD):
|
||||
Weapons.start_reload(player)
|
||||
if command == null or not command.is_pressed(PlayerCommand.BUTTON_FIRE):
|
||||
return
|
||||
if not Building.is_allowed(player):
|
||||
@@ -177,6 +183,8 @@ func _apply_command(player: SimEntity, command: PlayerCommand) -> void:
|
||||
return
|
||||
if player.selected == BOATHOOK_SLOT:
|
||||
Harvest.swing(player, ground, props, events, structures)
|
||||
else:
|
||||
Weapons.fire(self, player, command.is_pressed(PlayerCommand.BUTTON_AIM))
|
||||
|
||||
|
||||
## Marks players whose health reached 0 as eliminated, and drops what they carried.
|
||||
|
||||
Reference in New Issue
Block a user