Skip to content

Create a weapon

A weapon is a visual prefab (first-person sprite and Animator) plus an attack profile (TurnWeaponProfile). The weapon spawns no physical projectiles and applies no damage itself: the GridAttackPerformer resolves the attack on the grid.

Included prefabs (Prefabs/Weapons) and profiles (Data/Weapons/TurnProfiles): Melee-HuntingKnife (infinite ammo), Range-Pistol (Bullet), Range-Shotgun (Shell, damage falls off with distance), Range-Rifle (Clip, 3-shot burst), Range-PlasmaLauncher (Plasma, explosive) and Throwable-Grenade (Grenade, arcing explosive). With no weapon, the player punches (Unarmed_Melee).

Set up the attack profile

Create one with Create > AiasTech > Weapon > Turn Profile. Player weapons and enemy attacks use the same asset type.

  • Kind: Melee (always 1 cell) or RangedLine (straight line, range in cells).
  • Damage and DamageType (checked against enemy weaknesses and resistances).
  • Blast radius > 0 makes the attack explosive. DistanceFalloff scales damage by distance (ignored for explosives).
  • ImpactNormalized: point in the attack clip where the hit lands or the shot fires (0 = start, 1 = last frame).
  • BurstCount / BurstIntervalSeconds for bursts; AttackSound, MissSound, ImpactSound for audio.

Attack rules: only the first target in the line is hit (the shotgun too). A miss still spends ammo and the turn. With no ammo, nothing happens and the turn is not spent. Each burst shot spends one round; the burst stops when ammo runs out.

Add a new weapon

  1. Duplicate a prefab of the same category from Prefabs/Weapons and rename it.
  2. On the weapon component (MeleeWeapon, RangeWeapon or ThrowableWeapon), set slot, weaponName (key in the Weapons table), weaponIcon, positionOffsetX / positionOffsetY, ammunitionType (Infinity for none) and turnProfile.
  3. Run Tools > AiasTech > Generate Weapon IDs. The weaponId comes from the prefab GUID and is what the save stores.
  4. Register the prefab in Resources/WeaponRegistry.asset. Unregistered weapons disappear when a save loads.
  5. Animate it: Idle plus Shot (ranged) or Attack (melee and throwable). See Sprites and animation.
  6. Give it to the player: the level's LevelCore Starting Weapons lists, a pickup (below), or the shop (see Player, pickups, items and shop).
  7. Add the name to the Weapons table in both languages.
  8. Test switching, running out of ammo, picking up a duplicate, and save/load.

Never change a published weapon ID

Existing saves reference weapons by weaponId.

Don't animate the weapon root

PlayerWeaponManager positions the root with the offsets. Put the SpriteRenderer on a child (like Visual on Melee-HuntingKnife) and animate the child.

Attack sounds play through GridAttackPerformer.audioSource (mixer group Weapon), not through the weapon.

Add a weapon pickup

Duplicate a prefab from Prefabs/PickUp/Weapon. On PickUpWeapon, set the weapon prefab (name and sprite come from it) and DuplicateAmmunitionType / DuplicateAmmunitionAmount, the ammo given when the player already has the weapon. A new weapon gives no extra ammo. A duplicate with full ammo stays on the floor.

Ammo

Start and max values per type are in Resources/GameSettings.asset (AmmunitionStartMax); HUD icons in AmmunitionIcon.

To add an ammo type, add a value to the AmmunitionType enum without renumbering existing values (they are saved), set start and max in GameSettings, add an icon, and create an ammo box in Prefabs/PickUp/AmmoBox.

Switch weapons

1 / 2 / 3 select melee / ranged / throwable (press again to cycle); the mouse wheel moves within the category. Switching is ignored while the shop, inventory or a dialogue is open.

Limits

No reload, fire rate or physical projectiles. No public API to remove, drop or reorder weapons. A new attack shape (cone, area around the player) requires extending TurnAttackKind and Combat.

For internals, see Assets/DungeonCrawler/Scripts/Weapon/ARCHITECTURE.md.