Update mod
18
.luacheckrc
Normal file
@ -0,0 +1,18 @@
|
||||
unused_args = false
|
||||
allow_defined_top = true
|
||||
|
||||
globals = {
|
||||
"minetest", "grenades"
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
string = {fields = {"split"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
|
||||
-- Builtin
|
||||
"vector", "ItemStack",
|
||||
"dump", "DIR_DELIM", "VoxelArea", "Settings",
|
||||
|
||||
-- MTG
|
||||
"default", "sfinv", "creative",
|
||||
}
|
78
crafts.lua
@ -1,13 +1,29 @@
|
||||
if not minetest.get_modpath("ctf_crafting") then
|
||||
-- Regular Grenade
|
||||
local gunpowder = "grenades_basic:gun_power"
|
||||
|
||||
if not minetest.get_modpath("tnt") then
|
||||
minetest.register_craftitem("grenades_basic:gun_powder", {
|
||||
description = "A dark powder used for crafting some grenades",
|
||||
inventory_image = "grenades_basic_gun_powder.png"
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "grenades_basic:gun_powder",
|
||||
recipe = {"default:coal_lump", "default:coal_lump", "default:coal_lump", "default:coal_lump"},
|
||||
})
|
||||
else
|
||||
gunpowder = "tnt:gunpowder"
|
||||
end
|
||||
|
||||
-- Frag Grenade
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shaped",
|
||||
output = "grenades_basic:regular",
|
||||
output = "grenades_basic:frag",
|
||||
recipe = {
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"default:steel_ingot", "default:coal_lump", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
|
||||
{"default:obsidian_shard", "default:steel_ingot", "default:obsidian_shard"},
|
||||
{"default:steel_ingot", gunpowder, "default:steel_ingot"},
|
||||
{"default:obsidian_shard", "default:steel_ingot", "default:obsidian_shard"}
|
||||
},
|
||||
})
|
||||
|
||||
@ -17,9 +33,9 @@ if not minetest.get_modpath("ctf_crafting") then
|
||||
type = "shaped",
|
||||
output = "grenades_basic:smoke",
|
||||
recipe = {
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"default:steel_ingot", "grenades_basic:gun_powder", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
|
||||
{"default:coal_lump", "default:steel_ingot", "default:coal_lump"},
|
||||
{"default:steel_ingot", gunpowder, "default:steel_ingot"},
|
||||
{"default:coal_lump", "default:steel_ingot", "default:coal_lump"}
|
||||
}
|
||||
})
|
||||
|
||||
@ -29,46 +45,8 @@ if not minetest.get_modpath("ctf_crafting") then
|
||||
type = "shaped",
|
||||
output = "grenades_basic:flashbang",
|
||||
recipe = {
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"default:steel_ingot", "default:torch", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
|
||||
{"default:steel_ingot", "default:mese_crystal", "default:steel_ingot"},
|
||||
{"default:steel_ingot", gunpowder, "default:steel_ingot"},
|
||||
{"", "default:steel_ingot", ""}
|
||||
},
|
||||
})
|
||||
|
||||
-- Other
|
||||
|
||||
minetest.register_craftitem("grenades_basic:gun_powder", {
|
||||
description = "A dark powder used for crafting some grenades",
|
||||
inventory_image = "grenades_gun_powder.png"
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "grenades_basic:gun_powder",
|
||||
recipe = {"default:coal_lump", "default:coal_lump", "default:coal_lump", "default:coal_lump"},
|
||||
})
|
||||
else
|
||||
crafting.register_recipe({
|
||||
type = "inv",
|
||||
output = "grenades_basic:regular 1",
|
||||
items = { "default:steel_ingot 5", "default:iron_lump" },
|
||||
always_known = true,
|
||||
level = 1,
|
||||
})
|
||||
|
||||
crafting.register_recipe({
|
||||
type = "inv",
|
||||
output = "grenades_basic:smoke 1",
|
||||
items = { "default:steel_ingot 5", "default:coal_lump 4" },
|
||||
always_known = true,
|
||||
level = 1,
|
||||
})
|
||||
|
||||
crafting.register_recipe({
|
||||
type = "inv",
|
||||
output = "grenades_basic:flashbang 1",
|
||||
items = { "default:steel_ingot 5", "default:torch 5" },
|
||||
always_known = true,
|
||||
level = 1,
|
||||
})
|
||||
end
|
||||
|
88
init.lua
@ -1,17 +1,23 @@
|
||||
local function remove_flora(pos, radius)
|
||||
local function blast(pos, radius)
|
||||
local pos1 = vector.subtract(pos, radius)
|
||||
local pos2 = vector.add(pos, radius)
|
||||
|
||||
for _, p in ipairs(minetest.find_nodes_in_area(pos1, pos2, "group:flora")) do
|
||||
for _, p in ipairs(minetest.find_nodes_in_area(pos1, pos2, {"group:flora", "group:dig_immediate"})) do
|
||||
if vector.distance(pos, p) <= radius then
|
||||
local node = minetest.get_node(p).name
|
||||
|
||||
if node ~= "air" then
|
||||
minetest.add_item(p, node)
|
||||
end
|
||||
|
||||
minetest.remove_node(p)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
grenades.register_grenade("grenades_basic:regular", {
|
||||
description = "Regular grenade (Kills anyone near blast)",
|
||||
image = "grenades_regular.png",
|
||||
grenades.register_grenade("grenades_basic:frag", {
|
||||
description = "Frag grenade (Kills anyone near blast)",
|
||||
image = "grenades_basic_frag.png",
|
||||
on_explode = function(pos, name)
|
||||
if not name or not pos then
|
||||
return
|
||||
@ -37,23 +43,37 @@ grenades.register_grenade("grenades_basic:regular", {
|
||||
collisiondetection = true,
|
||||
collision_removal = false,
|
||||
vertical = false,
|
||||
texture = "grenades_smoke.png",
|
||||
texture = "grenades_basic_smoke.png",
|
||||
})
|
||||
|
||||
minetest.sound_play("boom", {
|
||||
minetest.add_particle({
|
||||
pos = pos,
|
||||
velocity = {x=0, y=0, z=0},
|
||||
acceleration = {x=0, y=0, z=0},
|
||||
expirationtime = 0.3,
|
||||
size = 15,
|
||||
collisiondetection = false,
|
||||
collision_removal = false,
|
||||
object_collision = false,
|
||||
vertical = false,
|
||||
texture = "grenades_basic_boom.png",
|
||||
glow = 10
|
||||
})
|
||||
|
||||
minetest.sound_play("grenades_basic_explode", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 32,
|
||||
max_hear_distance = 64,
|
||||
})
|
||||
|
||||
remove_flora(pos, radius)
|
||||
blast(pos, radius/2)
|
||||
|
||||
for _, v in ipairs(minetest.get_objects_inside_radius(pos, radius)) do
|
||||
local hit = minetest.raycast(pos, v:get_pos(), true, true):next()
|
||||
|
||||
if hit and v:is_player() and v:get_hp() > 0 and hit.type == "object" and hit.ref:is_player() and
|
||||
hit.ref:get_player_name() == v:get_player_name() then
|
||||
v:punch(player, 2, {damage_groups = {fleshy = 26 - (vector.distance(pos, v:get_pos()) * 2)}}, nil)
|
||||
v:punch(player, 2, {damage_groups = {grenade = 1, fleshy = 90 * 0.71 ^ vector.distance(pos, v:get_pos())}}, nil)
|
||||
end
|
||||
end
|
||||
end,
|
||||
@ -65,7 +85,7 @@ local flash_huds = {}
|
||||
|
||||
grenades.register_grenade("grenades_basic:flashbang", {
|
||||
description = "Flashbang grenade (Blinds all who look at blast)",
|
||||
image = "grenades_flashbang.png",
|
||||
image = "grenades_basic_flashbang.png",
|
||||
clock = 4,
|
||||
on_explode = function(pos)
|
||||
for _, v in ipairs(minetest.get_objects_inside_radius(pos, 20)) do
|
||||
@ -77,7 +97,7 @@ grenades.register_grenade("grenades_basic:flashbang", {
|
||||
local grenadedir = vector.round(vector.direction(v:get_pos(), pos))
|
||||
local pname = v:get_player_name()
|
||||
|
||||
minetest.sound_play("glasslike_break", {
|
||||
minetest.sound_play("grenades_basic_glasslike_break", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 32,
|
||||
@ -92,7 +112,7 @@ grenades.register_grenade("grenades_basic:flashbang", {
|
||||
position = {x = 0, y = 0},
|
||||
name = "flashbang hud "..pname,
|
||||
scale = {x = -200, y = -200},
|
||||
text = "grenades_white.png^[opacity:"..tostring(255 - (i * 20)),
|
||||
text = "default_cloud.png^[colorize:white:255^[opacity:"..tostring(255 - (i * 20)),
|
||||
alignment = {x = 0, y = 0},
|
||||
offset = {x = 0, y = 0}
|
||||
})
|
||||
@ -132,48 +152,62 @@ minetest.register_on_dieplayer(function(player)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
|
||||
if flash_huds[name] then
|
||||
for _, v in ipairs(flash_huds[name]) do
|
||||
player:hud_remove(v)
|
||||
end
|
||||
|
||||
flash_huds[name] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
-- Smoke Grenade
|
||||
|
||||
grenades.register_grenade("grenades_basic:smoke", {
|
||||
description = "Smoke grenade (Generates smoke around blast site)",
|
||||
image = "grenades_smoke_grenade.png",
|
||||
clock = 2,
|
||||
image = "grenades_basic_smoke_grenade.png",
|
||||
on_explode = function(pos)
|
||||
minetest.sound_play("glasslike_break", {
|
||||
minetest.sound_play("grenades_basic_glasslike_break", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 32,
|
||||
})
|
||||
|
||||
minetest.sound_play("hiss", {
|
||||
local hiss = minetest.sound_play("grenades_basic_hiss", {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
loop = true,
|
||||
max_hear_distance = 32,
|
||||
})
|
||||
|
||||
minetest.after(40, minetest.sound_stop, hiss)
|
||||
|
||||
for i = 0, 5, 1 do
|
||||
minetest.add_particlespawner({
|
||||
amount = 30,
|
||||
time = 11,
|
||||
minpos = vector.subtract(pos, 3),
|
||||
maxpos = vector.add(pos, 3),
|
||||
amount = 40,
|
||||
time = 45,
|
||||
minpos = vector.subtract(pos, 2),
|
||||
maxpos = vector.add(pos, 2),
|
||||
minvel = {x = 0, y = 2, z = 0},
|
||||
maxvel = {x = 0, y = 3, z = 0},
|
||||
minacc = {x = 1, y = 0.2, z = 1},
|
||||
maxacc = {x = 1, y = 0.2, z = 1},
|
||||
minexptime = 0.3,
|
||||
maxexptime = 0.5,
|
||||
minsize = 90,
|
||||
maxsize = 100,
|
||||
minexptime = 1,
|
||||
maxexptime = 1,
|
||||
minsize = 125,
|
||||
maxsize = 140,
|
||||
collisiondetection = false,
|
||||
collision_removal = false,
|
||||
vertical = false,
|
||||
texture = "grenades_smoke.png",
|
||||
texture = "grenades_basic_smoke.png",
|
||||
})
|
||||
end
|
||||
end,
|
||||
particle = {
|
||||
image = "grenades_smoke.png",
|
||||
image = "grenades_basic_smoke.png",
|
||||
life = 1,
|
||||
size = 4,
|
||||
glow = 0,
|
||||
|
BIN
sounds/boom.ogg
BIN
sounds/grenades_basic_explode.ogg
Normal file
BIN
sounds/grenades_basic_hiss.ogg
Normal file
BIN
sounds/hiss.ogg
@ -1,4 +1,5 @@
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
for grenades_glasslike_break.ogg and grenades_hiss.ogg
|
||||
|
||||
Copyright (c) 2019 LoneWolfHT
|
||||
|
||||
@ -95,3 +96,38 @@ Section 8 – Interpretation.
|
||||
To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
|
||||
=====================
|
||||
=====================
|
||||
=====================
|
||||
|
||||
CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
||||
for grenades_explode.ogg
|
||||
TumeniNodes
|
||||
steveygos93
|
||||
theneedle.tv
|
||||
frankelmedico
|
||||
|
||||
No Copyright
|
||||
|
||||
The person who associated a work with this deed has dedicated the work to the public domain
|
||||
by waiving all of his or her rights to the work worldwide under copyright law, including all
|
||||
related and neighboring rights, to the extent allowed by law.
|
||||
|
||||
You can copy, modify, distribute and perform the work, even for commercial purposes, all
|
||||
without asking permission. See Other Information below.
|
||||
|
||||
In no way are the patent or trademark rights of any person affected by CC0, nor are the
|
||||
rights that other persons may have in the work or in how the work is used, such as publicity
|
||||
or privacy rights.
|
||||
|
||||
Unless expressly stated otherwise, the person who associated a work with this deed makes no
|
||||
warranties about the work, and disclaims liability for all uses of the work, to the fullest
|
||||
extent permitted by applicable law.
|
||||
|
||||
When using or citing the work, you should not imply endorsement by the author or the affirmer.
|
||||
|
||||
This license is acceptable for Free Cultural Works.
|
||||
For more Information:
|
||||
https://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
|
BIN
textures/grenades_basic_boom.png
Normal file
After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 213 B |
Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 225 B |
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 180 B |
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 172 B After Width: | Height: | Size: 172 B |
Before Width: | Height: | Size: 102 B |