Page 1 of 3

Forest fires gadget

Posted: 01 Nov 2011, 23:24
by Jools
I was thinking of making a gadget that let's trees cacthc fire and let the fires spread to nearby trees.

Curerently I envisaged the following work flow:
- Catch trees dead in FeatureDestroyed Callin
- Spawn a CEG that looks like fire and smoke
- Make units nearby become damaged by it
- Manage the spreding of the fire

All that is cool and doable, but is there not a better way? Like using a default fire ceg that also handles the damages effect. Seems I'm inventing the wheel here.

Also, it would be nice to be able to start the fire before the tree has been destroyed, is there really no FeatureDamaged callin? Workaround: make the tree feature an unit? Or better ideas?

Re: Forest fires gadget

Posted: 01 Nov 2011, 23:26
by smoth
cegs are not damage dealing..

use a weapon...

I did some hacky shit like this for TD(videos on youtube), CA took it and did their fire code for units on fire...

Re: Forest fires gadget

Posted: 01 Nov 2011, 23:32
by knorke
smoth wrote:cegs are not damage dealing..
use a weapon...
use Spring.SetFeatureHealth or Spring.DestroyFeature

Re: Forest fires gadget

Posted: 01 Nov 2011, 23:44
by Jools
Yes, for killing the feature, but all that is moot if I can't catch the feature being damaged before it's desroyed. Units have a UnitdDamaged callin, but there seems to be no equivalent for features.

Or maybe just monitor all features (7000 in the map) in gameframe and do something when the health changes. Would be really slow I guess.

Re: Forest fires gadget

Posted: 01 Nov 2011, 23:50
by smoth
no that is silly.

do ceg, any features near by within burn distance..?

yes?

add to table of features..

only cycle that table.

Re: Forest fires gadget

Posted: 02 Nov 2011, 00:09
by knorke
in 0.83 FeatureDestroyed gets some more parameters so you can ie tell how a feature was destroyed. Some other advances too iirc. Maybe have a look if there is something else added that is helpful.
For now I'd do as in your first post except of using CEG for damage use Spring.SetFeatureHealth or Spring.DestroyFeature.
Yes, for killing the feature, but all that is moot if I can't catch the feature being damaged before it's desroyed.
That is only a problem for the starting of the fire: Atm you can only start the fire when a feature gets destroyed, not on damage. (beside watching explosions or something)
But for the spreading/burning you deal the damage yourself so there is no need for FeatureDamaged() in that case.

Re: Forest fires gadget

Posted: 02 Nov 2011, 00:43
by Jools
That's correct. I just wanted to have it possible that several trees burn at the same time, or that fires spread before the tree is completely destroyed, but maybe this is an acceptable compromise anyway (many simultaneous fires cause lag).

Is there a way of knowing the current windspeed and direction? Lua_Constgame has max and min, but no direction.

Re: Forest fires gadget

Posted: 02 Nov 2011, 00:48
by knorke
Spring.GetWind
y u no bookmark http://springrts.com/wiki/Lua_Scripting

Re: Forest fires gadget

Posted: 02 Nov 2011, 02:30
by luckywaldo7
Because he can just ask in the forum and have you look it up for him.

Also, was this feature lost somewhere over the years? http://www.youtube.com/watch?v=NyrzagbyXas

Re: Forest fires gadget

Posted: 02 Nov 2011, 05:06
by MidKnight
luckywaldo7 wrote:Because he can just ask in the forum and have you look it up for him.

Also, was this feature lost somewhere over the years? http://www.youtube.com/watch?v=NyrzagbyXas
That was the first thing I thought of after reading the thread title. :-)

Re: Forest fires gadget

Posted: 02 Nov 2011, 06:02
by jK
Nah, he wants to add it for general features while the engine forest fires are just supported by native trees (:= engine drawn ones).
There is for a very long time the request to extend this via a featuredef tag.

Re: Forest fires gadget

Posted: 02 Nov 2011, 06:33
by Jools
No, the engine version also works on 3rd party trees/features, but it's kinda bad: there's no visible fire and the spread mechanism can't be controlled in any other way than by altering the model radius. It's also too fast and too inclusive, either nothing burns or all trees in the whole forest burn.

The fact that it's too fast means that it influences game startegy too much, you can set a forest on fire and destroy too much of the enemy base too fast.

