OverTime Commands explained....

Lots of cool and useful tips to mod either serverside or clientside
Post Reply
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

OverTime Commands explained....

Post by Apache Thunder »

Alright I finally figured out how these commands work. After porting the fire flies effect from BFheroes to my BFheroes mod (which mean I had to code the effect from scratch as BFheroes and BF2 etc code effects to differently to be directly used in BF42).

So here is how I have found the commands to work.

There is quite a bit of commands that do stuff "overTime" so I will only explain the most important ones.

For example here are the commands I speak of:

Code: Select all

rem *** Particles only ***
ObjectTemplate.alphaOverTime

rem *** SpriteParticles Only ***
ObjectTemplate.colorRGBAOverTime

rem *** Both ***
ObjectTemplate.gravityModifierOvertime
ObjectTemplate.sizeOverTime 

I will now explain how to use the over time settings which pretty much applies to all the others for the most part.

First an example of the code for colorRGBAOverTime on a sprite:

Code: Select all

ObjectTemplate.colorRGBAOverTime 0/255/255/255/255|50/128/128/128/128|100/0/0/0/0
Looks complicated and that's what I thought at first. But as it turns out it's kinda simple really. First off unlike the vec3 color settings used on fog and verious lighting settings for levels, this is NOT a color vector. It's a RGBA integer value. As in each number is a value of RGBA. You know the same numbers you see when you bring up the color palette in MSPaint, Photoshop, Gimp, and other similar image apps. This works best if the texture has no color to it to start with. ;)

The numbers represent Red Green Blue and Alpha. In that order! First number is Red, next number is Green, number after that is Blue, and the last one is alpha. (higher number equals more opacity)

Now that accounts for the vec4. There is a fifth number. it's the very first number of each string. First sequence starts at 0 middle sequence starts at 50 and last one is at 100. (but this can vary if you have more time increments in the command)

Example: 50/255/255/255/255

First number is time in percentage of the timeToLive set for the sprite. So 50% or halfway through it's timeToLive it will transition to that color and alpha for the sprite in question. Each sequence is seperated with a pipe charactor. " | ". There is a minimum of two strings but for things more complex there can be 3 or more. (100 possible settings?) I've never seen a string exceed 100. So it's safe to assume the time setting is always a percantage of the timeToLive of the sprite. 0 being the start of the sprite's existance and 100 being the end of it. So in theory there is a max of 100 different time values you can define. (though this will result in very long command string. :P )

So to change the color halfway through the sprite's timeToLive then fade to zero (and make the sprite invisible) you do this:

Code: Select all

ObjectTemplate.colorRGBAOverTime 0/128/128/128/255|50/255/255/255/255|100/0/0/0/0
And that's basically it. It will start as 128 (made it the same for all colors to make this simple) and 255 for alpha. Lower numbers means more alpha on the sprite. So 0 means invisible sprite, and 255 means completely visible sprite. ;)

The sprite will "transition" from the last setting to the next between two sequence numbers. So it will "fade" from the first setting to the next that is set to 50, then fade to zero at the 100 mark.

Now to do more complicated stuff like make a sprite fade quckly to full color at start then remain the same for half it's life then fade to zero quickly, you do this:

Code: Select all

ObjectTemplate.colorRGBAOverTime 0/0/0/0/0|25/128/128/128/255/75/128/128/128/255|100/0/0/0/0
That would be how you have a sprite fade to your set color and alpha early on, then maintain that for roughly 50 to 60% of it's timeTolive and then 25% before it ends it then fades to zero again.

Now for gravity or size over time it's not much different. For size:

Code: Select all

ObjectTemplate.sizeOverTime 0/1|50/1.25|100/2
Simpler then the color value. With this you only worry about the time setting and the size. First number is time as with the last command and the next is the size.

Remember the size set here is relative to the particle/sprite's size setting so remember to set it correctly.

For example 1 is 100 percent it's set size and 0.5 is half it's normal size. To make a sprite go larger instead of smaller, simply use a number higher then 1. The size number is NEVER a negative number! Not that I have seen so I don't know what happens if you use negative numbers. Since the size of a sprite/particle is never set as a negative number it's safe to assume it's not going to have negative numbers in this command either!


So to have a sprite expand from zero size to full size then shrink to zero size at the end of it's timeToLive you do this:

Code: Select all

ObjectTemplate.sizeOverTime 0/0|50/1|100/0
For more complicated stuff do the same as described with the color commands. They all function the same in terms of time.

Now for the last one I will explain is the gravityModifierOverTime command. Now unlike the size command this command CAN have a negative number. Positive number makes the sprite fall, and a negative number makes it rise.

Code: Select all

ObjectTemplate.gravityModifierOverTime 0/1|50/0|100/-1
First number is time and next is gravity amount separated from each time segment with a | character as with the rest.

So to have a sprite rise then float at halfway point then fall you do this:

Code: Select all

ObjectTemplate.gravityModifierOverTime 0/-1|50/0|100/1
As before you can add smaller time increments for more fancy movements. As I understand the gravity modifier is either relative to the gravityModifier command or is absolute and overrides the command. I'm not entirely sure on that so experiment with it to be sure.


And the last one I'll go over quickly is AlphaOverTime for particles only. Sprites use the color command to define the alpha combined with it's color so sprites don't use this command.

Basically it works the same as the size command. I haven't played around with this command so I am only making an educated guess here. But 1 should no alpha and 0 is full alpha. Example:

Code: Select all

ObjectTemplate.alphaOverTime 0/1|70/1|100/0
That tells the particle to stay at full opacity until 70% through it's timeTOLive, then fade to zero after that.


That explains the most important ones. There are others but they pretty much function the same as the ones I described above. So happy coding folks! :D
ImageImageImage
I have cameras in your head!
User avatar
fo0k
Posts: 1433
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

Re: OverTime Commands explained....

Post by fo0k »

Really cool, thanks. I had a very vague idea about this stuff but not even tried playing with it before. After reading this I shall try and use it!

Epic stuff sir.
Post Reply