main()
{
precacheFX();
}
precacheFX()
{
level._effect["fire"] = loadfx ("fx/fire/tinybon.efx");
maps\mp\_fx::loopfx("fire", (2544, 184, -88), 0.6);
level._effect["smoke"] = loadfx ("fx/smoke/ash_smoke.efx");
maps\mp\_fx::loopfx("smoke", (2544, 184, -88), 0.7);
}
windowBreakInit()
{
//Breakable Windows Multiplayer Script by n00bCODmapper
/************************************************** *************************
This script is a a heavy modification of the _window.gsc file that comes with CoD.
This modification was necessary to make breakable windows work in multiplayer.
************************************************* ***************************/
windows = getentarray("window","targetname"); //find everything with targetname "window"
if(isdefined(windows)) //if there were window triggers found
{
windowfx = loadfx ("fx/impacts/glass_shatter2.efx"); //define the glass effect
for(i=0;i<windows.size;i++) //start threads listening for all window triggers
{
windows[i] thread window(windowfx);
}
}
//end breaking windows main
}
//Necessary function for Breakable Windows Multiplayer Script
window(windowfx) //This determines where, when, and how to play the glass breaking effect
{
if(!isdefined(self.target)) //see if window trigger still exists
{
iprintln("no target key found for window trigger at ", self getorigin());
return;
}
window = getent(self.target,"targetname"); //get the targetname (id) for window
if(!isdefined(window)) //see if trigger has target (the unbroken window)
{
iprintln("window not found for window trigger at ", self getorigin());
return;
}
if(!isdefined(window.origin)) //check for origin key on window
{
iprintln("origin key not found for window at ", self getorigin());
return;
}
self enableGrenadeTouchDamage(); //grenade impact will break window
window disableGrenadeBounce(); //so you can throw grenades through
if(isdefined(window.target)) //see if window has target (the broken window)
brokenwindow = getent(window.target,"targetname"); //get the targetname for broken window
/*
Origins are the smallest values of x, y, and z on your brush.
*/
org = spawn("script_origin",window.origin); //copy of origin of this trigger? Sets up an org.origin array.
sampledist = 1; //accuracy in determiniting size of window
spacing = 24; //distance between each small breaking glass effect
while(org istouching(window)) //determines end of trigger along x axis to nearest 1 unit, windows that are not aligned with an axis will not work because of this.
{
org.origin += (sampledist,0,0);
}
xendorg = org.origin; //record largest whole x value
xdist = org.origin[0]-window.origin[0]; //record size along x axis
org.origin = window.origin;
while(org istouching(window)) //determines end of trigger along y axis to nearest 1 unit
{
org.origin += (0,sampledist,0);
}
yendorg = org.origin; //record largest whole y value
ydist = org.origin[1]-window.origin[1]; //record size along y axis
org.origin = window.origin;
while(org istouching(window)) //determines end of trigger along z axis to nearest 1 unit
{
org.origin += (0,0,sampledist);
}
zendorg = org.origin; //record largest whole z value
zdist = org.origin[2]-window.origin[2]; //record size along z axis
point = []; //will hold all of the points to start glass effects
if(ydist>xdist) //window is aligned along the x axis, windows running along z axis will not work because of this.
{
direction = vectornormalize(xendorg-window.origin); //creates a vector perpendicular to the window for the width of the effect. Note that the width of the trigger will affect how far glass flies.
ycount = (int)(ydist)/spacing; //determines how many effects along y axis (rounds down)
if(!(ycount))
ycount = 1; //must have at least 1
zcount = (int)(zdist)/spacing; //determines how many effects along z axis (rounds down)
if(!(zcount))
zcount = 1; //must have at least 1
ystart = window.origin[1]+((ydist - (ycount*spacing))/2); //Since the effect has a pretetermined size, make the amount of error equal on both sides.
zstart = window.origin[2]+((zdist - (zcount*spacing))/2); //Since the effect has a pretetermined size, make the amount of error equal on both sides.
//Determine where center points are for glass effect.
for(x=0;x<ycount;x++)
{
for(y=0;y<zcount;y++)
{
point[x][y] = (window.origin[0], ystart+(spacing*x), zstart+(spacing*y));
}
}
}
else //window is aligned along the x axis
{
direction = vectornormalize(yendorg-window.origin); //creates a vector perpendicular to the window for the width of the effect. Note that the width of the trigger will affect how far glass flies.
xcount = (int)(xdist)/spacing; //determines how many effects along x axis (rounds down)
if(!(xcount))
xcount = 1; //must have at least 1
zcount = (int)(zdist)/spacing; //determines how many effects along z axis (rounds down)
if(!(zcount))
zcount = 1; //must have at least 1
xstart = window.origin[0]+((xdist - (xcount*spacing))/2); //Since the effect has a pretetermined size, make the amount of error equal on both sides.
zstart = window.origin[2]+((zdist - (zcount*spacing))/2); //Since the effect has a pretetermined size, make the amount of error equal on both sides.
//Determine where center points are for glass effect.
for(x=0;x<xcount;x++)
{
for(y=0;y<zcount;y++)
{
point[x][y] = (xstart+(spacing*x), window.origin[1], zstart+(spacing*y));
}
}
}
org delete(); //free memory
window show(); //show unbroken window
if(isdefined(brokenwindow)) //Broken window brush isn't necessary
{
brokenwindow hide(); //make broken window disappear.
brokenwindow notsolid(); //allow player to move through broken window.
}
breaktype = self breakwait(); //Function is defined below. There it waits for window break event.
if(isdefined(brokenwindow))
{
brokenwindow show(); //show broken window
}
window hide(); //hide unbroken window
if(breaktype != "smallbreak") //bigbreak
{
direction = vectormultiply(direction,5); //enhance the distance particles fly
}
//Use the info gathered earlier to play the effects
for(i=0;i<point.size;i++)
{
for(j=0;j<point[i].size;j++)
{
//iprintln("point = " + point[i][j]);
//iprintln("window origin = " + window.origin);
playfx(windowfx,point[i][j],direction); //this is the money shot
}
}
wait 1; //allow effects to finish playing out before thread ends
window delete(); //remove unbroken window
self delete(); //remove trigger
}
//Necessary function for Breakable Windows Multiplayer Script
//Determine big or small break, affecting how far glass flies
breakwait()
{
totaldamage = 0;
while(1) //Thread hangs here waiting for sufficient damage on the trigger
{
self waittill ("damage",amount);
if(amount > 95)
{
return ("bigbreak");
}
totaldamage += amount; //window accumulates damage
if(totaldamage > 150) //The trigger has been set off
break;
}
return ("smallbreak");
}
//Necessary function for Breakable Windows Multiplayer Script
vectormultiply(vec, dif) //used to enhance the direction vector so glass flies farther
{
vec = (vec[0] * dif, vec[1] * dif, vec[2] * dif);
return vec;
}
/*****To Do List****
Make windows Z axis capable.
Make windows able to run diagonally.
Make effects sequence start in middle and spiral out to edges.
Get rid of having to create an origin key or simplify use of origin key.
- I know how to do these but it will take time.
Watch the tutorial thread this was originally posted on for updates to address these things.
********************/
// Original by lordblank
// Rewritten by Snake Shift
elevatorInit()
{
level.elevatorDown = false; // elevator starts at bottom: true/false
level.elevatorMoving = false; // elevator is not currently moving
thread elevator_start();
}
elevator_start()
{
elevator = getentarray ("elevatorswitch","targetname");
if ( isdefined(elevator) )
for (i = 0; i < elevator.size; i++)
elevator[i] thread elevator_think();
}
elevator_think()
{
while (1)
{
self waittill ("trigger");
if(!level.elevatorMoving)
thread elevator_move();
}
}
elevator_move()
{
elevatormodel = getent ("elevatormodel", "targetname");
level.elevatorMoving = true;
speed = 4;
height = 272;
wait (1);
if (level.elevatorDown) // moves to top
{
elevatormodel moveZ (height, speed);
elevatormodel waittill ("movedone");
level.elevatorDown = false;
} else { // moves to bottom
elevatormodel moveZ (height - (height * 2), speed);
elevatormodel waittill ("movedone");
level.elevatorDown = true;
}
level.elevatorMoving = false;
}