Skip to content

Add a melee weapon

A melee weapon is two Data Assets that point at each other: an item that lives in the bag, and a weapon definition that holds its numbers. The survivor carries it, equips it, stows it in a weapon position and swings it.

Steps

  1. Create the item DA_Item_<Name>, with Category on Weapon, a unique ItemSaveId and a WorldMesh.
  2. In Content/ZombieSurvival/DataAssets/Weapons/Childs/, duplicate a DA_Weapon_*, or create a Data Asset of the class PDA_WeaponDef. Name it DA_Weapon_<Name>.
  3. Fill its fields (table below). Point Item at the item and WeaponMesh at the held mesh, then adjust HeldTransform until the mesh sits right in the hand.
  4. On the item, set WeaponDef to the weapon. The two references are read in both directions.
  5. Add the item to DataAssets/Items/Childs/DA_ItemRegistry_Default.
  6. Put it where players can find it. On Pine Hollow, add the item to a loot table. On a small map of your own, put it in a container's Contents in the spawn plan.
Field What it does
Damage Hit points removed per hit.
AttacksPerSecond The attack rate.
Range Reach in uu.
StaggerChance The chance, 0 to 1, that a hit interrupts the zombie.
KnockbackForce The impulse that pushes the zombie away.
CritChance, CritMultiplier The chance of a critical hit, and its damage multiplier.
WeaponMesh The static mesh held in hand.
HeldTransform How that mesh sits in the hand socket. Align it here, never in a graph.
Item The PDA_ItemDef that stands for the weapon in the inventory.
AttackSound, HitSound The swing and the impact. Empty: silent.
SkillTag The skill the weapon trains and reads: Skill.BluntWeapons, Skill.EdgedWeapons or Skill.Firearms. Empty, as on bare fists: none.
CarryKind Which weapon positions take it: Small, Handgun or Long.
PoseCategory A Weapon.Pose.* tag. It picks the animation layer linked while the weapon is held.

A swing costs 2 endurance, plus 1 per kg of the weapon. Those numbers are tuned in DA_Endurance_Default. The attack cone, the delay between the swing and the blow, and the stomp are not weapon fields. They are Class Defaults of BP_Survivor.

Test it

  1. Open Content/ZombieSurvival/Maps/L_World and press Play.
  2. Press T, type /give <ItemSaveId> and press Enter.
  3. Press Tab and left-click the weapon's row to equip it. Check the held mesh in the hand.
  4. Find a zombie in the street and press Left mouse near it to swing.
  5. Right-click the row. Equip puts the weapon in hand, and Stow on… lists the weapon positions that accept its CarryKind (Belt (left), Belt (right), Back…). Stow it, then press the matching number key to draw it.

If it does not work

  • The weapon is gone after a save and load: its item is not in DA_ItemRegistry_Default.