Category:Scripting

From Infinity Ward Community Wiki

Jump to: navigation, search

Here is a straightforward way to add smoke and fire fx to a multi-player Call of Duty 4 map.

Author: Ray from http://www.codutility.com

This tutorial was prepared using a simple basic test map. It included all aspects based on TDM gameplay and will work the same with any gametype. The aspects include a strip of terrain, prefab tank model, TDM spawn points, global intermission, a reflection probe, skybox, worldspawn values as well as the .gsc, _fx.gsc and a .csv.

One point to remember. You will have to remember that you will need to create the folder "createfx" and have it placed in /raw/maps.

Instructions:

Step #1

Start by either opening your map in radiant or by starting a new test map (recommended by me).

If using an existing map then choose a model that you want to apply the fx to or pick the spot for the fx. If using a new test map then add all the other necessary feature as I have stated above in my opening statement. Ie, a strip of terrain, prefab model, TDM spawn points, global intermission, a reflection probe, skybox, worldspawn values etc.

Step#2

Now that we have an area to work the fx lets gather the important co-ordinates that will be used in the scripting. See images below…..


While in Radiant use the 2d window and make sure that you are in the XY TOP view (use ctrl-tab to go there). Now look at the model or area of the map where you want the fx to be seen. Place your mouse at the position desired. If using a model try placing your mouse pointer near the center of the model. Now look at the bottom part of the 2d window and you will see the X Y and Z coordinates. Record on a piece of paper the values shown for the X and Y coordinates at this time. The Z value is most likely showing 0.0 at this time so just ignore it.

Now hit ctrl-tab to go to either the XZ FRONT or the YZ SIDE view. From either view again look at the coordinates generated at the bottom of the 2d window. You will now have your Z coordinate showing when you place your mouse pointer where you want the fx so write it along with the previous two coordinates. In this view you will also see your Y coordinate shown again. It will most likely be the same value as you found in the XY TOP view so you don’t need to write this one down again. Look at the images below to see the areas that you have to look for.


[img]http://www.oldmanray.com/sftut/sf1.jpg[[/img]


[img]http://www.oldmanray.com/sftut/sf1.jpg[[/img]



We are now done in Radiant and the rest is all done with scripting. If you need to save anything you have done in Radiant then remember to do so now. At any rate lets get ready to do some typing.


Step #3

Ok, flex your fingers and get them loosened up for a bunch of typing alternatively most of what you see below can be cut and pasted to make it easier for you. Remember though, if you cut and paste you will have to change some things to match up with your map. I will keep the name of my map (mp_smoketest) through out this tutorial so you will have to change that to the name you gave your map everywhere that is necessary. This would include your naming of the files and names within those files such as your .gsc, .csv and the to be created _fx.gsc.

***A tip at this time. Always use NOTEPAD to modify or create these files as anything else usually (invisibly) adds coding to the file that will cause errors in the game since it does not recognize the additional coding values.


Here are the file structures that (for me at any rate) worked.

Ok, either open up your existing .gsc file or by using NOTEPAD create one.

Here is my final mp_smoketest.gsc from raw/maps/mp

main()
{
maps\mp\mp_smoketest_fx::main();
maps\createfx\mp_smoketest_fx::main();
maps\mp\_load::main();
game["allies"] = "marines";
game["axis"] = "opfor";
game["attackers"] = "axis";
game["defenders"] = "allies";
game["allies_soldiertype"] = "desert";
game["axis_soldiertype"] = "desert";
setdvar( "r_specularcolorscale", "1" );
setdvar("r_glowbloomintensity0",".1");
setdvar("r_glowbloomintensity1",".1");
setdvar("r_glowskybleedintensity0",".1");
setdvar("compassmaxrange","1500");
}


As you can see this .gsc file looks and is pretty much the same as any other basic .gsc. What you will notice though is that I have added these two new lines at the beginning or top of the file. (They are the two in bold print).

maps\mp\mp_smoketest_fx::main();
maps\createfx\mp_smoketest_fx::main();

These will make the game go and look for the files that make your effect work. This .gsc file is now ready to work so make sure you save it and that it is in your raw/maps/mp folder.

Step #4

Ok, now we move on to the _fx.gsc. If you already have one then great but if not remember to use NOTEPAD to make one. If you have one already make sure that it looks like mine below or you may have some troubles later.

Here is my mp_smoketest_fx.gsc from raw/maps/mp


main()
{
level._effect[ "fire" ] = loadfx("fire/tank_fire_turret_abrams");
level._effect[ "smoke" ] = loadfx("smoke/thin_black_smoke_M");
/#
if ( getdvar( "clientSideEffects" ) != "1" )
maps\createfx\mp_smoketest_fx::main();
  1. / (for some reason this comes out looking wrong in this wiki - it should be the number symbol followed by /)
}

Ok lets break this down a bit. The first part of the line names your effect and tells the game which fx you want to have shown ingame.

[ “fire” ] you can name this whatever you like. If you have other fire fx in your map then do like I would do and give it a name unique to each instance in your map. For instance;

You have a tank on fire and a structure on fire. You could name them here like this….

Level._effect[ “firetank” ] and Level._effect[ “firestructure” ] so that you can keep track of the different fx’s. Remember that each requires its own line in the file structure. You can have as many effects running or called from here as you want in your game. There are limits to what is tasteful and too many can slow down the FPS ingame.

