Forest fires gadget

Forest fires gadget

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Forest fires gadget

Post 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?
Last edited by Jools on 01 Nov 2011, 23:31, edited 1 time in total.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Forest fires gadget

Post 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...
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Forest fires gadget

Post by knorke »

smoth wrote:cegs are not damage dealing..
use a weapon...
use Spring.SetFeatureHealth or Spring.DestroyFeature
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Forest fires gadget

Post 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.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Forest fires gadget

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Forest fires gadget

Post 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.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Forest fires gadget

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Forest fires gadget

Post by knorke »

Spring.GetWind
y u no bookmark http://springrts.com/wiki/Lua_Scripting
luckywaldo7
Posts: 1398
Joined: 17 Sep 2008, 04:36

Re: Forest fires gadget

Post 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
User avatar
MidKnight
Posts: 2652
Joined: 10 Sep 2008, 03:11

Re: Forest fires gadget

Post 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. :-)
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Forest fires gadget

Post 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.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Forest fires gadget

Post 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.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Forest fires gadget

Post 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
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Forest fires gadget

Post 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...
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Forest fires gadget

Post 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.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Forest fires gadget

Post 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..
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Forest fires gadget

Post 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.
luckywaldo7
Posts: 1398
Joined: 17 Sep 2008, 04:36

Re: Forest fires gadget

Post 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.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Forest fires gadget

Post 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.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Forest fires gadget

Post 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.
Post Reply

Return to “Lua Scripts”