Call of Duty 5: FXs

From COD Modding & Mapping Wiki
Jump to navigation Jump to search


NOTE: This tutorial, taken from the Treyarch Wiki, has been edited as the original code doesnt work

Creating your FX

In this tutorial we will be using a very simple but effective way to add effects to your map.

The very first thing we need to do, is to make sure that you have a mp_yourmapsname.csc in raw/clientscripts/mp, if you do not have one then you need to create one, once you have created one copy and paste these lines into it, you may need to change the team nationalities as well.

Make sure you replace any reference to mp_yourmapsname with the name of your map, also! When editing files always make sure you make backup copies first.

csc file

#include clientscripts\mp\_utility;

main()
{

	// If the team nationalites change in this level's gsc file,
	// you must update the team nationality here!
	level.allies_team = "marines";
	level.axis_team   = "german";

	// _load!
	clientscripts\mp\_load::main();

        // clientscripts\mp\mp_yourmapsname_fx::main();

	thread clientscripts\mp\_fx::fx_init(0);
	thread clientscripts\mp\_audio::audio_init(0);

	// thread clientscripts\mp\mp_yourmapsname_amb::main();

	// This needs to be called after all systems have been registered.
	thread waitforclient(0);

	println("*** Client : mp_yourmapsname running...");

}

Adding your script origins

The first thing you need to do is decide where you want to put your fx, once you have decided, right click in the 2d screen and select...

script/origin

In order to get the correct co-ords you need to deselect your script origin then select it again, press 'n' to bring up the entity window, and now you will have the correct co-ords, basically what happens is, when you move the script origin and then press 'n' while keeping it constantly highlighted it remembers the co-ords from its last position and retains those, this is why you have to deselect it and reselect it to get the correct co-ords.

when adding script origins I always leave them in, I never delete them from my map, mainly because if I have a lot of the same fx in the map and I want to either change an fx or delete it then I can just get the co-ords from the script origin and use 'find' in my fx.gsc file to find that particular fx, if you have too many script origins and script_structs in your map press 'f' to bring up the filter window and deselect 'script origins', now they will be hidden.

Create a new text document on your desktop called

fx_co-ords.txt.

Copy the co-ords from your cript origin and paste them into your 'fx_co-ords.txt file on your desktop, Once you have copied and pasted your co-ords into fx_co-ords.txt it should look something like this

48 110 236

In order for your fx to work properly in your fx.gsc file you need to add comma's

so now it should look like this

48, 110, 236

Without these comma's your fx won't work.

Now you need to create a 'fx.gsc file in...

raw/maps/mp

Now copy and paste these lines in to your newly created fx.gsc file.

#include maps\mp\_utility;

main()
{
        precacheFX();
        spawnFX();
}

precacheFX()
{
        level._effect["mp_fire_medium"] = loadfx("maps/mp_maps/fx_mp_fire_medium");
}

spawnFX()
{
        playLoopedFx(level._effect["mp_fire_medium"], 4, (0,0,0), 0, anglestoforward ((270,0,0)), anglestoup((270,0,0)));
}


Now save it.

Adding lines to your .gsc and zone files

Now we need to edit your mp_yourmapsname.gsc file which you will find in..

raw\maps\mp

Now add this line...

maps\mp\mp_yourmapname_fx::main();

Add the line directly below

maps\mp\_load::main();

So now it should look like this...

maps\mp\_load::main();
maps\mp\mp_yourmapname_fx::main();

Now we need to edit your mp_yourmapsname.csv file which you will find in...

raw\zone_source

Now add these two lines...

rawfile,maps\mp\mp_yourmapname_fx.gsc

fx,maps/mp_maps/fx_mp_fire_medium

Thats it! Now if you compile and run your map and you should now see your fire effect.

Description of your FX GSC

1. Your main function.

main()
{
        precacheFX();
        spawnFX();
}

This can do everything if you want but for organization purposes it is advised you have at least both these functions to separate the steps.

2. precacheFX() and spawnFX() functions.

precacheFX()
{
        level._effect["mp_fire_medium"] = loadfx("maps/mp_maps/fx_mp_fire_medium");
}

(level._effect["mp_fire_medium"]) the name "mp_fire_medium" will be referenced by all your scripts, this can be anything.

3.spawnFX() function

spawnFX()
{
        playLoopedFx(level._effect["mp_fire_medium"], 4, (0,0,0), 0, anglestoforward ((270,0,0)), anglestoup((270,0,0)));
}

Description of functions

playLoopedFx(level._effect["FX Name"], Repeat Rate in seconds, (position XYZ), 0, anglestoforward((Front direction XYZ)), anglestoup((Up direction XYZ)));

Introduction into scripting

Intro To Scripting


Sources: Treyarch's Wiki


--arachnofang 10:36, 7 July 2010 (UTC)