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 4 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
1 change: 1 addition & 0 deletions ctf_git
37 changes: 35 additions & 2 deletions mods/ctf/ctf_map/ctf_traps.lua
Original file line number Diff line number Diff line change
@@ -80,15 +80,20 @@ for _, team in ipairs(ctf_teams.teamlist) do
paramtype2 = "meshoptions",
sunlight_propagates = true,
walkable = false,
damage_per_second = 7,
damage_per_second = 1,
groups = {cracky=1, level=2},
drop = "ctf_map:spike",
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_place = function(itemstack, placer, pointed_thing)
return minetest.item_place(itemstack, placer, pointed_thing, 34)
local itemstack_, pos = minetest.item_place(itemstack, placer, pointed_thing, 34)
if placer then
local meta = minetest.get_meta(pos)
meta:set_string("placer", placer:get_player_name())
end
return itemstack_, pos
end
})
end
@@ -100,6 +105,34 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
if team and reason.node == string.format("ctf_map:spike_%s", team) then
return 0, true
end
local pattern = "ctf_map:spike_"
if string.sub(reason.node, 1, string.len(pattern)) == pattern then
-- I'm assuming the spike and the player will be
-- in the same position
local pos = player:get_pos()
pos["x"] = math.floor(pos["x"])
pos["y"] = math.floor(pos["y"])
pos["z"] = math.floor(pos["z"])
local meta = minetest.get_meta(pos)
local placer_name = meta:get_string("placer")
local spike_team = string.sub(reason.node, string.len(pattern) + 1, -1)
if placer_name then
minetest.chat_send_all(placer_name)
minetest.chat_send_all(spike_team)
minetest.chat_send_all(minetest.serialize(placer_name == ""))
end
if placer_name ~= "" and ctf_teams.get(placer_name) ~= spike_team then

minetest.chat_send_all(placer_name)
local placer = minetest.get_player_by_name(placer_name)
player:punch(placer, 10, {
damage_groups = {
spike = 1,
fleshy = 6
}
})
end
end
end

return hp_change
195 changes: 131 additions & 64 deletions mods/pvp/grenades/grenades.lua
Original file line number Diff line number Diff line change
@@ -123,78 +123,145 @@ 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)
minetest.register_node("grenades:poison_plant", {
drawtype = "airlike",
walkable = false,
pointable = false,
diggable = false,
})

if pteam then
local fpos = ctf_map.current_map.teams[pteam].flag_pos
minetest.register_abm({
label = "poisoning",
nodenames = {"grenades:poison_plant"},
interval = 3,
chance = 100/90,
catch_up = false,
action = function(pos, node, active_object_count, w_active_object_count)
local meta = minetest.get_meta(pos)
local thrower_name = meta:get_string("thrower")
local thrower = minetest.get_player_by_name(thrower_name)
local team = meta:get_string("thrower_team")
local objects = minetest.get_objects_inside_radius(pos, 7)
for _, object in pairs(objects) do
local pname = object:get_player_name()
if pname ~= "" and team ~= ctf_teams.get(pname) and pname ~= thrower_name then
local damagee = minetest.get_player_by_name(pname)
if damagee then
damagee:punch(thrower, 10, {
damage_groups = {
fleshy = 4,
poison = 1,
},
})
end
end
end
end
})

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

local pteam = ctf_teams.get(pname)

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

if not fpos then return end
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
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
if damage then
minetest.set_node(pos, { name = "grenades:poison_plant" })
local meta = minetest.get_meta(pos)
meta:set_string("thrower", pname)
meta:set_string("thrower_team", ctf_teams.get(pname))
end

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

local p = "grenades_smoke.png^["
local particletexture
if damage then
particletexture = p .. "colorize:" .. ctf_teams["team"][ctf_teams.get(pname)].color .. ":50"
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