Separate weapons and API
Use less generic mod names to avoid conflicts
This commit is contained in:
parent
0533d52142
commit
edb19cf061
68 changed files with 134 additions and 102 deletions
2
shooter_guns/depends.txt
Normal file
2
shooter_guns/depends.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
tnt
|
||||
shooter
|
134
shooter_guns/init.lua
Normal file
134
shooter_guns/init.lua
Normal file
|
@ -0,0 +1,134 @@
|
|||
shooter:register_weapon("shooter_guns:pistol", {
|
||||
description = "Pistol",
|
||||
inventory_image = "shooter_pistol.png",
|
||||
rounds = 200,
|
||||
spec = {
|
||||
range = 100,
|
||||
step = 20,
|
||||
tool_caps = {full_punch_interval=0.5, damage_groups={fleshy=2}},
|
||||
groups = {snappy=3, fleshy=3, oddly_breakable_by_hand=3},
|
||||
sound = "shooter_pistol",
|
||||
particle = "shooter_cap.png",
|
||||
},
|
||||
})
|
||||
|
||||
shooter:register_weapon("shooter_guns:rifle", {
|
||||
description = "Rifle",
|
||||
inventory_image = "shooter_rifle.png",
|
||||
rounds = 100,
|
||||
spec = {
|
||||
range = 200,
|
||||
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},
|
||||
sound = "shooter_rifle",
|
||||
particle = "shooter_bullet.png",
|
||||
},
|
||||
})
|
||||
|
||||
shooter:register_weapon("shooter_guns:shotgun", {
|
||||
description = "Shotgun",
|
||||
inventory_image = "shooter_shotgun.png",
|
||||
rounds = 50,
|
||||
spec = {
|
||||
range = 50,
|
||||
step = 15,
|
||||
tool_caps = {full_punch_interval=1.5, damage_groups={fleshy=4}},
|
||||
groups = {cracky=3, snappy=2, crumbly=2, choppy=2, fleshy=1, oddly_breakable_by_hand=1},
|
||||
sound = "shooter_shotgun",
|
||||
particle = "smoke_puff.png",
|
||||
},
|
||||
})
|
||||
|
||||
shooter:register_weapon("shooter_guns:machine_gun", {
|
||||
description = "Sub Machine Gun",
|
||||
inventory_image = "shooter_smgun.png",
|
||||
rounds = 50,
|
||||
shots = 4,
|
||||
spec = {
|
||||
range = 100,
|
||||
step = 20,
|
||||
tool_caps = {full_punch_interval=0.125, damage_groups={fleshy=2}},
|
||||
groups = {snappy=3, fleshy=3, oddly_breakable_by_hand=3},
|
||||
sound = "shooter_pistol",
|
||||
particle = "shooter_cap.png",
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("shooter_guns:ammo", {
|
||||
description = "Ammo pack",
|
||||
inventory_image = "shooter_ammo.png",
|
||||
})
|
||||
|
||||
if SHOOTER_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 = {
|
||||
{"shooter_guns:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"", "default:bronze_ingot", "default:mese_crystal"},
|
||||
{"", "default:bronze_ingot", ""},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "shooter_guns:ammo",
|
||||
recipe = {
|
||||
{"tnt:gunpowder", "default:bronze_ingot"},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
local rounds_update_time = 0
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
shooter.time = shooter.time + dtime
|
||||
if shooter.time - rounds_update_time > SHOOTER_ROUNDS_UPDATE_TIME then
|
||||
for i, round in ipairs(shooter.rounds) do
|
||||
if shooter:process_round(round) or round.dist > round.def.range then
|
||||
table.remove(shooter.rounds, i)
|
||||
else
|
||||
local v = vector.multiply(round.ray, round.def.step)
|
||||
shooter.rounds[i].pos = vector.add(round.pos, v)
|
||||
shooter.rounds[i].dist = round.dist + round.def.step
|
||||
end
|
||||
end
|
||||
rounds_update_time = shooter.time
|
||||
end
|
||||
if shooter.time > 100000 then
|
||||
shooter.shots = {}
|
||||
rounds_update_time = 0
|
||||
shooter.reload_time = 0
|
||||
shooter.update_time = 0
|
||||
shooter.time = 0
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
--Backwards compatibility
|
||||
minetest.register_alias("shooter:shotgun", "shooter_guns:shotgun")
|
||||
minetest.register_alias("shooter:pistol", "shooter_guns:pistol")
|
||||
minetest.register_alias("shooter:machine_gun", "shooter_guns:machine_gun")
|
||||
minetest.register_alias("shooter:rifle", "shooter_guns:rifle")
|
||||
minetest.register_alias("shooter:ammo", "shooter_guns:ammo")
|
BIN
shooter_guns/sounds/shooter_pistol.ogg
Normal file
BIN
shooter_guns/sounds/shooter_pistol.ogg
Normal file
Binary file not shown.
BIN
shooter_guns/sounds/shooter_rifle.ogg
Normal file
BIN
shooter_guns/sounds/shooter_rifle.ogg
Normal file
Binary file not shown.
BIN
shooter_guns/sounds/shooter_shotgun.ogg
Normal file
BIN
shooter_guns/sounds/shooter_shotgun.ogg
Normal file
Binary file not shown.
BIN
shooter_guns/textures/shooter_ammo.png
Normal file
BIN
shooter_guns/textures/shooter_ammo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 268 B |
BIN
shooter_guns/textures/shooter_pistol.png
Normal file
BIN
shooter_guns/textures/shooter_pistol.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 274 B |
BIN
shooter_guns/textures/shooter_rifle.png
Normal file
BIN
shooter_guns/textures/shooter_rifle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 420 B |
BIN
shooter_guns/textures/shooter_shotgun.png
Normal file
BIN
shooter_guns/textures/shooter_shotgun.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 402 B |
BIN
shooter_guns/textures/shooter_smgun.png
Normal file
BIN
shooter_guns/textures/shooter_smgun.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 289 B |
Loading…
Add table
Add a link
Reference in a new issue