Posted: Fri Jul 01, 2011 2:10 pm Post subject:
How to create random damage (***)
Subject description: using art.ini debris and a particlesystem for a mutation effect
This tutorial will show you how to create random damage between 0+X and a max+X value, where X is a arbitrary chosen value for a fixed damage that is always done.
It is rated with 3 stars, as the many necessary intermediate steps are prone to include bugs.
Pros:
-random damage
-can have fixed base damage
-easy to balance
Cons:
-veterancy (units gain veteran/elite status) is not or only reduced available
-can't be used against air or hover units and units on water
Description:
The game uses normally the Damage key which has a fixed value and always does the specified amount of damage (of course adjusted by the warheads verses settings).
There is unfortunately no way to achieve the desired random damage in rules.ini, thus we have to use a workaround going over art.ini.
In art.ini you can create an animation that spawns debris whose number is defined with SpawnCount. This key has the special feature to choose a number between 0 and the specified value, which is exactly what we need.
The reason that it can't be used against air or hover units, lies in the usage of art.ini debris. These explode by default only when they hit the ground, thus the damage that these inflict, won't hit the flying/hovering unit far above the ground. If you would still fire the gun on such a unit, only the base damage would hit it and the random damage would be done on the ground below the unit.
On water this doesn't works too, because art.ini debris always splash into water which stops them from spawning more debris. (conventional=no doesn't works in art.ini, unfortunately)
Implementation:
In the following example, i will show you an expanded version of the technique which will create a random amount of mutation damage, that mutates infantry into visceroids.
First we need a weapon. This is called Toxinrifle in my example.
This has a fixed amount of damage which will always be applied next to the random damage.
A unit using this weapon will also only gain veterancy, if it was able to destroy an object with this fixed damage.
Code:
[Toxinrifle]
Damage=50 ;always done damage that allows veterancy
ROF=60
Range=8
Projectile=Invisible
Speed=100
Warhead=MutateWH100 ;the warhead where the magic starts
Report=SILENCER
The weapon uses the warhead MutateWH100, which will define the used verses for the fixed amount of damage and which will start the random damage from 0 to 100 damage points.
Code:
[Warheads]
:
XX=MutateWH100 ;XX is a free number
[MutateWH100]
Spread=0
Verses=100%,25%,20%,15%,5%
InfDeath=1
AnimList=MUTATEINIT100 ;0-100 random points of mutation damage
ProneDamage=50%
The warhead starts the random damage via the Animation MUTATEINIT100. First lets add it in rules.ini to the end of the Animations list.(make sure the Animations list has already all firestorm anims added to the end or use the UMP, or else you get the nasty savegame bug)
Since we will need another animation (MUTATEDMG), we will add it right away too.
rules.ini
Code:
[Animations]
YYY=MUTATEINIT100 ; YYY is first free number
ZZZ=MUTATEDMG ;ZZZ is second free number
Now in art.ini create the following animation.
art.ini
Code:
;anim that starts the random mutation damage
;spawns 0-4 debris with each debris doing a small amount of mutation damage
[MUTATEINIT100]
Image=none ;this is only a dummy stage so we dont need any image
Elasticity=0.0 ;necessary to be an art.ini debris that allows other debris to be spawned
MaxXYVel=1.0 ;as a debris we dont want it to fly away and keep it on the position
MinZVel=-10.0 ;make the debris fall very fast down, so it hits the ground immediately when the debris is created
Damage=0
DamageRadius=0
Spawns=MUTATEDMG ;the special debris which will do 25 damage
SpawnCount=4 ;the random amount of debris (0-4) 4*25=100 damage
Warhead=SA ;not important since no damage is done by this debris
LoopStart=0
LoopEnd=1
LoopCount=-1
DetailLevel=0
RandomRate=220,500
Bouncer=yes ;necessary to be an art.ini debris
As you can see it starts a second art.ini debris called MUTATEDMG. This will do the actual damage via its warheads particlesystem.
The intermediate anim MUTATEINIT100 is only necessary to get the randomness into the whole thing via the SpawnCount key.
art.ini
Code:
;this one does the mutation damage via the warhead which creates a particlesystem with the gas mutation logic
[MUTATEDMG]
Image=none
Elasticity=0.0
MaxXYVel=1.0
MinZVel=-10.0
ExpireAnim=PIFF ;with none warhead is ignored
Damage=1 ;with 0 warhead is ignored
DamageRadius=0
Warhead=MutationWH ;the warhead that uses a particlesystem for the mutationdamage
LoopStart=0
LoopEnd=1
LoopCount=-1
RandomRate=220,600
DetailLevel=0
Bouncer=yes
For the mutation damage some more steps are necessary which will be explained now. If you don't want that, you can replace the MutationWH warhead on the MUTATEDMG animation with another one and give this debris a higher damage than 1. (Note: the warhead is correctly used on art.ini debris, against the believe of many modders who think that all animations ignore completely the set warhead)
Expanded version doing mutation damage:
To cause the mutation of an infantry into a visceroid exists only one way, via a particlesystem that has BehavesLike=Gas on the particle. Though to get there we need a warhead which will create the particlesystem. For that we create in rules.ini the MutationWH warhead.
rules.ini
And now the final step, the particlesystem and particle.
rules.ini
Code:
[ParticleSystems]
XX=MutateSys ;XX is a free number
[Particles]
XX=MutatePart ;XX is a free number
[MutateSys]
HoldsWhat=MutatePart
BehavesLike=Fire ;this allows the usage of damage on the particle
Image=none
[MutatePart]
Image=none ;we want it invisible
MaxDC=1 ;do every 1 frame the damage
MaxEC=1 ;the max amount of frames the PS lasts
Damage=25 ;do 25 damage
Warhead=MutationWH ;we can use the warhead here again as the warheads PS and anims are ignored
StartFrame=0 ;the first frame of the anim
EndStateAI=1 ;the last frame that should be shown
Translucency=0 ;use this for less lags ingame
WindEffect=0
BehavesLike=Gas ;The most important point to cause the mutation
StateAIAdvance=3 ;raise the shown framenumber every 3 EC steps
DeleteOnStateLimit=yes ;remove the particle when the last frame has been reached
As you can see, does this technique actually do only a random multiple of 25 as the random damage. For a finer graduation you can indeed raise SpawnCount and reduce the damage of the Particle (or the MUTATEDMG debris if only normal damage should be done), however this can cause some serious lags as the game still has to create the debris even if they are invisible.
You could have just used BehavesLike=Gas on the system too as both Fire and Gas accept damage on the subparticle while smoke etc does not.
Also why declare Translucency=50 for a blank anim of sorts? I would rather disable call of the system by Translucency=0 and for the record, default for particles is use translucent=yes like system unless told a set amount or 0 to disable, just better performance wise IMO. QUICK_EDIT
Yep. Gas would have worked too. But it makes no difference in this case. It also makes clearer that the mutation is done by the particles BehavesLike=Gas and not the ParticleSystem ones.
So many particles. I'd try this in RA2 if not for all of those. May still try anyway though... cause it's a good thing. _________________ KGR | AT
AZUR
Discord: theastronomer1836
Steam QUICK_EDIT
In Ra2 you don't need the particles, because there doesn't exists a visceroid mutation logic (afaik) and mutation can be done already in art.ini. So you can skip the "expanded version" part completely. _________________ SHP Artist of Twisted Insurrection: Nod buildings
In YR, there's the mutation logic, but it's not quite the same as the visceroid mutation so you'd still need to use the exact same code. At least I'm almost certain you would anyway.
I'll test it when I'm back in the mood to play YR. _________________ KGR | AT
AZUR
Discord: theastronomer1836
Steam QUICK_EDIT
Nah, only use of this code for RA2 is if you want random damage as per tut and Gas particles don't spawn viscs as said code is gone AFAIK, mutation logic wise easy just add mutate warhead into particle in YR probably but would create civilian owned probably... QUICK_EDIT
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