How to change rocket smoke color

Discussions about Coding and Scripting
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

How to change rocket smoke color

Post by JackGriffin »

Lets say you want to make your rockets more unique and add some color to the smoke. This will show you how. For the sake of simplicity I will not assign team colors or variables like that, that is good for another tutorial. This will simply show you how to change some textures that are linked and rocket smoke just happens to be a good example to use. Lets decide I want to make my rockets spew out a reddish smoke.

First we need to find the projectile used. I am going to reference the source code I have posted here: http://www.gopostals.com/uncodex-ut/ Please use IE with this, FF and Chrome break the links and I don't know why. Sorry! Go to that link and let the page load.

Now see down the left side? Those are all the default classes in UT. Since we know our weapon is the rocket launcher we look down the side and find "Eightball" and click it. Now click "Source" along the top and this will show us the source code for the RL. At the bottom we find this:

Code: Select all

defaultproperties
{
     itemname="Eightball"
     ProjectileClass=class'UnrealShare.Rocket'
     AltProjectileClass=class'UnrealShare.Grenade'
     AmmoName=Class'UnrealShare.RocketCan'
so this tells us the projectile is "Rocket" for primary fire. Off we go on the left now and find "Rocket" and look at it's source the same way.
So long, and thanks for all the fish
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How to change rocket smoke color

Post by JackGriffin »

OK now in "Rocket" we find this code:

Code: Select all

simulated function Tick(float DeltaTime)
{
    local SpriteSmokePuff b;

    if (bHitWater)
    {
        Disable('Tick');
        Return;
    }
    Count += DeltaTime;
    if ( (Count>(SmokeRate+FRand()*(SmokeRate+NumExtraRockets*0.035))) && (Level.NetMode!=NM_DedicatedServer) ) 
    {
        b = Spawn(class'SpriteSmokePuff');   <----SEE THIS LINE?
        b.RemoteRole = ROLE_None;       
        Count=0.0;
    }
}
So that tells me that the rocket spawns "SpriteSmokePuff" as it is flying around. Soooo...off we go to that class (same as the previous way)...
So long, and thanks for all the fish
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How to change rocket smoke color

Post by JackGriffin »

OK now we are getting somewhere. In the Smoke code we find this:

Code: Select all

defaultproperties
{
     SSprites(0)=Texture'UnrealShare.SmokeGray.sp_A00'
     SSprites(1)=Texture'UnrealShare.SmokeGray.sp1_A00'
     SSprites(2)=Texture'UnrealShare.SmokeGray.sp2_A00'
     SSprites(3)=Texture'UnrealShare.SmokeGray.sp3_A00'
     SSprites(4)=Texture'UnrealShare.SmokeGray.sp4_A00'
     SSprites(5)=Texture'UnrealShare.SmokeGray.sp5_A00'
     SSprites(6)=Texture'UnrealShare.SmokeGray.sp6_A00'
     SSprites(7)=Texture'UnrealShare.SmokeGray.sp7_A00'
     SSprites(8)=Texture'UnrealShare.SmokeGray.sp8_A00'
     SSprites(9)=Texture'UnrealShare.SmokeGray.sp9_A00'
So now we know the textures it uses and we can go grab them from editor and alter them to suit our needs. Let me grab them and post them in here, one second...
So long, and thanks for all the fish
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How to change rocket smoke color

Post by JackGriffin »

OK here they are in editor:
Image

Now you need to *carefully* extract each 'frame' (texture) preserving the name and put them into a folder. There will be 10 in all. Once you have that done, you can use photoshop to colorize them however you like. Once you are happy with them, import them back into UEd into your own custom package.

Now be SURE to restore the linking between the frames exactly as they are in the default setup. "AnimNext" tells the game "OK play this animation next" and so on...This allows the engine to play each frame in sequence and the effect is a smoke puff fading away. If you have trouble with this part, email me and I'll help you. Just think of each texture as links in a chain and you must preserve the chain all the way to the end of it.

Once your textures are imported and linked, use the default rocket code and extend your own projectile. Replace the normal smoke puff with your new colored one and enjoy your new mod.

**A couple of things to consider...
1) Bright primary colors are cartoonish. Go easy on the color and you'll be happier.
2) Don't forget rockets have homing capability. Use your new knowledge of code to find the alternate primary fire projectile and fix it's color also.
So long, and thanks for all the fish
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How to change rocket smoke color

Post by JackGriffin »

BTW if you need another example of this, I did these exact steps in creating the Healing Gun. I changed the fire of the pulse gun to an orange/red so you would know you were being healed. I can post the code for that if it would help.
So long, and thanks for all the fish
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: How to change rocket smoke color

Post by iloveut99 »

colorize them however you like. Once you are happy with them, import them back into UEd into your own custom package.
Should I export it as .utx, or put them in textures folder in the classes folder?

And how can I import them in uscript?
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How to change rocket smoke color

Post by JackGriffin »

You need to right-click on each of the texture tiles and export to desktop (I use a folder for each set of tiles to keep them straight). Export as a .pcx file then open each with photoshop and do your color edits. Once you have them colored the way you want import them back into a second utx that you create (not the default one). Once they reside in a utx file the game can access them to use in the code.
Let's go step by step:
1. Find all the textures used by your smoke puff and write them down on scratch paper.
2. Export each individual texture to a folder on your desktop. They will look like this:
Image
3. Open with photoshop and do your texture changes (this might require another tut).
4. Save all new texture files into that same folder.
5. Open UEd and import the new textures into a new utx file. Let's call it "ILoveUT.utx" Remember to link them on import.
6. Save this new utx into your textures folder.
7. Now you can call them from your mod's code. Here's an example of what your properties *might* look like:

Code: Select all

defaultproperties
{
     SSprites(0)=Texture'ILoveUT.SmokeGray.sp_A00'
     SSprites(1)=Texture'ILoveUT.SmokeGray.sp1_A00'
     SSprites(2)=Texture'ILoveUT.SmokeGray.sp2_A00'
     SSprites(3)=Texture'ILoveUT.SmokeGray.sp3_A00'
     SSprites(4)=Texture'ILoveUT.SmokeGray.sp4_A00'
     SSprites(5)=Texture'ILoveUT.SmokeGray.sp5_A00'
     SSprites(6)=Texture'ILoveUT.SmokeGray.sp6_A00'
     SSprites(7)=Texture'ILoveUT.SmokeGray.sp7_A00'
     SSprites(8)=Texture'ILoveUT.SmokeGray.sp8_A00'
     SSprites(9)=Texture'ILoveUT.SmokeGray.sp9_A00'
Last edited by JackGriffin on Sat Mar 26, 2011 10:10 pm, edited 1 time in total.
So long, and thanks for all the fish
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How to change rocket smoke color

Post by JackGriffin »

Oh BTW, usually you use code called "EXEC Import" to embed the textures into the U file but linked textures can't be done this way. They require being placed in a utx file so the linking is preserved.
So long, and thanks for all the fish
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: How to change rocket smoke color

Post by iloveut99 »

JackGriffin wrote:Oh BTW, usually you use code called "EXEC Import" to embed the textures into the U file but linked textures can't be done this way. They require being placed in a utx file so the linking is preserved.
so I don't need to writte something like this:
#exec TEXTURE IMPORT NAME=us8_a00 FILE=textures\us8_a00.pcx
just put the package location like this:
SSprites(0)=Texture'ILoveUT.SmokeGray.sp_A00'
right?

Thanks for the awesome tutorial.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How to change rocket smoke color

Post by JackGriffin »

Correct. You need to call the texture from the package in this specific case. Almost always exec import of textures will work for what you need but in very rare cases (like this one) you have to call from a package because the linking of the textures is preserved in the utx container. That's why if you look at the texture in UEd (Right click>Properties) it automatically begins to animate it's little slideshow, but if you try to export it you only get a single frame (texture). Opening any of the textures in the series this way begins the animation because they are chained. This is an important concept so it's good that you understand it thoroughly. You might not encounter this again for a while but it took me a good deal of time to suss out since there aren't a lot of tutorials for it.

YVW for the tut. I owe many before me that took the time to oversee my efforts. Once you learn, it's your turn.
So long, and thanks for all the fish
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: How to change rocket smoke color

Post by iloveut99 »

//=============================================================================
// UTSmokeTrail.
//=============================================================================
class ColorSmokeTrail extends UTSmokeTrail;

function PostBeginPlay()
{
local int i;
Super.PostBeginPlay();
SetTimer(1.4, false);
if ( bRandomize && (FRand() < 0.4) )
MultiSkins[5 + Rand(2)] = Texture'coloredSmoke.blueSmoke.US3_A00';

}
It's giving me this error:
\UnrealTournament\colorSmoke\Classes\ColorSmokeTrail.uc(12) : Error, Can't find Texture 'coloredSmoke.blueSmoke.US3_A00'
Failed due to errors.



History: CompileError <- TryCompile <- FScriptCompiler::CompileScript <- (Class colorSmoke.ColorSmokeTrail, Pass 1, Line 12) <- CompileScripts <- CompileScripts <- CompileScripts <- CompileScripts <- CompileScripts <- DoScripts <- UEditorEngine::MakeScripts <- UMakeCommandlet::Main

Exiting due to error
My code is attached.
Attachments
colorSmoke.rar
(43.13 KiB) Downloaded 155 times
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How to change rocket smoke color

Post by JackGriffin »

I'm looking at your code, but I like to start at the beginning. Lets fix some things before we get to the smoke.

In the class ColorEightball you have

Code: Select all

ProjectileClass=Class'Botpack.RocketMk3'
I can see your code has extended Mk2 and you have made Mk3. Since the Mk3 class resides in your mod you will need to alter that code to

Code: Select all

ProjectileClass=Class'MYMODNAME.RocketMk3'
(as an aside and this is just naggling, you should consider not using next generational names for things and instead personalize the class you are working on. Perhaps "RocketLUTMk2" instead, as calling it Mk3 implies you have versioned the actor forward in development)

Copy your colored smoke utx to here too. I don't immediately see why it doesn't pick it up.
So long, and thanks for all the fish
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: How to change rocket smoke color

Post by iloveut99 »

Ok, I fixed that.

The texture is in Textures folder:
Attachments
colorSmoke.rar
(43.14 KiB) Downloaded 162 times
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How to change rocket smoke color

Post by JackGriffin »

Derp. Sorry I went straight to the classes folder to grab code.

OK, first off..Fantastic work my brother. You did the textures nicely, imported them correctly and linked them. Very nice job :tu:

OK there's something wrong with the textures. If you go into ed and add them, they are not blue and in fact the texture reads as Botpack.utsmoke.us1.A00 even though I'm adding them from your utx package. Try importing them again into a utx package and see if you can find where your error was.
So long, and thanks for all the fish
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: How to change rocket smoke color

Post by iloveut99 »

That's really weird. In my unrealed they are blue and have the correct name, where's a new imported package:
Attachments

[The extension utx has been deactivated and can no longer be displayed.]

Post Reply