Again, another First box patch by your fav waw modder
This release adds a timer synchronized with the game without the need for external software
it also fixes the movement speed to be the same as console
#include maps\_utility;
#include common_scripts\utility;
#include maps\_zombiemode_utility;
//First Box by twitch.tv/AlexInVR
init()
{
replacefunc(maps\_zombiemode_weapons::treasure_chest_ChooseRandomWeapon, ::custom_treasure_chest_ChooseRandomWeapon);
replacefunc(maps\_zombiemode_weapons::treasure_chest_weapon_spawn, ::custom_treasure_chest_weapon_spawn);
replacefunc(maps\_zombiemode_weapons_sumpf::treasure_chest_ChooseRandomWeapon, ::custom_treasure_chest_ChooseRandomWeapon);
replacefunc(maps\_zombiemode_weapons_sumpf::treasure_chest_weapon_spawn, ::custom_treasure_chest_weapon_spawn);
replacefunc(maps\_zombiemode::round_think, ::custom_round_think);
thread onConnect();
}
onConnect()
{
for(;;)
{
level waittill( "connecting", player );
player thread onPlayerSpawned();
}
}
custom_round_think()
{
for( ;; )
{
level.round_spawn_func = maps\_zombiemode::round_spawning;
//////////////////////////////////////////
//designed by prod DT#36173
maxreward = 50 * level.round_number;
if ( maxreward > 500 )
maxreward = 500;
level.zombie_vars["rebuild_barrier_cap_per_round"] = maxreward;
//////////////////////////////////////////
level.round_timer = level.zombie_vars["zombie_round_time"];
add_later_round_spawners();
maps\_zombiemode::chalk_one_up();
// round_text( &"ZOMBIE_ROUND_BEGIN" );
maps\_zombiemode_powerups::powerup_round_start();
players = get_players();
array_thread( players, maps\_zombiemode_blockers::rebuild_barrier_reward_reset );
level thread maps\_zombiemode::award_grenades_for_survivors();
level.round_start_time = getTime();
level thread [[level.round_spawn_func]]();
level notify("start_of_round");
maps\_zombiemode::round_wait();
level.first_round = false;
level notify("end_of_round");
level thread maps\_zombiemode::spectators_respawn();
// round_text( &"ZOMBIE_ROUND_END" );
level thread maps\_zombiemode::chalk_round_hint();
wait( level.zombie_vars["zombie_between_round_time"] );
// here's the difficulty increase over time area
timer = level.zombie_vars["zombie_spawn_delay"];
if( timer < 0.08 )
{
timer = 0.08;
}
level.zombie_vars["zombie_spawn_delay"] = timer * 0.95;
// Increase the zombie move speed
level.zombie_move_speed = level.round_number * 8;
level.round_number++;
level notify( "between_round_over" );
}
}
custom_treasure_chest_ChooseRandomWeapon(player)
{
if (level.round_number <= 15){
if (!(player HasWeapon("tesla_gun"))){
return "tesla_gun";
}
if (!(player HasWeapon("zombie_ppsh"))){
return "zombie_ppsh";
}
} else {
keys = GetArrayKeys( level.zombie_weapons );
// Filter out any weapons the player already has
filtered = [];
for( i = 0; i < keys.size; i++ )
{
if( player HasWeapon( keys[i] ) )
{
continue;
}
//chrisP - make sure the chest doesn't give the player a bouncing betty
if(keys[i] == "mine_bouncing_betty")
{
continue;
}
// PI_CHANGE_BEGIN
if( isDefined(level.script) && level.script == "nazi_zombie_sumpf")
{
//make sure box moves once before allowing ray gun to be accessed.
if( level.box_moved == false )
{
if( keys[i] == "ray_gun" )
{
continue;
}
}
}
// PI_CHANGE_END
if( !IsDefined( keys[i] ) )
continue;
filtered[filtered.size] = keys[i];
}
// PI_CHANGE_BEGIN - adjusting the percentages of the ray gun and tesla gun showing up
if( isDefined(level.script) && level.script == "nazi_zombie_sumpf" )
{
if( level.box_moved == true )
{
if( !(player HasWeapon( "ray_gun" )) )
{
// 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 )
{
// calculate the number of times we have to add it to the array to get the desired percent
number_to_add = .15 * filtered.size;
for(i=1; i<number_to_add; i++)
{
filtered[filtered.size] = "ray_gun";
}
}
// after 8 pulls the Ray Gun percentage increases to 10%
else if( level.pulls_since_last_ray_gun > 7 )
{
// calculate the number of times we have to add it to the array to get the desired percent
number_to_add = .1 * filtered.size;
for(i=1; i<number_to_add; i++)
{
filtered[filtered.size] = "ray_gun";
}
}
}
}
}
// increase the percentage of tesla gun
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 )
{
// calculate the number of times we have to add it to the array to get the desired percent
number_to_add = .2 * filtered.size;
for(i=1; i<number_to_add; i++)
{
filtered[filtered.size] = "tesla_gun";
}
}
// 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 )
{
// calculate the number of times we have to add it to the array to get the desired percent
number_to_add = .2 * filtered.size;
for(i=1; i<number_to_add; i++)
{
filtered[filtered.size] = "tesla_gun";
}
}
// 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
number_to_add = .15 * filtered.size;
for(i=1; i<number_to_add; i++)
{
filtered[filtered.size] = "tesla_gun";
}
}
}
}
}
// PI_CHANGE_END
// Filter out the limited weapons
if( IsDefined( level.limited_weapons ) )
{
keys2 = GetArrayKeys( level.limited_weapons );
players = get_players();
for( q = 0; q < keys2.size; q++ )
{
count = 0;
for( i = 0; i < players.size; i++ )
{
if( players[i] HasWeapon( keys2[q] ) )
{
count++;
}
// check for last stand weapons that might not be on the player at the time
if (players[i] maps\_laststand::player_is_in_laststand())
{
for( m = 0; m < players[i].weaponInventory.size; m++ )
{
if (players[i].weaponInventory[m] == keys2[q])
{
count++;
}
}
}
}
if( count == level.limited_weapons[keys2[q]] )
{
filtered = array_remove( filtered, keys2[q] );
}
}
}
return filtered[RandomInt( filtered.size )];
}
}
custom_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;
for( i = 0; i < 40; 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 );
}
rand = custom_treasure_chest_ChooseRandomWeapon( 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);
//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 < 4)
{
// 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;
// PI_CHANGE_BEGIN - JMA
if( isDefined(level.script) && level.script == "nazi_zombie_sumpf" )
{
// make sure teddy bear appears on the 8th pull if it hasn't moved from the attic
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;
}
}
}
}
// PI_CHANGE_END
}
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");
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" )
{
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();
}
}
game_timer()
{
hud = create_simple_hud( self );
hud.foreground = true;
hud.sort = 1;
hud.hidewheninmenu = true;
hud.alignX = "left";
hud.alignY = "top";
hud.horzAlign = "user_left";
hud.vertAlign = "user_top";
hud.x = hud.x - -700;
hud.y = hud.y + 35;
hud.alpha = 1;
flag_wait("all_players_spawned");
hud setTimerUp(1);
}
round_timer()
{
timerHud = create_simple_hud( self );
timerHud.foreground = true;
timerHud.sort = 1;
timerHud.hidewheninmenu = true;
timerHud.alignX = "left";
timerHud.alignY = "top";
timerHud.horzAlign = "user_left";
timerHud.vertAlign = "user_top";
timerHud.x = timerHud.x - -700;
timerHud.y = timerHud.y + 45;
timerHud.color = (1, 0, 0);
timerHud.alpha = 1;
flag_wait("all_players_spawned");
for (;;){
start_time = GetTime() / 1000;
timerHud setTimerUp(0);
level waittill("end_of_round");
end_time = GetTime() / 1000;
time = end_time - start_time;
set_time_frozen(timerHud, time);
}
}
set_time_frozen(hud, time)
{
level endon("start_of_round");
time = time - 0.1;
while(1)
{
hud settimer(time);
wait(0.5);
}
}
onPlayerSpawned()
{
self endon( "disconnect" );
for( ;; )
{
level waittill( "connected", player );
self thread game_timer();
self thread round_timer();
self SetClientDvars(
"player_backSpeedScale", "1",
"player_strafeSpeedScale", "1");
wait 3;
self IPrintLnBold("First box patch by ^1twitch.tv/^2AlexInVR");
}
level waittill( "connected", player );
}
pic of what it looks like upon spawning in the game.