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

Making a custom perk Help (almost Done)!

HOT
broken avatar :(
Created 10 years ago
by Jackson
0 Members and 1 Guest are viewing this topic.
7,494 views
broken avatar :(
×
broken avatar :(
Location: usNorth Caroline
Date Registered: 28 April 2014
Last active: 7 years ago
Posts
13
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
The world is beautiful, and so are you. Enjoy it.
Signature
“For me, I am driven by two main philosophies: know more today about the world than I knew yesterday and lessen the suffering of others. You'd be surprised how far that gets you.”


― Neil deGrasse Tyson
I nearly have my new custom perk finished, but i need help with two things.

1. I need an experienced scripter to double check my script to ensure i didnt screw it up

2. I need to know where to put my script for my perk. Every perk has a place, and i need to know where mine would go.

Thanks!

-Flathead

Perk Script:
Code Snippet
Plaintext
while ( self hasperk ( "specialty_boost" ) )

{  if ( self maps\_laststand::player_is_in_laststand() )

{
IPrintLnBold("Pushing Daisies Acticated");

zombies = getaispeciesarray("axis");


zombies = get_array_of_closest( drop_item.origin, zombies );

for (i = 0; i < zombies.size; i++)
{
wait (randomfloatrange(0.1, 0.7));
if( !IsDefined( zombies[i] ) )
{
continue;
}

if( zombies[i].animname == "boss_zombie" )
{
continue;
}

if( is_magic_bullet_shield_enabled( zombies[i] ) )
{
continue;
}

if( i < 5 && !( zombies[i] enemy_is_dog() ) )
{
zombies[i] thread animscripts\death::flame_death_fx();

}

if( !( zombies[i] enemy_is_dog() ) )
{
zombies[i] maps\_zombiemode_spawner::zombie_head_gib();
}

zombies[i] dodamage( zombies[i].health + 666, zombies[i].origin );
playsoundatposition( "nuked", zombies[i].origin );
}
}

else
{

continue;

}

wait(.5);


}
(It makes a nuke go off when the person with the perk goes down)
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 25 June 2013
Last active: 2 years ago
Posts
3,997
Respect
Forum Rank
Eviscerator
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
×
HitmanVere's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Mapper Has released one or more maps to the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Thread this in _zombiemode_perks.gsc anywhere, so it gets called:
Code Snippet
Plaintext
level thread players_daisies();

I modified it a bit, should work from quick look:

Code Snippet
Plaintext
players_daisies()
{
players = getPlayers();
for (i=0; i<players.size; i++)
{
players[i] pushing_daisies();
}
}

pushing_daisies()
{
while(true)
{
if (self maps\_laststand::player_is_in_laststand() && self hasperk ( "specialty_boost" ))
{
IPrintLnBold("Pushing Daisies Acticated");
self thread nuke_explosion();
wait 10;
}
wait 0.1;
}
}

nuke_explosion()
{
zombies = getaispeciesarray("axis");
zombies = get_array_of_closest( self.origin, zombies );

for (i = 0; i < zombies.size; i++)
{
wait (randomfloatrange(0.1, 0.7));
if( !IsDefined( zombies[i] ) )
{
continue;
}

if( zombies[i].animname == "boss_zombie" )
{
continue;
}

if( is_magic_bullet_shield_enabled( zombies[i] ) )
{
continue;
}

if( i < 5 && !( zombies[i] enemy_is_dog() ) )
{
zombies[i] thread animscripts\death::flame_death_fx();
}

if( !( zombies[i] enemy_is_dog() ) )
{
zombies[i] maps\_zombiemode_spawner::zombie_head_gib();
}

zombies[i] dodamage( zombies[i].health + 666, zombies[i].origin );
playsoundatposition( "nuked", zombies[i].origin );
}
}

Havent scripted in few weeks, so yes, it might be sloppy, but should get the work done :P
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
It looks like the nuke will go off every 10 seconds when the player is downed? Unless I am mistaken.

You could just add to zombiemode.gsc where it puts the player in laststand to check for the perk and thread a function if they have it, one and done.

In player_damage_override function (between the laststand and the fake death calls)  or in the player_fake_death function you could find a place to put:

Code Snippet
Plaintext
    if(self HasPerk( "specialty_boost" )) self thread NukeMe();


Then use your script or just spawn a new powerup on the player or however you want to do it.

Code Snippet
Plaintext
NukeMe(){
if(!IsDefined( level.zombie_powerups )){
self IPrintLn( "Error, level.zombie_powerups is not defined" );
return;
}
struct = level.zombie_powerups["nuke"];
nuke = maps\_zombiemode_net::network_safe_spawn( "powerup", 1, "script_model", self.origin + (0,0,40));

if(IsDefined( nuke )){
if( IsDefined( struct.fx ) ) nuke.fx = struct.fx;
maps\_zombiemode_powerups::nuke_powerup(nuke);
}else{
self IPrintLn( "Error, nuke not defined" );
}
        wait(1);
        nuke delete();

}

None of this is tested, I just saw a lot of repeated code, and I always try to isolate that and find ways to reuse existing functions.
Last Edit: May 25, 2016, 02:04:31 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 25 June 2013
Last active: 2 years ago
Posts
3,997
Respect
Forum Rank
Eviscerator
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
×
HitmanVere's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Mapper Has released one or more maps to the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
It looks like the nuke will go off every 10 seconds when the player is downed? Unless I am mistaken.

I was thinking about this as well and forgot one key thing, even though I was thinking about this also. You wont have perk anymore, when you go down, so if perk gets unset after going down, then it would work. If they both happen at same time, it wont work. Your way probs would work, for mine I didnt want to guide him in new script :P
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I was thinking about this as well and forgot one key thing, even though I was thinking about this also. You wont have perk anymore, when you go down, so if perk gets unset after going down, then it would work. If they both happen at same time, it wont work. Your way probs would work, for mine I didnt want to guide him in new script :P

The perk is unset on the notify in the player_fake_death function, which the OP will need to make sure the if statement is placed before the notify, so threading it in the player_fake_death function above the notify should prob be best for that method. He could use the while loop and figure out something with that wait issue and it wouldn't matter I guess. Which ever function/method he goes with, I would not suggest going with a while loop or repeating the same function again.
Last Edit: May 25, 2016, 02:05:32 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: usNorth Caroline
Date Registered: 28 April 2014
Last active: 7 years ago
Posts
13
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
The world is beautiful, and so are you. Enjoy it.
Thread this in _zombiemode_perks.gsc anywhere, so it gets called:
Code Snippet
Plaintext
level thread players_daisies();

I modified it a bit, should work from quick look:

Code Snippet
Plaintext
players_daisies()
{
players = getPlayers();
for (i=0; i<players.size; i++)
{
players[i] pushing_daisies();
}
}

pushing_daisies()
{
while(true)
{
if (self maps\_laststand::player_is_in_laststand() && self hasperk ( "specialty_boost" ))
{
IPrintLnBold("Pushing Daisies Acticated");
self thread nuke_explosion();
wait 10;
}
wait 0.1;
}
}

nuke_explosion()
{
zombies = getaispeciesarray("axis");
zombies = get_array_of_closest( self.origin, zombies );

for (i = 0; i < zombies.size; i++)
{
wait (randomfloatrange(0.1, 0.7));
if( !IsDefined( zombies[i] ) )
{
continue;
}

if( zombies[i].animname == "boss_zombie" )
{
continue;
}

if( is_magic_bullet_shield_enabled( zombies[i] ) )
{
continue;
}

if( i < 5 && !( zombies[i] enemy_is_dog() ) )
{
zombies[i] thread animscripts\death::flame_death_fx();
}

if( !( zombies[i] enemy_is_dog() ) )
{
zombies[i] maps\_zombiemode_spawner::zombie_head_gib();
}

zombies[i] dodamage( zombies[i].health + 666, zombies[i].origin );
playsoundatposition( "nuked", zombies[i].origin );
}
}

Havent scripted in few weeks, so yes, it might be sloppy, but should get the work done :P
Should the rest of the code bne put into the Player_fake_death function? Or should it also be put into _zombiemode_perks?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Should the rest of the code bne put into the Player_fake_death function? Or should it also be put into _zombiemode_perks?

You weren't quoting me, but I wondered this when you first posted... Did you take care of the perk machine already? Cause that is done in zombiemode_perks, but the reward, if you will, for the perk can be done anywhere its applicable.
Last Edit: May 25, 2016, 08:06:20 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: usNorth Caroline
Date Registered: 28 April 2014
Last active: 7 years ago
Posts
13
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
The world is beautiful, and so are you. Enjoy it.
I used ZKs tutorial to change things like shader, hintstring, and all that. I just needed to know where the perk function itself went. I did what Hitman said and when i get in game the perk machine only says "power must be activate fist" which im guessing is something that i did wrong on my part.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I used ZKs tutorial to change things like shader, hintstring, and all that. I just needed to know where the perk function itself went. I did what Hitman said and when i get in game the perk machine only says "power must be activate fist" which im guessing is something that i did wrong on my part.

yeah, that has nothing to do with anything in this post. That has to do with the perk script for the machine. Once that is resolved, you buy the perk, and get the shader, you will then be ready to test whatever you did in this thread.
broken avatar :(
×
broken avatar :(
Location: usNorth Caroline
Date Registered: 28 April 2014
Last active: 7 years ago
Posts
13
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
The world is beautiful, and so are you. Enjoy it.
That is kind of why i made this post, everything IS set up now. The machine, the triggers, the perk. My only problem is that it says the power isnt active even though it is, and i followed ZKs tutorial to the teet. Its likely that the files have changed over the years and things have changed but that is what im asking.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
That is kind of why i made this post, everything IS set up now. The machine, the triggers, the perk. My only problem is that it says the power isnt active even though it is, and i followed ZKs tutorial to the teet. Its likely that the files have changed over the years and things have changed but that is what im asking.

Well, there are two sides to every swartz, lol. The part you posted is the part that handles what to do once the player has the perk. The part your having issues with right now is the perk machine part. It's waiting for the perk on notify, and something had a typo or wasn't set up for that. There are several easy fixes. If you post your perks script, it should be an easy fix.
Last Edit: May 26, 2016, 02:56:10 am by MakeCents
broken avatar :(
×
broken avatar :(
Location: usNorth Caroline
Date Registered: 28 April 2014
Last active: 7 years ago
Posts
13
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
The world is beautiful, and so are you. Enjoy it.
Here is all the code i added to add the perk (Taken from my _zombiemode_perks

Code Snippet
Plaintext
PrecacheShader( "specialty_push_zombies" );

level thread turn_push_on();

turn_push_on()
{
machine = getentarray("push_machine", "targetname");
level waittill("sleight_on");

for( i = 0; i < machine.size; i++ )
{
machine[i] setmodel("zombie_vending_push_on");
machine[i] vibrate((0,-100,0), 0.3, 0.4, 3);
machine[i] playsound("perks_power_on");
machine[i] thread perk_fx( "jugger_light" );
}

level notify( "specialty_boost_power_on" );
}

case "specialty_boost":
self SetHintString( &"Press & Hold &&1 to buy Pushing Daisies Dubonnet" );
break;

case "specialty_boost":
shader = "vending_push_shader";
break;

players_daisies()
{
players = getPlayers();
for (i=0; i<players.size; i++)
{
players[i] pushing_daisies();
}
}

pushing_daisies()
{
while(true)
{
if (self maps\_laststand::player_is_in_laststand() && self hasperk ( "specialty_boost" ))
{
IPrintLnBold("Pushing Daisies Acticated");
self thread nuke_explosion();
wait 10;
}
wait 0.1;
}
}

nuke_explosion()
{
zombies = getaispeciesarray("axis");
zombies = get_array_of_closest( self.origin, zombies );

for (i = 0; i < zombies.size; i++)
{
wait (randomfloatrange(0.1, 0.7));
if( !IsDefined( zombies[i] ) )
{
continue;
}

if( zombies[i].animname == "boss_zombie" )
{
continue;
}

if( is_magic_bullet_shield_enabled( zombies[i] ) )
{
continue;
}

if( i < 5 && !( zombies[i] enemy_is_dog() ) )
{
zombies[i] thread animscripts\death::flame_death_fx();
}

if( !( zombies[i] enemy_is_dog() ) )
{
zombies[i] maps\_zombiemode_spawner::zombie_head_gib();
}

zombies[i] dodamage( zombies[i].health + 666, zombies[i].origin );
playsoundatposition( "nuked", zombies[i].origin );
}
}

The KVPs on the perk machine are
Classname: Trigger_use
script_noteworthy: specialty_boost
targetname: Zombie_vending

That is literally everything i have done for the perk.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Well it would have been a simple fix if you would have posted the entire perks script... maybe.  ;) I'm gonna make some assumptions like you have the thread in a good place, and your other perks are working, and your vending_trigger_think is thread on all the triggers with the kvp targetname>zombie_vending, since your getting the power hint. I will also assume your kvps for your machines are targetname>push_machine, although that wouldn't affect your hint or your ability to buy it. Do you see your turn_push_on() function? It's notifying to the vending_trigger_think function, which you didn't include for me to see if it was setup right. It looks right. In the vending_trigger_think function you will find something like this:

Code Snippet
Plaintext
	notify_name = perk + "_power_on";
level waittill( notify_name );

You can change that to:

Code Snippet
Plaintext
	//notify_name = perk + "_power_on";
//level waittill( notify_name );
        flag_wait("electricity_on");

That may work but doesn't really solve your issue your having. If it does work, then there could be a typo in your script_noteworthy kvp in radiant. A screen shot always helps troubleshooting better than retyping it.

Your notifying "specialty_boost_power_on" in your script, so from what I see you can try a few things to isolate this issue. Add iprintln("what is happening"); after different areas. Add one before level waittill("sleight_on"); (which you may a not see) then one after it. You may want to print the script_noteworthy as well, and check for typos.



Also, once you get this fixed, you could still have issues with the specialty. Here is a list of all specialties, and I have a ? next to this specialty for some reason. I don't remember the reason, but it seems questionable to me. So you may want to try a different specialty. (you can ignore the stuff after the : its just what I use them for)

Code Snippet
Plaintext
/* 
SPECIALTIES:
*specialty_armorvest: Juggernaut
*specialty_bulletaccuracy: DeadShot
*specialty_detectexplosive: PHD
*specialty_extraammo: Mule Kick
*specialty_fastreload: Speed Cola
*specialty_fireproof: ZMP
*specialty_gpsjammer: shocknade
*specialty_longersprint: Staminup
*specialty_quickrevive: Quick Revive with solo qr
*specialty_rof: Double tap
*specialty_shades: Elecric Cherry
*specialty_twoprimaries: DoubleMag
specialty_boost: ?
specialty_bulletdamage: Stopping Power
specialty_bulletpenetration: Deep Impact
specialty_explosivedamage: Fireworks - like sonic boom in COD4
specialty_gas_mask: Reduces the effects of gas grenade attacks
specialty_grenadepulldeath: Martyrdom
specialty_holdbreath: Iron lungs
specialty_leadfoot: Increase tank's drive speed
specialty_ordinance: Faster firing main tank gun
specialty_pin_back: Toss back - resets timer on throwing back grenades
specialty_pistoldeath: Last stand
specialty_quieter: Dead Silence
specialty_specialgrenade: Specials Grenades x 3
specialty_water_cooled: Slows the overheating of tank guns
X-specialty_doublegrenade: (Doesn't work)
X-specialty_flak_jacket: (Doesn't work)
X-specialty_greased_bearings: (Doesn't work)
X-specialty_recon: (Doesn't work)
X-specialty_weapon_betty: (Doesn't work)
X-specialty_weapon_flamethrower: (Doesn't work)
X-specialty_weapon_rpg: (Doesn't work)
X-specialty_weapon_satchel: (Doesn't work)
*/
Last Edit: May 26, 2016, 12:58:07 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: usNUKETOWN
Date Registered: 19 February 2014
Last active: 9 years ago
Posts
177
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Zombie Specialist
Signature
×
thezombieproject's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.

Code Snippet
Plaintext
 
players_daisies()
{
players = getPlayers();
for (i=0; i<players.size; i++)
{
players[i] pushing_daisies();
}
}

pushing_daisies()
{
while(true)
{
if (self maps\_laststand::player_is_in_laststand() && self hasperk ( "specialty_boost" ))
{
IPrintLnBold("Pushing Daisies Acticated");
self thread nuke_explosion();
wait 10;
}
wait 0.1;
}
}



i think most perks systems use "specialty_boost" for electric cherry
specialty_boost works but you should change it to something different or you will most likely run into problems if using cherry. 
I made a custom perk and specialty_leadfoot works
so maybe try that one or try 1 from the list that Mcents gave you.

all game constantly checking all players for perk is really not needed.
you should do something more like what cents told you.
only thing with that is all players are going to get 400 points when player goes down but thats an easy fix
if you dont want that.
Last Edit: May 26, 2016, 10:57:00 pm by thezombieproject
broken avatar :(
×
broken avatar :(
Location: usNorth Caroline
Date Registered: 28 April 2014
Last active: 7 years ago
Posts
13
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
The world is beautiful, and so are you. Enjoy it.
Okay so i changed my perk to Leadfoot, and added the script to the power. Now when ever i launch my map it looks like im about to spawn (Process bar vaishes after full) and the game crashes.
Heres the code for my _zombiemode_perks:
Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

init()
{
level thread players_daisies();
vending_triggers = GetEntArray( "zombie_vending", "targetname" );

if ( vending_triggers.size < 1 )
{
return;
}

vending_upgrade_trigger = GetEntArray("zombie_vending_upgrade", "targetname");

if ( vending_upgrade_trigger.size >= 1 )
{
array_thread( vending_upgrade_trigger, ::vending_upgrade );;
}


// this map uses atleast 1 perk machine
PrecacheItem( "zombie_perk_bottle_doubletap" );
PrecacheItem( "zombie_perk_bottle_jugg" );
PrecacheItem( "zombie_perk_bottle_revive" );
PrecacheItem( "zombie_perk_bottle_sleight" );
PrecacheItem( "zombie_knuckle_crack" );

PrecacheShader( "specialty_juggernaut_zombies" );
PrecacheShader( "specialty_fastreload_zombies" );
PrecacheShader( "specialty_doubletap_zombies" );
PrecacheShader( "specialty_quickrevive_zombies" );
PrecacheShader( "specialty_push_zombies" );

//PI ESM - sumpf vending machine
if (isDefined(level.script) && level.script == "nazi_zombie_sumpf")
{
PrecacheModel("zombie_vending_jugg_on_price");
PrecacheModel("zombie_vending_doubletap_price");
PrecacheModel("zombie_vending_revive_on_price");
PrecacheModel("zombie_vending_sleight_on_price");
}
else
{
PrecacheModel("zombie_vending_jugg_on");
PrecacheModel("zombie_vending_doubletap_on");
PrecacheModel("zombie_vending_revive_on");
PrecacheModel("zombie_vending_sleight_on");
precachemodel("zombie_vending_packapunch_on");
}

level._effect["sleight_light"] = loadfx("misc/fx_zombie_cola_on");
level._effect["doubletap_light"] = loadfx("misc/fx_zombie_cola_dtap_on");
level._effect["jugger_light"] = loadfx("misc/fx_zombie_cola_jugg_on");
level._effect["revive_light"] = loadfx("misc/fx_zombie_cola_revive_on");
level._effect["packapunch_fx"] = loadfx("maps/zombie/fx_zombie_packapunch");

if( !isDefined( level.packapunch_timeout ) )
{
level.packapunch_timeout = 15;
}

PrecacheString( &"ZOMBIE_PERK_JUGGERNAUT" );
PrecacheString( &"ZOMBIE_PERK_QUICKREVIVE" );
PrecacheString( &"ZOMBIE_PERK_FASTRELOAD" );
PrecacheString( &"ZOMBIE_PERK_DOUBLETAP" );
PrecacheString( &"ZOMBIE_PERK_PACKAPUNCH" );

set_zombie_var( "zombie_perk_cost", 2500 );
set_zombie_var( "zombie_perk_juggernaut_health", 325 );

// this map uses atleast 1 perk machine
array_thread( vending_triggers, ::vending_trigger_think );
array_thread( vending_triggers, :: electric_perks_dialog);


level thread turn_jugger_on();
level thread turn_doubletap_on();
level thread turn_sleight_on();
level thread turn_revive_on();
level thread turn_PackAPunch_on();
level thread turn_push_on();


level thread machine_watcher();
level.speed_jingle = 0;
level.revive_jingle = 0;
level.doubletap_jingle = 0;
level.jugger_jingle = 0;
level.packa_jingle = 0;

}

third_person_weapon_upgrade( current_weapon, origin, angles, packa_rollers, perk_machine )
{
forward = anglesToForward( angles );
interact_pos = origin + (forward*-25);

worldgun = spawn( "script_model", interact_pos );
worldgun.angles  = self.angles;
worldgun setModel( GetWeaponModel( current_weapon ) );
PlayFx( level._effect["packapunch_fx"], origin+(0,1,-34), forward );

worldgun rotateto( angles+(0,90,0), 0.35, 0, 0 );
wait( 0.5 );
worldgun moveto( origin, 0.5, 0, 0 );
packa_rollers playsound( "packa_weap_upgrade" );
if( isDefined( perk_machine.wait_flag ) )
{
perk_machine.wait_flag rotateto( perk_machine.wait_flag.angles+(179, 0, 0), 0.25, 0, 0 );
}
wait( 0.35 );
worldgun delete();
wait( 3 );
packa_rollers playsound( "packa_weap_ready" );
worldgun = spawn( "script_model", origin );
worldgun.angles  = angles+(0,90,0);
worldgun setModel( GetWeaponModel( current_weapon+"_upgraded" ) );
worldgun moveto( interact_pos, 0.5, 0, 0 );
if( isDefined( perk_machine.wait_flag ) )
{
perk_machine.wait_flag rotateto( perk_machine.wait_flag.angles-(179, 0, 0), 0.25, 0, 0 );
}
wait( 0.5 );
worldgun moveto( origin, level.packapunch_timeout, 0, 0);
return worldgun;
}

vending_upgrade()
{
perk_machine = GetEnt( self.target, "targetname" );
if( isDefined( perk_machine.target ) )
{
perk_machine.wait_flag = GetEnt( perk_machine.target, "targetname" );
}

self UseTriggerRequireLookAt();
self SetHintString( &"ZOMBIE_FLAMES_UNAVAILABLE" );
self SetCursorHint( "HINT_NOICON" );
level waittill("Pack_A_Punch_on");

self thread maps\_zombiemode_weapons::decide_hide_show_hint();

packa_rollers = spawn("script_origin", self.origin);
packa_timer = spawn("script_origin", self.origin);
packa_rollers playloopsound("packa_rollers_loop");

self SetHintString( &"ZOMBIE_PERK_PACKAPUNCH" );
cost = level.zombie_vars["zombie_perk_cost"];

for( ;; )
{
self waittill( "trigger", player );
index = maps\_zombiemode_weapons::get_player_index(player);
cost = 5000;
plr = "plr_" + index + "_";

if( !player maps\_zombiemode_weapons::can_buy_weapon() )
{
wait( 0.1 );
continue;
}

if (player maps\_laststand::player_is_in_laststand() )
{
wait( 0.1 );
continue;
}

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

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

current_weapon = player getCurrentWeapon();

if( !IsDefined( level.zombie_include_weapons[current_weapon] ) || !IsDefined( level.zombie_include_weapons[current_weapon + "_upgraded"] ) )
{
continue;
}

if ( player.score < cost )
{
//player iprintln( "Not enough points to buy Perk: " + perk );
self playsound("deny");
player thread play_no_money_perk_dialog();
continue;
}
player maps\_zombiemode_score::minus_to_player_score( cost );
self achievement_notify("perk_used");
sound = "bottle_dispense3d";
playsoundatposition(sound, self.origin);
rand = randomintrange(1,100);

if( rand <= 8 )
{
player thread play_packa_wait_dialog(plr);
}

self thread play_vendor_stings("mx_packa_sting");

origin = self.origin;
angles = self.angles;

if( isDefined(perk_machine))
{
origin = perk_machine.origin+(0,0,35);
angles = perk_machine.angles+(0,90,0);
}

self disable_trigger();

player thread do_knuckle_crack();

// Remember what weapon we have.  This is needed to check unique weapon counts.
self.current_weapon = current_weapon;

weaponmodel = player third_person_weapon_upgrade( current_weapon, origin, angles, packa_rollers, perk_machine );

self enable_trigger();
self SetHintString( &"ZOMBIE_GET_UPGRADED" );
self setvisibletoplayer( player );

self thread wait_for_player_to_take( player, current_weapon, packa_timer );
self thread wait_for_timeout( packa_timer );

self waittill_either( "pap_timeout", "pap_taken" );

self.current_weapon = "";
weaponmodel delete();
self SetHintString( &"ZOMBIE_PERK_PACKAPUNCH" );
self setvisibletoall();
}
}

wait_for_player_to_take( player, weapon, packa_timer )
{
index = maps\_zombiemode_weapons::get_player_index(player);
plr = "plr_" + index + "_";

self endon( "pap_timeout" );
while( true )
{
packa_timer playloopsound( "ticktock_loop" );
self waittill( "trigger", trigger_player );
packa_timer stoploopsound(.05);
if( trigger_player == player )
{
if( !player maps\_laststand::player_is_in_laststand() )
{
self notify( "pap_taken" );
primaries = player GetWeaponsListPrimaries();
if( isDefined( primaries ) && primaries.size >= self.MuleCount )
{
player maps\bam_bo_mod_bo1_perks_standalone_functions::weapon_give( weapon+"_upgraded" );
}
else
{
player GiveWeapon( weapon+"_upgraded" );
player GiveMaxAmmo( weapon+"_upgraded" );
}

player SwitchToWeapon( weapon+"_upgraded" );
player achievement_notify( "DLC3_ZOMBIE_PAP_ONCE" );
player achievement_notify( "DLC3_ZOMBIE_TWO_UPGRADED" );
player thread play_packa_get_dialog(plr);
return;
}
}
wait( 0.05 );
}
}
wait_for_timeout( packa_timer )
{
self endon( "pap_taken" );

wait( level.packapunch_timeout );

self notify( "pap_timeout" );
packa_timer stoploopsound(.05);
packa_timer playsound( "packa_deny" );
}

do_knuckle_crack()
{
gun = self upgrade_knuckle_crack_begin();

self.is_drinking = 1;
self waittill_any( "fake_death", "death", "player_downed", "weapon_change_complete" );

self upgrade_knuckle_crack_end( gun );
self.is_drinking = undefined;
}

upgrade_knuckle_crack_begin()
{
self DisableOffhandWeapons();
self DisableWeaponCycling();

self AllowLean( true );
self AllowAds( true );
self AllowSprint( true );
self AllowProne( true );
self AllowMelee( true );

if ( self GetStance() == "prone" )
{
self SetStance( "crouch" );
}

primaries = self GetWeaponsListPrimaries();

gun = self GetCurrentWeapon();
weapon = "zombie_knuckle_crack";

if ( gun != "none" && gun != "mine_bouncing_betty" )
{
self TakeWeapon( gun );
}
else
{
return;
}

if( primaries.size <= 1 )
{
self GiveWeapon( "colt_dirty_harry" );
}

self GiveWeapon( weapon );
self SwitchToWeapon( weapon );

return gun;
}

upgrade_knuckle_crack_end( gun )
{
assert( gun != "zombie_perk_bottle_doubletap" );
assert( gun != "zombie_perk_bottle_revive" );
assert( gun != "zombie_perk_bottle_jugg" );
assert( gun != "zombie_perk_bottle_sleight" );
assert( gun != "syrette" );

self EnableOffhandWeapons();
self EnableWeaponCycling();

self AllowLean( true );
self AllowAds( true );
self AllowSprint( true );
self AllowProne( true );
self AllowMelee( true );
weapon = "zombie_knuckle_crack";

// TODO: race condition?
if ( self maps\_laststand::player_is_in_laststand() )
{
self TakeWeapon(weapon);
return;
}

self TakeWeapon(weapon);
primaries = self GetWeaponsListPrimaries();
if( isDefined( primaries ) && primaries.size > 0 )
{
self SwitchToWeapon( primaries[0] );
}
else
{
self SwitchToWeapon( "colt_dirty_harry" );
}
}

// PI_CHANGE_BEGIN
// JMA - in order to have multiple Pack-A-Punch machines in a map we're going to have
// to run a thread on each on.
// NOTE:  In the .map, you'll have to make sure that each Pack-A-Punch machine has a unique targetname
turn_PackAPunch_on()
{
level waittill("Pack_A_Punch_on");

vending_upgrade_trigger = GetEntArray("zombie_vending_upgrade", "targetname");
for(i=0; i<vending_upgrade_trigger.size; i++ )
{
perk = getent(vending_upgrade_trigger[i].target, "targetname");
if(isDefined(perk))
{
perk thread activate_PackAPunch();
}
}
}

activate_PackAPunch()
{
self setmodel("zombie_vending_packapunch_on");
self playsound("perks_power_on");
self vibrate((0,-100,0), 0.3, 0.4, 3);
/*
self.flag = spawn( "script_model", machine GetTagOrigin( "tag_flag" ) );
self.angles = machine GetTagAngles( "tag_flag" );
self.flag setModel( "zombie_sign_please_wait" );
self.flag linkto( machine );
self.flag.origin = (0, 40, 40);
self.flag.angles = (0, 0, 0);
*/
timer = 0;
duration = 0.05;

level notify( "Carpenter_On" );
}
// PI_CHANGE_END

turn_sleight_on()
{
machine = getentarray("vending_sleight", "targetname");
level waittill("sleight_on");

for( i = 0; i < machine.size; i++ )
{
machine[i] setmodel("zombie_vending_sleight_on");
machine[i] vibrate((0,-100,0), 0.3, 0.4, 3);
machine[i] playsound("perks_power_on");
machine[i] thread perk_fx( "sleight_light" );
}

level notify( "specialty_fastreload_power_on" );
}

turn_push_on()
{
iprintln("Perk On");
machine = getentarray("push_machine", "targetname");
level waittill("sleight_on");

for( i = 0; i < machine.size; i++ )
{
machine[i] setmodel("zombie_vending_push_on");
machine[i] vibrate((0,-100,0), 0.3, 0.4, 3);
machine[i] playsound("perks_power_on");
machine[i] thread perk_fx( "jugger_light" );
}

level notify( "specialty_leadfoot_power_on" );
}


turn_revive_on()
{
machine = getentarray("vending_revive", "targetname");

players = get_players();

if(players.size > 1)
level waittill("revive_on");

for( i = 0; i < machine.size; i++ )
{
machine[i] setmodel("zombie_vending_revive_on");
machine[i] playsound("perks_power_on");
machine[i] vibrate((0,-100,0), 0.3, 0.4, 3);
machine[i] thread perk_fx( "revive_light" );
}

level notify( "specialty_quickrevive_power_on" );
}

turn_jugger_on()
{
machine = getentarray("vending_jugg", "targetname");
//temp until I can get the wire to jugger.
level waittill("juggernog_on");

for( i = 0; i < machine.size; i++ )
{
machine[i] setmodel("zombie_vending_jugg_on");
machine[i] vibrate((0,-100,0), 0.3, 0.4, 3);
machine[i] playsound("perks_power_on");
machine[i] thread perk_fx( "jugger_light" );

}
level notify( "specialty_armorvest_power_on" );

}

turn_doubletap_on()
{
machine = getentarray("vending_doubletap", "targetname");
level waittill("doubletap_on");

for( i = 0; i < machine.size; i++ )
{
machine[i] setmodel("zombie_vending_doubletap_on");
machine[i] vibrate((0,-100,0), 0.3, 0.4, 3);
machine[i] playsound("perks_power_on");
machine[i] thread perk_fx( "doubletap_light" );
}
level notify( "specialty_rof_power_on" );
}

perk_fx( fx )
{
wait(3);
playfxontag( level._effect[ fx ], self, "tag_origin" );
}




electric_perks_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)
{

players[i] thread do_player_vo("vox_start", 5);
wait(3);
self notify ("warning_dialog");
iprintlnbold("warning_given");
}
}
}
}
vending_trigger_think()
{

//self thread turn_cola_off();
perk = self.script_noteworthy;


self SetHintString( &"ZOMBIE_FLAMES_UNAVAILABLE" );

self SetCursorHint( "HINT_NOICON" );
self UseTriggerRequireLookAt();

//notify_name = perk + "_power_on";
//level waittill( notify_name );
    flag_wait("electricity_on");

perk_hum = spawn("script_origin", self.origin);
perk_hum playloopsound("perks_machine_loop");

self thread check_player_has_perk(perk);

self vending_set_hintstring(perk);

for( ;; )
{
self waittill( "trigger", player );
index = maps\_zombiemode_weapons::get_player_index(player);

cost = level.zombie_vars["zombie_perk_cost"];
switch( perk )
{
case "specialty_armorvest":
cost = 3000;
break;

case "specialty_leadfoot":
cost = 2750;
break;


case "specialty_quickrevive":
players = get_players();
if(players.size == 1)
{
cost = 500;
self.reviveUsesLeft--;
}
else
cost = 1500;
break;

case "specialty_fastreload":
cost = 3500;
break;

case "specialty_rof":
cost = 2750;
break;

}

if (player maps\_laststand::player_is_in_laststand() )
{
continue;
}

if(player in_revive_trigger())
{
continue;
}

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

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

if ( player HasPerk( perk ) )
{
cheat = false;

/#
if ( GetDVarInt( "zombie_cheat" ) >= 5 )
{
cheat = true;
}
#/

if ( cheat != true )
{
//player iprintln( "Already using Perk: " + perk );
self playsound("deny");
player thread play_no_money_perk_dialog();


continue;
}
}

if ( player.score < cost )
{
//player iprintln( "Not enough points to buy Perk: " + perk );
self playsound("deny");
player thread play_no_money_perk_dialog();
continue;
}

sound = "bottle_dispense3d";
player achievement_notify( "perk_used" );
playsoundatposition(sound, self.origin);
player maps\_zombiemode_score::minus_to_player_score( cost );
///bottle_dispense
switch( perk )
{
case "specialty_armorvest":
sound = "mx_jugger_sting";
break;

case "specialty_quickrevive":
sound = "mx_revive_sting";
break;

case "specialty_fastreload":
sound = "mx_speed_sting";
break;

case "specialty_rof":
sound = "mx_doubletap_sting";
break;

default:
sound = "mx_jugger_sting";
break;
}

self thread play_vendor_stings(sound);

// self waittill("sound_done");


// do the drink animation
gun = player perk_give_bottle_begin( perk );
player.is_drinking = 1;
player waittill_any( "fake_death", "death", "player_downed", "weapon_change_complete" );

// restore player controls and movement
player perk_give_bottle_end( gun, perk );
player.is_drinking = undefined;
// TODO: race condition?
if ( player maps\_laststand::player_is_in_laststand() )
{
continue;
}

player SetPerk( perk );
player thread perk_vo(perk);
player setblur( 4, 0.1 );
wait(0.1);
player setblur(0, 0.1);
//earthquake (0.4, 0.2, self.origin, 100);
if(perk == "specialty_armorvest")
{
player.maxhealth = level.zombie_vars["zombie_perk_juggernaut_health"];
player.health = level.zombie_vars["zombie_perk_juggernaut_health"];
//player.health = 160;
}


player perk_hud_create( perk );

//stat tracking
player.stats["perks"]++;

//player iprintln( "Bought Perk: " + perk );
bbPrint( "zombie_uses: playername %s playerscore %d round %d cost %d name %s x %f y %f z %f type perk",
player.playername, player.score, level.round_number, cost, perk, self.origin );

player thread perk_think( perk );

}
}
play_no_money_perk_dialog()
{

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

player_index = "plr_" + index + "_";
if(!IsDefined (self.vox_nomoney_perk))
{
num_variants = maps\_zombiemode_spawner::get_number_variants(player_index + "vox_nomoney_perk");
self.vox_nomoney_perk = [];
for(i=0;i<num_variants;i++)
{
self.vox_nomoney_perk[self.vox_nomoney_perk.size] = "vox_nomoney_perk_" + i;
}
self.vox_nomoney_perk_available = self.vox_nomoney_perk;
}
sound_to_play = random(self.vox_nomoney_perk_available);

self.vox_nomoney_perk_available = array_remove(self.vox_nomoney_perk_available,sound_to_play);

if (self.vox_nomoney_perk_available.size < 1 )
{
self.vox_nomoney_perk_available = self.vox_nomoney_perk;
}

self maps\_zombiemode_spawner::do_player_playdialog(player_index, sound_to_play, 0.25);




}
check_player_has_perk(perk)
{
/#
if ( GetDVarInt( "zombie_cheat" ) >= 5 )
{
return;
}
#/

dist = 128 * 128;
while(true)
{
players = get_players();
for( i = 0; i < players.size; i++ )
{
if(DistanceSquared( players[i].origin, self.origin ) < dist)
{
if(!players[i] hasperk(perk) && !(players[i] in_revive_trigger())  && (players[i].perk_hud.size < level.perk_limit) && self.reviveUsesLeft > 0)
{
//PI CHANGE: this change makes it so that if there are multiple players within the trigger for the perk machine, the hint string is still
//                   visible to all of them, rather than the last player this check is done for
if (IsDefined(level.script) && level.script == "nazi_zombie_theater")
self setinvisibletoplayer(players[i], false);
else
self setvisibletoplayer(players[i]);
//END PI CHANGE
//iprintlnbold("turn it off to player");

}
else
{
self SetInvisibleToPlayer(players[i]);
//iprintlnbold(players[i].health);
}
}


}

wait(0.1);

}

}


vending_set_hintstring( perk )
{
switch( perk )
{

case "specialty_armorvest":
self SetHintString( &"ZOMBIE_PERK_JUGGERNAUT" );
break;

case "specialty_leadfoot":
self SetHintString( &"Press & Hold &&1 to buy Pushing Daisies Dubonnet" );
break;


case "specialty_quickrevive":
flag_wait( "all_players_connected" );
players = get_players();
if(players.size == 1)
{
self SetHintString( "Press & Hold &&1 to buy Revive Soda [Cost: 500]" );
self.reviveUsesLeft = 3;
}
else
self SetHintString( &"ZOMBIE_PERK_QUICKREVIVE" );
break;

case "specialty_fastreload":
self SetHintString( &"ZOMBIE_PERK_FASTRELOAD" );
break;

case "specialty_rof":
self SetHintString( &"ZOMBIE_PERK_DOUBLETAP" );
break;

default:
self SetHintString( perk + " Cost: " + level.zombie_vars["zombie_perk_cost"] );
break;

}
}


perk_think( perk )
{
/#
if ( GetDVarInt( "zombie_cheat" ) >= 5 )
{
if ( IsDefined( self.perk_hud[ perk ] ) )
{
return;
}
}
#/

self waittill_any( "fake_death", "death", "player_downed" );

self UnsetPerk( perk );
self.maxhealth = 100;
self perk_hud_destroy( perk );
//self iprintln( "Perk Lost: " + perk );
}


perk_hud_create( perk )
{
if ( !IsDefined( self.perk_hud ) )
{
self.perk_hud = [];
}

/#
if ( GetDVarInt( "zombie_cheat" ) >= 5 )
{
if ( IsDefined( self.perk_hud[ perk ] ) )
{
return;
}
}
#/


shader = "";

switch( perk )
{
case "specialty_armorvest":
shader = "specialty_juggernaut_zombies";
break;

case "specialty_leadfoot":
shader = "vending_push_shader";
break;

case "specialty_quickrevive":
shader = "specialty_quickrevive_zombies";
break;

case "specialty_fastreload":
shader = "specialty_fastreload_zombies";
break;

case "specialty_rof":
shader = "specialty_doubletap_zombies";
break;

default:
shader = "";
break;
}

hud = create_simple_hud( self );
hud.foreground = true;
hud.sort = 1;
hud.hidewheninmenu = false;
hud.alignX = "left";
hud.alignY = "bottom";
hud.horzAlign = "left";
hud.vertAlign = "bottom";
hud.x = self.perk_hud.size * 30;
hud.y = hud.y - 70;
hud.alpha = 1;
hud SetShader( shader, 24, 24 );

self.perk_hud[ perk ] = hud;
}


perk_hud_destroy( perk )
{
self.perk_hud[ perk ] destroy_hud();
self.perk_hud[ perk ] = undefined;
}

perk_give_bottle_begin( perk )
{
self DisableOffhandWeapons();
self DisableWeaponCycling();

self AllowLean( false );
self AllowAds( false );
self AllowSprint( true );
self AllowProne( true );
self AllowMelee( true );

wait( 0.05 );

if ( self GetStance() == "prone" )
{
self SetStance( "crouch" );
}

gun = self GetCurrentWeapon();
weapon = "";

switch( perk )
{
case "specialty_armorvest":
weapon = "zombie_perk_bottle_jugg";
break;

case "specialty_leadfoot":
weapon = "zombie_perk_bottle_jugg";
break;

case "specialty_quickrevive":
weapon = "zombie_perk_bottle_revive";
break;

case "specialty_fastreload":
weapon = "zombie_perk_bottle_sleight";
break;

case "specialty_rof":
weapon = "zombie_perk_bottle_doubletap";
break;
}

self GiveWeapon( weapon );
self SwitchToWeapon( weapon );

return gun;
}


perk_give_bottle_end( gun, perk )
{
assert( gun != "zombie_perk_bottle_doubletap" );
assert( gun != "zombie_perk_bottle_revive" );
assert( gun != "zombie_perk_bottle_jugg" );
assert( gun != "zombie_perk_bottle_sleight" );
assert( gun != "syrette" );

self EnableOffhandWeapons();
self EnableWeaponCycling();

self AllowLean( true );
self AllowAds( true );
self AllowSprint( true );
self AllowProne( true );
self AllowMelee( true );
weapon = "";
switch( perk )
{
case "specialty_armorvest":
weapon = "zombie_perk_bottle_jugg";
break;

case "specialty_leadfoot":
weapon = "zombie_perk_bottle_jugg";
break;

case "specialty_quickrevive":
weapon = "zombie_perk_bottle_revive";
break;

case "specialty_fastreload":
weapon = "zombie_perk_bottle_sleight";
break;

case "specialty_rof":
weapon = "zombie_perk_bottle_doubletap";
break;
}

// TODO: race condition?
if ( self maps\_laststand::player_is_in_laststand() )
{
self TakeWeapon(weapon);
return;
}

if ( gun != "none" && gun != "mine_bouncing_betty" )
{
self SwitchToWeapon( gun );
}
else
{
// try to switch to first primary weapon
primaryWeapons = self GetWeaponsListPrimaries();
if( IsDefined( primaryWeapons ) && primaryWeapons.size > 0 )
{
self SwitchToWeapon( primaryWeapons[0] );
}
}

self TakeWeapon(weapon);
}

perk_vo(type)
{
self endon("death");
self endon("disconnect");

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

if(!isdefined (level.player_is_speaking))
{
level.player_is_speaking = 0;
}
player_index = "plr_" + index + "_";
//wait(randomfloatrange(1,2));

//TUEY We need to eventually store the dialog in an array so you can add multiple variants...but we only have 1 now anyway.
switch(type)
{
case "specialty_armorvest":
sound_to_play = "vox_perk_jugga_0";
break;
case "specialty_fastreload":
sound_to_play = "vox_perk_speed_0";
break;
case "specialty_quickrevive":
sound_to_play = "vox_perk_revive_0";
break;
case "specialty_rof":
sound_to_play = "vox_perk_doubletap_0";
break;
default:
sound_to_play = "vox_perk_jugga_0";
break;
}

wait(1.0);
self maps\_zombiemode_spawner::do_player_playdialog(player_index, sound_to_play, 0.25);
}
machine_watcher()
{
//PI ESM - support for two level switches for Factory
if (isDefined(level.DLC3.perksNeedPowerOn) && level.DLC3.perksNeedPowerOn)
{
level thread machine_watcher_factory("juggernog_on");
level thread machine_watcher_factory("sleight_on");
level thread machine_watcher_factory("doubletap_on");
level thread machine_watcher_factory("revive_on");
level thread machine_watcher_factory("Pack_A_Punch_on");
}
else
{
level waittill("master_switch_activated");
//array_thread(getentarray( "zombie_vending", "targetname" ), ::perks_a_cola_jingle);

}

}

//PI ESM - added for support for two switches in factory
machine_watcher_factory(vending_name)
{
level waittill(vending_name);
switch(vending_name)
{
case "juggernog_on":
temp_script_sound = "mx_jugger_jingle"; break;

case "sleight_on":
temp_script_sound = "mx_speed_jingle";
break;

case "doubletap_on":
temp_script_sound = "mx_doubletap_jingle";
break;

case "revive_on":
temp_script_sound = "mx_revive_jingle";
break;

case "Pack_A_Punch_on":
temp_script_sound = "mx_packa_jingle";
break;

default:
temp_script_sound = "mx_jugger_jingle";
break;
}


temp_machines = getstructarray("perksacola", "targetname");
for (x = 0; x < temp_machines.size; x++)
{
if (temp_machines[x].script_sound == temp_script_sound)
temp_machines[x] thread perks_a_cola_jingle();
}

}

play_vendor_stings(sound)
{
if(!IsDefined (level.speed_jingle))
{
level.speed_jingle = 0;
}
if(!IsDefined (level.revive_jingle))
{
level.revive_jingle = 0;
}
if(!IsDefined (level.doubletap_jingle))
{
level.doubletap_jingle = 0;
}
if(!IsDefined (level.jugger_jingle))
{
level.jugger_jingle = 0;
}
if(!IsDefined (level.packa_jingle))
{
level.packa_jingle = 0;
}
if(!IsDefined (level.eggs))
{
level.eggs = 0;
}
if (level.eggs == 0)
{
if(sound == "mx_speed_sting" && level.speed_jingle == 0 )
{
// iprintlnbold("stinger speed:" + level.speed_jingle);
level.speed_jingle = 1;
temp_org_speed_s = spawn("script_origin", self.origin);
temp_org_speed_s playsound (sound, "sound_done");
temp_org_speed_s waittill("sound_done");
level.speed_jingle = 0;
temp_org_speed_s delete();
// iprintlnbold("stinger speed:" + level.speed_jingle);
}
else if(sound == "mx_revive_sting" && level.revive_jingle == 0)
{
level.revive_jingle = 1;
// iprintlnbold("stinger revive:" + level.revive_jingle);
temp_org_revive_s = spawn("script_origin", self.origin);
temp_org_revive_s playsound (sound, "sound_done");
temp_org_revive_s waittill("sound_done");
level.revive_jingle = 0;
temp_org_revive_s delete();
// iprintlnbold("stinger revive:" + level.revive_jingle);
}
else if(sound == "mx_doubletap_sting" && level.doubletap_jingle == 0)
{
level.doubletap_jingle = 1;
// iprintlnbold("stinger double:" + level.doubletap_jingle);
temp_org_dp_s = spawn("script_origin", self.origin);
temp_org_dp_s playsound (sound, "sound_done");
temp_org_dp_s waittill("sound_done");
level.doubletap_jingle = 0;
temp_org_dp_s delete();
// iprintlnbold("stinger double:" + level.doubletap_jingle);
}
else if(sound == "mx_jugger_sting" && level.jugger_jingle == 0)
{
level.jugger_jingle = 1;
// iprintlnbold("stinger juggernog" + level.jugger_jingle);
temp_org_jugs_s = spawn("script_origin", self.origin);
temp_org_jugs_s playsound (sound, "sound_done");
temp_org_jugs_s waittill("sound_done");
level.jugger_jingle = 0;
temp_org_jugs_s delete();
// iprintlnbold("stinger juggernog:"  + level.jugger_jingle);
}
else if(sound == "mx_packa_sting" && level.packa_jingle == 0)
{
level.packa_jingle = 1;
// iprintlnbold("stinger packapunch:" + level.packa_jingle);
temp_org_pack_s = spawn("script_origin", self.origin);
temp_org_pack_s playsound (sound, "sound_done");
temp_org_pack_s waittill("sound_done");
level.packa_jingle = 0;
temp_org_pack_s delete();
// iprintlnbold("stinger packapunch:"  + level.packa_jingle);
}
}
}

perks_a_cola_jingle()
{
self thread play_random_broken_sounds();
if(!IsDefined(self.perk_jingle_playing))
{
self.perk_jingle_playing = 0;
}
if (!IsDefined (level.eggs))
{
level.eggs = 0;
}
while(1)
{
//wait(randomfloatrange(60, 120));
wait(randomfloatrange(31,45));
if(randomint(100) < 15 && level.eggs == 0)
{
level notify ("jingle_playing");
//playfx (level._effect["electric_short_oneshot"], self.origin);
playsoundatposition ("electrical_surge", self.origin);

if(self.script_sound == "mx_speed_jingle" && level.speed_jingle == 0)
{
level.speed_jingle = 1;
temp_org_speed = spawn("script_origin", self.origin);
wait(0.05);
temp_org_speed playsound (self.script_sound, "sound_done");
temp_org_speed waittill("sound_done");
level.speed_jingle = 0;
temp_org_speed delete();
}
if(self.script_sound == "mx_revive_jingle" && level.revive_jingle == 0)
{
level.revive_jingle = 1;
temp_org_revive = spawn("script_origin", self.origin);
wait(0.05);
temp_org_revive playsound (self.script_sound, "sound_done");
temp_org_revive waittill("sound_done");
level.revive_jingle = 0;
temp_org_revive delete();
}
if(self.script_sound == "mx_doubletap_jingle" && level.doubletap_jingle == 0)
{
level.doubletap_jingle = 1;
temp_org_doubletap = spawn("script_origin", self.origin);
wait(0.05);
temp_org_doubletap playsound (self.script_sound, "sound_done");
temp_org_doubletap waittill("sound_done");
level.doubletap_jingle = 0;
temp_org_doubletap delete();
}
if(self.script_sound == "mx_jugger_jingle" && level.jugger_jingle == 0)
{
level.jugger_jingle = 1;
temp_org_jugger = spawn("script_origin", self.origin);
wait(0.05);
temp_org_jugger playsound (self.script_sound, "sound_done");
temp_org_jugger waittill("sound_done");
level.jugger_jingle = 0;
temp_org_jugger delete();
}
if(self.script_sound == "mx_packa_jingle" && level.packa_jingle == 0)
{
level.packa_jingle = 1;
temp_org_packa = spawn("script_origin", self.origin);
temp_org_packa playsound (self.script_sound, "sound_done");
temp_org_packa waittill("sound_done");
level.packa_jingle = 0;
temp_org_packa delete();
}

self thread play_random_broken_sounds();
}
}
}
play_random_broken_sounds()
{
level endon ("jingle_playing");
if (!isdefined (self.script_sound))
{
self.script_sound = "null";
}
if (self.script_sound == "mx_revive_jingle")
{
while(1)
{
wait(randomfloatrange(7, 18));
playsoundatposition ("broken_random_jingle", self.origin);
//playfx (level._effect["electric_short_oneshot"], self.origin);
playsoundatposition ("electrical_surge", self.origin);

}
}
else
{
while(1)
{
wait(randomfloatrange(7, 18));
// playfx (level._effect["electric_short_oneshot"], self.origin);
playsoundatposition ("electrical_surge", self.origin);
}
}
}

play_packa_wait_dialog(player_index)
{
waittime = 0.05;
if(!IsDefined (self.vox_perk_packa_wait))
{
num_variants = maps\_zombiemode_spawner::get_number_variants(player_index + "vox_perk_packa_wait");
self.vox_perk_packa_wait = [];
for(i=0;i<num_variants;i++)
{
self.vox_perk_packa_wait[self.vox_perk_packa_wait.size] = "vox_perk_packa_wait_" + i;
}
self.vox_perk_packa_wait_available = self.vox_perk_packa_wait;
}
if(!isdefined (level.player_is_speaking))
{
level.player_is_speaking = 0;
}
sound_to_play = random(self.vox_perk_packa_wait_available);
self maps\_zombiemode_spawner::do_player_playdialog(player_index, sound_to_play, waittime);
self.vox_perk_packa_wait_available = array_remove(self.vox_perk_packa_wait_available,sound_to_play);

if (self.vox_perk_packa_wait_available.size < 1 )
{
self.vox_perk_packa_wait_available = self.vox_perk_packa_wait;
}
}

play_packa_get_dialog(player_index)
{
waittime = 0.05;
if(!IsDefined (self.vox_perk_packa_get))
{
num_variants = maps\_zombiemode_spawner::get_number_variants(player_index + "vox_perk_packa_get");
self.vox_perk_packa_get = [];
for(i=0;i<num_variants;i++)
{
self.vox_perk_packa_get[self.vox_perk_packa_get.size] = "vox_perk_packa_get_" + i;
}
self.vox_perk_packa_get_available = self.vox_perk_packa_get;
}
if(!isdefined (level.player_is_speaking))
{
level.player_is_speaking = 0;
}
sound_to_play = random(self.vox_perk_packa_get_available);
self maps\_zombiemode_spawner::do_player_playdialog(player_index, sound_to_play, waittime);
self.vox_perk_packa_get_available = array_remove(self.vox_perk_packa_get_available,sound_to_play);

if (self.vox_perk_packa_get_available.size < 1 )
{
self.vox_perk_packa_get_available = self.vox_perk_packa_get;
}
}

players_daisies()
{
players = getPlayers();
for (i=0; i<players.size; i++)
{
players[i] pushing_daisies();
}
}

pushing_daisies()
{
while(true)
{
if (self maps\_laststand::player_is_in_laststand() && self hasperk ( "specialty_leadfoot" ))
{
IPrintLnBold("Pushing Daisies Acticated");
self thread nuke_explosion();
wait 10;
}
wait 0.1;
}
}

nuke_explosion()
{
zombies = getaispeciesarray("axis");
zombies = get_array_of_closest( self.origin, zombies );

for (i = 0; i < zombies.size; i++)
{
wait (randomfloatrange(0.1, 0.7));
if( !IsDefined( zombies[i] ) )
{
continue;
}

if( zombies[i].animname == "boss_zombie" )
{
continue;
}

if( is_magic_bullet_shield_enabled( zombies[i] ) )
{
continue;
}

if( i < 5 && !( zombies[i] enemy_is_dog() ) )
{
zombies[i] thread animscripts\death::flame_death_fx();
}

if( !( zombies[i] enemy_is_dog() ) )
{
zombies[i] maps\_zombiemode_spawner::zombie_head_gib();
}

zombies[i] dodamage( zombies[i].health + 666, zombies[i].origin );
playsoundatposition( "nuked", zombies[i].origin );
}
}

Ill see what i can do about the crashing, i have a theory as to what the problem is.

 
Loading ...