Skip to content

ItemDefinitionEquipmentWeapon ​

Inherits: ItemDefinitionEquipment < ItemDefinition < DatabaseResource < Resource

Weapon items that can be equipped to provide combat capabilities Inherits all equipment functionality and adds weapon-specific properties for damage, speed, and combat

Properties ​

intweapon_class
floatweapon_scale1.0
Meshammo_modelnull
Vector3ammo_model_rotationVector3.ZERO
boolno_damagefalse
intweapon_damage_min10
intweapon_damage_max15
floatweapon_speed2.4
intweapon_damage_type0
Stringcollision_template"medium_capsule"

Methods ​

Dictionaryget_effective_stat_bonuses( item_instance: ItemInstance )
floatget_average_damage()
floatget_damage_variance()
intget_weapon_damage()
Stringget_damage_range_text()
floatget_weapon_speed()
voidset_weapon_speed( new_speed: float )
floatget_base_attacks_per_second()
floatget_attacks_per_minute()
floatget_base_damage_per_second()
Stringget_speed_category()
intget_weapon_damage_type()
voidset_weapon_damage_type( new_damage_type: int )
booldeals_damage_type( damage_type: int )
booldeals_damage()
boolis_utility_weapon()
Stringget_damage_type_display()
Shape3Dget_weapon_collision_shape()
boolvalidate_collision_template()
intget_weapon_hand_requirement()
WeaponTypeDefinitionget_weapon_type_definition()
Array[EquipmentSlotDefinition]get_blocked_equipment_slots()
WeaponClassDefinitionget_weapon_class()
boolhas_valid_weapon_type()
floatget_weapon_scale()
voidset_weapon_scale( new_scale: float )
boolcan_use( user: Entity, item_instance: ItemInstance = null )

Property descriptions ​

Weapon Properties

int weapon_class ​

Weapon class definition that determines weapon type, hand requirements, and equipment slot compatibility

float weapon_scale = 1.0 ​

Visual scale multiplier applied to the weapon model when equipped

Mesh ammo_model = null ​

The mesh of the projectile a ranged weapon shoots when no ammo item is spent (an NPC, or a weapon that needs no ammo): the arrow of a bow. The ammo item that is spent has its own mesh and wins over this one. Empty: the projectile effect shows its own.

Vector3 ammo_model_rotation = Vector3.ZERO ​

How the ammo model is turned so that its tip points along +Y, in degrees.

Weapon Combat

bool no_damage = false ​

If true, this weapon provides no damage (cosmetic/utility weapon)

int weapon_damage_min = 10 ​

Minimum damage this weapon can deal in a single attack

int weapon_damage_max = 15 ​

Maximum damage this weapon can deal in a single attack

float weapon_speed = 2.4 ​

Base attack speed in seconds between swings

int weapon_damage_type = 0 ​

Type of damage this weapon deals - affects resistances and damage calculations

String collision_template = "medium_capsule" ​

Collision template name for weapon hitbox detection during attacks

Method descriptions ​

Dictionary get_effective_stat_bonuses( item_instance: ItemInstance ) ​

Override to include weapon combat stats in the stat bonuses

float get_average_damage() ​

Get average damage for calculations

float get_damage_variance() ​

Get damage variance (±amount around average)

int get_weapon_damage() ​

Get random damage within the weapon's range (for direct weapon attacks)

String get_damage_range_text() ​

Get damage range as string for UI

float get_weapon_speed() ​

Get the weapon's base swing speed in seconds

void set_weapon_speed( new_speed: float ) ​

Set the weapon's swing speed

float get_base_attacks_per_second() ​

Get base attacks per second (before character modifiers)

float get_attacks_per_minute() ​

Get attacks per minute for display

float get_base_damage_per_second() ​

Calculate base DPS (before character bonuses)

String get_speed_category() ​

Get weapon speed category for UI display

int get_weapon_damage_type() ​

Get the weapon's damage type

void set_weapon_damage_type( new_damage_type: int ) ​

Set the weapon's damage type

bool deals_damage_type( damage_type: int ) ​

Check if weapon deals a specific damage type

bool deals_damage() ​

Check if this weapon deals damage

bool is_utility_weapon() ​

Check if this is a utility/cosmetic weapon

String get_damage_type_display() ​

Get damage type for display (capitalize first letter)

Shape3D get_weapon_collision_shape() ​

The collision shape of the weapon, from its template.

bool validate_collision_template() ​

Does the collision template of the weapon exist?

int get_weapon_hand_requirement() ​

How many hands the weapon takes: 2 when its weapon type blocks other slots (a two-handed weapon blocks the off hand), else 1

WeaponTypeDefinition get_weapon_type_definition() ​

The weapon type of the class of the weapon, or null.

Array[EquipmentSlotDefinition] get_blocked_equipment_slots() ​

The slots this weapon blocks while it is worn.

WeaponClassDefinition get_weapon_class() ​

The weapon class of the weapon, or null.

bool has_valid_weapon_type() ​

Check if weapon type is valid

float get_weapon_scale() ​

Get the weapon scale

void set_weapon_scale( new_scale: float ) ​

Set the weapon scale

bool can_use( user: Entity, item_instance: ItemInstance = null ) ​

Override equipment validation to include weapon-specific checks