Forum

> > CS2D > Scripts > Making fire
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Making fire

22 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Making fire

Marcell
Super User Off Offline

Zitieren
Hi,

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?

alt Re: Making fire

Rainoth
Moderator Off Offline

Zitieren
Gen_FX > Fire
or
effect "fire"

Depends how you want to use the fire.
In map, it's as user RisingXD said : you use env_hurt.

In script you can try

1
2
fire = {}
fire.a = {X*32+16,Y*32+16}
or something similar, doesn't really matter. Then you calculate distance between player and fire and if it's small enough, reduce the player's health.

P.S. is it even too small with amount set to maximum for fire effect ?

alt Re: Making fire

Marcell
Super User Off Offline

Zitieren
No, not a map... a script...

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

alt Re: Making fire

Marcell
Super User Off Offline

Zitieren
I dont tried that, but i will..
anyways what should i use to make player health lower by seconds and distance?

alt Re: Making fire

Rainoth
Moderator Off Offline

Zitieren
Do you mean that the closer the person is to fire, the more damage he receives ?

alt Re: Making fire

VADemon
User Off Offline

Zitieren
@user Marcell:
1
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)))
http://www.lua.org/cgi-bin/demo
1× editiert, zuletzt 17.04.14 18:53:52

alt Re: Making fire

Rainoth
Moderator Off Offline

Zitieren
1
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.
1× editiert, zuletzt 17.04.14 20:26:46

alt Re: Making fire

Marcell
Super User Off Offline

Zitieren
Tried it, but something wrong with ")" and your pasted lua has no end

alt Re: Making fire

Rainoth
Moderator Off Offline

Zitieren
I'm probably blind but I'm fairly sure that I've placed all ENDs ._.
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..

alt Re: Making fire

Marcell
Super User Off Offline

Zitieren
I mean thats why has no end because of ")"...
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)

alt Re: Making fire

Rainoth
Moderator Off Offline

Zitieren
Did you replace "firex" and "firey" variables ? They're there just for example, you have to replace them with pixels of where the fire is supposed to work.

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.

alt Re: Making fire

Marcell
Super User Off Offline

Zitieren
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
------------------------------
--**  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

alt Re: Making fire

Rainoth
Moderator Off Offline

Zitieren
@user VADemon: Are you sure..?
@user 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"

alt Re: Making fire

Rainoth
Moderator Off Offline

Zitieren
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
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...
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht