UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: madsniper124 on March 30, 2016, 12:58:27 am

Title: Certain Prefabs Cause Script Runtime Error?
Post by: madsniper124 on March 30, 2016, 12:58:27 am
Hi, I'm new to mapping and I am currently working on my first map. However, I wanted to add in the springfield using the prefab weapon_upgrade_springfield but I receive a script runtime error. Any way to fix this?
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: DidUknowiPwn on March 30, 2016, 05:43:32 pm
What's the error specifically state?
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: Harry Bo21 on March 30, 2016, 05:59:06 pm
What's the error specifically state?
most likely that springfield is unknown item coz hes in devmode

some copies of the mod tools include it in dlc3.csv, some dont
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: madsniper124 on March 30, 2016, 07:13:02 pm
most likely that springfield is unknown item coz hes in devmode

some copies of the mod tools include it in dlc3.csv, some dont

How would I fix this? Should I simply download another copy of the mod tools and install it?
Thanks.

Double Post Merge: March 30, 2016, 11:24:10 pm
What's the error specifically state?

It says that "undefined is not a field object."
Here is the console log if it helps.
(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FPuWcMek.png&hash=9616870ae21fe9dc383ef6cb07dc1f524d58a82e)
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: daedra descent on March 31, 2016, 01:17:55 pm
Its trying to get the hintstring of the weapon but it doesn't exist. My guess is that in the _zombiemode_weapons include_weapons function, the hint isn't being passed correctly.

Mind posting the contents of include_weapons in _zombiemode_weapons and what weapon your trying to add?
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: DidUknowiPwn on March 31, 2016, 01:21:00 pm
Make a new line for it in add_zombie_weapon in _zombiemode_weapons
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: madsniper124 on March 31, 2016, 08:05:51 pm
Its trying to get the hintstring of the weapon but it doesn't exist. My guess is that in the _zombiemode_weapons include_weapons function, the hint isn't being passed correctly.

Mind posting the contents of include_weapons in _zombiemode_weapons and what weapon your trying to add?

Here is the code. I've been trying to add in the springfield and I also think that the sawed double barrel gives that error too.
Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

