I would like to get some idea how to create fire in 2D like Molotov Coctail does... I tried effect "fire" but thats too small and does not hurts you... any idea?
Forum
CS2D Scripts Making fireMaking fire
22 repliesI would like to get some idea how to create fire in 2D like Molotov Coctail does... I tried effect "fire" but thats too small and does not hurts you... any idea?
or
effect "fire"
Depends how you want to use the fire.
In map, it's as RisingXD said : you use env_hurt.
In script you can try
1
2
2
fire = {} fire.a = {X*32+16,Y*32+16}
P.S. is it even too small with amount set to maximum for fire effect ?
exactly i cannot set more amount because it's limited...
i would like to create a napalm MOD, but it's require enough fire... but currently its looks like impossible
anyways what should i use to make player health lower by seconds and distance?
1
2
3
4
5
2
3
4
5
--something simple like dmg = 25 -- Max damage dist = 15 -- current player distance range = 200 -- Max range of triggering print(dmg/(range/(range-dist)))
edited 1×, last 17.04.14 06:53:52 pm
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
function Distance(x1, y1, x2, y2) return math.floor(math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))) end addhook("second","gimme_a_sec") function gimme_a_sec() 	for _,id in pairs (player(0,"tableliving")) do 		if Distance(player(id,"x"),player(id,"y"),firex,firey)<33 then 			local damage = 6 -math.ceil(Distance(player(id,"x"),player(id,"y"),firex,firey)/6) 			parse("sethealth "..id.." "..player(id,"health")-damage) 		end 	end end
Where firex and firey are the positions of fire center. You can also use locals to shorten this but since I'm copy-pasting ...
P.S. You can change the damage calculation, it's entirely up to you. The hook can be changed too if you like.
edited 1×, last 17.04.14 08:26:46 pm
The ')' error I've edited. The message box here doesn't really show the tabbing clearly so it's easy to miss little details when you don't see the overall view..
nobody said you are blind
now finally the last error is:
LUA ERROR: sys/lua/napalms.lua:24: attempt to perform arithmetic on local 'x2' (a nil value)
x2 is exactly where firex is. You need to replace it!
P.S. I said that I was blind myself ;P It's an expression.
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
------------------------------ --** NAPALM MOD FOR CS2D **-- --** 2014. 03. 30. **-- ------------------------------ --- Support for Engin33r function napalm(id,x,y,power) if (player(id, "money") >= 1000 * power) then parse("setmoney "..id.." "..player(id, "money") - 1000 * power) parse("explosion "..x.." "..y.." "..power*100 .." "..power*10+10) parse("effect fire "..x.." "..y.." "..power*10000 .." "..power*90) 				parse("effect fire "..x.." "..y.." "..power*10000 .." "..power*90) 				parse("effect fire "..x.." "..y.." "..power*10000 .." "..power*90) 				parse("effect fire "..x.." "..y.." "..power*10000 .." "..power*90) 				parse("effect fire "..x.." "..y.." "..power*10000 .." "..power*90) else msg2(id, "You don't have enough money!") end end --- Support for Raining Mammoths function Distance(x1, y1, x2, y2) return math.floor(math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))) end addhook("second","gimme_a_sec") function gimme_a_sec() 	for _,id in pairs (player(0,"tableliving")) do 		if Distance(player(id,"x"),player(id,"y"),firex,firey)<33 then 			local damage = 6 -math.ceil(Distance(player(id,"x"),player(id,"y"),firex,firey)/6) 			parse("sethealth "..id.." "..player(id,"health")-damage) 		end 	end end function string.split(str,pat) local t = {} for word in string.gmatch(str, pat or "[^%s]+") do t[#t+1] = word end return t end addhook("say","GetNapalm") function GetNapalm(id,t) local cmd = t:split() if cmd[1] == "!napalm" then 		napalm(id, tonumber(cmd[3]), tonumber(cmd[4]), tonumber(cmd[2])) 		end end
Fire place is usually other everytime
edited 1×, last 19.04.14 08:45:24 am
@ Marcell: You still don't define firex and firey anywhere.
That napalm call is a bit weird,why would you mix up all those arguments ?
One more thing. Your napalm is called upon say hook. You do not set a permanent/temporary source of fire. It's momentary. The effect appears for a short while (about a second) and disappears, that's the end of it. Why would you want to have continuous fire damage if your napalm is momentary ?
EDIT : The amount is weird too. The maximum is 100, yet you do "power * 10000"
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
fire = {} function NewNapalm(id,x,y,lifetime) 	fire[#fire+1] = {} 	fire[#fire+1].x = x*32+16 -- X in tiles 	fire[#fire+1].y = y*32+16 -- Y in tiles 	fire[#fire+1].id = id -- ID of who made the napalm appear 	fire[#fire+1].lifetime = lifetime -- How long in seconds should napalm last end --- Support by* Raining Mammoths function Distance(x1, y1, x2, y2) 	return math.floor(math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))) end addhook("second","gimme_a_sec") function gimme_a_sec() 	for _,id in pairs (player(0,"tableliving")) do 		for k,v in pairs (fire) do 			local x = fire[k].x 			local y = fire[k].y 			if Distance(player(id,"x"),player(id,"y"),x,y)<33 then 				local damage = 6 -math.ceil(Distance(player(id,"x"),player(id,"y"),firex,firey)/6) 				if damage > player(id,"health") then 					parse("customkill "..fire[k].id.." napalm "..id) 				else 					parse("sethealth "..id.." "..player(id,"health")-damage) 				end 			end 			if fire[k].lifetime > 0 then 				fire[k].lifetime = fire[k].lifetime - 1 			else 				fire[k] = {} 			end 		end 	end end addhook("ms100","Yey_I_Discovered_Fire") function Yey_I_Discovered_Fire() 	for k,v in pairs (fire) do 		if fire[k].lifetime > 0 then 			parse("effect fire "..fire[k].x.." "..fire[k].y.." 100 100") 		end 	end end
I apologize in advance if this is totally wrong. I'm really unsure cause my brain can't think properly after reading books for school. I was doing exactly that before I wrote this.
I see you want to have explosions, add another argument for NewNapalm function and make the explosion there if you like...