mirror of
https://github.com/LoneWolfHT/grenades.git
synced 2024-11-22 06:43:45 +01:00
Flashbangs only flash you if you are looking at the explosion pos. May be buggy
This commit is contained in:
parent
1a16126f63
commit
e67f8cc2f1
29
grenades.lua
29
grenades.lua
@ -39,20 +39,25 @@ if settings:get_bool("enable_flashbang_grenade") then
|
|||||||
description = "A flashbang grenade (Blinds all who look at the explosion)",
|
description = "A flashbang grenade (Blinds all who look at the explosion)",
|
||||||
image = "grenades_flashbang.png",
|
image = "grenades_flashbang.png",
|
||||||
on_explode = function(pos, player, self)
|
on_explode = function(pos, player, self)
|
||||||
for k, v in ipairs(minetest.get_objects_inside_radius(pos, 6)) do
|
for k, v in ipairs(minetest.get_objects_inside_radius(pos, 15)) do
|
||||||
if v:is_player() and v:get_hp() > 0 then
|
if v:is_player() and v:get_hp() > 0 then
|
||||||
for i = 1, 3, 1 do
|
local playerdir = vector.floor(vector.normalize(v:get_look_dir()))
|
||||||
local key = v:hud_add({
|
local grenadedir = vector.floor(vector.normalize(vector.direction(v:get_pos(), pos)))
|
||||||
hud_elem_type = "image",
|
|
||||||
position = {x=0, 0},
|
|
||||||
name = "death_list_hud",
|
|
||||||
scale = {x=1000, y=1000},
|
|
||||||
text = "grenades_white_"..tostring(i)..".png",
|
|
||||||
alignment = {x=0, y=0},
|
|
||||||
offset = {x=0, y=0}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.after(4*i, function() v:hud_remove(key) end)
|
if playerdir.x == grenadedir.x and playerdir.z == grenadedir.z then
|
||||||
|
for i = 1, 3, 1 do
|
||||||
|
local key = v:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x=0, 0},
|
||||||
|
name = "death_list_hud",
|
||||||
|
scale = {x=1000, y=1000},
|
||||||
|
text = "grenades_white_"..tostring(i)..".png",
|
||||||
|
alignment = {x=0, y=0},
|
||||||
|
offset = {x=0, y=0}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.after(4*i, function() v:hud_remove(key) end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user