init()
{
init_weapons();
init_weapon_upgrade();
init_pay_turret();
init_weapon_cabinet();
treasure_chest_init();
level thread add_limited_tesla_gun();
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()
{
// Pistols
add_zombie_weapon( "colt", &"ZOMBIE_WEAPON_COLT_50", 50, "vox_crappy", 8 );
add_zombie_weapon( "colt_dirty_harry", &"ZOMBIE_WEAPON_COLT_DH_100", 100, "vox_357", 5 );
add_zombie_weapon( "nambu", &"ZOMBIE_WEAPON_NAMBU_50", 50, "vox_crappy", 8 );
add_zombie_weapon( "sw_357", &"ZOMBIE_WEAPON_SW357_100", 100, "vox_357", 5 );
add_zombie_weapon( "zombie_sw_357", &"ZOMBIE_WEAPON_SW357_100", 100, "vox_357", 5 );
add_zombie_weapon( "zombie_sw_357_upgraded", &"ZOMBIE_WEAPON_SW357_100", 100, "vox_357", 5 );
add_zombie_weapon( "tokarev", &"ZOMBIE_WEAPON_TOKAREV_50", 50, "vox_crappy", 8 );
add_zombie_weapon( "walther", &"ZOMBIE_WEAPON_WALTHER_50", 50, "vox_crappy", 8 );
add_zombie_weapon( "zombie_colt", &"ZOMBIE_WEAPON_ZOMBIECOLT_25", 25, "vox_crappy", 8 );
add_zombie_weapon( "zombie_colt_upgraded", &"ZOMBIE_WEAPON_ZOMBIECOLT_25", 25, "vox_crappy", 8 );

// Bolt Action                                     
add_zombie_weapon( "kar98k", &"ZOMBIE_WEAPON_KAR98K_200", 200, "", 0);
add_zombie_weapon( "zombie_kar98k", &"ZOMBIE_WEAPON_KAR98K_200", 200, "", 0);
add_zombie_weapon( "zombie_kar98k_upgraded", &"ZOMBIE_WEAPON_KAR98K_200", 200, "", 0);
add_zombie_weapon( "kar98k_bayonet", &"ZOMBIE_WEAPON_KAR98K_B_200", 200, "", 0);
add_zombie_weapon( "mosin_rifle", &"ZOMBIE_WEAPON_MOSIN_200", 200, "", 0);
add_zombie_weapon( "mosin_rifle_bayonet", &"ZOMBIE_WEAPON_MOSIN_B_200", 200, "", 0 );
add_zombie_weapon( "springfield", &"ZOMBIE_WEAPON_SPRINGFIELD_200", 200, "", 0 );
add_zombie_weapon( "zombie_springfield", &"ZOMBIE_WEAPON_SPRINGFIELD_200", 200, "", 0 );
add_zombie_weapon( "springfield_bayonet", &"ZOMBIE_WEAPON_SPRINGFIELD_B_200", 200, "", 0 );
add_zombie_weapon( "zombie_type99_rifle", &"ZOMBIE_WEAPON_TYPE99_200", 200, "", 0 );
add_zombie_weapon( "zombie_type99_rifle_upgraded", &"ZOMBIE_WEAPON_TYPE99_200", 200, "", 0 );
add_zombie_weapon( "type99_rifle_bayonet", &"ZOMBIE_WEAPON_TYPE99_B_200", 200, "", 0 );

// Semi Auto                                       
add_zombie_weapon( "zombie_gewehr43", &"ZOMBIE_WEAPON_GEWEHR43_600", 600, "" , 0 );
add_zombie_weapon( "zombie_gewehr43_upgraded", &"ZOMBIE_WEAPON_GEWEHR43_600", 600, "" , 0 );
add_zombie_weapon( "zombie_m1carbine", &"ZOMBIE_WEAPON_M1CARBINE_600", 600, "" , 0 );
add_zombie_weapon( "zombie_m1carbine_upgraded", &"ZOMBIE_WEAPON_M1CARBINE_600", 600, "" , 0 );
add_zombie_weapon( "m1carbine_bayonet", &"ZOMBIE_WEAPON_M1CARBINE_B_600", 600, "" , 0 );
add_zombie_weapon( "zombie_m1garand", &"ZOMBIE_WEAPON_M1GARAND_600", 600, "" , 0 );
add_zombie_weapon( "zombie_m1garand_upgraded", &"ZOMBIE_WEAPON_M1GARAND_600", 600, "" , 0 );
add_zombie_weapon( "m1garand_bayonet", &"ZOMBIE_WEAPON_M1GARAND_B_600", 600, "" , 0 );
add_zombie_weapon( "svt40", &"ZOMBIE_WEAPON_SVT40_600", 600, "" , 0 );

// Grenades                                         
add_zombie_weapon( "fraggrenade", &"ZOMBIE_WEAPON_FRAGGRENADE_250", 250, "" , 0 );
add_zombie_weapon( "molotov", &"ZOMBIE_WEAPON_MOLOTOV_200", 200, "vox_crappy", 8 );
add_zombie_weapon( "molotov_zombie", &"ZOMBIE_WEAPON_MOLOTOV_200", 200, "vox_crappy", 8 );
add_zombie_weapon( "stick_grenade", &"ZOMBIE_WEAPON_STICKGRENADE_250", 250, "" , 0 );
add_zombie_weapon( "stielhandgranate", &"ZOMBIE_WEAPON_STIELHANDGRANATE_250", 250, "" , 0, 250 );
add_zombie_weapon( "type97_frag", &"ZOMBIE_WEAPON_TYPE97FRAG_250", 250, "" , 0 );

// Scoped
add_zombie_weapon( "kar98k_scoped_zombie", &"ZOMBIE_WEAPON_KAR98K_S_750", 750, "vox_ppsh", 5);
add_zombie_weapon( "kar98k_scoped_bayonet_zombie", &"ZOMBIE_WEAPON_KAR98K_S_B_750", 750, "vox_ppsh", 5);
add_zombie_weapon( "mosin_rifle_scoped_zombie", &"ZOMBIE_WEAPON_MOSIN_S_750", 750, "vox_ppsh", 5);
add_zombie_weapon( "mosin_rifle_scoped_bayonet_zombie", &"ZOMBIE_WEAPON_MOSIN_S_B_750", 750, "vox_ppsh", 5);
add_zombie_weapon( "ptrs41_zombie", &"ZOMBIE_WEAPON_PTRS41_750", 750, "vox_ppsh", 5);
add_zombie_weapon( "ptrs41_zombie_upgraded", &"ZOMBIE_WEAPON_PTRS41_750", 750, "vox_ppsh", 5);
add_zombie_weapon( "springfield_scoped_zombie", &"ZOMBIE_WEAPON_SPRINGFIELD_S_750", 750, "vox_ppsh", 5);
add_zombie_weapon( "springfield_scoped_bayonet_zombie", &"ZOMBIE_WEAPON_SPRINGFIELD_S_B_750", 750, "vox_ppsh", 5);
add_zombie_weapon( "type99_rifle_scoped_zombie", &"ZOMBIE_WEAPON_TYPE99_S_750", 750, "vox_ppsh", 5);
add_zombie_weapon( "type99_rifle_scoped_bayonet_zombie", &"ZOMBIE_WEAPON_TYPE99_S_B_750", 750, "vox_ppsh", 5);

// Full Auto                                                                               
add_zombie_weapon( "zombie_mp40", &"ZOMBIE_WEAPON_MP40_1000", 1000, "vox_mp40", 2 );
add_zombie_weapon( "zombie_mp40_upgraded", &"ZOMBIE_WEAPON_MP40_1000", 1000, "vox_mp40", 2 );
add_zombie_weapon( "zombie_ppsh", &"ZOMBIE_WEAPON_PPSH_2000", 2000, "vox_ppsh", 5 );
add_zombie_weapon( "zombie_ppsh_upgraded", &"ZOMBIE_WEAPON_PPSH_2000", 2000, "vox_ppsh", 5 );
add_zombie_weapon( "zombie_stg44", &"ZOMBIE_WEAPON_STG44_1200", 1200, "vox_mg", 9 );
add_zombie_weapon( "zombie_stg44_upgraded", &"ZOMBIE_WEAPON_STG44_1200", 1200, "vox_mg", 9 );
add_zombie_weapon( "zombie_thompson", &"ZOMBIE_WEAPON_THOMPSON_1200", 1200, "", 0 );
add_zombie_weapon( "zombie_thompson_upgraded", &"ZOMBIE_WEAPON_THOMPSON_1200", 1200, "", 0 );
add_zombie_weapon( "zombie_type100_smg", &"ZOMBIE_WEAPON_TYPE100_1000", 1000, "", 0 );
add_zombie_weapon( "zombie_type100_smg_upgraded", &"ZOMBIE_WEAPON_TYPE100_1000", 1000, "", 0 );

// Shotguns                                         
add_zombie_weapon( "zombie_doublebarrel", &"ZOMBIE_WEAPON_DOUBLEBARREL_1200", 1200, "vox_shotgun", 6);
add_zombie_weapon( "zombie_doublebarrel_upgraded", &"ZOMBIE_WEAPON_DOUBLEBARREL_1200", 1200, "vox_shotgun", 6);
add_zombie_weapon( "zombie_doublebarrel_sawed", &"ZOMBIE_WEAPON_DOUBLEBARREL_SAWED_1200", 1200, "vox_shotgun", 6);
add_zombie_weapon( "zombie_doublebarrel_sawed_upgraded", &"ZOMBIE_WEAPON_DOUBLEBARREL_SAWED_1200", 1200, "vox_shotgun", 6);
add_zombie_weapon( "zombie_shotgun", &"ZOMBIE_WEAPON_SHOTGUN_1500", 1500, "vox_shotgun", 6);
add_zombie_weapon( "zombie_shotgun_upgraded", &"ZOMBIE_WEAPON_SHOTGUN_1500", 1500, "vox_shotgun", 6);

// Heavy Machineguns                               
add_zombie_weapon( "zombie_30cal", &"ZOMBIE_WEAPON_30CAL_3000", 3000, "vox_mg", 9 );
add_zombie_weapon( "zombie_30cal_upgraded", &"ZOMBIE_WEAPON_30CAL_3000", 3000, "vox_mg", 9 );
add_zombie_weapon( "zombie_bar", &"ZOMBIE_WEAPON_BAR_1800", 1800, "vox_bar", 5 );
add_zombie_weapon( "zombie_bar_upgraded", &"ZOMBIE_WEAPON_BAR_1800", 1800, "vox_bar", 5 );
add_zombie_weapon( "dp28", &"ZOMBIE_WEAPON_DP28_2250", 2250, "vox_mg" , 9 );
add_zombie_weapon( "zombie_fg42", &"ZOMBIE_WEAPON_FG42_1500", 1500, "vox_mg" , 9 );
add_zombie_weapon( "zombie_fg42_upgraded", &"ZOMBIE_WEAPON_FG42_1500", 1500, "vox_mg" , 9 );
add_zombie_weapon( "fg42_scoped", &"ZOMBIE_WEAPON_FG42_S_1500", 1500, "vox_mg" , 9 );
add_zombie_weapon( "zombie_mg42", &"ZOMBIE_WEAPON_MG42_3000", 3000, "vox_mg" , 9 );
add_zombie_weapon( "zombie_mg42_upgraded", &"ZOMBIE_WEAPON_MG42_3000", 3000, "vox_mg" , 9 );
add_zombie_weapon( "type99_lmg", &"ZOMBIE_WEAPON_TYPE99_LMG_1750", 1750, "vox_mg" , 9 );

// Grenade Launcher                                 
add_zombie_weapon( "m1garand_gl_zombie", &"ZOMBIE_WEAPON_M1GARAND_GL_1500", 1500, "", 0 );
add_zombie_weapon( "m1garand_gl_zombie_upgraded", &"ZOMBIE_WEAPON_M1GARAND_GL_1500", 1500, "", 0 );
add_zombie_weapon( "mosin_launcher_zombie", &"ZOMBIE_WEAPON_MOSIN_GL_1200", 1200, "", 0 );

// Bipods                               
add_zombie_weapon( "30cal_bipod", &"ZOMBIE_WEAPON_30CAL_BIPOD_3500", 3500, "vox_mg", 5 );
add_zombie_weapon( "bar_bipod", &"ZOMBIE_WEAPON_BAR_BIPOD_2500", 2500, "vox_bar", 5 );
add_zombie_weapon( "dp28_bipod", &"ZOMBIE_WEAPON_DP28_BIPOD_2500", 2500, "vox_mg", 5 );
add_zombie_weapon( "fg42_bipod", &"ZOMBIE_WEAPON_FG42_BIPOD_2000", 2000, "vox_mg", 5 );
add_zombie_weapon( "mg42_bipod", &"ZOMBIE_WEAPON_MG42_BIPOD_3250", 3250, "vox_mg", 5 );
add_zombie_weapon( "type99_lmg_bipod", &"ZOMBIE_WEAPON_TYPE99_LMG_BIPOD_2250", 2250, "vox_mg", 5 );

// Rocket Launchers
add_zombie_weapon( "bazooka", &"ZOMBIE_WEAPON_BAZOOKA_2000", 2000, "", 0 );
add_zombie_weapon( "panzerschrek_zombie", &"ZOMBIE_WEAPON_PANZERSCHREK_2000", 2000, "vox_panzer", 5 );
add_zombie_weapon( "panzerschrek_zombie_upgraded", &"ZOMBIE_WEAPON_PANZERSCHREK_2000", 2000, "vox_panzer", 5 );

// Flamethrower                                     
add_zombie_weapon( "m2_flamethrower_zombie", &"ZOMBIE_WEAPON_M2_FLAMETHROWER_3000", 3000, "vox_flame", 7);
add_zombie_weapon( "m2_flamethrower_zombie_upgraded", &"ZOMBIE_WEAPON_M2_FLAMETHROWER_3000", 3000, "vox_flame", 7);

// Special                                         
add_zombie_weapon( "mine_bouncing_betty", &"ZOMBIE_WEAPON_SATCHEL_2000", 2000, "" );
add_zombie_weapon( "mortar_round", &"ZOMBIE_WEAPON_MORTARROUND_2000", 2000, "" );
add_zombie_weapon( "satchel_charge", &"ZOMBIE_WEAPON_SATCHEL_2000", 2000, "vox_monkey", 3 );
add_zombie_weapon( "zombie_cymbal_monkey", &"ZOMBIE_WEAPON_SATCHEL_2000", 2000, "vox_monkey", 3 );
add_zombie_weapon( "ray_gun", &"ZOMBIE_WEAPON_RAYGUN_10000", 10000, "vox_raygun", 6 );
add_zombie_weapon( "ray_gun_upgraded", &"ZOMBIE_WEAPON_RAYGUN_10000", 10000, "vox_raygun", 6 );
add_zombie_weapon( "tesla_gun", &"ZOMBIE_BUY_TESLA", 10, "vox_tesla", 5 );
add_zombie_weapon( "tesla_gun_upgraded", &"ZOMBIE_BUY_TESLA", 10, "vox_tesla", 5 );

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

//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
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( hint_string );
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(level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory" || level.script == "nazi_zombie_coast")
{
// 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 );
}
}
}


}

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();
}
}

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("laugh_child");
}

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.script) && (level.script != "nazi_zombie_sumpf") && (level.script != "nazi_zombie_factory") && (level.script != "nazi_zombie_coast") )
{
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" );
}