It also skips leaving a wreck after the feature has been destroyed.

Also, I'd like to have the fire spread only in the direction of the wind at the moment.

Re: Forest fires gadget

Posted: 02 Nov 2011, 08:30
by FLOZi
smoth wrote:cegs are not damage dealing..
Spring.SpawnCEG
( string "cegname",
number posX = 0, number posY = 0, number posZ = 0,
number dirX = 0, number dirY = 0, number dirZ = 0,
number radius = 0, number damage = 0
) -> nil

Re: Forest fires gadget

Posted: 02 Nov 2011, 17:00
by Beherith
Hmm, i have actually ran into that before, but I thought it was just a parameter passed to the ceg so it could look different based on damage recieved.

I dont think spawnceg deals damage...

Re: Forest fires gadget

Posted: 02 Nov 2011, 17:16
by Jools
Does it matter really? You can set damage with Spring.AddUnitDamage() anyway and get the affected units from the position of the feature.

I also want to add that I probably can't make a better looking gadget than the one included, but the primary concern with the included forest fire function is that it merits big collision volumes of the trees. I want to keep the volumes small for improved gameplay.

Actually, I thought about having a spherical volume offset from the ground, so that unts like flashes can fire under the trees, but arcing projectiles would be caught in them. However, this makes it hard to dgun the trees, so I still thought a cylindrical collision volume is best. But I want the cylinder to be so small that it just covers the stem of the tree. It seems that such small volumes disables the built in fire mechanism. Hence, I need an own one.

It would actually be optimal to have a collision volume dependent on the type of projectile: I'd like to have a small cylindrical volume for solid projectiles and a large spherical for flame type weapons. But I guess this is not possible.

Re: Forest fires gadget

Posted: 02 Nov 2011, 17:29
by smoth
FLOZi wrote:
smoth wrote:cegs are not damage dealing..
Spring.SpawnCEG
( string "cegname",
number posX = 0, number posY = 0, number posZ = 0,
number dirX = 0, number dirY = 0, number dirZ = 0,
number radius = 0, number damage = 0
) -> nil
that is part of the spawn ceg function, not cegs themselves, unless that has changed..

Re: Forest fires gadget

Posted: 02 Nov 2011, 19:07
by FLOZi
smoth wrote: that is part of the spawn ceg function, not cegs themselves, unless that has changed..
How else to spawn CEG with lua?

Behe might be right though, not sure.

Re: Forest fires gadget

Posted: 02 Nov 2011, 22:28
by luckywaldo7
Jools wrote:No, the engine version also works on 3rd party trees/features, but it's kinda bad: there's no visible fire and the spread mechanism can't be controlled in any other way than by altering the model radius. It's also too fast and too inclusive, either nothing burns or all trees in the whole forest burn.

The fact that it's too fast means that it influences game startegy too much, you can set a forest on fire and destroy too much of the enemy base too fast.

It also skips leaving a wreck after the feature has been destroyed.

Also, I'd like to have the fire spread only in the direction of the wind at the moment.
I like where you are going with this. :D

Disregard me then please, and carry on.

Re: Forest fires gadget

Posted: 03 Nov 2011, 00:24
by PicassoCT
realistic forrest fire, are difficult. Because the physics involved are difficult. First there is a grass fire, which heats and drys the outer bork of the trees who are set aflame, drying the leafes, which burst into fire in a cloudlikeflame.

Also sometimes, smoke-gases form a "big ernie"

http://www.youtube.com/watch?v=XsfwiRfv ... re=related

http://www.youtube.com/watch?v=tg8t3OVt ... re=related

This will be good.

Re: Forest fires gadget

Posted: 03 Nov 2011, 01:34
by Jools
Cool, all this helps. I have already thought of making different probabilities of the fire spreading via bushes and trees. I think we start with something and then when it works it can be improved.

I can't really design CEG:s so I'm reusing old ones. Currently I'm working with one called "napalam". It's quite okay, but i'd like to make it a bit smaller to minimise lag etc.

The spreading formula will be interesting to make. As of now I thought that the area of contagion should be proportional to feature height and momenetary wind speed. Then maybe spreading from trees should be more likely than from bushes, but contagion to bushes should be more likely than to trees. Maybe also read some customParam that can be added to feature.