I am working on a "little" grenade script, don't mind that is it, you will see it once it is ready.
first, I found a couple of bugs, that I can't seems to resolve or at least having difficulties find out a way do do.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
addhook("projectile_impact", "custom_he")
function custom_he(id, w, x, y, mode, projectileid)
for _,id in pairs(player(0, "table")) do
if w == 51 then -- The projectile is HE grenade
he = image(grenades[1]['path_img'], x, y, 0)
timer(grenades[1]['delay'], "removeGrenade")
function removeGrenade () -- remove grenade img
freeimage(he)
end
parse("freeprojectile " ..projectileid.. " " ..id) -- remove explosion
end
end
end
addhook("projectile_impact", "shrapnel")
function shrapnel(id, w, x, y, mode, projectileid)
if w == 51 then -- The projectile is HE grenade
timer(grenades[1]['delay'], "explodeGrenade")
function explodeGrenade()
for i = 2,10,2 do
timer(20*i,"parse","effect \"smoke\" " .. x .. " " .. y .. " 100 80")
end
local he_sound = grenades[1]['sound']
parse ("effect \"fire\" "..x.." "..y.." 25 5 0 0 0")
parse ("shake "..id.. " 10")
parse('sv_soundpos "'..grenades[1]['sound']..'" '..x..' '..y)
-- further damage scripts goes there...
end
else return false end
end
Another thing, I am wondering which would be a good way to cause the players nearby to get damage (including the src if close)
I was thinking maybe 2-3 tiles /2-3m/ from the core of the "explosion" would cause instant death, then the rest would get just some amount of damage.
yes, I know explosion can do that, but I would like to create some sort of custom damage with ranges and many more later.
before some smart guys comes, High Explosive grenades mostly causing deaths to 2-3 meters, depending on the type.
I apricate any help, even suggesting some better way to code.