The second part of the line ( = loadfx(“fire/tank_fire_turret_abrams”); calls for and loads the actual fx that will be seen ingame.

All the fx’s and different categories of fx’s are found in the /raw/fx folder. You will notice that each fx in the raw/fx folders end with the extension .efx. You do NOT have to include this extension in the _fx.gsc. Another thing to remember is that when you open your raw/fx folder you will see all the available sub-folders of the different fx’s. These include /smoke and /fire. ****Some tutorials will show that your loadfx line should look like this following example;

= loadfx(“fx/tank_fire_turret_abrams.efx”);

This would be wrong as cod4 assumes or knows where the fx folder is and all fx end with .efx. So DON’T include them in the line. Do it as I have shown above.

Don’t be afraid to try some of the different fx files that are available. You will find through trial which one works and looks best in your map.

You are now done with the _fx.gsc part. Save it with your map name (mp_smoketest_fx.gsc) in your /raw/maps/mp folder.


Step #5

Lets prepare things for this very important step.

1> Go to your /raw/maps folder. Create a new folder called createfx. When completed you will have /raw/maps/createfx folder available for this step.

2> Go and drag your previously created _fx.gsc file that you put in raw/maps/mp and drop it into this new createfx folder. ( sounds crazy but do it anyway ) LOL

3> Now that you have the _fx.gsc in this new createfx folder open it with notepad and immediately select all the content and delete it. ( sounds really crazy but it has to die at this point since you are going to replace it with new stuff )

4> Now cut and paste the following into this new (empty) _fx.gsc.





main()
{
ent = maps\mp\_utility::createOneshotEffect( "fire/tank_fire_turret_abrams");
ent.v[ "origin" ] = ( 120, -576, 112 );
ent.v[ "angles" ] = ( 270, 0, 0 );
ent.v[ "fxid" ] = "fire";
ent.v[ "delay" ] = -3;
ent = maps\mp\_utility::createOneshotEffect( "smoke/thin_black_smoke_M");
ent.v[ "origin" ] = ( 192, -576, 80 );
ent.v[ "angles" ] = ( 270, 0, 0 );
ent.v[ "fxid" ] = "smoke";
ent.v[ "delay" ] = -3;
}


Lets break these lines down as well to understand what they do for a living.

ent = maps\mp\_utility::createOneshotEffect( "fire/tank_fire_turret_abrams");

This line lets the game know that there is a specific fx happening here.

ent.v[ "origin" ] = ( 120, -576, 112 );

This one is important because this is where you will replace the coordinates shown here with the coordinates that you wrote down for the fx location that I had you do in Step #2. They are in order xyz. I will wait while you go and find them and enter them…….

ent.v[ "angles" ] = ( 270, 0, 0 );

I would suggest that you leave this value alone. I have tested with different values but have seen no difference ingame.

ent.v[ "fxid" ] = "fire";

This one is very important. The part “fire” must be the same name that you gave the fx back in step #4. (level._effect[ "fire" ]). If they don’t match you will get an error and it most definitely will not show up ingame.


ent.v[ "delay" ] = -3;

This final value is the one that controls how often or quickly the fx will loop or repeat itself ingame.

As you add more fx you can simply cut and paste a section of the values shown and then modify them to match the new fx. Always remember to save your changes.

That’s it for this section. Im having a coffee while I write this tut so feel free to have one too.

Step #5

Finally we have arrived at the last section of things to do.

As with all maps, fx enriched or not, you must have a .csv file.

If you have one already then great and if you don’t then you have to make one in excel. Not to worry though as you can cut and paste the one that I have but remember to change all lines that are required to reflect the names and needs of your map.

Remember that the .csv goes in your /zone_source folder.


Here is my .csv as found in my /zone_source folder


ignore code_post_gfx_mp
ignore common_mp
ignore localized_code_post_gfx_mp
ignore localized_common_mp
col_map_mp maps/mp/mp_smoketest.d3dbsp
rawfile maps/mp/mp_smoketest.gsc
rawfile maps/mp/mp_smoketest_fx.gsc
rawfile maps/createfx/mp_smoketest_fx.gsc
impactfx mp_smoketest
sound common mp_smoketest !all_mp
sound generic mp_smoketest !all_mp
sound voiceovers mp_smoketest !all_mp
sound multiplayer mp_smoketest !all_mp
include mptypes_desert
fx fire/tank_fire_turret_abrams
fx smoke/thin_black_smoke_M


The lines in bold shown above must be there in order for the fx’s to show up so make sure that either the program has updated this file or simply add them yourself. Again, if you cut and pasted my .csv then you must change the values to match your map name and requirements.


Step #6


Ok, I know I said that the last step was the last but do this one anyway……


Make sure that you always update your zone files, fast files, reflections, bsp while you make changes to your map. Failing to do this will result in things not working right and this can lead to frustration and the desire to take up smoking or tearing your hair out.

Though this tutorial was made for the smoke and fire fx’s you will find that the procedures are the same for adding any fx to your map.

Good luck with this. It really isn’t as difficult as it seems. If I can learn it anyone can. Don’t hesitate to contact me in the forums or via pm at http://www.codutility.com

Thanks, Ray



Here is a screenshot of the final effect ingame.


[img]http://www.oldmanray.com/sftut/tankfire.jpg[[/img]

Articles in category "Scripting"

There are 4 articles in this category.

F

M

S

Personal tools