Page 1 of 1

Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 22:20
by MaNGusT
Can the gfx effects event be scripted? or is it still hard-coded?
I want to add some effects that will appear in needed events and do some moves. Also I need a parameter - how many times an effect will be repeated or how long an effect will be visible.
Well, I want to add a crater(or fired earth) and some dust in the air on the places where units blow up. Crater will appear at blow and lose transparency over time, dust will just repeat texture animation few times on specified places.

For first time there could be few events like: onUnitDeath, onUnitFire, onUnitMove, onBuildingBlow, etc. where I can set up what files must be placed and its coordinates with the center point in the event center and its appearing time.

Re: Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 22:46
by aubergine
There's a few extra functions that will be needed to do that sort of stuff - for example fireWeaponAt() and functions to allow basic map editing.

As for stuff dissipating over time, maybe same approach as on weapon trails could be used (the way their smoke fades over time)?

Here's a list of the events currently in the game: Events & Timers

It's currently not possible to directly position objects though, although that's something that would be massively useful for a huge number of things. Eg. if we could place objects, and especially change the texture on them (like we can with skybox to some extent) we could create all sorts of custom effects, weather and a bunch of other stuff.

Re: Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 22:52
by MaNGusT
aubergine wrote:functions to allow basic map editing.
Why? The crater or fired earth effect can be a square model with a transparent borders in texture that will be placed on terrain on unit death event and disappear over time.

Re: Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 23:07
by aubergine
Because if you add a model to a map, such as a feature, just as a aesthetic thing, it will start to mess with the game mechanics -- ie. it will be treated by the game engine and AIs as an actual object on the map, rather than just a graphic effect.

It would be better, therefore, to have some map editing functions which would allow terrain changes, etc., and those other functions I mentioned to "fire weapon" (in other words, do the weapon explosion effect, which doesn't have to look like an explosion - it can be whatever is desired).

This way a texture change (and possibly even minor terrain deformation) could do the crater effect, and weapon effects could be used to create dust clouds or whatever.

For example, the mine features in NTW were done using weapon fire effect, but with a radar ping as the weapon -- so player would see radar pings where their own mines were. In terms of dust clouds, things like the existing effects shown when a sky scraper is destroyed could be used and so on.

That being said, I really would like some sort of script-driven way to add square models to the map, or more specifically rectangles (don't really need sides for most requirements). The texture could be applied to them through script (filename of a png, like we can do with setSky() function) and their lighting and alpha could be scripted also, along with their position, rotation, scaling, etc. That would facilitate things like your craters and also a bunch of stuff I want to do with clouds.

As a custom object with type EFFECT and not owned by any player, they could be set to be non-blocking, and not treated as an object so they wouldn't affect path finding and so on.

You could then have functions like:

* addEffect(...) // add an effect rectangle to the world, returns the effect object
* enumEffects(...) // get a list of all effect objects in the world, optionally filtered somehow (eg. get list of all Crater effects)
* effectLighting(effectID, ambientRGBA, diffuseRGBA, specularRBGA) // set lighting for an effect
* removeEffect(effectID) // remove an effect
* setEffectPosition(x,z,y, roll, pan, tilt, scale) // change position, rotation and scale of an effect
* setEffectTexture(effectID, texture) // set effect texture (note: due to game limitations, can only update once per 100ms)

Re: Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 23:20
by MaNGusT
Now I think that it'll be just a waste of time to add this high amount of code. In the end it will look like hybrid effect system with messed up code while to be correct it should be divided onto script-event system and particle effect system.
We don't have the particle engine, so I just thought about something that can be easily added via scripts..

Re: Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 23:29
by Per
I want to see what I can do in that regard, but it is a bit down on the priority list...

Re: Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 23:33
by MaNGusT
Per wrote:I want to see what I can do in that regard, but it is a bit down on the priority list...
Oh, your famous to-do list with items long from here to mars. :D

Re: Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 23:42
by aubergine
Having ability to add rectangle objects, position/rotate/light/texture them would still enable a vast array of new effects, particularly atmospheric effects.

A rectangle would be like single side of skybox, with ability to do those extra things to it. Hopefully not too much coding, but would unleash vast array of new possibilities with very few polys.

Re: Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 23:51
by MaNGusT
and will impact performance because these kind of effects should be calculated on video card.

Re: Add support for event-driven effects via scripts?

Posted: 21 Jan 2013, 23:53
by aubergine
There is no calculation being done though. Eg. If I put a cloud in the sky, it's just a rectangle with image of cloud on it and lighting applied by OpenGL.

I could have dozens of clouds and still be using far less time than a single droid takes to render.

Re: Add support for event-driven effects via scripts?

Posted: 22 Jan 2013, 00:12
by MaNGusT
I mean if represent triangle as primitive particle of the effect that will have few parameters as color, brightness, moving speed and direction, etc. that's how particle graphics engines work. They just create a mass of particles which moves, rotates and disappear.

Re: Add support for event-driven effects via scripts?

Posted: 22 Jan 2013, 06:36
by aubergine
Yes, but I imagine introducing a particle engine will bring it's own set of problems to overcome.

What I'm looking for is an interim measure, that would still be viable long term, which is the ability to create a rectangle and put my own texture on it, rotate, position, and light it. And I'm not talking a small particle-sized rectangle, I mean a bigger rectangle that, for example, would have an image of a cloud, or the sun, or or fog of whatever. There are a gazillion effects that can be achieved using just a few rectangles and some ingenuity.