Remove shooter as a submodule and add mobkit submodule

master
LoneWolfHT 2019-12-27 11:59:19 -08:00
parent e210a01b67
commit 9b403be195
88 changed files with 3185 additions and 4 deletions

6
.gitmodules vendored
View File

@ -13,6 +13,6 @@
[submodule "mods/skybox"]
path = mods/skybox
url = https://github.com/minetest-mods/skybox.git
[submodule "mods/shooter"]
path = mods/shooter
url = https://github.com/LoneWolfHT/shooter.git
[submodule "mods/mobkit"]
path = mods/mobkit
url = https://github.com/TheTermos/mobkit.git

1
mods/mobkit Submodule

@ -0,0 +1 @@
Subproject commit a4e06bfac2802376251d5bc7aac90a83bcf38e6b

@ -1 +0,0 @@
Subproject commit b2f6acb5a6c191cc4893647697e040cda147bd2e

8
mods/shooter/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
## Generic ignorable patterns and files
*~
.*.swp
*bak*
tags
*.vim
shooter.conf
crosshair.png

47
mods/shooter/.luacheckrc Normal file
View File

@ -0,0 +1,47 @@
allow_defined_top = true
read_globals = {
"ItemStack",
"VoxelArea",
"VoxelManip",
"PseudoRandom",
table = {fields = {"copy"}},
}
globals = {
"vector",
"minetest",
}
files["shooter/init.lua"] = {
globals = {"shooter"}
}
files["shooter_crossbow/init.lua"] = {
globals = {"shooter", "SHOOTER_ARROW_TOOL_CAPS", "dye"}
}
files["shooter_flaregun/init.lua"] = {
globals = {"shooter"}
}
files["shooter_grenade/init.lua"] = {
globals = {"shooter"}
}
files["shooter_guns/init.lua"] = {
globals = {"shooter"}
}
files["shooter_hook/init.lua"] = {
globals = {"shooter"}
}
files["shooter_rocket/init.lua"] = {
globals = {"shooter"}
}
files["shooter_turret/init.lua"] = {
globals = {"shooter", "player_api"}
}

504
mods/shooter/LICENSE Normal file
View File

@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random
Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

33
mods/shooter/LICENSE.txt Normal file
View File

@ -0,0 +1,33 @@
Minetest Mod - Simple Shooter [shooter]
=======================================
License Source Code: 2013-2019 Stuart Jones - LGPL v2.1
Additional credit for code ideas taken from other mods.
PilzAdam [throwing] for the throwing physics
ShadowNinja [nuke] for the vm explosion routine
License Textures: Stuart Jones - CC0 1.0 Universal (CC0 1.0)
Licence Models: Stuart Jones - CC-BY-SA 3.0
License Sounds: freesound.org
flobert1_20070728.wav by Nonoo - Attribution 3.0 Unported (CC BY 3.0)
shot.wav by Sergenious - Attribution 3.0 Unported (CC BY 3.0)
GUNSHOT.WAV by erkanozan - CC0 1.0 Universal (CC0 1.0)
winchester-rifle-cock-reload.wav by MentalSanityOff - CC0 1.0 Universal (CC0 1.0)
trigger-with-hammer-fall.wav by Nanashi - CC0 1.0 Universal (CC0 1.0)
woosh.wav by ReadeOnly - CC0 1.0 Universal (CC0 1.0)
AGM-114 Hellfire Rocket Missile Launch.flac by qubodup - CC0 1.0 Universal (CC0 1.0)
Sparkler.aif by Ned Bouhalassa - CC0 1.0 Universal (CC0 1.0)
explosion10.wav by V-ktor - CC0 1.0 Universal (CC0 1.0)

79
mods/shooter/README.md Normal file
View File

