What a player holds and uses: a catalogue of weapon definitions that each name a behaviour script by path. Guns, bows, melee, thrown charges, beams, and anything your game writes that none of those describe. Adding a weapon is a script, a definition and a row in a table, never an edit to the addon.
GameSpice addon, MIT licence, built with Claude Code; run examples/weapon_selftest.tscn headless for the tests. Weapons in the games of Zee's Games are defined and fired through it on live servers. Bug reports go to the issue tracker.
- Get Godot 4.7.
- Either use GameSpice Bootstrap, which clones every project and links the addons, or copy
addons/gs_weapon/, gs-core'saddons/gs_core/and GameSpice Combat'saddons/gs_combat/into your project and enable gs-weapon in Project > Project Settings > Plugins.
It needs GameSpice Core and GameSpice Combat. GameSpice Loadout and GameSpice Inventory are optional.
var arsenal := GSWeaponArsenal.new()
arsenal.catalogue = my_catalogue
arsenal.authority = is_server
add_child(arsenal)
arsenal.setup()
arsenal.give(&"rifle")
# once a tick
var ctx := GSWeaponContext.make(player_id, tick, eye_position, aim_direction)
ctx.speed = state.horizontal_speed()
ctx.airborne = not state.is_grounded()
var outcome := arsenal.simulate_tick(command, ctx, previous_command)
for shot in outcome.shots:
combat.resolve_shot(shot)
for spawn in outcome.spawns:
my_projectiles.launch(spawn)
A behaviour is a script that returns what a use produced:
extends "res://addons/gs_weapon/behaviour/gs_weapon_behaviour.gd"
func _use(ctx: GSWeaponContext) -> GSWeaponOutcome:
var out := GSWeaponOutcome.of(GSWeaponOutcome.KIND_SPAWN)
var arrow := GSWeaponSpawn.make(&"arrow", ctx.origin, ctx.direction * lerpf(
25.0, 90.0, ctx.charge
), ctx.entity)
arrow.damage = lerpf(14.0, 70.0, ctx.charge)
arrow.gravity_scale = 1.0
out.add_spawn(arrow)
return out
A bow is a row in a table with fire mode CHARGE; the arsenal accumulates the draw and the behaviour reads ctx.charge. A crossbow is the same row with SEMI and a reload.
| Fire mode | When a use happens |
|---|---|
SEMI |
On the press. |
AUTO |
Repeatedly while held. |
BURST |
A count per press. |
CHARGE |
Builds while held, fires on release. |
HOLD |
Every tick the button is down (beams, physics guns). |
Durations are counted in ticks. A definition that sets authored_tick_rate is scaled to the rate the arsenal runs at, so a weapon written for 64 Hz behaves the same on a 128 Hz server.
- The script is a path, not a
class_name. A GameSpice Cloud pack mounted at runtime does not register itsclass_nameglobals, so naming by path is what lets downloaded content bring its own weapons. - A behaviour decides that a use happened, never what it hit. It returns a
GSWeaponOutcome; gs-combat resolves shots against the world at the tick the trigger was pulled, so a client can predict and the server decide. - Behaviours are pure functions of the context: an origin and direction, a tick, an entity id. Scatter comes from a hash of shooter, tick, use index and pellet index rather than a random stream, so a predicted use matches the server's.
- Ammunition is pooled by name. Weapons with the same ammo type share a reserve. A pickup returns how many rounds fitted.
| Bridge | What it does |
|---|---|
GSWeaponPlayerBridge |
Builds a context from a gs-player: origin at the eye, direction along the view, a stable entity number, view model on the weapon mount, an arsenal from a class definition. |
GSWeaponLoadoutBridge |
Fills an arsenal from what GameSpice Loadout resolved. |
GSWeaponInventoryBridge |
Keeps reserve ammunition matching the bag, which is the truth. |
All are duck-typed; none of those addons is imported.
var ctx := GSWeaponPlayerBridge.context_for(player, tick, index)
var outcome := arsenal.use(ctx)
A weapon lists its mount points. A GSWeaponAttachment names a mount and the numbers it scales or adds, and a GSWeaponFitting records what a player fitted. arsenal.fit(slot, fitting) gives that slot a modified copy of the definition, and GSWeaponNetSync.fitting_specs() replicates the choice. Both machines must share the attachment catalogue.
Import the project once, then run examples/weapon_selftest.tscn headless with Godot.
All of these games from Zee's Games vendor this addon:
- Fatal Contact
- Airdrift
- Playlot
- Hungario
- Buses From Hell
- Smash Copter
- Zombie Zone
- Hide n Seek
- Prop Hunt
- Murder Mystery
- Deathrun
- Wipeout
- Dangerous Delivery
- Look At Me
The whole collection is at zeesgames.com.
MIT licence, see LICENSE. The only closed part of the GameSpice platform is the web back end; you can use your own instead of GameSpice's.
