Posted: Sun Sep 30, 2012 4:07 am Post subject:
Advanced debris logic
If you've ever tried to create some sort of weapon using art.ini debris, you've probably noticed how completely random it can be. You can only define the max amount of debris to spawn with the SpawnCount key, but the minimum cannot be changed. It can be as low as 0, completely stopping your weapon from being used. This simple tutorial will show you how to get rid of the randomness in debris spawning. You will get consistent and guaranteed results with it.
If you aren't familiar with debris logics in art.ini, check this tutorial which covers all the needed keys.
The trick is to never use the Spawns or SpawnCount keys, instead we use the TrailerAnim and TrailerSeperation keys.
To start the spawning, define:
Code:
; Debris spawner 1
[SPAWNER1]
Image=EMPTYANIM ; INVISO or NULL won't work here
TrailerAnim=DEBRIS1 ; Spawn the 1st set of debris
TrailerSeperation=3 ; This defines how quickly debris is spawned (lower value = faster. Minimum is 1)
Rate=200 ; These can be used to define for how long debris will be spawned
LoopStart=0
LoopEnd=8
LoopCount=1
;Next= ; Could be used to play another anim at the site of debris spawning
You need to of course attach this anim to a warhead or somewhere else where it will be played. EMPTYANIM is just an invisible 10 frame animation I have created myself, INVISO or NULL don't seem to work for it. The TrailerAnim will keep spawning / throwing debris around, at the speed defined in TrailerSeperation (lower value = faster spawning). Debris will be spawned for as long as this animation plays (so adjust the rate / loop keys).
Next up the debris itself (this deals the damage):
Code:
; Debris 1
[DEBRIS1]
Image=NULL ;METSMALL ; Enable for testing
ExpireAnim=SPAWNER2 ; Next debris spawner animation
;Spawns= ; Don't use these keys for spawning!
;SpawnCount= ; Don't use these keys for spawning!
Damage=250
DamageRadius=5000
Warhead=AP
Elasticity=0.0
MaxXYVel=24.0
MinZVel=10.0
LoopStart=0
LoopEnd=8
LoopCount=-1
Rate=500
Bouncer=yes
Adjust the damage and other values to your liking. The important key here is ExpireAnim. Attach another debris spawner animation to it, so more debris will be spawned from where the old debris landed.
Code:
; Debris spawner 2
[SPAWNER2]
Image=EMPTYANIM
TrailerAnim=DEBRIS2 ; Spawn the 2nd set of debris
TrailerSeperation=3
Rate=200
Start=0
End=8
;Next=
The STOPDEBRIS is needed for the last set of debris to deal damage, since an ExpireAnim is always required for a debris to deal damage. INVISO might work for it too, didn't test it myself.
That should cover it. The Next key can be used on the debris spawner animations to play more animations. That is if you have a big explosion animation, you probably don't want to use the actual animation itself to spawn debris. That would mean it would keep spawning debris until the very last frame, thus damage would keep happening long after the explosion is gone. Instead, give [SPAWNER1] the first few frames of the animation, and give it Next=BIGEXPLOSION. Debris will now be spawned only for the first few frames of BIGEXPLOSION, then the rest animation will play out without spawning any further debris.
INVISO isn't good, as it deals already by default 1 damage. IIRC this was even hardcoded to do 1 damage.
Instead of STOPDEBRIS i would also suggest using EMPTYANIM, so this one is reused and the game doesn't has to load another animation. But this is just my personal opinion. Someone could also say that the few frames of STOPDEBRIS are better working.
A small note for those who use this: Beware that this kind of damage does not work for anti-air and anti-water weaponry!
When used against air, the debris will fall to the ground and do the damage there.
When used against water targets, the debris will only cause a splash in the water and don't do any damage at all. _________________ SHP Artist of Twisted Insurrection: Nod buildings
afaik no. The traileranim will do the damage on the ground below it instead.
AFAIK do all the animations simply have no z value and only xy, except for debris of course which unfortunately can only hit ground. _________________ SHP Artist of Twisted Insurrection: Nod buildings
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