fixed an issue with infammo crashing the game if a gun wasn't held in hand, added new initial_vertical_aim property, changed name of swap charge to draw

This commit is contained in:
FatalErr42O 2024-03-16 14:45:47 -07:00
parent a15ae832a9
commit cc309bb6f2
15 changed files with 42 additions and 556 deletions

View File

@ -3,17 +3,21 @@
( ) find better name
-guns4d-WMA (western military arms)
( ) finish guns
(~) m4
( ) add reload anim hand movement
(~) awm
(x) m4
(x) add reload anim hand movement
( ) equip animation chambering sound
(x) awm
( ) fix texture issues
(~) complete animations
( ) load, unload
(~) complete sound effects
( ) load, unload
(x) load, unload
( ) equip animation
(x) complete sound effects
(x) load, unload
(~) glock21
( ) animate
( ) mp5
( ) Vector
( ) berreta (pistol)
( ) glock
( ) spas12
( ) guns4d_pack_2
@ -59,9 +63,9 @@
( ) bolt-catch releasing click
(x) firemode sound effects
( ) firemode switching sound
(~) add config
(x) add config
(x) add a table for config storage, some settings
( ) integrate with minetest settings, add config file.
(x) integrate with minetest settings, add config file.
(x) fix crash when switching from a gun into a gun with a sprite_scope
(x) add infinite ammo privelage and quick command
(x) privilege not directly tied to infinite ammo, fix without breaking performance?

View File

@ -103,7 +103,6 @@ function Guns4d.ammo.register_magazine(def)
Guns4d.ammo.initialize_mag_data(v)
end
end
minetest.chat_send_all(num_mags)
if num_mags == 1 then
if itemstack:get_name()=="" then
for i, v in pairs(craft_inv:get_list("craft")) do

View File

@ -92,9 +92,9 @@ local gun_default = {
firemode = Guns4d.default_controls.firemode
},
charging = { --how the gun "cocks"
require_charge_on_swap = true,
require_draw_on_swap = true,
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_charge_time = 1,
default_draw_time = 1,
},
reload = { --used by defualt controls. Still provides usefulness elsewhere.
__overfill=true,
@ -162,6 +162,7 @@ local gun_default = {
}
},
},
initial_vertical_rotation = -60,
--inventory_image
--inventory_image_empty
--used by ammo_handler
@ -174,6 +175,7 @@ local gun_default = {
recoil = {
gun_axial = Vec.new(),
player_axial = Vec.new(),
--move_dynamic_crosshair = false, this would make the dynamic crosshair move instead of get larger
},
sway = {
gun_axial = Vec.new(),
@ -198,7 +200,7 @@ local gun_default = {
gun_axial = Vec.new(),
player_axial = Vec.new(),
},]]
player_rotation = Vec.new(),
--player_rotation = Vec.new(),
velocities = {
recoil = {
gun_axial = Vec.new(),
@ -254,14 +256,14 @@ local gun_default = {
function gun_default.multiplier_coefficient(multiplier, ratio)
return 1+((multiplier*ratio)-ratio)
end
function gun_default:charge()
function gun_default:draw()
assert(self.instance, "attempt to call object method on a class")
local props = self.properties
if props.visuals.animations.charge then
self:set_animation(props.visuals.animations.charge, props.charging.default_charge_time)
if props.visuals.animations.draw then
self:set_animation(props.visuals.animations.draw, props.charging.default_draw_time)
end
self.ammo_handler:chamber_round()
self.rechamber_time = props.charging.default_charge_time
self.rechamber_time = props.charging.default_draw_time
end
--update gun, the main function.
function gun_default:update(dt)
@ -842,10 +844,10 @@ gun_default.construct = function(def)
gun = def
})
local ammo = def.ammo_handler.ammo
if def.properties.require_charge_on_swap then
if def.properties.require_draw_on_swap then
ammo.next_bullet = "empty"
end
minetest.after(0, function() if ammo.total_bullets > 0 then def:charge() end end)
minetest.after(0, function() if ammo.total_bullets > 0 then def:draw() end end)
def:update_image_and_text_meta() --has to be called manually in post as ammo_handler would not exist yet.
def.player:set_wielded_item(def.itemstack)
--unavoidable table instancing
@ -856,7 +858,7 @@ gun_default.construct = function(def)
gun_axial = Vec.new(),
player_axial = Vec.new(),
}
def.player_rotation = Vec.new()
def.player_rotation = Vec.new(def.properties.initial_vertical_rotation,0,0)
--initialize all offsets
--def.offsets = Guns4d.table.deep_copy(def.base_class.offsets)
def.offsets = {}
@ -889,6 +891,7 @@ gun_default.construct = function(def)
gun = def
})
end
if def.custom_construct then def:custom_construct() end
elseif def.name ~= "__guns4d:default__" then
local props = def.properties

