Posted: Sat Jul 30, 2016 5:58 am Post subject:
Making Smoke come out of tank barrels on firing.
Use a customized smoke particle in the weapon section coupled with a spark particle declaration. The advantages are that the smoke can be made to be effected by wind (but not with the code below), you won't have to make separate animations for each muzzle flash animation, and it'll be easier to implement on many tanks.
Weapon Code
Spoiler (click here to read it):
Code:
[120mm] Â ;or any other tank weapon
...
UseSparkParticles=yes  ;makes the particle only appear at the barrel tip
AttachedParticleSystem=MuzzleSmokeSys  ;a very low-duration smoke particle to avoid ROF issues
Lists
Spoiler (click here to read it):
Code:
[Particles]
...
##=MuzzleSmoke  ;replace ## with the last number in the list +1
[ParticleSystems]
...
##=MuzzleSmokeSys  ;replace ## with the last number in the list +1
Particle Code
Spoiler (click here to read it):
Code:
; a system for small amounts of smoke (damaged units)
[MuzzleSmokeSys]
HoldsWhat=MuzzleSmoke ; the particle it holds
Spawns=yes
SpawnFrames=1 ;this is important to keep it short
SpawnRadius=5 ;low figures make sure the smoke appears to come from the muzzle
Slowdown=.0025
ParticleCap=3 ;an ideal value for a more smokey-appearance
SpawnCutoff=1.0 ;no need for multi-level transparency
SpawnTranslucencyCutoff=1.0 ;this too
BehavesLike=Smoke ;this makes it move slightly upwards after being drawn
[MuzzleSmoke]
Image=SGRYSMK1 ;the actual image. change it if you want a different look
MaxEC=40
Translucency=50 ;remove the translucency if you experience slow downs.
Velocity=6.0 ;speed of the smoke particle
Deacc=.05
WindEffect=0 ;increase to increase the effect of wind on the smoke
BehavesLike=Smoke
DeleteOnStateLimit=no ;so the particle can exist longer than the system
EndStateAI=20 ;tied to image frame count
StateAIAdvance=4
Note that the duration of the particle system effects the tank's ROF; it will not fire as long as a particle system is active. this is the reason I used a new particle system instead of the existing smoke particles.
Edit: thanks ApolloTD for confirming that Ares isn't needed for this. Last edited by silverwind on Sat Jul 30, 2016 7:27 am; edited 1 time in total QUICK_EDIT
No, ARES is not needed for that...even Tiberian Sun suffices.
However, I am sorry to say but if this was a tutorial it is a bad one on to particle systems, you just gave bunch of code for copy and paste practice but didn't really care to elaborate how the relevant codes can affect it so one can customize it like adjusting wind factor for one you mention.
Especially the oversight of UseSparkParticles=yes key, this will cause drawback of tank being unable to fire on the move thus tank must stop before it can fire, this may not be desirable outcome and should be mentioned.
Also if doing this for every tank in mod, should look into optimizing the particle codes further else frame rate drops very likely when using in mass. QUICK_EDIT
I use this in all the tanks in my game, and I don't notice any frame drops, but of course, I can see it can be optimized further.
I hadn't actually known that UseSparkParticles=yes disables tanks firing while moving (I'll just confirm this in a while, because I don't recall this being such in any recent plays), and iirc, it is what makes the particle only appear at muzzle instead of following the bullet around like a trailer. QUICK_EDIT
I use this in all the tanks in my game, and I don't notice any frame drops, but of course, I can see it can be optimized further.
I hadn't actually known that UseSparkParticles=yes disables tanks firing while moving (I'll just confirm this in a while, because I don't recall this being such in any recent plays), and iirc, it is what makes the particle only appear at muzzle instead of following the bullet around like a trailer.
ARES optimized particles fairly recently to be fair but I see things that could be trimmed.
And no, UseSparkParticles key does not tell spawn location as such, it is merely activator key for AttachedParticleSystem just like UseFireParticles=yes etc are.
You define particle in weapon directly, it spawns at firing FLH thus barrel and won't follow...
You define at projectile, it follows projectile, you define at warhead, it is created at target and again follows nothing. QUICK_EDIT
Just checked this. You're right. UseFireParticles=yes instead of UseSparkParticles achieved a similar result, but for my code, that turnout out a bit more buggy -- enemy units not retaliating, occasional damageless shots, etc. that didn't happen with spark particles. Heck, units don't actually fire while moving in either case, which I just tested. Instead, they just point the turret nd wait till they at least momentarily stop moving.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum