completely reformated construction of gun, and fixed an issue where animation_data was not instanced.
This commit is contained in:
parent
fd201fb1cd
commit
9922a37206
148
autogen_docs/classes/Gun.html
Normal file
148
autogen_docs/classes/Gun.html
Normal file
@ -0,0 +1,148 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>4dguns documentation</title>
|
||||
<link rel="stylesheet" href="../ldoc_new.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>4dguns</h1>
|
||||
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Classes</h2>
|
||||
<ul class="nowrap">
|
||||
<li><strong>Gun</strong></li>
|
||||
<li><a href="../classes/Instantiatable_class.html">Instantiatable_class</a></li>
|
||||
</ul>
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/default_controls.html">default_controls</a></li>
|
||||
</ul>
|
||||
<h2>Scripts</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../scripts/item_entities.lua.html">item_entities.lua</a></li>
|
||||
<li><a href="../scripts/misc_helpers.html">misc_helpers</a></li>
|
||||
<li><a href="../scripts/play_sound.html">play_sound</a></li>
|
||||
</ul>
|
||||
<h2>Topics</h2>
|
||||
<ul class="">
|
||||
<li><a href="../topics/readme.md.html">readme</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Class <code>Gun</code></h1>
|
||||
<p>Gun class
|
||||
this is the system used to represent guns and their attributes directly.</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#gun.properties">gun.properties</a></td>
|
||||
<td class="summary">properties</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "gun.properties"></a>
|
||||
<strong>gun.properties</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
properties
|
||||
|
||||
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">infinite_inventory_overlay</span>
|
||||
defines the filename to to be used as the overlay on the item when the player has infinite ammo.
|
||||
</li>
|
||||
<li><span class="parameter">breathing_scale</span>
|
||||
the max angluler offset caused by breathing.
|
||||
</li>
|
||||
<li><span class="parameter">flash_offset</span>
|
||||
used by fire() (for fsx and ray start pos) [RENAME NEEDED]
|
||||
</li>
|
||||
<li><span class="parameter">firerateRPM</span>
|
||||
used by update() and by extent fire() + default controls. The firerate of the gun. Rounds per minute
|
||||
</li>
|
||||
<li><span class="parameter">burst</span>
|
||||
how many rounds in burst using when firemode is at "burst"
|
||||
</li>
|
||||
<li><span class="parameter">ammo_handler</span>
|
||||
absurd. @table hip @field I can't believe i'm doing this
|
||||
</li>
|
||||
<li><span class="parameter">hip</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">sway_vel_mul</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">sway_angle_mul</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||
<i style="float:right;">Last updated 2024-03-28 12:40:54 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
201
autogen_docs/classes/Instantiatable_class.html
Normal file
201
autogen_docs/classes/Instantiatable_class.html
Normal file
@ -0,0 +1,201 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>4dguns documentation</title>
|
||||
<link rel="stylesheet" href="../ldoc_new.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>4dguns</h1>
|
||||
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
<li><a href="#Methods">Methods</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Classes</h2>
|
||||
<ul class="nowrap">
|
||||
<li><strong>Instantiatable_class</strong></li>
|
||||
</ul>
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/Gun.html">Gun</a></li>
|
||||
<li><a href="../modules/default_controls.html">default_controls</a></li>
|
||||
</ul>
|
||||
<h2>Scripts</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../scripts/item_entities.lua.html">item_entities.lua</a></li>
|
||||
<li><a href="../scripts/misc_helpers.html">misc_helpers</a></li>
|
||||
<li><a href="../scripts/play_sound.html">play_sound</a></li>
|
||||
</ul>
|
||||
<h2>Topics</h2>
|
||||
<ul class="">
|
||||
<li><a href="../topics/readme.md.html">readme</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Class <code>Instantiatable_class</code></h1>
|
||||
<p>Instantiatable_class.</p>
|
||||
<p> The system for defining classes in 4dguns. Please note the capital "I", Ldoc converts it to a lowercase in all of this file</p>
|
||||
|
||||
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#instantiatable_class.god_work">instantiatable_class.god_work</a></td>
|
||||
<td class="summary">Instantiatable_class</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Methods">Methods</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#instantiatable_class:inherit">instantiatable_class:inherit (def)</a></td>
|
||||
<td class="summary">creates a new base class.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#instantiatable_class:construct">instantiatable_class:construct ()</a></td>
|
||||
<td class="summary">construct
|
||||
every parent constructor is called in order of inheritance, this is used to make changes to the child table.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#instantiatable_class:new">instantiatable_class:new ()</a></td>
|
||||
<td class="summary">creates an instance of the base class.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "instantiatable_class.god_work"></a>
|
||||
<strong>instantiatable_class.god_work</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Instantiatable_class
|
||||
|
||||
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">instance</span>
|
||||
defines wether the object is an instance
|
||||
</li>
|
||||
<li><span class="parameter">base_class</span>
|
||||
only present for instances: the class from which this instance originates
|
||||
</li>
|
||||
<li><span class="parameter">parent_class</span>
|
||||
the class from which this class was inherited from
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Methods"></a>Methods</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "instantiatable_class:inherit"></a>
|
||||
<strong>instantiatable_class:inherit (def)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
creates a new base class. Calls all constructors in the chain with def.instance=true
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">def</span>
|
||||
the table containing a new definition (where the class calling the method is the parent). The content of the definition will override the fields for it's children.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
def a new base class
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "instantiatable_class:construct"></a>
|
||||
<strong>instantiatable_class:construct ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
construct
|
||||
every parent constructor is called in order of inheritance, this is used to make changes to the child table. In self you will find base_class defining what class it is from, and the bool instance indicating (shocking) wether it is an instance.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "instantiatable_class:new"></a>
|
||||
<strong>instantiatable_class:new ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
creates an instance of the base class. Calls all constructors in the chain with def.instance=true
|
||||
|
||||
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
def a new instance of the class.
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||
<i style="float:right;">Last updated 2024-03-28 12:47:10 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
@ -30,11 +30,21 @@
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="modules/Gun.html">Gun</a></li>
|
||||
<li><a href="modules/default_controls.html">default_controls</a></li>
|
||||
</ul>
|
||||
<h2>Scripts</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="scripts/item_entities.lua.html">item_entities.lua</a></li>
|
||||
<li><a href="scripts/misc_helpers.html">misc_helpers</a></li>
|
||||
<li><a href="scripts/play_sound.html">play_sound</a></li>
|
||||
</ul>
|
||||
<h2>Classes</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="classes/Instantiatable_class.html">Instantiatable_class</a></li>
|
||||
</ul>
|
||||
<h2>Topics</h2>
|
||||
<ul class="">
|
||||
<li><a href="topics/readme.md.html">readme</a></li>
|
||||
@ -47,8 +57,24 @@
|
||||
|
||||
<h2>THEE ultimate 3d gun library.</h2>
|
||||
|
||||
<h2>Modules</h2>
|
||||
<table class="module_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/Gun.html">Gun</a></td>
|
||||
<td class="summary">Gun class
|
||||
this is the system used to represent guns and their attributes directly.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/default_controls.html">default_controls</a></td>
|
||||
<td class="summary">a default control system for aiming, reloading, firing, reloading, and more.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Scripts</h2>
|
||||
<table class="module_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="scripts/item_entities.lua.html">item_entities.lua</a></td>
|
||||
<td class="summary">adds 3d items for guns and magazines</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="scripts/misc_helpers.html">misc_helpers</a></td>
|
||||
<td class="summary">misc.</td>
|
||||
@ -58,6 +84,13 @@
|
||||
<td class="summary">implements tools for quickly playing audio.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Classes</h2>
|
||||
<table class="module_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="classes/Instantiatable_class.html">Instantiatable_class</a></td>
|
||||
<td class="summary">Instantiatable_class.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Topics</h2>
|
||||
<table class="module_list">
|
||||
<tr>
|
||||
@ -70,7 +103,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||
<i style="float:right;">Last updated 2024-01-19 14:08:01 </i>
|
||||
<i style="float:right;">Last updated 2024-03-28 12:47:10 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
148
autogen_docs/modules/Gun.html
Normal file
148
autogen_docs/modules/Gun.html
Normal file
@ -0,0 +1,148 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>4dguns documentation</title>
|
||||
<link rel="stylesheet" href="../ldoc_new.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>4dguns</h1>
|
||||
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><strong>Gun</strong></li>
|
||||
<li><a href="../modules/default_controls.html">default_controls</a></li>
|
||||
</ul>
|
||||
<h2>Scripts</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../scripts/item_entities.lua.html">item_entities.lua</a></li>
|
||||
<li><a href="../scripts/misc_helpers.html">misc_helpers</a></li>
|
||||
<li><a href="../scripts/play_sound.html">play_sound</a></li>
|
||||
</ul>
|
||||
<h2>Classes</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../classes/Instantiatable_class.html">Instantiatable_class</a></li>
|
||||
</ul>
|
||||
<h2>Topics</h2>
|
||||
<ul class="">
|
||||
<li><a href="../topics/readme.md.html">readme</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>Gun</code></h1>
|
||||
<p>Gun class
|
||||
this is the system used to represent guns and their attributes directly.</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#properties">properties</a></td>
|
||||
<td class="summary">properties</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "properties"></a>
|
||||
<strong>properties</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
properties
|
||||
|
||||
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">infinite_inventory_overlay</span>
|
||||
defines the filename to to be used as the overlay on the item when the player has infinite ammo.
|
||||
</li>
|
||||
<li><span class="parameter">breathing_scale</span>
|
||||
the max angluler offset caused by breathing.
|
||||
</li>
|
||||
<li><span class="parameter">flash_offset</span>
|
||||
used by fire() (for fsx and ray start pos) [RENAME NEEDED]
|
||||
</li>
|
||||
<li><span class="parameter">firerateRPM</span>
|
||||
used by update() and by extent fire() + default controls. The firerate of the gun. Rounds per minute
|
||||
</li>
|
||||
<li><span class="parameter">burst</span>
|
||||
how many rounds in burst using when firemode is at "burst"
|
||||
</li>
|
||||
<li><span class="parameter">ammo_handler</span>
|
||||
absurd. @table hip @field I can't believe i'm doing this
|
||||
</li>
|
||||
<li><span class="parameter">hip</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">sway_vel_mul</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">sway_angle_mul</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||
<i style="float:right;">Last updated 2024-03-28 12:47:10 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
82
autogen_docs/modules/default_controls.html
Normal file
82
autogen_docs/modules/default_controls.html
Normal file
@ -0,0 +1,82 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>4dguns documentation</title>
|
||||
<link rel="stylesheet" href="../ldoc_new.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>4dguns</h1>
|
||||
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/Gun.html">Gun</a></li>
|
||||
<li><strong>default_controls</strong></li>
|
||||
</ul>
|
||||
<h2>Scripts</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../scripts/item_entities.lua.html">item_entities.lua</a></li>
|
||||
<li><a href="../scripts/misc_helpers.html">misc_helpers</a></li>
|
||||
<li><a href="../scripts/play_sound.html">play_sound</a></li>
|
||||
</ul>
|
||||
<h2>Classes</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../classes/Instantiatable_class.html">Instantiatable_class</a></li>
|
||||
</ul>
|
||||
<h2>Topics</h2>
|
||||
<ul class="">
|
||||
<li><a href="../topics/readme.md.html">readme</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>default_controls</code></h1>
|
||||
<p>a default control system for aiming, reloading, firing, reloading, and more.</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||
<i style="float:right;">Last updated 2024-03-28 12:47:10 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
172
autogen_docs/scripts/item_entities.lua.html
Normal file
172
autogen_docs/scripts/item_entities.lua.html
Normal file
@ -0,0 +1,172 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>4dguns documentation</title>
|
||||
<link rel="stylesheet" href="../ldoc_new.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>4dguns</h1>
|
||||
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Scripts</h2>
|
||||
<ul class="nowrap">
|
||||
<li><strong>item_entities.lua</strong></li>
|
||||
<li><a href="../scripts/misc_helpers.html">misc_helpers</a></li>
|
||||
<li><a href="../scripts/play_sound.html">play_sound</a></li>
|
||||
</ul>
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/Gun.html">Gun</a></li>
|
||||
<li><a href="../modules/default_controls.html">default_controls</a></li>
|
||||
</ul>
|
||||
<h2>Classes</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../classes/Instantiatable_class.html">Instantiatable_class</a></li>
|
||||
</ul>
|
||||
<h2>Topics</h2>
|
||||
<ul class="">
|
||||
<li><a href="../topics/readme.md.html">readme</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Script <code>item_entities.lua</code></h1>
|
||||
<p>adds 3d items for guns and magazines</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#Guns4d.register_item">Guns4d.register_item (itemstring, def)</a></td>
|
||||
<td class="summary">replaces the item entity of the provided item with a 3d entity based on the definition</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#guns4d_itemdef">guns4d_itemdef</a></td>
|
||||
<td class="summary">table defining the new 3d entity for a dropped item</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "Guns4d.register_item"></a>
|
||||
<strong>Guns4d.register_item (itemstring, def)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
replaces the item entity of the provided item with a 3d entity based on the definition
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">itemstring</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">def</span>
|
||||
, a <a href="../scripts/item_entities.lua.html#guns4d_itemdef">guns4d_itemdef</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "guns4d_itemdef"></a>
|
||||
<strong>guns4d_itemdef</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
table defining the new 3d entity for a dropped item
|
||||
|
||||
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">light_source</span>
|
||||
int, equivelant to minetest itemdef version
|
||||
</li>
|
||||
<li><span class="parameter">size</span>
|
||||
int, the size of the collision box
|
||||
</li>
|
||||
<li><span class="parameter">mesh</span>
|
||||
string, the mesh to use for the item
|
||||
</li>
|
||||
<li><span class="parameter">textures</span>
|
||||
table, a list of textures (see minetest entity documentation)
|
||||
</li>
|
||||
<li><span class="parameter">collisionbox_size</span>
|
||||
, the size of collisionbox in tenths of meters.
|
||||
</li>
|
||||
<li><span class="parameter">selectionbox</span>
|
||||
vector, xyz scale of the selectionbox
|
||||
</li>
|
||||
<li><span class="parameter">offset</span>
|
||||
vector, xyz offset of the visual object from the collision and selectionbox. (so that magazines's origin can match their bone.)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||
<i style="float:right;">Last updated 2024-03-28 12:47:10 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
@ -39,9 +39,19 @@
|
||||
|
||||
<h2>Scripts</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../scripts/item_entities.lua.html">item_entities.lua</a></li>
|
||||
<li><strong>misc_helpers</strong></li>
|
||||
<li><a href="../scripts/play_sound.html">play_sound</a></li>
|
||||
</ul>
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/Gun.html">Gun</a></li>
|
||||
<li><a href="../modules/default_controls.html">default_controls</a></li>
|
||||
</ul>
|
||||
<h2>Classes</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../classes/Instantiatable_class.html">Instantiatable_class</a></li>
|
||||
</ul>
|
||||
<h2>Topics</h2>
|
||||
<ul class="">
|
||||
<li><a href="../topics/readme.md.html">readme</a></li>
|
||||
@ -108,7 +118,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||
<i style="float:right;">Last updated 2024-01-19 14:08:01 </i>
|
||||
<i style="float:right;">Last updated 2024-03-28 12:47:10 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -40,9 +40,19 @@
|
||||
|
||||
<h2>Scripts</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../scripts/item_entities.lua.html">item_entities.lua</a></li>
|
||||
<li><a href="../scripts/misc_helpers.html">misc_helpers</a></li>
|
||||
<li><strong>play_sound</strong></li>
|
||||
</ul>
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/Gun.html">Gun</a></li>
|
||||
<li><a href="../modules/default_controls.html">default_controls</a></li>
|
||||
</ul>
|
||||
<h2>Classes</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../classes/Instantiatable_class.html">Instantiatable_class</a></li>
|
||||
</ul>
|
||||
<h2>Topics</h2>
|
||||
<ul class="">
|
||||
<li><a href="../topics/readme.md.html">readme</a></li>
|
||||
@ -62,9 +72,13 @@
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#Guns4d.play_sound">Guns4d.play_sound (sound_specs)</a></td>
|
||||
<td class="name" nowrap><a href="#Guns4d.play_sounds">Guns4d.play_sounds (sound_specs)</a></td>
|
||||
<td class="summary">allows you to play one or more sounds with more complex features, so sounds can be easily coded for guns without the need for functions.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#Guns4d.stop_sounds">Guns4d.stop_sounds (handle_list)</a></td>
|
||||
<td class="summary">stops a list of sounds</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
@ -82,8 +96,8 @@
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "Guns4d.play_sound"></a>
|
||||
<strong>Guns4d.play_sound (sound_specs)</strong>
|
||||
<a name = "Guns4d.play_sounds"></a>
|
||||
<strong>Guns4d.play_sounds (sound_specs)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
allows you to play one or more sounds with more complex features, so sounds can be easily coded for guns without the need for functions.
|
||||
@ -109,12 +123,32 @@
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
out a list of Minetest sound handles [insert link] (in the order they came)
|
||||
out a Guns4d sound handle (an integer)
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "Guns4d.stop_sounds"></a>
|
||||
<strong>Guns4d.stop_sounds (handle_list)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
stops a list of sounds
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">handle_list</span>
|
||||
a list of minetest sound handles to stop, this is the returned output of @{guns4d.play_sounds
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
@ -136,11 +170,14 @@
|
||||
this is useful if you wish to play a sound which has a "far" sound, such as distant gunshots. incompatible <code>with to_player</code>
|
||||
</li>
|
||||
<li><span class="parameter">sounds</span>
|
||||
a <a href="../scripts/misc_helpers.html#weighted_randoms"> weighted_randoms table</a> the output will overwrite the <code>sound</code> field.
|
||||
a <a href="../scripts/misc_helpers.html#weighted_randoms"> weighted_randoms table</a> for randomly selecting sounds. The output will overwrite the <code>sound</code> field.
|
||||
</li>
|
||||
<li><span class="parameter">to_player</span>
|
||||
4dguns changes <code>to_player</code> so it only plays positionless audio (as it is only intended for first person audio)
|
||||
</li>
|
||||
<li><span class="parameter">delay</span>
|
||||
delay the playing of the sound
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@ -155,7 +192,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||
<i style="float:right;">Last updated 2024-01-19 14:08:01 </i>
|
||||
<i style="float:right;">Last updated 2024-03-28 12:47:10 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -37,11 +37,21 @@
|
||||
<ul class="">
|
||||
<li><strong>readme</strong></li>
|
||||
</ul>
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/Gun.html">Gun</a></li>
|
||||
<li><a href="../modules/default_controls.html">default_controls</a></li>
|
||||
</ul>
|
||||
<h2>Scripts</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../scripts/item_entities.lua.html">item_entities.lua</a></li>
|
||||
<li><a href="../scripts/misc_helpers.html">misc_helpers</a></li>
|
||||
<li><a href="../scripts/play_sound.html">play_sound</a></li>
|
||||
</ul>
|
||||
<h2>Classes</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../classes/Instantiatable_class.html">Instantiatable_class</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
@ -56,7 +66,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||
<i style="float:right;">Last updated 2024-01-19 14:08:01 </i>
|
||||
<i style="float:right;">Last updated 2024-03-28 12:47:10 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
269
classes/Gun.lua
269
classes/Gun.lua
@ -1,3 +1,7 @@
|
||||
--- Gun class
|
||||
-- this is the system used to represent guns and their attributes directly.
|
||||
-- @module Gun
|
||||
|
||||
local Vec = vector
|
||||
local gun_default = {
|
||||
--itemstack = Itemstack
|
||||
@ -6,11 +10,18 @@ local gun_default = {
|
||||
itemstring = "",
|
||||
registered = {},
|
||||
property_modifiers = {},
|
||||
|
||||
--- properties
|
||||
properties = {
|
||||
magnification = 1,
|
||||
hip = { --used by gun entity (attached offset)
|
||||
infinite_inventory_overlay = "inventory_overlay_inf_ammo.png", -- defines the filename to to be used as the overlay on the item when the player has infinite ammo.
|
||||
breathing_scale = .5, -- the max angluler offset caused by breathing.
|
||||
flash_offset = Vec.new(), -- used by fire() (for fsx and ray start pos) [RENAME NEEDED]
|
||||
firerateRPM = 600, -- used by update() and by extent fire() + default controls. The firerate of the gun. Rounds per minute
|
||||
burst = 3, -- how many rounds in burst using when firemode is at "burst"
|
||||
ammo_handler = Ammo_handler,
|
||||
hip = {
|
||||
offset = Vec.new(),
|
||||
sway_vel_mul = 5, --these are multipliers for various attributes. Does support fractional vals (which can be useful if you want to make hipfire more random with spread.)
|
||||
sway_vel_mul = 5,
|
||||
sway_angle_mul = 1,
|
||||
},
|
||||
ads = { --used by player_handler, animation handler (eye bone offset from horizontal_offset), gun entity (attached offset)
|
||||
@ -29,7 +40,7 @@ local gun_default = {
|
||||
burst = "inventory_overlay_burst.png",
|
||||
safe = "inventory_overlay_safe.png"
|
||||
},
|
||||
bloom = {
|
||||
--[[bloom = { not yet implemented.
|
||||
base_aiming = 0, --amount of bloom at a full rest while aiming down sights (if possible)
|
||||
base_hip = 0, --amount of bloom at rest while not aiming down sights.
|
||||
recoil = {
|
||||
@ -42,8 +53,7 @@ local gun_default = {
|
||||
amount = 0,
|
||||
ratio = 0,
|
||||
}
|
||||
},
|
||||
infinite_inventory_overlay = "inventory_overlay_inf_ammo.png",
|
||||
},]]
|
||||
recoil = { --used by update_recoil()
|
||||
velocity_correction_factor = { --velocity correction factor is currently very broken.
|
||||
gun_axial = 1,
|
||||
@ -96,7 +106,6 @@ local gun_default = {
|
||||
gun_axial = {x=1, y=-1},
|
||||
player_axial = {x=1,y=1},
|
||||
},
|
||||
breathing_scale = .5, --the max angluler offset caused by breathing.
|
||||
control_actions = { --used by control_handler
|
||||
__overfill=true, --this table will not be filled in.
|
||||
aim = Guns4d.default_controls.aim,
|
||||
@ -104,11 +113,15 @@ local gun_default = {
|
||||
reload = Guns4d.default_controls.reload,
|
||||
on_use = Guns4d.default_controls.on_use,
|
||||
firemode = Guns4d.default_controls.firemode
|
||||
},
|
||||
mobile_control_actions = {
|
||||
|
||||
},
|
||||
charging = { --how the gun "cocks"
|
||||
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_draw_time = 1,
|
||||
--sound = soundspec
|
||||
},
|
||||
reload = { --used by defualt controls. Still provides usefulness elsewhere.
|
||||
__overfill=true,
|
||||
@ -188,10 +201,6 @@ local gun_default = {
|
||||
--inventory_image
|
||||
--inventory_image_empty
|
||||
--used by ammo_handler
|
||||
flash_offset = Vec.new(), --used by fire() (for fsx and ray start pos) [RENAME NEEDED]
|
||||
firerateRPM = 600, --used by update() and by extent fire() + default controls
|
||||
burst = 3, --default burst length
|
||||
ammo_handler = Ammo_handler
|
||||
},
|
||||
offsets = {
|
||||
recoil = {
|
||||
@ -829,240 +838,16 @@ function gun_default:prepare_deletion()
|
||||
if self.sprite_scope then self.sprite_scope:prepare_deletion() end
|
||||
if self.crosshair then self.crosshair:prepare_deletion() end
|
||||
end
|
||||
local valid_ctrls = { --for validation of controls.
|
||||
up=true,
|
||||
down=true,
|
||||
left=true,
|
||||
right=true,
|
||||
jump=true,
|
||||
aux1=true,
|
||||
sneak=true,
|
||||
dig=true,
|
||||
place=true,
|
||||
LMB=true,
|
||||
RMB=true,
|
||||
zoom=true,
|
||||
}
|
||||
|
||||
Guns4d.gun = gun_default
|
||||
dofile(minetest.get_modpath("guns4d").."/classes/gun_construct.lua")
|
||||
|
||||
gun_default.construct = function(def)
|
||||
if def.instance then
|
||||
--make some quick checks.
|
||||
assert(def.handler, "no player handler object provided")
|
||||
|
||||
--initialize some variables
|
||||
def.player = def.handler.player
|
||||
local meta = def.itemstack:get_meta()
|
||||
def.meta = meta
|
||||
--create ID so we can track switches between weapons, also get some other data.
|
||||
if meta:get_string("guns4d_id") == "" then
|
||||
local id = tostring(Guns4d.unique_id.generate())
|
||||
meta:set_string("guns4d_id", id)
|
||||
def.player:set_wielded_item(def.itemstack)
|
||||
def.id = id
|
||||
def.current_firemode = 1
|
||||
meta:set_int("guns4d_firemode", 1)
|
||||
else
|
||||
def.id = meta:get_string("guns4d_id")
|
||||
def.current_firemode = meta:get_int("guns4d_firemode")
|
||||
end
|
||||
def.ammo_handler = def.properties.ammo_handler:new({ --initialize ammo handler from gun and gun metadata.
|
||||
gun = def
|
||||
})
|
||||
local ammo = def.ammo_handler.ammo
|
||||
if def.properties.require_draw_on_swap then
|
||||
ammo.next_bullet = "empty"
|
||||
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
|
||||
def.properties = Guns4d.table.fill(def.base_class.properties, def.properties)
|
||||
def.particle_spawners = {} --Instantiatable_class only shallow copies. So tables will not change, and thus some need to be initialized.
|
||||
def.property_modifiers = {}
|
||||
def.total_offset_rotation = {
|
||||
gun_axial = Vec.new(),
|
||||
player_axial = 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 = {}
|
||||
for offset, tbl in pairs(def.base_class.offsets) do
|
||||
def.offsets[offset] = {}
|
||||
for i, v in pairs(tbl) do
|
||||
if type(v) == "table" and v.x then
|
||||
def.offsets[offset][i] = vector.new()
|
||||
else
|
||||
def.offsets[offset][i] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
def.animation_rotation = vector.new()
|
||||
--def.velocities = Guns4d.table.deep_copy(def.base_class.velocities)
|
||||
def.velocities = {}
|
||||
for i, tbl in pairs(def.base_class.velocities) do
|
||||
def.velocities[i] = {}
|
||||
def.velocities[i].gun_axial = Vec.new()
|
||||
def.velocities[i].player_axial = Vec.new()
|
||||
end
|
||||
--properties have been assigned, create necessary objects TODO: completely change this system for defining them.
|
||||
if def.properties.sprite_scope then
|
||||
def.sprite_scope = def.properties.sprite_scope:new({
|
||||
gun = def
|
||||
})
|
||||
end
|
||||
if def.properties.crosshair then
|
||||
def.crosshair = def.properties.crosshair:new({
|
||||
gun = def
|
||||
})
|
||||
end
|
||||
if def.custom_construct then def:custom_construct() end
|
||||
gun_default.construct_instance(def)
|
||||
elseif def.name ~= "__guns4d:default__" then
|
||||
local props = def.properties
|
||||
|
||||
--validate controls, done before properties are filled to avoid duplication.
|
||||
if props.control_actions then
|
||||
for i, control in pairs(props.control_actions) do
|
||||
if not (i=="on_use") and not (i=="on_secondary_use") then
|
||||
assert(control.conditions, "no conditions provided for control")
|
||||
for _, condition in pairs(control.conditions) do
|
||||
if not valid_ctrls[condition] then
|
||||
assert(false, "invalid key: '"..condition.."'")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--fill in the properties.
|
||||
def.properties = Guns4d.table.fill(def.parent_class.properties, props or {})
|
||||
def.consts = Guns4d.table.fill(def.parent_class.consts, def.consts or {})
|
||||
props = def.properties --have to reinitialize this as the reference is replaced.
|
||||
|
||||
--print(table.tostring(props))
|
||||
def.b3d_model = mtul.b3d_reader.read_model(props.visuals.mesh, true)
|
||||
def.b3d_model.global_frames = {
|
||||
arm_right = {}, --the aim position of the right arm
|
||||
arm_left = {}, --the aim position of the left arm
|
||||
rotation = {} --rotation of the gun (this is assumed as gun_axial, but that's probably fucked for holo sight alignments)
|
||||
}
|
||||
--print(table.tostring(def.b3d_model))
|
||||
--precalculate keyframe "samples" for intepolation.
|
||||
local left = mtul.b3d_nodes.get_node_by_name(def.b3d_model, props.visuals.arm_left, true)
|
||||
local right = mtul.b3d_nodes.get_node_by_name(def.b3d_model, props.visuals.arm_right, true)
|
||||
local main = mtul.b3d_nodes.get_node_by_name(def.b3d_model, props.visuals.root, true)
|
||||
--we add 2 because we have to add 1 for the loop to make it there if it's a float val, and MTUL uses a system where frame 0 is 1
|
||||
for target_frame = 0, def.b3d_model.node.animation.frames+1, def.consts.KEYFRAME_SAMPLE_PRECISION do
|
||||
--we need to check that the bone exists first.
|
||||
if left then
|
||||
table.insert(def.b3d_model.global_frames.arm_left, vector.new(mtul.b3d_nodes.get_node_global_position(def.b3d_model, left, nil, target_frame))/10)
|
||||
else
|
||||
def.b3d_model.global_frames.arm_left = nil
|
||||
end
|
||||
|
||||
if right then
|
||||
table.insert(def.b3d_model.global_frames.arm_right, vector.new(mtul.b3d_nodes.get_node_global_position(def.b3d_model, right, nil, target_frame))/10)
|
||||
else
|
||||
def.b3d_model.global_frames.arm_right = nil
|
||||
end
|
||||
|
||||
if main then
|
||||
--use -1 as it does not exist and thus will always go to the default resting pose
|
||||
--we compose it by the inverse because we need to get the global CHANGE in rotation for the animation rotation offset. I really need to comment more often
|
||||
local newvec = (mtul.b3d_nodes.get_node_rotation(def.b3d_model, main, nil, -1):inverse())*mtul.b3d_nodes.get_node_rotation(def.b3d_model, main, nil, target_frame)
|
||||
--used to use euler
|
||||
table.insert(def.b3d_model.global_frames.rotation, newvec)
|
||||
end
|
||||
end
|
||||
--[[if main then
|
||||
local quat = mtul.math.quat.new(main.keys[1].rotation)
|
||||
print(dump(main.keys[1]), vector.new(quat:to_euler_angles_unpack(quat)))
|
||||
end
|
||||
for i, v in pairs(def.b3d_model.global_frames.rotation) do
|
||||
print(i, dump(vector.new(v:to_euler_angles_unpack())*180/math.pi))
|
||||
end]]
|
||||
--print()
|
||||
-- if it's not a template, then create an item, override some props
|
||||
if def.name ~= "__template" then
|
||||
assert(def.itemstring, "no itemstring provided. Cannot create a gun without an associated itemstring.")
|
||||
local item_def = minetest.registered_items[def.itemstring]
|
||||
assert(rawget(def, "name"), "no name provided in new class")
|
||||
assert(rawget(def, "itemstring"), "no itemstring provided in new class")
|
||||
assert(not((props.ammo.capacity) and (not props.ammo.magazine_only)), "gun does not accept magazines, but has no set capcity! Please define ammo.capacity")
|
||||
assert(item_def, def.itemstring.." : item is not registered.")
|
||||
|
||||
--override methods so control handler can do it's job
|
||||
local old_on_use = item_def.on_use
|
||||
local old_on_s_use = item_def.on_secondary_use
|
||||
def.properties.inventory_image = item_def.inventory_image
|
||||
--override the item to hook in controls. (on_drop needed)
|
||||
minetest.override_item(def.itemstring, {
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if old_on_use then
|
||||
old_on_use(itemstack, user, pointed_thing)
|
||||
end
|
||||
Guns4d.players[user:get_player_name()].control_handler:on_use(itemstack, pointed_thing)
|
||||
end,
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
if old_on_s_use then
|
||||
old_on_s_use(itemstack, user, pointed_thing)
|
||||
end
|
||||
Guns4d.players[user:get_player_name()].control_handler:on_secondary_use(itemstack, pointed_thing)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
--TODO this may need to be renamed and put in constructor for instances (modifications could later change ammo types.)
|
||||
def.accepted_bullets = {}
|
||||
for _, v in pairs(def.properties.ammo.accepted_bullets) do
|
||||
def.accepted_bullets[v] = true
|
||||
end
|
||||
def.accepted_magazines = {}
|
||||
for _, v in pairs(def.properties.ammo.accepted_magazines) do
|
||||
def.accepted_magazines[v] = true
|
||||
end
|
||||
--add gun def to the registered table
|
||||
Guns4d.gun.registered[def.name] = def
|
||||
|
||||
--register the visual entity
|
||||
minetest.register_entity(def.name.."_visual", {
|
||||
initial_properties = {
|
||||
visual = "mesh",
|
||||
mesh = props.visuals.mesh,
|
||||
textures = props.textures,
|
||||
glow = 0,
|
||||
pointable = false,
|
||||
static_save = false,
|
||||
backface_culling = props.visuals.backface_culling
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
local obj = self.object
|
||||
if not self.parent_player then obj:remove() return end
|
||||
local player = self.parent_player
|
||||
local handler = Guns4d.players[player:get_player_name()]
|
||||
local lua_object = handler.gun
|
||||
if not lua_object then obj:remove() return end
|
||||
--this is changing the point of rotation if not aiming, this is to make it look less shit.
|
||||
local axial_modifier = Vec.new()
|
||||
if not handler.control_handler.ads then
|
||||
local pitch = lua_object.total_offset_rotation.player_axial.x+lua_object.player_rotation.x
|
||||
axial_modifier = Vec.new(pitch*(1-lua_object.consts.HIP_PLAYER_GUN_ROT_RATIO),0,0)
|
||||
end
|
||||
local axial_rot = lua_object.total_offset_rotation.gun_axial+axial_modifier
|
||||
--attach to the correct bone, and rotate
|
||||
local visibility = true
|
||||
if lua_object.sprite_scope and lua_object.sprite_scope.hide_gun and (not (handler.ads_location == 0)) then
|
||||
visibility = false
|
||||
end
|
||||
if handler.control_handler.ads then
|
||||
local normal_pos = (props.ads.offset)*10
|
||||
obj:set_attach(player, lua_object.consts.AIMING_BONE, normal_pos, -axial_rot, visibility)
|
||||
else
|
||||
local normal_pos = Vec.new(props.hip.offset)*10
|
||||
-- Vec.multiply({x=normal_pos.x, y=normal_pos.z, z=-normal_pos.y}, 10)
|
||||
obj:set_attach(player, lua_object.consts.HIPFIRE_BONE, normal_pos, -axial_rot, visibility)
|
||||
end
|
||||
end,
|
||||
})
|
||||
--print(dump(def))
|
||||
gun_default.construct_base_class(def)
|
||||
end
|
||||
end
|
||||
Guns4d.gun = Instantiatable_class:inherit(gun_default)
|
@ -1,7 +1,20 @@
|
||||
--- Instantiatable_class. The system for defining classes in 4dguns. Please note the capital "I", Ldoc converts it to a lowercase in all of this file
|
||||
-- @classmod Instantiatable_class
|
||||
|
||||
Instantiatable_class = {
|
||||
instance = false,
|
||||
__no_copy = true
|
||||
}
|
||||
--- Instantiatable_class
|
||||
-- @table god_work please
|
||||
-- @field instance defines wether the object is an instance
|
||||
-- @field base_class only present for instances: the class from which this instance originates
|
||||
-- @field parent_class the class from which this class was inherited from
|
||||
|
||||
--- creates a new base class. Calls all constructors in the chain with def.instance=true
|
||||
-- @param def the table containing a new definition (where the class calling the method is the parent). The content of the definition will override the fields for it's children.
|
||||
-- @return def a new base class
|
||||
-- @function Instantiatable_class:inherit()
|
||||
function Instantiatable_class:inherit(def)
|
||||
--construction chain for inheritance
|
||||
--if not def then def = {} else def = table.shallow_copy(def) end
|
||||
@ -24,12 +37,20 @@ function Instantiatable_class:inherit(def)
|
||||
setmetatable(def, {__index = self})
|
||||
return def
|
||||
end
|
||||
--- construct
|
||||
-- every parent constructor is called in order of inheritance, this is used to make changes to the child table. In self you will find base_class defining what class it is from, and the bool instance indicating (shocking) wether it is an instance.
|
||||
-- @function construct where self is the definition (after all higher parent calls) of the table. This is the working object, no returns necessary to change it's fields/methods.
|
||||
|
||||
|
||||
--- creates an instance of the base class. Calls all constructors in the chain with def.instance=true
|
||||
-- @return def a new instance of the class.
|
||||
-- @function Instantiatable_class:new(def)
|
||||
function Instantiatable_class:new(def)
|
||||
--if not def then def = {} else def = table.shallow_copy(def) end
|
||||
def.base_class = self
|
||||
def.instance = true
|
||||
def.__no_copy = true
|
||||
function def:inherit(def)
|
||||
function def:inherit()
|
||||
assert(false, "cannot inherit instantiated object")
|
||||
end
|
||||
setmetatable(def, {__index = self})
|
||||
|
@ -74,6 +74,7 @@ function player_handler:update(dt)
|
||||
--delete model handler object (this resets the player model)
|
||||
self.player_model_handler:prepare_deletion()
|
||||
self.player_model_handler = nil
|
||||
--patch for spriteguns.
|
||||
if (not spriteguns) or (spriteguns and (not spriteguns.registered_guns[player:get_wielded_item():get_name()])) then
|
||||
player:hud_set_flags({wielditem = true, crosshair = true}) --reenable hud elements
|
||||
end
|
||||
|
299
classes/gun_construct.lua
Normal file
299
classes/gun_construct.lua
Normal file
@ -0,0 +1,299 @@
|
||||
|
||||
|
||||
local gun_default = Guns4d.gun
|
||||
|
||||
--[[
|
||||
*
|
||||
*
|
||||
*
|
||||
==================================INSTANCE CONSTRUCTOR====================================
|
||||
*
|
||||
*
|
||||
*
|
||||
]]
|
||||
|
||||
local function initialize_data(self)
|
||||
--create ID so we can track switches between weapons, also get some other data.
|
||||
local meta = self.itemstack:get_meta()
|
||||
self.meta = meta
|
||||
if meta:get_string("guns4d_id") == "" then
|
||||
local id = tostring(Guns4d.unique_id.generate())
|
||||
meta:set_string("guns4d_id", id)
|
||||
self.player:set_wielded_item(self.itemstack)
|
||||
self.id = id
|
||||
self.current_firemode = 1
|
||||
meta:set_int("guns4d_firemode", 1)
|
||||
else
|
||||
self.id = meta:get_string("guns4d_id")
|
||||
self.current_firemode = meta:get_int("guns4d_firemode")
|
||||
end
|
||||
end
|
||||
local function initialize_ammo(self)
|
||||
self.ammo_handler = self.properties.ammo_handler:new({ --initialize ammo handler from gun and gun metadata.
|
||||
gun = self
|
||||
})
|
||||
local ammo = self.ammo_handler.ammo
|
||||
if self.properties.require_draw_on_swap then
|
||||
ammo.next_bullet = "empty"
|
||||
end
|
||||
minetest.after(0, function() if ammo.total_bullets > 0 then self:draw() end end)
|
||||
self:update_image_and_text_meta() --has to be called manually in post as ammo_handler would not exist yet.
|
||||
self.player:set_wielded_item(self.itemstack)
|
||||
end
|
||||
|
||||
local function initialize_physics(self)
|
||||
--initialize rotation offsets
|
||||
self.total_offset_rotation = {
|
||||
gun_axial = vector.new(),
|
||||
player_axial = vector.new(),
|
||||
}
|
||||
self.offsets = {}
|
||||
for offset, tbl in pairs(self.base_class.offsets) do
|
||||
self.offsets[offset] = {}
|
||||
for i, v in pairs(tbl) do
|
||||
if type(v) == "table" and v.x then
|
||||
self.offsets[offset][i] = vector.new()
|
||||
else
|
||||
self.offsets[offset][i] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
--self.velocities = Guns4d.table.deep_copy(self.base_class.velocities)
|
||||
self.velocities = {}
|
||||
for i, tbl in pairs(self.base_class.velocities) do
|
||||
self.velocities[i] = {}
|
||||
self.velocities[i].gun_axial = vector.new()
|
||||
self.velocities[i].player_axial = vector.new()
|
||||
end
|
||||
end
|
||||
|
||||
local function initialize_animation(self)
|
||||
self.animation_data = { --where animations data is stored.
|
||||
anim_runtime = 0,
|
||||
length = 0,
|
||||
fps = 0,
|
||||
frames = {0,0},
|
||||
current_frame = 0,
|
||||
}
|
||||
self.player_rotation = vector.new(self.properties.initial_vertical_rotation,0,0)
|
||||
self.animation_rotation = vector.new()
|
||||
end
|
||||
|
||||
|
||||
--========================== MAIN INSTANCE CONSTRUCTOR ===============================
|
||||
|
||||
|
||||
function gun_default:construct_instance()
|
||||
assert(self.handler, "no player handler object provided")
|
||||
|
||||
--initialize important data.
|
||||
self.player = self.handler.player
|
||||
initialize_data(self)
|
||||
initialize_ammo(self)
|
||||
|
||||
--unavoidable table instancing
|
||||
self.properties = Guns4d.table.fill(self.base_class.properties, self.properties)
|
||||
self.particle_spawners = {} --Instantiatable_class only shallow copies. So tables will not change, and thus some need to be initialized.
|
||||
self.property_modifiers = {}
|
||||
|
||||
initialize_animation(self)
|
||||
initialize_physics(self)
|
||||
|
||||
--properties have been assigned, create necessary objects TODO: completely change this system for selfining them.
|
||||
if self.properties.sprite_scope then
|
||||
self.sprite_scope = self.properties.sprite_scope:new({
|
||||
gun = self
|
||||
})
|
||||
end
|
||||
if self.properties.crosshair then
|
||||
self.crosshair = self.properties.crosshair:new({
|
||||
gun = self
|
||||
})
|
||||
end
|
||||
if self.custom_construct then self:custom_construct() end
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
*
|
||||
*
|
||||
*
|
||||
==================================BASE CLASS CONSTRUCTOR======================================
|
||||
*
|
||||
*
|
||||
*
|
||||
]]
|
||||
local valid_ctrls = { --for validation of controls.
|
||||
up=true,
|
||||
down=true,
|
||||
left=true,
|
||||
right=true,
|
||||
jump=true,
|
||||
aux1=true,
|
||||
sneak=true,
|
||||
dig=true,
|
||||
place=true,
|
||||
LMB=true,
|
||||
RMB=true,
|
||||
zoom=true,
|
||||
}
|
||||
|
||||
local function validate_controls(props)
|
||||
--validate controls, done before properties are filled to avoid duplication.
|
||||
if props.control_actions then
|
||||
for i, control in pairs(props.control_actions) do
|
||||
if (i~="on_use") and (i~="on_secondary_use") and (i~="__overfill") then
|
||||
assert(control.conditions, "no conditions provided for control")
|
||||
for _, condition in pairs(control.conditions) do
|
||||
if not valid_ctrls[condition] then
|
||||
assert(false, "invalid key: '"..condition.."'")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local function initialize_b3d_animation_data(self, props)
|
||||
self.b3d_model = mtul.b3d_reader.read_model(props.visuals.mesh, true)
|
||||
self.b3d_model.global_frames = {
|
||||
arm_right = {}, --the aim position of the right arm
|
||||
arm_left = {}, --the aim position of the left arm
|
||||
rotation = {} --rotation of the gun (this is assumed as gun_axial, but that's probably fucked for holo sight alignments)
|
||||
}
|
||||
--print(table.tostring(self.b3d_model))
|
||||
--precalculate keyframe "samples" for intepolation.
|
||||
local left = mtul.b3d_nodes.get_node_by_name(self.b3d_model, props.visuals.arm_left, true)
|
||||
local right = mtul.b3d_nodes.get_node_by_name(self.b3d_model, props.visuals.arm_right, true)
|
||||
local main = mtul.b3d_nodes.get_node_by_name(self.b3d_model, props.visuals.root, true)
|
||||
--we add 2 because we have to add 1 for the loop to make it there if it's a float val, and MTUL uses a system where frame 0 is 1
|
||||
for target_frame = 0, self.b3d_model.node.animation.frames+1, self.consts.KEYFRAME_SAMPLE_PRECISION do
|
||||
--we need to check that the bone exists first.
|
||||
if left then
|
||||
table.insert(self.b3d_model.global_frames.arm_left, vector.new(mtul.b3d_nodes.get_node_global_position(self.b3d_model, left, nil, target_frame))/10)
|
||||
else
|
||||
self.b3d_model.global_frames.arm_left = nil
|
||||
end
|
||||
|
||||
if right then
|
||||
table.insert(self.b3d_model.global_frames.arm_right, vector.new(mtul.b3d_nodes.get_node_global_position(self.b3d_model, right, nil, target_frame))/10)
|
||||
else
|
||||
self.b3d_model.global_frames.arm_right = nil
|
||||
end
|
||||
|
||||
if main then
|
||||
--use -1 as it does not exist and thus will always go to the default resting pose
|
||||
--we compose it by the inverse because we need to get the global CHANGE in rotation for the animation rotation offset. I really need to comment more often
|
||||
local newvec = (mtul.b3d_nodes.get_node_rotation(self.b3d_model, main, nil, -1):inverse())*mtul.b3d_nodes.get_node_rotation(self.b3d_model, main, nil, target_frame)
|
||||
--used to use euler
|
||||
table.insert(self.b3d_model.global_frames.rotation, newvec)
|
||||
end
|
||||
end
|
||||
|
||||
--[[if main then
|
||||
local quat = mtul.math.quat.new(main.keys[1].rotation)
|
||||
print(dump(main.keys[1]), vector.new(quat:to_euler_angles_unpack(quat)))
|
||||
end
|
||||
for i, v in pairs(self.b3d_model.global_frames.rotation) do
|
||||
print(i, dump(vector.new(v:to_euler_angles_unpack())*180/math.pi))
|
||||
end]]
|
||||
--print()
|
||||
end
|
||||
local function complete_item(self, props)
|
||||
assert(self.itemstring, "no itemstring provided. Cannot create a gun without an associated itemstring.")
|
||||
local item_def = minetest.registered_items[self.itemstring]
|
||||
assert(rawget(self, "name"), "no name provided in new class")
|
||||
assert(rawget(self, "itemstring"), "no itemstring provided in new class")
|
||||
assert(not((props.ammo.capacity) and (not props.ammo.magazine_only)), "gun does not accept magazines, but has no set capcity! Please define ammo.capacity")
|
||||
assert(item_def, self.itemstring.." : item is not registered.")
|
||||
|
||||
--override methods so control handler can do it's job
|
||||
local old_on_use = item_def.on_use
|
||||
local old_on_s_use = item_def.on_secondary_use
|
||||
self.properties.inventory_image = item_def.inventory_image
|
||||
--override the item to hook in controls. (on_drop needed)
|
||||
minetest.override_item(self.itemstring, {
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if old_on_use then
|
||||
old_on_use(itemstack, user, pointed_thing)
|
||||
end
|
||||
Guns4d.players[user:get_player_name()].control_handler:on_use(itemstack, pointed_thing)
|
||||
end,
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
if old_on_s_use then
|
||||
old_on_s_use(itemstack, user, pointed_thing)
|
||||
end
|
||||
Guns4d.players[user:get_player_name()].control_handler:on_secondary_use(itemstack, pointed_thing)
|
||||
end
|
||||
})
|
||||
end
|
||||
local function create_visual_entity(self,props)
|
||||
minetest.register_entity(self.name.."_visual", {
|
||||
initial_properties = {
|
||||
visual = "mesh",
|
||||
mesh = props.visuals.mesh,
|
||||
textures = props.textures,
|
||||
glow = 0,
|
||||
pointable = false,
|
||||
static_save = false,
|
||||
backface_culling = props.visuals.backface_culling
|
||||
},
|
||||
on_step = function(self, dtime)
|
||||
local obj = self.object
|
||||
if not self.parent_player then obj:remove() return end
|
||||
local player = self.parent_player
|
||||
local handler = Guns4d.players[player:get_player_name()]
|
||||
local lua_object = handler.gun
|
||||
if not lua_object then obj:remove() return end
|
||||
--this is changing the point of rotation if not aiming, this is to make it look less shit.
|
||||
local axial_modifier = vector.new()
|
||||
if not handler.control_handler.ads then
|
||||
local pitch = lua_object.total_offset_rotation.player_axial.x+lua_object.player_rotation.x
|
||||
axial_modifier = vector.new(pitch*(1-lua_object.consts.HIP_PLAYER_GUN_ROT_RATIO),0,0)
|
||||
end
|
||||
local axial_rot = lua_object.total_offset_rotation.gun_axial+axial_modifier
|
||||
--attach to the correct bone, and rotate
|
||||
local visibility = true
|
||||
if lua_object.sprite_scope and lua_object.sprite_scope.hide_gun and (not (handler.ads_location == 0)) then
|
||||
visibility = false
|
||||
end
|
||||
if handler.control_handler.ads then
|
||||
local normal_pos = (props.ads.offset)*10
|
||||
obj:set_attach(player, lua_object.consts.AIMING_BONE, normal_pos, -axial_rot, visibility)
|
||||
else
|
||||
local normal_pos = vector.new(props.hip.offset)*10
|
||||
-- vector.multiply({x=normal_pos.x, y=normal_pos.z, z=-normal_pos.y}, 10)
|
||||
obj:set_attach(player, lua_object.consts.HIPFIRE_BONE, normal_pos, -axial_rot, visibility)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
--========================== MAIN CLASS CONSTRUCTOR ===============================
|
||||
|
||||
function gun_default:construct_base_class()
|
||||
local props = self.properties
|
||||
|
||||
--copy the properties
|
||||
self.properties = Guns4d.table.fill(self.parent_class.properties, props or {})
|
||||
self.consts = Guns4d.table.fill(self.parent_class.consts, self.consts or {})
|
||||
props = self.properties
|
||||
validate_controls(props)
|
||||
|
||||
initialize_b3d_animation_data(self, props) --this is for animation offsets (like the spritescope uses)
|
||||
|
||||
-- if it's not a template, then create an item, override some props
|
||||
if self.name ~= "__template" then
|
||||
complete_item(self, props)
|
||||
end
|
||||
--create sets. This may need to be put in instances of modifications can change accepted ammos
|
||||
self.accepted_bullets = {}
|
||||
for _, v in pairs(self.properties.ammo.accepted_bullets) do
|
||||
self.accepted_bullets[v] = true
|
||||
end
|
||||
self.accepted_magazines = {}
|
||||
for _, v in pairs(self.properties.ammo.accepted_magazines) do
|
||||
self.accepted_magazines[v] = true
|
||||
end
|
||||
|
||||
Guns4d.gun.registered[self.name] = self --add gun self to the registered table
|
||||
create_visual_entity(self, props) --register the visual entity
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user