Project Perfect Mod Forums
:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Privacy Policy :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::


The time now is Thu Mar 28, 2024 3:00 pm
All times are UTC + 0
How to create random damage (***)
Moderators: Global Moderators, Tiberian Sun Moderators
Post new topic   Reply to topic Page 1 of 1 [8 Posts] Mark the topic unread ::  View previous topic :: View next topic
Author Message
Lin Kuei Ominae
Seth


Joined: 16 Aug 2006
Location: Germany

PostPosted: 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
Reply with quote  Mark this post and the followings unread

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.

You can see this technique in action already in Twisted Insurrection, where it is used on visceroids and the Infector.

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
Code:
[Warheads]
XX=MutationWH ;XX is a free number

[MutationWH]
Spread=0
Verses=100%,25%,20%,15%,5%
InfDeath=1
Particle=MutateSys   ;always do 25 mutation damage
ProneDamage=50%


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.


Key Words: #Tutorials #Modding #TiberianSun #Firestorm #Rules.INI #Art.INI 

_________________
SHP Artist of Twisted Insurrection:  Nod buildings

Public SHPs
X-Mech Calendar (28 Mechs for GDI and Nod)
5 GDI, 5 Nod, 1 Mutant, 1 Scrin unit, 1 GDI building

Tools
Image Shaper______TMP Shop______C&C Executable Modifier

Last edited by Lin Kuei Ominae on Fri Jul 01, 2011 10:10 pm; edited 3 times in total

Back to top
View user's profile Send private message
Palkia323
Pyro Sniper


Joined: 10 May 2008

PostPosted: Fri Jul 01, 2011 5:22 pm    Post subject: Reply with quote  Mark this post and the followings unread

Wow, can't say I thought of this myself.

I love your little workarounds! Genius at work here people.
Thanks for this man, will be used(:

_________________
Tore wrote:
Oh noes Nod32 must have found some GDI32 in the art.ini file!

3ds Topic
Clicky

Back to top
View user's profile Send private message
ApolloTD
Commander


Joined: 19 Nov 2003

PostPosted: Fri Jul 01, 2011 6:26 pm    Post subject: Reply with quote  Mark this post and the followings unread

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.

Back to top
View user's profile Send private message
Lin Kuei Ominae
Seth


Joined: 16 Aug 2006
Location: Germany

PostPosted: Fri Jul 01, 2011 7:21 pm    Post subject: Reply with quote  Mark this post and the followings unread

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.

Oh right. Translucent=0 changed. Thanks.

_________________
SHP Artist of Twisted Insurrection:  Nod buildings

Public SHPs
X-Mech Calendar (28 Mechs for GDI and Nod)
5 GDI, 5 Nod, 1 Mutant, 1 Scrin unit, 1 GDI building

Tools
Image Shaper______TMP Shop______C&C Executable Modifier

Back to top
View user's profile Send private message
FurryQueen
General


Joined: 24 Jul 2010
Location: Liyue

PostPosted: Fri Jul 01, 2011 8:41 pm    Post subject: Reply with quote  Mark this post and the followings unread

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

Back to top
View user's profile Send private message Skype Account
Lin Kuei Ominae
Seth


Joined: 16 Aug 2006
Location: Germany

PostPosted: Fri Jul 01, 2011 10:09 pm    Post subject: Reply with quote  Mark this post and the followings unread

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

Public SHPs
X-Mech Calendar (28 Mechs for GDI and Nod)
5 GDI, 5 Nod, 1 Mutant, 1 Scrin unit, 1 GDI building

Tools
Image Shaper______TMP Shop______C&C Executable Modifier

Back to top
View user's profile Send private message
FurryQueen
General


Joined: 24 Jul 2010
Location: Liyue

PostPosted: Sat Jul 02, 2011 12:13 am    Post subject: Reply with quote  Mark this post and the followings unread

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. #Tongue

_________________
KGR | AT
AZUR
Discord: theastronomer1836
Steam

Back to top
View user's profile Send private message Skype Account
ApolloTD
Commander


Joined: 19 Nov 2003

PostPosted: Sat Jul 02, 2011 6:22 am    Post subject: Reply with quote  Mark this post and the followings unread

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...

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [8 Posts] Mark the topic unread ::  View previous topic :: View next topic
 
Share on TwitterShare on FacebookShare on Google+Share on DiggShare on RedditShare on PInterestShare on Del.icio.usShare on Stumble Upon
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


Powered by phpBB © phpBB Group

[ Time: 0.1766s ][ Queries: 11 (0.0085s) ][ Debug on ]