documentation updates :)

This commit is contained in:
FatalErr42O 2024-12-19 20:35:56 -08:00
parent 938ea52529
commit a2302d2e4d
14 changed files with 922 additions and 267 deletions

View File

@ -1,10 +1,18 @@
-- @within Gun.gun
-- @compact
local gun_default = Guns4d.gun
local mat4 = leef.math.mat4
--I dont remember why I made this, used it though lmao
function gun_default.multiplier_coefficient(multiplier, ratio)
return 1+((multiplier*ratio)-ratio)
end
--update gun, the main function.
--- The entry method for the update of the gun
--
-- calls virtually all functions that begin with `update` once. Also updates subclass
--
-- @tparam float dt
function gun_default:update(dt)
assert(self.instance, "attempt to call object method on a class")
if not self:has_entity() then self:add_entity(); self:clear_animation() end
@ -41,10 +49,11 @@ function gun_default:update(dt)
self.crosshair:update()
end
--finalize transforms
self:update_rotations()
self:update_transforms()
end
function gun_default:update_rotations()
--- updates self.total_offsets which stores offsets for bones
function gun_default:update_transforms()
local total_offset = self.total_offsets
--axis rotations
total_offset.player_axial.x = 0; total_offset.player_axial.y = 0
@ -64,7 +73,7 @@ function gun_default:update_rotations()
--total_offset.gun_axial.x = 0; total_offset.gun_axial.y = 0
end
--manage burstfire
--- Update and fire the queued weapon burst
function gun_default:update_burstfire()
if self.rechamber_time <= 0 then
while true do
@ -80,7 +89,8 @@ function gun_default:update_burstfire()
end
end
end
--cycle firemodes, typically activated by default_controls.lua.
--- cycles to the next firemode of the weapon
function gun_default:cycle_firemodes()
--cannot get length using length operator because it's a proxy table
local length = 0
@ -93,7 +103,8 @@ function gun_default:cycle_firemodes()
self:update_image_and_text_meta()
self.player:set_wielded_item(self.itemstack)
end
--remember to set_wielded_item to self.itemstack! otherwise these changes will not apply!
--- update the inventory information of the gun
function gun_default:update_image_and_text_meta(meta)
meta = meta or self.meta
local ammo = self.ammo_handler.ammo
@ -129,7 +140,8 @@ function gun_default:update_image_and_text_meta(meta)
end
meta:set_string("inventory_image", image)
end
--draw the gun from holster
--- plays the draw animation and sound for the gun, delays usage.
function gun_default:draw()
assert(self.instance, "attempt to call object method on a class")
local props = self.properties
@ -143,7 +155,8 @@ function gun_default:draw()
self.ammo_handler:chamber_round()
self.rechamber_time = props.charging.draw_time
end
--attempt to fire the weapon
--- attempt to fire the gun
function gun_default:attempt_fire()
assert(self.instance, "attempt to call object method on a class")
local props = self.properties
@ -196,6 +209,8 @@ local function rand_sign(b)
if math.random() > b then int=-1 end
return int
end
--- simulate recoil by adding to the recoil velocity (called by attempt_fire)
function gun_default:recoil()
assert(self.instance, "attempt to call object method on a class")
local rprops = self.properties.recoil
@ -216,6 +231,8 @@ function gun_default:recoil()
end
self.time_since_last_fire = 0
end
--- update the offsets of the player's look created by the gun
function gun_default:update_look_offsets(dt)
assert(self.instance, "attempt to call object method on a class")
local handler = self.handler
@ -328,6 +345,12 @@ local ttransform = mat4.identity()
local out = vector.new() --reserve the memory, we still want to create new vectors each time though.
--gets the gun's position relative to the player. Relative indicates wether it's relative to the player's horizontal look
--offset is relative to the's rotation
--- get the global position of the gun. This is customized to rely on the assumption that there are 3-4 main rotations and 2-3 translations. If the behavior of the bones are changed this method may not work
-- @tparam vec3 offset_pos
-- @tparam bool relative_y wether the y axis is relative to the player's look
-- @tparam bool relative_x wether the x axis is relative to the player's look
-- @treturn vec3 position of gun (in global or local orientation) relative to the player's position
function gun_default:get_pos(offset, relative_y, relative_x, with_animation)
assert(self.instance, "attempt to call object method on a class")
--local player = self.player
@ -415,7 +438,7 @@ end
--=============================================== ENTITY ======================================================
--- adds the gun entity
function gun_default:add_entity()
assert(self.instance, "attempt to call object method on a class")
self.entity = minetest.add_entity(self.player:get_pos(), "guns4d:gun_entity")
@ -433,6 +456,8 @@ end
local tmp_mat4_rot = mat4.identity()
local ip_time = Guns4d.config.gun_axial_interpolation_time
local ip_time2 = Guns4d.config.translation_interpolation_time
--- updates the gun's entity
function gun_default:update_entity()
local obj = self.entity
local player = self.player
@ -475,6 +500,9 @@ function gun_default:update_entity()
}
})
end
--- checks if the gun entity exists...
-- @treturn bool
function gun_default:has_entity()
assert(self.instance, "attempt to call object method on a class")
if not self.entity then return false end
@ -482,7 +510,8 @@ function gun_default:has_entity()
return true
end
--- updates the gun's wag offset for walking
-- @tparam float dt
function gun_default:update_wag(dt)
local handler = self.handler
local wag = self.offsets.walking
@ -533,6 +562,9 @@ function gun_default:update_wag(dt)
end
end
local e = 2.7182818284590452353602874713527 --I don't know how to find it otherwise...
--- updates the gun's recoil simulation
-- @tparam float dt
function gun_default:update_recoil(dt)
for axis, _ in pairs(self.offsets.recoil) do
for _, i in pairs({"x","y"}) do
@ -571,6 +603,9 @@ function gun_default:update_recoil(dt)
end
--print(self.velocities.recoil.player_axial.x, self.velocities.recoil.player_axial.y)
end
--- updates the gun's animation data
-- @tparam dt
function gun_default:update_animation(dt)
local ent = self.entity
local data = self.animation_data
@ -584,6 +619,11 @@ function gun_default:update_animation(dt)
end
--IMPORTANT!!! this does not directly modify the animation_data table anymore, it's all hooked through ObjRef:set_animation() (init.lua) so if animation is set elsewhere it doesnt break.
--this may be deprecated in the future- as it is no longer really needed now that I hook ObjRef functions.
--- sets the gun's animation in the same format as ObjRef:set_animation() (future deprecation?)
-- @tparam table frames `{x=int, y=int}`
-- @tparam float|nil length length of the animation in seconds
-- @tparam int fps frames per second of the animation
-- @tparam bool loop wether to loop
function gun_default:set_animation(frames, length, fps, loop)
loop = loop or false --why the fuck default is true? I DONT FUCKIN KNOW (this undoes this)
assert(type(frames)=="table" and frames.x and frames.y, "frames invalid or nil in set_animation()!")
@ -596,6 +636,8 @@ function gun_default:set_animation(frames, length, fps, loop)
end
self.entity:set_animation(frames, fps, 0, loop) --see init.lua for modified ObjRef stuff.
end
--- clears the animation to the rest state
function gun_default:clear_animation()
local loaded = false
if self.properties.ammo.magazine_only then
@ -625,6 +667,11 @@ local function adjust_gain(tbl, v)
end
end
end
--- plays a list of sounds for the gun's user and thirdpersons
-- @tparam soundspec_list sound parameters following the format of @{Guns4d.play_sounds}
-- @treturn integer thirdperson sound's guns4d sound handle
-- @treturn integer firstperson sound's guns4d sound handle
function gun_default:play_sounds(sound)
local thpson_sound = Guns4d.table.deep_copy(sound)
local fsprsn_sound = Guns4d.table.deep_copy(sound)

View File

