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
Show file tree
Hide file tree
Changes from all 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 mods/ctf/ctf_modes/ctf_mode_classes/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ ctf_modebase.register_mode("classes", {

["grenades:frag" ] = {rarity = 0.1, max_stacks = 1},
["grenades:smoke"] = {rarity = 0.2, max_stacks = 2},
["grenades:poison"] = {rarity = 0.1, max_stacks = 2},
},
crafts = {
"ctf_ranged:ammo", "default:axe_mese", "default:axe_diamond", "default:shovel_mese", "default:shovel_diamond",
Expand Down
1 change: 1 addition & 0 deletions mods/ctf/ctf_modes/ctf_mode_nade_fight/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ctf_modebase.register_mode("nade_fight", {
["ctf_healing:bandage" ] = { rarity = 0.08 , max_stacks = 2},

["grenades:smoke"] = {rarity = 0.2, max_stacks = 3},
["grenades:poison"] = {rarity = 0.1, max_stacks = 2},
},
crafts = {
"ctf_map:damage_cobble",
Expand Down
185 changes: 120 additions & 65 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,132 @@ 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

local pteam = ctf_teams.get(pname)
local duration_multiplier = 1
-- it gets multiplied with the default duration

if pteam then
for _, team in pairs(ctf_map.current_map.teams) do
if team.flag_pos then
local distance_from_flag = vector.distance(pos, team.flag_pos)
if distance_from_flag <= 15 then
minetest.chat_send_player(pname, "You can't explode smoke grenades so close to a flag!")
player:get_inventory():add_item("main", "grenades:"..name)
return
elseif distance_from_flag <= 25 then
duration_multiplier = 10 / distance_from_flag
end
end
end
end

if pteam then
local fpos = ctf_map.current_map.teams[pteam].flag_pos
minetest.sound_play("grenades_glasslike_break", {
pos = pos,
gain = 1.0,
max_hear_distance = 32,
})

if not fpos then return end
local hiss = minetest.sound_play("grenades_hiss", {
pos = pos,
gain = 1.0,
loop = true,
max_hear_distance = 32,
})
sounds[hiss] = true
local stop = false
if damage then
local function damage_fn()
local thrower = minetest.get_player_by_name(pname)
for _, target in pairs(minetest.get_connected_players()) do
if vector.distance(target:get_pos(), pos) <= 6 then
local dname = target:get_player_name()
local dteam = ctf_teams.get(dname)
if dname ~= pname and dteam ~= pteam then
target:punch(thrower, 10, {
damage_groups = {
fleshy = 1,
poison = 1,
}
})
end
end
end
if not stop then
minetest.after(1, damage_fn)
end
end
damage_fn()
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
minetest.after(SMOKE_GRENADE_TIME * duration_multiplier, function()
sounds[hiss] = nil
minetest.sound_stop(hiss)
stop = true
end)

local p = "grenades_smoke.png^["
local particletexture
if pteam and damage then
particletexture = p .. "colorize:" .. ctf_teams.team[pteam].color .. ":76^[noalpha"
else
particletexture = p .. "noalpha"
end
end

minetest.sound_play("grenades_glasslike_break", {
pos = pos,
gain = 1.0,
max_hear_distance = 32,
})
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

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",
})
end
end,
particle = {
image = "grenades_smoke.png",
life = 1,
size = 4,
glow = 0,
interval = 0.3,
}
})
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:#015f01:90",
true
)

-- Flashbang Grenade

Expand Down