Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poisonous grenade #1091

Merged
merged 28 commits into from
Mar 2, 2023
Merged
Changes from 17 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4e4ee2c
adding poison grenade
farooqkz Feb 2, 2023
780802a
finally working \o/
farooqkz Feb 3, 2023
0700b81
making the linter happy
farooqkz Feb 3, 2023
c3581ef
not my job but okay...
farooqkz Feb 3, 2023
e4e335a
unwanted file
farooqkz Feb 3, 2023
03c3c20
revert
farooqkz Feb 3, 2023
2ebaf92
update maps submodule
farooqkz Feb 3, 2023
f9653c2
trying to do it with minetest.after
farooqkz Feb 4, 2023
4500179
self -> damage_fn
farooqkz Feb 7, 2023
67adb09
working \o/
farooqkz Feb 7, 2023
6c9456c
making the CI happy
farooqkz Feb 7, 2023
8de1317
fix bug when all objects(including non-players) are dmg'ed
farooqkz Feb 7, 2023
944b6c0
unnecessary line
farooqkz Feb 7, 2023
6f3675f
Merge branch 'MT-CTF:master' into poison
farooqkz Feb 9, 2023
ec58d9d
per suggestion
farooqkz Feb 9, 2023
48831fc
per request
farooqkz Feb 12, 2023
27a1ce6
fix
farooqkz Feb 12, 2023
838dde4
remove leftover code
farooqkz Feb 13, 2023
5c28401
improvement
farooqkz Feb 13, 2023
5d10bf9
betterway of getting team color
farooqkz Feb 13, 2023
623cfee
fix poison grenade get replaced by smoke grenade when thrown to flag
farooqkz Feb 27, 2023
80b7614
Merge branch 'poison' of github.com:farooqkz/capturetheflag into poison
farooqkz Feb 27, 2023
2178f42
no poison or smoke grenade too close to flags + reduced time for smok…
farooqkz Feb 27, 2023
ecf9d9f
make poison grenade more green
farooqkz Feb 27, 2023
abbda58
add poison grenade to treasure chests
farooqkz Feb 28, 2023
161d71f
fix bug when throwing near flags
farooqkz Feb 28, 2023
5e9900e
Update mods/pvp/grenades/grenades.lua per LW suggestion
farooqkz Mar 1, 2023
802b649
Update mods/pvp/grenades/grenades.lua per LV suggestion(better partic…
farooqkz Mar 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 116 additions & 64 deletions mods/pvp/grenades/grenades.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

local function remove_flora(pos, radius)
local pos1 = vector.subtract(pos, radius)
local pos2 = vector.add(pos, radius)
Expand Down Expand Up @@ -123,78 +124,129 @@ grenades.register_grenade("grenades:frag_sticky", fragdef_sticky)

local sounds = {}
local SMOKE_GRENADE_TIME = 30
grenades.register_grenade("grenades:smoke", {
description = "Smoke grenade (Generates smoke around blast site)",
image = "grenades_smoke_grenade.png",
on_collide = function()
return true
end,
on_explode = function(def, obj, pos, pname)
local player = minetest.get_player_by_name(pname)
if not player or not pos then return end

local pteam = ctf_teams.get(pname)
local register_smoke_grenade = function(name, description, image, damage)
grenades.register_grenade("grenades:"..name, {
description = description,
image = image,
on_collide = function()
return true
end,
on_explode = function(def, obj, pos, pname)
local player = minetest.get_player_by_name(pname)
if not player or not pos then return end

if pteam then
local fpos = ctf_map.current_map.teams[pteam].flag_pos
local pteam = ctf_teams.get(pname)

if not fpos then return end
if pteam then
local fpos = ctf_map.current_map.teams[pteam].flag_pos

if vector.distance(pos, fpos) <= 15 then
minetest.chat_send_player(pname, "You can't explode smoke grenades so close to your flag!")
player:get_inventory():add_item("main", "grenades:smoke")
return
if not fpos then return end

if vector.distance(pos, fpos) <= 15 then
minetest.chat_send_player(pname, "You can't explode smoke grenades so close to your flag!")
player:get_inventory():add_item("main", "grenades:smoke")
return
end
end
end

minetest.sound_play("grenades_glasslike_break", {
pos = pos,
gain = 1.0,
max_hear_distance = 32,
})
minetest.sound_play("grenades_glasslike_break", {
pos = pos,
gain = 1.0,
max_hear_distance = 32,
})

local hiss = minetest.sound_play("grenades_hiss", {
pos = pos,
gain = 1.0,
loop = true,
max_hear_distance = 32,
})
sounds[hiss] = true

minetest.after(SMOKE_GRENADE_TIME, function()
sounds[hiss] = nil
minetest.sound_stop(hiss)
end)

for i = 0, 5, 1 do
minetest.add_particlespawner({
amount = 40,
time = SMOKE_GRENADE_TIME + 3,
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 = 1,
maxexptime = 1,
minsize = 125,
maxsize = 140,
collisiondetection = false,
collision_removal = false,
vertical = false,
texture = "grenades_smoke.png^[noalpha",
local hiss = minetest.sound_play("grenades_hiss", {
pos = pos,
gain = 1.0,
loop = true,
max_hear_distance = 32,
})
end
end,
particle = {
image = "grenades_smoke.png",
life = 1,
size = 4,
glow = 0,
interval = 0.3,
}
})
sounds[hiss] = true
local stop = false
if damage then
local function damage_fn()
local online_players = minetest.get_connected_players()
local thrower = minetest.get_player_by_name(pname)
for _, object in pairs(online_players) do
if vector.distance(object:get_pos(), pos) <= 6 then
local dname = object:get_player_name()
local dteam = ctf_teams.get(dname)
if dname ~= pname and object:is_player() and dteam ~= pteam then
object:punch(thrower, 10, {
damage_groups = {
fleshy = 1,
poison = 1,
}
})
end
end
end
if not stop then
minetest.after(1, damage_fn)
end
end
farooqkz marked this conversation as resolved.
Show resolved Hide resolved
damage_fn()
end

minetest.after(SMOKE_GRENADE_TIME, function()
sounds[hiss] = nil
minetest.sound_stop(hiss)
minetest.remove_node(pos)
farooqkz marked this conversation as resolved.
Show resolved Hide resolved
stop = true
end)

local p = "grenades_smoke.png^["
local particletexture
if damage then
particletexture = p .. "colorize:" .. ctf_teams["team"][ctf_teams.get(pname)].color .. ":50"
farooqkz marked this conversation as resolved.
Show resolved Hide resolved
else
particletexture = p .. "noalpha"
end

for i = 0, 5, 1 do
minetest.add_particlespawner({
amount = 40,
time = SMOKE_GRENADE_TIME + 3,
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 = 1,
maxexptime = 1,
minsize = 125,
maxsize = 140,
collisiondetection = false,
collision_removal = false,
vertical = false,
texture = particletexture,
})
end
end,
particle = {
image = "grenades_smoke.png",
life = 1,
size = 4,
glow = 0,
interval = 0.3,
}
})
end

register_smoke_grenade(
"smoke",
"Smoke grenade (Generates smoke around blast site)",
"grenades_smoke_grenade.png",
false
)
register_smoke_grenade(
"poison",
"Poison grenade (Generates poisonous smoke around blast site)",
"grenades_smoke_grenade.png^[colorize:#001f00:90",
true
)

-- Flashbang Grenade

Expand Down