View File

@ -103,9 +103,7 @@ function player_model:update_head(dt)
local player = self.player
local handler = self.handler
local gun = handler.gun
local player_axial_offset = gun.total_offset_rotation.player_axial
local pitch = player_axial_offset.x+gun.player_rotation.x
player:set_bone_position(self.bone_names.head, self.offsets.relative.head, {x=pitch,z=0,y=0})
player:set_bone_position(self.bone_names.head, self.offsets.relative.head, {x=-handler.look_rotation.x,z=0,y=0})
end
--should be renamed to "release" but, whatever.
function player_model:prepare_deletion()

View File

@ -1,18 +0,0 @@
z = reload
tap shift+z = switch fire mode
while aiming
q-e = aux switch leaning side/aiming side (default is always right)
while hip
e = aux
hold shift+z = open gun menu
q = drop the weapon
gun menu
turn safety on (can be turned off with shift+z)
unload weapon
set preferred ammo type(s)
set preferred ammo type weighting(?) (allow for control over when there's not enough ammo in a mag to prefer it)
add modifications

View File

@ -1,40 +0,0 @@
{
--defines the base recoil this gun experiences
recoil = {
--big ass table here
}
----------------------------------AMMUNITION--------------------------------------
--note: internally clips are the same as a magazine (sort of)
--Ammo_handler derived class to handle ammunition, can be changed for modularity- not reccomended, it should provide everything you need.
ammo_handler = Ammo_handler
--a table containing info about the magazines this gun may use.
magazine = {
--define if the gun only uses a magazine
magazine_only = false,
--the name of the magazine that the gun comes loaded with (optional)
comes_with = "modname:itemstring",
--a list of magazines that this gun takes. These must be registered via Guns4d.ammo.register_magazine()
--note that if the magazine contains unaccepted bullets (properties.ammo.accepted_bullets), the magazine won't be accepted.
accepted_mags = {
"modname:itemstring",
"modname:itemstring"
}
}
--list of bullets this gun accepts. These must be registered via Guns4d.ammo.register_bullet()
ammo.accepted_bullets = {
"modname:itemstring",
"modname:itemstring"
}

View File

@ -1,3 +0,0 @@
when spamming on_use, sometimes RMB in get_player_control will become stuck (engine)
classes that pollute global environment: Sprite_scope, Bullet_ray, Sprite_scope

View File

@ -1,14 +0,0 @@
The modifier class is a class that's used to specify
specific changes to a gun's properties.
to make a modifier, do something like this
Modifier:new({
apply = function(properties)
--absolutely DO NOT EVER change properties here
--this function is only so you can calculate changes
--based on the properties of the gun.
return {
}
end
})

View File

@ -1,52 +0,0 @@
VFX, SFX:
~Bullet hit node FX (steal mostly from 3dguns)
Bullet fly-by SFX
HUD system (most can once again be pulled from 3dguns)
reload progress
ammunition left
ammo type
player model & gun model reading
gun sounds
gun features
firemodes
gun ammo:
fractional reloading
magless flat reload
"3d" optics
attachments (last before beta)
fix shooting through walls while pressing against them
correct player look-down
gun leaning
add hip and aim bone offsets (this is for guns or modifiers that add stuff like "laser sights" or hud that simulates holographic sights, could be cool for futuristic type shooters)
movement rotation
sprite scopes: fix player aim delay being present with sprite scopes
bullets
bullet class system
add blunt force properties
on_hitnode function callback
compatibility
add consts for player inv use in Ammo_handler (i.e. "main", "craft_inv")
make monoid or use for player properties, player look offsets (especially needed for vehicle mods)
possibly make a library for overriding core functions.
optimization
hardcore optimization of get_dir() type functions required- super inefficient.
optimization of sprite scopes needed, buffering for relative dirs needed for when inactive. Potentially remove the global table for them (if possible.)
auxillary (beta+/never)
player hitboxes
server to client lag prediction
possible user CSM for lag prediction
bullet drop (maybe bullet wind?)
bullet tracers
inverse kinematics
stamina
a better system for reloading magazine (something like a inventory that fractionally reloads magazines so it takes time.)
create a non-player gun API
bullets, mags: add meta data support? (probably not)
jamming

View File

@ -1,310 +0,0 @@
<mxfile host="app.diagrams.net" modified="2023-08-08T02:26:17.905Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" etag="44jzb9uK1u4jJbBgrsUi" version="21.6.6" type="device">
<diagram name="Page-1" id="hjH4469px_Ex89IZIbiB">
<mxGraphModel dx="1049" dy="561" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="XBcHE4cyeVAlC1C74syX-11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="W6xmUVEbs_vsLZUt_kYx-8" target="W6xmUVEbs_vsLZUt_kYx-12">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="520" y="680" />
<mxPoint x="405" y="680" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-12" value="Instantiate" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="XBcHE4cyeVAlC1C74syX-11">
<mxGeometry x="0.4996" y="1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-102" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;fillColor=#d5e8d4;strokeColor=#82b366;entryX=0.25;entryY=0;entryDx=0;entryDy=0;exitX=0.75;exitY=1;exitDx=0;exitDy=0;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-8" target="W6xmUVEbs_vsLZUt_kYx-73" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="676" y="630" as="sourcePoint" />
<mxPoint x="714" y="775" as="targetPoint" />
<Array as="points">
<mxPoint x="550" y="720" />
<mxPoint x="700" y="720" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-5" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="740" y="580" as="targetPoint" />
<mxPoint x="830" y="545" as="sourcePoint" />
<Array as="points" />
</mxGeometry>
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-15" value="Creates and updates" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="W6xmUVEbs_vsLZUt_kYx-10">
<mxGeometry x="-0.261" y="1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-5" target="W6xmUVEbs_vsLZUt_kYx-8" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-37" value="Creates &amp;amp; updates" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="W6xmUVEbs_vsLZUt_kYx-11" vertex="1" connectable="0">
<mxGeometry x="-0.3348" y="1" relative="1" as="geometry">
<mxPoint x="-17" y="-1" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-15" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-5" target="W6xmUVEbs_vsLZUt_kYx-14" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="820" y="510" as="sourcePoint" />
<mxPoint x="950" y="580" as="targetPoint" />
<Array as="points">
<mxPoint x="990" y="510" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-61" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.25;entryY=0;entryDx=0;entryDy=0;fillColor=#d80073;strokeColor=#A50040;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-5" target="W6xmUVEbs_vsLZUt_kYx-14" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="960" y="530" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-64" value="Pass gun controls def" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="W6xmUVEbs_vsLZUt_kYx-61" vertex="1" connectable="0">
<mxGeometry x="-0.3137" y="-1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-5" value="Player handler" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="680" y="480" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-28" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-8" target="W6xmUVEbs_vsLZUt_kYx-9" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="600" y="560" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-32" value="Bone info" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="W6xmUVEbs_vsLZUt_kYx-28" vertex="1" connectable="0">
<mxGeometry x="0.1556" y="1" relative="1" as="geometry">
<mxPoint x="-12" y="1" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-72" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.582;entryY=-0.003;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryPerimeter=0;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-8" target="W6xmUVEbs_vsLZUt_kYx-71" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="520" y="680" />
<mxPoint x="590" y="680" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-77" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.25;entryY=0;entryDx=0;entryDy=0;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-8" target="W6xmUVEbs_vsLZUt_kYx-71" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="550" y="670" />
<mxPoint x="550" y="670" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-78" value="Bone info &amp;amp;&lt;br&gt;gun direction" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="W6xmUVEbs_vsLZUt_kYx-77" vertex="1" connectable="0">
<mxGeometry x="0.1298" y="-2" relative="1" as="geometry">
<mxPoint y="-5" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-75" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-8" target="W6xmUVEbs_vsLZUt_kYx-73" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="520" y="680" />
<mxPoint x="730" y="680" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-76" value="Creates &amp;amp; updates" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="W6xmUVEbs_vsLZUt_kYx-75" vertex="1" connectable="0">
<mxGeometry x="-0.8968" y="-1" relative="1" as="geometry">
<mxPoint x="1" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-95" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;entryX=0.875;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-8" target="W6xmUVEbs_vsLZUt_kYx-88" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-8" value="Gun" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="460" y="580" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-9" value="model handler" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="680" y="580" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="W6xmUVEbs_vsLZUt_kYx-12" target="W6xmUVEbs_vsLZUt_kYx-19">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-12" value="Bullet ray(s)" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="345" y="790" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.75;entryDx=0;entryDy=0;fillColor=#dae8fc;strokeColor=#6c8ebf;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-14" target="W6xmUVEbs_vsLZUt_kYx-8" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="990" y="660" />
<mxPoint x="615" y="660" />
<mxPoint x="615" y="625" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-7" value="call :fire() or other methods" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="wAXQPkzS34ZOuWmKrVVe-5" vertex="1" connectable="0">
<mxGeometry x="-0.0751" relative="1" as="geometry">
<mxPoint x="-20" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-14" value="Control handler" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="930" y="580" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-17" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" target="W6xmUVEbs_vsLZUt_kYx-5" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="740" y="330" as="sourcePoint" />
<Array as="points" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-35" value="Creates" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="W6xmUVEbs_vsLZUt_kYx-17" vertex="1" connectable="0">
<mxGeometry x="-0.1753" y="2" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-16" value="on joinplayer" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="680" y="270" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-19" value="Target or node" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" parent="1" vertex="1">
<mxGeometry x="260" y="790" width="30" height="60" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-38" value="Creates &amp;amp; updates" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="1" vertex="1" connectable="0">
<mxGeometry x="869.9966666666667" y="510" as="geometry" />
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-18" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-58" target="W6xmUVEbs_vsLZUt_kYx-121" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-58" value="Gun class" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="867.5" y="245" width="80" height="100" as="geometry" />
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.385;entryY=0.052;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="W6xmUVEbs_vsLZUt_kYx-67" target="W6xmUVEbs_vsLZUt_kYx-83">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-67" value="attachments" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;fillColor=#e1d5e7;strokeColor=#9673a6;" parent="1" vertex="1">
<mxGeometry x="1045" y="230" width="80" height="100" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-71" value="Sprite scope" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="520" y="790" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-73" value="Physical scope" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" parent="1" vertex="1">
<mxGeometry x="670" y="790" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-26" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-83" target="W6xmUVEbs_vsLZUt_kYx-121" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-35" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-88" target="W6xmUVEbs_vsLZUt_kYx-8" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-10" value="Predict client&lt;br&gt;view or request&lt;br&gt;directly" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="wAXQPkzS34ZOuWmKrVVe-35">
<mxGeometry x="-0.1935" y="1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-88" value="External server side modifications" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" parent="1" vertex="1">
<mxGeometry x="210" y="565" width="135" height="90" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-109" value="&lt;h1&gt;&lt;i&gt;&lt;u&gt;guns4d structure specification diagram&lt;/u&gt;&lt;/i&gt;&lt;/h1&gt;" style="text;html=1;strokeColor=#FFFFFF;fillColor=#fff2cc;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;align=center;" parent="1" vertex="1">
<mxGeometry x="40" y="30" width="510" height="40" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-114" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#FFFFFF;" parent="1" vertex="1">
<mxGeometry x="40" y="90" width="120" height="250" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-115" value="process" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;" parent="1" vertex="1">
<mxGeometry x="50" y="110" width="100" height="30" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-118" value="class&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="50" y="165" width="100" height="45" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-120" value="Instance" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="50" y="230" width="100" height="40" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-121" value="&lt;font style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;background-color: rgb(255, 255, 255);&quot;&gt;create correct gun by finding correct class and modifying properties by item metadata&lt;/span&gt;&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="835" y="375" width="145" height="80" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-127" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=0.75;exitY=0;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="W6xmUVEbs_vsLZUt_kYx-5" target="W6xmUVEbs_vsLZUt_kYx-121" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="775" y="460" as="sourcePoint" />
<mxPoint x="825" y="410" as="targetPoint" />
<Array as="points">
<mxPoint x="770" y="455" />
<mxPoint x="770" y="415" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-130" value="inactive" style="rounded=0;whiteSpace=wrap;html=1;strokeColor=#C3ABD0;fillColor=#e1d5e7;" parent="1" vertex="1">
<mxGeometry x="50" y="290" width="100" height="30" as="geometry" />
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-21" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.991;entryY=0.611;entryDx=0;entryDy=0;entryPerimeter=0;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="1226.08" y="609.92" as="sourcePoint" />
<mxPoint x="1050.0000000000005" y="609.5799999999998" as="targetPoint" />
<Array as="points">
<mxPoint x="1226.08" y="609.92" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-17" value="Player controls" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="wAXQPkzS34ZOuWmKrVVe-21">
<mxGeometry x="0.0076" y="-1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-40" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="1260" y="449.9999999999999" as="targetPoint" />
<mxPoint x="1260" y="530" as="sourcePoint" />
</mxGeometry>
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-131" value="Gun holder" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" parent="1" vertex="1">
<mxGeometry x="1235" y="540" width="50" height="100" as="geometry" />
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-8" value="" style="shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;rotation=-180;position2=1;base=45;strokeColor=none;fillColor=#fff2cc;" parent="1" vertex="1">
<mxGeometry x="800" y="670" width="120" height="120" as="geometry" />
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-11" value="&lt;font style=&quot;font-size: 8px;&quot;&gt;Note that this is the behavior from the API layer (via properties.controls), but in the base class there&#39;s no interaction between these two components by default&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="800" y="710" width="115" height="70" as="geometry" />
</mxCell>
<mxCell id="W6xmUVEbs_vsLZUt_kYx-83" value="held item string and metadata" style="ellipse;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" parent="1" vertex="1">
<mxGeometry x="1045" y="380" width="105" height="70" as="geometry" />
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-41" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" target="W6xmUVEbs_vsLZUt_kYx-83" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="1200" y="414.9999999999999" as="sourcePoint" />
</mxGeometry>
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-43" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.75;entryY=0;entryDx=0;entryDy=0;exitX=0.181;exitY=0.967;exitDx=0;exitDy=0;exitPerimeter=0;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" source="wAXQPkzS34ZOuWmKrVVe-42" target="W6xmUVEbs_vsLZUt_kYx-14" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="1225" y="448" />
<mxPoint x="1225" y="510" />
<mxPoint x="1020" y="510" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-45" value="on_use (etc) &lt;br&gt;callbacks" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="wAXQPkzS34ZOuWmKrVVe-43" vertex="1" connectable="0">
<mxGeometry x="-0.0218" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="wAXQPkzS34ZOuWmKrVVe-42" value="Item / Itemstack" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="1200" y="390" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="497.5" y="470" as="sourcePoint" />
<mxPoint x="497" y="580" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-9" value="Bullet definition" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="XBcHE4cyeVAlC1C74syX-8">
<mxGeometry x="-0.6286" y="1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-7" value="held item string and metadata" style="ellipse;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="445" y="400" width="105" height="70" as="geometry" />
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-20" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="XBcHE4cyeVAlC1C74syX-18" target="XBcHE4cyeVAlC1C74syX-7">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="XBcHE4cyeVAlC1C74syX-18" value="Bullet class" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1">
<mxGeometry x="457.5" y="230" width="80" height="100" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

View File

@ -1,92 +0,0 @@
This document contains (hopefully) all you need to know about
the control_handler, and any other relevant input systems
The control system is designed to be simple but versatile,
----------------------------------------------------------------------------
basic information
----------------------------------------------------------------------------
IMPORTANT: `on_use` and `on_secondary_use` are RESERVED indexes. They
have different behaviors and function parameters. (see special actions)
control action example:
------------------------------------------------------------------------
(The default aim taken from gun_api.lua)
aim = {
conditions = {"RMB"},
loop = false,
timer = 0,
func = function(active, interrupted, data, busy_list, handler)
if active then
handler.control_handler.ads = not handler.control_handler.ads
end
end
},
------------------------------------------------------------------------
here's the breakdown:
`conditions = {"RMB"}` is the list of conditions (see get_player_control
in minetest's lua_api.txt) that need to be fufulled for the control to
be activated
`timer = 0` tells the handler that if condtions are met for 0 seconds
that it is active.
`loop = false` indicates the it only will call once if the key(s) are
held for the the specified amount of time `timer = 0`. In short, this
tells the handler to run the function one time instead of calling it
in (as the name implies) a loop.
additional properties:
`call_before_timer = false` if true, then the handler calls the function
while the timer is in progress, this is very useful if you want something
like a reload animation, or maybe a bow with a cocking animation, etc.
use the function parameters (as follows) for better information.
----------------------------------------------------------------------------
standard function parameters
----------------------------------------------------------------------------
function parameters for normal actions (see special actions)
`active` indicates wether conditions or timers were met/finished, the
function can be called for reasons other then conditions being finished.
use this to check if you actually want to do an action (such as firing)
or finalizing reloads.
`interrupted` indicates if conditions were no longer met while the timer
was in progress. This cannot not be called with active as true.
`data` is actually the Control_handler's table for the control action,
it has `timer` which is the time left on the action and `held` which
indicates if the keyboard and mouse conditions are met.
`busy_list` is a list of other active actions, use this if you want to
only act if
`handler` is the Player_handler, this is guns4d's *everything* handler.
to get the gun use `handler.gun`, to get the player use `handler.player`
----------------------------------------------------------------------------
special action
----------------------------------------------------------------------------
The indexes `on_use` and `on_secondary_use` are reserved for calls from
the default on_use and on_secondary_use of tools. By default, the on_use
and on_secondary_use of the itemstring provided is overwritten to contain
this call.
set these as functions (with the following parameters) for on_use and
on_secondary_use. It's not set in busy list by defaults, so if you
wish (or otherwise need to) add a `self.busy_list.on_use = true` to it.
note that the busy list is cleared each update by default.
function parameters:
`itemstack`, `handler`, `pointed_thing`
see lua_api.txt for details on `itemstack` and `pointed_thing` and
see "standard function parameters" for handler info.

0
guns4d_settings.conf Normal file
View File

View File

@ -54,7 +54,9 @@ minetest.register_chatcommand("ammoinf", {
minetest.set_player_privs(trgt, privs)
minetest.chat_send_player(caller, "infinite ammo "..((set_to and "granted to") or "revoked from") .." user '"..trgt.."'")
handler.infinite_ammo = set_to or false
handler.gun:update_image_and_text_meta()
handler.player:set_wielded_item(handler.gun.itemstack)
if handler.gun then
handler.gun:update_image_and_text_meta()
handler.player:set_wielded_item(handler.gun.itemstack)
end
end
})

View File

@ -12,9 +12,19 @@ Guns4d.config = {
control_hybrid_toggle_threshold = .3,
control_held_toggle_threshold = 0,
empty_symbol = "0e",
infinite_ammo_priv = "guns4d_infinite_ammo"
infinite_ammo_priv = "guns4d_infinite_ammo",
--`["official_content.replace_ads_with_bloom"] = false,
--`["official_content.uses_magazines"] = true
}
local path = minetest.get_modpath("guns4d")
print("file read?")
local conf = Settings(path.."/guns4d_settings.conf")
for i, v in pairs(conf:to_table() or {}) do
print(i,v)
Guns4d.config[i] = v
end
dofile(path.."/infinite_ammo.lua")
dofile(path.."/misc_helpers.lua")
dofile(path.."/item_entities.lua")

View File

@ -89,7 +89,6 @@ def.set_item = function(self, item)
self._collisionbox = cbox
end
local old = def.on_step
print(dump(def))
def.on_step = function(self, dt, mr, ...)
old(self, dt, mr, ...)
--icky nesting.