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¶
- Create the item
DA_Item_<Name>, withCategoryon Weapon, a uniqueItemSaveIdand aWorldMesh. - In
Content/ZombieSurvival/DataAssets/Weapons/Childs/, duplicate aDA_Weapon_*, or create a Data Asset of the classPDA_WeaponDef. Name itDA_Weapon_<Name>. - Fill its fields (table below). Point
Itemat the item andWeaponMeshat the held mesh, then adjustHeldTransformuntil the mesh sits right in the hand. - On the item, set
WeaponDefto the weapon. The two references are read in both directions. - Add the item to
DataAssets/Items/Childs/DA_ItemRegistry_Default. - 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
Contentsin 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¶
- Open
Content/ZombieSurvival/Maps/L_Worldand press Play. - Press T, type
/give <ItemSaveId>and press Enter. - Press Tab and left-click the weapon's row to equip it. Check the held mesh in the hand.
- Find a zombie in the street and press Left mouse near it to swing.
- 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.