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) orRangedLine(straight line, range in cells).- Damage and
DamageType(checked against enemy weaknesses and resistances). - Blast radius > 0 makes the attack explosive.
DistanceFalloffscales 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/BurstIntervalSecondsfor bursts;AttackSound,MissSound,ImpactSoundfor 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¶
- Duplicate a prefab of the same category from
Prefabs/Weaponsand rename it. - On the weapon component (
MeleeWeapon,RangeWeaponorThrowableWeapon), setslot,weaponName(key in theWeaponstable),weaponIcon,positionOffsetX/positionOffsetY,ammunitionType(Infinityfor none) andturnProfile. - Run Tools > AiasTech > Generate Weapon IDs. The
weaponIdcomes from the prefab GUID and is what the save stores. - Register the prefab in
Resources/WeaponRegistry.asset. Unregistered weapons disappear when a save loads. - Animate it:
IdleplusShot(ranged) orAttack(melee and throwable). See Sprites and animation. - Give it to the player: the level's
LevelCoreStarting Weapons lists, a pickup (below), or the shop (see Player, pickups, items and shop). - Add the name to the
Weaponstable in both languages. - 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.