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

[TUT] Updated Power Ups HUD

broken avatar :(
Created 8 years ago
by Scobalula
0 Members and 1 Guest are viewing this topic.
4,653 views
broken avatar :(
×
broken avatar :(
OnionmanVere Bo21
Location: ieu dnt wnt 2 no
Date Registered: 27 September 2013
Last active: 1 year ago
Posts
1,864
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Mapper
My Groups
More
Personal Quote
ok
Signature
Aye mate you don't know me so y don't you shut tf up ok buddy :)

×
Scobalula's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Box Mappers Elite
Box Mappers Elite
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Scobalula's Contact & Social Links
shaders are not included. :gusta:


Updated HUD for danke display effect. Looks similar to BO2/3, gussssttttaaaaaaa.

Copy _zombiemode_powerups.gsc to your mods folder (or edit it from raw, don't really care, that's your call).

Find this and remove it:

Code Snippet
Plaintext
level thread powerup_hud_overlay();

Find the function called "init_powerups()" and replace it with this:

Code Snippet
Plaintext
init_powerups()
{
if( !IsDefined( level.zombie_powerup_array ) )
{
level.zombie_powerup_array = [];
}
if ( !IsDefined( level.zombie_special_drop_array ) )
{
level.zombie_special_drop_array = [];
}

// Random Drops
add_zombie_powerup( "nuke", "zombie_bomb", &"ZOMBIE_POWERUP_NUKE", "misc/fx_zombie_mini_nuke" );
add_zombie_powerup( "insta_kill", "zombie_skull", &"ZOMBIE_POWERUP_INSTA_KILL", undefined, "specialty_instakill_zombies", "zombie_powerup_insta_kill_time");
add_zombie_powerup( "double_points","zombie_x2_icon", &"ZOMBIE_POWERUP_DOUBLE_POINTS" , undefined, "specialty_doublepoints_zombies", "zombie_powerup_point_doubler_time" );
add_zombie_powerup( "full_ammo",  "zombie_ammocan", &"ZOMBIE_POWERUP_MAX_AMMO");
add_zombie_powerup( "carpenter",  "zombie_carpenter", &"ZOMBIE_POWERUP_MAX_AMMO");

// add_zombie_special_powerup( "monkey" );

// additional special "drops"
// add_zombie_special_drop( "nothing" );
add_zombie_special_drop( "dog" );

// Randomize the order
randomize_powerups();

level.zombie_powerup_index = 0;
randomize_powerups();



We have 2 new psh at the end:

Code Snippet
Plaintext
add_zombie_powerup( powerup_name, model_name, hint, fx, shader, timer_var )

We shall define our shader and timer variable here for danka obtaining effect.

Now find the function "add_zombie_powerup()" and replace it with this:

Code Snippet
Plaintext
add_zombie_powerup( powerup_name, model_name, hint, fx, shader, timer_var )
{
if( IsDefined( level.zombie_include_powerups ) && !IsDefined( level.zombie_include_powerups[powerup_name] ) )
{
return;
}

PrecacheModel( model_name );
PrecacheString( hint );

struct = SpawnStruct();

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

struct.powerup_name = powerup_name;
struct.model_name = model_name;
struct.weapon_classname = "script_model";
struct.hint = hint;
if(IsDefined(shader))
struct.shader = shader;
if(IsDefined(timer_var))
struct.timer = timer_var;

if( IsDefined( fx ) )
{
struct.fx = LoadFx( fx );
}

level.zombie_powerups[powerup_name] = struct;
level.zombie_powerup_array[level.zombie_powerup_array.size] = powerup_name;
add_zombie_special_drop( powerup_name );
}

Now find the function "powerup_hud_overlay()" and replace the entire function with this set of functions:


Code Snippet
Plaintext
RemovePowerUpHud( powerup_name )
{
for(i = 0; i < self.powerup_hud.size ; i++)
{
if(IsDefined(self.powerup_hud[i].powerup_name) && self.powerup_hud[i].powerup_name == powerup_name)
{
self.hud_is_being_deleted = true;
self.powerup_hud[i] notify("hud_gone");
// IPrintLnBold(self.powerup_hud[i].powerup_name ); // Debug Purposes
self.powerup_hud[i].alpha = 1;
wait 0.1;
self.powerup_hud[i] FadeOverTime(0.5);
self.powerup_hud[i].alpha = 0;
wait 0.6;
self.powerup_hud[i] destroy_hud();
self.powerup_hud[i] Delete();
self.powerup_hud = array_remove(self.powerup_hud, self.powerup_hud[i]);
self.current_powerups = array_remove(self.current_powerups, self.current_powerups[powerup_name]);
self.hud_is_being_deleted = false;
}
}

for(i = 0; i < self.powerup_hud.size ; i++)
self.powerup_hud[i] thread MoveThyHUD(i, self.powerup_hud.size);
}

CreatePowerUpHud( powerup )
{
if(IsDefined(self.current_powerups))
self.current_powerups = [];
if(!IsDefined( self.powerup_hud))
self.powerup_hud = [];

while(IsDefined(self.current_powerups[powerup])) // Check because from testing if the player is fast enough (Though very rare for it to happen), 2 elements can spawn for same HUD.
wait 0.05;

self.current_powerups[powerup] = create_simple_hud( self ); // Made Client HUD so we modify per player for things like Minigun, etc.
self.current_powerups[powerup].powerup_name = powerup;
self.current_powerups[powerup].foreground = true;
self.current_powerups[powerup].sort = 2;
self.current_powerups[powerup].hidewheninmenu = false;
self.current_powerups[powerup].alignX = "center";
self.current_powerups[powerup].alignY = "bottom";
self.current_powerups[powerup].horzAlign = "center";
self.current_powerups[powerup].vertAlign = "bottom";
self.current_powerups[powerup].x = self.current_powerups[powerup].x;
self.current_powerups[powerup].y = self.current_powerups[powerup].y - 35;
self.current_powerups[powerup].alpha = 0;
self.current_powerups[powerup] setshader(level.zombie_powerups[powerup].shader, 48, 48);
self.current_powerups[powerup] scaleOverTime( .3, 32, 32 );
self.current_powerups[powerup] FadeOverTime(0.3);
self.current_powerups[powerup].alpha = 1;
self.current_powerups[powerup] thread LowTimeFade();

self.powerup_hud[self.powerup_hud.size] = self.current_powerups[powerup];

for(i = 0; i < self.powerup_hud.size ; i++)
self.powerup_hud[i] thread MoveThyHUD(i, self.powerup_hud.size);
}

LowTimeFade()
{
self endon("hud_gone");
while(IsDefined(self))
{
self.timer = level.zombie_vars[level.zombie_powerups[self.powerup_name].timer];
if(self.timer < 5)
{
fade_time = 0.2;
}
else if(self.timer < 10)
{
fade_time = 0.6;
}
else
{
wait 0.1;
continue;
}

self FadeOverTime(fade_time);
self.alpha = 0.1;
wait fade_time;
self FadeOverTime(fade_time);
self.alpha = 1;
wait fade_time;

}
}

MoveThyHUD(i, array_size) // Mjáá
{
self MoveOverTime(0.5);
self.x = (24 + (-24 * array_size + (i * 48))); // Jáám
self.y = self.y;
}


The 2 functions "CreatePowerUpHud()" and "RemovePowerUpHud()" will allow us to create and remove our shaders, more info below.

F

Now we need to edit the Double Points and Insta Kill to use this so find the function called "insta_kill_powerup()" and replace it with this:

Code Snippet
Plaintext
insta_kill_powerup( drop_item )
{

power_up_name = drop_item.powerup_name;
level notify( "powerup instakill" );
level endon( "powerup instakill" );

// array_thread (players, ::insta_kill_on_hud, drop_item);
level thread insta_kill_on_hud( drop_item, power_up_name );

level.zombie_vars["zombie_insta_kill"] = 1;
wait( 30 );
level.zombie_vars["zombie_insta_kill"] = 0;
players = get_players();
for(i = 0; i < players.size; i++)
{
players[i] notify("insta_kill_over");
}

}

Now find "insta_kill_on_hud()" and replace with this:

Code Snippet
Plaintext
insta_kill_on_hud( drop_item, power_up_name )
{
self endon ("disconnect");

// check to see if this is on or not
if ( level.zombie_vars["zombie_powerup_insta_kill_on"] )
{
// reset the time and keep going
level.zombie_vars["zombie_powerup_insta_kill_time"] = 30;
return;
}

for( i = 0; i < GetPlayers().size; i ++ )
GetPlayers()[i] thread CreatePowerUpHud( power_up_name );

level.zombie_vars["zombie_powerup_insta_kill_on"] = true;

// set up the hudelem
//hudelem = maps\_hud_util::createFontString( "objective", 2 );
//hudelem maps\_hud_util::setPoint( "TOP", undefined, 0, level.zombie_vars["zombie_timer_offset"] + level.zombie_vars["zombie_timer_offset_interval"]);
//hudelem.sort = 0.5;
//hudelem.alpha = 0;
//hudelem fadeovertime(0.5);
//hudelem.alpha = 1;
//hudelem.label = drop_item.hint;

// set time remaining for insta kill
level thread time_remaning_on_insta_kill_powerup( drop_item, power_up_name );

// offset in case we get another powerup
//level.zombie_timer_offset -= level.zombie_timer_offset_interval;
}

You can see here were are calling it on ALL players, as you may have guessed the 2 functions above and all the stuff is player specific allowing use to have different shaders like Death Machine, etc. while other players don't, and allowing it to scale depending on what player has what for example a player has Insta, Death, and x2 but other will only have the 2 global ones it will show up fine specific to player and move specific to player, this has been tested in co-op and works. :)

Now find the function "time_remaning_on_insta_kill_powerup()" and replace with this:

Code Snippet
Plaintext
time_remaning_on_insta_kill_powerup( drop_item, power_up_name ) // Must pass on power_up_name from above for some reason or it won't work.
{
//self setvalue( level.zombie_vars["zombie_powerup_insta_kill_time"] );
level thread play_devil_dialog("insta_vox");
temp_enta = spawn("script_origin", (0,0,0));
temp_enta playloopsound("insta_kill_loop");

/*
players = get_players();
for (i = 0; i < players.size; i++)
{
players[i] playloopsound ("insta_kill_loop");
}
*/


// time it down!
while ( level.zombie_vars["zombie_powerup_insta_kill_time"] >= 0)
{
wait 0.1;
level.zombie_vars["zombie_powerup_insta_kill_time"] = level.zombie_vars["zombie_powerup_insta_kill_time"] - 0.1;
// self setvalue( level.zombie_vars["zombie_powerup_insta_kill_time"] );
}

players = get_players();
for (i = 0; i < players.size; i++)
{
//players[i] stoploopsound (2);

players[i] playsound("insta_kill");

}

temp_enta stoploopsound(2);
for( i = 0; i < GetPlayers().size; i ++ )
GetPlayers()[i] thread RemovePowerUpHud( power_up_name );
// turn off the timer
level.zombie_vars["zombie_powerup_insta_kill_on"] = false;

// remove the offset to make room for new powerups, reset timer for next time
level.zombie_vars["zombie_powerup_insta_kill_time"] = 30;

//level.zombie_timer_offset += level.zombie_timer_offset_interval;
//self destroy();
temp_enta delete();
}

As you see from some reason we must pass on the power up name from the main function for the power up so make sure to do that.

Now for the Double Points replace the "point_double_on_hud()" and 2 functions under it with this:

Code Snippet
Plaintext
point_doubler_on_hud( drop_item, power_up_name )
{
self endon ("disconnect");

// check to see if this is on or not
if ( level.zombie_vars["zombie_powerup_point_doubler_on"] )
{
// reset the time and keep going
level.zombie_vars["zombie_powerup_point_doubler_time"] = 30;
return;
}

for( i = 0; i < GetPlayers().size; i ++ )
GetPlayers()[i] thread CreatePowerUpHud( power_up_name );

level.zombie_vars["zombie_powerup_point_doubler_on"] = true;
//power_hud_array[0] = true;
// set up the hudelem
//hudelem = maps\_hud_util::createFontString( "objective", 2 );
//hudelem maps\_hud_util::setPoint( "TOP", undefined, 0, level.zombie_vars["zombie_timer_offset"] );
//hudelem.sort = 0.5;
//hudelem.alpha = 0;
//hudelem fadeovertime( 0.5 );
//hudelem.alpha = 1;
//hudelem.label = drop_item.hint;

// set time remaining for point doubler
level thread time_remaining_on_point_doubler_powerup( drop_item, power_up_name );

// offset in case we get another powerup
//level.zombie_timer_offset -= level.zombie_timer_offset_interval;
}
play_devil_dialog(sound_to_play)
{
if(!IsDefined(level.devil_is_speaking))
{
level.devil_is_speaking = 0;
}
if(level.devil_is_speaking == 0)
{
level.devil_is_speaking = 1;
play_sound_2D( sound_to_play );
wait 2.0;
level.devil_is_speaking =0;
}

}
time_remaining_on_point_doubler_powerup(drop_item, power_up_name)
{
//self setvalue( level.zombie_vars["zombie_powerup_point_doubler_time"] );

temp_ent = spawn("script_origin", (0,0,0));
temp_ent playloopsound ("double_point_loop");

level thread play_devil_dialog("dp_vox");


// time it down!
while ( level.zombie_vars["zombie_powerup_point_doubler_time"] >= 0)
{
wait 0.1;
level.zombie_vars["zombie_powerup_point_doubler_time"] = level.zombie_vars["zombie_powerup_point_doubler_time"] - 0.1;
//self setvalue( level.zombie_vars["zombie_powerup_point_doubler_time"] );
}

for( i = 0; i < GetPlayers().size; i ++ )
GetPlayers()[i] thread RemovePowerUpHud( power_up_name );

// turn off the timer
level.zombie_vars["zombie_powerup_point_doubler_on"] = false;
players = get_players();
for (i = 0; i < players.size; i++)
{
//players[i] stoploopsound("double_point_loop", 2);
players[i] playsound("points_loop_off");
}
temp_ent stoploopsound(2);



// remove the offset to make room for new powerups, reset timer for next time
level.zombie_vars["zombie_powerup_point_doubler_time"] = 30;
//level.zombie_timer_offset += level.zombie_timer_offset_interval;
//self destroy();
temp_ent delete();
}

And replace the main function for it called

Code Snippet
Plaintext
double_points_powerup( drop_item )
{

power_up_name = drop_item.powerup_name;
level notify ("powerup points scaled");
level endon ("powerup points scaled");

// players = get_players();
// array_thread(level,::point_doubler_on_hud, drop_item);
level thread point_doubler_on_hud( drop_item, power_up_name );

level.zombie_vars["zombie_point_scalar"] = 2;
wait 30;

level.zombie_vars["zombie_point_scalar"] = 1;
}

And that should be it, now for some explaining of the 2 functions.

Like I said these are player spefic, for general power ups like Double Points we simply call it like this on all players:

   for( i = 0; i < GetPlayers().size; i ++ )
      GetPlayers() thread CreatePowerUpHud( power_up_name );

And remove it like so:

Code Snippet
Plaintext
	for( i = 0; i < GetPlayers().size; i ++ )
GetPlayers()[i] thread RemovePowerUpHud( power_up_name );

You can also pass on the player from the switch statement and call it on them specifically and it will add and move only their HUD:

Code Snippet
Plaintext
player thread CreatePowerUpHud( power_up_name );


With the nature of pulling stuff out of GSCs there might be something I missed, let me know if there are any errors or bugs.

FAQ:

Spoiler: click to open...
Q: dis is my mums.

A: z__ :gusta: __z

Q: u stole this from me mum.

A: \_ :gusta: _/

Q: u stole this from my iwd

A: You script? \_________________ :gusta: _/

Q: I don't know how to use this with my custom power ups.

A: Contact me. :)


Enjoy!
Last Edit: October 23, 2016, 12:46:51 pm by Scobalula
broken avatar :(
×
broken avatar :(
Location: gbNewport
Date Registered: 2 November 2014
Last active: 2 years ago
Posts
1,265
Respect
Forum Rank
Zombie Colossus
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Embrace the Darkness
×
Tim Smith's Groups
Tim Smith's Contact & Social Linkstimsmith90THEREALBaDBoY17TimSmithMy clan Website
Pretty nice Good work man +1. Was actually thinking of doing it :).
broken avatar :(
  • steviewonder87
  • Deleted Member
×
broken avatar :(
steviewonder87
This user is deleted :(
Was actually thinking of doing it

???
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 7 May 2015
Last active: 11 days ago
Posts
312
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Signature
×
EmpGeneral's Groups
EmpGeneral's Contact & Social LinksldraweEletricStorm
Nice script man!But have a way to disable the insta_kill and double_points text when the powerup end?
broken avatar :(
×
broken avatar :(
OnionmanVere Bo21
Location: ieu dnt wnt 2 no
Date Registered: 27 September 2013
Last active: 1 year ago
Posts
1,864
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Mapper
My Groups
More
Personal Quote
ok
×
Scobalula's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Box Mappers Elite
Box Mappers Elite
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Scobalula's Contact & Social Links
Nice script man!But have a way to disable the insta_kill and double_points text when the powerup end?

Thanks, I must have left it in by mistake, in the Remove function remove the print:

Code Snippet
Plaintext
RemovePowerUpHud( powerup_name )
{
for(i = 0; i < self.powerup_hud.size ; i++)
{
if(IsDefined(self.powerup_hud[i].powerup_name) && self.powerup_hud[i].powerup_name == powerup_name)
{
self.hud_is_being_deleted = true;
self.powerup_hud[i] notify("hud_gone");
// IPrintLnBold(self.powerup_hud[i].powerup_name ); // Remove this by commenting it.
self.powerup_hud[i].alpha = 1;
wait 0.1;
self.powerup_hud[i] FadeOverTime(0.5);
self.powerup_hud[i].alpha = 0;
wait 0.6;
self.powerup_hud[i] destroy_hud();
self.powerup_hud[i] Delete();
self.powerup_hud = array_remove(self.powerup_hud, self.powerup_hud[i]);
self.current_powerups = array_remove(self.current_powerups, self.current_powerups[powerup_name]);
self.hud_is_being_deleted = false;
}
}

for(i = 0; i < self.powerup_hud.size ; i++)
self.powerup_hud[i] thread MoveThyHUD(i, self.powerup_hud.size);
}
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 7 May 2015
Last active: 11 days ago
Posts
312
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
EmpGeneral's Groups
EmpGeneral's Contact & Social LinksldraweEletricStorm
Thanks man  :) !

 
Loading ...