@ -0,0 +1,79 @@
[modpack] Simple Shooter [shooter]
====================================
![screenshot](https://raw.githubusercontent.com/stujones11/shooter/master/screenshot.png)
**Mod Version:** 0.6.1
**Minetest Version:** 5.0.0 (engine & game)
A simple first person shooter mod originally developed as part of a game that
was never completed. Now distributed as a Minetest Game compatible mod-pack.
[mod] Shooter API [shooter]
---------------------------
**Depends:** default
<img align="left" width="32" height="32" src="https://raw.githubusercontent.com/stujones11/shooter/master/shooter/textures/shooter_powder.png">
Handles raycasting, blasting and audio-visual effects of dependent mods.
[mod] Shooter Guns [shooter_guns]
---------------------------------
**Depends:** shooter
<img align="left" width="32" height="32" src="https://raw.githubusercontent.com/stujones11/shooter/master/shooter_guns/textures/shooter_rifle.png">
Adds basic guns using the shooter API.
[mod] Crossbow [shooter_crossbow]
---------------------------------
**Depends:** shooter
**Optional Depends:** dye (required for colored arrows)
<img align="left" width="32" height="32" src="https://raw.githubusercontent.com/stujones11/shooter/master/shooter_crossbow/textures/shooter_crossbow.png">
Adds a crossbow with colored arrows.
[mod] Flare Gun [shooter_flaregun]
----------------------------------
**Depends:** shooter
<img align="left" width="32" height="32" src="https://raw.githubusercontent.com/stujones11/shooter/master/shooter_flaregun/textures/shooter_flaregun.png">
Adds a flare-gun with temporary light emitting flares.
[mod] Grenade [shooter_grenade]
-------------------------------
**Depends:** shooter
<img align="left" width="32" height="32" src="https://raw.githubusercontent.com/stujones11/shooter/master/shooter_grenade/textures/shooter_hand_grenade.png">
Adds simple hand grenades.
[mod] Rocket Launcher [shooter_rocket]
--------------------------------------
**Depends:** shooter
<img align="left" width="32" height="32" src="https://raw.githubusercontent.com/stujones11/shooter/master/shooter_rocket/textures/shooter_rocket_gun_loaded.png">
Adds rocket missiles and launching gun.
[mod] Grapple Hook [shooter_hook]
---------------------------------
**Depends:** shooter
<img align="left" width="32" height="32" src="https://raw.githubusercontent.com/stujones11/shooter/master/shooter_hook/textures/shooter_hook_gun_loaded.png">
Adds a teleporting grapple hook which can be thrown or launched
further from a grapple hook gun.
[mod] Turret Gun [shooter_turret]
---------------------------------
**Depends:** shooter_rocket
<img align="left" width="32" height="32" src="https://raw.githubusercontent.com/stujones11/shooter/master/shooter_turret/textures/shooter_turret_gun.png">
Adds a mountable turret gun which can also be triggered by mesecon signals.
Still WIP and experimental and may be subject to change or removal.

View File

@ -0,0 +1,2 @@
name = shooter
description = First person shooter mod, adds firearms plus a few other fun items.

BIN
mods/shooter/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

View File

@ -0,0 +1,21 @@
[shooter]
shooter_automatic_weapons (Enable automatic weapons) bool true
shooter_admin_weapons (Enable admin super weapons) bool false
shooter_enable_blasting (Enable node destruction with explosives) bool false
shooter_enable_particle_fx (Enable hit particle effects) bool true
shooter_enable_protection (Respect protection mods) bool false
shooter_enable_crafting (Allow crafting of weapons) bool true
shooter_explosion_texture (Hit particle texture for 'fleshy' object, inc. players) string shooter_hit.png
shooter_allow_nodes (Allow node destruction) bool true
shooter_allow_entities (Allow damage to active objects in multiplayer mode) bool false
shooter_allow_players (Allow damage to players in multiplayer mode) bool true
shooter_rounds_update_time (Round update time, should be >= dedicated server step) float 0.4
shooter_damage_multiplier (Entity damage coefficient) float 1.0
[shooter_crossbow]
shooter_crossbow_uses (Number of crossbow uses) int 50
shooter_arrow_lifetime (Arrow exipiry time in seconds) int 180
shooter_arrow_fleshy (Arrow 'fleshy' damage level) float 2
shooter_arrow_object_attach (Experimental, attach arrows to objects when hit) bool false

View File

@ -0,0 +1,221 @@
Minetest Mod - Shooter API [shooter]
====================================
Depends: default
Handles raycasting, blasting and audio-visual effects of dependent mods
Crafting
--------
### Gunpowder
1 x Coal Lump + 1 x Clay Lump = 5 x Gunpowder
```
output = "shooter:gunpowder 5",
type = "shapeless",
recipe = {"default:coal_lump", "default:clay_lump"},
```
Configuration
-------------
Override the following default settings by adding them to your minetest.conf file
### Enable automatic weapons
Uses globalstep to detect left mouse button
`shooter_automatic_weapons = true`
### Enable admin super weapons
Allows admins (server priv) to shoot all guns automatically
Requires `shooter_automatic_weapons` to be `true`
`shooter_admin_weapons = false`
### Enable node destruction with explosives
`shooter_enable_blasting = true`
### Enable Crafting
`shooter_enable_crafting = true`
### Enable hit particle effects
`shooter_enable_particle_fx = true`
### Enable protection
Requires a protection mod that utilizes `minetest.is_protected()`
`shooter_enable_protection = false`
### Particle texture
Particle texture used when a player or entity with the 'fleshy' armor group is hit
`shooter_explosion = "shooter_hit.png"`
### Allow node destruction
`shooter_allow_nodes = true`
### Node Drops
Drops the node item when hit, requires `shooter_allow_nodes` to be `true`
Currently excludes 'blasting'
`shooter_node_drops = false`
### Allow entity damage
Defaults to `true` in singleplayer mode
`shooter_allow_entities = false`
### Allow player damage
Defaults to `false` in singleplayer mode
`shooter_allow_players = true`
### Round update time
Maximum round 'step' processing interval, will inversely effect the long-range velocity of the virtual projectiles. This should always be greater than the dedicated server step time
`shooter_rounds_update_time = 0.4`
### Entity damage coefficient
May be used to globaly increase or decrease damage done to entities/mobs
`shooter_damage_multiplier = 1`
API Documentation
-----------------
### Global tables
* `shooter.registered_weapons`: Registered weapons by itemstring
* `shooter.config`: Present configuration
* `shooter.default_particles`: Default hit particle definition
```Lua
{
amount = 15,
time = 0.3,
minpos = {x=-0.1, y=-0.1, z=-0.1},
maxpos = {x=0.1, y=0.1, z=0.1},
minvel = {x=-1, y=1, z=-1},
maxvel = {x=1, y=2, z=1},
minacc = {x=-2, y=-2, z=-2},
maxacc = {x=2, y=-2, z=2},
minexptime = 0.1,
maxexptime = 0.75,
minsize = 1,
maxsize = 2,
collisiondetection = false,
texture = "shooter_hit.png",
}
```
### Methods
* `shooter.register_weapon(name, definition)`: Register a shooting weapon. -- See "Weapon Definition"
* `shooter.get_weapon_spec(player, weaponname)`: Gets the spec for a particular weapon
* Override this function to add support for per-player specs, for example
* `shooter.get_configuration(config)`: Loads matching config settings into a table ref `config`
* `shooter.spawn_particles(pos, particles)`: Adds particles at the specified position
* `particles` is an optional table of overrides for `shooter.default_particles`
* `shooter.play_node_sound(node, pos)`: Plays the registered 'dug' sound for the node at `pos`
* `shooter.is_valid_object(object)`: Returns `true` if the object can be damaged
* `shooter.punch_node(pos, spec)`: Punches the node at `pos` with the `spec` group capabilities
* Returns `true` if the node was destroyed
* `shooter.punch_object(object, tool_caps, dir, on_blast)`: Punches the object
* Returns `true` if the object is damaged
* `object`: Object to be punched, not checked for validity!
* `tool_caps`: Tool capabilities of the weapon uesd -- See "Weapon Definition"
* `dir`: Unit vector pointing from the source of the punch to the object, may be `nil`
* `on_blast`: Respect entity `on_blast` damage callback
* `shooter.fire_weapon(player, itemstack, spec)`: Adds a 'round' with `spec` to the processing que
* `shooter.blast(pos, radius, fleshy, distance, user)`: Create explosion at `pos`
* `radius`: Blast radius in nodes
* `fleshy`: Damage to inflict on fleshy objects: `(fleshy * 0.5 ^ distance) * 2`
* `distance`: Area of effect for objects
* `user`: A player reference, used for protection
* `shooter.get_shooting(name)`: Returns `true` if player `name` is holding the left mouse button or `nil`
* Requires `shooter_automatic_weapons` to be set `true`
* `shooter.set_shooting(name, is_shooting)`: Sets the left mouse button status of player `name`
Weapon Definition
-----------------
Used by `shooter.register_weapon`
```Lua
{
description = "My Awesome Gun",
inventory_image = "my_awesome_gun.png",
reload_item = "itemstring",
-- Reload Item, "shooter:ammo" is used if omitted
unloaded_item = {
-- Optional. Item to be registered as unloaded weapon item
name = "itemstring",
description = "My Awesome Gun (Unloaded)",
inventory_image = "my_awesome_gun_unloaded.png",
},
on_use = function(itemstack, user, pointed_thing)
-- Called before the built-in tool `one_use` handler
-- Should return a valid `ItemStack` or `nil` to cancel the shot
return itemstack
end,
on_hit = function(pointed_thing, spec, dir)
-- May be used for arbitary shot effects like knock-back, etc.
-- Return `true` to override built-in damage effects
-- `pointed_thing`: Returned by `minetest.raycast()`
-- `spec`: Gunspec of the weapon used including some additional fields
-- `name`: Name of the weapon item, eg. `shooter_guns:rifle`
-- `user`: Name of the player that fired the weapon
-- `origin`: Initial starting position of the shot
-- `dir`: Unit vector direction of the virtual shot
end,
spec = {
-- Weapon specifications
rounds = 100,
-- Number of rounds, refilled by the defined reload item
range = 200,
-- Range (in nodes) of each shot
step = 30,
-- Distance per `shooter_rounds_update_time`
shots = 1,
-- Number of shots fired per `round`
spread = 10,
-- Spread of shots in degrees if `shots` > 1
-- Uses a sunflower seed arrangement for even distributuion
tool_caps = {
-- Tool capabilities, used for object/player damage
full_punch_interval = 1.0,
damage_groups = {fleshy=3},
},
groups = {
-- Damage groups, used to effect nodes as a normal tool item would
snappy = 3,
crumbly = 3,
choppy = 3,
fleshy = 2,
oddly_breakable_by_hand = 2,
},
sounds = {
-- Sound files (defaults)
shot = "guns_rifle",
reload = "shooter_reload",
fail_shot = "shooter_click",
},
bullet_texture = "shooter_bullet.png",
-- Particle texture file name for the projectile
particles = {},
-- Optional. Table of overrides for `shooter.default_particles`
},
}
```

View File

@ -0,0 +1,540 @@
--[[
Shooter API [shooter]
Copyright (C) 2013-2019 stujones11, Stuart Jones
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]--
shooter = {
registered_weapons = {},
}
shooter.config = {
automatic_weapons = true,
admin_weapons = false,
enable_blasting = false,
enable_particle_fx = true,
enable_protection = false,
enable_crafting = true,
explosion_texture = "shooter_hit.png",
node_drops = false,
allow_nodes = true,
allow_entities = false,
allow_players = true,
rounds_update_time = 0.4,
damage_multiplier = 1,
}
shooter.default_particles = {
amount = 15,
time = 0.3,
minpos = {x=-0.1, y=-0.1, z=-0.1},
maxpos = {x=0.1, y=0.1, z=0.1},
minvel = {x=-1, y=1, z=-1},
maxvel = {x=1, y=2, z=1},
minacc = {x=-2, y=-2, z=-2},
maxacc = {x=2, y=-2, z=2},
minexptime = 0.1,
maxexptime = 0.75,
minsize = 1,
maxsize = 2,
collisiondetection = false,
texture = "shooter_hit.png",
}
local shots = {}
local shooting = {}
local server_step = minetest.settings:get("dedicated_server_step")
local v3d = table.copy(vector)
local PI = math.pi
local sin = math.sin
local cos = math.cos
local sqrt = math.sqrt
local phi = (math.sqrt(5) + 1) / 2 -- Golden ratio
shooter.register_weapon = function(name, def)
-- Backwards compatibility
if not def.spec.sounds then
def.spec.sounds = def.sounds or {}
end
if not def.spec.sounds.shot and def.spec.sound then
def.spec.sounds.shot = def.spec.sound
end
-- Fix definition table
def.spec.reload_item = def.reload_item or "shooter:ammo"
def.spec.tool_caps.full_punch_interval = math.max(server_step,
def.spec.tool_caps.full_punch_interval)
def.spec.wear = math.ceil(65535 / def.spec.rounds)
def.unloaded_item = def.unloaded_item or {
description = def.description.." (unloaded)",
inventory_image = def.inventory_image,
}
def.unloaded_item.name = name
shooter.registered_weapons[name] = table.copy(def)
-- Register loaded item tool
minetest.register_tool(name.."_loaded", {
description = def.description,
inventory_image = def.inventory_image,
on_use = function(itemstack, user, pointed_thing)
if type(def.on_use) == "function" then
itemstack = def.on_use(itemstack, user, pointed_thing)
end
if itemstack then
local spec = shooter.get_weapon_spec(nil, name) or
table.copy(def.spec)
if shooter.fire_weapon(user, itemstack, spec) then
itemstack:add_wear(spec.wear)
if itemstack:get_count() == 0 then
itemstack:replace(def.unloaded_item.name)
end
end
end
return itemstack
end,
unloaded_item = def.unloaded_item,
on_hit = def.on_hit,
groups = {not_in_creative_inventory=1},
})
-- Register unloaded item tool
minetest.register_tool(name, {
description = def.unloaded_item.description,
inventory_image = def.unloaded_item.inventory_image,
groups = def.unloaded_item.groups or {},
on_use = function(itemstack, user)
local inv = user:get_inventory()
if inv then
local stack = def.spec.reload_item
if inv:contains_item("main", stack) then
local sound = def.spec.sounds.reload or "shooter_reload"
minetest.sound_play(sound, {object=user})
inv:remove_item("main", stack)
itemstack:replace(name.."_loaded 1 1")
else
local sound = def.spec.sounds.fail_shot or "shooter_click"
minetest.sound_play(sound, {object=user})
end
end
return itemstack
end,
})
end
shooter.get_weapon_spec = function(_, name)
local def = shooter.registered_weapons[name]
if def then
return table.copy(def.spec)
end
end
shooter.get_configuration = function(conf)
for k, v in pairs(conf) do
local setting = minetest.settings:get("shooter_"..k)
if type(v) == "number" then
setting = tonumber(setting)
elseif type(v) == "boolean" then
setting = minetest.settings:get_bool("shooter_"..k)
end
if setting ~= nil then
conf[k] = setting
end
end
return conf
end
shooter.spawn_particles = function(pos, particles)
particles = particles or {}
if not shooter.config.enable_particle_fx == true or particles.amount == 0 then
return
end
for k, v in pairs(shooter.default_particles) do
if not particles[k] then
particles[k] = type(v) == "table" and table.copy(v) or v
end
end
particles.minpos = v3d.subtract(pos, particles.minpos)
particles.maxpos = v3d.add(pos, particles.maxpos)
minetest.add_particlespawner(particles)
end
shooter.play_node_sound = function(node, pos)
local item = minetest.registered_items[node.name]
if item then
if item.sounds then
local spec = item.sounds.dug
if spec then
spec.pos = pos
minetest.sound_play(spec.name, spec)
end
end
end
end
shooter.is_valid_object = function(object)
if object then
if object:is_player() == true then
return shooter.config.allow_players
end
if shooter.config.allow_entities == true then
local luaentity = object:get_luaentity()
if luaentity then
return luaentity.name ~= "__builtin:item"
end
end
end
end
shooter.punch_node = function(pos, spec)
if shooter.config.enable_protection and minetest.is_protected(pos, spec.user) then
return
end
local node = minetest.get_node(pos)
if not node then
return
end
local item = minetest.registered_items[node.name]
if not item then
return
end
if item.groups then
for k, v in pairs(spec.groups) do
local level = item.groups[k] or 0
if level >= v then
minetest.remove_node(pos)
shooter.play_node_sound(node, pos)
if item.tiles then
if item.tiles[1] then
shooter.spawn_particles(pos, {texture=item.tiles[1]})
end
end
if shooter.config.node_drops then
local object = minetest.add_item(pos, item)
if object then
object:set_velocity({
x = math.random(-1, 1),
y = 4,
z = math.random(-1, 1)
})
end
end
return true
end
end
end
end
shooter.punch_object = function(object, tool_caps, dir, on_blast)
local do_damage = true
local groups = tool_caps.damage_groups or {}
if on_blast and not object:is_player() then
local ent = object:get_luaentity()
if ent then
local def = minetest.registered_entities[ent.name] or {}
if def.on_blast and groups.fleshy then
do_damage = def.on_blast(ent, groups.fleshy *
shooter.config.damage_multiplier)
end
end
end
if do_damage then
for k, v in pairs(groups) do
tool_caps.damage_groups[k] = v * shooter.config.damage_multiplier
end
object:punch(object, nil, tool_caps, dir)
return true
end
end
local function matrix_from_quat(q)
local m = {{}, {}, {}}
m[1][1] = 1 - 2 * q.y * q.y - 2 * q.z * q.z
m[1][2] = 2 * q.x * q.y + 2 * q.z * q.w
m[1][3] = 2 * q.x * q.z - 2 * q.y * q.w
m[2][1] = 2 * q.x * q.y - 2 * q.z * q.w
m[2][2] = 1 - 2 * q.x * q.x - 2 * q.z * q.z
m[2][3] = 2 * q.z * q.y + 2 * q.x * q.w
m[3][1] = 2 * q.x * q.z + 2 * q.y * q.w
m[3][2] = 2 * q.z * q.y - 2 * q.x * q.w
m[3][3] = 1 - 2 * q.x * q.x - 2 * q.y * q.y
return m
end
local function quat_from_angle_axis(angle, axis)
local t = angle / 2
local s = sin(t)
return {
x = s * axis.x,
y = s * axis.y,
z = s * axis.z,
w = cos(t),
}
end
v3d.cross = function(v1, v2)
return {
x = v1.y * v2.z - v2.y * v1.z,
y = v1.z * v2.x - v2.z * v1.x,
z = v1.x * v2.y - v2.x * v1.y,
}
end
v3d.mult_matrix = function(v, m)
return {
x = m[1][1] * v.x + m[1][2] * v.y + m[1][3] * v.z,
y = m[2][1] * v.x + m[2][2] * v.y + m[2][3] * v.z,
z = m[3][1] * v.x + m[3][2] * v.y + m[3][3] * v.z,
}
end
v3d.rotate = function(v, angle, axis)
local q = quat_from_angle_axis(angle, axis)
local m = matrix_from_quat(q)
return v3d.mult_matrix(v, m)
end
local function get_directions(dir, spec)
local directions = {dir}
local n = spec.shots or 1
if n > 1 then
local right = v3d.normalize(v3d.cross(dir, {x=0, y=1, z=0}))
local up = v3d.normalize(v3d.cross(dir, right))
local s = spec.spread or 10
s = s * 0.017453 -- Convert to radians
for k = 1, n - 1 do
-- Sunflower seed arrangement
local r = sqrt(k - 0.5) / sqrt(n - 0.5)
local theta = 2 * PI * k / (phi * phi)
local x = r * cos(theta) * s
local y = r * sin(theta) * s
local d = v3d.rotate(dir, y, up)
directions[k + 1] = v3d.rotate(d, x, right)
end
end
return directions
end
local function process_hit(pointed_thing, spec, dir)
local def = minetest.registered_items[spec.name] or {}
if type(def.on_hit) == "function" then
if def.on_hit(pointed_thing, spec, dir) == true then
return
end
end
if pointed_thing.type == "node" and shooter.config.allow_nodes == true then
local pos = minetest.get_pointed_thing_position(pointed_thing, false)
shooter.punch_node(pos, spec)
elseif pointed_thing.type == "object" then
local object = pointed_thing.ref
if shooter.is_valid_object(object) and
shooter.punch_object(object, spec.tool_caps, dir) then
local pos = pointed_thing.intersection_point or object:get_pos()
local groups = object:get_armor_groups() or {}
if groups.fleshy then
shooter.spawn_particles(pos, spec.particles)
end
end
end
end
local function process_round(round)
round.dist = round.dist + round.spec.step
if round.dist > round.spec.range then
return
end
local p1 = round.pos
local p2 = v3d.add(p1, v3d.multiply(round.dir, round.spec.step))
local ray = minetest.raycast(p1, p2, true, true)
local pointed_thing = ray:next() or {type="nothing"}
if pointed_thing.type ~= "nothing" then
return process_hit(pointed_thing, round.spec, round.dir)
end
round.pos = p2
minetest.after(shooter.config.rounds_update_time, function(...)
process_round(...)
end, round)
end
local function fire_weapon(player, itemstack, spec, extended)
if not player then
return
end
local dir = player:get_look_dir()
local pos = player:get_pos()
if not dir or not pos then
return
end
pos.y = pos.y + player:get_properties().eye_height
spec.origin = v3d.add(pos, v3d.multiply(dir, 1.5))
local interval = spec.tool_caps.full_punch_interval
shots[spec.user] = minetest.get_us_time() / 1000000 + interval
local sound = spec.sounds.shot or "shooter_pistol"
minetest.sound_play(sound, {object=player})
local speed = spec.step / (shooter.config.rounds_update_time * 2)
local time = spec.range / speed
local directions = get_directions(dir, spec)
for _, d in pairs(directions) do
if spec.bullet_image then
minetest.add_particle({
pos = pos,
velocity = v3d.multiply(d, speed),
acceleration = {x=0, y=0, z=0},
expirationtime = time,
size = 0.25,
texture = spec.bullet_image,
})
end
process_round({
spec = spec,
pos = v3d.new(spec.origin),
dir = d,
dist = 0,
})
end
if extended then
itemstack:add_wear(spec.wear)
if itemstack:get_count() == 0 then
local def = minetest.registered_items[spec.name] or {}
if def.unloaded_item then
itemstack = def.unloaded_item.name or ""
end
player:set_wielded_item(itemstack)
return
end
player:set_wielded_item(itemstack)
end
if not spec.automatic or not shooting[spec.user] then
return
end
minetest.after(interval, function(...)
if shooting[spec.user] then
local arg = {...}
fire_weapon(arg[1], arg[2], arg[3], true)
end
end, player, itemstack, spec)
end
shooter.fire_weapon = function(player, itemstack, spec)
local name = player:get_player_name()
local time = minetest.get_us_time() / 1000000
if shots[name] and time <= shots[name] then
return false
end
if shooter.config.automatic_weapons then
if shooter.config.admin_weapons and minetest.check_player_privs(name,
{server=true}) then
spec.automatic = true
end
shooting[name] = true
end
spec.user = name
spec.name = itemstack:get_name()
fire_weapon(player, itemstack, spec)
return true
end
shooter.blast = function(pos, radius, fleshy, distance, user)
if not user then
return
end
pos = v3d.round(pos)
local name = user:get_player_name()
local p1 = v3d.subtract(pos, radius)
local p2 = v3d.add(pos, radius)
minetest.sound_play("shooter_explode", {
pos = pos,
gain = 10,
max_hear_distance = 100
})
if shooter.config.allow_nodes and shooter.config.enable_blasting then
if not shooter.config.enable_protection or
not minetest.is_protected(pos, name) then
minetest.set_node(pos, {name="shooter:boom"})
end
end
if shooter.config.enable_particle_fx == true then
minetest.add_particlespawner({
amount = 50,
time = 0.1,
minpos = p1,
maxpos = p2,
minvel = {x=0, y=0, z=0},
maxvel = {x=0, y=0, z=0},
minacc = {x=-0.5, y=5, z=-0.5},
maxacc = {x=0.5, y=5, z=0.5},
minexptime = 0.1,
maxexptime = 1,
minsize = 8,
maxsize = 15,
collisiondetection = false,
texture = "shooter_smoke.png",
})
end
local objects = minetest.get_objects_inside_radius(pos, distance)
for _,obj in ipairs(objects) do
if shooter.is_valid_object(obj) then
local obj_pos = obj:get_pos()
local dist = v3d.distance(obj_pos, pos)
local damage = (fleshy * 0.5 ^ dist) * 2 * shooter.config.damage_multiplier
if dist ~= 0 then
obj_pos.y = obj_pos.y + 1
local blast_pos = {x=pos.x, y=pos.y + 4, z=pos.z}
if shooter.is_valid_object(obj) and
minetest.line_of_sight(obj_pos, blast_pos, 1) then
shooter.punch_object(obj, {
full_punch_interval = 1.0,
damage_groups = {fleshy=damage},
}, nil, true)
end
end
end
end
if shooter.config.allow_nodes and shooter.config.enable_blasting then
local pr = PseudoRandom(os.time())
local vm = VoxelManip()
local min, max = vm:read_from_map(p1, p2)
local area = VoxelArea:new({MinEdge=min, MaxEdge=max})
local data = vm:get_data()
local c_air = minetest.get_content_id("air")
for z = -radius, radius do
for y = -radius, radius do
local vp = {x=pos.x - radius, y=pos.y + y, z=pos.z + z}
local vi = area:index(vp.x, vp.y, vp.z)
for x = -radius, radius do
if (x * x) + (y * y) + (z * z) <=
(radius * radius) + pr:next(-radius, radius) then
if shooter.config.enable_protection then
if not minetest.is_protected(vp, name) then
data[vi] = c_air
end
else
data[vi] = c_air
end
end
vi = vi + 1
end
end
end
vm:set_data(data)
vm:update_liquids()
vm:write_to_map()
end
end
shooter.get_shooting = function(name)
return shooting[name]
end
shooter.set_shooting = function(name, is_shooting)
shooting[name] = is_shooting and true or nil
end

View File

@ -0,0 +1,101 @@
--[[
Simple Shooter [shooter]
Copyright (C) 2013-2019 stujones11, Stuart Jones
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]--
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local worldpath = minetest.get_worldpath()
dofile(modpath.."/api.lua")
if minetest.is_singleplayer() then
shooter.config.enable_blasting = true
shooter.config.allow_entities = true
shooter.config.allow_players = false
end
-- Legacy Config Support
local input = io.open(modpath.."/shooter.conf", "r")
if input then
dofile(modpath.."/shooter.conf")
input:close()
end
input = io.open(worldpath.."/shooter.conf", "r")
if input then
dofile(worldpath.."/shooter.conf")
input:close()
end
for name, _ in pairs(shooter.config) do
local global = "SHOOTER_"..name:upper()
if minetest.global_exists(global) then
shooter.config[name] = _G[global]
end
end
-- Load Configuration
shooter.config = shooter.get_configuration(shooter.config)
shooter.default_particles.texture = shooter.config.explosion_texture
-- Legacy Entity Support
minetest.register_entity("shooter:turret_entity", {
visual = "sprite",
textures = {"blank.png"},
on_activate = function(self)
self.object:remove()
end,
})
-- Automatic Firing
if shooter.config.automatic_weapons == true then
minetest.register_globalstep(function()
for _,player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if name then
shooter.set_shooting(name,
player:get_player_control().LMB == true)
end
end
end)
end
minetest.register_node("shooter:boom", {
drawtype = "airlike",
light_source = 14,
walkable = false,
drop = "",
groups = {dig_immediate = 3},
-- unaffected by explosions
on_blast = function() end,
})
minetest.register_craftitem("shooter:gunpowder", {
description = "Gunpowder",
inventory_image = "shooter_powder.png",
})
if shooter.config.enable_crafting then
minetest.register_craft({
output = "shooter:gunpowder 5",
type = "shapeless",
recipe = {"default:coal_lump", "default:clay_lump"},
})
end

View File

@ -0,0 +1,3 @@
name = shooter
description = Shooter mod API
depends = default

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

View File

@ -0,0 +1,57 @@
Minetest Mod - Crossbow [shooter_crossbow]
==========================================
Depends: shooter, wool, dye
Adds a crossbow with colored arrows.
Configuration
=============
Override the following default settings by adding them to your minetest.conf file
* `shooter_crossbow_uses = 50`: Number of crossbow uses
* `shooter_arrow_lifetime = 180`: Arrow exipiry time in seconds
* `shooter_arrow_fleshy = 2`: Arrow 'fleshy' damage level
* `shooter_arrow_object_attach = false`: Attach arrows to objects when hit
* Experimental, currently does not work well with oversized selection boxes!
Crafting
========
<color> = grey, black, red, yellow, green, cyan, blue, magenta
A = Arrow [shooter:arrow_white]
C = Color Dye [dye:<color>]
W = Wooden Stick [default:stick]
P = Paper [default:paper]
S = Steel Ingot [default:steel_ingot]
B = Bronze Ingot [default:bronze_ingot]
Crossbow: [shooter_crossbow:crossbow]
+---+---+---+
| W | W | W |
+---+---+---+
| W | W | |
+---+---+---+
| W | | B |
+---+---+---+
White Arrow: [shooter_crossbow:arrow_white]
+---+---+---+
| S | | |
+---+---+---+
| | W | P |
+---+---+---+
| | P | W |
+---+---+---+
Coloured Arrow: [shooter_crossbow:arrow_<color>]
+---+---+
| C | A |
+---+---+

View File

@ -0,0 +1,322 @@
--[[
Shooter Crossbow [shooter_crossbow]
Copyright (C) 2013-2019 stujones11, Stuart Jones
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]--
local config = {
crossbow_uses = 50,
arrow_lifetime = 180,
arrow_fleshy = 2,
arrow_object_attach = false,
}
-- Legacy Config Support
for name, _ in pairs(config) do
local global = "SHOOTER_"..name:upper()
if minetest.global_exists(global) then
config[name] = _G[global]
end
end
-- Load configuration
config = shooter.get_configuration(config)
local arrow_tool_caps = {damage_groups={fleshy=config.arrow_fleshy}}
if minetest.global_exists("SHOOTER_ARROW_TOOL_CAPS") then
arrow_tool_caps = table.copy(SHOOTER_ARROW_TOOL_CAPS)
end
local dye_basecolors = (dye and dye.basecolors) or
{"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"}
-- name is the overlay texture name, colour is used to select the wool texture
local function get_texture(name, colour)
return "wool_"..colour..".png^shooter_"..name..".png^[makealpha:255,126,126"
end
local function get_animation_frame(dir)
local angle = math.atan(dir.y)
local frame = 90 - math.floor(angle * 360 / math.pi)
if frame < 1 then
frame = 1
elseif frame > 180 then
frame = 180
end
return frame
end
local function get_pointed_thing(pos, dir, dist)
local p1 = vector.add(pos, dir)
local p2 = vector.add(pos, vector.multiply(dir, dist))
local ray = minetest.raycast(p1, p2, true, true)
return ray:next()
end
local function strike(arrow, pointed_thing, name)
local puncher = minetest.get_player_by_name(name)
if not puncher then
return
end
local object = arrow.object
local hit_pos = pointed_thing.intersection_point or object:get_pos()
local dir = vector.normalize(object:get_velocity())
if pointed_thing.type == "object" then
local target = pointed_thing.ref
if shooter.is_valid_object(target) then
if puncher and puncher ~= target then
local groups = target:get_armor_groups() or {}
if groups.fleshy then
shooter.spawn_particles(hit_pos)
end
target:punch(object, nil, arrow_tool_caps, dir)
if config.arrow_object_attach then
local pos = vector.multiply(vector.subtract(target:get_pos(),
hit_pos), -10)
local rot = vector.new()
rot.y = (target:get_yaw() - object:get_yaw()) * 57.2958
object:set_attach(target, "", pos, rot)
arrow.state = "stuck"
else
arrow.state = "dropped"
end
end
end
elseif pointed_thing.type == "node" then
local pos = minetest.get_pointed_thing_position(pointed_thing, false)
local node = minetest.get_node(pos)
hit_pos = vector.subtract(hit_pos, vector.multiply(dir, 0.25))
arrow.node_pos = pos
arrow.state = "stuck"
shooter.play_node_sound(node, pos)
else
return
end
arrow:stop(hit_pos)
end
minetest.register_entity("shooter_crossbow:arrow_entity", {
physical = false,
visual = "mesh",
mesh = "shooter_arrow.b3d",
visual_size = {x=1, y=1},
textures = {
get_texture("arrow_uv", "white"),
},
color = "white",
timer = 0,
lifetime = config.arrow_lifetime,
user = nil,
state = "init",
node_pos = nil,
collisionbox = {0,0,0, 0,0,0},
stop = function(self, pos)
local acceleration = {x=0, y=-10, z=0}
if self.state == "stuck" then
pos = pos or self.object:get_pos()
acceleration = {x=0, y=0, z=0}
end
if pos then
self.object:move_to(pos)
end
self.object:set_properties({
physical = true,
collisionbox = {-1/8,-1/8,-1/8, 1/8,1/8,1/8},
})
self.object:set_velocity({x=0, y=0, z=0})
self.object:set_acceleration(acceleration)
end,
on_activate = function(self, staticdata)
self.object:set_armor_groups({immortal=1})
if staticdata == "expired" then
self.object:remove()
end
end,
on_punch = function(self, puncher)
if puncher then
if puncher:is_player() then
local stack = "shooter_crossbow:arrow_"..self.color
local inv = puncher:get_inventory()
if inv:room_for_item("main", stack) then
inv:add_item("main", stack)
self.object:remove()
end
end
end
end,
on_step = function(self, dtime)
if self.state == "init" then
return
end
self.timer = self.timer + dtime
self.lifetime = self.lifetime - dtime
if self.lifetime < 0 then
self.object:remove()
return
elseif self.state == "dropped" then
return
elseif self.state == "stuck" then
if self.timer > 1 then
if self.node_pos then
local node = minetest.get_node(self.node_pos)
if node.name then
local item = minetest.registered_items[node.name]
if item then
if not item.walkable then
self.state = "dropped"
self:stop()
return
end
end
end
end
self.timer = 0
end
return
end
if self.timer > 0.2 then
local dir = vector.normalize(self.object:get_velocity())
local frame = get_animation_frame(dir)
local pos = self.object:get_pos()
local pointed_thing = get_pointed_thing(pos, dir, 5)
if pointed_thing then
strike(self, pointed_thing, self.user)
end
self.object:set_animation({x=frame, y=frame}, 0)
self.timer = 0
end
end,
get_staticdata = function()
return "expired"
end,
})
for _, color in pairs(dye_basecolors) do
minetest.register_craftitem("shooter_crossbow:arrow_"..color, {
description = color:gsub("%a", string.upper, 1).." Arrow",
inventory_image = get_texture("arrow_inv", color),
})
minetest.register_tool("shooter_crossbow:crossbow_loaded_"..color, {
description = "Crossbow",
inventory_image = get_texture("crossbow_loaded", color),
groups = {not_in_creative_inventory=1},
on_use = function(itemstack, user)
minetest.sound_play("shooter_click", {object=user})
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535 / config.crossbow_uses)
end
itemstack = "shooter_crossbow:crossbow 1 "..itemstack:get_wear()
local pos = user:get_pos()
local dir = user:get_look_dir()
local yaw = user:get_look_horizontal()
if pos and dir and yaw then
pos.y = pos.y + user:get_properties().eye_height
local obj = minetest.add_entity(pos,
"shooter_crossbow:arrow_entity")
local ent = nil
if obj then
ent = obj:get_luaentity()
end
if ent then
ent.user = user:get_player_name()
ent.state = "flight"
ent.color = color
obj:set_properties({
textures = {get_texture("arrow_uv", color)}
})
minetest.sound_play("shooter_throw", {object=obj})
local frame = get_animation_frame(dir)
obj:set_yaw(yaw - math.pi / 2)
obj:set_animation({x=frame, y=frame}, 0)
obj:set_velocity({x=dir.x * 14, y=dir.y * 14, z=dir.z * 14})
obj:set_acceleration({x=dir.x * -3, y=-5, z=dir.z * -3})
local pointed_thing = get_pointed_thing(pos, dir, 5)
if pointed_thing then
strike(ent, pointed_thing, ent.user)
end
end
end
return itemstack
end,
})
end
minetest.register_tool("shooter_crossbow:crossbow", {
description = "Crossbow",
inventory_image = "shooter_crossbow.png",
on_use = function(itemstack, user)
local inv = user:get_inventory()
local stack = inv:get_stack("main", user:get_wield_index() + 1)
local color = string.match(stack:get_name(), "shooter_crossbow:arrow_(%a+)")
if color then
minetest.sound_play("shooter_reload", {object=user})
if not minetest.setting_getbool("creative_mode") then
inv:remove_item("main", "shooter_crossbow:arrow_"..color.." 1")
end
return "shooter_crossbow:crossbow_loaded_"..color.." 1 "..itemstack:get_wear()
end
for _, clr in pairs(dye_basecolors) do
if inv:contains_item("main", "shooter_crossbow:arrow_"..clr) then
minetest.sound_play("shooter_reload", {object=user})
if not minetest.setting_getbool("creative_mode") then
inv:remove_item("main", "shooter_crossbow:arrow_"..clr.." 1")
end
return "shooter_crossbow:crossbow_loaded_"..clr.." 1 "..itemstack:get_wear()
end
end
minetest.sound_play("shooter_click", {object=user})
end,
})
if shooter.config.enable_crafting == true then
minetest.register_craft({
output = "shooter_crossbow:crossbow",
recipe = {
{"default:stick", "default:stick", "default:stick"},
{"default:stick", "default:stick", ""},
{"default:stick", "", "default:bronze_ingot"},
},
})
minetest.register_craft({
output = "shooter_crossbow:arrow_white",
recipe = {
{"default:steel_ingot", "", ""},
{"", "default:stick", "default:paper"},
{"", "default:paper", "default:stick"},
},
})
if minetest.get_modpath("dye") then
for _, color in pairs(dye_basecolors) do
if color ~= "white" then
minetest.register_craft({
output = "shooter_crossbow:arrow_"..color,
recipe = {
{"", "dye:"..color, "shooter_crossbow:arrow_white"},
},
})
end
end
end
end
--Backwards compatibility
minetest.register_alias("shooter:crossbow", "shooter_crossbow:crossbow")
for _, color in pairs(dye_basecolors) do
minetest.register_alias("shooter:arrow_"..color, "shooter_crossbow:arrow_"..color)
minetest.register_alias("shooter:crossbow_loaded_"..color, "shooter_crossbow:crossbow_loaded_"..color)
end

View File

@ -0,0 +1,4 @@
name = shooter_crossbow
description = Adds a crossbow with colored arrows
depends = shooter
optional_depends = dye

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

View File

@ -0,0 +1,29 @@
Minetest Mod - Flare Gun [shooter_flaregun]
===========================================
Depends: shooter
Adds a flare-gun with temporary light emitting flares.
Crafting
========
S = Steel Ingot [default:steel_ingot]
C = Copper Ingot [default:copper_ingot]
P = Paper [default:paper]
G = Gunpowder [shooter:gunpowder]
Flare: [shooter_flaregun:flare]
+---+---+
| G | P |
+---+---+
Flare Gun: [shooter_flaregun:flaregun]
+---+---+---+
| C | C | C |
+---+---+---+
| | | S |
+---+---+---+

View File

@ -0,0 +1,176 @@
--[[
Shooter Flare Gun [shooter_flaregun]
Copyright (C) 2013-2019 stujones11, Stuart Jones
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]--
minetest.register_craftitem("shooter_flaregun:flare", {
description = "Flare",
inventory_image = "shooter_flare_inv.png",
})
minetest.register_node("shooter_flaregun:flare_light", {
drawtype = "glasslike",
tiles = {"shooter_flare_light.png"},
paramtype = "light",
groups = {not_in_creative_inventory=1},
drop = "",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
light_source = 14,
pointable = false,
})
minetest.register_abm({
nodenames = "shooter_flaregun:flare_light",
interval = 5,
chance = 1,
action = function(pos)
local time = os.time()
local meta = minetest.get_meta(pos)
local init_time = meta:get_int("init_time") or 0
if time > init_time + 30 then
local id = meta:get_int("particle_id")
if id then
minetest.delete_particlespawner(id)
end
minetest.remove_node(pos)
end
end,
})
minetest.register_entity("shooter_flaregun:flare_entity", {
physical = true,
timer = 0,
visual = "cube",
visual_size = {x=1/8, y=1/8},
textures = {
"shooter_flare.png",
"shooter_flare.png",
"shooter_flare.png",
"shooter_flare.png",
"shooter_flare.png",
"shooter_flare.png",
},
glow = 14,
collisionbox = {-1/16,-1/16,-1/16, 1/16,1/16,1/16},
on_activate = function(self, staticdata)
if staticdata == "expired" then
self.object:remove()
end
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 0.2 then
local pos = self.object:get_pos()
local below = {x=pos.x, y=pos.y - 1, z=pos.z}
local node = minetest.get_node(below)
if node.name ~= "air" then
self.object:set_velocity({x=0, y=-10, z=0})
self.object:set_acceleration({x=0, y=0, z=0})
if minetest.get_node(pos).name == "air" and
node.name ~= "default:water_source" and
node.name ~= "default:water_flowing" then
minetest.place_node(pos, {name="shooter_flaregun:flare_light"})
local meta = minetest.get_meta(pos)
pos.y = pos.y - 0.1
local id = minetest.add_particlespawner({
amount = 1000,
time = 30,
minpos = pos,
maxpos = pos,
minvel = {x=-1, y=1, z=-1},
maxvel = {x=1, y=1, z=1},
minacc = {x=2, y=-2, z=-2},
maxacc = {x=2, y=-2, z=2},
minexptime = 0.1,
maxexptime = 0.75,
minsize = 1,
maxsize = 8,
collisiondetection = false,
texture = "shooter_flare_particle.png",
glow = 14,
})
meta:set_int("particle_id", id)
meta:set_int("init_time", os.time())
local sound = minetest.sound_play("shooter_flare_burn", {
pos = pos,
loop = true,
max_hear_distance = 8,
})
minetest.after(30, function(...)
minetest.sound_stop(...)
end, sound)
end
self.object:remove()
end
self.timer = 0
end
end,
get_staticdata = function()
return "expired"
end,
})
minetest.register_tool("shooter_flaregun:flaregun", {
description = "Flare Gun",
inventory_image = "shooter_flaregun.png",
on_use = function(itemstack, user)
local inv = user:get_inventory()
if not inv:contains_item("main", "shooter_flaregun:flare") then
minetest.sound_play("shooter_click", {object=user})
return itemstack
end
if not minetest.setting_getbool("creative_mode") then
inv:remove_item("main", "shooter:flare 1")
itemstack:add_wear(65535 / 100)
end
local pos = user:get_pos()
local dir = user:get_look_dir()
local yaw = user:get_look_horizontal()
if pos and dir and yaw then
pos.y = pos.y + 1.5
local obj = minetest.add_entity(pos, "shooter_flaregun:flare_entity")
if obj then
minetest.sound_play("shooter_flare_fire", {object=obj})
obj:set_velocity(vector.multiply(dir, 16))
obj:set_acceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
obj:set_yaw(yaw + math.pi / 2)
end
end
return itemstack
end,
})
if shooter.config.enable_crafting == true then
minetest.register_craft({
output = "shooter_flaregun:flare",
type = "shapeless",
recipe = {"shooter:gunpowder", "default:paper"},
})
minetest.register_craft({
output = "shooter_flaregun:flaregun",
recipe = {
{"default:copper_ingot", "default:copper_ingot", "default:copper_ingot"},
{"", "", "default:steel_ingot"}
},
})
end
--Backwards compatibility
minetest.register_alias("shooter:flaregun", "shooter_flaregun:flaregun")
minetest.register_alias("shooter:flare", "shooter_flaregun:flare")

View File

@ -0,0 +1,3 @@
name = shooter_flaregun
description = Adds a flare-gun with temporary light emitting flares
depends = shooter

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

View File

@ -0,0 +1,19 @@
Minetest Mod - Grenade [shooter_grenade]
========================================
Depends: shooter
Adds simple hand grenades.
Crafting
========
S = Steel Ingot [default:steel_ingot]
G = Gunpowder [shooter:gunpowder]
Grenade: [shooter_grenade:grenade]
+---+---+
| G | S |
+---+---+

View File

@ -0,0 +1,106 @@
--[[
Shooter Grenade [shooter_grenade]
Copyright (C) 2013-2019 stujones11, Stuart Jones
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]--
minetest.register_entity("shooter_grenade:grenade_entity", {
physical = false,
timer = 0,
visual = "cube",
visual_size = {x=1/8, y=1/8},
textures = {
"shooter_grenade.png",
"shooter_grenade.png",
"shooter_grenade.png",
"shooter_grenade.png",
"shooter_grenade.png",
"shooter_grenade.png",
},
user = nil,
collisionbox = {0,0,0, 0,0,0},
on_activate = function(self, staticdata)
if staticdata == "expired" then
self.object:remove()
end
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 0.2 then
local pos = self.object:get_pos()
local above = {x=pos.x, y=pos.y + 1, z=pos.z}
if minetest.get_node(pos).name ~= "air" then
if self.user then
local player = minetest.get_player_by_name(self.user)
if player then
shooter.blast(above, 2, 25, 5, player)
end
end
self.object:remove()
end
self.timer = 0
end
end,
get_staticdata = function()
return "expired"
end,
})
minetest.register_tool("shooter_grenade:grenade", {
description = "Grenade",
inventory_image = "shooter_hand_grenade.png",
on_use = function(itemstack, user, pointed_thing)
if not minetest.setting_getbool("creative_mode") then
itemstack:clear()
end
if pointed_thing.type ~= "nothing" then
local pointed = minetest.get_pointed_thing_position(pointed_thing)
if vector.distance(user:get_pos(), pointed) < 8 then
shooter.blast(pointed, 1, 25, 5)
return
end
end
local pos = user:get_pos()
local dir = user:get_look_dir()
local yaw = user:get_look_horizontal()
if pos and dir then
pos.y = pos.y + user:get_properties().eye_height
local obj = minetest.add_entity(pos, "shooter_grenade:grenade_entity")
if obj then
minetest.sound_play("shooter_throw", {object=obj})
obj:set_velocity(vector.multiply(dir, 15))
obj:set_acceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
obj:set_yaw(yaw + math.pi / 2)
local ent = obj:get_luaentity()
if ent then
ent.user = user:get_player_name()
end
end
end
return itemstack
end,
})
if shooter.config.enable_crafting == true then
minetest.register_craft({
output = "shooter_grenade:grenade",
type = "shapeless",
recipe = {"shooter:gunpowder", "default:steel_ingot"},
})
end
--Backwards compatibility
minetest.register_alias("shooter:grenade", "shooter_grenade:grenade")

View File

@ -0,0 +1,3 @@
name = shooter_grenade
description = Adds simple hand grenades
depends = shooter

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

View File

@ -0,0 +1,59 @@
Minetest Mod - Shooter Guns [shooter_guns]
==========================================
Depends: shooter
Adds basic guns using the shooter API.
Crafting
========
S = Steel Ingot [default:steel_ingot]
B = Bronze Ingot [default:bronze_ingot]
M = Mese Crystal [default:mese_crysytal]
G = Gunpowder [shooter:gunpowder]
Pistol: [shooter_guns:pistol]
+---+---+
| S | S |
+---+---+
| | M |
+---+---+
Rifle: [shooter_guns:rifle]
+---+---+---+
| S | | |
+---+---+---+
| | B | |
+---+---+---+
| | M | B |
+---+---+---+
Shotgun: [shooter_guns:shotgun]
+---+---+---+
| S | | |
+---+---+---+
| | S | |
+---+---+---+
| | M | B |
+---+---+---+
Sub Machine Gun: [shooter_guns:machine_gun]
+---+---+---+
| S | S | S |
+---+---+---+
| | B | M |
+---+---+---+
| | B | |
+---+---+---+
Ammo Pack: [shooter_guns:ammo]
+---+---+
| G | B |
+---+---+

View File

@ -0,0 +1,156 @@
--[[
Shooter Guns [shooter_guns]
Copyright (C) 2013-2019 stujones11, Stuart Jones
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]--
shooter.register_weapon("shooter_guns:pistol", {
description = "Pistol",
inventory_image = "shooter_pistol.png",
spec = {
rounds = 200,
range = 160,
step = 20,
tool_caps = {full_punch_interval=0.5, damage_groups={fleshy=2}},
groups = {snappy=3, fleshy=3, oddly_breakable_by_hand=3},
sounds = {
shot = "shooter_pistol",
},
bullet_image = "shooter_cap.png",
particles = {
amount = 8,
minsize = 0.25,
maxsize = 0.75,
},
},
})
shooter.register_weapon("shooter_guns:rifle", {
description = "Rifle",
inventory_image = "shooter_rifle.png",
spec = {
rounds = 100,
range = 240,
step = 30,
tool_caps = {full_punch_interval=1.0, damage_groups={fleshy=3}},
groups = {snappy=3, crumbly=3, choppy=3, fleshy=2, oddly_breakable_by_hand=2},
sounds = {
shot = "shooter_rifle",
},
bullet_image = "shooter_bullet.png",
particles = {
amount = 12,
minsize = 0.75,
maxsize = 1.5,
},
},
})
shooter.register_weapon("shooter_guns:shotgun", {
description = "Shotgun",
inventory_image = "shooter_shotgun.png",
spec = {
rounds = 50,
range = 30,
step = 15,
shots = 15,
spread = 10,
tool_caps = {full_punch_interval=0.5, damage_groups={fleshy=2}},
groups = {snappy=3, fleshy=3, oddly_breakable_by_hand=3},
sounds = {
shot = "shooter_shotgun",
},
bullet_image = "shooter_cap.png",
particles = {
amount = 8,
minsize = 0.25,
maxsize = 0.75,
},
},
})
shooter.register_weapon("shooter_guns:machine_gun", {
description = "Sub Machine Gun",
inventory_image = "shooter_smgun.png",
spec = {
automatic = true,
rounds = 32,
range = 160,
step = 20,
tool_caps = {full_punch_interval=0.1, damage_groups={fleshy=2}},
groups = {snappy=3, fleshy=3, oddly_breakable_by_hand=3},
sounds = {
shot = "shooter_pistol",
},
bullet_image = "shooter_cap.png",
particles = {
amount = 4,
minsize = 0.25,
maxsize = 0.75,
},
},
})
minetest.register_craftitem("shooter_guns:ammo", {
description = "Ammo pack",
inventory_image = "shooter_ammo.png",
})
if shooter.config.enable_crafting == true then
minetest.register_craft({
output = "shooter_guns:pistol 1 65535",
recipe = {
{"default:steel_ingot", "default:steel_ingot"},
{"", "default:mese_crystal"},
},
})
minetest.register_craft({
output = "shooter_guns:rifle 1 65535",
recipe = {
{"default:steel_ingot", "", ""},
{"", "default:bronze_ingot", ""},
{"", "default:mese_crystal", "default:bronze_ingot"},
},
})
minetest.register_craft({
output = "shooter_guns:shotgun 1 65535",
recipe = {
{"default:steel_ingot", "", ""},
{"", "default:steel_ingot", ""},
{"", "default:mese_crystal", "default:bronze_ingot"},
},
})
minetest.register_craft({
output = "shooter_guns:machine_gun 1 65535",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"", "default:bronze_ingot", "default:mese_crystal"},
{"", "default:bronze_ingot", ""},
},
})
minetest.register_craft({
output = "shooter_guns:ammo",
type = "shapeless",
recipe = {"shooter:gunpowder", "default:bronze_ingot"},
})
end
--Backwards compatibility
minetest.register_alias("shooter:shotgun", "shooter_guns:shotgun_loaded")
minetest.register_alias("shooter:pistol", "shooter_guns:pistol_loaded")
minetest.register_alias("shooter:machine_gun", "shooter_guns:machine_gun_loaded")
minetest.register_alias("shooter:rifle", "shooter_guns:rifle_loaded")
minetest.register_alias("shooter:ammo", "shooter_guns:ammo")

View File

@ -0,0 +1,3 @@
name = shooter_guns
description = Adds basic guns using the shooter API
depends = shooter

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

View File

@ -0,0 +1,32 @@
Minetest Mod - Grapple Hook [shooter_hook]
==========================================
Depends: shooter
Adds a teleporting grapple hook which can be thrown or launched
further from a grapple hook gun.
Crafting
========
S = Steel Ingot [default:steel_ingot]
D = Diamond [default:diamond]
Grappling Hook: [shooter_hook:grapple_hook]
+---+---+---+
| S | S | D |
+---+---+---+
| S | S | |
+---+---+---+
| D | | S |
+---+---+---+
Grappling Hook Gun: [shooter_hook:grapple_gun]
+---+---+
| S | S |
+---+---+
| | D |
+---+---+

View File

@ -0,0 +1,157 @@
--[[
Shooter Grapple Hook [shooter_hook]
Copyright (C) 2013-2019 stujones11, Stuart Jones
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]--
local function throw_hook(itemstack, user, vel)
local pos = user:get_pos()
local dir = user:get_look_dir()
local yaw = user:get_look_horizontal()
if pos and dir and yaw then
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535 / 100)
end
pos.y = pos.y + 1.5
local obj = minetest.add_entity(pos, "shooter_hook:hook")
if obj then
minetest.sound_play("shooter_throw", {object=obj})
obj:set_velocity(vector.multiply(dir, vel))
obj:set_acceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
obj:set_yaw(yaw + math.pi / 2)
local ent = obj:get_luaentity()
if ent then
ent.user = user:get_player_name()
ent.itemstack = itemstack
end
end
end
end
minetest.register_entity("shooter_hook:hook", {
physical = true,
timer = 0,
visual = "wielditem",
visual_size = {x=1/2, y=1/2},
textures = {"shooter_hook:grapple_hook"},
user = nil,
itemstack = "",
collisionbox = {-1/4,-1/4,-1/4, 1/4,1/4,1/4},
on_activate = function(self, staticdata)
self.object:set_armor_groups({fleshy=0})
if staticdata == "expired" then
self.object:remove()
end
end,
on_step = function(self, dtime)
if not self.user then
return
end
self.timer = self.timer + dtime
if self.timer > 0.25 then
local pos = self.object:get_pos()
local below = {x=pos.x, y=pos.y - 1, z=pos.z}
local node = minetest.get_node(below)
if node.name ~= "air" then
self.object:set_velocity({x=0, y=-10, z=0})
self.object:set_acceleration({x=0, y=0, z=0})
if minetest.get_item_group(node.name, "liquid") == 0 and
minetest.get_node(pos).name == "air" then
local player = minetest.get_player_by_name(self.user)
if player then
player:move_to(pos)
end
end
if minetest.get_item_group(node.name, "lava") == 0 then
minetest.add_item(pos, self.itemstack)
end
self.object:remove()
end
self.timer = 0
end
end,
get_staticdata = function()
return "expired"
end,
})
minetest.register_tool("shooter_hook:grapple_hook", {
description = "Grappling Hook",
inventory_image = "shooter_hook.png",
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "nothing" then
return itemstack
end
throw_hook(itemstack, user, 14)
return ""
end,
})
minetest.register_tool("shooter_hook:grapple_gun", {
description = "Grappling Gun",
inventory_image = "shooter_hook_gun.png",
on_use = function(itemstack, user)
local inv = user:get_inventory()
if inv:contains_item("main", "shooter_hook:grapple_hook") and
inv:contains_item("main", "shooter:gunpowder") then
inv:remove_item("main", "shooter:gunpowder")
minetest.sound_play("shooter_reload", {object=user})
local stack = inv:remove_item("main", "shooter_hook:grapple_hook")
itemstack = "shooter_hook:grapple_gun_loaded 1 "..stack:get_wear()
else
minetest.sound_play("shooter_click", {object=user})
end
return itemstack
end,
})
minetest.register_tool("shooter_hook:grapple_gun_loaded", {
description = "Grappling Gun",
inventory_image = "shooter_hook_gun_loaded.png",
groups = {not_in_creative_inventory=1},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "nothing" then
return itemstack
end
minetest.sound_play("shooter_pistol", {object=user})
itemstack = ItemStack("shooter_hook:grapple_hook 1 "..itemstack:get_wear())
throw_hook(itemstack, user, 20)
return "shooter_hook:grapple_gun"
end,
})
if shooter.config.enable_crafting == true then
minetest.register_craft({
output = "shooter_hook:grapple_hook",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:diamond"},
{"default:steel_ingot", "default:steel_ingot", ""},
{"default:diamond", "", "default:steel_ingot"},
},
})
minetest.register_craft({
output = "shooter_hook:grapple_gun",
recipe = {
{"", "default:steel_ingot", "default:steel_ingot"},
{"", "", "default:diamond"},
},
})
end
--Backwards compatibility
minetest.register_alias("shooter:grapple_hook", "shooter_hook:grapple_hook")
minetest.register_alias("shooter:grapple_gun", "shooter_hook:grapple_gun")
minetest.register_alias("shooter:grapple_gun_loaded", "shooter_hook:grapple_gun_loaded")

View File

@ -0,0 +1,3 @@
name = shooter_hook
description = Adds a teleporting grapple hook and gun
depends = shooter

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

View File

@ -0,0 +1,29 @@
Minetest Mod - Rocket Launcher [shooter_rocket]
===============================================
Depends: shooter
Adds rocket missiles and launching gun.
Crafting
========
S = Steel Ingot [default:steel_ingot]
B = Bronze Ingot [default:bronze_ingot]
D = Diamond [default:diamond]
G = Gunpowder [shooter:gunpowder]
Rocket: [shooter_rocket:rocket]
+---+---+---+
| B | G | B |
+---+---+---+
Rocket Gun: [shooter_rocket:rocket_gun]
+---+---+---+
| B | S | S |
+---+---+---+
| | | D |
+---+---+---+

View File

@ -0,0 +1,143 @@
--[[
Shooter Rocket Gun [shooter_rocket]
Copyright (C) 2013-2019 stujones11, Stuart Jones
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]--
minetest.register_craftitem("shooter_rocket:rocket", {
description = "Rocket",
stack_max = 1,
inventory_image = "shooter_rocket_inv.png",
})
minetest.register_entity("shooter_rocket:rocket_entity", {
physical = false,
timer = 0,
visual = "cube",
visual_size = {x=1/8, y=1/8},
textures = {
"shooter_bullet.png",
"shooter_bullet.png",
"shooter_bullet.png",
"shooter_bullet.png",
"shooter_bullet.png",
"shooter_bullet.png",
},
user = nil,
collisionbox = {0,0,0, 0,0,0},
on_activate = function(self, staticdata)
if staticdata == "expired" then
self.object:remove()
end
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 0.2 then
local pos = self.object:get_pos()
local above = {x=pos.x, y=pos.y + 1, z=pos.z}
if minetest.get_node(pos).name ~= "air" then
if self.user then
local player = minetest.get_player_by_name(self.user)
if player then
shooter.blast(above, 4, 50, 8, player)
end
end
self.object:remove()
end
self.timer = 0
end
end,
get_staticdata = function()
return "expired"
end,
})
minetest.register_tool("shooter_rocket:rocket_gun_loaded", {
description = "Rocket Gun",
inventory_image = "shooter_rocket_gun_loaded.png",
groups = {not_in_creative_inventory=1},
on_use = function(itemstack, user, pointed_thing)
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535 / 50)
end
itemstack = "shooter_rocket:rocket_gun 1 "..itemstack:get_wear()
if pointed_thing.type ~= "nothing" then
local pointed = minetest.get_pointed_thing_position(pointed_thing)
if vector.distance(user:get_pos(), pointed) < 8 then
shooter.blast(pointed, 2, 50, 7)
return itemstack
end
end
local pos = user:get_pos()
local dir = user:get_look_dir()
local yaw = user:get_look_horizontal()
if pos and dir and yaw then
pos.y = pos.y + user:get_properties().eye_height
local obj = minetest.add_entity(pos, "shooter_rocket:rocket_entity")
if obj then
minetest.sound_play("shooter_rocket_fire", {object=obj})
obj:set_velocity(vector.multiply(dir, 20))
obj:set_acceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
obj:set_yaw(yaw + math.pi / 2)
local ent = obj:get_luaentity()
if ent then
ent.user = user:get_player_name()
end
end
end
return itemstack
end,
})
minetest.register_tool("shooter_rocket:rocket_gun", {
description = "Rocket Gun",
inventory_image = "shooter_rocket_gun.png",
on_use = function(itemstack, user)
local inv = user:get_inventory()
if inv:contains_item("main", "shooter_rocket:rocket") then
minetest.sound_play("shooter_reload", {object=user})
if not minetest.setting_getbool("creative_mode") then
inv:remove_item("main", "shooter_rocket:rocket 1")
end
itemstack = "shooter_rocket:rocket_gun_loaded 1 "..itemstack:get_wear()
else
minetest.sound_play("shooter_click", {object=user})
end
return itemstack
end,
})
if shooter.config.enable_crafting == true then
minetest.register_craft({
output = "shooter_rocket:rocket_gun",
recipe = {
{"default:bronze_ingot", "default:steel_ingot", "default:steel_ingot"},
{"", "", "default:diamond"},
},
})
minetest.register_craft({
output = "shooter_rocket:rocket",
type = "shapeless",
recipe = {"default:bronze_ingot", "shooter:gunpowder", "default:bronze_ingot"},
})
end
--Backwards compatibility
minetest.register_alias("shooter:rocket", "shooter_rocket:rocket")
minetest.register_alias("shooter:rocket_gun", "shooter_rocket:rocket_gun")
minetest.register_alias("shooter:rocket_gun_loaded", "shooter_rocket:rocket_gun_loaded")

View File

@ -0,0 +1,3 @@
name = shooter_rocket
description = Adds rocket missiles and launching gun
depends = shooter

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

View File

@ -0,0 +1,25 @@
Minetest Mod - Turret Gun [shooter_turret]
==========================================
Depends: shooter_rocket
Adds a mountable turret gun which can also be triggered by mesecon signals.
Still WIP and experimental and may be subject to change or removal.
Crafting
========
S = Steel Ingot [default:steel_ingot]
B = Bronze Ingot [default:bronze_ingot]
D = Diamond [default:diamond]
Turret Gun: [shooter_turret:turret]
+---+---+---+
| B | B | S |
+---+---+---+
| | B | S |
+---+---+---+
| | D | |
+---+---+---+

View File

@ -0,0 +1,289 @@
--[[
Shooter Turret Gun [shooter_turret]
Copyright (C) 2013-2019 stujones11, Stuart Jones
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]--
local use_player_api = minetest.get_modpath("player_api")
local function get_turret_entity(pos)
local entity = nil
local objects = minetest.get_objects_inside_radius(pos, 1)
for _, obj in ipairs(objects) do
local ent = obj:get_luaentity()
if ent then
if ent.name == "shooter_turret:turret_entity" then
-- Remove duplicates
if entity then
obj:remove()
else
entity = ent
end
end
end
end
return entity
end
minetest.register_entity("shooter_turret:turret_entity", {
physical = true,
visual = "mesh",
mesh = "shooter_turret.b3d",
visual_size = {x=1, y=1},
collisionbox = {-0.3, 0.5,-0.3, 0.3,1,0.3},
textures = {
"shooter_turret_uv.png",
},
timer = 0,
user = nil,
pitch = 40,
yaw = 0,
firing = false,
on_activate = function(self)
self.pos = self.object:get_pos()
self.yaw = self.object:get_yaw()
if minetest.get_node(self.pos).name ~= "shooter_turret:turret" then
self.object:remove()
return
end
self.object:set_animation({x=self.pitch, y=self.pitch}, 0)
self.object:set_armor_groups({immortal=1})
-- Remove duplicates
get_turret_entity(self.pos)
end,
on_rightclick = function(self, clicker)
if self.user then
local player = minetest.get_player_by_name(self.user)
if player then
player:set_detach()
if use_player_api then
player_api.player_attached[self.user] = false
end
end
self.user = nil
else
clicker:set_attach(self.object, "", {x=0,y=-5,z=-8}, {x=0,y=0,z=0})
self.user = clicker:get_player_name()
if use_player_api then
player_api.player_attached[self.user] = true
end
end
end,
on_step = function(self, dtime)
if not self.user then
return
end
self.timer = self.timer + dtime
if self.timer < 0.2 then
return
end
local player = minetest.get_player_by_name(self.user)
if player then
local pitch = self.pitch
local yaw = self.object:get_yaw()
local ctrl = player:get_player_control()
local step = 2
if ctrl then
if ctrl.sneak then
step = 1
if ctrl.jump then
if self.firing == false then
self:fire()
self.firing = true
end
else
self.firing = false
end
end
if ctrl.down then
pitch = pitch + 1 * step
elseif ctrl.up then
pitch = pitch - 1 * step
end
if ctrl.left then
yaw = yaw + 0.025 * step
elseif ctrl.right then
yaw = yaw - 0.025 * step
end
if pitch < 0 then
pitch = 0
elseif pitch > 90 then
pitch = 90
end
if self.pitch ~= pitch then
self.object:set_animation({x=pitch, y=pitch}, 0)
self.pitch = pitch
end
if self.yaw ~= yaw then
self.object:set_yaw(yaw)
self.yaw = yaw
end
end
end
self.timer = 0
end,
fire = function(self)
if not self.user then
return
end
local meta = minetest.get_meta(self.pos)
local inv = meta:get_inventory()
if not inv then
return
end
if not inv:contains_item("main", "shooter_rocket:rocket") then
minetest.sound_play("shooter_click", {object=self.object})
return
end
inv:remove_item("main", "shooter_rocket:rocket")
minetest.sound_play("shooter_shotgun", {object=self.object})
local pitch = math.rad(self.pitch - 40)
local len = math.cos(pitch)
local dir = vector.normalize({
x = len * math.sin(-self.yaw),
y = math.sin(pitch),
z = len * math.cos(self.yaw),
})
local pos = {x=self.pos.x, y=self.pos.y + 0.87, z=self.pos.z}
pos = vector.add(pos, vector.multiply(dir, 1.5))
local obj = minetest.add_entity(pos, "shooter_rocket:rocket_entity")
if obj then
local ent = obj:get_luaentity()
if ent then
minetest.sound_play("shooter_rocket_fire", {object=obj})
ent.user = self.user
obj:set_yaw(self.yaw)
obj:set_velocity(vector.multiply(dir, 30))
obj:set_acceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
end
end
if shooter.config.enable_particle_fx == true then
minetest.add_particlespawner({
amount = 10,
time = 0.1,
minpos = {x=pos.x - 1, y=pos.y - 1, z=pos.z - 1},
maxpos = {x=pos.x + 1, y=pos.y + 1, z=pos.z + 1},
minvel = {x=0, y=0, z=0},
maxvel = {x=0, y=0, z=0},
minacc = {x=-0.5, y=-0.5, z=-0.5},
maxacc = {x=0.5, y=0.5, z=0.5},
minexptime = 0.1,
maxexptime = 1,
minsize = 8,
maxsize = 15,
collisiondetection = false,
texture = "shooter_smoke.png",
})
end
end
})
minetest.register_node("shooter_turret:turret", {
description = "Turret Gun",
tiles = {"shooter_turret_base.png"},
inventory_image = "shooter_turret_gun.png",
wield_image = "shooter_turret_gun.png",
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=3},
node_box = {
type = "fixed",
fixed = {
{-1/8, 1/8, -1/8, 1/8, 1/2, 1/8},
{-5/16, 0, -5/16, 5/16, 1/8, 5/16},
{-3/8, -1/2, -3/8, -1/4, 0, -1/4},
{1/4, -1/2, 1/4, 3/8, 0, 3/8},
{1/4, -1/2, -3/8, 3/8, 0, -1/4},
{-3/8, -1/2, 1/4, -1/4, 0, 3/8},
},
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[8,9]"..
"list[current_name;main;2,0;4,4;]"..
"list[current_player;main;0,5;8,4;]"..
"listring[]"
)
meta:set_string("infotext", "Turret Gun")
local inv = meta:get_inventory()
inv:set_size("main", 16)
end,
after_place_node = function(pos)
local node = minetest.get_node({x=pos.x, y=pos.y + 1, z=pos.z})
if node.name == "air" then
if not get_turret_entity(pos) then
minetest.add_entity(pos, "shooter_turret:turret_entity")
end
end
end,
can_dig = function(pos)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
after_destruct = function(pos)
local ent = get_turret_entity(pos)
if ent then
ent.object:remove()
end
end,
mesecons = {
effector = {
action_on = function(pos)
local ent = get_turret_entity(pos)
if ent then
if ent.firing == false then
ent:fire()
ent.firing = true
end
end
end,
action_off = function(pos)
local ent = get_turret_entity(pos)
if ent then
ent.firing = false
end
end,
},
},
})
minetest.register_abm({
nodenames = {"shooter_turret:turret"},
interval = 15,
chance = 1,
action = function(pos)
if not get_turret_entity(pos) then
minetest.add_entity(pos, "shooter_turret:turret_entity")
end
end
})
if shooter.config.enable_crafting == true then
minetest.register_craft({
output = "shooter_turret:turret",
recipe = {
{"default:bronze_ingot", "default:bronze_ingot", "default:steel_ingot"},
{"", "default:bronze_ingot", "default:steel_ingot"},
{"", "default:diamond", ""},
},
})
end
--Backward compatibility
minetest.register_alias("shooter:turret", "shooter_turret:turret")

View File

@ -0,0 +1,4 @@
name = shooter_turret
description = Experimental turret gun which can also be triggered by mesecon signals.
depends = shooter_rocket
optional_depends = player_api

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB