UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - RamboBadass

 ;D ;D ;D ;D ;D ;D


Dan and I by round 23 very fun thank UGX Team
10 years ago
......so ya who noticed the background ????? ::)
10 years ago
someones map file
made by Gbomb
10 years ago
hey guys not going to show much but I have a nice Christmas map in the works

Features
* UGX Mod 1.0.4
* Snow lol
* tons of other good stuff that im not going to give away :-x .... Put it this way these features will blow your mind

I might add more info tonight, while being board off my ass at work :-\
10 years ago
STOP WITH THE DAMN GROUP CALLS THEN!!!  >:(
10 years ago
10 years ago
hey guys

so I finished my origins guns made weapon files added them to the mod and mod.csv. also updated my dlc3_code.gsc and zombiemode_weapons.gsc.... and get nothing, but if I type give five7 it gives the gun... what am in missing? ??? I have also recompiled the map and mod 10 times lol

heres my zombiemode_weapons

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;
#using_animtree( "redspace_box" );

init()
{
init_weapons();
init_weapon_upgrade();
init_pay_turret();
init_weapon_cabinet();
treasure_chest_init();
level thread add_limited_tesla_gun();
level thread set_box_hideModels();
level.box_moved = false;
}

add_zombie_weapon( weapon_name, hint, cost, weaponVO, variation_count, ammo_cost  )
{
if( IsDefined( level.zombie_include_weapons ) && !IsDefined( level.zombie_include_weapons[weapon_name] ) )
{
return;
}

add_weapon_to_sound_array(weaponVO,variation_count);

// Check the table first
table = "mp/zombiemode.csv";
table_cost = TableLookUp( table, 0, weapon_name, 1 );
table_ammo_cost = TableLookUp( table, 0, weapon_name, 2 );

if( IsDefined( table_cost ) && table_cost != "" )
{
//cost = round_up_to_ten( int( table_cost ) );
}

if( IsDefined( table_ammo_cost ) && table_ammo_cost != "" )
{
//ammo_cost = round_up_to_ten( int( table_ammo_cost ) );
}

PrecacheItem( weapon_name );
PrecacheString( hint );

struct = SpawnStruct();

if( !IsDefined( level.zombie_weapons ) )
{
level.zombie_weapons = [];
}

struct.weapon_name = weapon_name;
struct.weapon_classname = "weapon_" + weapon_name;
struct.hint = hint;
struct.cost = cost;
struct.sound = weaponVO;
struct.variation_count = variation_count;
struct.is_in_box = level.zombie_include_weapons[weapon_name];

if( !IsDefined( ammo_cost ) )
{
ammo_cost = round_up_to_ten( int( cost * 0.5 ) );
}

struct.ammo_cost = ammo_cost;

level.zombie_weapons[weapon_name] = struct;
}

default_weighting_func()
{
return 1;
}

default_tesla_weighting_func()
{
num_to_add = 1;
if( isDefined( level.pulls_since_last_tesla_gun ) )
{
// player has dropped the tesla for another weapon, so we set all future polls to 20%
if( isDefined(level.player_drops_tesla_gun) && level.player_drops_tesla_gun == true )
{
num_to_add += int(.2 * level.zombie_include_weapons.size);
}

// player has not seen tesla gun in late rounds
if( !isDefined(level.player_seen_tesla_gun) || level.player_seen_tesla_gun == false )
{
// after round 10 the Tesla gun percentage increases to 20%
if( level.round_number > 10 )
{
num_to_add += int(.2 * level.zombie_include_weapons.size);
}
// after round 5 the Tesla gun percentage increases to 15%
else if( level.round_number > 5 )
{
// calculate the number of times we have to add it to the array to get the desired percent
num_to_add += int(.15 * level.zombie_include_weapons.size);
}
}
}
return num_to_add;
}

default_ray_gun_weighting_func()
{
if( level.box_moved == true )
{
num_to_add = 1;
// increase the percentage of ray gun
if( isDefined( level.pulls_since_last_ray_gun ) )
{
// after 12 pulls the ray gun percentage increases to 15%
if( level.pulls_since_last_ray_gun > 11 )
{
num_to_add += int(level.zombie_include_weapons.size*0.15);
}
// after 8 pulls the Ray Gun percentage increases to 10%
else if( level.pulls_since_last_ray_gun > 7 )
{
num_to_add += int(.1 * level.zombie_include_weapons.size);
}
}
return num_to_add;
}
else
{
return 0;
}
}


//
// Slightly elevate the chance to get it until someone has it, then make it even
default_cymbal_monkey_weighting_func()
{
players = get_players();
count = 0;
for( i = 0; i < players.size; i++ )
{
if( players[i] has_weapon_or_upgrade( "zombie_cymbal_monkey" ) )
{
count++;
}
}
if ( count > 0 )
{
return 1;
}
else
{
if( level.round_number < 10 )
{
return 3;
}
else
{
return 5;
}
}
}


include_zombie_weapon( weapon_name, in_box, weighting_func )
{
if( !IsDefined( level.zombie_include_weapons ) )
{
level.zombie_include_weapons = [];
}
if( !isDefined( in_box ) )
{
in_box = true;
}

level.zombie_include_weapons[weapon_name] = in_box;

if( !isDefined( weighting_func ) )
{
level.weapon_weighting_funcs[weapon_name] = maps\_zombiemode_weapons::default_weighting_func;
}
else
{
level.weapon_weighting_funcs[weapon_name] = weighting_func;
}
}

init_weapons()
{
// Zombify
PrecacheItem( "zombie_melee" );


// Pistols
add_zombie_weapon( "mouser", "", 25, "vox_crappy", 8 );
add_zombie_weapon( "mouser_upgraded", "", 25, "vox_crappy", 8 );
add_zombie_weapon( "b23r", "B23R", 25, "vox_crappy", 8 );
add_zombie_weapon( "b23r_upgraded", "B23R Upgraded", 25, "vox_crappy", 8 );
add_zombie_weapon( "five7", "Five-Seven", 25, "vox_crappy", 8 );
add_zombie_weapon( "five7_upgraded", "Five-Seven Upgraded", 25, "vox_crappy", 8 );
add_zombie_weapon( "kap40", "", 25, "vox_crappy", 8 );
add_zombie_weapon( "kap40_upgraded", "", 25, "vox_crappy", 8 );
add_zombie_weapon( "rnma", "", 25, "vox_crappy", 8 );
add_zombie_weapon( "rnma_upgraded", "", 25, "vox_crappy", 8 );

// Grenades                                         
add_zombie_weapon( "fraggrenade", "Frag Grenade", 250, "" , 0 );

// Scoped
add_zombie_weapon( "dsr", "", 750, "vox_ppsh", 5);
add_zombie_weapon( "dsr_upgraded", "", 750, "vox_ppsh", 5);
add_zombie_weapon( "ballista", "Ballista", 750, "vox_ppsh", 5);
add_zombie_weapon( "ballista_upgraded", "Ballista Upgraded", 750, "vox_ppsh", 5);

// SMG
add_zombie_weapon( "zombie_mp40", "MP40", 1000, "vox_mp40", 2 );
add_zombie_weapon( "zombie_mp40_upgraded", "MP40 Upgraded", 1000, "vox_mp40", 2 );
add_zombie_weapon( "zombie_ppsh", "", 2000, "vox_ppsh", 5 );
add_zombie_weapon( "zombie_ppsh_upgraded", "", 2000, "vox_ppsh", 5 );
add_zombie_weapon( "msmc", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "msmc_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "pdw", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "pdw_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "scorpion", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "scorpion_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "bo2_mp7", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "bo2_mp7_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "m1927", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "m1927_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "chicom", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "chicom_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "ak74u_zm", "AK-74u", 1800, "vox_mg" , 5 );
add_zombie_weapon( "ak74u_zm_upgraded", "AK-74u Upgraded", 1800, "vox_mg" , 5 );

// Assault Rifle                                                                                 
add_zombie_weapon( "zombie_stg44", "STG-44", 1200, "vox_mg", 9 );
add_zombie_weapon( "zombie_stg44_upgraded", "STG-44_Upgraded", 1200, "vox_mg", 9 );
add_zombie_weapon( "an94_mp", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "an94_mp_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "m27", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "m27_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "scar_h", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "scar_h_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "type25", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "type25_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "mtar", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "mtar_upgraded", "", 1800, "vox_mg" , 5 );
add_zombie_weapon( "m14", "M14", 1800, "vox_mg" , 5 );
add_zombie_weapon( "m14_upgraded", "M14 Upgraded", 1800, "vox_mg" , 5 );

// Shotguns                                         
add_zombie_weapon( "remington", "Remington 870 MCS", 1500, "vox_shotgun", 6);
add_zombie_weapon( "remington_upgraded", "Remington 870 MCS Upgraded", 1500, "vox_shotgun", 6);
add_zombie_weapon( "ksg", "", 1500, "vox_shotgun", 6);
add_zombie_weapon( "ksg_upgraded", "", 1500, "vox_shotgun", 6);

// Heavy Machineguns 
add_zombie_weapon( "zombie_mg08", "", 3000, "vox_mg" , 9 );
add_zombie_weapon( "zombie_mg08_upgraded", "", 3000, "vox_mg" , 9 );
add_zombie_weapon( "hamr_mp", "", 3000, "vox_mg" , 9 );
add_zombie_weapon( "hamr_mp_upgraded", "", 3000, "vox_mg" , 9 );

// Special                                         
//add_zombie_weapon( "mine_bouncing_betty", "Claymore", 1000, "" );
add_zombie_weapon( "zombie_cymbal_monkey", "", 2000, "vox_monkey", 3 );
add_zombie_weapon( "ray_gun", "", 10000, "vox_raygun", 6 );
add_zombie_weapon( "ray_gun_upgraded", "", 10000, "vox_raygun", 6 );
add_zombie_weapon( "raguma", "", 15000, "vox_raygun", 6 );
add_zombie_weapon( "raguma_upgraded", "", 15000, "vox_raygun", 6 );

if(level.script != "nazi_zombie_prototype")
{
Precachemodel("zombie_teddybear");
}
// ONLY 1 OF THE BELOW SHOULD BE ALLOWED
PrecacheModel("bo2_p6_anim_zm_tm_magic_box");
// add_limited_weapon( "m2_flamethrower_zombie", 1 );
// add_limited_weapon( "tesla_gun", 1);
add_limited_weapon( "raguma", 4);
}

//remove this function and whenever it's call for production. this is only for testing purpose.
add_limited_tesla_gun()
{

weapon_spawns = GetEntArray( "weapon_upgrade", "targetname" );

for( i = 0; i < weapon_spawns.size; i++ )
{
hint_string = weapon_spawns[i].zombie_weapon_upgrade;
if(hint_string == "tesla_gun")
{
weapon_spawns[i] waittill("trigger");
weapon_spawns[i] trigger_off();
break;

}

}

}


add_limited_weapon( weapon_name, amount )
{
if( !IsDefined( level.limited_weapons ) )
{
level.limited_weapons = [];
}

level.limited_weapons[weapon_name] = amount;
}                                         

// For pay turrets
init_pay_turret()
{
pay_turrets = [];
pay_turrets = GetEntArray( "pay_turret", "targetname" );

for( i = 0; i < pay_turrets.size; i++ )
{
cost = level.pay_turret_cost;
if( !isDefined( cost ) )
{
cost = 1000;
}
pay_turrets[i] SetHintString( &"ZOMBIE_PAY_TURRET", cost );
pay_turrets[i] SetCursorHint( "HINT_NOICON" );
pay_turrets[i] UseTriggerRequireLookAt();

pay_turrets[i] thread pay_turret_think( cost );
}
}

// For buying weapon upgrades in the environment
// Upgraded with dynamic hintstrings by treminaor
init_weapon_upgrade()
{
weapon_spawns = [];
weapon_spawns = GetEntArray( "weapon_upgrade", "targetname" );

for( i = 0; i < weapon_spawns.size; i++ )
{
hint_string = get_weapon_hint( weapon_spawns[i].zombie_weapon_upgrade );

weapon_spawns[i] SetHintString( "Press &&1 to buy " + hint_string + " ^1[^7Cost: " + get_weapon_cost(weapon_spawns[i].zombie_weapon_upgrade) + "^1]" );
weapon_spawns[i] setCursorHint( "HINT_NOICON" );
weapon_spawns[i] UseTriggerRequireLookAt();

weapon_spawns[i] thread weapon_spawn_think();
model = getent( weapon_spawns[i].target, "targetname" );
model hide();
}
}

// weapon cabinets which open on use
init_weapon_cabinet()
{
// the triggers which are targeted at doors
weapon_cabs = GetEntArray( "weapon_cabinet_use", "targetname" );

for( i = 0; i < weapon_cabs.size; i++ )
{

weapon_cabs[i] SetHintString( &"ZOMBIE_CABINET_OPEN_1500" );
weapon_cabs[i] setCursorHint( "HINT_NOICON" );
weapon_cabs[i] UseTriggerRequireLookAt();
}

array_thread( weapon_cabs, ::weapon_cabinet_think );
}

// returns the trigger hint string for the given weapon
get_weapon_hint( weapon_name )
{
AssertEx( IsDefined( level.zombie_weapons[weapon_name] ), weapon_name + " was not included or is not part of the zombie weapon list." );

return level.zombie_weapons[weapon_name].hint;
}

get_weapon_cost( weapon_name )
{
AssertEx( IsDefined( level.zombie_weapons[weapon_name] ), weapon_name + " was not included or is not part of the zombie weapon list." );

return level.zombie_weapons[weapon_name].cost;
}

get_ammo_cost( weapon_name )
{
AssertEx( IsDefined( level.zombie_weapons[weapon_name] ), weapon_name + " was not included or is not part of the zombie weapon list." );

return level.zombie_weapons[weapon_name].ammo_cost;
}

get_is_in_box( weapon_name )
{
AssertEx( IsDefined( level.zombie_weapons[weapon_name] ), weapon_name + " was not included or is not part of the zombie weapon list." );

return level.zombie_weapons[weapon_name].is_in_box;
}

is_weapon_upgraded( weaponname )
{
if( !isdefined( weaponname ) )
{
return false;
}

weaponname = ToLower( weaponname );

upgraded = issubstr( weaponname, "_upgraded" );

return upgraded;

}

has_upgrade( weaponname )
{
has_upgrade = false;
if( IsDefined( level.zombie_include_weapons[weaponname+"_upgraded"] ) )
{
has_upgrade = self HasWeapon( weaponname+"_upgraded" );
}
return has_upgrade;
}

has_weapon_or_upgrade( weaponname )
{
has_weapon = false;
if (self maps\_laststand::player_is_in_laststand())
{
for( m = 0; m < self.weaponInventory.size; m++ )
{
if (self.weaponInventory[m] == weaponname || self.weaponInventory[m] == weaponname+"_upgraded" )
{
has_weapon = true;
}
}
}
else
{
// If the weapon you're checking doesn't exist, it will return undefined
if( IsDefined( level.zombie_include_weapons[weaponname] ) )
{
has_weapon = self HasWeapon( weaponname );
}

if( !has_weapon && isdefined( level.zombie_include_weapons[weaponname+"_upgraded"] ) )
{
has_weapon = self HasWeapon( weaponname+"_upgraded" );
}
}

return has_weapon;
}

using_weapon_or_upgrade( weaponname )
{
if( self GetCurrentWeapon() == weaponname || self GetCurrentWeapon() == weaponname+"_upgraded" )
{
return true;
}
return false;
}

// for the random weapon chest
treasure_chest_init()
{
flag_init("moving_chest_enabled");
flag_init("moving_chest_now");


level.chests = GetEntArray( "treasure_chest_use", "targetname" );

if (level.chests.size > 1)
{

flag_set("moving_chest_enabled");

while ( 1 )
{
level.chests = array_randomize(level.chests);

if( isdefined( level.random_pandora_box_start ) )
break;
   
if ( !IsDefined( level.chests[0].script_noteworthy ) || ( level.chests[0].script_noteworthy != "start_chest" ) )
{
break;
}

}

level.chest_index = 0;

while(level.chest_index < level.chests.size)
{

if( isdefined( level.random_pandora_box_start ) )
break;

            if(level.chests[level.chest_index].script_noteworthy == "start_chest")
            {
                 break;
            }
           
            level.chest_index++;     
      }

//init time chest accessed amount.

if(level.script != "nazi_zombie_prototype")
{
level.chest_accessed = 0;
}

if(isDefined(level.DLC3.usePandoraBoxLight) && level.DLC3.usePandoraBoxLight)
{
// Anchor target will grab the weapon spawn point inside the box, so the fx will be centered on it too
anchor = GetEnt(level.chests[level.chest_index].target, "targetname");
anchorTarget = GetEnt(anchor.target, "targetname");

level.pandora_light = Spawn( "script_model", anchorTarget.origin );
level.pandora_light.angles = anchorTarget.angles + (-90, 0, 0);
//temp_fx_origin rotateto((-90, (box_origin.angles[1] * -1), 0), 0.05);
level.pandora_light SetModel( "tag_origin" );
playfxontag(level._effect["lght_marker"], level.pandora_light, "tag_origin");
}
// DCS: we need a smaller light in the catacombs for paris, the generic one fills the area under the tower.
else if(level.script == "nazi_zombie_paris")
{
// Anchor target will grab the weapon spawn point inside the box, so the fx will be centered on it too
anchor = GetEnt(level.chests[level.chest_index].target, "targetname");
anchorTarget = GetEnt(anchor.target, "targetname");

level.pandora_light = Spawn( "script_model", anchorTarget.origin );
level.pandora_light.angles = (-90, 0, 0);
level.pandora_light SetModel( "tag_origin" );
//playfxontag(level._effect["lght_marker"], level.pandora_light, "tag_origin");
}

//determine magic box starting location at random or normal
init_starting_chest_location();

}

array_thread( level.chests, ::treasure_chest_think );

}

init_starting_chest_location()
{

for( i = 0; i < level.chests.size; i++ )
{

if( isdefined( level.random_pandora_box_start ) && level.random_pandora_box_start == true )
{
if( i != 0 )
{
level.chests[i] hide_chest();
}
else
{
level.chest_index = i;
unhide_magic_box( i );
}

}
else
{
if ( !IsDefined(level.chests[i].script_noteworthy ) || ( level.chests[i].script_noteworthy != "start_chest" ) )
{
level.chests[i] hide_chest();
}
else
{
level.chest_index = i;
unhide_magic_box( i );
level.main_chest = level.chests[i];
}
}
}


}

unhide_magic_box( index )
{

//PI CHANGE - altered to allow for more than one piece of rubble
rubble = getentarray( level.chests[index].script_noteworthy + "_rubble", "script_noteworthy" );
if ( IsDefined( rubble ) )
{
for ( x = 0; x < rubble.size; x++ )
{
rubble[x] hide();
}
//END PI CHANGE
}
else
{
println( "^3Warning: No rubble found for magic box" );
}
}

set_treasure_chest_cost( cost )
{
level.zombie_treasure_chest_cost = cost;
}

hide_chest()
{
pieces = self get_chest_pieces();

for(i=0;i<pieces.size;i++)
{
pieces[i] disable_trigger();
pieces[i] hide();
}
if(isDefined(self.firesale_pandora_light))
self.firesale_pandora_light delete();
}

get_chest_pieces()
{
// self = trigger

lid = GetEnt(self.target, "targetname");
org = GetEnt(lid.target, "targetname");
box = GetEnt(org.target, "targetname");

pieces = [];
pieces[pieces.size] = self;
pieces[pieces.size] = lid;
pieces[pieces.size] = org;
//pieces[pieces.size] = box;

return pieces;
}

play_crazi_sound()
{
self playlocalsound("temp_a_laugh");
wait 4;
self playlocalsound("temp_a_laugh");
}

// Redspace200 - Added for origins box (Begin custom functions)
grab_chest_visible_models() // Grabs the base part of all of the chests that exist and sets them to a level array variable
{
level.chest_model = [];
for(i=0;i<level.chests.size;i++) { level.chest_model[i] = getEnt("magic_box_base_"+i,"targetname");
level.chest_model[i] thread weapon_box_anims(); }
}
setup_box_model()
{
// iprintln("^2 SETTING UP BOX MODEL ON: "+self.targetname);
if (!isdefined(self.setup_done) )
{
self setModel("bo2_p6_anim_zm_tm_magic_box");
self.origin = self.origin+(0,0,-10);
self.angles = self.angles+(0,180,0);
self.setup_done = true;
}
self show();
}
set_box_hideModels()
{
flag_wait("all_players_connected"); wait 1;
level grab_chest_visible_models();
wait 1;
for(i=0;i<level.chests.size;i++) // Hides rubble
{
level.chest_model[i] setup_box_model();
rubble = getentarray( level.chests[i].script_noteworthy + "_rubble", "script_noteworthy" );
if ( IsDefined( rubble ) )
for ( x = 0; x < rubble.size; x++ )
rubble[x] hide();
}
for( i = 0; i < level.chests.size; i++ ) // Hides lid
{
// if (level.chests[i].script_noteworthy == "start_chest") { level.chest_model[i] thread weapon_box_anims(); break; }
wait .05;
box_lid[i] = getent( "magic_box_lid_"+i , "targetname" );
box_lid[i].origin = box_lid[i].origin+(0,0,-999);
box_lid[i] hide();
}
}
weapon_box_light_fx()
{
light_color = "red";
while(true)
{
fx_origin = self getTagOrigin("tag_light");
fxObj = spawn( "script_model", fx_origin + ( 0, 0, 5.88 ) );
fxobj setmodel( "tag_origin" );
fxobj.angles = self.angles +( 90, 0, 0 );
if (light_color == "red") playfxontag( level._effect["zapper_light_notready"], fxObj, "tag_origin" );
else if (light_color == "green") playfxontag( level._effect["zapper_light_ready"], fxObj, "tag_origin" );
self waittill("light_switch");
if (isdefined(self.light_color) )
light_color = self.light_color;
else
{
if (light_color == "red" && !isdefined(self.no_box) ) light_color = "green";
else light_color = "red";
}
self.light_color = undefined;
fxObj delete(); wait 1;
}
}
weapon_box_anims()
{
// self endon("roll over");
wait 1;
if (isdefined(self.box_anims) ) return;
else
{
self thread weapon_box_light_fx();
box_trigger = getEntArray("treasure_chest_use","targetname");
while(true)
{
for(i=0;i<box_trigger.size;i++)
{
if (Distance(box_trigger[i].origin,self.origin) <= 50)
{
self Show(); self SetVisibleToAll();
self.box_t = box_trigger[i];
break;
}
}
if (isdefined(self.box_t) ) break;
else level waittill("box_move_complete");
}
// iprintln("Found closest box trigger");
self.box_anims = true;
// iprintln("^3WEAPON BOX ANIMS ON: "+self.targetname);
self UseAnimTree( #animtree );
self SetAnim(%tomb_box_closed_idle);
while(true)
{
wait .05;
while(isdefined(self.box_t) )
{
wait .05;
if (!isdefined(self.box_inuse) ) { wait .5;
if (!isdefined(level.box_active) ) self thread weapon_box_animation_value();
else self thread weapon_box_firesale_wait();
self.light_color = "green"; self notify("light_switch");
if (!isdefined(level.firesaleactive) ) { level.box_has_been_hit = undefined; self SetAnim(%tomb_box_spawn); wait getAnimLength(%tomb_box_spawn); self ClearAnim(%tomb_box_spawn,.05); }
else playfx( level._effect["poltergeist"],self.origin); wait .05; }
self SetAnim(%tomb_box_closed_idle);
self.box_anim_clear = undefined; self.box_over = undefined;
self waittill_either("box_opened","box_over"); wait .05; level.box_has_been_hit = true; self ClearAnim(%tomb_box_closed_idle,.05);
if (!isdefined(self.box_over) ) { self playSound("hellbox_open"); self playSound("hellbox_gunselect"); self thread box_open_fx(); }
if (!isdefined(self.box_over) ) { self SetAnim(%tomb_box_open); wait getAnimLength(%tomb_box_open); self ClearAnim(%tomb_box_open,.5);
self SetAnim(%tomb_box_open_idle); self thread wepaon_box_anim_failsafe(); self waittill_any("box_closed","box_over","box_timeout"); if (!isdefined(self.box_over) ) { self ClearAnim(%tomb_box_open_idle,.05);
self SetAnim(%tomb_box_close); wait getAnimLength(%tomb_box_close); self playSound("hellbox_close"); self notify("box_model_closed");
self ClearAnim(%tomb_box_close,5); self SetAnim(%tomb_box_closed_idle); } }
if (isdefined(self.box_over) || isdefined(self.box_timed_out) ) break;
}
if (!isdefined(self.box_anim_clear) )
{
wait 1;
if (isdefined(self.box_inuse) )
{
self.light_color = "red"; self notify("light_switch");
if ( (Distance(level.main_chest.origin,self.origin) > 50 && !isdefined(self.trigger_in_use) ) || !isdefined(self.firesale_box) )
{
// self ClearAnim(%tomb_box_closed_idle,.05);
self thread weapon_box_animClear();
self SetAnim(%tomb_box_open_move);
wait getAnimLength(%tomb_box_open_move);
// level.perk_origin["box"] = undefined;
//if (Distance(self.origin,level.main_chest.origin) <= 50 || isdefined(self.box_timed_out) ) self notify("light_switch");
self weapon_box_animClear();
self.box_inuse = undefined;
level.box_has_been_hit = undefined;
}
else if (Distance(level.main_chest.origin,self.origin) > 50)
{
self thread weapon_box_animClear();
self.box_inuse = undefined;
continue;
}
}
self.box_anim_clear = true;
self.box_t = undefined;
wait 2;
self.box_timed_out = undefined;
}
else
{
while(true)
{
for(i=0;i<box_trigger.size;i++)
{
if (Distance(box_trigger[i].origin,self.origin) <= 50)
{
self Show(); self SetVisibleToAll();
self.box_t = box_trigger[i];
break;
}
}
if (isdefined(self.box_t) ) break;
else level waittill("box_move_complete");
}
}
}
}
}
// Assures the box open animation doesn't play infinity
wepaon_box_anim_failsafe()
{
self endon("box_closed");
self endon("box_over");
for(t=0;t<18;t++)
wait 1;
self.box_timed_out = true;
self notify("box_timeout");
}
box_open_fx()
{
self endon("box_model_closed");
self endon("light_switch");
level endon("weapon_fly_away_end");
level endon("firesale_over");
n = 0;
while(true)
{
if (n >= 3) n = 0;
fx_org = self GetTagOrigin("tag_fx_0"+n);
n += 1;
if (isdefined(fx_org) )
playFx(level._effect["elec_md"], fx_org+(0,0,20));
wait .7; fx_org = undefined;
}
}
weapon_box_animClear()
{
self ClearAnim(%tomb_box_open,.05);
self ClearAnim(%tomb_box_open_idle,.05);
self ClearAnim(%tomb_box_open_move,.05);
self ClearAnim(%tomb_box_close,.05);
self ClearAnim(%tomb_box_closed_idle,.05);
self ClearAnim(%tomb_box_spawn,.05);
}
weapon_box_animation_value()
{
level.box_active = true;
self.box_inuse = true;
wait .05;
self thread hellbox_loopSound();
level waittill("weapon_fly_away_end");

self.box_over = true;
self notify("box_over"); wait .3; self notify("box_over");
self notify("box_model_closed");
level.box_active = undefined;
}
weapon_box_firesale_wait()
{
self.box_inuse = true;
level waittill("firesale_over");
if (isdefined(self.trigger_in_use) )
self waittill("box_closed");
self.light_color = "red"; self notify("light_switch");
self.box_over = true;
self notify("box_over"); wait .3; self notify("box_over");
self notify("box_model_closed");
}
show_magic_box_model()
{
wait .5;
pieces = self get_chest_pieces();
for(i=0;i<pieces.size;i++)
pieces[i] show();
}
show_magic_box()
{
pieces = self get_chest_pieces();
for(i=0;i<pieces.size;i++)
{
pieces[i] enable_trigger();
}

// PI_CHANGE_BEGIN - JMA - we want to play another effect on swamp
anchor = GetEnt(self.target, "targetname");
anchorTarget = GetEnt(anchor.target, "targetname");

if(isDefined(level.DLC3.usePandoraBoxLight) && level.DLC3.usePandoraBoxLight != true )
{
playfx( level._effect["poltergeist"],pieces[0].origin);
}
else
{
level.pandora_light.angles = (-90, anchorTarget.angles[1] + 180, 0);
level.pandora_light moveto(anchorTarget.origin, 0.05);
wait(1);
playfx( level._effect["lght_marker_flare"],level.pandora_light.origin );
// playfxontag(level._effect["lght_marker_flare"], level.pandora_light, "tag_origin");
}
// PI_CHANGE_END

playsoundatposition( "box_poof", pieces[0].origin );
wait(.5);
for(i=0;i<pieces.size;i++)
{
if( pieces[i].classname != "trigger_use" )
{
pieces[i] show();
}
}
pieces[0] playsound ( "box_poof_land" );
pieces[0] playsound( "couch_slam" );
level notify("box_move_complete"); // redspace200 - added
}
start_firesale()
{
level endon("game is over");
for(;;)
{
if (!isdefined(level.chestinuse )) break;
wait 1;
}
set_treasure_chest_cost(10);
for(i=0;i<level.chests.size;i++)
{
if(i == level.chest_index)
continue;

pieces = level.chests[i] get_chest_pieces();
for(j=0;j<pieces.size;j++)
{
pieces[j] enable_trigger();
}

anchor = GetEnt(level.chests[i].target, "targetname");
anchorTarget = GetEnt(anchor.target, "targetname");

if(isDefined(level.DLC3.usePandoraBoxLight) && level.DLC3.usePandoraBoxLight != true )
{
playfx( level._effect["poltergeist"],pieces[0].origin);
}
else
{
if(!isDefined(level.chests[i].firesale_pandora_light))
{
level.chests[i].firespawn = true;
level.chests[i].firesale_pandora_light = Spawn( "script_model", anchorTarget.origin );
level.chests[i].firesale_pandora_light.angles = anchorTarget.angles + (-90, 0, 0);
level.chests[i].firesale_pandora_light SetModel( "tag_origin" );
playfxontag(level._effect["lght_marker"], level.chests[i].firesale_pandora_light, "tag_origin");
}
}

playsoundatposition( "box_poof", pieces[0].origin );
playsoundatposition( "box_poof_land", pieces[0].origin );
playsoundatposition( "couch_slam", pieces[0].origin );
level notify("box_move_complete");

for(j=0;j<pieces.size;j++)
{
if( pieces[j].classname != "trigger_use" )
{
pieces[j] show();
}
}
unhide_magic_box(i);
}
}
stop_firesale()
{
level.stopfiresalesounds = true;
level.stopping_firesale = true;
set_treasure_chest_cost(950);
for(i=0;i<level.chests.size;i++)
{
// don't need to do this on the currently active chest

if(i == level.chest_index)
continue;


if(isdefined(level.chests[i].chestinuse))
{
level.chests[i] thread stop_firesale_on_inuse_box();
}
else
{

level.chests[i] hide_chest();
playfx(level._effect["poltergeist"], level.chests[i].origin-10);
if(isDefined(level.chests[i].firesale_pandora_light))
level.chests[i].firesale_pandora_light delete();

level.firesale_boxes_stopped ++;

rubble = getentarray( level.chests[i].script_noteworthy + "_rubble", "script_noteworthy" );
if ( IsDefined( rubble ) )
for ( x = 0; x < rubble.size; x++ )
rubble[x] hide();
}
}
thread stop_firesale_thread();
// Stop firesale sound
}
stop_firesale_thread()
{
level endon("started_firesale");
count = 0;

while(1)
{
if(level.firesale_boxes_stopped >= level.chests.size - 1) // -1 because there is the box that is the real current box
break;
if(count > 200) // 20 second failsafe
break;

count ++;
wait 0.1;
}
level.stopping_firesale = undefined;
level.firesale_boxes_stopped = 0;
}
firesale_end_var()
{
wait 6;
level.firesale_just_ended = undefined;
}
stop_firesale_on_inuse_box()
{
level endon("started_firesale");
while(isdefined(self.chestinuse))
wait 0.01;

self hide_chest();
playfx(level._effect["poltergeist"], self.origin);
if(isDefined(self.firesale_pandora_light))
self.firesale_pandora_light delete();

rubble = getentarray( self.script_noteworthy + "_rubble", "script_noteworthy" );
if ( IsDefined( rubble ) )
for ( x = 0; x < rubble.size; x++ )
rubble[x] hide();

level.firesale_boxes_stopped ++;
}
fix_box_trigger() // Attempt to fix the box trigger if the firesale glitches it
{
// iprintln("Running: fix_box_trigger()");
for( i = 0; i < level.chests.size; i++ )
{
if( (level.chest_index == i && (( level.zombie_vars["zombie_powerup_firesale_on"] == false ))))
{
if (!isdefined(level.chests[i].chestinuse))
level.chests[i] enable_trigger();
}
wait 30;
}
}
hellbox_loopSound()
{
if ( level.zombie_vars["zombie_powerup_firesale_on"] != true && !isdefined(self.has_sound) )
{
self.has_sound = true;
sou = spawn("script_origin", self.origin);
sou playloopsound("hellbox_loop", "stop sound");
level waittill_any("weapon_fly_away_end","game is over","box disabled");
wait(0.1);
sou delete();
self.has_sound = undefined;
}
}
light_distance_check(org)
{
wait 4;
for(a=0;a<level.chest_model.size;a++)
{
wait .05;
if (Distance(org,level.chest_model[a].origin) <= 50)
{
iprintln("^2NOTIFY LIGHT");
// level.chest_model[a] notify("light_switch");
}
}
}
check_for_firesale()
{
if (level.zombie_vars["zombie_powerup_firesale_on"] != true )
{
// self thread light_distance_check(self.origin);
for(a=0;a<level.chest_model.size;a++)
{
wait .05;
if (Distance(self.origin,level.chest_model[a].origin) <= 50)
level.chest_model[a].box_checker = true;
}
}
// else iprintln("^2 fire sale was active");
// self thread hellbox_loopSound();
// if(isdefined(self.check_for_firesale)) return;
self endon("roll over");
while(1)
{
if (!isdefined(self.chestinuse) && (isdefined(level.firesaleactive)) && (!isdefined(self.onfiresale)))
{
self.cost = 10;
set_treasure_chest_cost(10);
string = "Press ^3[{+activate}]^7  to use Mystery Box [Cost: 10]";
self sethintstring(string);
self.onfiresale = true;
level thread start_firesale();
break;
}
wait 1;
}
}
check_for_firesale_over()
{
if(isdefined(self.check_for_firesale_over)) return;
// self.check_for_firesale_over = true;
self endon("roll over");
while(1)
{
if (!isdefined(self.chestinuse) && (!isdefined(level.firesaleactive)) && (isdefined(self.onfiresale)))
{
self.cost = 950;
set_treasure_chest_cost(950);
string = "Press ^3[{+activate}]^7  to use Mystery Box [Cost: 950]";
self sethintstring(string);
self.onfiresale = undefined;
level thread stop_firesale();
for( i = 0; i < level.chests.size; i++ )
{
if( level.chest_index == i )
{
level thread enable_box_trig(i);
}
}
break;
}
wait 1;
}
}
enable_box_trig(chest_index)
{
wait 2;
level.chests[chest_index] enable_trigger();
}
reverse_firesale_thread()
{
if(isdefined(self.reverse_firesale_thread)) return;
self.reverse_firesale_thread = true;
while(1)
{
if (!isdefined(self.chestinuse) && (!isdefined(level.firesaleactive)) && (isdefined(level.reverse_firesale)))
{
// iprintln("reverse firesale price updated");
wait 1;
reverse_cost = randomintrange(3500,6500);
self.cost = reverse_cost;
set_treasure_chest_cost(reverse_cost);
string = "Press ^3[{+activate}]^7  to Unlock Box ^1 [Cost: "+reverse_cost+"]";
self sethintstring(string);
level.reverse_firesale = undefined;
self.cursed = true;
wait .5;
string = "Press ^3[{+activate}]^7  to Unlock Box ^1 [Cost: "+reverse_cost+"]";
self sethintstring(string);
}
wait 2;
}
}
// Redspace200 - Added for origins box (End custom functions)

treasure_chest_think()
{
// Redspace200 - begin
cost = 950;
self.chestinuse = undefined; level.chestinuse = undefined;
level.inuse_fs_box = undefined;
if (isdefined(self.on_lockdown) )
while(isdefined(self.on_lockdown) )
wait 1;
if (!isdefined(self.on_lockdown) )
{
if(!isdefined(level.firesaleactive))
{
cost = 950;
string = "Press ^3[{+activate}]^7  to use Mystery Box [Cost: 950]";
self sethintstring(string);
self.onfiresale = undefined;
}
else
{
cost = 10;
string = "Press ^3[{+activate}]^7  to use Mystery Box [Cost: 10]";
self sethintstring(string);
self.onfiresale = true;
}
}
if (!isdefined(level.firesaleactive))
{
self thread check_for_firesale();
self thread check_for_firesale_over();
self thread reverse_firesale_thread();
}
// Redspace200 - end
if( IsDefined( level.zombie_treasure_chest_cost ) )
{
cost = level.zombie_treasure_chest_cost;
}
else
{
cost = self.zombie_cost;
}

self set_hint_string( self, "default_treasure_chest_" + cost );
self setCursorHint( "HINT_NOICON" );

//self thread decide_hide_show_chest_hint( "move_imminent" );

// waittill someuses uses this
user = undefined;
while( 1 )
{
self waittill( "trigger", user );

// Redspace200 - begin
if (isdefined(level.firesaleactive) ) cost = 10;
else cost = 950;
// Redspace200 - end

if( user in_revive_trigger() )
{
wait( 0.1 );
continue;
}
if (isdefined(self.disable) )
{
wait( 0.1 );
continue;
}

// make sure the user is a player, and that they can afford it
// redspace200 - begin
// make sure the user is a player, and that they can afford it
// Box does not have a fire sale
if (!isdefined(self.onfiresale) && (!isdefined(self.cursed)))
{
if( is_player_valid( user ) && user.score >= cost)
{
user maps\_zombiemode_score::minus_to_player_score( cost );
break;
}
else if ( user.score < cost )
{
user thread maps\_zombiemode_perks::play_no_money_perk_dialog();
continue;
}
}
else // Box has a fire sale (Costs 10 points)
{
if (isdefined(self.onfiresale))
{
if( is_player_valid( user ) && user.score >= 10 )
{
user maps\_zombiemode_score::minus_to_player_score( 10 );
break;
}
else if ( user.score < cost )
{
user thread maps\_zombiemode_perks::play_no_money_perk_dialog();
continue;
}
}
else if (isdefined(self.cursed))
{
if( is_player_valid( user ) && user.score >= self.cost)
{
user maps\_zombiemode_score::minus_to_player_score( self.cost );
self.cursed = undefined;
break;
}
}
}

wait 0.05;
}
if(level.zombie_vars["zombie_powerup_firesale_on"] == true)
{
for(a=0;a<level.chest_model.size;a++)
{
if (Distance(self.origin,level.chest_model[a].origin) <= 50)
level.chest_model[a].firesale_box = true;
}
}
self.chestinuse = true; level.chestinuse = true;
if ( level.zombie_vars["zombie_powerup_firesale_on"] == true) level.inuse_fs_box = true;
// redspace200 - end

// trigger_use->script_brushmodel lid->script_origin in radiant
lid = getent( self.target, "targetname" );
weapon_spawn_org = getent( lid.target, "targetname" );

// open the lid
// lid thread treasure_chest_lid_open();
for(a=0;a<level.chest_model.size;a++)
{
if (Distance(self.origin,level.chest_model[a].origin) <= 50) {
level.chest_model[a] notify("box_opened"); level.chest_model[a].trigger_in_use = true; }
}

// SRS 9/3/2008: added to help other functions know if we timed out on grabbing the item
self.timedOut = false;

// mario kart style weapon spawning
weapon_spawn_org thread treasure_chest_weapon_spawn( self, user );

// the glowfx
weapon_spawn_org thread treasure_chest_glowfx();

// take away usability until model is done randomizing
self disable_trigger();

weapon_spawn_org waittill( "randomization_done" );

if (flag("moving_chest_now"))
{
level.main_chest = undefined;
self thread light_distance_check(self.origin);
for(a=0;a<level.chest_model.size;a++) { wait .05; level.chest_model[a].trigger_in_use = undefined; level.chest_model[a] playSound("hellbox_bear");
level.chest_model[a].box_checker = undefined; }
self.check_for_firesale = undefined;
self.check_for_firesale_over = undefined;
// user thread treasure_chest_move_vo();
self treasure_chest_move(lid);

}
else
{
// Let the player grab the weapon and re-enable the box //
self.grab_weapon_hint = true;
self.chest_user = user;
self sethintstring( &"ZOMBIE_TRADE_WEAPONS" );
self setCursorHint( "HINT_NOICON" );
self setvisibletoplayer( user );

// Limit its visibility to the player who bought the box
self enable_trigger();
self thread treasure_chest_timeout();

// make sure the guy that spent the money gets the item
// SRS 9/3/2008: ...or item goes back into the box if we time out
while( 1 )
{
self waittill( "trigger", grabber );

if( grabber == user || grabber == level )
{


if( grabber == user && is_player_valid( user ) && user GetCurrentWeapon() != "mine_bouncing_betty" )
{
bbPrint( "zombie_uses: playername %s playerscore %d round %d cost %d name %s x %f y %f z %f type magic_accept",
user.playername, user.score, level.round_number, cost, weapon_spawn_org.weapon_string, self.origin );
self notify( "user_grabbed_weapon" );
user thread treasure_chest_give_weapon( weapon_spawn_org.weapon_string );
break;
}
else if( grabber == level )
{
// it timed out
self.timedOut = true;
bbPrint( "zombie_uses: playername %s playerscore %d round %d cost %d name %s x %f y %f z %f type magic_reject",
user.playername, user.score, level.round_number, cost, weapon_spawn_org.weapon_string, self.origin );
break;
}
}

wait 0.05;
}

self.grab_weapon_hint = false;
self.chest_user = undefined;

weapon_spawn_org notify( "weapon_grabbed" );
// redspace200 - added
for(a=0;a<level.chest_model.size;a++)
{
if (Distance(self.origin,level.chest_model[a].origin) <= 50) { level.chest_model[a].firesale_box = undefined;
level.chest_model[a] notify("box_closed"); level.chest_model[a].trigger_in_use = undefined; }
}

//increase counter of amount of time weapon grabbed.
if(level.script != "nazi_zombie_prototype")
{
level.chest_accessed += 1;

// PI_CHANGE_BEGIN
// JMA - we only update counters when it's available
if( isDefined(level.DLC3.useChestPulls) && level.DLC3.useChestPulls )
{
level.pulls_since_last_ray_gun += 1;
}

if( isDefined(level.DLC3.useChestPulls) && level.DLC3.useChestPulls )
{
level.pulls_since_last_tesla_gun += 1;
}
// PI_CHANGE_END
}
self disable_trigger();

// spend cash here...
// give weapon here...
lid thread treasure_chest_lid_close( self.timedOut );
self notify("roll_over");

//Chris_P
//magic box dissapears and moves to a new spot after a predetermined number of uses

wait 1.5;
self enable_trigger();
self setvisibletoall();
}

flag_clear("moving_chest_now");
self thread treasure_chest_think();
}


//
// Disable trigger if can't buy weapon and also if someone else is using the chest
decide_hide_show_chest_hint( endon_notify )
{
if( isDefined( endon_notify ) )
{
self endon( endon_notify );
}

while( true )
{
players = get_players();
for( i = 0; i < players.size; i++ )
{
// chest_user defined if someone bought a weapon spin, false when chest closed
if ( (IsDefined(self.chest_user) && players[i] != self.chest_user ) ||
!players[i] can_buy_weapon() )
{
self SetInvisibleToPlayer( players[i], true );
}
else
{
self SetInvisibleToPlayer( players[i], false );
}
}
wait( 0.1 );
}
}

decide_hide_show_hint( endon_notify )
{
if( isDefined( endon_notify ) )
{
self endon( endon_notify );
}

while( true )
{
players = get_players();
for( i = 0; i < players.size; i++ )
{
if( players[i] can_buy_weapon() )
{
self SetInvisibleToPlayer( players[i], false );
}
else
{
self SetInvisibleToPlayer( players[i], true );
}
}
wait( 0.1 );
}
}

can_buy_weapon()
{
if( isDefined( self.is_drinking ) && self.is_drinking )
{
return false;
}
if( self GetCurrentWeapon() == "mine_bouncing_betty" )
{
return false;
}
if( self in_revive_trigger() )
{
return false;
}

return true;
}

treasure_chest_move_vo()
{

self endon("disconnect");

index = maps\_zombiemode_weapons::get_player_index(self);
sound = undefined;

if(!isdefined (level.player_is_speaking))
{
level.player_is_speaking = 0;
}
variation_count = 5;
sound = "plr_" + index + "_vox_box_move" + "_" + randomintrange(0, variation_count);


//This keeps multiple voice overs from playing on the same player (both killstreaks and headshots).
if (level.player_is_speaking != 1 && isDefined(sound))
{
level.player_is_speaking = 1;
self playsound(sound, "sound_done");
self waittill("sound_done");
level.player_is_speaking = 0;
}

}


treasure_chest_move(lid)
{
level waittill("weapon_fly_away_start");
level.chest_moving = true;

players = get_players();

array_thread(players, ::play_crazi_sound);

level waittill("weapon_fly_away_end");
level.chest_moving = undefined;
// lid thread treasure_chest_lid_close(false);
//self setvisibletoall();

fake_pieces = [];
pieces = self get_chest_pieces();


for(i=0;i<pieces.size;i++)
{
if(pieces[i].classname == "script_model")
{
fake_pieces[fake_pieces.size] = spawn("script_model",pieces[i].origin);
fake_pieces[fake_pieces.size - 1].angles = pieces[i].angles;
fake_pieces[fake_pieces.size - 1] setmodel(pieces[i].model);
pieces[i] disable_trigger();
pieces[i] hide();
}
else
{
pieces[i] disable_trigger();
pieces[i] hide();
}
}


anchor = spawn("script_origin",fake_pieces[0].origin);
soundpoint = spawn("script_origin", anchor.origin);
    playfx( level._effect["poltergeist"],anchor.origin);

anchor playsound("box_move");
for(i=0;i<fake_pieces.size;i++)
{
fake_pieces[i] linkto(anchor);
}

playsoundatposition ("whoosh", soundpoint.origin );
playsoundatposition ("ann_vox_magicbox", soundpoint.origin );

anchor moveto(anchor.origin + (0,0,50),5);
//anchor rotateyaw(360 * 10,5,5);
if(level.chests[level.chest_index].script_noteworthy == "magic_box_south" || level.chests[level.chest_index].script_noteworthy == "magic_box_bathroom" || level.chests[level.chest_index].script_noteworthy == "magic_box_hallway")
{
anchor Vibrate( (50, 0, 0), 10, 0.5, 5 );
}
else if(level.script != "nazi_zombie_sumpf")
{
anchor Vibrate( (0, 50, 0), 10, 0.5, 5 );
}
else
{
   //Get the normal of the box using the positional data of the box and lid
   direction = pieces[3].origin - pieces[1].origin;
   direction = (direction[1], direction[0], 0);
   
   if(direction[1] < 0 || (direction[0] > 0 && direction[1] > 0))
   {
            direction = (direction[0], direction[1] * -1, 0);
       }
       else if(direction[0] < 0)
       {
            direction = (direction[0] * -1, direction[1], 0);
       }
   
        anchor Vibrate( direction, 10, 0.5, 5);
}

//anchor thread rotateroll_box();
anchor waittill("movedone");
//players = get_players();
//array_thread(players, ::play_crazi_sound);
//wait(3.9);

playfx(level._effect["poltergeist"], anchor.origin);

//TUEY - Play the 'disappear' sound
playsoundatposition ("box_poof", soundpoint.origin);
for(i=0;i<fake_pieces.size;i++)
{
fake_pieces[i] delete();
}


//gzheng-Show the rubble
//PI CHANGE - allow for more than one object of rubble per box
/*
rubble = getentarray(self.script_noteworthy + "_rubble", "script_noteworthy");

if ( IsDefined( rubble ) )
{
for (i = 0; i < rubble.size; i++)
{
rubble[i] show();
}
}
else
{
println( "^3Warning: No rubble found for magic box" );
}
*/

wait(0.1);
anchor delete();
soundpoint delete();

old_chest_index = level.chest_index;
level.main_chest = self;

wait(5);

//chest moving logic
//PI CHANGE - for sumpf, this doesn't work because chest_index is always incremented twice (here and line 724) - while this would work with an odd number of chests,
//      with an even number it skips half of the chest locations in the map

level.verify_chest = false;

//wait(3);
//make sure level is asylum, factory, or sumpf and make magic box only appear in location player have open, it's off by default
//also make sure box doesn't respawn in old location.
//PI WJB: removed check on "magic_box_explore_only" dvar because it is only ever used here and when it is set in _zombiemode.gsc line 446
// where it is declared and set to 0, causing this while loop to never happen because the check was to see if it was equal to 1
if( isDefined(level.DLC3.useChestMoves) && level.DLC3.useChestMoves)
{
level.chest_index++;

/* while(level.chests[level.chest_index].origin == level.chests[old_chest_index].origin)
{
level.chest_index++;
}*/

if (level.chest_index >= level.chests.size)
{
//PI CHANGE - this way the chests won't move in the same order the second time around
temp_chest_name = level.chests[level.chest_index - 1].script_noteworthy;
level.chest_index = 0;
level.chests = array_randomize(level.chests);
//in case it happens to randomize in such a way that the chest_index now points to the same location
// JMA - want to avoid an infinite loop, so we use an if statement
if (temp_chest_name == level.chests[level.chest_index].script_noteworthy)
{
level.chest_index++;
}
//END PI CHANGE
}

//verify_chest_is_open();
wait(0.01);

}
level.main_chest = level.chests[level.chest_index];
level.chests[level.chest_index] show_magic_box();

//turn off magic box light.
level notify("magic_box_light_switch");
//PI CHANGE - altered to allow for more than one object of rubble per box
unhide_magic_box( level.chest_index );

}

rotateroll_box()
{
angles = 40;
angles2 = 0;
//self endon("movedone");
while(isdefined(self))
{
self RotateRoll(angles + angles2, 0.5);
wait(0.7);
angles2 = 40;
self RotateRoll(angles * -2, 0.5);
wait(0.7);
}



}
//verify if that magic box is open to players or not.
verify_chest_is_open()
{

//for(i = 0; i < 5; i++)
//PI CHANGE - altered so that there can be more than 5 valid chest locations
for (i = 0; i < level.open_chest_location.size; i++)
{
if(isdefined(level.open_chest_location[i]))
{
if(level.open_chest_location[i] == level.chests[level.chest_index].script_noteworthy)
{
level.verify_chest = true;
return;
}
}

}

level.verify_chest = false;


}


treasure_chest_timeout()
{
self endon( "user_grabbed_weapon" );

wait( 12 );
self notify( "trigger", level );
}

treasure_chest_lid_open()
{
openRoll = 105;
openTime = 0.5;

self RotateRoll( 105, openTime, ( openTime * 0.5 ) );

play_sound_at_pos( "open_chest", self.origin );
play_sound_at_pos( "music_chest", self.origin );
}

treasure_chest_lid_close( timedOut )
{
closeRoll = -105;
closeTime = 0.5;

self RotateRoll( closeRoll, closeTime, ( closeTime * 0.5 ) );
play_sound_at_pos( "close_chest", self.origin );
}

treasure_chest_ChooseRandomWeapon( player )
{

keys = GetArrayKeys( level.zombie_weapons );

// Filter out any weapons the player already has
filtered = [];
for( i = 0; i < keys.size; i++ )
{
if( !get_is_in_box( keys[i] ) )
{
continue;
}

if( player has_weapon_or_upgrade( keys[i] ) )
{
continue;
}

if( !IsDefined( keys[i] ) )
{
continue;
}

filtered[filtered.size] = keys[i];
}

// Filter out the limited weapons
if( IsDefined( level.limited_weapons ) )
{
keys2 = GetArrayKeys( level.limited_weapons );
players = get_players();
pap_triggers = GetEntArray("zombie_vending_upgrade", "targetname");
for( q = 0; q < keys2.size; q++ )
{
count = 0;
for( i = 0; i < players.size; i++ )
{
if( players[i] has_weapon_or_upgrade( keys2[q] ) )
{
count++;
}
}

// Check the pack a punch machines to see if they are holding what we're looking for
for ( k=0; k<pap_triggers.size; k++ )
{
if ( IsDefined(pap_triggers[k].current_weapon) && pap_triggers[k].current_weapon == keys2[q] )
{
count++;
}
}

if( count >= level.limited_weapons[keys2[q]] )
{
filtered = array_remove( filtered, keys2[q] );
}
}
}

return filtered[RandomInt( filtered.size )];
}

treasure_chest_ChooseWeightedRandomWeapon( player )
{

keys = GetArrayKeys( level.zombie_weapons );

// Filter out any weapons the player already has
filtered = [];
for( i = 0; i < keys.size; i++ )
{
if( !get_is_in_box( keys[i] ) )
{
continue;
}

if( player has_weapon_or_upgrade( keys[i] ) )
{
continue;
}

if( !IsDefined( keys[i] ) )
{
continue;
}

num_entries = [[ level.weapon_weighting_funcs[keys[i]] ]]();

for( j = 0; j < num_entries; j++ )
{
filtered[filtered.size] = keys[i];
}
}

// Filter out the limited weapons
if( IsDefined( level.limited_weapons ) )
{
keys2 = GetArrayKeys( level.limited_weapons );
players = get_players();
pap_triggers = GetEntArray("zombie_vending_upgrade", "targetname");
for( q = 0; q < keys2.size; q++ )
{
count = 0;
for( i = 0; i < players.size; i++ )
{
if( players[i] has_weapon_or_upgrade( keys2[q] ) )
{
count++;
}
}

// Check the pack a punch machines to see if they are holding what we're looking for
for ( k=0; k<pap_triggers.size; k++ )
{
if ( IsDefined(pap_triggers[k].current_weapon) && pap_triggers[k].current_weapon == keys2[q] )
{
count++;
}
}

if( count >= level.limited_weapons[keys2[q]] )
{
filtered = array_remove( filtered, keys2[q] );
}
}
}

return filtered[RandomInt( filtered.size )];
}

treasure_chest_weapon_spawn( chest, player )
{
assert(IsDefined(player));
// spawn the model
model = spawn( "script_model", self.origin+(0,0,15) );
model.angles = self.angles +( 0, 90, 0 );

floatHeight = 14;

//move it up
model moveto( model.origin +( 0, 0, floatHeight ), 3, 2, 0.9 );

// rotation would go here

// make with the mario kart
modelname = undefined;
rand = undefined;
number_cycles = 40;
for( i = 0; i < number_cycles; i++ )
{

if( i < 20 )
{
wait( 0.05 );
}
else if( i < 30 )
{
wait( 0.1 );
}
else if( i < 35 )
{
wait( 0.2 );
}
else if( i < 38 )
{
wait( 0.3 );
}

if( i+1 < number_cycles )
{
rand = treasure_chest_ChooseRandomWeapon( player );
}
else
{
rand = treasure_chest_ChooseWeightedRandomWeapon( player );
}

/#
if( maps\_zombiemode_tesla::tesla_gun_exists() )
{
if ( i == 39 && GetDvar( "scr_spawn_tesla" ) != "" )
{
SetDvar( "scr_spawn_tesla", "" );
rand = "tesla_gun";
}
}
#/

modelname = GetWeaponModel( rand );
model setmodel( modelname );


}

self.weapon_string = rand; // here's where the org get it's weapon type for the give function

// random change of getting the joker that moves the box
random = Randomint(100);

if( !isdefined( level.chest_min_move_usage ) )
{
level.chest_min_move_usage = 4;
}

//increase the chance of joker appearing from 0-100 based on amount of the time chest has been opened.
if(level.script != "nazi_zombie_prototype" && getdvar("magic_chest_movable") == "1")
{

if(level.chest_accessed < level.chest_min_move_usage)
{
// PI_CHANGE_BEGIN - JMA - RandomInt(100) can return a number between 0-99.  If it's zero and chance_of_joker is zero
// we can possibly have a teddy bear one after another.
chance_of_joker = -1;
// PI_CHANGE_END
}
else
{
chance_of_joker = level.chest_accessed + 20;

// make sure teddy bear appears on the 8th pull if it hasn't moved from the initial spot
if( (!isDefined(level.magic_box_first_move) || level.magic_box_first_move == false ) && level.chest_accessed >= 8)
{
chance_of_joker = 100;
}

// pulls 4 thru 8, there is a 15% chance of getting the teddy bear
// NOTE:  this happens in all cases
if( level.chest_accessed >= 4 && level.chest_accessed < 8 )
{
if( random < 15 )
{
chance_of_joker = 100;
}
else
{
chance_of_joker = -1;
}
}

// after the first magic box move the teddy bear percentages changes
if( isDefined(level.magic_box_first_move) && level.magic_box_first_move == true )
{
// between pulls 8 thru 12, the teddy bear percent is 30%
if( level.chest_accessed >= 8 && level.chest_accessed < 13 )
{
if( random < 30 )
{
chance_of_joker = 100;
}
else
{
chance_of_joker = -1;
}
}

// after 12th pull, the teddy bear percent is 50%
if( level.chest_accessed >= 13 )
{
if( random < 50 )
{
chance_of_joker = 100;
}
else
{
chance_of_joker = -1;
}
}
}
}

if (random <= chance_of_joker)
{
model SetModel("zombie_teddybear");
// model rotateto(level.chests[level.chest_index].angles, 0.01);
//wait(1);
model.angles = self.angles;
wait 1;
flag_set("moving_chest_now");
self notify( "move_imminent" );
level.chest_accessed = 0;

player maps\_zombiemode_score::add_to_player_score( 950 );

//allow power weapon to be accessed.
level.box_moved = true;
}
}

self notify( "randomization_done" );

if (flag("moving_chest_now"))
{
wait .5; // we need a wait here before this notify
level notify("weapon_fly_away_start");
wait 2;
model MoveZ(500, 4, 3);
model waittill("movedone");
model delete();
self notify( "box_moving" );
level notify("weapon_fly_away_end");
}
else
{

//turn off power weapon, since player just got one
if( rand == "tesla_gun" || rand == "ray_gun" )
{
// PI_CHANGE_BEGIN - JMA - reset the counters for tesla gun and ray gun pulls
if(isDefined(level.DLC3.useWeaponSpawn) && level.DLC3.useWeaponSpawn )
{
if( rand == "ray_gun" )
{
level.box_moved = false;
level.pulls_since_last_ray_gun = 0;
}

if( rand == "tesla_gun" )
{
level.pulls_since_last_tesla_gun = 0;
level.player_seen_tesla_gun = true;
}
}
else
{
level.box_moved = false;
}
// PI_CHANGE_END
}

model thread timer_til_despawn(floatHeight);
self waittill( "weapon_grabbed" );

if( !chest.timedOut )
{
model Delete();
}


}
}
timer_til_despawn(floatHeight)
{


// SRS 9/3/2008: if we timed out, move the weapon back into the box instead of deleting it
putBackTime = 12;
self MoveTo( self.origin - ( 0, 0, floatHeight ), putBackTime, ( putBackTime * 0.5 ) );
wait( putBackTime );

if(isdefined(self))
{
self Delete();
}
}

treasure_chest_glowfx()
{
fxObj = spawn( "script_model", self.origin +( 0, 0, 0 ) );
fxobj setmodel( "tag_origin" );
fxobj.angles = self.angles +( 90, 0, 0 );

playfxontag( level._effect["chest_light"], fxObj, "tag_origin"  );

self waittill_any( "weapon_grabbed", "box_moving" );

fxobj delete();
}

// self is the player string comes from the randomization function
treasure_chest_give_weapon( weapon_string )
{

self.showboxhud = true;

primaryWeapons = self GetWeaponsListPrimaries();
current_weapon = self getCurrentWeapon();

if( !( weapon_string == "fraggrenade" || weapon_string == "stielhandgranate" || weapon_string == "molotov" || weapon_string == "zombie_cymbal_monkey"|| weapon_string == "mine_bouncing_betty") && current_weapon != "mine_bouncing_betty")
{
if(primaryWeapons.size >= self.MuleCount)
{
self TakeWeapon( current_weapon);

if(current_weapon == "tesla_gun")
level.player_drops_tesla_gun = true;

self GiveWeapon( weapon_string, 0);
self GiveMaxAmmo( weapon_string );
self SwitchToWeapon( weapon_string );
}
else
{
self GiveWeapon( weapon_string, 0);
self GiveMaxAmmo( weapon_string );
self SwitchToWeapon( weapon_string );
}
}
else
{

if(weapon_string == "zombie_cymbal_monkey")
{

if(self HasWeapon( "molotov" ))
self TakeWeapon( "molotov" );
self maps\_zombiemode_cymbal_monkey::player_give_cymbal_monkey();

}

if(weapon_string == "molotov")
{

if(self HasWeapon( "zombie_cymbal_monkey" ))
self TakeWeapon( "zombie_cymbal_monkey" );
self GiveWeapon( weapon_string, 0 );

}

}
}

weapon_cabinet_think()
{
weapons = getentarray( "cabinet_weapon", "targetname" );

doors = getentarray( self.target, "targetname" );
for( i = 0; i < doors.size; i++ )
{
doors[i] NotSolid();
}

self.has_been_used_once = false;

self decide_hide_show_hint();

while( 1 )
{
self waittill( "trigger", player );

if( !player can_buy_weapon() )
{
wait( 0.1 );
continue;
}

cost = 1500;
if( self.has_been_used_once )
{
cost = get_weapon_cost( self.zombie_weapon_upgrade );
}
else
{
if( IsDefined( self.zombie_cost ) )
{
cost = self.zombie_cost;
}
}

ammo_cost = get_ammo_cost( self.zombie_weapon_upgrade );

if( !is_player_valid( player ) )
{
player thread ignore_triggers( 0.5 );
continue;
}

if( self.has_been_used_once )
{
player_has_weapon = player has_weapon_or_upgrade( self.zombie_weapon_upgrade );
/*
player_has_weapon = false;
weapons = player GetWeaponsList();
if( IsDefined( weapons ) )
{
for( i = 0; i < weapons.size; i++ )
{
if( weapons[i] == self.zombie_weapon_upgrade )
{
player_has_weapon = true;
}
}
}
*/

if( !player_has_weapon )
{
if( player.score >= cost )
{
self play_sound_on_ent( "purchase" );
player maps\_zombiemode_score::minus_to_player_score( cost );
player weapon_give( self.zombie_weapon_upgrade );
}
else // not enough money
{
play_sound_on_ent( "no_purchase" );
player thread maps\_zombiemode_perks::play_no_money_perk_dialog();
}
}
else if ( player.score >= ammo_cost )
{
ammo_given = player ammo_give( self.zombie_weapon_upgrade );
if( ammo_given )
{
self play_sound_on_ent( "purchase" );
player maps\_zombiemode_score::minus_to_player_score( ammo_cost ); // this give him ammo to early
}
}
else // not enough money
{
play_sound_on_ent( "no_purchase" );
player thread maps\_zombiemode_perks::play_no_money_perk_dialog();
}
}
else if( player.score >= cost ) // First time the player opens the cabinet
{
self.has_been_used_once = true;

self play_sound_on_ent( "purchase" );

self SetHintString( &"ZOMBIE_WEAPONCOSTAMMO", cost, ammo_cost );
// self SetHintString( get_weapon_hint( self.zombie_weapon_upgrade ) );
self setCursorHint( "HINT_NOICON" );
player maps\_zombiemode_score::minus_to_player_score( self.zombie_cost );

doors = getentarray( self.target, "targetname" );

for( i = 0; i < doors.size; i++ )
{
if( doors[i].model == "dest_test_cabinet_ldoor_dmg0" )
{
doors[i] thread weapon_cabinet_door_open( "left" );
}
else if( doors[i].model == "dest_test_cabinet_rdoor_dmg0" )
{
doors[i] thread weapon_cabinet_door_open( "right" );
}
}

player_has_weapon = player has_weapon_or_upgrade( self.zombie_weapon_upgrade );
/*
player_has_weapon = false;
weapons = player GetWeaponsList();
if( IsDefined( weapons ) )
{
for( i = 0; i < weapons.size; i++ )
{
if( weapons[i] == self.zombie_weapon_upgrade )
{
player_has_weapon = true;
}
}
}
*/

if( !player_has_weapon )
{
player weapon_give( self.zombie_weapon_upgrade );
}
else
{
if( player has_upgrade( self.zombie_weapon_upgrade ) )
{
player ammo_give( self.zombie_weapon_upgrade+"_upgraded" );
}
else
{
player ammo_give( self.zombie_weapon_upgrade );
}
}
}
else // not enough money
{
play_sound_on_ent( "no_purchase" );
player thread maps\_zombiemode_perks::play_no_money_perk_dialog();
}
}
}

pay_turret_think( cost )
{
if( !isDefined( self.target ) )
{
return;
}
turret = GetEnt( self.target, "targetname" );

if( !isDefined( turret ) )
{
return;
}

turret makeTurretUnusable();

while( true )
{
self waittill( "trigger", player );

if( !is_player_valid( player ) )
{
player thread ignore_triggers( 0.5 );
continue;
}

if( player in_revive_trigger() )
{
wait( 0.1 );
continue;
}

if(isdefined(player.is_drinking))
{
wait(0.1);
continue;
}

if( player.score >= cost )
{
player maps\_zombiemode_score::minus_to_player_score( cost );
turret makeTurretUsable();
turret UseBy( player );
self disable_trigger();

player.curr_pay_turret = turret;

turret thread watch_for_laststand( player );
turret thread watch_for_fake_death( player );
if( isDefined( level.turret_timer ) )
{
turret thread watch_for_timeout( player, level.turret_timer );
}

while( isDefined( turret getTurretOwner() ) && turret getTurretOwner() == player )
{
wait( 0.05 );
}

turret notify( "stop watching" );

player.curr_pay_turret = undefined;

turret makeTurretUnusable();
self enable_trigger();
}
else // not enough money
{
play_sound_on_ent( "no_purchase" );
player thread maps\_zombiemode_perks::play_no_money_perk_dialog();
}
}
}

watch_for_laststand( player )
{
self endon( "stop watching" );

while( !player maps\_laststand::player_is_in_laststand() )
{
if( isDefined( level.intermission ) && level.intermission )
{
intermission = true;
}
wait( 0.05 );
}

if( isDefined( self getTurretOwner() ) && self getTurretOwner() == player )
{
self UseBy( player );
}
}

watch_for_fake_death( player )
{
self endon( "stop watching" );

player waittill( "fake_death" );

if( isDefined( self getTurretOwner() ) && self getTurretOwner() == player )
{
self UseBy( player );
}
}

watch_for_timeout( player, time )
{
self endon( "stop watching" );

self thread cancel_timer_on_end( player );

player thread maps\_zombiemode_timer::start_timer( time, "stop watching" );

wait( time );

if( isDefined( self getTurretOwner() ) && self getTurretOwner() == player )
{
self UseBy( player );
}
}

cancel_timer_on_end( player )
{
self waittill( "stop watching" );
player notify( "stop watching" );
}

weapon_cabinet_door_open( left_or_right )
{
if( left_or_right == "left" )
{
self rotateyaw( 120, 0.3, 0.2, 0.1 );
}
else if( left_or_right == "right" )
{
self rotateyaw( -120, 0.3, 0.2, 0.1 );
}
}

weapon_spawn_think()
{
cost = get_weapon_cost( self.zombie_weapon_upgrade );
ammo_cost = get_ammo_cost( self.zombie_weapon_upgrade );
is_grenade = (WeaponType( self.zombie_weapon_upgrade ) == "grenade");
if(is_grenade)
{
ammo_cost = cost;
}

self thread decide_hide_show_hint();

self.first_time_triggered = false;
for( ;; )
{
self waittill( "trigger", player );
// if not first time and they have the weapon give ammo

if( !is_player_valid( player ) )
{
player thread ignore_triggers( 0.5 );
continue;
}

if( !player can_buy_weapon() )
{
wait( 0.1 );
continue;
}

// Allow people to get ammo off the wall for upgraded weapons
player_has_weapon = player has_weapon_or_upgrade( self.zombie_weapon_upgrade );
/*
player_has_weapon = false;
weapons = player GetWeaponsList();
if( IsDefined( weapons ) )
{
for( i = 0; i < weapons.size; i++ )
{
if( weapons[i] == self.zombie_weapon_upgrade )
{
player_has_weapon = true;
}
}
}
*/

if( !player_has_weapon )
{
// else make the weapon show and give it
if( player.score >= cost )
{
if( self.first_time_triggered == false )
{
model = getent( self.target, "targetname" );
// model show();
model thread weapon_show( player );
self.first_time_triggered = true;

if(!is_grenade)
{
self SetHintString( &"ZOMBIE_WEAPONCOSTAMMO", cost, ammo_cost );
}
}

player maps\_zombiemode_score::minus_to_player_score( cost );

bbPrint( "zombie_uses: playername %s playerscore %d round %d cost %d name %s x %f y %f z %f type weapon",
player.playername, player.score, level.round_number, cost, self.zombie_weapon_upgrade, self.origin );

player weapon_give( self.zombie_weapon_upgrade );
}
else
{
play_sound_on_ent( "no_purchase" );
player thread maps\nazi_zombie_sumpf_blockers::play_no_money_purchase_dialog();

}
}
else
{
// MM - need to check and see if the player has an upgraded weapon.  If so, the ammo cost is much higher
if ( player has_upgrade( self.zombie_weapon_upgrade ) )
{
ammo_cost = 4500;
}
else
{
ammo_cost = get_ammo_cost( self.zombie_weapon_upgrade );
}

// if the player does have this then give him ammo.
if( player.score >= ammo_cost )
{
if( self.first_time_triggered == false )
{
model = getent( self.target, "targetname" );
// model show();
model thread weapon_show( player );
self.first_time_triggered = true;
if(!is_grenade)
{
self SetHintString( &"ZOMBIE_WEAPONCOSTAMMO", cost, get_ammo_cost( self.zombie_weapon_upgrade ) );
}
}

if( player HasWeapon( self.zombie_weapon_upgrade ) && player has_upgrade( self.zombie_weapon_upgrade ) )
{
ammo_given = player ammo_give( self.zombie_weapon_upgrade, true );
}
else if( player has_upgrade( self.zombie_weapon_upgrade ) )
{
ammo_given = player ammo_give( self.zombie_weapon_upgrade+"_upgraded" );
}
else
{
ammo_given = player ammo_give( self.zombie_weapon_upgrade );
}

if( ammo_given )
{
player maps\_zombiemode_score::minus_to_player_score( ammo_cost ); // this give him ammo to early

bbPrint( "zombie_uses: playername %s playerscore %d round %d cost %d name %s x %f y %f z %f type ammo",
player.playername, player.score, level.round_number, ammo_cost, self.zombie_weapon_upgrade, self.origin );
}
}
else
{
play_sound_on_ent( "no_purchase" );
}
}
}
}

weapon_show( player )
{
player_angles = VectorToAngles( player.origin - self.origin );

player_yaw = player_angles[1];
weapon_yaw = self.angles[1];

yaw_diff = AngleClamp180( player_yaw - weapon_yaw );

if( yaw_diff > 0 )
{
yaw = weapon_yaw - 90;
}
else
{
yaw = weapon_yaw + 90;
}

self.og_origin = self.origin;
self.origin = self.origin +( AnglesToForward( ( 0, yaw, 0 ) ) * 8 );

wait( 0.05 );
self Show();

play_sound_at_pos( "weapon_show", self.origin, self );

time = 1;
self MoveTo( self.og_origin, time );
}

weapon_give( weapon, is_upgrade )
{
primaryWeapons = self GetWeaponsListPrimaries();
current_weapon = undefined;

//if is not an upgraded perk purchase
if( !IsDefined( is_upgrade ) )
{
is_upgrade = false;
}

// This should never be true for the first time.
if( primaryWeapons.size >= self.MuleCount ) // he has two weapons
{
current_weapon = self getCurrentWeapon(); // get his current weapon

if ( current_weapon == "mine_bouncing_betty" )
{
current_weapon = undefined;
}

if( isdefined( current_weapon ) )
{
if( !( weapon == "fraggrenade" || weapon == "stielhandgranate" || weapon == "molotov" || weapon == "zombie_cymbal_monkey" ) )
{
self TakeWeapon( current_weapon );
}
}
}

if( weapon == "zombie_cymbal_monkey" )
{
// PI_CHANGE_BEGIN
// JMA 051409 sanity check to see if we have the weapon before we remove it
has_weapon = self HasWeapon( "molotov" );
if( isDefined(has_weapon) && has_weapon )
{
self TakeWeapon( "molotov" );
}

if( isDefined(level.zombie_weapons) && isDefined(level.zombie_weapons["molotov_zombie"]) )
{
has_weapon = self HasWeapon( "molotov_zombie" );
if( isDefined(has_weapon) && has_weapon )
{
self TakeWeapon( "molotov_zombie" );
}
}
// PI_CHANGE_END

self maps\_zombiemode_cymbal_monkey::player_give_cymbal_monkey();
play_weapon_vo( weapon );
return;
}
if( (weapon == "molotov" || weapon == "molotov_zombie") )
{
self TakeWeapon( "zombie_cymbal_monkey" );
}

self play_sound_on_ent( "purchase" );
self GiveWeapon( weapon, 0 );
self GiveMaxAmmo( weapon );
self SwitchToWeapon( weapon );

play_weapon_vo(weapon);
}
play_weapon_vo(weapon)
{
index = get_player_index(self);
if(!IsDefined (level.zombie_weapons[weapon].sound))
{
return;
}

if( level.zombie_weapons[weapon].sound == "vox_monkey" )
{
plr = "plr_" + index + "_";
create_and_play_dialog( plr, "vox_monkey", .25, "resp_monk" );
return;
}
// iprintlnbold (index);
if( level.zombie_weapons[weapon].sound != "" )
{
weap = level.zombie_weapons[weapon].sound;
// iprintlnbold("Play_Weap_VO_" + weap);
switch(weap)
{
case "vox_crappy":
if (level.vox_crappy_available.size < 1 )
{
level.vox_crappy_available = level.vox_crappy;
}
sound_to_play = random(level.vox_crappy_available);
level.vox_crappy_available = array_remove(level.vox_crappy_available,sound_to_play);
break;

case "vox_mg":
if (level.vox_mg_available.size < 1 )
{
level.vox_mg_available = level.vox_mg;
}
sound_to_play = random(level.vox_mg_available);
level.vox_mg_available = array_remove(level.vox_mg_available,sound_to_play);
break;
case "vox_shotgun":
if (level.vox_shotgun_available.size < 1 )
{
level.vox_shotgun_available = level.vox_shotgun;
}
sound_to_play = random(level.vox_shotgun_available);
level.vox_shotgun_available = array_remove(level.vox_shotgun_available,sound_to_play);
break;
case "vox_357":
if (level.vox_357_available.size < 1 )
{
level.vox_357_available = level.vox_357;
}
sound_to_play = random(level.vox_357_available);
level.vox_357_available = array_remove(level.vox_357_available,sound_to_play);
break;
case "vox_bar":
if (level.vox_bar_available.size < 1 )
{
level.vox_bar_available = level.vox_bar;
}
sound_to_play = random(level.vox_bar_available);
level.vox_bar_available = array_remove(level.vox_bar_available,sound_to_play);
break;
case "vox_flame":
if (level.vox_flame_available.size < 1 )
{
level.vox_flame_available = level.vox_flame;
}
sound_to_play = random(level.vox_flame_available);
level.vox_flame_available = array_remove(level.vox_flame_available,sound_to_play);
break;
case "vox_raygun":
if (level.vox_raygun_available.size < 1 )
{
level.vox_raygun_available = level.vox_raygun;
}
sound_to_play = random(level.vox_raygun_available);
level.vox_raygun_available = array_remove(level.vox_raygun_available,sound_to_play);
break;
case "vox_tesla":
if (level.vox_tesla_available.size < 1 )
{
level.vox_tesla_available = level.vox_tesla;
}
sound_to_play = random(level.vox_tesla_available);
level.vox_tesla_available = array_remove(level.vox_tesla_available,sound_to_play);
break;
case "vox_sticky":
if (level.vox_sticky_available.size < 1 )
{
level.vox_sticky_available = level.vox_sticky;
}
sound_to_play = random(level.vox_sticky_available);
level.vox_sticky_available = array_remove(level.vox_sticky_available,sound_to_play);
break;
case "vox_ppsh":
if (level.vox_ppsh_available.size < 1 )
{
level.vox_ppsh_available = level.vox_ppsh;
}
sound_to_play = random(level.vox_ppsh_available);
level.vox_ppsh_available = array_remove(level.vox_ppsh_available,sound_to_play);
break;
case "vox_mp40":
if (level.vox_mp40_available.size < 1 )
{
level.vox_mp40_available = level.vox_mp40;
}
sound_to_play = random(level.vox_mp40_available);
level.vox_mp40_available = array_remove(level.vox_mp40_available,sound_to_play);
break;

default:
sound_var = randomintrange(0, level.zombie_weapons[weapon].variation_count);
sound_to_play = level.zombie_weapons[weapon].sound + "_" + sound_var;

}

plr = "plr_" + index + "_";
//self playsound ("plr_" + index + "_" + sound_to_play);
//iprintlnbold (sound_to_play);

//thread setup_response_line( self, index, "monk" );
self maps\_zombiemode_spawner::do_player_playdialog(plr, sound_to_play, 0.05);
}
}
do_player_weap_dialog(player_index, sound_to_play, waittime)
{
if(!IsDefined (level.player_is_speaking))
{
level.player_is_speaking = 0;
}
if(level.player_is_speaking != 1)
{
level.player_is_speaking = 1;
self playsound(player_index + sound_to_play, "sound_done" + sound_to_play);
self waittill("sound_done" + sound_to_play);
wait(waittime);
level.player_is_speaking = 0;
}

}
get_player_index(player)
{
assert( IsPlayer( player ) );
assert( IsDefined( player.entity_num ) );
/#
// used for testing to switch player's VO in-game from devgui
if( player.entity_num == 0 && GetDVar( "zombie_player_vo_overwrite" ) != "" )
{
new_vo_index = GetDVarInt( "zombie_player_vo_overwrite" );
return new_vo_index;
}
#/
return player.entity_num;
}

ammo_give( weapon, also_has_upgrade )
{
// We assume before calling this function we already checked to see if the player has this weapon...

if( !isDefined( also_has_upgrade ) )
{
also_has_upgrade = false;
}

// Should we give ammo to the player
give_ammo = false;

// Check to see if ammo belongs to a primary weapon
if( weapon != "fraggrenade" && weapon != "stielhandgranate" && weapon != "molotov" )
{
if( isdefined( weapon ) ) 
{
// get the max allowed ammo on the current weapon
stockMax = WeaponMaxAmmo( weapon );
if( also_has_upgrade )
{
stockMax += WeaponMaxAmmo( weapon+"_upgraded" );
}

// Get the current weapon clip count
clipCount = self GetWeaponAmmoClip( weapon );

currStock = self GetAmmoCount( weapon );

// compare it with the ammo player actually has, if more or equal just dont give the ammo, else do
if( ( currStock - clipcount ) >= stockMax )
{
give_ammo = false;
}
else
{
give_ammo = true; // give the ammo to the player
}
}
}
else
{
// Ammo belongs to secondary weapon
if( self has_weapon_or_upgrade( weapon ) )
{
// Check if the player has less than max stock, if no give ammo
if( self getammocount( weapon ) < WeaponMaxAmmo( weapon ) )
{
// give the ammo to the player
give_ammo = true;
}
}
}

if( give_ammo )
{
self playsound( "cha_ching" );
self GivemaxAmmo( weapon );
if( also_has_upgrade )
{
self GiveMaxAmmo( weapon+"_upgraded" );
}
return true;
}

if( !give_ammo )
{
return false;
}
}
add_weapon_to_sound_array(vo,num)
{
if(!isDefined(vo))
{
return;
}
player = getplayers();
for(i=0;i<player.size;i++)
{
index = maps\_zombiemode_weapons::get_player_index(player);
player_index = "plr_" + index + "_";
num = maps\_zombiemode_spawner::get_number_variants(player_index + vo);
}
// iprintlnbold(vo);

switch(vo)
{
case "vox_crappy":
if(!isDefined(level.vox_crappy))
{
level.vox_crappy = [];
for(i=0;i<num;i++)
{
level.vox_crappy[level.vox_crappy.size] = "vox_crappy_" + i;
}
}
level.vox_crappy_available = level.vox_crappy;
break;

case "vox_mg":
if(!isDefined(level.vox_mg))
{
level.vox_mg = [];
for(i=0;i<num;i++)
{
level.vox_mg[level.vox_mg.size] = "vox_mg_" + i;
}
}
level.vox_mg_available = level.vox_mg;
break;
case "vox_shotgun":
if(!isDefined(level.vox_shotgun))
{
level.vox_shotgun = [];
for(i=0;i<num;i++)
{
level.vox_shotgun[level.vox_shotgun.size] = "vox_shotgun_" + i;
}
}
level.vox_shotgun_available = level.vox_shotgun;
break;
case "vox_357":
if(!isDefined(level.vox_357))
{
level.vox_357 = [];
for(i=0;i<num;i++)
{
level.vox_357[level.vox_357.size] = "vox_357_" + i;
}
}
level.vox_357_available = level.vox_357;
break;
case "vox_bar":
if(!isDefined(level.vox_bar))
{
level.vox_bar = [];
for(i=0;i<num;i++)
{
level.vox_bar[level.vox_bar.size] = "vox_bar_" + i;
}
}
level.vox_bar_available = level.vox_bar;
break;
case "vox_flame":
if(!isDefined(level.vox_flame))
{
level.vox_flame = [];
for(i=0;i<num;i++)
{
level.vox_flame[level.vox_flame.size] = "vox_flame_" + i;
}
}
level.vox_flame_available = level.vox_flame;
break;

case "vox_raygun":
if(!isDefined(level.vox_raygun))
{
level.vox_raygun = [];
for(i=0;i<num;i++)
{
level.vox_raygun[level.vox_raygun.size] = "vox_raygun_" + i;
}
}
level.vox_raygun_available = level.vox_raygun;
break;
case "vox_tesla":
if(!isDefined(level.vox_tesla))
{
level.vox_tesla = [];
for(i=0;i<num;i++)
{
level.vox_tesla[level.vox_tesla.size] = "vox_tesla_" + i;
}
}
level.vox_tesla_available = level.vox_tesla;
break;
case "vox_sticky":
if(!isDefined(level.vox_sticky))
{
level.vox_sticky = [];
for(i=0;i<num;i++)
{
level.vox_sticky[level.vox_sticky.size] = "vox_sticky_" + i;
}
}
level.vox_sticky_available = level.vox_sticky;
break;
case "vox_ppsh":
if(!isDefined(level.vox_ppsh))
{
level.vox_ppsh = [];
for(i=0;i<num;i++)
{
level.vox_ppsh[level.vox_ppsh.size] = "vox_ppsh_" + i;
}
}
level.vox_ppsh_available = level.vox_ppsh;
break;
case "vox_mp40":
if(!isDefined(level.vox_mp40))
{
level.vox_mp40 = [];
for(i=0;i<num;i++)
{
level.vox_mp40[level.vox_mp40.size] = "vox_mp40_" + i;
}
}
level.vox_mp40_available = level.vox_mp40;
break;
case "vox_monkey":
if(!isDefined(level.vox_monkey))
{
level.vox_monkey = [];
for(i=0;i<num;i++)
{
level.vox_monkey[level.vox_monkey.size] = "vox_monkey_" + i;
}
}
level.vox_monkey_available = level.vox_monkey;
break;
}

}






and here's dlc3_code
Code Snippet
Plaintext
// Sparks (9/12/2009 3:20:27 PM)
// treminaor (6/03/2013 10:54 AM) - This file is an adaptation of nazi_zombie_factory.gsc. Key functions have been pulled out and put here, adapted for general use.
//   - The file was originally created for the Sniperbolt Tutorial but as a result contained a couple bugs. I have gone through and fixed them for this Modtools patch.
#include maps\ugx_modder_help;

#include maps\_utility;
#include common_scripts\utility;
#include maps\_zombiemode_utility;
#include maps\_music;

// DLC3 Utilities
#include maps\dlc3_teleporter;

/***********************************************************************
    DLC3 STUFF
***********************************************************************/

initDLC3_Vars()
{
// Alter The Pulls
level.pulls_since_last_ray_gun = 0;
level.pulls_since_last_tesla_gun = 0;
level.player_drops_tesla_gun = false;

// Coop Heroes Loadout
if( isDefined( level.DLC3.useCoopHeroes ) && level.DLC3.useCoopHeroes )
{
level.use_zombie_heroes = level.DLC3.useCoopHeroes;
}
else
{
level.use_zombie_heroes = true;
}

// Bowie Knife Damage
if( isDefined( level.DLC3.perk_altMeleeDamage ) && level.DLC3.perk_altMeleeDamage )
{
SetDvar( "perk_altMeleeDamage", level.DLC3.perk_altMeleeDamage );
}
else
{
SetDvar( "perk_altMeleeDamage", 1000 );
}

// Dogs Enabled
if( isDefined( level.DLC3.useHellHounds ) && level.DLC3.useHellHounds )
{
level.dogs_enabled = level.DLC3.useHellHounds;
}
else
{
level.dogs_enabled = true;
}

// Mixed Crawlers And Dogs
if( isDefined( level.DLC3.useMixedRounds ) && level.DLC3.useMixedRounds )
{
level.mixed_rounds_enabled = level.DLC3.useMixedRounds;
}
else
{
level.mixed_rounds_enabled = true;
}

// Array For Burning Zombies, Traps, and Risers -- Leave These
level.burning_zombies = [];
level.traps = [];
level.zombie_rise_spawners = [];

// Barrier Search Override
if( isDefined( level.DLC3.barrierSearchOverride ) && level.DLC3.barrierSearchOverride )
{
level.max_barrier_search_dist_override = level.DLC3.barrierSearchOverride;
}
else
{
level.max_barrier_search_dist_override = 400;
}

// Pointer Functions -- These Are Stock
level.door_dialog_function = maps\_zombiemode::play_door_dialog;
level.achievement_notify_func = maps\_zombiemode_utility::achievement_notify;
level.dog_spawn_func = maps\_zombiemode_dogs::dog_spawn_factory_logic;

level.zombie_anim_override = maps\dlc3_code::anim_override_func;
}

initDLC3_Vars2()
{
// Special level specific settings
if( isDefined( level.DLC3.powerUpDropMax ) && level.DLC3.powerUpDropMax )
{
set_zombie_var( "zombie_powerup_drop_max_per_round", level.DLC3.powerUpDropMax ); // lower this to make drop happen more often
}
{
set_zombie_var( "zombie_powerup_drop_max_per_round", 3 ); // lower this to make drop happen more often
}
}

DLC3_threadCalls()
{
initDLC3_Vars();

script_anims_init();

level thread maps\_callbacksetup::SetupCallbacks();

precacheDLC3();
}

DLC3_threadCalls2()
{
if( isArray( level.DLC3.initialZones ) && isDefined( level.DLC3.initialZones[ 0 ] ) )
{
level thread maps\_zombiemode_zone_manager::manage_zones( level.DLC3.initialZones );
}

if( isDefined( level.DLC3.useSnow ) && level.DLC3.useSnow )
{
level thread player_Snow();
}

init_sounds();

level thread initDLC3_Vars2();

if( isDefined( level.DLC3.useElectricSwitch ) && level.DLC3.useElectricSwitch )
{
level thread power_electric_switch();
}
else
{
level thread power_electric_switch_on();
}

level thread magic_box_init();

if( isDefined( level.DLC3.useElectricTraps ) && level.DLC3.useElectricTraps )
{
thread init_elec_trap_trigs();
}

// Need this here because of the createFX hack for teleporter FX
if( !isDefined( level._script_exploders ) )
{
level._script_exploders = [];
}

teleporter_init();

level thread mapStartAudio();

level thread intro_screen();

level thread jump_from_bridge();
level lock_additional_player_spawner();

if( isDefined( level.DLC3.useBridge ) && level.DLC3.useBridge )
{
level thread bridge_init();
}

level thread perkMachineRattles();
}

precacheDLC3()
{
precachestring(&"ZOMBIE_FLAMES_UNAVAILABLE");
precachestring(&"ZOMBIE_ELECTRIC_SWITCH");

precachestring(&"ZOMBIE_POWER_UP_TPAD");
precachestring(&"ZOMBIE_TELEPORT_TO_CORE");
precachestring(&"ZOMBIE_LINK_TPAD");
precachestring(&"ZOMBIE_LINK_ACTIVE");
precachestring(&"ZOMBIE_INACTIVE_TPAD");
precachestring(&"ZOMBIE_START_TPAD");

precacheshellshock("electrocution");
precachemodel("zombie_zapper_cagelight_red");
precachemodel("zombie_zapper_cagelight_green");
precacheModel("lights_indlight_on" );
precacheModel("lights_milit_lamp_single_int_on" );
precacheModel("lights_tinhatlamp_on" );
precacheModel("lights_berlin_subway_hat_0" );
precacheModel("lights_berlin_subway_hat_50" );
precacheModel("lights_berlin_subway_hat_100" );
precachemodel("collision_geo_32x32x128");

precachestring(&"ZOMBIE_BETTY_ALREADY_PURCHASED");
precachestring(&"ZOMBIE_BETTY_HOWTO");
}

intro_screen()
{

flag_wait( "all_players_connected" );
wait(2);
level.intro_hud = [];
for(i = 0;  i < 3; i++)
{
level.intro_hud[i] = newHudElem();
level.intro_hud[i].x = 0;
level.intro_hud[i].y = 0;
level.intro_hud[i].alignX = "left";
level.intro_hud[i].alignY = "bottom";
level.intro_hud[i].horzAlign = "left";
level.intro_hud[i].vertAlign = "bottom";
level.intro_hud[i].foreground = true;

if ( level.splitscreen && !level.hidef )
{
level.intro_hud[i].fontScale = 2.75;
}
else
{
level.intro_hud[i].fontScale = 1.75;
}
level.intro_hud[i].alpha = 0.0;
level.intro_hud[i].color = (1, 1, 1);
level.intro_hud[i].inuse = false;
}
level.intro_hud[0].y = -110;
level.intro_hud[1].y = -90;
level.intro_hud[2].y = -70;


level.intro_hud[0] settext(level.DLC3.introString);
level.intro_hud[1] settext("");
level.intro_hud[2] settext("");

for(i = 0 ; i < 3; i++)
{
level.intro_hud[i] FadeOverTime( 3.5 );
level.intro_hud[i].alpha = 1;
wait(1.5);
}
wait(1.5);
for(i = 0 ; i < 3; i++)
{
level.intro_hud[i] FadeOverTime( 3.5 );
level.intro_hud[i].alpha = 0;
wait(1.5);
}
//wait(1.5);
for(i = 0 ; i < 3; i++)
{
level.intro_hud[i] destroy();
}
}

init_sounds()
{
maps\_zombiemode_utility::add_sound( "break_stone", "break_stone" );
maps\_zombiemode_utility::add_sound( "gate_door", "open_door" );
maps\_zombiemode_utility::add_sound( "heavy_door", "open_door" );
}

include_weapons()
{
// Pistols
include_weapon( "mouser" );
include_weapon( "mouser_upgraded", false );
include_weapon( "b23r", true );
include_weapon( "b23r_upgraded", false );
include_weapon( "rnma", true );
include_weapon( "rnma_upgraded", false );
include_weapon( "five7", true );
include_weapon( "five7_upgraded", false );
include_weapon( "kap40", true );
include_weapon( "kap40_upgraded", false );

// SMG
include_weapon( "zombie_mp40", false );
include_weapon( "zombie_mp40_upgraded", false );
include_weapon( "bo2_mp7", true );
include_weapon( "bo2_mp7_upgraded", false );
include_weapon( "pdw", true );
include_weapon( "pdw_upgraded", false );
include_weapon( "zombie_ppsh", true );
include_weapon( "zombie_ppsh_upgraded", false );
include_weapon( "msmc", true );
include_weapon( "msmc_upgraded", false );
include_weapon( "ak74u_zm", true );
include_weapon( "ak74u_zm_upgraded", false );
include_weapon( "chicom", true );
include_weapon( "chicom_upgraded", false );

// Assault Rifle
include_weapon( "zombie_stg44", false );
include_weapon( "zombie_stg44_upgraded", false );
include_weapon( "an94_mp", true );
include_weapon( "an94_mp_upgraded", false );
include_weapon( "m1927", true );
include_weapon( "m1927_upgraded", false );
include_weapon( "m27", true );
include_weapon( "m27_upgraded", false );
include_weapon( "scar_h", true );
include_weapon( "scar_h_upgraded", false );
include_weapon( "scorpion", true );
include_weapon( "scorpion_upgraded", false );
include_weapon( "m14", true );
include_weapon( "m14_upgraded", false );
include_weapon( "mtar", true );
include_weapon( "mtar_upgraded", false );
include_weapon( "type25", true );
include_weapon( "type25_upgraded", false );


// Scoped
include_weapon( "dsr", true );
include_weapon( "dsr_upgraded", false );
include_weapon( "ballista" );
include_weapon( "ballista_upgraded", false );

// Shotgun
include_weapon( "remington" );
include_weapon( "remington_upgraded", false );
include_weapon( "ksg", true );
include_weapon( "ksg_upgraded", false );

// Heavy MG
include_weapon( "zombie_mg08", true );
include_weapon( "zombie_mg08_upgraded", false );
include_weapon( "hamr_mp", true );
include_weapon( "hamr_mp_upgraded", false );

// Special
include_weapon( "ray_gun", ::factory_ray_gun_weighting_func );
include_weapon( "ray_gun_upgraded", false );
include_weapon( "raguma" );
include_weapon( "raguma_upgraded", false );
include_weapon( "zombie_cymbal_monkey" );

// Bouncing betties
//include_weapon( "mine_bouncing_betty", false );

// Limited weapons
maps\_zombiemode_weapons::add_limited_weapon( "mouser", 0 );
maps\_zombiemode_weapons::add_limited_weapon( "rnma", 2 );
maps\_zombiemode_weapons::add_limited_weapon( "raguma", 2 );
maps\_zombiemode_weapons::add_limited_weapon( "ray_gun", 2 );
}

include_powerups()
{
include_powerup( "nuke" );
include_powerup( "insta_kill" );
include_powerup( "double_points" );
include_powerup( "full_ammo" );
include_powerup( "carpenter" );
}

DLC3_FX()
{
// THESE ARE NEEDED FOR ZOMBIE MODE -- LEAVE THESE

// Scripted FX
level._effect["large_ceiling_dust"] = LoadFx( "env/dirt/fx_dust_ceiling_impact_lg_mdbrown" );
level._effect["poltergeist"] = LoadFx( "misc/fx_zombie_couch_effect" );
level._effect["gasfire"] = LoadFx("destructibles/fx_dest_fire_vert");
level._effect["switch_sparks"] = loadfx("env/electrical/fx_elec_wire_spark_burst");
level._effect["wire_sparks_oneshot"] = loadfx("env/electrical/fx_elec_wire_spark_dl_oneshot");

level._effect["rise_burst"] = LoadFx("maps/mp_maps/fx_mp_zombie_hand_dirt_burst");
level._effect["rise_billow"] = LoadFx("maps/mp_maps/fx_mp_zombie_body_dirt_billowing");
level._effect["rise_dust"] = LoadFx("maps/mp_maps/fx_mp_zombie_body_dust_falling");

level._effect["dog_eye_glow"] = loadfx("maps/zombie/fx_zombie_dog_eyes");
level._effect["dog_gib"] = loadfx( "maps/zombie/fx_zombie_dog_explosion" );
level._effect["dog_trail_fire"] = loadfx("maps/zombie/fx_zombie_dog_fire_trail");
level._effect["dog_trail_ash"] = loadfx("maps/zombie/fx_zombie_dog_ash_trail");
level._effect["dog_breath"] = Loadfx("maps/zombie/fx_zombie_dog_breath");

level._effect["lght_marker"] = Loadfx("maps/zombie/fx_zombie_factory_marker");
level._effect["lght_marker_flare"] = Loadfx("maps/zombie/fx_zombie_factory_marker_fl");

level._effect["betty_explode"] = loadfx("weapon/bouncing_betty/fx_explosion_betty_generic");
level._effect["betty_trail"] = loadfx("weapon/bouncing_betty/fx_betty_trail");

level._effect["zapper_fx"] = loadfx("misc/fx_zombie_zapper_powerbox_on");
level._effect["zapper"] = loadfx("misc/fx_zombie_electric_trap");
level._effect["zapper_wall"] = loadfx("misc/fx_zombie_zapper_wall_control_on");
level._effect["zapper_light_ready"] = loadfx("maps/zombie/fx_zombie_light_glow_green");
level._effect["zapper_light_notready"] = loadfx("maps/zombie/fx_zombie_light_glow_red");
level._effect["elec_room_on"] = loadfx("fx_zombie_light_elec_room_on");
level._effect["elec_md"] = loadfx("env/electrical/fx_elec_player_md");
level._effect["elec_sm"] = loadfx("env/electrical/fx_elec_player_sm");
level._effect["elec_torso"] = loadfx("env/electrical/fx_elec_player_torso");

level._effect["elec_trail_one_shot"] = loadfx("misc/fx_zombie_elec_trail_oneshot");
level._effect["wire_spark"] = loadfx("maps/zombie/fx_zombie_wire_spark");
level._effect["powerup_on"] = loadfx( "misc/fx_zombie_powerup_on" );

// Create FX

if( isDefined( level.DLC3.myFX ) )
{
[[level.DLC3.myFX]]();
}

level._effect["transporter_beam"]           = loadfx("maps/zombie/fx_transporter_beam");
level._effect["transporter_pad_start"]     = loadfx("maps/zombie/fx_transporter_pad_start");
level._effect["transporter_start"]         = loadfx("maps/zombie/fx_transporter_start");
level._effect["transporter_ambient"]       = loadfx("maps/zombie/fx_transporter_ambient");
level._effect["zombie_mainframe_link_all"] = loadfx("maps/zombie/fx_zombie_mainframe_link_all");
level._effect["zombie_mainframe_link_single"] = loadfx("maps/zombie/fx_zombie_mainframe_link_single");
level._effect["zombie_mainframe_linked"]       = loadfx("maps/zombie/fx_zombie_mainframe_linked");
level._effect["zombie_mainframe_beam"]       = loadfx("maps/zombie/fx_zombie_mainframe_beam");
level._effect["zombie_mainframe_flat"]       = loadfx("maps/zombie/fx_zombie_mainframe_flat");
level._effect["zombie_mainframe_flat_start"]   = loadfx("maps/zombie/fx_zombie_mainframe_flat_start");
level._effect["zombie_mainframe_beam_start"]   = loadfx("maps/zombie/fx_zombie_mainframe_beam_start");
level._effect["zombie_flashback_american"]     = loadfx("maps/zombie/fx_zombie_flashback_american");
level._effect["gasfire2"]                   = Loadfx("destructibles/fx_dest_fire_vert");
level._effect["mp_light_lamp"]               = Loadfx("maps/mp_maps/fx_mp_light_lamp");
level._effect["zombie_difference"]             = loadfx("maps/zombie/fx_zombie_difference");
level._effect["zombie_mainframe_steam"]         = loadfx("maps/zombie/fx_zombie_mainframe_steam");
level._effect["zombie_heat_sink"]               = loadfx("maps/zombie/fx_zombie_heat_sink");
level._effect["mp_smoke_stack"]             = loadfx("maps/mp_maps/fx_mp_smoke_stack");
level._effect["mp_elec_spark_fast_random"]   = loadfx("maps/mp_maps/fx_mp_elec_spark_fast_random");
level._effect["zombie_elec_gen_idle"]       = loadfx("misc/fx_zombie_elec_gen_idle");
level._effect["zombie_moon_eclipse"]           = loadfx("maps/zombie/fx_zombie_moon_eclipse");
level._effect["zombie_clock_hand"]             = loadfx("maps/zombie/fx_zombie_clock_hand");
level._effect["zombie_elec_pole_terminal"]     = loadfx("maps/zombie/fx_zombie_elec_pole_terminal");
level._effect["mp_elec_broken_light_1shot"]     = loadfx("maps/mp_maps/fx_mp_elec_broken_light_1shot");
level._effect["mp_light_lamp_no_eo"]         = loadfx("maps/mp_maps/fx_mp_light_lamp_no_eo");
level._effect["zombie_packapunch"]             = loadfx("maps/zombie/fx_zombie_packapunch");
level._effect["electric_short_oneshot"] = loadfx("env/electrical/fx_elec_short_oneshot");

animscripts\utility::setFootstepEffect( "asphalt",    LoadFx( "bio/player/fx_footstep_dust" ) );
animscripts\utility::setFootstepEffect( "brick",      LoadFx( "bio/player/fx_footstep_dust" ) );
animscripts\utility::setFootstepEffect( "carpet",     LoadFx( "bio/player/fx_footstep_dust" ) );
animscripts\utility::setFootstepEffect( "cloth",      LoadFx( "bio/player/fx_footstep_dust" ) );
animscripts\utility::setFootstepEffect( "concrete",   LoadFx( "bio/player/fx_footstep_dust" ) );
animscripts\utility::setFootstepEffect( "dirt",       LoadFx( "bio/player/fx_footstep_sand" ) );
animscripts\utility::setFootstepEffect( "foliage",    LoadFx( "bio/player/fx_footstep_dust" ) );
animscripts\utility::setFootstepEffect( "gravel",     LoadFx( "bio/player/fx_footstep_sand" ) );
animscripts\utility::setFootstepEffect( "grass",      LoadFx( "bio/player/fx_footstep_sand" ) );
animscripts\utility::setFootstepEffect( "metal",      LoadFx( "bio/player/fx_footstep_dust" ) );
animscripts\utility::setFootstepEffect( "mud",        LoadFx( "bio/player/fx_footstep_mud" ) );
animscripts\utility::setFootstepEffect( "paper",      LoadFx( "bio/player/fx_footstep_dust" ) );
animscripts\utility::setFootstepEffect( "plaster",    LoadFx( "bio/player/fx_footstep_dust" ) );
animscripts\utility::setFootstepEffect( "rock",       LoadFx( "bio/player/fx_footstep_sand" ) );
animscripts\utility::setFootstepEffect( "sand",       LoadFx( "bio/player/fx_footstep_sand" ) );
animscripts\utility::setFootstepEffect( "water",      LoadFx( "bio/player/fx_footstep_water" ) );
animscripts\utility::setFootstepEffect( "wood",       LoadFx( "bio/player/fx_footstep_dust" ) );

[[level.DLC3.createArt]]();

spawnFX();
}

spawnFX()
{
[[level.DLC3.createFX]]();

maps\createFX\dlc3_fx::main();
}

/***********************************************************************
    TRAP STUFF
***********************************************************************/

init_elec_trap_trigs()
{
array_thread( getStructArray( "dlc3_electric_trap", "targetname"), ::electric_trap_think );
}

electric_trap_dialog()
{

self endon ("warning_dialog");
level endon("switch_flipped");
timer =0;
while(1)
{
wait(0.5);
players = get_players();
for(i = 0; i < players.size; i++)
{
dist = distancesquared(players[i].origin, self.origin );
if(dist > 70*70)
{
timer = 0;
continue;
}
if(dist < 70*70 && timer < 3)
{
wait(0.5);
timer ++;
}
if(dist < 70*70 && timer == 3)
{

index = maps\_zombiemode_weapons::get_player_index(players[i]);
plr = "plr_" + index + "_";
//players[i] create_and_play_dialog( plr, "vox_level_start", 0.25 );
wait(3);
self notify ("warning_dialog");
//iprintlnbold("warning_given");
}
}
}
}

electric_trap_think()
{
enable_flag = undefined;

if( !isDefined( self.script_string ) )
{
return;
}
else
{
enable_flag = self.script_string;
}

self sethintstring(&"ZOMBIE_FLAMES_UNAVAILABLE");
self.zombie_cost = 1000;

self thread electric_trap_dialog();

// get a list of all of the other triggers with the same name
triggers = getentarray( self.targetname, "targetname" );
flag_wait( "electricity_on" );

// Get the damage trigger.  This is the unifying element to let us know it's been activated.
self.zombie_dmg_trig = getent(self.target,"targetname");
self.zombie_dmg_trig.in_use = 0;

// Set buy string
self sethintstring(&"ZOMBIE_BUTTON_NORTH_FLAMES");

// Getting the light that's related is a little esoteric, but there isn't
// a better way at the moment.  It uses linknames, which are really dodgy.
light_name = ""; // scope declaration
tswitch = getent(self.script_linkto,"script_linkname");
switch ( tswitch.script_linkname )
{
case "10": // wnuen
case "11":
light_name = "zapper_light_wuen";
break;

case "20": // warehouse
case "21":
light_name = "zapper_light_warehouse";
break;

case "30": // Bridge
case "31":
light_name = "zapper_light_bridge";
break;
}

// The power is now on, but keep it disabled until a certain condition is met
// such as opening the door it is blocking or waiting for the bridge to lower.
if ( !flag( enable_flag ) )
{
self trigger_off();

zapper_light_red( light_name );
flag_wait( enable_flag );

self trigger_on();
}

// Open for business! 
zapper_light_green( light_name );

while(1)
{
//valve_trigs = getentarray(self.script_noteworthy ,"script_noteworthy");

//wait until someone uses the valve
self waittill("trigger",who);
if( who in_revive_trigger() )
{
continue;
}

if( is_player_valid( who ) )
{
if( who.score >= self.zombie_cost )
{
if(!self.zombie_dmg_trig.in_use)
{
self.zombie_dmg_trig.in_use = 1;

//turn off the valve triggers associated with this trap until available again
array_thread (triggers, ::trigger_off);

play_sound_at_pos( "purchase", who.origin );
self thread electric_trap_move_switch(self);
//need to play a 'woosh' sound here, like a gas furnace starting up
self waittill("switch_activated");
//set the score
who maps\_zombiemode_score::minus_to_player_score( self.zombie_cost );

//this trigger detects zombies walking thru the flames
self.zombie_dmg_trig trigger_on();

//play the flame FX and do the actual damage
self thread activate_electric_trap();

//wait until done and then re-enable the valve for purchase again
self waittill("elec_done");

clientnotify(self.script_string +"off");

//delete any FX ents
if(isDefined(self.fx_org))
{
self.fx_org delete();
}
if(isDefined(self.zapper_fx_org))
{
self.zapper_fx_org delete();
}
if(isDefined(self.zapper_fx_switch_org))
{
self.zapper_fx_switch_org delete();
}

//turn the damage detection trigger off until the flames are used again
self.zombie_dmg_trig trigger_off();
wait(25);

array_thread (triggers, ::trigger_on);

//COLLIN: Play the 'alarm' sound to alert players that the traps are available again (playing on a temp ent in case the PA is already in use.
//speakerA = getent("loudspeaker", "targetname");
//playsoundatposition("warning", speakera.origin);
self notify("available");

self.zombie_dmg_trig.in_use = 0;
}
}
}
}
}

electric_trap_move_switch(parent)
{
light_name = ""; // scope declaration
tswitch = getent(parent.script_linkto,"script_linkname");
switch ( tswitch.script_linkname )
{
case "10": // wnuen
case "11":
light_name = "zapper_light_wuen";
break;

case "20": // warehouse
case "21":
light_name = "zapper_light_warehouse";
break;

case "30":
case "31":
light_name = "zapper_light_bridge";
break;
}

//turn the light above the door red
zapper_light_red( light_name );
tswitch rotatepitch(180,.5);
tswitch playsound("amb_sparks_l_b");
tswitch waittill("rotatedone");

self notify("switch_activated");
self waittill("available");
tswitch rotatepitch(-180,.5);

//turn the light back green once the trap is available again
zapper_light_green( light_name );
}

activate_electric_trap()
{
if(isDefined(self.script_string) && self.script_string == "warehouse")
{
clientnotify("warehouse");
}
else if(isDefined(self.script_string) && self.script_string == "wuen")
{
clientnotify("wuen");
}
else
{
clientnotify("bridge");
}

clientnotify(self.target);

fire_points = getentarray(self.target,"targetname");

for(i=0;i<fire_points.size;i++)
{
wait_network_frame();
fire_points[i] thread electric_trap_fx(self);
}

//do the damage
self.zombie_dmg_trig thread elec_barrier_damage();

// reset the zapper model
level waittill("arc_done");
}

electric_trap_fx(notify_ent)
{
self.tag_origin = spawn("script_model",self.origin);
//self.tag_origin setmodel("tag_origin");

//playfxontag(level._effect["zapper"],self.tag_origin,"tag_origin");

self.tag_origin playsound("elec_start");
self.tag_origin playloopsound("elec_loop");
self thread play_electrical_sound();

wait(25);

self.tag_origin stoploopsound();

self.tag_origin delete();
notify_ent notify("elec_done");
level notify ("arc_done");
}

play_electrical_sound()
{
level endon ("arc_done");
while(1)
{
wait(randomfloatrange(0.1, 0.5));
playsoundatposition("elec_arc", self.origin);
}


}

elec_barrier_damage()
{
while(1)
{
self waittill("trigger",ent);

//player is standing electricity, dumbass
if(isplayer(ent) )
{
ent thread player_elec_damage();
}
else
{
if(!isDefined(ent.marked_for_death))
{
ent.marked_for_death = true;
ent thread zombie_elec_death( randomint(100) );
}
}
}
}

play_elec_vocals()
{
if(IsDefined (self))
{
org = self.origin;
wait(0.15);
playsoundatposition("elec_vocals", org);
playsoundatposition("zombie_arc", org);
playsoundatposition("exp_jib_zombie", org);
}
}

player_elec_damage()
{
self endon("death");
self endon("disconnect");

if(!IsDefined (level.elec_loop))
{
level.elec_loop = 0;
}

if( !isDefined(self.is_burning) && !self maps\_laststand::player_is_in_laststand() )
{
self.is_burning = 1;
self setelectrified(1.25);
shocktime = 2.5;
//Changed Shellshock to Electrocution so we can have different bus volumes.
self shellshock("electrocution", shocktime);

if(level.elec_loop == 0)
{
elec_loop = 1;
//self playloopsound ("electrocution");
self playsound("zombie_arc");
}
if(!self hasperk("specialty_armorvest") || self.health - 100 < 1)
{

radiusdamage(self.origin,10,self.health + 100,self.health + 100);
self.is_burning = undefined;
}
else
{
self dodamage(50, self.origin);
wait(.1);
//self playsound("zombie_arc");
self.is_burning = undefined;
}
}
}

zombie_elec_death(flame_chance)
{
self endon("death");

//10% chance the zombie will burn, a max of 6 burning zombs can be goign at once
//otherwise the zombie just gibs and dies
if(flame_chance > 90 && level.burning_zombies.size < 6)
{
level.burning_zombies[level.burning_zombies.size] = self;
self thread zombie_flame_watch();
self playsound("ignite");
self thread animscripts\death::flame_death_fx();
wait(randomfloat(1.25));
}
else
{

refs[0] = "guts";
refs[1] = "right_arm";
refs[2] = "left_arm";
refs[3] = "right_leg";
refs[4] = "left_leg";
refs[5] = "no_legs";
refs[6] = "head";
self.a.gib_ref = refs[randomint(refs.size)];

playsoundatposition("zombie_arc", self.origin);
if( !self enemy_is_dog() && randomint(100) > 50 )
{
self thread electroctute_death_fx();
self thread play_elec_vocals();
}
wait(randomfloat(1.25));
self playsound("zombie_arc");
}

self dodamage(self.health + 666, self.origin);
iprintlnbold("should be damaged");
}

zombie_flame_watch()
{
self waittill("death");
self stoploopsound();
level.burning_zombies = array_remove_nokeys(level.burning_zombies,self);
}

zapper_light_red( lightname )
{
zapper_lights = getentarray( lightname, "targetname");
for(i=0;i<zapper_lights.size;i++)
{
zapper_lights[i] setmodel("zombie_zapper_cagelight_red");

if(isDefined(zapper_lights[i].fx))
{
zapper_lights[i].fx delete();
}

zapper_lights[i].fx = maps\_zombiemode_net::network_safe_spawn( "trap_light_red", 2, "script_model", zapper_lights[i].origin );
zapper_lights[i].fx setmodel("tag_origin");
zapper_lights[i].fx.angles = zapper_lights[i].angles+(-90,0,0);
playfxontag(level._effect["zapper_light_notready"],zapper_lights[i].fx,"tag_origin");
}
}

zapper_light_green( lightname )
{
zapper_lights = getentarray( lightname, "targetname");
for(i=0;i<zapper_lights.size;i++)
{
zapper_lights[i] setmodel("zombie_zapper_cagelight_green");

if(isDefined(zapper_lights[i].fx))
{
zapper_lights[i].fx delete();
}

zapper_lights[i].fx = maps\_zombiemode_net::network_safe_spawn( "trap_light_green", 2, "script_model", zapper_lights[i].origin );
zapper_lights[i].fx setmodel("tag_origin");
zapper_lights[i].fx.angles = zapper_lights[i].angles+(-90,0,0);
playfxontag(level._effect["zapper_light_ready"],zapper_lights[i].fx,"tag_origin");
}
}

electroctute_death_fx()
{
self endon( "death" );

if (isdefined(self.is_electrocuted) && self.is_electrocuted )
{
return;
}

self.is_electrocuted = true;

self thread electrocute_timeout();

// JamesS - this will darken the burning body
self StartTanning();

if(self.team == "axis")
{
level.bcOnFireTime = gettime();
level.bcOnFireOrg = self.origin;
}

PlayFxOnTag( level._effect["elec_torso"], self, "J_SpineLower" );
self playsound ("elec_jib_zombie");
wait 1;

tagArray = [];
tagArray[0] = "J_Elbow_LE";
tagArray[1] = "J_Elbow_RI";
tagArray[2] = "J_Knee_RI";
tagArray[3] = "J_Knee_LE";
tagArray = array_randomize( tagArray );

PlayFxOnTag( level._effect["elec_md"], self, tagArray[0] );
self playsound ("elec_jib_zombie");

wait 1;
self playsound ("elec_jib_zombie");

tagArray[0] = "J_Wrist_RI";
tagArray[1] = "J_Wrist_LE";
if( !IsDefined( self.a.gib_ref ) || self.a.gib_ref != "no_legs" )
{
tagArray[2] = "J_Ankle_RI";
tagArray[3] = "J_Ankle_LE";
}
tagArray = array_randomize( tagArray );

PlayFxOnTag( level._effect["elec_sm"], self, tagArray[0] );
PlayFxOnTag( level._effect["elec_sm"], self, tagArray[1] );
}

electrocute_timeout()
{
self endon ("death");
self playloopsound("fire_manager_0");
// about the length of the flame fx
wait 12;
self stoploopsound();
if (isdefined(self) && isalive(self))
{
self.is_electrocuted = false;
self notify ("stop_flame_damage");
}
}

/***********************************************************************
    ELECTRIC SWITCH STUFF
***********************************************************************/

power_electric_switch()
{
trig = getent("use_power_switch","targetname");
master_switch = getent("power_switch","targetname");
master_switch notsolid();
trig sethintstring(&"ZOMBIE_ELECTRIC_SWITCH");

cheat = false;

/#
if( GetDvarInt( "zombie_cheat" ) >= 3 )
{
wait( 5 );
cheat = true;
}
#/

user = undefined;
if ( cheat != true )
{
trig waittill("trigger",user);
}

master_switch rotateroll(-90,.3);

//TO DO (TUEY) - kick off a 'switch' on client script here that operates similiarly to Berlin2 subway.
master_switch playsound("switch_flip");

power_electric_switch_on();

playfx(level._effect["switch_sparks"] ,getstruct("power_switch_fx","targetname").origin);

trig delete();
}

power_electric_switch_on()
{
flag_set( "electricity_on" );
wait_network_frame();
clientnotify( "revive_on" );
wait_network_frame();
clientnotify( "fast_reload_on" );
wait_network_frame();
clientnotify( "doubletap_on" );
wait_network_frame();
clientnotify( "jugger_on" );
wait_network_frame();
level notify( "sleight_on" );
wait_network_frame();
level notify( "revive_on" );
wait_network_frame();
level notify( "doubletap_on" );
wait_network_frame();
level notify( "juggernog_on" );
wait_network_frame();
level notify( "Pack_A_Punch_on" );
wait_network_frame();
level notify( "specialty_armorvest_power_on" );
wait_network_frame();
level notify( "specialty_rof_power_on" );
wait_network_frame();
level notify( "specialty_quickrevive_power_on" );
wait_network_frame();
level notify( "specialty_fastreload_power_on" );
wait_network_frame();

ClientNotify( "pl1" ); // power lights on
exploder(600);

// Don't want east or west to spawn when in south zone, but vice versa is okay
//maps\_zombiemode_zone_manager::connect_zones( "outside_east_zone", "outside_south_zone" );
//maps\_zombiemode_zone_manager::connect_zones( "outside_west_zone", "outside_south_zone", true );
}

/***********************************************************************
    BRIDGE STUFF
***********************************************************************/

bridge_init()
{
flag_init( "bridge_down" );
// raise bridge
wnuen_bridge = getent( "wnuen_bridge", "targetname" );
wnuen_bridge_coils = GetEntArray( "wnuen_bridge_coils", "targetname" );
for ( i=0; i<wnuen_bridge_coils.size; i++ )
{
wnuen_bridge_coils[i] LinkTo( wnuen_bridge );
}
wnuen_bridge rotatepitch( 90, 1, .5, .5 );

warehouse_bridge = getent( "warehouse_bridge", "targetname" );
warehouse_bridge_coils = GetEntArray( "warehouse_bridge_coils", "targetname" );
for ( i=0; i<warehouse_bridge_coils.size; i++ )
{
warehouse_bridge_coils[i] LinkTo( warehouse_bridge );
}
warehouse_bridge rotatepitch( -90, 1, .5, .5 );

bridge_audio = getent( "bridge_audio", "targetname" );

// wait for power
flag_wait( "electricity_on" );

// lower bridge
wnuen_bridge rotatepitch( -90, 4, .5, 1.5 );
warehouse_bridge rotatepitch( 90, 4, .5, 1.5 );

if(isdefined( bridge_audio ) )
playsoundatposition( "bridge_lower", bridge_audio.origin );

wnuen_bridge connectpaths();
warehouse_bridge connectpaths();

exploder( 500 );

// wait until the bridges are down.
wnuen_bridge waittill( "rotatedone" );

flag_set( "bridge_down" );
if(isdefined( bridge_audio ) )
playsoundatposition( "bridge_hit", bridge_audio.origin );

wnuen_bridge_clip = getent( "wnuen_bridge_clip", "targetname" );
wnuen_bridge_clip delete();

warehouse_bridge_clip = getent( "warehouse_bridge_clip", "targetname" );
warehouse_bridge_clip delete();

//maps\_zombiemode_zone_manager::connect_zones( "wnuen_bridge_zone", "bridge_zone" );
//maps\_zombiemode_zone_manager::connect_zones( "warehouse_top_zone", "bridge_zone" );
}

jump_from_bridge()
{
trig = GetEnt( "trig_outside_south_zone", "targetname" );

if( isDefined( trig ) )
{
trig waittill( "trigger" );
}

//maps\_zombiemode_zone_manager::connect_zones( "outside_south_zone", "bridge_zone", true );
//maps\_zombiemode_zone_manager::connect_zones( "outside_south_zone", "wnuen_bridge_zone", true );
}

/***********************************************************************
    AUDIO STUFF
***********************************************************************/

perkMachineRattles()
{
// Check under the machines for change
trigs = GetEntArray( "audio_bump_trigger", "targetname" );

for ( i=0; i<trigs.size; i++ )
{
if ( IsDefined(trigs[i].script_sound) && trigs[i].script_sound == "perks_rattle" )
{
trigs[i] thread check_for_change();
}
}
}

mapStartAudio()
{
players = get_players();

for( i = 0; i < players.size; i++ )
{
players[i] thread player_killstreak_timer();
players[i] thread player_zombie_awareness();
}

players[randomint(players.size)] thread level_start_vox(); //Plays a "Power's Out" Message from a random player at start
}

player_zombie_awareness()
{
self endon("disconnect");
self endon("death");
players = getplayers();
index = maps\_zombiemode_weapons::get_player_index(self);
while(1)
{
wait(1);
//zombie = get_closest_ai(self.origin,"axis");

zombs = getaiarray("axis");
for(i=0;i<zombs.size;i++)
{
if(DistanceSquared(zombs[i].origin, self.origin) < 200 * 200)
{
if(!isDefined(zombs[i]))
{
continue;
}

dist = 200;
switch(zombs[i].zombie_move_speed)
{
case "walk": dist = 200;break;
case "run": dist = 250; break;
case "sprint": dist = 275;break;
}
if(distance2d(zombs[i].origin,self.origin) < dist)
{
yaw = self animscripts\utility::GetYawToSpot(zombs[i].origin );
//check to see if he's actually behind the player
if(yaw < -95 || yaw > 95)
{
zombs[i] playsound ("behind_vocals");
}
}
}
}
if(players.size > 1)
{
//Plays 'teamwork' style dialog if there are more than 1 player...
close_zombs = 0;
for(i=0;i<zombs.size;i++)
{
if(DistanceSquared(zombs[i].origin, self.origin) < 250 * 250)
{
close_zombs ++;
}
}
if(close_zombs > 4)
{
if(randomintrange(0,20) < 5)
{
plr = "plr_" + index + "_";
self thread create_and_play_dialog( plr, "vox_oh_shit", .25, "resp_ohshit" );
}
}
}
}
}

level_start_vox()
{
index = maps\_zombiemode_weapons::get_player_index( self );
plr = "plr_" + index + "_";
wait( 6 );
self thread create_and_play_dialog( plr, "vox_level_start", 0.25 );
}

check_for_change()
{
while (1)
{
self waittill( "trigger", player );

if ( player GetStance() == "prone" )
{
player maps\_zombiemode_score::add_to_player_score( 100 );
play_sound_at_pos( "purchase", player.origin );
break;
}
}
}

/***********************************************************************
    WEAPON STUFF
***********************************************************************/



magic_box_init()
{
level.open_chest_location = [];

for( x = 0 ; x < level.DLC3.PandoraBoxes.size ; x++ )
{
level.open_chest_location[ x ] = level.DLC3.PandoraBoxes[ x ];
}
}

factory_ray_gun_weighting_func()
{
if( level.box_moved == true )
{
num_to_add = 1;
// increase the percentage of ray gun
if( isDefined( level.pulls_since_last_ray_gun ) )
{
// after 12 pulls the ray gun percentage increases to 15%
if( level.pulls_since_last_ray_gun > 11 )
{
num_to_add += int(level.zombie_include_weapons.size*0.1);
}
// after 8 pulls the Ray Gun percentage increases to 10%
else if( level.pulls_since_last_ray_gun > 7 )
{
num_to_add += int(.05 * level.zombie_include_weapons.size);
}
}
return num_to_add;
}
else
{
return 0;
}
}

factory_cymbal_monkey_weighting_func()
{
players = get_players();
count = 0;
for( i = 0; i < players.size; i++ )
{
if( players[i] maps\_zombiemode_weapons::has_weapon_or_upgrade( "zombie_cymbal_monkey" ) )
{
count++;
}
}
if ( count > 0 )
{
return 1;
}
else
{
if( level.round_number < 10 )
{
return 3;
}
else
{
return 5;
}
}
}

/***********************************************************************
    ZOMBIE STUFF
***********************************************************************/

#using_animtree( "zombie_factory" );
script_anims_init()
{
level.scr_anim[ "half_gate" ] = %o_zombie_lattice_gate_half;
level.scr_anim[ "full_gate" ] = %o_zombie_lattice_gate_full;
level.scr_anim[ "difference_engine" ] = %o_zombie_difference_engine_ani;

level.blocker_anim_func = ::factory_playanim;
}

factory_playanim( animname )
{
self UseAnimTree(#animtree);
self animscripted("door_anim", self.origin, self.angles, level.scr_anim[animname] );
}

lock_additional_player_spawner()
{

spawn_points = getentarray("player_respawn_point", "targetname");
for( i = 0; i < spawn_points.size; i++ )
{

spawn_points[i].locked = true;
}
}

#using_animtree( "generic_human" );
anim_override_func()
{
level._zombie_melee[0] = %ai_zombie_attack_forward_v1;
level._zombie_melee[1] = %ai_zombie_attack_forward_v2;
level._zombie_melee[2] = %ai_zombie_attack_v1;
level._zombie_melee[3] = %ai_zombie_attack_v2;
level._zombie_melee[4] = %ai_zombie_attack_v1;
level._zombie_melee[5] = %ai_zombie_attack_v4;
level._zombie_melee[6] = %ai_zombie_attack_v6;

level._zombie_run_melee[0] = %ai_zombie_run_attack_v1;
level._zombie_run_melee[1] = %ai_zombie_run_attack_v2;
level._zombie_run_melee[2] = %ai_zombie_run_attack_v3;

level.scr_anim["zombie"]["run4"] = %ai_zombie_run_v2;
level.scr_anim["zombie"]["run5"] = %ai_zombie_run_v4;
level.scr_anim["zombie"]["run6"] = %ai_zombie_run_v3;

level.scr_anim["zombie"]["walk5"] = %ai_zombie_walk_v6;
level.scr_anim["zombie"]["walk6"] = %ai_zombie_walk_v7;
level.scr_anim["zombie"]["walk7"] = %ai_zombie_walk_v8;
level.scr_anim["zombie"]["walk8"] = %ai_zombie_walk_v9;
}

/***********************************************************************
    HELP CENTER STUFF
***********************************************************************/

//UGX Notes: Moved to an external file.

/***********************************************************************
    MISC STUFF
***********************************************************************/

player_Snow()
{
players = get_players();
array_thread( players, ::_player_Snow );
}

_player_Snow()
{
self endon("death");
self endon("disconnect");

for (;;)
{
playfx ( level._effect["snow_thick"], self.origin + (0,0,0));
wait (0.2);
}
}

extra_events()
{
self UseTriggerRequireLookAt();
self SetCursorHint( "HINT_NOICON" );
self waittill( "trigger" );

targ = GetEnt( self.target, "targetname" );
if ( IsDefined(targ) )
{
targ MoveZ( -10, 5 );
}
}

#using_animtree( "generic_human" );
force_zombie_crawler()
{
if( !IsDefined( self ) )
{
return;
}

if( !self.gibbed )
{
refs = [];

refs[refs.size] = "no_legs";

if( refs.size )
{
self.a.gib_ref = animscripts\death::get_random( refs );

// Don't stand if a leg is gone
self.has_legs = false;
self AllowedStances( "crouch" );

which_anim = RandomInt( 5 );

if( which_anim == 0 )
{
self.deathanim = %ai_zombie_crawl_death_v1;
self set_run_anim( "death3" );
self.run_combatanim = level.scr_anim["zombie"]["crawl1"];
self.crouchRunAnim = level.scr_anim["zombie"]["crawl1"];
self.crouchrun_combatanim = level.scr_anim["zombie"]["crawl1"];
}
else if( which_anim == 1 )
{
self.deathanim = %ai_zombie_crawl_death_v2;
self set_run_anim( "death4" );
self.run_combatanim = level.scr_anim["zombie"]["crawl2"];
self.crouchRunAnim = level.scr_anim["zombie"]["crawl2"];
self.crouchrun_combatanim = level.scr_anim["zombie"]["crawl2"];
}
else if( which_anim == 2 )
{
self.deathanim = %ai_zombie_crawl_death_v1;
self set_run_anim( "death3" );
self.run_combatanim = level.scr_anim["zombie"]["crawl3"];
self.crouchRunAnim = level.scr_anim["zombie"]["crawl3"];
self.crouchrun_combatanim = level.scr_anim["zombie"]["crawl3"];
}
else if( which_anim == 3 )
{
self.deathanim = %ai_zombie_crawl_death_v2;
self set_run_anim( "death4" );
self.run_combatanim = level.scr_anim["zombie"]["crawl4"];
self.crouchRunAnim = level.scr_anim["zombie"]["crawl4"];
self.crouchrun_combatanim = level.scr_anim["zombie"]["crawl4"];
}
else if( which_anim == 4 )
{
self.deathanim = %ai_zombie_crawl_death_v1;
self set_run_anim( "death3" );
self.run_combatanim = level.scr_anim["zombie"]["crawl5"];
self.crouchRunAnim = level.scr_anim["zombie"]["crawl5"];
self.crouchrun_combatanim = level.scr_anim["zombie"]["crawl5"];
}
}

if( self.health > 50 )
{
self.health = 50;

// force gibbing if the zombie is still alive
self thread animscripts\death::do_gib();
}
}
}
10 years ago

But got a free Verizon ellipsis 7 and new droid mini
:D
10 years ago

1st add this to your mov.csv in the mod builder tab
Code Snippet
Plaintext
menufile,ui/MAPNAMEHERE.menu
replace mapnamehere with your map name EX: my undead town would be undead_town

2nd download this
rename it to your mapname.menu and add it to raw/ui

3rdopen the file and search for MAPNAMEHERE (line 457)
so this line
Code Snippet
Plaintext
CHOICE_BUTTON_VIS( 1, "Fight alone", exec "map MAPNAMEHERE"; , when( !localvarBool( ui_hideBack ) ); )
replace mapnamehere with your map name

EX: my undead town would be undead_town
Or if your .ff file is named nazi_zombie_NAMEHERE. Then it would be exec "map nazi_zombie_MAPNAMEHERE"

save compile mod.ff done


Edit: you can change Fight Alone to whatever you want.
10 years ago
so DualVII, Gregster33 and another buddy upyourshaft tested my origins map today everything was fine.... but we were all invisible to eachother. does anyone know why this would happen? it made reviving very difficult. it seems like a 3rd person error.

10 years ago

Yes I am back, working slowly but working , I'll update soon.



Origins Nov, 1922

Afew years after the crew have their first encounter with the undead they come back to try and find out what started the outbreak. The robots have fallen, the generators powered down, tank broke down, but some things remained....

Some thing very nice thanks to Trem for scripting the Wunderfizz, Sajeone for anims, and my testing.
NEW VIDEO
WounderFizz on Origins (WaW Custom Zombies)

Here's some new images.












Thank you RedSpace


don't worrie I will be detailing the age in towards the end of mapping, as well as textures being changed.

Map Features

*All Origins Weapons but one
*1 WaW Weapon
*1 Buried Weapon
*Working Generators
*Origins Box
*Origins PaP
*Intense EE
*Origins Round Sounds
*Some Special Weapons ;)
*Zombie Counter
*Dig Sites
*Soul Chest .... with a twist
More to come!

Keep an eye out.  :D

Mapping
43%

Much needed update .... tank station 80% done




WE HAVE A NEW FRIEND!!!


Credit's
 ME lol--- (Mapping, putting it all together)
 DualVII--- (scripting, build-ables script, pre-alpha testing).....MIA
 treminaor--- (Wunderfizz, scripting, and tons more)
 Gregster33--- (pre-alpha testing, future mapping help{ill need it lol})
 Upyourshaft--- (pre-alpha testing)
 Redspace200--- (Origins Box scripting and pre-alpha testing)
 BluntStuffy--- (Generators scripts, Soul Chest scripts, Challenge System, Zombie Blood)
 Lukkie1998--- (some sounds)
 Tom_BMX--- (tools thank you!)
 BlackJackJonny--- (all your youtube tuts)
 AwesomePieMan---(Panzer, Scripts, and FX on the Staff's)
10 years ago
hey guys I have a very huge project I plan on working on .... but I don't want t start because radiant crashes on save/auto-save every damn time. anyone know what I can do .....

BTW I get no error or error report and its boggling my head , it worked fine a month ago
10 years ago
anyone have a detailed idea on what to do about this ?



im so damn lost and soooo close.
10 years ago
This map can be downloaded from the UGX Map Manager.




Update Log 1.3
 - Fixed a number of spots where you could get out of the map. Update is live on the Manager.


Update Log 1.2
*fixed buyable ending price
*added a gun.....
*moved the 3 teddys for the Thompson
*clipped some buyable debris
*a few other things I can not remember sorry


Update Log 1.1
*Pathing issues fixed (thank you Saje)
*Added collison to a few items
*Packaged correctly lol sorry that was a epic fail
*All weapons other then WaW weapons fixed to there default ZOMBIE stats
*Prices lowered on BO guns
*JukeBox working
*Fixed a door the was visible through a wall


Special Thanks to DualVII for a major potential infinite loop fix THANK YOU

Thanks to Trem map is back on track should be out soon!!!! :D

hey guys iv been working on a new map (lost my files to the first) but here we go
The setting is a small town out side of The Factory in the mountians. In 1946. You must fight your way threw the hordes to buy a ticket to leave the mountian inclosed town, with the help of the perks and PAP. The only problem is the conductor is a greedy old fool that has a high price set on his tickets. Can you survive long enough to make the money needed?

Things map has
* Challenging Map
* buildable ending (DualVII)
* multiple power switches (DualVII)
* zombie counter
* Custom Load Screen - Thanks to HexZombies
* 10 perks with BO2 shaders - Thanks to Bamskater, JR-Imagine, ZK
* Soul chest - Thank you BluntStuffy
* Dig Sites - Thank you again BluntStuffy lol
* UGX-jukebox - Thank you UGX
* hidden guns, and a hidden Tompson for Spiderbite
* customized guns- Thanks to the UGX Weapon Editor
* PAP
* Achievements - Thanks to Don Goony
* Unsure of train ending (don't want to copy others) ;)
* no-dogs :'( lol
* custom textures
* custom fx
* buyable ending Thanks TOM_BMX
* and other things stil coming


Big Help
Trem,GrantDaddy,Codmoddd1234,all of UGX team. damn it I guess Treyarch
HexZombies - for the loadscreen Thanks man
ZK - Thank you. You know why.
RedSpace200 - for a custom weapon script
Zombie Madness - for .... weapons and anims
Lukkie1998 for weapon help and other things



Images





Good Luck Spider!





Thank you BluntStuffy







Beta Testers:
DualVII
SajeOne
GrantDaddy
Gregsta33
BluntStuffy
Alerion
Zombie Madness
Lukkie1998
Me

If I missed anyone for any credit pm me [/font]
11 years ago
Can Aiden remake or someone make the full tutorial on how to disable the console for maps ...

http://www.zombiemodding.com/index.php?topic=1931.0

this one is a fail as he says in the OP at the bottom
11 years ago
Loading ...