Guns4d | The ultimate 3d gun mod.

Module Gun-methods

Synopsis

Functions
gun_default:update()

The entry method for the update of the gun

gun_default:regenerate_visuals()

not typically called every step, updates the gun object's visuals

gun_default:update_transforms()

updates self.total_offsets which stores offsets for bones

gun_default:update_burstfire()

Update and fire the queued weapon burst

gun_default:cycle_firemodes()

cycles to the next firemode of the weapon

gun_default:update_image_and_text_meta()

update the inventory information of the gun

gun_default:draw()

plays the draw animation and sound for the gun, delays usage

gun_default:muzzle_flash()

plays the muzzle flash animation

gun_default:attempt_fire()

attempt to fire the gun

gun_default:recoil()

simulate recoil by adding to the recoil velocity (called by attempt_fire)

gun_default:update_look_offsets()

update the offsets of the player's look created by the gun

gun_default:get_pos()

get the global position of the gun

gun_default:add_entity()

adds the gun entity

gun_default:update_entity()

updates the gun's entity

gun_default:has_entity()

checks if the gun entity exists

gun_default:update_wag()

updates the gun's wag offset for walking

gun_default:update_recoil()

updates the gun's recoil simulation

gun_default:update_animation()

updates the gun's animation data

gun_default:set_animation()

sets the gun's animation in the same format as ObjRef:set_animation() (future deprecation?)

gun_default:clear_animation()

clears the animation to the rest state

gun_default:play_sounds()

plays a list of sounds for the gun's user and thirdpersons

gun_default:prepare_deletion()

ready the gun to be deleted

gun_default:update(dt)

The entry method for the update of the gun

calls virtually all functions that begin with update once. Also updates subclass

Parameters
dt (float)
gun_default:regenerate_visuals()

not typically called every step, updates the gun object's visuals

gun_default:update_transforms()

updates self.total_offsets which stores offsets for bones

gun_default:update_burstfire()

Update and fire the queued weapon burst

gun_default:cycle_firemodes()

cycles to the next firemode of the weapon

gun_default:update_image_and_text_meta(meta)

update the inventory information of the gun

gun_default:draw()

plays the draw animation and sound for the gun, delays usage.

gun_default:muzzle_flash()

plays the muzzle flash animation

gun_default:attempt_fire()

attempt to fire the gun

gun_default:recoil()

simulate recoil by adding to the recoil velocity (called by attempt_fire)

gun_default:update_look_offsets(dt)

update the offsets of the player's look created by the gun

gun_default:get_pos(offset, relative_y, relative_x, with_animation)

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. the point of this is to allow the user to find the gun's object origin as well as calculate where a given point should be offset given the parameters.

Parameters
offset ()
relative_y (bool)

wether the y axis player look rotation is set to 0

relative_x (bool)

wether the x axis player look rotation is set to 0

with_animation (bool)

wether rotational and translational offsets from the animation are applied or 0

Return Values
(vec3)

position of gun (in global or local orientation) relative to the player's position

gun_default:add_entity()

adds the gun entity

gun_default:update_entity()

updates the gun's entity

gun_default:has_entity()

checks if the gun entity exists...

Return Values
(bool)
gun_default:update_wag(dt)

updates the gun's wag offset for walking

Parameters
dt (float)
gun_default:update_recoil(dt)

updates the gun's recoil simulation

Parameters
dt (float)
gun_default:update_animation(dt)

updates the gun's animation data

gun_default:set_animation(frames, length, fps, loop)

sets the gun's animation in the same format as ObjRef:set_animation() (future deprecation?)

Parameters
frames (table)

{x=int, y=int}

length (float or nil)

length of the animation in seconds

fps (int)

frames per second of the animation

loop (bool)

wether to loop

gun_default:clear_animation()

clears the animation to the rest state

gun_default:play_sounds(sound)

plays a list of sounds for the gun's user and thirdpersons

Parameters
sound (soundspec_list)

parameters following the format of Guns4d.play_sounds()

Return Values
1. (integer)

thirdperson sound's guns4d sound handle

2. (integer)

firstperson sound's guns4d sound handle

gun_default:prepare_deletion()

ready the gun to be deleted