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

Make certain powerups rare and/or not appear until power is on.

HOT
broken avatar :(
Created 10 years ago
by ProGamerzFTW
0 Members and 1 Guest are viewing this topic.
4,816 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 10 October 2013
Last active: 4 months ago
Posts
541
Respect
Forum Rank
Zombie Enslaver
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
×
ProGamerzFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Ok something else it happening, it seems like having multiple while loops in get_next_powerup can only have one active at a time, causing the other powerup that isn't suppose to drop, drop.

I understand why it does this, as it doesnt continue a function unless a function is false.

What should I change to fix this? As in, how can I have multiple loops either "while" or something that works similar in one function, or if not possible, how would i run it in multiple threads?

here is part of the code :)

Code Snippet
Plaintext
while( powerup == "gtlad" && !flag("electricity_on") )
{


if( level.zombie_powerup_index >= level.zombie_powerup_array.size )
{
level.zombie_powerup_index = 0;
randomize_powerups();
}


powerup = level.zombie_powerup_array[level.zombie_powerup_index];
level.zombie_powerup_index++;

if( powerup != "gtlad" )
return powerup;


wait(0.05);
}
while( powerup == "fire_sale" && ( level.zombie_vars["zombie_powerup_fire_sale_on"] == true || level.chest_moved == false ) )
{


if( level.zombie_powerup_index >= level.zombie_powerup_array.size )
{
level.zombie_powerup_index = 0;
randomize_powerups();
}


powerup = level.zombie_powerup_array[level.zombie_powerup_index];
level.zombie_powerup_index++;

if( powerup != "fire_sale" )
return powerup;


wait(0.05);
}

Edit: I changed the way this check works, based on how black ops handles it, and it works fine.
Last Edit: March 27, 2014, 03:02:39 am by ProGamerzFTW
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 4 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Community Scripter Elite
My Groups
More
×
YaPh1l's Groups
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Edit: I changed the way this check works, based on how black ops handles it, and it works fine.
Yeah, that's probably a good idea. Would you maybe post your final working solution so this thread can be useful for others who want to do a similar thing?

- Phil.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 10 October 2013
Last active: 4 months ago
Posts
541
Respect
Forum Rank
Zombie Enslaver
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
×
ProGamerzFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Yeah, that's probably a good idea. Would you maybe post your final working solution so this thread can be useful for others who want to do a similar thing?

- Phil.

Sure.

Make sure you backup _zombiemode_powerups.gsc before doing this.

1. There should be three instances of

Code Snippet
Plaintext
powerup = get_next_powerup()

one of which is in the function powerup_setup() and two in special_drop_setup()

replace

Code Snippet
Plaintext
powerup = get_next_powerup()

with

Code Snippet
Plaintext
powerup = get_valid_powerup()

2. Replace the entire get_next_powerup() function with

Code Snippet
Plaintext
get_next_powerup()
{
powerup = level.zombie_powerup_array[ level.zombie_powerup_index ];

level.zombie_powerup_index++;
if( level.zombie_powerup_index >= level.zombie_powerup_array.size )
{
level.zombie_powerup_index = 0;
randomize_powerups();
}

return powerup;
}

3. Below this function place

Code Snippet
Plaintext
get_valid_powerup()
{
powerup = get_next_powerup();
while( 1 )
{
// Carpenter needs 5 destroyed windows
if( powerup == "carpenter" && get_num_window_destroyed() < 5 )
{
powerup = get_next_powerup();
}
else
{
return( powerup );
}
}
}

And if you are not adding any custom perks, you are done, otherwise continue below for an example on how to add custom perks to this function.

4. If you would like to add a custom powerup to this, lets say to add a random perk powerup with the name of "gtlad" to make it more rare and not drop until the power is on you would add

Code Snippet
Plaintext
		else if ( powerup == "gtlad" && ( randomint(100) > 25 || !flag("electricity_on") ) )
{
powerup = get_next_powerup();
}

after

Code Snippet
Plaintext
		if( powerup == "carpenter" && get_num_window_destroyed() < 5 )
{
powerup = get_next_powerup();
}

so it looks like

Code Snippet
Plaintext
get_valid_powerup()
{
powerup = get_next_powerup();
while( 1 )
{
// Carpenter needs 5 destroyed windows
if( powerup == "carpenter" && get_num_window_destroyed() < 5 )
{
powerup = get_next_powerup();
}
else if ( powerup == "gtlad" && ( randomint(100) > 25 || !flag("electricity_on") ) )
{
powerup = get_next_powerup();
}
else
{
return( powerup );
}
}
}

Where increasing the value 25 will make it less rare, and lowering it will make it more rare.

And you are done! :)

Last Edit: March 27, 2014, 07:21:46 pm by ProGamerzFTW

 
Loading ...