Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 159 Guests
Online:

LATEST FORUM THREADS

»
Mohaa maps on Cod2?
CoD2 MP Mapping
is this place alive?
CoDBO3 Mapping
Call of DutyŽ: WWII
CoD WW2 General

Tutorials

»
CoD Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Adding Thunder and Lightning
Versions: You must be logged in to view history.
How to add thunder and lightning to you CoD map
This is great work by Synman and Hellspawn

user posted image user posted image user posted image


First let's get the Radiant part out of the way.
Create an 8x8x8 brush and give it the NO DRAW texture on all sides. Convert it to a script_brushmodel and give it a targetname of "lightning". Place it somewhere in your map where you don't have to worry about a player stumbling on it and recompile.

The next step involves you mapping out acceptable areas within your
geometry where you want the lightning to occur. I do not recommend having lightning strike in playable area of your map (although the thought of associating a trigger_hurt or damageradius with this was very tempting) because it takes away from the realism.

In main() add the following:

CODE

level._effect["cloudflash1"] = loadfx ("fx/atmosphere/cloudflash1.efx");
thread do_cloudflashes();


Paste the following somewhere in your .gsc:

CODE

do_cloudflashes() {
while (1) {
wait randomint(5) + 1;
x=randomint(7000) - 3500;
y=randomint(7000) - 3500;
z=randomint(1800) + 200;

thread lightningBolt((x, y, z));
}
}


A couple things here:
    wait randomint(10) + 1 is the maximum number of seconds that will elapse before a lightning bolt is rendered.

    dimension = randomint(distance) - minimum

    You need to do define thresholds for each of your three dimensions (x, y, & z). That is why you see this statement three times. Basically what we're doing here is establishing acceptable places (vectors) to render a lightning bolt.

    Distance equals the absolute value of your minimum grid value plus the real value of your maximum grid value. Grid values refer to where something is in your map. abs(min) + max

    Lets say I have an area on my map that begins for X at -3000 and I want to extend the area to X coordinate 3000. The distance between those two points is 6000 units abs(-3000) + 3000 = 6000.

    By subtracting the minimum value from our distance we're able to use it as the base for our random number generator. randomint(6000) - 3000 tells the engine to pick a random number between -3000 and +3000.

    I've added my own exclusion ranges here with a simple nested if statement. You can represent yours similarly. In a nutshell, I'm only going to accept two random xy combinations. This limits the lightning to two key areas on my map.

    When defining Z, you're actually defining the distance from the top of your skybox to your terrain. Your maximum value should be the highest point on your map and your minimum is your "ground". This is necessary so that we can define the longest possible value for our lightning bolt. You may need to tweak this given your needs. In this example my ground level is actually about -200 units so you can see I made some subjective adjustments.

    Here is the sound alias you need for "cloudflash2"
CODE

cloudflash2 explosions/explo_distant04.wav 0.8 1.07 0.9 1.1 50000000 0 auto


Add the following code to your .gsc:
CODE

lightningBolt(v) {
x = v[0];
y = v[1];
z = 1800; // Max. Z-Value of Skybox
l = v[2];
arcs = randomint(7) + 3;
positive = true;
for (a = 0; a < arcs; a++) {
arcvariant = randomint(7) + 1;
avFloat = (float)arcvariant / 10;
len = randomint( (l * avFloat) ) + 1;
offset = z - len;
inc = randomint(2) + 1;
inc = inc * 10;
if (positive)
positive = false;
else {
inc = inc * -1;
positive = true;
}
for (z=z; z > offset; z-=15) {
thread drawlightning((x, y, z));
y+=inc;
wait .001;
}
l = l - len;
}
wait .05;
playSoundAtLocation( "expl_dist04", (x, y, z));
}

// playSoundAtLocation compliments of Hellspawn
playSoundAtLocation( sound, location ) {
org = spawn( "script_model", location );
wait 0.05;
org show();
org playSound( sound, "sounddone" );
wait 5;
org delete();
return;
}



This function does all the magic. There isn't much you need to know here.

The one change you need to make is bolded above. This is the maximum Z value for your map (the top of your skybox).

Feel free to experiment. One thought I had was adding additional "branches" to the bolt, but I didn't get around to it.

Finally, wrap up with the following snipit in your .gsc:
CODE

drawlightning(v)
{
playfx(level._effect["cloudflash1"], v);
}


All this function does is render a single point in each arc of the bolt. Its called multiple times per per arc per bolt.

Your script should look something like this
CODE

// Original by Synman
// Enhanced by Hellspawn

main() {
mapsmp_load::main();
// mapsmpweather_flash::main();

game["allies"] = "american";
game["axis"] = "german";
game["american_soldiertype"] = "airborne";
game["american_soldiervariation"] = "normal";
game["german_soldiertype"] = "german_waffen";
game["german_soldiervariation"] = "normal";

level._effect["cloudflash1"] = loadfx ("fx/atmosphere/cloudflash1.efx");
thread do_cloudflashes();
}

do_cloudflashes() {
while (1) {
wait randomint(5) + 1;
x=randomint(7000) - 3500;
y=randomint(7000) - 3500;
z=randomint(1800) + 200;

thread lightningBolt((x, y, z));
}
}

lightningBolt(v) {
x = v[0];
y = v[1];
z = 1800; // Max. Z-Value of Skybox
l = v[2];
arcs = randomint(7) + 3;
positive = true;
for (a = 0; a < arcs; a++) {
arcvariant = randomint(7) + 1;
avFloat = (float)arcvariant / 10;
len = randomint( (l * avFloat) ) + 1;
offset = z - len;
inc = randomint(2) + 1;
inc = inc * 10;
if (positive)
positive = false;
else {
inc = inc * -1;
positive = true;
}
for (z=z; z > offset; z-=15) {
thread drawlightning((x, y, z));
y+=inc;
wait .001;
}
l = l - len;
}
wait .05;
playSoundAtLocation( "expl_dist04", (x, y, z));
}

// playSoundAtLocation compliments of Hellspawn
playSoundAtLocation( sound, location ) {
org = spawn( "script_model", location );
wait 0.05;
org show();
org playSound( sound, "sounddone" );
wait 5;
org delete();
return;
}

drawlightning(v) {
playfx(level._effect["cloudflash1"], v);
}


Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»