Initial commit
This commit is contained in:
commit
6255c81015
11 changed files with 174 additions and 0 deletions
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
## Generic ignorable patterns and files
|
||||
*~
|
||||
.*.swp
|
||||
*bak*
|
||||
tags
|
||||
*.vim
|
||||
|
12
LICENSE.txt
Normal file
12
LICENSE.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
Minetest Mod - Simple Shooter [shooter]
|
||||
=======================================
|
||||
|
||||
License Source: 2013 Stuart Jones - LGPL
|
||||
|
||||
License Textures: Stuart Jones - WTFPL
|
||||
|
||||
License Sounds: freesound.org
|
||||
|
||||
flobert1_20070728.wav by Nonoo - Attribution 3.0 Unported (CC BY 3.0)
|
||||
GUNSHOT.WAV by erkanozan - CC0 1.0 Universal (CC0 1.0)
|
||||
|
54
README.txt
Normal file
54
README.txt
Normal file
|
@ -0,0 +1,54 @@
|
|||
Minetest Mod - Simple Shooter [shooter]
|
||||
=======================================
|
||||
|
||||
Mod Version: 0.1.0
|
||||
|
||||
Minetest Version: 0.4.8
|
||||
|
||||
Depends: default
|
||||
|
||||
An experimental first person shooter mod using vector mathematics instead of
|
||||
physical projectile entities. This has a number of advantages along with a
|
||||
number disadvantages.
|
||||
|
||||
Pros:
|
||||
|
||||
Fast and responsive
|
||||
Fairly light weight
|
||||
Not affected by chunk boundaries
|
||||
|
||||
Cons:
|
||||
|
||||
Only works against other players
|
||||
Slightly less realistic
|
||||
|
||||
This is still very much a work in progress and currently not much use in a
|
||||
singleplayer game. I plan to eventually use this as a base for a 'Spades' style
|
||||
FPS game using the minetest engine, however, I decided to add a couple of craft
|
||||
recipes and release this simple version for minetest_game.
|
||||
|
||||
Crafting
|
||||
========
|
||||
|
||||
S = Steel Ingot [default:steel_ingot]
|
||||
B = Bronze Ingot [default:bronze_ingot]
|
||||
M = Mese Crystal [default:mese_crysytal]
|
||||
|
||||
Pistol: [shooter:pistol]
|
||||
|
||||
+---+---+
|
||||
| S | B |
|
||||
+---+---+
|
||||
| | M |
|
||||
+---+---+
|
||||
|
||||
Riffle: [shooter:riffle]
|
||||
|
||||
+---+---+---+
|
||||
| S | | |
|
||||
+---+---+---+
|
||||
| | B | |
|
||||
+---+---+---+
|
||||
| | M | B |
|
||||
+---+---+---+
|
||||
|
2
depends.txt
Normal file
2
depends.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
|
47
init.lua
Normal file
47
init.lua
Normal file
|
@ -0,0 +1,47 @@
|
|||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/shooter.lua")
|
||||
|
||||
minetest.register_tool("shooter:pistol", {
|
||||
description = "Pistol",
|
||||
inventory_image = "shooter_pistol.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
shooter:fire_weapon(user, {
|
||||
range_func = {a=-0.1, b=-1.5, c=100},
|
||||
tool_caps = {full_punch_interval=1.0, damage_groups={fleshy=3}},
|
||||
sound = "shooter_pistol",
|
||||
})
|
||||
itemstack:add_wear(328) -- 200 Rounds
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("shooter:riffle", {
|
||||
description = "Riffle",
|
||||
inventory_image = "shooter_riffle.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
shooter:fire_weapon(user, {
|
||||
range_func = {a=-0.02, b=-0.6, c=100},
|
||||
tool_caps = {full_punch_interval=1.0, damage_groups={fleshy=5}},
|
||||
sound = "shooter_riffle",
|
||||
})
|
||||
itemstack:add_wear(656) -- 100 Rounds
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "shooter:pistol",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "default:bronze_ingot"},
|
||||
{"", "default:mese_crystal"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "shooter:riffle",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "", ""},
|
||||
{"", "default:bronze_ingot", ""},
|
||||
{"", "default:mese_crystal", "default:bronze_ingot"},
|
||||
},
|
||||
})
|
||||
|
52
shooter.lua
Normal file
52
shooter.lua
Normal file
|
@ -0,0 +1,52 @@
|
|||
shooter = {}
|
||||
|
||||
local function in_range(r, x)
|
||||
local chance = r.a * (x * x) + r.b * x + r.c
|
||||
if math.random(100) < chance then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function shooter:fire_weapon(user, def)
|
||||
minetest.sound_play(def.sound, {object=user})
|
||||
local target = {player=nil, distance=50}
|
||||
local p1 = user:getpos()
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local p2 = player:getpos()
|
||||
if p1 and p2 then
|
||||
local x = vector.distance(p1, p2)
|
||||
p2.y = p2.y - 0.75
|
||||
if x > 0 and x < target.distance and x < 50 then
|
||||
if in_range(def.range_func, x) == true then
|
||||
local v1 = user:get_look_dir()
|
||||
local v2 = vector.normalize(vector.direction(p1, p2))
|
||||
local vd = vector.subtract(v1, v2)
|
||||
local yx = 0.00002 * (x * x) - 0.002 * x + 0.05
|
||||
local yy = yx * 3
|
||||
if math.abs(vd.x) < yx and
|
||||
math.abs(vd.z) < yx and
|
||||
math.abs(vd.y) < yy then
|
||||
target = {
|
||||
player = player,
|
||||
distance = x,
|
||||
direction = v1,
|
||||
pos1 = {x=p1.x, z=p1.z, y=p1.y+1},
|
||||
pos2 = {x=p2.x, z=p2.z, y=p2.y+1.75},
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if target.player then
|
||||
if minetest.line_of_sight(target.pos1, target.pos2, 1) then
|
||||
target.player:punch(user, nil, def.tool_caps, target.direction)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
player:hud_set_flags({crosshair = true})
|
||||
end)
|
||||
|
BIN
sounds/shooter_pistol.ogg
Normal file
BIN
sounds/shooter_pistol.ogg
Normal file
Binary file not shown.
BIN
sounds/shooter_riffle.ogg
Normal file
BIN
sounds/shooter_riffle.ogg
Normal file
Binary file not shown.
BIN
textures/crosshair.png
Normal file
BIN
textures/crosshair.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 364 B |
BIN
textures/shooter_pistol.png
Normal file
BIN
textures/shooter_pistol.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 274 B |
BIN
textures/shooter_riffle.png
Normal file
BIN
textures/shooter_riffle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 420 B |
Loading…
Reference in a new issue