B7: Weapon roster and consumables
Eight slot weapons: the six from the design plus the rivet repeater (fast, short-range automatic) and the harpoon gun (slow heavy bolt, 2.5x damage to built pieces). Four quality tiers, Rusted to Captain's, scale damage and reload time. The line thrower now yanks the shooter towards where its line lands, through a data field (pull_speed) any weapon can use. Four consumables: sailcloth bandage (heals to 75), brine tonic, cork vest and the new tar patch. Fire with one held starts using it if it would help; it takes effect after its use time. Changing slot, dropping, sprinting, swimming or elimination interrupts it and uses nothing up. All checks run on the server. A data-validation test covers every weapon, tier, consumable and ammunition type, including unknown stat keys, name format and that every ammo type is used. The GDD's weapons section lists the roster. Closes #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+20
-6
@@ -64,7 +64,7 @@ static func start_reload(player: SimEntity) -> bool:
|
||||
return false
|
||||
if player.ammo[Inventory.ammo_index(def.ammo_code)] <= 0:
|
||||
return false
|
||||
player.reload_ticks = maxi(def.reload_ticks(), 1)
|
||||
player.reload_ticks = maxi(def.reload_ticks(player.slot_tiers[slot]), 1)
|
||||
return true
|
||||
|
||||
|
||||
@@ -207,6 +207,8 @@ static func body_box(player: SimEntity) -> AABB:
|
||||
## Applies a pellet's hit. `distance` is from where the shot started.
|
||||
static func _apply_hit(sim: Simulation, attacker: int, def: ItemDef, tier: int, hit: Hit, distance: float) -> void:
|
||||
sim.events.append({"type": "impact", "player": attacker, "item": def.code, "point": hit.point, "hit": hit.kind, "target": hit.target})
|
||||
if def.pull_speed > 0.0 and hit.kind != HIT_NONE:
|
||||
_pull(sim, sim.entities.find(attacker), hit.point, def.pull_speed)
|
||||
if def.damage <= 0:
|
||||
return
|
||||
var amount: float = def.damage_at(distance) * tier_multiplier(tier)
|
||||
@@ -216,15 +218,27 @@ static func _apply_hit(sim: Simulation, attacker: int, def: ItemDef, tier: int,
|
||||
amount *= def.headshot_multiplier
|
||||
damage_player(sim, sim.entities.find(hit.target), roundi(amount), attacker, hit.headshot)
|
||||
HIT_PIECE:
|
||||
sim.damage_piece(hit.target, roundi(amount * Tuning.WEAPON_STRUCTURE_FACTOR), "weapon")
|
||||
sim.damage_piece(hit.target, roundi(amount * def.structure_factor), "weapon")
|
||||
HIT_PROP:
|
||||
if sim.damage_prop(hit.target, roundi(amount * Tuning.WEAPON_STRUCTURE_FACTOR)):
|
||||
if sim.damage_prop(hit.target, roundi(amount * def.structure_factor)):
|
||||
sim.events.append({"type": "prop_destroyed", "prop": hit.target})
|
||||
|
||||
|
||||
## Damage multiplier for a quality tier. Tiers arrive with the weapon roster (B7).
|
||||
static func tier_multiplier(_tier: int) -> float:
|
||||
return 1.0
|
||||
## Damage multiplier for a quality tier, from Tuning.WEAPON_TIERS.
|
||||
static func tier_multiplier(tier: int) -> float:
|
||||
return float(ItemDef.tier_stats(tier)["damage"])
|
||||
|
||||
|
||||
## Yanks a player on foot towards `point`, lifting them off the ground.
|
||||
static func _pull(sim: Simulation, player: SimEntity, point: Vector3, speed: float) -> void:
|
||||
if player == null or player.eliminated or player.drop_state != Drop.NONE or player.swimming:
|
||||
return
|
||||
var direction: Vector3 = point - Harvest.eye(player)
|
||||
if direction.length_squared() < 0.0001:
|
||||
return
|
||||
player.velocity = direction.normalized() * speed + Vector3(0.0, Tuning.LINE_PULL_LIFT, 0.0)
|
||||
player.on_ground = false
|
||||
sim.events.append({"type": "line_pull", "player": player.id, "point": point})
|
||||
|
||||
|
||||
## Takes `amount` from armor, then health. Returns the damage actually done.
|
||||
|
||||
Reference in New Issue
Block a user