English Making fire

22 replies
Goto Page
To the start Previous 1 2 Next To the start
17.04.14 04:41:37 pm
Up
Marcell
Super User
Offline Off
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?
CS2DArchive - Version Database www.CS2DArchive.com - WebHosting: www.BroHosting.eu
17.04.14 04:47:40 pm
Up
RisingXD
User
Offline Off
In maps? Use Hurt.
Rising XD: Say Hello to my little friend! (M249) & [bot]Adon-is-gay AWP Rising & [bot]Adon-is-gay: Nope.
17.04.14 04:58:55 pm
Up
Rainoth
Moderator
Offline Off
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

Code:
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 ?
17.04.14 05:06:05 pm
Up
Marcell
Super User
Offline Off
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
CS2DArchive - Version Database www.CS2DArchive.com - WebHosting: www.BroHosting.eu
17.04.14 05:07:55 pm
Up
Rainoth
Moderator
Offline Off
why don't you do multiple fire effects, then ?
17.04.14 05:26:53 pm
Up
Marcell
Super User
Offline Off
I dont tried that, but i will..
anyways what should i use to make player health lower by seconds and distance?
CS2DArchive - Version Database www.CS2DArchive.com - WebHosting: www.BroHosting.eu
17.04.14 05:46:09 pm
Up
Rainoth
Moderator
Offline Off
Do you mean that the closer the person is to fire, the more damage he receives ?
17.04.14 06:14:40 pm
Up
Marcell
Super User
Offline Off
Yeah, exactly what you saying
CS2DArchive - Version Database www.CS2DArchive.com - WebHosting: www.BroHosting.eu
17.04.14 06:52:17 pm
Up
VADemon
User
Offline Off
@user Marcell:
Code:
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
edited 1×, last 17.04.14 06:53:52 pm
17.04.14 06:52:19 pm
Up
Rainoth
Moderator
Offline Off
Code:
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.
edited 1×, last 17.04.14 08:26:46 pm
17.04.14 08:02:38 pm
Up
Marcell
Super User
Offline Off
Tried it, but something wrong with ")" and your pasted lua has no end
CS2DArchive - Version Database www.CS2DArchive.com - WebHosting: www.BroHosting.eu
17.04.14 08:29:02 pm
Up
Rainoth
Moderator
Offline Off
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..
17.04.14 08:41:20 pm
Up
Marcell
Super User
Offline Off
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)
CS2DArchive - Version Database www.CS2DArchive.com - WebHosting: www.BroHosting.eu
17.04.14 09:03:17 pm
Up
Rainoth
Moderator
Offline Off
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.
17.04.14 09:10:52 pm
Up
Marcell
Super User
Offline Off
Code:
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
CS2DArchive - Version Database www.CS2DArchive.com - WebHosting: www.BroHosting.eu
17.04.14 09:46:08 pm
Up
VADemon
User
Offline Off
Bullshit, was too sleepy >
edited 1×, last 19.04.14 08:45:24 am
17.04.14 09:50:25 pm
Up
Marcell
Super User
Offline Off
what are you talking about? thats totally same
CS2DArchive - Version Database www.CS2DArchive.com - WebHosting: www.BroHosting.eu
17.04.14 09:52:49 pm
Up
Rainoth
Moderator
Offline Off
@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"
17.04.14 09:56:52 pm
Up
Marcell
Super User
Offline Off
@user Rainoth: I dunno... i am cunfused
CS2DArchive - Version Database www.CS2DArchive.com - WebHosting: www.BroHosting.eu
17.04.14 10:15:14 pm
Up
Rainoth
Moderator
Offline Off
Code:
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...
To the start Previous 1 2 Next To the start