gun
¶
Gun class fields
method documentation coming soon (or never...)
The appearance and handling of guns by default are defined by two table fields: their consts and their properties. properties define nearly everything, from how a gun handles to how it looks, what model it uses, while consts define attributes that should never change, like bones within the gun, framerates, hwether the gun is allowed to have certain attributes at all. The other fields of the class define tracking variables or other important things for the internal workings.
There are essentially only 2 fields you must define to register a gun: itemstring, name, and properties To have a functional gun however, more will need to be changed in terms of properties.
Guns4d uses a class system for most moving parts- including the gun. New guns therefore are created with the :inherit(def) method, where def is the definition of your new gun- or rather the changed parts of it. So to make a new gun you can run Guns4d.gun:inherit() or you can do the same thing with a seperate class of weapons. Set name to "__template" for template classes of guns.
properties¶ | properties which define the vast majority of gun attributes and may change accross instances |
consts¶ | constants which define gun attributes and should not be changed in an instance of the gun |
offsets¶ | runtime storage of offsets generated by recoil sway wag or any other element. |
name¶ |
|
itemstack¶ |
|
meta¶ |
|
id¶ |
|
gun_entity¶ |
|
inventory_image_magless¶ |
|
inventory_image¶ |
|
itemstring¶ |
|
_registered¶ | list of registered guns, DO NOT MODIFY I really need a metatable for this class... |
bolt_charged¶ |
|
particle_spawners¶ |
|
current_firemode¶ |
|
walking_tick¶ |
|
time_since_last_fire¶ |
|
time_since_creation¶ |
|
rechamber_time¶ |
|
burst_queue¶ |
|
muzzle_flash¶ |
|
gun_translation¶ |
|
property_modifiers¶ |
|
reload¶ | and ordered list of reloading states used by default_controls. the default reload states for a magazine operated weapon, copied from the m4. Example
|
model_bounding_box¶ | a table {x1,y1,z1,x2,y2,z2} specifying the bounding box of the model. The first 3 (x1,y1,z1) are the lower of their counterparts |
sounds¶ | a table of soundspecs to be referenced by other functions |
animation_rotation¶ |
|
gun_axial¶ | total offsets of the gun in the same format as a an offset [[total_offsets = { |
the table containing every attribute of the gun.
hip¶ | |
ads¶ | |
firemodes¶ | |
firemode_inventory_overlays¶ | |
recoil¶ | |
sway¶ | |
wag¶ | |
charging¶ | |
ammo¶ | |
visuals¶ | |
breathing_scale¶ |
|
flash_offset¶ |
|
firerateRPM¶ |
|
burst¶ |
|
infinite_inventory_overlay¶ |
|
pc_control_actions¶ |
|
touch_control_actions¶ |
|
offset¶ |
|
axis_rotation_ratio¶ | the ratio that the look rotation is expressed through player_axial (rotated around the viewport) rotation as opposed to gun_axial (rotating the entity). |
sway_vel_mul¶ | sway speed multiplier while at hip |
sway_angle_mul¶ | sway angle multiplier while at hip+ |
defines the overlay on the gun item for each firemode. These are selected automatically by firemode string. Defaults are as follows:
IMPORTANT: expects fields to be tables containing a "gun_axial" and "player_axial" field.
property = {
gun_axial = type
player_axial = type
}
--using a vector...
property = {
gun_axial={x=float, y=float},
player_axial={x=float, y=float}
}`
velocity_correction_factor¶ |
|
target_correction_factor¶ |
|
target_correction_max_rate¶ |
|
angular_velocity_max¶ |
|
angular_velocity¶ |
|
bias¶ |
|
hipfire_multiplier¶ |
|
IMPORTANT: expects fields to be tables containing a "gun_axial" and "player_axial" field. In the same format as gun.properties.recoil
cycle_speed¶ |
|
decay_speed¶ |
|
offset¶ |
|
require_draw_on_swap¶ |
|
bolt_charge_mode¶ |
|
draw_time¶ |
|
draw_animation¶ |
|
draw_sound¶ |
|
magazine_only¶ |
|
accepted_bullets¶ |
|
accepted_magazines¶ |
|
initial_mag¶ |
|
a list of tables each containing offset vectors These are required for automatic initialization of offsets.
recoil = {
gun_axial = {x=0, y=0}, --rotation of the gun around it's origin
player_axial = {x=0, y=0}, --rotation of the gun around the bone it's attached to
--translations of gun
player_trans = {x=0, y=0, z=0}, --translation of the bone the gun is attached to
eye_trans = {x=0, y=0, z=0}, --trnaslation of the player's look
gun_tran = {x=0, y=0, z=0}s --translation of the gun relative to the bone it's attachted to.
}
These are variables that are constant across the class and should usually not ever be changed by instnaces
KEYFRAME_SAMPLE_PRECISION¶ | frequency of keyframe samples for animation offsets and |
DEFAULT_MAX_HEAR_DISTANCE¶ | default max hear distance when not specified |
DEFAULT_FPS¶ |
|
HAS_RECOIL¶ |
|
HAS_BREATHING¶ |
|
HAS_SWAY¶ |
|
HAS_WAG¶ |
|
HAS_GUN_AXIAL_OFFSETS¶ |
|
ANIMATIONS_OFFSET_AIM¶ | wether animations create an offset |
LOOP_IDLE_ANIM¶ | whether the idle animation changes or not |
THIRD_PERSON_GAIN_MULTIPLIER¶ | general gain multiplier for third persons when hearing sounds |
ROOT_BONE¶ | the root bone of the gun (for animation offsets) |
MAG_BONE¶ |
|
ARM_RIGHT_BONE¶ |
|
ARM_LEFT_BONE¶ |
|