@ -9,17 +9,20 @@ local Vec = vector
-- **method documentation coming soon** (or never...)
--
-- The appearance and handling of guns by default are defined by two table fields: their @{lvl1_fields.consts|consts} and their @{lvl1_fields.properties|properties}.
-- @{lvl1_fields.properties|properties} define nearly everything, from how a gun handles to how it looks, what model it uses,
-- @{lvl1_fields.properties|properties} define nearly everything, from how a gun handles to how it looks, what model it uses, etc.
-- while @{lvl1_fields.consts|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.
-- wether 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: @{gun.itemstring|itemstring}, @{gun.name|name}, and @{lvl1_fields.properties|properties}
-- To hold the gun, the item defined in itemstring must exist. To have a functional gun however, more will need to be changed in terms of properties.
-- There are essentially only 3 fields you must define to register a gun: @{gun.itemstring|itemstring}, @{gun.name|name}, and @{lvl1_fields.properties|properties}.
-- To hold the gun, the item defined in itemstring must actually exist, it will not automatically register. To have a functional gun however, more will need to be changed in terms of properties.
-- it's reccomended that you take a look at existing mods (like guns4d_pack_1) for guidance
--
-- 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.
--
-- *Please note:* there are likey undocumented fields that are used in internal functions. If you find one, please make an issue on Github.
--
--
-- @class gun
-- @field properties @{lvl1_fields.properties|properties} which define the vast majority of gun attributes and may change accross instances
@ -29,20 +32,18 @@ local Vec = vector
local gun_default = {
--- `string` the name of the gun. Set to __template for guns which have no instances and serve as a template. It is safe to set name to the same as @{gun.itemstring}
name = "__guns4d:default__",
--- `string` the itemstring of the gun- i.e. `"guns4d_pack_1:m4"`. Set to `""` for `__template` guns.
itemstring = "",
--- `ItemStack` the gun itemstack. Remember to player:set_wielded_item(self.itemstack) when making meta or itemstack changes.
itemstack = nil,
--- `ObjRef` the operator of the weapon. This may at some point be deprecated when I start to implement AI/mob usage
player = nil,
--- `MetaDataRef` itemstack meta
meta = nil,
--- `string` the ID of the gun used for tracking of it's inventory
id = nil,
--- `ObjRef` the gun entity
gun_entity = nil,
--- `string` inventory image for when the gun has no magazine
inventory_image_magless = nil,
--- `string` inventory image for when the gun is loaded. This is added automatically during construction.
inventory_image = nil,
--- `string` the itemstring of the gun- i.e. `"guns4d_pack_1:m4"`. Set to `""` for `__template` guns.
itemstring = "",
--- list of registered guns, **DO NOT MODIFY** I really need a metatable for this class...
_registered = {},
--- `bool` is the bolt charged
@ -80,32 +81,86 @@ local gun_default = {
-- @field sway `table` @{gun.properties.sway|defines the guns idle sway}
-- @field wag `table` @{gun.properties.wag|defines the movement of the gun while walking}
-- @field charging `table` @{gun.properties.charging|defines how rounds are chambered into the gun}
-- @field ammo @{gun.properties.ammo|defines what ammo the gun uses}
-- @field visuals @{gun.properties.visuals|defines visual attributes of the gun}
-- @field ammo `table` @{gun.properties.ammo|defines what ammo the gun uses}
-- @field visuals `table` @{gun.properties.visuals|defines visual attributes of the gun}
-- @compact
properties = {
--- `Ammo_handler` the class (based on) ammo_handler to create an instance of and use. Default is `Guns4d.ammo_handler`
ammo_handler = Guns4d.ammo_handler,
--- `Attachment_handler` attachment_handler class to use. Default is `Guns4d.attachment_handler`
attachment_handler = Guns4d.attachment_handler,
--- `Sprite_scope` sprite scope class to use
sprite_scope = nil,
--- `Dynamic_crosshair` crosshair class to use
crosshair = nil,
--- starting vertical rotation of the gun
initial_vertical_rotation = -60,
--- `float`=.5 max angular deviation (vertical) from breathing
breathing_scale = .5,
--- `vector` the offset from the center of the muzzle flash. Used by fire()
flash_offset = Vec.new(),
--- `int`=600 The number of rounds (cartidges) this gun can throw per minute. Used by update(), fire() and default controls
firerateRPM = 600,
--- properties.hip
-- @table gun.properties.hip
-- @compact
hip = {--#1
--- `vector` the offset of the gun (relative to the right arm's default position) at hip.
offset = Vec.new(),
--- the ratio that the look rotation is expressed through player_axial (rotated around the viewport) rotation as opposed to gun_axial (rotating the entity).
axis_rotation_ratio = .75,
--- sway speed multiplier while at hip
sway_vel_mul = 5,
--- sway angle multiplier while at hip+
sway_angle_mul = 1,
--- `string` inventory image for when the gun has no magazine
inventory_image_magless = nil,
--- `string` inventory image for when the gun is loaded. This is added automatically during construction.
inventory_image = nil,
--- an ordered list of reloading states used by @{default_controls}.
--
-- the default reload states for a magazine operated weapon, copied from the m4.
-- @example
-- {action="charge", time=.5, anim="charge", sounds={sound="ar_charge", delay = .2}},
-- {action="unload_mag", time=.25, anim="unload", sounds = {sound="ar_mag_unload"}},
-- {action="store", time=.5, anim="store", sounds = {sound="ar_mag_store"}},
-- {action="load", time=.5, anim="load", sounds = {sound="ar_mag_load", delay = .25}},
-- {action="charge", time=.5, anim="charge", sounds={sound="ar_charge", delay = .2}}
reload = {},
--- 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. This is autogenerated if not present.
model_bounding_box = nil,
--- `string` overlay on the item to use when infinite ammo is on
infinite_inventory_overlay = "inventory_overlay_inf_ammo.png",
--- `int`=3 how many rounds in burst using when firemode is at "burst"
burst = 3,
--- `table` containing a list of actions for PC users passed to @{Control_handler}
pc_control_actions = { --used by control_handler
__overfill=true, --this table will not be filled in.
aim = Guns4d.default_controls.aim,
auto = Guns4d.default_controls.auto,
reload = Guns4d.default_controls.reload,
on_use = Guns4d.default_controls.on_use,
firemode = Guns4d.default_controls.firemode,
jump_cancel_ads = Guns4d.default_controls.jump_cancel_ads
},
--- `table` containing a list of actions for touch screen users passed to @{Control_handler}
touch_control_actions = {
__overfill=true,
aim = Guns4d.default_touch_controls.aim,
auto = Guns4d.default_touch_controls.auto,
reload = Guns4d.default_touch_controls.reload,
on_secondary_use = Guns4d.default_touch_controls.on_secondary_use,
firemode = Guns4d.default_touch_controls.firemode,
jump_cancel_ads = Guns4d.default_touch_controls.jump_cancel_ads
},
inventory = {
--[[attachment_slots = {
underbarrel = {
formspec_inventory_location = {x=0, y=1}
slots = 2,
rail = "picatinny" --only attachments fit for this type will be usable.
allowed = {
"group:guns4d_underbarrel"
},
bone = "" --the bone both to attach to and to display at on the menu.
}
},]]
render_size = 2, --length (in meters) which is visible accross the z/forward axis at y/up=0, x=0. For orthographic this will be the scale of the orthographic camera. Default 2
render_image = "m4_ortho.png", --expects an image of the right side of the gun, where the gun is facing the right. Default "m4_ortho.png"
--rendered_from_model = true --if true the rendering is automatically moved to the center of the screen
},
--- properties.ads
--
-- @table gun.properties.ads
-- @see lvl1_fields.properties|properties
-- @compact
ads = { --#2
--- `vector` the offset of the gun relative to the eye's position at hip.
@ -115,12 +170,26 @@ local gun_default = {
--- the time it takes to go into full aim
aim_time = 1,
},
--- `int`=3 how many rounds in burst using when firemode is at "burst"
burst = 3,
--- properties.hip
--
-- @table gun.properties.hip
-- @see lvl1_fields.properties|properties
-- @compact
hip = {--#1
--- `vector` the offset of the gun (relative to the right arm's default position) at hip.
offset = Vec.new(),
--- the ratio that the look rotation is expressed through player_axial (rotated around the viewport) rotation as opposed to gun_axial (rotating the entity).
axis_rotation_ratio = .75,
--- sway speed multiplier while at hip
sway_vel_mul = 5,
--- sway angle multiplier while at hip
sway_angle_mul = 1,
},
--- properties.firemodes
--
-- list containing the firemodes of the gun. Default only contains "single". Strings allowed by default:
-- @table gun.properties.firemodes
-- @see lvl1_fields.properties|properties
-- @compact
-- @field "single"
-- @field "burst"
@ -128,26 +197,26 @@ local gun_default = {
firemodes = { --#3
"single", --not limited to semi-automatic.
},
--- `string` overlay on the item to use when infinite ammo is on
infinite_inventory_overlay = "inventory_overlay_inf_ammo.png",
--- properties.firemode_inventory_overlays
--
-- defines the overlay on the gun item for each firemode. These are selected automatically by firemode string. Defaults are as follows:
-- Defines the overlay on the gun item for each firemode. These are selected automatically by firemode string. Defaults are as follows:
-- @table gun.properties.firemode_inventory_overlays
-- @see lvl1_fields.properties|properties
-- @compact
firemode_inventory_overlays = { --#4
--- "inventory_overlay_single.png"
--- singlefire default: "inventory_overlay_single.png"
single = "inventory_overlay_single.png",
--- "inventory_overlay_auto.png"
--- automatic default: "inventory_overlay_auto.png"
auto = "inventory_overlay_auto.png",
--- "inventory_overlay_burst.png"
--- burstfire default: "inventory_overlay_burst.png"
burst = "inventory_overlay_burst.png",
--- "inventory_overlay_safe.png" (unimplemented firemode)
--- safe default: "inventory_overlay_safe.png" (unimplemented firemode)
safe = "inventory_overlay_safe.png"
},
--- properties.recoil
--
-- **IMPORTANT**: expects fields to be tables containing a "gun_axial" and "player_axial" field.
-- @see lvl1_fields.properties|properties
-- @example
-- property = {
-- gun_axial = type
@ -202,6 +271,7 @@ local gun_default = {
--
-- **IMPORTANT**: expects fields to be tables containing a "gun_axial" and "player_axial" field. In the same format as @{gun.properties.recoil}
-- @table gun.properties.sway
-- @see lvl1_fields.properties|properties
-- @compact
sway = { --#6
--- `float` maximum angle of the sway
@ -228,6 +298,7 @@ local gun_default = {
--- properties.wag
--
-- @table gun.properties.wag
-- @see lvl1_fields.properties|properties
-- @compact
wag = {
--- `float`=1.6 the cycle speed multiplier
@ -240,81 +311,28 @@ local gun_default = {
player_axial = {x=1,y=1},
},
},
--- `table` containing a list of actions for PC users passed to @{Control_handler}
pc_control_actions = { --used by control_handler
__overfill=true, --this table will not be filled in.
aim = Guns4d.default_controls.aim,
auto = Guns4d.default_controls.auto,
reload = Guns4d.default_controls.reload,
on_use = Guns4d.default_controls.on_use,
firemode = Guns4d.default_controls.firemode,
jump_cancel_ads = Guns4d.default_controls.jump_cancel_ads
},
--- `table` containing a list of actions for touch screen users passed to @{Control_handler}
touch_control_actions = {
__overfill=true,
aim = Guns4d.default_touch_controls.aim,
auto = Guns4d.default_touch_controls.auto,
reload = Guns4d.default_touch_controls.reload,
on_secondary_use = Guns4d.default_touch_controls.on_secondary_use,
firemode = Guns4d.default_touch_controls.firemode,
jump_cancel_ads = Guns4d.default_touch_controls.jump_cancel_ads
},
--[[ parts framework coming soon. example for m4
parts = {
barrel = {
operable_without = false,
group = "guns4d_m4_barrel"
default = "guns4d:m4_15in"
}
}
]]
inventory = {
--[[attachment_slots = {
underbarrel = {
formspec_inventory_location = {x=0, y=1}
slots = 2,
rail = "picatinny" --only attachments fit for this type will be usable.
allowed = {
"group:guns4d_underbarrel"
},
bone = "" --the bone both to attach to and to display at on the menu.
}
},]]
render_size = 2, --length (in meters) which is visible accross the z/forward axis at y/up=0, x=0. For orthographic this will be the scale of the orthographic camera.
render_image = "m4_ortho.png", --expects an image of the right side of the gun, where the gun is facing the right.
--rendered_from_model = true --if true the rendering is automatically moved to the center of the screen
},
--- properties.charging
--
-- @table gun.properties.charging
-- @see lvl1_fields.properties|properties
-- @compact
charging = { --#7
--- `bool` defines wether the draw animation is played on swap (when loaded). Used in the instance construction method
--- `bool` defines wether the draw animation is played on swap (when loaded). Default true.
require_draw_on_swap = true,
--- `string` "none" bolt will never need to be charged after reload, "catch" when fired to empty bolt will not need to be charged after reload, "no_catch" bolt will always need to be charged after reload.
bolt_charge_mode = "none", --"none"-chamber is always full, "catch"-when fired to dry bolt will not need to be charged after reload, "no_catch" bolt will always need to be charged after reload.
bolt_charge_mode = "none", --"none"-chamber is always full, "catch"-when fired to dry bolt will not need to be charged after reload, "no_catch" bolt will always need to be charged after reload. Default "none"
--- `float` the time it takes to swap to the gun
draw_time = 1,
--- `string` name of the animation to play from @{gun.properties.visuals.animations|visuals.animations}
--- `string` name of the animation to play from @{gun.properties.visuals.animations|visuals.animations}. Default "draw"
draw_animation = "draw",
--- `string` name of the sound to play from @{gun.properties.sounds|sounds}
--- `string` name of the sound to play from @{gun.properties.sounds|sounds}. Default "draw"
draw_sound = "draw"
--sound = soundspec
},
--- and ordered list of reloading states used by @{default_controls}.
--
-- the default reload states for a magazine operated weapon, copied from the m4.
-- @example
-- {action="charge", time=.5, anim="charge", sounds={sound="ar_charge", delay = .2}},
-- {action="unload_mag", time=.25, anim="unload", sounds = {sound="ar_mag_unload"}},
-- {action="store", time=.5, anim="store", sounds = {sound="ar_mag_store"}},
-- {action="load", time=.5, anim="load", sounds = {sound="ar_mag_load", delay = .25}},
-- {action="charge", time=.5, anim="charge", sounds={sound="ar_charge", delay = .2}}
reload = {},
--- properties.ammo
--
-- @table gun.properties.ammo
-- @see lvl1_fields.properties|properties
-- @compact
ammo = { --#8
--- `bool` wether the gun only uses a magazine or accepts raw ammunition too.
@ -330,24 +348,35 @@ local gun_default = {
--- properties.visuals
--
-- @table gun.properties.visuals
-- @see lvl1_fields.properties|properties
-- @compact
visuals = {
--- name of mesh to display. Currently only supports b3d
mesh = nil,
--- list of textures to use
--- list of textures to use.
textures = {},
--- scale multiplier
--- scale multiplier. Default 1
scale = 1,
--- toggles backface culling
--- toggles backface culling. Default true
backface_culling = true,
--- a table of animations in the format {x=int, y=float}. Indexes define the name of the animation to be refrenced by other functions of the gun.
--- a table of animations. Indexes define the name of the animation to be refrenced by other functions of the gun.
-- should be in the format `{x=integer,y=integer}`
-- @example
-- animations = {
-- empty = {x=0,y=0}
-- loaded = {x=1,y=1}
-- fire = {x=10,y=20}
-- draw = {x=24,y=30} --DEFAULT of charging.draw_animation.
-- }
--
-- There are other animations which are variable which are not listed here, these are usually defined by properties such as:
-- @{reload}, @{gun.properties.charging.draw_animation|draw_animation}
animations = { --used by animations handler for idle, and default controls
empty = {x=0,y=0},
loaded = {x=1,y=1},
fire = {x=0,y=0},
},
},
--- 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
model_bounding_box = nil,
--- a table of @{guns4d_soundspec|soundspecs} to be referenced by other functions
sounds = { --this does not contain reload sound effects.
fire = {
@ -380,18 +409,40 @@ local gun_default = {
}
},
},
ammo_handler = Guns4d.ammo_handler,
attachment_handler = Guns4d.attachment_handler,
sprite_scope = nil,
crosshair = nil,
initial_vertical_rotation = -60,
},
--- `vector` containing the offset from animations, this will be generated if {@consts.ANIMATIONS_OFFSET_AIM}=true
animation_rotation = vector.new(),
--- all offsets from @{offsets|gun.offset} of a type added together gun in the same format as a @{offsets|an offset} (that is, five vectors, `gun_axial`, `player_axial`, etc.). Note that if
-- offsets are changed after update, this will not be updated automatically until the next update. update_rotations() must be called to do so.
total_offsets = {
gun_axial = vector.new(), --rotation of the gun entity (around entity's own axis)
player_axial = vector.new(), --rotation around the eye (the player's axis)
gun_trans = vector.new(), --translation of the gun relative to attached bone's rotation
player_trans = vector.new(), --translation of the gun relative to the player's eye
look_trans = vector.new() --translation/offset of the player's eye
},
--- velocities in the format of @{offsets|offsets}, but only containing angular (`gun_axial` and `player_axial`) offsets.
velocities = {
recoil = {
gun_axial = Vec.new(),
player_axial = Vec.new(),
},
init_recoil = {
gun_axial = Vec.new(),
player_axial = Vec.new(),
},
sway = {
gun_axial = Vec.new(),
player_axial = Vec.new(),
},
},
--- offsets
--
-- a list of tables each containing offset vectors These are required for automatic initialization of offsets.
-- note rotations are in degrees, and translations are in meters.
-- @example
-- recoil = {
-- gun_axial = {x=0, y=0}, --rotation of the gun around it's origin
-- 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
@ -433,31 +484,6 @@ local gun_default = {
gun_trans = Vec.new()
},
},
--- `vector` containing the offset from animations, this will be generated if {@consts.ANIMATIONS_OFFSET_AIM}=true
animation_rotation = vector.new(),
--- total offsets of the gun in the same format as a @{offsets|an offset}
--[[total_offsets = {
gun_axial = vector.new(), rotation of the gun entity (around entity's own axis)
player_axial = vector.new(), rotation around the eye (the player's axis)
gun_trans = vector.new(), translation of the gun relative to attached bone's rotation
player_trans = vector.new(), translation of the gun relative to the player's eye
look_trans = vector.new() translation/offset of the player's eye
}, ]]
--player_rotation = Vec.new(),
velocities = {
recoil = {
gun_axial = Vec.new(),
player_axial = Vec.new(),
},
init_recoil = {
gun_axial = Vec.new(),
player_axial = Vec.new(),
},
sway = {
gun_axial = Vec.new(),
player_axial = Vec.new(),
},
},
--- consts
--
-- These are variables that are constant across the class and should usually not ever be changed by instnaces

View File

@ -0,0 +1,49 @@
local physics_system = leef.class.new_class:inherit({
objects = {}, --table of vectors,
object_pos = vector.new(),
center_of_mass = vector.new(),
object_weight = 1, --weight in kg
forcefields = {}
})
--forcefield def
--[[
{
midline_radius = 0, --midline of attraction/repulsion
deadzone_radius = 1,
border_radius = 0
pos = vec3(),
elastic_constant = 0 --F = e * d^(|e|/e)
}
]]
--calculate delta-velocity of a given forcefield
--@tparam int index of the forcefield
--@treturn deltaV of
local rpos = vector.new()
--not going to optimize this because AHHHHHHHHHH its a lot of vector math
function physics_system:update(dt)
end
function physics_system:calculate_dv(dt, i)
local pos =
local field = self.forcefields[i]
local borderR = field.border_radius
local deadzoneR = field.deadzone_radius
local midlineR = field.midline_radius
local fpos = field.pos
--rpos.x, rpos.y, rpos.z = pos.x-fpos.x,pos.y-fpos.y,pos.z-fpos.x
rpos = pos-fpos --relative pos
local midline_intersect = rpos:normalize()*midlineR --dir*r is the intersect with midline
local d=(midline_intersect-pos):length() --distance from midline
local e= field.elastic_constant
local f = e*d^(math.abs(e)/e) --force
--local a = f/self.object_weight --acceleration
return a*dt --change in velocity
end

View File

@ -29,10 +29,10 @@
<li><a href="#gun">Class <code>gun</code></a></li>
<li><a href="#lvl1_fields.properties"><p>properties</p>
</a></li>
<li><a href="#gun.properties.hip"><p>properties.hip</p>
</a></li>
<li><a href="#gun.properties.ads"><p>properties.ads</p>
</a></li>
<li><a href="#gun.properties.hip"><p>properties.hip</p>
</a></li>
<li><a href="#gun.properties.firemodes"><p>properties.firemodes</p>
</a></li>
<li><a href="#gun.properties.firemode_inventory_overlays"><p>properties.firemode_inventory_overlays</p>
@ -69,6 +69,7 @@
<li><a href="../module/play_sound.html">play_sound</a></li>
<li><a href="../module/Bullet_hole.html">Bullet_hole</a></li>
<li><a href="../module/Control_handler.html">Control_handler</a></li>
<li><a href="../module/Gun-methods.html">Gun-methods</a></li>
</ul>
</div>
</div>
@ -82,14 +83,16 @@
<h2>Defining a gun:</h2>
<p><strong>method documentation coming soon</strong> (or never...)</p>
<p>The appearance and handling of guns by default are defined by two table fields: their <a href="../class/gun.html#lvl1_fields.consts">consts</a> and their <a href="../class/gun.html#lvl1_fields.properties">properties</a>.
<a href="../class/gun.html#lvl1_fields.properties">properties</a> define nearly everything, from how a gun handles to how it looks, what model it uses,
<a href="../class/gun.html#lvl1_fields.properties">properties</a> define nearly everything, from how a gun handles to how it looks, what model it uses, etc.
while <a href="../class/gun.html#lvl1_fields.consts">consts</a> 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.</p>
<p>There are essentially only 2 fields you must define to register a gun: <a href="../class/gun.html#gun.itemstring">itemstring</a>, <a href="../class/gun.html#gun.name">name</a>, and <a href="../class/gun.html#lvl1_fields.properties">properties</a>
To have a functional gun however, more will need to be changed in terms of properties.</p>
wether 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.</p>
<p>There are essentially only 3 fields you must define to register a gun: <a href="../class/gun.html#gun.itemstring">itemstring</a>, <a href="../class/gun.html#gun.name">name</a>, and <a href="../class/gun.html#lvl1_fields.properties">properties</a>.
To hold the gun, the item defined in itemstring must actually exist, it will not automatically register. To have a functional gun however, more will need to be changed in terms of properties.
it's reccomended that you take a look at existing mods (like guns4d_pack_1) for guidance</p>
<p>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 &quot;__template&quot; for template classes of guns.</p>
<p><em>Please note:</em> there are likey undocumented fields that are used in internal functions. If you find one, please make an issue on Github.</p>
<div class="synopsis">
<table class="fields compact">
@ -114,11 +117,21 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
</td>
</tr>
<tr>
<td class="name"><var id="gun.itemstring">itemstring</var><a class="permalink" href="#gun.itemstring" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>string</code> the itemstring of the gun- i.e. <code>&quot;guns4d_pack_1:m4&quot;</code>. Set to <code>&quot;&quot;</code> for <code>__template</code> guns.</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.itemstack">itemstack</var><a class="permalink" href="#gun.itemstack" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>ItemStack</code> the gun itemstack. Remember to player:set_wielded_item(self.itemstack) when making meta or itemstack changes.</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.player">player</var><a class="permalink" href="#gun.player" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>ObjRef</code> the operator of the weapon. This may at some point be deprecated when I start to implement AI/mob usage</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.meta">meta</var><a class="permalink" href="#gun.meta" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>MetaDataRef</code> itemstack meta</p>
</td>
@ -134,21 +147,6 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
</td>
</tr>
<tr>
<td class="name"><var id="gun.inventory_image_magless">inventory_image_magless</var><a class="permalink" href="#gun.inventory_image_magless" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>string</code> inventory image for when the gun has no magazine</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.inventory_image">inventory_image</var><a class="permalink" href="#gun.inventory_image" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>string</code> inventory image for when the gun is loaded. This is added automatically during construction.</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.itemstring">itemstring</var><a class="permalink" href="#gun.itemstring" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>string</code> the itemstring of the gun- i.e. <code>&quot;guns4d_pack_1:m4&quot;</code>. Set to <code>&quot;&quot;</code> for <code>__template</code> guns.</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun._registered">_registered</var><a class="permalink" href="#gun._registered" title="Permalink to this definition"></a></td>
<td class="doc"><p>list of registered guns, <strong>DO NOT MODIFY</strong> I really need a metatable for this class...</p>
</td>
@ -209,24 +207,6 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
</td>
</tr>
<tr>
<td class="name"><var id="gun.reload">reload</var><a class="permalink" href="#gun.reload" title="Permalink to this definition"></a></td>
<td class="doc"><p>and ordered list of reloading states used by default_controls.</p>
<p>the default reload states for a magazine operated weapon, copied from the m4.</p>
<h5>Example</h5>
<pre><code class="language-lua">{action=&quot;charge&quot;, time=.5, anim=&quot;charge&quot;, sounds={sound=&quot;ar_charge&quot;, delay = .2}},
{action=&quot;unload_mag&quot;, time=.25, anim=&quot;unload&quot;, sounds = {sound=&quot;ar_mag_unload&quot;}},
{action=&quot;store&quot;, time=.5, anim=&quot;store&quot;, sounds = {sound=&quot;ar_mag_store&quot;}},
{action=&quot;load&quot;, time=.5, anim=&quot;load&quot;, sounds = {sound=&quot;ar_mag_load&quot;, delay = .25}},
{action=&quot;charge&quot;, time=.5, anim=&quot;charge&quot;, sounds={sound=&quot;ar_charge&quot;, delay = .2}}
</code></pre>
</td>
</tr>
<tr>
<td class="name"><var id="gun.model_bounding_box">model_bounding_box</var><a class="permalink" href="#gun.model_bounding_box" title="Permalink to this definition"></a></td>
<td class="doc"><p>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</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.sounds">sounds</var><a class="permalink" href="#gun.sounds" title="Permalink to this definition"></a></td>
<td class="doc"><p>a table of <a href="../module/play_sound.html#guns4d_soundspec">soundspecs</a> to be referenced by other functions</p>
</td>
@ -237,9 +217,14 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
</td>
</tr>
<tr>
<td class="name"><var id="gun.gun_axial">gun_axial</var><a class="permalink" href="#gun.gun_axial" title="Permalink to this definition"></a></td>
<td class="doc"><p>total offsets of the gun in the same format as a <a href="../class/gun.html#gun.offsets">an offset</a>
[[total_offsets = {</p>
<td class="name"><var id="gun.total_offsets">total_offsets</var><a class="permalink" href="#gun.total_offsets" title="Permalink to this definition"></a></td>
<td class="doc"><p>all offsets from <a href="../class/gun.html#gun.offsets">gun.offset</a> of a type added together gun in the same format as a <a href="../class/gun.html#gun.offsets">an offset</a> (that is, five vectors, <code>gun_axial</code>, <code>player_axial</code>, etc.). Note that if
offsets are changed after update, this will not be updated automatically until the next update. update_rotations() must be called to do so.</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.velocities">velocities</var><a class="permalink" href="#gun.velocities" title="Permalink to this definition"></a></td>
<td class="doc"><p>velocities in the format of <a href="../class/gun.html#gun.offsets">offsets</a>, but only containing angular (<code>gun_axial</code> and <code>player_axial</code>) offsets.</p>
</td>
</tr>
</table>
@ -298,12 +283,37 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.ammo">ammo</var><a class="permalink" href="#lvl1_fields.properties.ammo" title="Permalink to this definition"></a></td>
<td class="doc"><p><a href="../class/gun.html#gun.properties.ammo">defines what ammo the gun uses</a></p>
<td class="doc"><p><a href="../module/misc_helpers.html#table"><code>table</code></a> <a href="../class/gun.html#gun.properties.ammo">defines what ammo the gun uses</a></p>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.visuals">visuals</var><a class="permalink" href="#lvl1_fields.properties.visuals" title="Permalink to this definition"></a></td>
<td class="doc"><p><a href="../class/gun.html#gun.properties.visuals">defines visual attributes of the gun</a></p>
<td class="doc"><p><a href="../module/misc_helpers.html#table"><code>table</code></a> <a href="../class/gun.html#gun.properties.visuals">defines visual attributes of the gun</a></p>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.ammo_handler">ammo_handler</var><a class="permalink" href="#lvl1_fields.properties.ammo_handler" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>Ammo_handler</code> the class (based on) ammo_handler to create an instance of and use. Default is <code>Guns4d.ammo_handler</code></p>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.attachment_handler">attachment_handler</var><a class="permalink" href="#lvl1_fields.properties.attachment_handler" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>Attachment_handler</code> attachment_handler class to use. Default is <code>Guns4d.attachment_handler</code></p>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.sprite_scope">sprite_scope</var><a class="permalink" href="#lvl1_fields.properties.sprite_scope" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>Sprite_scope</code> sprite scope class to use</p>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.crosshair">crosshair</var><a class="permalink" href="#lvl1_fields.properties.crosshair" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>Dynamic_crosshair</code> crosshair class to use</p>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.initial_vertical_rotation">initial_vertical_rotation</var><a class="permalink" href="#lvl1_fields.properties.initial_vertical_rotation" title="Permalink to this definition"></a></td>
<td class="doc"><p>starting vertical rotation of the gun</p>
</td>
</tr>
<tr>
@ -322,8 +332,31 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.burst">burst</var><a class="permalink" href="#lvl1_fields.properties.burst" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>int</code>=3 how many rounds in burst using when firemode is at &quot;burst&quot;</p>
<td class="name"><var id="lvl1_fields.properties.inventory_image_magless">inventory_image_magless</var><a class="permalink" href="#lvl1_fields.properties.inventory_image_magless" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>string</code> inventory image for when the gun has no magazine</p>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.inventory_image">inventory_image</var><a class="permalink" href="#lvl1_fields.properties.inventory_image" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>string</code> inventory image for when the gun is loaded. This is added automatically during construction.</p>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.reload">reload</var><a class="permalink" href="#lvl1_fields.properties.reload" title="Permalink to this definition"></a></td>
<td class="doc"><p>an ordered list of reloading states used by default_controls.</p>
<p>the default reload states for a magazine operated weapon, copied from the m4.</p>
<h5>Example</h5>
<pre><code class="language-lua">{action=&quot;charge&quot;, time=.5, anim=&quot;charge&quot;, sounds={sound=&quot;ar_charge&quot;, delay = .2}},
{action=&quot;unload_mag&quot;, time=.25, anim=&quot;unload&quot;, sounds = {sound=&quot;ar_mag_unload&quot;}},
{action=&quot;store&quot;, time=.5, anim=&quot;store&quot;, sounds = {sound=&quot;ar_mag_store&quot;}},
{action=&quot;load&quot;, time=.5, anim=&quot;load&quot;, sounds = {sound=&quot;ar_mag_load&quot;, delay = .25}},
{action=&quot;charge&quot;, time=.5, anim=&quot;charge&quot;, sounds={sound=&quot;ar_charge&quot;, delay = .2}}
</code></pre>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.model_bounding_box">model_bounding_box</var><a class="permalink" href="#lvl1_fields.properties.model_bounding_box" title="Permalink to this definition"></a></td>
<td class="doc"><p>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. This is autogenerated if not present.</p>
</td>
</tr>
<tr>
@ -332,6 +365,11 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.burst">burst</var><a class="permalink" href="#lvl1_fields.properties.burst" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>int</code>=3 how many rounds in burst using when firemode is at &quot;burst&quot;</p>
</td>
</tr>
<tr>
<td class="name"><var id="lvl1_fields.properties.pc_control_actions">pc_control_actions</var><a class="permalink" href="#lvl1_fields.properties.pc_control_actions" title="Permalink to this definition"></a></td>
<td class="doc"><p><a href="../module/misc_helpers.html#table"><code>table</code></a> containing a list of actions for PC users passed to <a href="../module/Control_handler.html">Control_handler</a></p>
</td>
@ -346,43 +384,13 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
</div>
</div>
<div class="section">
<h2 class="table" id="gun.properties.hip">properties.hip
<a class="permalink" href="#gun.properties.hip" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<div class="synopsis">
<table class="fields compact">
<tr>
<td class="name"><var id="gun.properties.hip.offset">offset</var><a class="permalink" href="#gun.properties.hip.offset" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>vector</code> the offset of the gun (relative to the right arm's default position) at hip.</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.hip.axis_rotation_ratio">axis_rotation_ratio</var><a class="permalink" href="#gun.properties.hip.axis_rotation_ratio" title="Permalink to this definition"></a></td>
<td class="doc"><p>the ratio that the look rotation is expressed through player_axial (rotated around the viewport) rotation as opposed to gun_axial (rotating the entity).</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.hip.sway_vel_mul">sway_vel_mul</var><a class="permalink" href="#gun.properties.hip.sway_vel_mul" title="Permalink to this definition"></a></td>
<td class="doc"><p>sway speed multiplier while at hip</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.hip.sway_angle_mul">sway_angle_mul</var><a class="permalink" href="#gun.properties.hip.sway_angle_mul" title="Permalink to this definition"></a></td>
<td class="doc"><p>sway angle multiplier while at hip+</p>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="section">
<h2 class="table" id="gun.properties.ads">properties.ads
<a class="permalink" href="#gun.properties.ads" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<div class="synopsis">
<table class="fields compact">
<tr>
@ -405,12 +413,47 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
</div>
</div>
<div class="section">
<h2 class="table" id="gun.properties.hip">properties.hip
<a class="permalink" href="#gun.properties.hip" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<div class="synopsis">
<table class="fields compact">
<tr>
<td class="name"><var id="gun.properties.hip.offset">offset</var><a class="permalink" href="#gun.properties.hip.offset" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>vector</code> the offset of the gun (relative to the right arm's default position) at hip.</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.hip.axis_rotation_ratio">axis_rotation_ratio</var><a class="permalink" href="#gun.properties.hip.axis_rotation_ratio" title="Permalink to this definition"></a></td>
<td class="doc"><p>the ratio that the look rotation is expressed through player_axial (rotated around the viewport) rotation as opposed to gun_axial (rotating the entity).</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.hip.sway_vel_mul">sway_vel_mul</var><a class="permalink" href="#gun.properties.hip.sway_vel_mul" title="Permalink to this definition"></a></td>
<td class="doc"><p>sway speed multiplier while at hip</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.hip.sway_angle_mul">sway_angle_mul</var><a class="permalink" href="#gun.properties.hip.sway_angle_mul" title="Permalink to this definition"></a></td>
<td class="doc"><p>sway angle multiplier while at hip</p>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="section">
<h2 class="table" id="gun.properties.firemodes">properties.firemodes
<a class="permalink" href="#gun.properties.firemodes" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<p>list containing the firemodes of the gun. Default only contains &quot;single&quot;. Strings allowed by default:</p>
<p>list containing the firemodes of the gun. Default only contains &quot;single&quot;. Strings allowed by default:
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<div class="synopsis">
<table class="fields compact">
@ -433,28 +476,29 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
<a class="permalink" href="#gun.properties.firemode_inventory_overlays" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<p>defines the overlay on the gun item for each firemode. These are selected automatically by firemode string. Defaults are as follows:</p>
<p>Defines the overlay on the gun item for each firemode. These are selected automatically by firemode string. Defaults are as follows:
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<div class="synopsis">
<table class="fields compact">
<tr>
<td class="name"><var id="gun.properties.firemode_inventory_overlays.single">single</var><a class="permalink" href="#gun.properties.firemode_inventory_overlays.single" title="Permalink to this definition"></a></td>
<td class="doc"><p>&quot;inventory_overlay_single.png&quot;</p>
<td class="doc"><p>singlefire default: &quot;inventory_overlay_single.png&quot;</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.firemode_inventory_overlays.auto">auto</var><a class="permalink" href="#gun.properties.firemode_inventory_overlays.auto" title="Permalink to this definition"></a></td>
<td class="doc"><p>&quot;inventory_overlay_auto.png&quot;</p>
<td class="doc"><p>automatic default: &quot;inventory_overlay_auto.png&quot;</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.firemode_inventory_overlays.burst">burst</var><a class="permalink" href="#gun.properties.firemode_inventory_overlays.burst" title="Permalink to this definition"></a></td>
<td class="doc"><p>&quot;inventory_overlay_burst.png&quot;</p>
<td class="doc"><p>burstfire default: &quot;inventory_overlay_burst.png&quot;</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.firemode_inventory_overlays.safe">safe</var><a class="permalink" href="#gun.properties.firemode_inventory_overlays.safe" title="Permalink to this definition"></a></td>
<td class="doc"><p>&quot;inventory_overlay_safe.png&quot; (unimplemented firemode)</p>
<td class="doc"><p>safe default: &quot;inventory_overlay_safe.png&quot; (unimplemented firemode)</p>
</td>
</tr>
</table>
@ -467,7 +511,8 @@ or you can do the same thing with a seperate class of weapons. Set name to &quot
<a class="permalink" href="#gun.properties.recoil" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<p><strong>IMPORTANT</strong>: expects fields to be tables containing a &quot;gun_axial&quot; and &quot;player_axial&quot; field.</p>
<p><strong>IMPORTANT</strong>: expects fields to be tables containing a &quot;gun_axial&quot; and &quot;player_axial&quot; field.
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<h5>Example</h5>
<pre><code class="language-lua">property = {
gun_axial = type
@ -528,7 +573,8 @@ this means that increasing it decreases the time it takes for the angular veloci
<a class="permalink" href="#gun.properties.sway" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<p><strong>IMPORTANT</strong>: expects fields to be tables containing a &quot;gun_axial&quot; and &quot;player_axial&quot; field. In the same format as <a href="../class/gun.html#gun.properties.recoil">gun.properties.recoil</a></p>
<p><strong>IMPORTANT</strong>: expects fields to be tables containing a &quot;gun_axial&quot; and &quot;player_axial&quot; field. In the same format as <a href="../class/gun.html#gun.properties.recoil">gun.properties.recoil</a>
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<div class="synopsis">
<table class="fields compact">
@ -562,6 +608,8 @@ this means that increasing it decreases the time it takes for the angular veloci
<a class="permalink" href="#gun.properties.wag" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<div class="synopsis">
<table class="fields compact">
<tr>
@ -589,11 +637,13 @@ this means that increasing it decreases the time it takes for the angular veloci
<a class="permalink" href="#gun.properties.charging" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<div class="synopsis">
<table class="fields compact">
<tr>
<td class="name"><var id="gun.properties.charging.require_draw_on_swap">require_draw_on_swap</var><a class="permalink" href="#gun.properties.charging.require_draw_on_swap" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>bool</code> defines wether the draw animation is played on swap (when loaded). Used in the instance construction method</p>
<td class="doc"><p><code>bool</code> defines wether the draw animation is played on swap (when loaded). Default true.</p>
</td>
</tr>
<tr>
@ -608,12 +658,12 @@ this means that increasing it decreases the time it takes for the angular veloci
</tr>
<tr>
<td class="name"><var id="gun.properties.charging.draw_animation">draw_animation</var><a class="permalink" href="#gun.properties.charging.draw_animation" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>string</code> name of the animation to play from <a href="../class/gun.html#gun.properties.visuals.animations">visuals.animations</a></p>
<td class="doc"><p><code>string</code> name of the animation to play from <a href="../class/gun.html#gun.properties.visuals.animations">visuals.animations</a>. Default &quot;draw&quot;</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.charging.draw_sound">draw_sound</var><a class="permalink" href="#gun.properties.charging.draw_sound" title="Permalink to this definition"></a></td>
<td class="doc"><p><code>string</code> name of the sound to play from sounds</p>
<td class="doc"><p><code>string</code> name of the sound to play from sounds. Default &quot;draw&quot;</p>
</td>
</tr>
</table>
@ -626,6 +676,8 @@ this means that increasing it decreases the time it takes for the angular veloci
<a class="permalink" href="#gun.properties.ammo" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<div class="synopsis">
<table class="fields compact">
<tr>
@ -658,31 +710,44 @@ this means that increasing it decreases the time it takes for the angular veloci
<a class="permalink" href="#gun.properties.visuals" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<div class="see">See also <a href="../class/gun.html#lvl1_fields.properties">properties</a></div>
<div class="synopsis">
<table class="fields compact">
<tr>
<td class="name"><var id="gun.properties.visuals.mesh">mesh</var><a class="permalink" href="#gun.properties.visuals.mesh" title="Permalink to this definition"></a></td>
<td class="doc"><p>name of mesh to display</p>
<td class="doc"><p>name of mesh to display. Currently only supports b3d</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.visuals.textures">textures</var><a class="permalink" href="#gun.properties.visuals.textures" title="Permalink to this definition"></a></td>
<td class="doc"><p>list of textures to use</p>
<td class="doc"><p>list of textures to use.</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.visuals.scale">scale</var><a class="permalink" href="#gun.properties.visuals.scale" title="Permalink to this definition"></a></td>
<td class="doc"><p>scale multiplier</p>
<td class="doc"><p>scale multiplier. Default 1</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.visuals.backface_culling">backface_culling</var><a class="permalink" href="#gun.properties.visuals.backface_culling" title="Permalink to this definition"></a></td>
<td class="doc"><p>toggles backface culling</p>
<td class="doc"><p>toggles backface culling. Default true</p>
</td>
</tr>
<tr>
<td class="name"><var id="gun.properties.visuals.animations">animations</var><a class="permalink" href="#gun.properties.visuals.animations" title="Permalink to this definition"></a></td>
<td class="doc"><p>a table of animations in the format {x=int, y=float}. Indexes define the name of the animation to be refrenced by other functions of the gun.</p>
<td class="doc"><p>a table of animations. Indexes define the name of the animation to be refrenced by other functions of the gun.
should be in the format <code>{x=integer,y=integer}</code></p>
<h5>Example</h5>
<pre><code class="language-lua">animations = {
empty = {x=0,y=0}
loaded = {x=1,y=1}
fire = {x=10,y=20}
draw = {x=24,y=30} --DEFAULT of charging.draw_animation.
}
</code></pre>
<p>There are other animations which are variable which are not listed here, these are usually defined by properties such as:
reload, <a href="../class/gun.html#gun.properties.charging.draw_animation">draw_animation</a></p>
</td>
</tr>
</table>
@ -695,10 +760,11 @@ this means that increasing it decreases the time it takes for the angular veloci
<a class="permalink" href="#lvl1_fields.offsets" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<p>a list of tables each containing offset vectors These are required for automatic initialization of offsets.</p>
<p>a list of tables each containing offset vectors These are required for automatic initialization of offsets.
note rotations are in degrees, and translations are in meters.</p>
<h5>Example</h5>
<pre><code class="language-lua">recoil = {
gun_axial = {x=0, y=0}, --rotation of the gun around it's origin
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

View File

@ -46,6 +46,7 @@
<li><a href="../module/play_sound.html">play_sound</a></li>
<li><a href="../module/Bullet_hole.html">Bullet_hole</a></li>
<li><a href="../module/Control_handler.html">Control_handler</a></li>
<li><a href="../module/Gun-methods.html">Gun-methods</a></li>
</ul>
</div>
</div>

View File

@ -37,6 +37,7 @@
<li><a href="module/play_sound.html">play_sound</a></li>
<li><a href="module/Bullet_hole.html">Bullet_hole</a></li>
<li><a href="module/Control_handler.html">Control_handler</a></li>
<li><a href="module/Gun-methods.html">Gun-methods</a></li>
</ul>
</div>
</div>

View File

@ -1,10 +1,11 @@
var docs = [
{path:"class/gun.html", type:"class", title:"Gun.gun", text:"Gun class fields Defining a gun: *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."},
{path:"class/gun.html", type:"class", title:"Gun.gun", text:"Gun class fields Defining a gun: *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, etc. while consts define attributes that should never change, like bones within the gun, framerates, wether 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 3 fields you must define to register a gun: itemstring, name, and properties. To hold the gun, the item defined in itemstring must actually exist, it will not automatically register. To have a functional gun however, more will need to be changed in terms of properties. it's reccomended that you take a look at existing mods (like guns4d_pack_1) for guidance 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. Please note:* there are likey undocumented fields that are used in internal functions. If you find one, please make an issue on Github."},
{path:"class/player_model_handler.html", type:"class", title:"Player_model_handler.player_model_handler", text:"player_model_handler defining the player model when holding a gun each player model should have a \"gun holding equivelant\". There are numerous reasons for this first and foremost is that because Minetest is a [redacted mindless insults]. because of this you cannot unset bone offsets and return to normal animations. Bone offsets are needed for the arms to aim at the gun there's no simple way around this fact. Since every model is different custom behavior has to be defined for most."},
{path:"module/misc_helpers.html", type:"module", title:"misc_helpers", text:""},
{path:"module/play_sound.html", type:"module", title:"play_sound", text:"implements tools for quickly playing audio."},
{path:"module/Bullet_hole.html", type:"module", title:"Bullet_hole", text:""},
{path:"module/Control_handler.html", type:"module", title:"Control_handler", text:""},
{path:"module/Gun-methods.html", type:"module", title:"Gun-methods", text:""},
{path:"module/Gun.html", type:"module", title:"Gun", text:""},
{path:"module/play_sound.html#guns4d_soundspec.min_hear_distance", type:"field", title:"guns4d_soundspec.min_hear_distance", text:"float this is useful if you wish to play a sound which has a \"far\" sound, such as distant gunshots. incompatible with to_player"},
{path:"module/play_sound.html#guns4d_soundspec.sounds", type:"field", title:"guns4d_soundspec.sounds", text:"table a weighted_randoms table for randomly selecting sounds. The output will overwrite the sound field."},
@ -18,13 +19,12 @@ var docs = [
{path:"class/gun.html#gun.consts", type:"field", title:"gun.consts", text:"constants which define gun attributes and should not be changed in an instance of the gun"},
{path:"class/gun.html#gun.offsets", type:"field", title:"gun.offsets", text:"runtime storage of offsets generated by recoil sway wag or any other element."},
{path:"class/gun.html#gun.name", type:"field", title:"gun.name", text:"string the name of the gun. Set to __template for guns which have no instances and serve as a template. It is safe to set name to the same as gun.itemstring"},
{path:"class/gun.html#gun.itemstring", type:"field", title:"gun.itemstring", text:"string the itemstring of the gun- i.e. \"guns4d_pack_1:m4\". Set to \"\" for __template guns."},
{path:"class/gun.html#gun.itemstack", type:"field", title:"gun.itemstack", text:"ItemStack the gun itemstack. Remember to player:set_wielded_item(self.itemstack) when making meta or itemstack changes."},
{path:"class/gun.html#gun.player", type:"field", title:"gun.player", text:"ObjRef the operator of the weapon. This may at some point be deprecated when I start to implement AI/mob usage"},
{path:"class/gun.html#gun.meta", type:"field", title:"gun.meta", text:"MetaDataRef itemstack meta"},
{path:"class/gun.html#gun.id", type:"field", title:"gun.id", text:"string the ID of the gun used for tracking of it's inventory"},
{path:"class/gun.html#gun.gun_entity", type:"field", title:"gun.gun_entity", text:"ObjRef the gun entity"},
{path:"class/gun.html#gun.inventory_image_magless", type:"field", title:"gun.inventory_image_magless", text:"string inventory image for when the gun has no magazine"},
{path:"class/gun.html#gun.inventory_image", type:"field", title:"gun.inventory_image", text:"string inventory image for when the gun is loaded. This is added automatically during construction."},
{path:"class/gun.html#gun.itemstring", type:"field", title:"gun.itemstring", text:"string the itemstring of the gun- i.e. \"guns4d_pack_1:m4\". Set to \"\" for __template guns."},
{path:"class/gun.html#gun._registered", type:"field", title:"gun._registered", text:"list of registered guns, *DO NOT MODIFY* I really need a metatable for this class..."},
{path:"class/gun.html#gun.bolt_charged", type:"field", title:"gun.bolt_charged", text:"bool is the bolt charged"},
{path:"class/gun.html#gun.particle_spawners", type:"field", title:"gun.particle_spawners", text:"table list of particle spawner handles (generated by firing)"},
@ -45,27 +45,38 @@ var docs = [
{path:"class/gun.html#lvl1_fields.properties.sway", type:"field", title:"lvl1_fields.properties.sway", text:"table defines the guns idle sway"},
{path:"class/gun.html#lvl1_fields.properties.wag", type:"field", title:"lvl1_fields.properties.wag", text:"table defines the movement of the gun while walking"},
{path:"class/gun.html#lvl1_fields.properties.charging", type:"field", title:"lvl1_fields.properties.charging", text:"table defines how rounds are chambered into the gun"},
{path:"class/gun.html#lvl1_fields.properties.ammo", type:"field", title:"lvl1_fields.properties.ammo", text:"defines what ammo the gun uses"},
{path:"class/gun.html#lvl1_fields.properties.visuals", type:"field", title:"lvl1_fields.properties.visuals", text:"defines visual attributes of the gun"},
{path:"class/gun.html#lvl1_fields.properties.ammo", type:"field", title:"lvl1_fields.properties.ammo", text:"table defines what ammo the gun uses"},
{path:"class/gun.html#lvl1_fields.properties.visuals", type:"field", title:"lvl1_fields.properties.visuals", text:"table defines visual attributes of the gun"},
{path:"class/gun.html#lvl1_fields.properties.ammo_handler", type:"field", title:"lvl1_fields.properties.ammo_handler", text:"Ammo_handler the class (based on) ammo_handler to create an instance of and use. Default is Guns4d.ammo_handler"},
{path:"class/gun.html#lvl1_fields.properties.attachment_handler", type:"field", title:"lvl1_fields.properties.attachment_handler", text:"Attachment_handler attachment_handler class to use. Default is Guns4d.attachment_handler"},
{path:"class/gun.html#lvl1_fields.properties.sprite_scope", type:"field", title:"lvl1_fields.properties.sprite_scope", text:"Sprite_scope sprite scope class to use"},
{path:"class/gun.html#lvl1_fields.properties.crosshair", type:"field", title:"lvl1_fields.properties.crosshair", text:"Dynamic_crosshair crosshair class to use"},
{path:"class/gun.html#lvl1_fields.properties.initial_vertical_rotation", type:"field", title:"lvl1_fields.properties.initial_vertical_rotation", text:"starting vertical rotation of the gun"},
{path:"class/gun.html#lvl1_fields.properties.breathing_scale", type:"field", title:"lvl1_fields.properties.breathing_scale", text:"float=.5 max angular deviation (vertical) from breathing"},
{path:"class/gun.html#lvl1_fields.properties.flash_offset", type:"field", title:"lvl1_fields.properties.flash_offset", text:"vector the offset from the center of the muzzle flash. Used by fire()"},
{path:"class/gun.html#lvl1_fields.properties.firerateRPM", type:"field", title:"lvl1_fields.properties.firerateRPM", text:"int=600 The number of rounds (cartidges) this gun can throw per minute. Used by update(), fire() and default controls"},
{path:"class/gun.html#gun.properties.hip.offset", type:"field", title:"gun.properties.hip.offset", text:"vector the offset of the gun (relative to the right arm's default position) at hip."},
{path:"class/gun.html#gun.properties.hip.axis_rotation_ratio", type:"field", title:"gun.properties.hip.axis_rotation_ratio", text:"the ratio that the look rotation is expressed through player_axial (rotated around the viewport) rotation as opposed to gun_axial (rotating the entity)."},
{path:"class/gun.html#gun.properties.hip.sway_vel_mul", type:"field", title:"gun.properties.hip.sway_vel_mul", text:"sway speed multiplier while at hip"},
{path:"class/gun.html#gun.properties.hip.sway_angle_mul", type:"field", title:"gun.properties.hip.sway_angle_mul", text:"sway angle multiplier while at hip+"},
{path:"class/gun.html#lvl1_fields.properties.inventory_image_magless", type:"field", title:"lvl1_fields.properties.inventory_image_magless", text:"string inventory image for when the gun has no magazine"},
{path:"class/gun.html#lvl1_fields.properties.inventory_image", type:"field", title:"lvl1_fields.properties.inventory_image", text:"string inventory image for when the gun is loaded. This is added automatically during construction."},
{path:"class/gun.html#lvl1_fields.properties.reload", type:"field", title:"lvl1_fields.properties.reload", text:"an ordered list of reloading states used by default_controls. the default reload states for a magazine operated weapon, copied from the m4. Example"},
{path:"class/gun.html#lvl1_fields.properties.model_bounding_box", type:"field", title:"lvl1_fields.properties.model_bounding_box", text:"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. This is autogenerated if not present."},
{path:"class/gun.html#lvl1_fields.properties.infinite_inventory_overlay", type:"field", title:"lvl1_fields.properties.infinite_inventory_overlay", text:"string overlay on the item to use when infinite ammo is on"},
{path:"class/gun.html#lvl1_fields.properties.burst", type:"field", title:"lvl1_fields.properties.burst", text:"int=3 how many rounds in burst using when firemode is at \"burst\""},
{path:"class/gun.html#lvl1_fields.properties.pc_control_actions", type:"field", title:"lvl1_fields.properties.pc_control_actions", text:"table containing a list of actions for PC users passed to Control_handler"},
{path:"class/gun.html#lvl1_fields.properties.touch_control_actions", type:"field", title:"lvl1_fields.properties.touch_control_actions", text:"table containing a list of actions for touch screen users passed to Control_handler"},
{path:"class/gun.html#gun.properties.ads.offset", type:"field", title:"gun.properties.ads.offset", text:"vector the offset of the gun relative to the eye's position at hip."},
{path:"class/gun.html#gun.properties.ads.horizontal_offset", type:"field", title:"gun.properties.ads.horizontal_offset", text:"float the horizontal offset of the eye when aiming"},
{path:"class/gun.html#gun.properties.ads.aim_time", type:"field", title:"gun.properties.ads.aim_time", text:"the time it takes to go into full aim"},
{path:"class/gun.html#lvl1_fields.properties.burst", type:"field", title:"lvl1_fields.properties.burst", text:"int=3 how many rounds in burst using when firemode is at \"burst\""},
{path:"class/gun.html#gun.properties.hip.offset", type:"field", title:"gun.properties.hip.offset", text:"vector the offset of the gun (relative to the right arm's default position) at hip."},
{path:"class/gun.html#gun.properties.hip.axis_rotation_ratio", type:"field", title:"gun.properties.hip.axis_rotation_ratio", text:"the ratio that the look rotation is expressed through player_axial (rotated around the viewport) rotation as opposed to gun_axial (rotating the entity)."},
{path:"class/gun.html#gun.properties.hip.sway_vel_mul", type:"field", title:"gun.properties.hip.sway_vel_mul", text:"sway speed multiplier while at hip"},
{path:"class/gun.html#gun.properties.hip.sway_angle_mul", type:"field", title:"gun.properties.hip.sway_angle_mul", text:"sway angle multiplier while at hip"},
{path:"class/gun.html#gun.properties.firemodes."single"", type:"field", title:"gun.properties.firemodes.\"single\"", text:""},
{path:"class/gun.html#gun.properties.firemodes."burst"", type:"field", title:"gun.properties.firemodes.\"burst\"", text:""},
{path:"class/gun.html#gun.properties.firemodes."auto"", type:"field", title:"gun.properties.firemodes.\"auto\"", text:""},
{path:"class/gun.html#lvl1_fields.properties.infinite_inventory_overlay", type:"field", title:"lvl1_fields.properties.infinite_inventory_overlay", text:"string overlay on the item to use when infinite ammo is on"},
{path:"class/gun.html#gun.properties.firemode_inventory_overlays.single", type:"field", title:"gun.properties.firemode_inventory_overlays.single", text:"\"inventory_overlay_single.png\""},
{path:"class/gun.html#gun.properties.firemode_inventory_overlays.auto", type:"field", title:"gun.properties.firemode_inventory_overlays.auto", text:"\"inventory_overlay_auto.png\""},
{path:"class/gun.html#gun.properties.firemode_inventory_overlays.burst", type:"field", title:"gun.properties.firemode_inventory_overlays.burst", text:"\"inventory_overlay_burst.png\""},
{path:"class/gun.html#gun.properties.firemode_inventory_overlays.safe", type:"field", title:"gun.properties.firemode_inventory_overlays.safe", text:"\"inventory_overlay_safe.png\" (unimplemented firemode)"},
{path:"class/gun.html#gun.properties.firemode_inventory_overlays.single", type:"field", title:"gun.properties.firemode_inventory_overlays.single", text:"singlefire default: \"inventory_overlay_single.png\""},
{path:"class/gun.html#gun.properties.firemode_inventory_overlays.auto", type:"field", title:"gun.properties.firemode_inventory_overlays.auto", text:"automatic default: \"inventory_overlay_auto.png\""},
{path:"class/gun.html#gun.properties.firemode_inventory_overlays.burst", type:"field", title:"gun.properties.firemode_inventory_overlays.burst", text:"burstfire default: \"inventory_overlay_burst.png\""},
{path:"class/gun.html#gun.properties.firemode_inventory_overlays.safe", type:"field", title:"gun.properties.firemode_inventory_overlays.safe", text:"safe default: \"inventory_overlay_safe.png\" (unimplemented firemode)"},
{path:"class/gun.html#gun.properties.recoil.velocity_correction_factor", type:"field", title:"gun.properties.recoil.velocity_correction_factor", text:"float TL:DR higher decreases recoil at expense of smoothness. 1/value is the deviation of a normalized bell curve, where x is the time since firing. this means that increasing it decreases the time it takes for the angular velocity to fully \"decay\"."},
{path:"class/gun.html#gun.properties.recoil.target_correction_factor", type:"field", title:"gun.properties.recoil.target_correction_factor", text:"float Correction of recoil offset per second is calculated as such: target_correction_factor[axis]time_since_firerecoil[axis]"},
{path:"class/gun.html#gun.properties.recoil.target_correction_max_rate", type:"field", title:"gun.properties.recoil.target_correction_max_rate", text:"float The maximum rate per second of recoil offset as determined with target_correction_factor"},
@ -80,32 +91,29 @@ var docs = [
{path:"class/gun.html#gun.properties.wag.cycle_speed", type:"field", title:"gun.properties.wag.cycle_speed", text:"float=1.6 the cycle speed multiplier"},
{path:"class/gun.html#gun.properties.wag.decay_speed", type:"field", title:"gun.properties.wag.decay_speed", text:"float=1 decay factor when walking has stopped and offset remains."},
{path:"class/gun.html#gun.properties.wag.offset", type:"field", title:"gun.properties.wag.offset", text:"table containing angular deviation while walking in the same format as an offset vector. Acts as a multiplier on the figure-8 generated while walking."},
{path:"class/gun.html#lvl1_fields.properties.pc_control_actions", type:"field", title:"lvl1_fields.properties.pc_control_actions", text:"table containing a list of actions for PC users passed to Control_handler"},
{path:"class/gun.html#lvl1_fields.properties.touch_control_actions", type:"field", title:"lvl1_fields.properties.touch_control_actions", text:"table containing a list of actions for touch screen users passed to Control_handler"},
{path:"class/gun.html#gun.properties.charging.require_draw_on_swap", type:"field", title:"gun.properties.charging.require_draw_on_swap", text:"bool defines wether the draw animation is played on swap (when loaded). Used in the instance construction method"},
{path:"class/gun.html#gun.properties.charging.require_draw_on_swap", type:"field", title:"gun.properties.charging.require_draw_on_swap", text:"bool defines wether the draw animation is played on swap (when loaded). Default true."},
{path:"class/gun.html#gun.properties.charging.bolt_charge_mode", type:"field", title:"gun.properties.charging.bolt_charge_mode", text:"string \"none\" bolt will never need to be charged after reload, \"catch\" when fired to empty bolt will not need to be charged after reload, \"no_catch\" bolt will always need to be charged after reload."},
{path:"class/gun.html#gun.properties.charging.draw_time", type:"field", title:"gun.properties.charging.draw_time", text:"float the time it takes to swap to the gun"},
{path:"class/gun.html#gun.properties.charging.draw_animation", type:"field", title:"gun.properties.charging.draw_animation", text:"string name of the animation to play from visuals.animations"},
{path:"class/gun.html#gun.properties.charging.draw_sound", type:"field", title:"gun.properties.charging.draw_sound", text:"string name of the sound to play from sounds"},
{path:"class/gun.html#gun.reload", type:"field", title:"gun.reload", text:"and ordered list of reloading states used by default_controls. the default reload states for a magazine operated weapon, copied from the m4. Example"},
{path:"class/gun.html#gun.properties.charging.draw_animation", type:"field", title:"gun.properties.charging.draw_animation", text:"string name of the animation to play from visuals.animations. Default \"draw\""},
{path:"class/gun.html#gun.properties.charging.draw_sound", type:"field", title:"gun.properties.charging.draw_sound", text:"string name of the sound to play from sounds. Default \"draw\""},
{path:"class/gun.html#gun.properties.ammo.magazine_only", type:"field", title:"gun.properties.ammo.magazine_only", text:"bool wether the gun only uses a magazine or accepts raw ammunition too."},
{path:"class/gun.html#gun.properties.ammo.accepted_bullets", type:"field", title:"gun.properties.ammo.accepted_bullets", text:"table a list of accepted bullet itemstrings"},
{path:"class/gun.html#gun.properties.ammo.accepted_magazines", type:"field", title:"gun.properties.ammo.accepted_magazines", text:"table a list of accepted magazine itemstrings"},
{path:"class/gun.html#gun.properties.ammo.initial_mag", type:"field", title:"gun.properties.ammo.initial_mag", text:"string the mag the gun starts with. Set to \"empty\" for no mag, otherwise it defaults to accepted_magazines[1] (if present)"},
{path:"class/gun.html#gun.properties.visuals.mesh", type:"field", title:"gun.properties.visuals.mesh", text:"name of mesh to display"},
{path:"class/gun.html#gun.properties.visuals.textures", type:"field", title:"gun.properties.visuals.textures", text:"list of textures to use"},
{path:"class/gun.html#gun.properties.visuals.scale", type:"field", title:"gun.properties.visuals.scale", text:"scale multiplier"},
{path:"class/gun.html#gun.properties.visuals.backface_culling", type:"field", title:"gun.properties.visuals.backface_culling", text:"toggles backface culling"},
{path:"class/gun.html#gun.properties.visuals.animations", type:"field", title:"gun.properties.visuals.animations", text:"a table of animations in the format {x=int, y=float}. Indexes define the name of the animation to be refrenced by other functions of the gun."},
{path:"class/gun.html#gun.model_bounding_box", type:"field", title:"gun.model_bounding_box", text:"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"},
{path:"class/gun.html#gun.properties.visuals.mesh", type:"field", title:"gun.properties.visuals.mesh", text:"name of mesh to display. Currently only supports b3d"},
{path:"class/gun.html#gun.properties.visuals.textures", type:"field", title:"gun.properties.visuals.textures", text:"list of textures to use."},
{path:"class/gun.html#gun.properties.visuals.scale", type:"field", title:"gun.properties.visuals.scale", text:"scale multiplier. Default 1"},
{path:"class/gun.html#gun.properties.visuals.backface_culling", type:"field", title:"gun.properties.visuals.backface_culling", text:"toggles backface culling. Default true"},
{path:"class/gun.html#gun.properties.visuals.animations", type:"field", title:"gun.properties.visuals.animations", text:"a table of animations. Indexes define the name of the animation to be refrenced by other functions of the gun. should be in the format {x=integer,y=integer} Example There are other animations which are variable which are not listed here, these are usually defined by properties such as: draw_animation"},
{path:"class/gun.html#gun.sounds", type:"field", title:"gun.sounds", text:"a table of soundspecs to be referenced by other functions"},
{path:"class/gun.html#gun.animation_rotation", type:"field", title:"gun.animation_rotation", text:"vector containing the offset from animations, this will be generated if {@consts.ANIMATIONS_OFFSET_AIM}=true"},
{path:"class/gun.html#gun.total_offsets", type:"field", title:"gun.total_offsets", text:"all offsets from gun.offset of a type added together gun in the same format as a an offset (that is, five vectors, gun_axial, player_axial, etc.). Note that if offsets are changed after update, this will not be updated automatically until the next update. update_rotations() must be called to do so."},
{path:"class/gun.html#gun.velocities", type:"field", title:"gun.velocities", text:"velocities in the format of offsets, but only containing angular (gun_axial and player_axial) offsets."},
{path:"class/gun.html#lvl1_fields.offsets.recoil", type:"field", title:"lvl1_fields.offsets.recoil", text:""},
{path:"class/gun.html#lvl1_fields.offsets.sway", type:"field", title:"lvl1_fields.offsets.sway", text:""},
{path:"class/gun.html#lvl1_fields.offsets.walking", type:"field", title:"lvl1_fields.offsets.walking", text:""},
{path:"class/gun.html#lvl1_fields.offsets.breathing", type:"field", title:"lvl1_fields.offsets.breathing", text:""},
{path:"class/gun.html#lvl1_fields.offsets.look", type:"field", title:"lvl1_fields.offsets.look", text:""},
{path:"class/gun.html#gun.animation_rotation", type:"field", title:"gun.animation_rotation", text:"vector containing the offset from animations, this will be generated if {@consts.ANIMATIONS_OFFSET_AIM}=true"},
{path:"class/gun.html#gun.gun_axial", type:"field", title:"gun.gun_axial", text:"total offsets of the gun in the same format as a an offset [[total_offsets = {"},
{path:"class/gun.html#lvl1_fields.consts.KEYFRAME_SAMPLE_PRECISION", type:"field", title:"lvl1_fields.consts.KEYFRAME_SAMPLE_PRECISION", text:"frequency of keyframe samples for animation offsets and"},
{path:"class/gun.html#lvl1_fields.consts.DEFAULT_MAX_HEAR_DISTANCE", type:"field", title:"lvl1_fields.consts.DEFAULT_MAX_HEAR_DISTANCE", text:"default max hear distance when not specified"},
{path:"class/gun.html#lvl1_fields.consts.DEFAULT_FPS", type:"field", title:"lvl1_fields.consts.DEFAULT_FPS", text:"fps=60 animation fps i.e. during firing when no length is specified"},
@ -128,6 +136,25 @@ var docs = [
{path:"module/play_sound.html#Guns4d.stop_sounds", type:"function", title:"Guns4d.stop_sounds", text:"stops a list of sounds"},
{path:"module/Bullet_hole.html#Bullet_hole.construct", type:"function", title:"Bullet_hole.construct", text:""},
{path:"module/Control_handler.html#controls.toggle_touchscreen_mode", type:"function", title:"controls:toggle_touchscreen_mode", text:""},
{path:"module/Gun-methods.html#gun_default.update", type:"function", title:"gun_default:update", text:"The entry method for the update of the gun calls virtually all functions that begin with update once. Also updates subclass"},
{path:"module/Gun-methods.html#gun_default.update_transforms", type:"function", title:"gun_default:update_transforms", text:"updates self.total_offsets which stores offsets for bones"},
{path:"module/Gun-methods.html#gun_default.update_burstfire", type:"function", title:"gun_default:update_burstfire", text:"Update and fire the queued weapon burst"},
{path:"module/Gun-methods.html#gun_default.cycle_firemodes", type:"function", title:"gun_default:cycle_firemodes", text:"cycles to the next firemode of the weapon"},
{path:"module/Gun-methods.html#gun_default.update_image_and_text_meta", type:"function", title:"gun_default:update_image_and_text_meta", text:"update the inventory information of the gun"},
{path:"module/Gun-methods.html#gun_default.draw", type:"function", title:"gun_default:draw", text:"plays the draw animation and sound for the gun, delays usage."},
{path:"module/Gun-methods.html#gun_default.attempt_fire", type:"function", title:"gun_default:attempt_fire", text:"attempt to fire the gun"},
{path:"module/Gun-methods.html#gun_default.recoil", type:"function", title:"gun_default:recoil", text:"simulate recoil by adding to the recoil velocity (called by attempt_fire)"},
{path:"module/Gun-methods.html#gun_default.update_look_offsets", type:"function", title:"gun_default:update_look_offsets", text:"update the offsets of the player's look created by the gun"},
{path:"module/Gun-methods.html#gun_default.get_pos", type:"function", title:"gun_default:get_pos", text:"get the global position of the gun. This is customized to rely on the assumption that there are 3-4 main rotations and 2-3 translations. If the behavior of the bones are changed this method may not work"},
{path:"module/Gun-methods.html#gun_default.add_entity", type:"function", title:"gun_default:add_entity", text:"adds the gun entity"},
{path:"module/Gun-methods.html#gun_default.update_entity", type:"function", title:"gun_default:update_entity", text:"updates the gun's entity"},
{path:"module/Gun-methods.html#gun_default.has_entity", type:"function", title:"gun_default:has_entity", text:"checks if the gun entity exists..."},
{path:"module/Gun-methods.html#gun_default.update_wag", type:"function", title:"gun_default:update_wag", text:"updates the gun's wag offset for walking"},
{path:"module/Gun-methods.html#gun_default.update_recoil", type:"function", title:"gun_default:update_recoil", text:"updates the gun's recoil simulation"},
{path:"module/Gun-methods.html#gun_default.update_animation", type:"function", title:"gun_default:update_animation", text:"updates the gun's animation data"},
{path:"module/Gun-methods.html#gun_default.set_animation", type:"function", title:"gun_default:set_animation", text:"sets the gun's animation in the same format as ObjRef:set_animation() (future deprecation?)"},
{path:"module/Gun-methods.html#gun_default.clear_animation", type:"function", title:"gun_default:clear_animation", text:"clears the animation to the rest state"},
{path:"module/Gun-methods.html#gun_default.play_sounds", type:"function", title:"gun_default:play_sounds", text:"plays a list of sounds for the gun's user and thirdpersons"},
{path:"class/player_model_handler.html#player_model.construct", type:"function", title:"player_model.construct", text:""},
{path:"module/misc_helpers.html#math", type:"section", title:"math helpers", text:"in guns4d.math"},
{path:"module/misc_helpers.html#table", type:"section", title:"table helpers", text:"in guns4d.table"},

View File

@ -44,6 +44,7 @@
<li><a href="../module/play_sound.html">play_sound</a></li>
<li class="selected"><a href="../module/Bullet_hole.html">Bullet_hole</a></li>
<li><a href="../module/Control_handler.html">Control_handler</a></li>
<li><a href="../module/Gun-methods.html">Gun-methods</a></li>
</ul>
</div>
</div>

View File

@ -17,7 +17,7 @@
</div>
<div class="group three">
<div class="button iconleft"><a href="../module/Bullet_hole.html" title="Bullet_hole"><img src="../img/i-left.svg?7653a2d" alt=""/><span>Previous</span></a></div>
<div class="button iconright"><a href="../module/Gun.html" title="Gun"><span>Next</span><img src="../img/i-right.svg?7653a2d" alt=""/></a></div>
<div class="button iconright"><a href="../module/Gun-methods.html" title="Gun-methods"><span>Next</span><img src="../img/i-right.svg?7653a2d" alt=""/></a></div>
</div>
</div>
<div class="sidebar">
@ -44,6 +44,7 @@
<li><a href="../module/play_sound.html">play_sound</a></li>
<li><a href="../module/Bullet_hole.html">Bullet_hole</a></li>
<li class="selected"><a href="../module/Control_handler.html">Control_handler</a></li>
<li><a href="../module/Gun-methods.html">Gun-methods</a></li>
</ul>
</div>
</div>

View File

@ -0,0 +1,433 @@
<!DOCTYPE html>
<html lang="en">
<!-- Documentation generated by LuaDox: https://github.com/jtackaberry/luadox -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Gun-methods - Guns4d</title>
<link href="../prism.css?7653a2d" rel="stylesheet" />
<link rel="stylesheet" href="../luadox.css?7653a2d" type="text/css">
</head>
<body class="module-gunmethods">
<div class="topbar">
<div class="group one">
<div class="description"><span>Guns4d | The ultimate 3d gun mod.</span></div>
</div>
<div class="group two">
</div>
<div class="group three">
<div class="button iconleft"><a href="../module/Control_handler.html" title="Control_handler"><img src="../img/i-left.svg?7653a2d" alt=""/><span>Previous</span></a></div>
<div class="button iconright"><a href="../module/Gun.html" title="Gun"><span>Next</span><img src="../img/i-right.svg?7653a2d" alt=""/></a></div>
</div>
</div>
<div class="sidebar">
<form action="../search.html">
<input class="search" name="q" type="search" placeholder="Search" />
</form>
<div class="sections">
<div class="heading">Contents</div>
<ul>
<li><a href="#Gun-methods">Module <code>Gun-methods</code></a></li>
</ul>
</div>
<div class="classes">
<div class="heading">Classes</div>
<ul>
<li><a href="../class/gun.html">Gun.gun</a></li>
<li><a href="../class/player_model_handler.html">Player_model_handler.player_model_handler</a></li>
</ul>
</div>
<div class="modules">
<div class="heading">Modules</div>
<ul>
<li><a href="../module/misc_helpers.html">misc_helpers</a></li>
<li><a href="../module/play_sound.html">play_sound</a></li>
<li><a href="../module/Bullet_hole.html">Bullet_hole</a></li>
<li><a href="../module/Control_handler.html">Control_handler</a></li>
<li class="selected"><a href="../module/Gun-methods.html">Gun-methods</a></li>
</ul>
</div>
</div>
<div class="body">
<div class="section">
<h2 class="module" id="Gun-methods">Module <code>Gun-methods</code>
<a class="permalink" href="#Gun-methods" title="Permalink to this definition"></a>
</h2>
<div class="inner">
<div class="synopsis">
<h3>Synopsis</h3>
<div class="heading">Functions</div>
<table class="functions ">
<tr>
<td class="name"><a href="#gun_default.update"><var>gun_default:update</var></a>()</td>
<td class="doc"><p>The entry method for the update of the gun</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.update_transforms"><var>gun_default:update_transforms</var></a>()</td>
<td class="doc"><p>updates self.total_offsets which stores offsets for bones</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.update_burstfire"><var>gun_default:update_burstfire</var></a>()</td>
<td class="doc"><p>Update and fire the queued weapon burst</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.cycle_firemodes"><var>gun_default:cycle_firemodes</var></a>()</td>
<td class="doc"><p>cycles to the next firemode of the weapon</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.update_image_and_text_meta"><var>gun_default:update_image_and_text_meta</var></a>()</td>
<td class="doc"><p>update the inventory information of the gun</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.draw"><var>gun_default:draw</var></a>()</td>
<td class="doc"><p>plays the draw animation and sound for the gun, delays usage</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.attempt_fire"><var>gun_default:attempt_fire</var></a>()</td>
<td class="doc"><p>attempt to fire the gun</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.recoil"><var>gun_default:recoil</var></a>()</td>
<td class="doc"><p>simulate recoil by adding to the recoil velocity (called by attempt_fire)</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.update_look_offsets"><var>gun_default:update_look_offsets</var></a>()</td>
<td class="doc"><p>update the offsets of the player's look created by the gun</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.get_pos"><var>gun_default:get_pos</var></a>()</td>
<td class="doc"><p>get the global position of the gun</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.add_entity"><var>gun_default:add_entity</var></a>()</td>
<td class="doc"><p>adds the gun entity</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.update_entity"><var>gun_default:update_entity</var></a>()</td>
<td class="doc"><p>updates the gun's entity</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.has_entity"><var>gun_default:has_entity</var></a>()</td>
<td class="doc"><p>checks if the gun entity exists</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.update_wag"><var>gun_default:update_wag</var></a>()</td>
<td class="doc"><p>updates the gun's wag offset for walking</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.update_recoil"><var>gun_default:update_recoil</var></a>()</td>
<td class="doc"><p>updates the gun's recoil simulation</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.update_animation"><var>gun_default:update_animation</var></a>()</td>
<td class="doc"><p>updates the gun's animation data</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.set_animation"><var>gun_default:set_animation</var></a>()</td>
<td class="doc"><p>sets the gun's animation in the same format as ObjRef:set_animation() (future deprecation?)</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.clear_animation"><var>gun_default:clear_animation</var></a>()</td>
<td class="doc"><p>clears the animation to the rest state</p>
</td>
</tr>
<tr>
<td class="name"><a href="#gun_default.play_sounds"><var>gun_default:play_sounds</var></a>()</td>
<td class="doc"><p>plays a list of sounds for the gun's user and thirdpersons</p>
</td>
</tr>
</table>
</div>
<dl class="functions">
<dt id="gun_default.update">
<span class="icon"></span><var>gun_default:update</var>(<em>dt</em>)
<a class="permalink" href="#gun_default.update" title="Permalink to this definition"></a>
</dt>
<dd>
<p>The entry method for the update of the gun</p>
<p>calls virtually all functions that begin with <code>update</code> once. Also updates subclass</p>
<div class="heading">Parameters</div>
<table class="parameters">
<tr>
<td class="name"><var>dt</var></td>
<td class="types">(<em>float</em>)</td>
<td class="doc"></td>
</tr>
</table>
</dd>
<dt id="gun_default.update_transforms">
<span class="icon"></span><var>gun_default:update_transforms</var>()
<a class="permalink" href="#gun_default.update_transforms" title="Permalink to this definition"></a>
</dt>
<dd>
<p>updates self.total_offsets which stores offsets for bones</p>
</dd>
<dt id="gun_default.update_burstfire">
<span class="icon"></span><var>gun_default:update_burstfire</var>()
<a class="permalink" href="#gun_default.update_burstfire" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Update and fire the queued weapon burst</p>
</dd>
<dt id="gun_default.cycle_firemodes">
<span class="icon"></span><var>gun_default:cycle_firemodes</var>()
<a class="permalink" href="#gun_default.cycle_firemodes" title="Permalink to this definition"></a>
</dt>
<dd>
<p>cycles to the next firemode of the weapon</p>
</dd>
<dt id="gun_default.update_image_and_text_meta">
<span class="icon"></span><var>gun_default:update_image_and_text_meta</var>(<em>meta</em>)
<a class="permalink" href="#gun_default.update_image_and_text_meta" title="Permalink to this definition"></a>
</dt>
<dd>
<p>update the inventory information of the gun</p>
</dd>
<dt id="gun_default.draw">
<span class="icon"></span><var>gun_default:draw</var>()
<a class="permalink" href="#gun_default.draw" title="Permalink to this definition"></a>
</dt>
<dd>
<p>plays the draw animation and sound for the gun, delays usage.</p>
</dd>
<dt id="gun_default.attempt_fire">
<span class="icon"></span><var>gun_default:attempt_fire</var>()
<a class="permalink" href="#gun_default.attempt_fire" title="Permalink to this definition"></a>
</dt>
<dd>
<p>attempt to fire the gun</p>
</dd>
<dt id="gun_default.recoil">
<span class="icon"></span><var>gun_default:recoil</var>()
<a class="permalink" href="#gun_default.recoil" title="Permalink to this definition"></a>
</dt>
<dd>
<p>simulate recoil by adding to the recoil velocity (called by attempt_fire)</p>
</dd>
<dt id="gun_default.update_look_offsets">
<span class="icon"></span><var>gun_default:update_look_offsets</var>(<em>dt</em>)
<a class="permalink" href="#gun_default.update_look_offsets" title="Permalink to this definition"></a>
</dt>
<dd>
<p>update the offsets of the player's look created by the gun</p>
</dd>
<dt id="gun_default.get_pos">
<span class="icon"></span><var>gun_default:get_pos</var>(<em>offset</em>, <em>relative_y</em>, <em>relative_x</em>, <em>with_animation</em>)
<a class="permalink" href="#gun_default.get_pos" title="Permalink to this definition"></a>
</dt>
<dd>
<p>get the global position of the gun. This is customized to rely on the assumption that there are 3-4 main rotations and 2-3 translations. If the behavior of the bones are changed this method may not work</p>
<div class="heading">Parameters</div>
<table class="parameters">
<tr>
<td class="name"><var>offset</var></td>
<td class="types">()</td>
<td class="doc"></td>
</tr>
<tr>
<td class="name"><var>relative_y</var></td>
<td class="types">(<em>bool</em>)</td>
<td class="doc"><p>wether the y axis is relative to the player's look</p>
</td>
</tr>
<tr>
<td class="name"><var>relative_x</var></td>
<td class="types">(<em>bool</em>)</td>
<td class="doc"><p>wether the x axis is relative to the player's look</p>
</td>
</tr>
<tr>
<td class="name"><var>with_animation</var></td>
<td class="types">()</td>
<td class="doc"></td>
</tr>
</table>
<div class="heading">Return Values</div>
<table class="returns">
<tr>
<td class="types">(<em>vec3</em>)</td>
<td class="doc"><p>position of gun (in global or local orientation) relative to the player's position</p>
</td>
</tr>
</table>
</dd>
<dt id="gun_default.add_entity">
<span class="icon"></span><var>gun_default:add_entity</var>()
<a class="permalink" href="#gun_default.add_entity" title="Permalink to this definition"></a>
</dt>
<dd>
<p>adds the gun entity</p>
</dd>
<dt id="gun_default.update_entity">
<span class="icon"></span><var>gun_default:update_entity</var>()
<a class="permalink" href="#gun_default.update_entity" title="Permalink to this definition"></a>
</dt>
<dd>
<p>updates the gun's entity</p>
</dd>
<dt id="gun_default.has_entity">
<span class="icon"></span><var>gun_default:has_entity</var>()
<a class="permalink" href="#gun_default.has_entity" title="Permalink to this definition"></a>
</dt>
<dd>
<p>checks if the gun entity exists...</p>
<div class="heading">Return Values</div>
<table class="returns">
<tr>
<td class="types">(<em>bool</em>)</td>
<td class="doc"></td>
</tr>
</table>
</dd>
<dt id="gun_default.update_wag">
<span class="icon"></span><var>gun_default:update_wag</var>(<em>dt</em>)
<a class="permalink" href="#gun_default.update_wag" title="Permalink to this definition"></a>
</dt>
<dd>
<p>updates the gun's wag offset for walking</p>
<div class="heading">Parameters</div>
<table class="parameters">
<tr>
<td class="name"><var>dt</var></td>
<td class="types">(<em>float</em>)</td>
<td class="doc"></td>
</tr>
</table>
</dd>
<dt id="gun_default.update_recoil">
<span class="icon"></span><var>gun_default:update_recoil</var>(<em>dt</em>)
<a class="permalink" href="#gun_default.update_recoil" title="Permalink to this definition"></a>
</dt>
<dd>
<p>updates the gun's recoil simulation</p>
<div class="heading">Parameters</div>
<table class="parameters">
<tr>
<td class="name"><var>dt</var></td>
<td class="types">(<em>float</em>)</td>
<td class="doc"></td>
</tr>
</table>
</dd>
<dt id="gun_default.update_animation">
<span class="icon"></span><var>gun_default:update_animation</var>(<em>dt</em>)
<a class="permalink" href="#gun_default.update_animation" title="Permalink to this definition"></a>
</dt>
<dd>
<p>updates the gun's animation data</p>
</dd>
<dt id="gun_default.set_animation">
<span class="icon"></span><var>gun_default:set_animation</var>(<em>frames</em>, <em>length</em>, <em>fps</em>, <em>loop</em>)
<a class="permalink" href="#gun_default.set_animation" title="Permalink to this definition"></a>
</dt>
<dd>
<p>sets the gun's animation in the same format as ObjRef:set_animation() (future deprecation?)</p>
<div class="heading">Parameters</div>
<table class="parameters">
<tr>
<td class="name"><var>frames</var></td>
<td class="types">(<em><a href="../module/misc_helpers.html#table">table</a></em>)</td>
<td class="doc"><p><code>{x=int, y=int}</code></p>
</td>
</tr>
<tr>
<td class="name"><var>length</var></td>
<td class="types">(<em>float</em> or <em>nil</em>)</td>
<td class="doc"><p>length of the animation in seconds</p>
</td>
</tr>
<tr>
<td class="name"><var>fps</var></td>
<td class="types">(<em>int</em>)</td>
<td class="doc"><p>frames per second of the animation</p>
</td>
</tr>
<tr>
<td class="name"><var>loop</var></td>
<td class="types">(<em>bool</em>)</td>
<td class="doc"><p>wether to loop</p>
</td>
</tr>
</table>
</dd>
<dt id="gun_default.clear_animation">
<span class="icon"></span><var>gun_default:clear_animation</var>()
<a class="permalink" href="#gun_default.clear_animation" title="Permalink to this definition"></a>
</dt>
<dd>
<p>clears the animation to the rest state</p>
</dd>
<dt id="gun_default.play_sounds">
<span class="icon"></span><var>gun_default:play_sounds</var>(<em>sound</em>)
<a class="permalink" href="#gun_default.play_sounds" title="Permalink to this definition"></a>
</dt>
<dd>
<p>plays a list of sounds for the gun's user and thirdpersons</p>
<div class="heading">Parameters</div>
<table class="parameters">
<tr>
<td class="name"><var>sound</var></td>
<td class="types">(<em>soundspec_list</em>)</td>
<td class="doc"><p>parameters following the format of <a href="../module/play_sound.html#Guns4d.play_sounds">Guns4d.play_sounds()</a></p>
</td>
</tr>
</table>
<div class="heading">Return Values</div>
<table class="returns">
<tr>
<td class="name">1.</td>
<td class="types">(<em>integer</em>)</td>
<td class="doc"><p>thirdperson sound's guns4d sound handle</p>
</td>
</tr>
<tr>
<td class="name">2.</td>
<td class="types">(<em>integer</em>)</td>
<td class="doc"><p>firstperson sound's guns4d sound handle</p>
</td>
</tr>
</table>
</dd>
</dl>
</div>
</div>
</div>
<script src="../prism.js?7653a2d"></script>
</body>
</html>

View File

@ -50,6 +50,7 @@
<li><a href="../module/play_sound.html">play_sound</a></li>
<li><a href="../module/Bullet_hole.html">Bullet_hole</a></li>
<li><a href="../module/Control_handler.html">Control_handler</a></li>
<li><a href="../module/Gun-methods.html">Gun-methods</a></li>
</ul>
</div>
</div>

View File

@ -46,6 +46,7 @@
<li class="selected"><a href="../module/play_sound.html">play_sound</a></li>
<li><a href="../module/Bullet_hole.html">Bullet_hole</a></li>
<li><a href="../module/Control_handler.html">Control_handler</a></li>
<li><a href="../module/Gun-methods.html">Gun-methods</a></li>
</ul>
</div>
</div>

View File

@ -37,6 +37,7 @@
<li><a href="module/play_sound.html">play_sound</a></li>
<li><a href="module/Bullet_hole.html">Bullet_hole</a></li>
<li><a href="module/Control_handler.html">Control_handler</a></li>
<li><a href="module/Gun-methods.html">Gun-methods</a></li>
</ul>
</div>
</div>

Binary file not shown.