treasure_chest_think()
{
cost = 950;
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 );

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

// make sure the user is a player, and that they can afford it
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;
}

wait 0.05;
}

// 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();

// 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"))
{
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" );

//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.script) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") && level.box_moved == true && isDefined(level.pulls_since_last_ray_gun) )
{
level.pulls_since_last_ray_gun += 1;
}

if( isDefined(level.script) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") && isDefined(level.pulls_since_last_tesla_gun) )
{
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 );

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

wait 3;
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");

players = get_players();

array_thread(players, ::play_crazi_sound);

level waittill("weapon_fly_away_end");

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;

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( level.script == "nazi_zombie_asylum" || level.script == "nazi_zombie_factory" || level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_paris" || level.script == "nazi_zombie_coast" || level.script == "nazi_zombie_theater" || level.script == "nazi_zombie_tunnel")
{
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.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 );
model.angles = self.angles +( 0, 90, 0 );

floatHeight = 40;

//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.script ) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") )
{
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 )
{
primaryWeapons = self GetWeaponsListPrimaries();
current_weapon = undefined;

if( self HasWeapon( weapon_string ) )
{
self GiveMaxAmmo( weapon_string );
self SwitchToWeapon( weapon_string );
return;
}

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

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

if( isdefined( current_weapon ) )
{
if( !( weapon_string == "fraggrenade" || weapon_string == "stielhandgranate" || weapon_string == "molotov" || weapon_string == "zombie_cymbal_monkey" ) )
{
// PI_CHANGE_BEGIN
// JMA - player dropped the tesla gun
if( isDefined(level.script) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") )
{
if( current_weapon == "tesla_gun" )
{
level.player_drops_tesla_gun = true;
}
}
// PI_CHANGE_END

self TakeWeapon( current_weapon );
}
}
}

if( IsDefined( primaryWeapons ) && !isDefined( current_weapon ) )
{
for( i = 0; i < primaryWeapons.size; i++ )
{
if( primaryWeapons[i] == "zombie_colt" )
{
continue;
}

if( weapon_string != "fraggrenade" && weapon_string != "stielhandgranate" && weapon_string != "molotov" && weapon_string != "zombie_cymbal_monkey" )
{
// PI_CHANGE_BEGIN
// JMA - player dropped the tesla gun
if( isDefined(level.script) && (level.script == "nazi_zombie_sumpf" || level.script == "nazi_zombie_factory") )
{
if( primaryWeapons[i] == "tesla_gun" )
{
level.player_drops_tesla_gun = true;
}
}
// PI_CHANGE_END

self TakeWeapon( primaryWeapons[i] );
}
}
}

self play_sound_on_ent( "purchase" );

if( weapon_string == "molotov" || weapon_string == "molotov_zombie" )
{
// PI_CHANGE_BEGIN
// JMA 051409 sanity check to see if we have the weapon before we remove it
has_weapon = self HasWeapon( "zombie_cymbal_monkey" );
if( isDefined(has_weapon) && has_weapon )
{
self TakeWeapon( "zombie_cymbal_monkey" );
}
// PI_CHANGE_END
}
if( weapon_string == "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_string);
return;
}

self GiveWeapon( weapon_string, 0 );
self GiveMaxAmmo( weapon_string );
self SwitchToWeapon( weapon_string );

play_weapon_vo(weapon_string);

// self playsound (level.zombie_weapons[weapon_string].sound);
}

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 );
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: Harry Bo21 on March 31, 2016, 09:03:00 pm
So I'll ask again then...

Is the gun actually "loaded"?

Ie, it's not in dlc3.csv by default most of the time, so it's assets and weapon file do not get loaded - which causes add_zombie_weapon to fail

Post you dlc3.csv, mapname.csv and mapname_patch.csv here - you will find them in root/zone_source
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: madsniper124 on March 31, 2016, 10:05:24 pm
So I'll ask again then...

Is the gun actually "loaded"?

Ie, it's not in dlc3.csv by default most of the time, so it's assets and weapon file do not get loaded - which causes add_zombie_weapon to fail

Post you dlc3.csv, mapname.csv and mapname_patch.csv here - you will find them in root/zone_source

Here you go.
dlc3.csv:
Code Snippet
Plaintext
ignore	code_post_gfx		
ignore common

// UGX Modder help
rawfile maps/ugx_modder_help.gsc

// for coop players
mptype nazi_zombie_heroes

rawfile maps/ugx_modder_help.gsc
rawfile maps/createfx/dlc3_fx.gsc
rawfile maps/dlc3_code.gsc
rawfile maps/dlc3_teleporter.gsc
rawfile clientscripts/createfx/dlc3_fx.csc
rawfile clientscripts/dlc3_code.csc
rawfile clientscripts/dlc3_teleporter.csc
rawfile clientscripts/_zombiemode_tesla.csc
rawfile clientscripts/_zombie_mode.csc

sound character nazi_zombie_factory all_sp
sound common nazi_zombie_factory all_sp
sound projectiles nazi_zombie_factory all_sp
sound physics nazi_zombie_factory all_sp
sound destructibles nazi_zombie_factory all_sp
sound nazi_zombie_factory nazi_zombie_factory all_sp
// dlc2 vox and shared csv
sound dlc3_vox nazi_zombie_factory all_sp
sound dlc_share nazi_zombie_factory all_sp
// for all weapon sounds
sound weapons audio_test_tuey all_sp

xmodel viewmodel_usa_marine_arms
xmodel viewmodel_usa_marine_player
xmodel viewmodel_knife_bowie

xanim ch_dazed_d_death
xanim ch_dazed_c_death
xanim ch_dazed_b_death
xanim ch_dazed_a_death
xanim ch_dazed_d
xanim ch_dazed_c
xanim ch_dazed_b
xanim ch_dazed_a

//PI ESM - added for bouncing betties
fx weapon/bouncing_betty/fx_explosion_betty_generic
fx weapon/bouncing_betty/fx_betty_trail

//ESM - added for electrical trap
fx misc/fx_zombie_electric_trap
fx env/electrical/fx_elec_sparking_oneshot
fx misc/fx_zombie_zapper_powerbox_on
fx misc/fx_zombie_zapper_wall_control_on
fx maps/zombie/fx_zombie_light_glow_green
fx maps/zombie/fx_zombie_light_glow_red
fx misc/fx_zombie_elec_trail_oneshot
fx env/electrical/fx_elec_wire_spark_dl_oneshot
fx env/electrical/fx_elec_player_md
fx env/electrical/fx_elec_player_sm
fx env/electrical/fx_elec_player_torso
fx misc/fx_zombie_elec_gen_on
fx misc/fx_zombie_elec_gen_idle
xmodel zombie_zapper_cagelight_red
xmodel zombie_zapper_cagelight_green

// PI ESM - added for PC running
//xmodel exploding_barrel_test_d
xmodel zombie_teddybear

// Swapping light models
xmodel lights_indlight
xmodel lights_indlight_on
xmodel lights_milit_lamp_single_int
xmodel lights_milit_lamp_single_int_on
xmodel lights_tinhatlamp_off
xmodel lights_tinhatlamp_on
xmodel lights_berlin_subway_hat_0
xmodel lights_berlin_subway_hat_50
xmodel lights_berlin_subway_hat_100

// WEAPONS

//Missing models
xmodel viewmodel_zombie_colt45_pistol
xmodel weapon_zombie_colt45_pistol
xmodel viewmodel_zombie_ptrs41
xmodel weapon_zombie_ptrs41
xmodel viewmodel_zombie_flamethrower
xmodel weapon_zombie_flamethrower

// grenades
//weapon sp/fraggrenade

// weapons
weapon "sp/colt // default weaponn"
weapon "sp/napalmblob // default weapon"
weapon "sp/napalmbloblight // default weapon"
"// - pistol"
weapon "sp/zombie_colt // last stand weapon"
weapon sp/zombie_colt_upgraded
weapon sp/zombie_sw_357
weapon sp/zombie_sw_357_upgraded
"// - bolt-action"
weapon sp/zombie_kar98k
weapon sp/zombie_kar98k_upgraded
//weapon sp/springfield
//weapon sp/zombie_type99_rifle
//weapon sp/zombie_type99_rifle_upgraded
"// - semi-auto"
weapon sp/zombie_m1carbine
weapon sp/zombie_m1carbine_upgraded
weapon sp/zombie_gewehr43
weapon sp/zombie_gewehr43_upgraded
weapon sp/zombie_m1garand
weapon sp/zombie_m1garand_upgraded
"// - auto"
weapon sp/zombie_stg44
weapon sp/zombie_stg44_upgraded
weapon sp/zombie_thompson
weapon sp/zombie_thompson_upgraded
weapon sp/zombie_mp40
weapon sp/zombie_mp40_upgraded
weapon sp/zombie_type100_smg
weapon sp/zombie_type100_smg_upgraded
"// - scoped"
weapon sp/ptrs41_zombie
weapon sp/ptrs41_zombie_upgraded
//weapon sp/type99_rifle_scoped_zombie
//weapon sp/kar98k_scoped_zombie
"// - grenade"
weapon sp/molotov
weapon sp/stielhandgranate
"// - grenade launcher"
weapon sp/m1garand_gl_zombie
weapon sp/m1garand_gl_zombie_upgraded
weapon sp/m7_launcher_zombie
weapon sp/m7_launcher_zombie_upgraded
"// - shotgun"
weapon sp/zombie_doublebarrel
weapon sp/zombie_doublebarrel_upgraded
weapon sp/zombie_shotgun
weapon sp/zombie_shotgun_upgraded
"// - heavy mg"
weapon sp/zombie_bar
weapon sp/zombie_bar_upgraded
weapon sp/zombie_fg42
weapon sp/zombie_fg42_upgraded
weapon sp/zombie_30cal
weapon sp/zombie_30cal_upgraded
weapon sp/zombie_mg42
weapon sp/zombie_mg42_upgraded
weapon sp/zombie_ppsh
weapon sp/zombie_ppsh_upgraded
"// - special"
weapon sp/panzerschrek_zombie
weapon sp/panzerschrek_zombie_upgraded
weapon sp/m2_flamethrower_zombie
weapon sp/m2_flamethrower_zombie_upgraded
weapon sp/ray_gun
weapon sp/ray_gun_upgraded
weapon sp/tesla_gun
weapon sp/tesla_gun_upgraded
weapon sp/zombie_cymbal_monkey
weapon sp/mine_bouncing_betty


// Scripted effects
fx env/dirt/fx_dust_ceiling_impact_lg_mdbrown
fx env/electrical/fx_elec_wire_spark_burst
fx misc/fx_zombie_couch_effect
fx destructibles/fx_dest_fire_vert
fx bio/player/fx_footstep_dust
fx bio/player/fx_footstep_water
fx bio/player/fx_footstep_sand
fx bio/player/fx_footstep_mud

fx weapon/bouncing_betty/fx_explosion_betty_generic
fx weapon/bouncing_betty/fx_betty_trail

// Exploding barrel effects
//fx destructibles/fx_barrelexp
//fx destructibles/fx_barrel_ignite
//fx destructibles/fx_barrel_fire_top

// Perks-a-cola effects
fx misc/fx_zombie_cola_on
fx misc/fx_zombie_cola_dtap_on
fx misc/fx_zombie_cola_jugg_on
fx misc/fx_zombie_cola_revive_on

// CreateFX effects
fx env/fire/fx_embers_falling_sm

fx maps/mp_maps/fx_mp_ray_moon_lg_1sd
fx maps/mp_maps/fx_mp_ray_fire_ribbon
fx maps/mp_maps/fx_mp_ray_fire_ribbon_med
fx maps/mp_maps/fx_mp_ray_moon_lg
fx maps/mp_maps/fx_mp_ray_moon_md
//fx maps/mp_maps/fx_mp_flare_med
//fx maps/mp_maps/fx_mp_flare_md
fx maps/mp_maps/fx_mp_ray_moon_sm
//fx maps/mp_maps/fx_mp_ray_moon_xsm

//fx maps/ber3/fx_tracers_flak88_amb

fx maps/mp_maps/fx_mp_ash_falling_large
//fx maps/mp_maps/fx_mp_battlesmoke_thin_lg
//fx maps/mp_maps/fx_mp_fire_150x150_tall_distant
//fx maps/mp_maps/fx_mp_fire_150x600_tall_distant
//fx maps/mp_maps/fx_mp_fire_column_lg
//fx maps/mp_maps/fx_mp_fire_rubble_detail_grp
//fx maps/mp_maps/fx_mp_fire_rubble_md_lowsmk
//fx maps/mp_maps/fx_mp_fire_rubble_md_smk
//fx maps/mp_maps/fx_mp_fire_rubble_small
//fx maps/mp_maps/fx_mp_fire_small_detail
//fx maps/mp_maps/fx_mp_fire_window
//fx maps/mp_maps/fx_mp_fire_window_smk_lf
//fx maps/mp_maps/fx_mp_fire_window_smk_rt
//fx maps/mp_maps/fx_mp_fire_furnace
//fx maps/mp_maps/fx_mp_flak_field
//fx maps/mp_maps/fx_mp_flak_field_flash
//fx maps/mp_maps/fx_mp_ray_fire_ribbon
//fx maps/mp_maps/fx_mp_ray_fire_thin
//fx maps/mp_maps/fx_mp_smoke_fire_column
//fx maps/mp_maps/fx_mp_smoke_hall
//fx maps/mp_maps/fx_mp_smoke_plume_lg
//fx maps/mp_maps/fx_mp_smoke_stack

fx maps/mp_maps/fx_mp_light_glow_indoor_short_loop
fx maps/mp_maps/fx_mp_light_glow_outdoor_long_loop
fx maps/mp_maps/fx_mp_insects_lantern
fx maps/mp_maps/fx_mp_light_lamp
fx maps/mp_maps/fx_mp_fire_torch_noglow
fx maps/zombie/fx_zombie_moon_eclipse
fx maps/zombie/fx_zombie_clock_hand
fx maps/mp_maps/fx_mp_elec_broken_light_1shot
fx "maps/mp_maps/fx_mp_light_lamp_no_eo "

fx maps/zombie/fx_zombie_packapunch


// CreateFX Exploders
fx maps/zombie/fx_transporter_beam
fx maps/zombie/fx_transporter_pad_start
fx maps/zombie/fx_transporter_start
fx maps/zombie/fx_transporter_ambient
fx maps/zombie/fx_zombie_wire_spark
fx maps/zombie/fx_zombie_mainframe_link_single
fx maps/zombie/fx_zombie_mainframe_link_all
fx maps/zombie/fx_zombie_mainframe_linked
fx maps/zombie/fx_zombie_mainframe_beam
fx maps/zombie/fx_zombie_mainframe_flat
fx maps/zombie/fx_zombie_mainframe_flat_start
fx maps/zombie/fx_zombie_mainframe_beam_start
fx maps/zombie/fx_zombie_flashback_american
fx maps/zombie/fx_zombie_difference
fx maps/zombie/fx_zombie_mainframe_steam
fx maps/zombie/fx_zombie_heat_sink
fx maps/mp_maps/fx_mp_elec_spark_fast_random
fx misc/fx_zombie_elec_gen_idle
fx maps/zombie/fx_zombie_elec_pole_terminal

// Fog Sky and vision
rawfile maps/createart/nazi_zombie_factory_art.gsc
rawfile vision/zombie_factory.vision

// Pandora Box
fx maps/zombie/fx_zombie_factory_marker
fx maps/zombie/fx_zombie_factory_marker_fl
fx maps/zombie/fx_zombie_factory_marker_sm

// dogs
fx maps/zombie/fx_zombie_dog_eyes
fx maps/zombie/fx_zombie_dog_explosion
fx maps/zombie/fx_zombie_dog_fire_trail
fx maps/zombie/fx_zombie_dog_ash_trail
fx maps/zombie/fx_zombie_dog_breath

// Teleporter
fx maps/zombie/fx_transporter_pad_start
fx maps/zombie/fx_transporter_start
fx maps/zombie/fx_transporter_beam

// Pause Screen Map
material menu_map_nazi_zombie_factory

// Animtrees
rawfile animtrees/zombie_factory.atr

// extra anims
xanim o_zombie_lattice_gate_full
xanim o_zombie_lattice_gate_half
xanim o_zombie_difference_engine_ani

xanim ai_zombie_jump_down_127
xanim ai_zombie_jump_down_184
xanim ai_zombie_crawl_jump_down_127
xanim ai_zombie_crawl_jump_down_184

My map .csv:
Code Snippet
Plaintext
// Ignores		
ignore code_post_gfx
ignore common

// DLC3 Stuff -- Leave This
include dlc3

// Screens

// Level BSP
col_map_sp maps/nazi_zombie_tunnel.d3dbsp

// Client Scripts
rawfile clientscripts/nazi_zombie_tunnel.csc
rawfile clientscripts/nazi_zombie_tunnel_amb.csc
rawfile clientscripts/createfx/nazi_zombie_tunnel_fx.csc

// Server Scripts
rawfile maps/nazi_zombie_tunnel.gsc
rawfile maps/createfx/nazi_zombie_tunnel_fx.gsc

// Fog Sky and Vision
rawfile maps/createart/nazi_zombie_tunnel_art.gsc
" // -- Keep This" But Can Change Values Inside File
rawfile vision/zombie_factory.vision

//////////////////////////////////////////////////////////////////
                           FX AREA
/////////////////////////////////////////////////////////////////

// Scripted Effects
fx env/dirt/fx_dust_ceiling_impact_lg_mdbrown
fx env/electrical/fx_elec_wire_spark_burst
fx misc/fx_zombie_couch_effect
fx destructibles/fx_dest_fire_vert
fx bio/player/fx_footstep_dust
fx bio/player/fx_footstep_water
fx bio/player/fx_footstep_sand
fx bio/player/fx_footstep_mud
fx env/weather/fx_snow_blizzard_intense


// CreateFX Effects
fx maps/mp_maps/fx_mp_ray_moon_lg_1sd
fx maps/mp_maps/fx_mp_ray_fire_ribbon
fx maps/mp_maps/fx_mp_ray_fire_ribbon_med
fx maps/mp_maps/fx_mp_ray_moon_lg
fx maps/mp_maps/fx_mp_ray_moon_md
fx maps/mp_maps/fx_mp_ray_moon_sm

fx maps/mp_maps/fx_mp_light_glow_indoor_short_loop
fx maps/mp_maps/fx_mp_light_glow_outdoor_long_loop
fx maps/mp_maps/fx_mp_insects_lantern
fx maps/mp_maps/fx_mp_light_lamp
fx maps/mp_maps/fx_mp_fire_torch_noglow
fx maps/zombie/fx_zombie_moon_eclipse
fx maps/zombie/fx_zombie_clock_hand
fx maps/mp_maps/fx_mp_elec_broken_light_1shot
fx maps/mp_maps/fx_mp_light_lamp_no_eo

My map patch .csv:
Code Snippet
Plaintext
// Materials		
material zombie_electric_shock_overlay
material zombie_transporter_overlay

// Scripts
rawfile animscripts/death.gsc
rawfile animscripts/melee.gsc
rawfile animscripts/scripted.gsc
rawfile animscripts/utility.gsc
rawfile animscripts/traverse/shared.gsc
rawfile animscripts/traverse/zombie_jump_down_72.gsc
rawfile animscripts/traverse/zombie_jump_down_96.gsc
rawfile animscripts/traverse/zombie_jump_down_120.gsc
rawfile animscripts/traverse/zombie_jump_down_127.gsc
rawfile animscripts/traverse/zombie_jump_down_184.gsc
rawfile animscripts/traverse/zombie_jump_down_190.gsc
rawfile animscripts/traverse/zombie_jump_up_to_climb.gsc
rawfile maps/_arcademode.gsc
rawfile maps/_audio.gsc
rawfile maps/_callbackglobal.gsc
rawfile maps/_challenges_coop.gsc
rawfile maps/_collectibles_game.gsc
rawfile maps/_friendlyfire.gsc
rawfile maps/_gameskill.gsc
rawfile maps/_laststand.gsc
rawfile maps/_load.gsc
rawfile maps/_loadout.gsc
rawfile maps/_mgturret.gsc
rawfile maps/_zombiemode.gsc
rawfile maps/_zombiemode_blockers_new.gsc
rawfile maps/_zombiemode_spawner.gsc
rawfile maps/_zombiemode_tesla.gsc
rawfile maps/_zombiemode_weapons.gsc
rawfile maps/_zombiemode_dogs.gsc

// Characters
rawfile mptype/nazi_zombie_heroes.gsc
rawfile character/char_zomb_player_0.gsc
rawfile character/char_zomb_player_1.gsc
rawfile character/char_zomb_player_2.gsc
rawfile character/char_zomb_player_3.gsc

// Dog Anim Scripts
rawfile animscripts/dog_combat.gsc
rawfile animscripts/dog_death.gsc
rawfile animscripts/dog_init.gsc
rawfile animscripts/dog_pain.gsc
rawfile animscripts/dog_move.gsc
rawfile animscripts/dog_scripted.gsc
rawfile animscripts/dog_stop.gsc
rawfile animscripts/dog_flashed.gsc

// Client Scripts
rawfile clientscripts/_callbacks.csc
rawfile clientscripts/_footsteps.csc
rawfile clientscripts/_lights.csc
rawfile clientscripts/_load.csc

// Shellshock
rawfile shock/dog_bite.shock

// Animtrees
rawfile animtrees/dog.atr
rawfile animtrees/generic_human.atr
rawfile animtrees/zombie_cymbal_monkey.atr

// String Table
stringtable mp/zombiemode.csv

// Menu
menufile ui/hud.txt

// Model
//xmodel collision_geo_32x32x128

Thanks.
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: Harry Bo21 on March 31, 2016, 10:27:31 pm
as i thought, its not in any of them

add it to dlc3.csv and recompile the map

Code Snippet
Plaintext
weapon,sp/WEAPONFILENAME
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: madsniper124 on April 01, 2016, 12:36:01 am
as i thought, its not in any of them

add it to dlc3.csv and recompile the map

Code Snippet
Plaintext
weapon,sp/WEAPONFILENAME

I've noticed that there is no "zombie_springfield" in root\raw\weapons\sp. Could this be the source of the problem?
After adding any of the other springfield files in that folder because there wasn't a zombie_springfield, I receive the error "Unknown item 'zombie_colt".
Here is the console log.
(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2F1KEhzVE.png&hash=57af12ba72e665c5b3a84d81df33cf7a774d9f4c)

Maybe it just wasn't meant to be?

Thanks.

P.S.
What's with the Nicolas Cage background?
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: HitmanVere on April 01, 2016, 07:19:26 pm
P.S.
What's with the Nicolas Cage background?

nic cage is love, nic cage is life :S
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: Harry Bo21 on April 01, 2016, 07:22:31 pm
I've noticed that there is no "zombie_springfield" in root\raw\weapons\sp. Could this be the source of the problem?
After adding any of the other springfield files in that folder because there wasn't a zombie_springfield, I receive the error "Unknown item 'zombie_colt".
Here is the console log.
(http://i.imgur.com/1KEhzVE.png)

Maybe it just wasn't meant to be?

Thanks.

P.S.
What's with the Nicolas Cage background?
that would "also" be a problem yes

it should be in raw/weapon/sp/


would need to copy it to your mod as well
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: madsniper124 on April 03, 2016, 06:24:20 pm
that would "also" be a problem yes

it should be in raw/weapon/sp/


would need to copy it to your mod as well

Welp, maybe it's time to give up now. I can't find a copy of mod tools that has zombie_springfield. I think I can get by without adding one of the worst guns. Thanks for taking the time to help a Fresh Corpse.
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: HitmanVere on April 03, 2016, 07:03:06 pm
Welp, maybe it's time to give up now. I can't find a copy of mod tools that has zombie_springfield. I think I can get by without adding one of the worst guns. Thanks for taking the time to help a Fresh Corpse.

These are the Springfield weaponfiles:

(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FaX9HccO.png&hash=bd56f53b62fe45c197e31c07f1cc146a2a0f05e8)

Located in root/raw/weaponfiles/sp/, just like Harry said
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: madsniper124 on April 04, 2016, 01:30:13 am
These are the Springfield weaponfiles:

(http://i.imgur.com/aX9HccO.png)

Located in root/raw/weaponfiles/sp/, just like Harry said

When I added those into dlc3.csv, I got the zombie_colt error like I've said before. I'll try it again, maybe I did something wrong.

Shame that the background of the site was changed back.

Thanks.
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: Harry Bo21 on April 05, 2016, 05:54:06 pm
dunno in my dlc3.csv it has "zombie_springfield" called but ofc i commented it straight back out, but none of those are "zombie_"

did it actually appear in zombies? I mean i know it was on one of the loadout lists but im not sure it ever actually appeared - might explain the missing weapon file


scratch that, i guess itd be this one

(https://gyazo.com/f5cd4f8bdb94ae55da666af168abab50.png)

(https://i.gyazo.com/dbdc34a012843ecc13f724b30558d075.png)



also if your zombie_colt error is "unknown item" - youve gone horribly wrong somewhere
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: madsniper124 on April 05, 2016, 09:19:56 pm
dunno in my dlc3.csv it has "zombie_springfield" called but ofc i commented it straight back out, but none of those are "zombie_"

did it actually appear in zombies? I mean i know it was on one of the loadout lists but im not sure it ever actually appeared - might explain the missing weapon file


scratch that, i guess itd be this one

(https://gyazo.com/f5cd4f8bdb94ae55da666af168abab50.png)

(https://i.gyazo.com/dbdc34a012843ecc13f724b30558d075.png)



also if your zombie_colt error is "unknown item" - youve gone horribly wrong somewhere

Maybe not. Adding those into the .csv causes the zombie_colt error and the prefab (which doesn't have a scope?) gives the script runtime error. What is strange to me is that the model of the springfield in the prefab doesn't have a scope, yet the ones with _zombie after it has one.

Am I the only person with this issue?
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: Harry Bo21 on April 06, 2016, 08:10:36 pm
Adding that other gun does not cause the Colt error... I told you this a post back. All waw guns are called from dlc3.csv - if your getting a error it's a mistake in there

And I don't remember it being in the game at all - only remember the kar, scoped kar and ptrs - this no scope one doesn't exist
Title: Re: Certain Prefabs Cause Script Runtime Error?
Post by: madsniper124 on April 07, 2016, 02:01:05 am
Adding that other gun does not cause the Colt error... I told you this a post back. All waw guns are called from dlc3.csv - if your getting a error it's a mistake in there

And I don't remember it being in the game at all - only remember the kar, scoped kar and ptrs - this no scope one doesn't exist

I suppose that I was trying to add a weapon in that wasn't supposed to be in. Case is solved?