UGX-Mods

Call of Duty: Black Ops 3 => Tutorial Desk => Scripting => Topic started by: Rampage_619 on October 05, 2016, 01:55:47 am

Title: BO3 Zombie Counter
Post by: Rampage_619 on October 05, 2016, 01:55:47 am
Zombie Counter for BO3 Custom maps

(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fimage.prntscr.com%2Fimage%2F49c42a98b37641b7b970962ef7dbbf89.jpg&hash=68dc6e039c184a6703da51513dc2f11b)

(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fimage.prntscr.com%2Fimage%2F76d852f627284829beb5b91f296bd04d.jpg&hash=301c16479cbf7b646566ad771934d584)


Go to Root>usermaps>zm_yourmapname(open the folder corresponding with your map)

Open zm_yourmapname.gsc

Find the following function
function main()

add the following line inside
zombiesleft_hud();

so it should look like this
function main()
{
zm_usermap::main();

level._zombie_custom_add_weapons =&custom_add_weapons;

//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
//Zombie Counter
zombiesleft_hud();


// Added to allow On spawned functionality
callback::on_spawned( &on_player_spawned );

// Change this to TRUE if you would like the Weapon Box to spawn in a random location other than _start

level.random_pandora_box_start = false;


}

Now go to the bottom of the file and copy and paste the following code

// Zombie Counter 1.0
function zombiesleft_hud()
{   
//Rampage_619: Beta 1.0
//Rampage_619: play with the x value to move the hud left and right
// Rampage_619: increase the " Remaining.x" if the numbers start to overlay
// Rampage_619: play with the Y value to push the hud up and down

Remaining = create_simple_hud();
  Remaining.horzAlign = "center";
  Remaining.vertAlign = "middle";
    Remaining.alignX = "middle";
    Remaining.alignY = "middle";
    Remaining.y = 230;
    Remaining.x = 5;
    Remaining.foreground = 1;
    Remaining.fontscale = 2.0;
    Remaining.alpha = 1;
    Remaining.color = ( 0.423, 0.004, 0 );


    ZombiesLeft = create_simple_hud();
    ZombiesLeft.horzAlign = "center";
    ZombiesLeft.vertAlign = "middle";
    ZombiesLeft.alignX = "right";
    ZombiesLeft.alignY = "middle";
    ZombiesLeft.y = 230;
    ZombiesLeft.x = -1;
    ZombiesLeft.foreground = 1;
    ZombiesLeft.fontscale = 2.0;
    ZombiesLeft.alpha = 1;
    ZombiesLeft.color = ( 0.423, 0.004, 0 );
    ZombiesLeft SetText("Zombies Left: ");


while(1)
{
//level.zombie_total = get_zombie_count_for_round( level.round_number, level.players.size );
//zw_total = zombie_utility::get_current_actor_count();
remainingZw = get_zw_count();
//= zw_total;
Remaining SetValue(remainingZw);

if(remainingZw ==  0 )
{
Remaining.alpha = 0;
ZombiesLeft.alpha = 0;
while(1)
{
remainingZw = get_zw_count();
//= zw_total;
Remaining SetValue(remainingZw);

if(remainingZw != 0  )
{
Remaining.alpha = 1;
ZombiesLeft.alpha = 1;                     
break;
}
wait 0.05;
}
}
wait 0.5;
}
}

function get_zw_count()
{
enemies = [];
level.current_zw_array = [];
enemies = GetAiSpeciesArray( level.zombie_team, "all" );

for( i = 0; i < enemies.size; i++ )
{
if ( IS_TRUE( enemies[i].ignore_enemy_count ) )
{
continue;
}
ARRAY_ADD( level.current_zw_array, enemies[i] );
}

level.current_zw_count = level.current_zw_array.size;

return level.current_zw_count;
}
function create_simple_hud( client, team )
{
if ( IsDefined( team ) )
{
hud = NewTeamHudElem( team );
hud.team = team;
}
else
{
if( IsDefined( client ) )
{
hud = NewClientHudElem( client );
}
else
{
hud = NewHudElem();
}
}

level.hudelem_count++;

hud.foreground = true;
hud.sort = 1;
hud.hidewheninmenu = false;

return hud;
}

Use launcher to select your map and only check the link option and build.

Will be updating this with more color tuts and different designs.

Post comments if any issue persists.

Title: Re: BO3 Zombie Counter
Post by: SponsoredByCloro on October 05, 2016, 08:31:30 pm
Good work, anyway we can change the "Souls Needed" text to just "Zombies Left"?
Title: Re: BO3 Zombie Counter
Post by: ZombieKills on October 05, 2016, 10:18:24 pm
Good work, anyway we can change the "Souls Needed" text to just "Zombies Left"?
In the script it looks like it already is, but all you need to do is change what is in the parenthesis after SetText
Title: Re: BO3 Zombie Counter
Post by: Tomzen on October 09, 2016, 08:52:23 am
Using this script apparently breaks triggers. Me and a friend had to remove it in order for custom triggers to work.
Title: Re: BO3 Zombie Counter
Post by: reckfullies on October 10, 2016, 11:47:12 am
Using this script apparently breaks triggers. Me and a friend had to remove it in order for custom triggers to work.

This shouldn't break triggers since it doesn't reference them in any way.

The problem might be is you are not threading the function, OP should update the script.

This would only be a problem if you are trying to initialize other scripts/functions below this one, which is probably what you are doing if you have custom triggers.

Change the main function to this:
function main()
{
zm_usermap::main();

level._zombie_custom_add_weapons =&custom_add_weapons;

//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
//Zombie Counter
thread zombiesleft_hud();


// Added to allow On spawned functionality
callback::on_spawned( &on_player_spawned );

// Change this to TRUE if you would like the Weapon Box to spawn in a random location other than _start

level.random_pandora_box_start = false;
}
Title: Re: BO3 Zombie Counter
Post by: DuBCraft21 on October 11, 2016, 11:57:33 pm
I have a bit of a question... why in the get_zw_count function, why do you write:

	if ( IS_TRUE( enemies[i].ignore_enemy_count ) )
{
continue;
}
ARRAY_ADD( level.current_zw_array, enemies[i] );
}

level.current_zw_count = level.current_zw_array.size;
return level.current_zw_count;

instead of:

	if ( IS_TRUE( enemies[i].ignore_enemy_count ) )
{
continue;
}
level.current_zw_count++;
}
return level.current_zw_count;

This way is more efficient because the game doesn't need to handle memory allocation, as well as the counter which in your code is just hidden in the array. This is also more efficient because it doesn't have to handle as many function calls as the currently standing code does.
Title: Re: BO3 Zombie Counter
Post by: kaizokuroof on October 12, 2016, 08:25:29 am
First of all - Thanks for releasing your script! Second of all, is this script just counting the zombies that have spawned? So it's max number would be that of 24 (the total possible instances of zombies on a map at one time).

Not a true representation of the zombies to go?


Snippy

I tried replacing your code, but it did not work for me?
Title: Re: BO3 Zombie Counter
Post by: Rampage_619 on October 12, 2016, 07:06:59 pm
First of all - Thanks for releasing your script! Second of all, is this script just counting the zombies that have spawned? So it's max number would be that of 24 (the total possible instances of zombies on a map at one time).

Not a true representation of the zombies to go?


I tried replacing your code, but it did not work for me?

this script is to get the total amount of zombies for the round, not the total amount of zombies alive.
Title: Re: BO3 Zombie Counter
Post by: Rampage_619 on October 12, 2016, 07:09:07 pm
I have a bit of a question... why in the get_zw_count function, why do you write:

	if ( IS_TRUE( enemies[i].ignore_enemy_count ) )
{
continue;
}
ARRAY_ADD( level.current_zw_array, enemies[i] );
}

level.current_zw_count = level.current_zw_array.size;
return level.current_zw_count;

instead of:

	if ( IS_TRUE( enemies[i].ignore_enemy_count ) )
{
continue;
}
level.current_zw_count++;
}
return level.current_zw_count;

This way is more efficient because the game doesn't need to handle memory allocation, as well as the counter which in your code is just hidden in the array. This is also more efficient because it doesn't have to handle as many function calls as the currently standing code does.

Dubcraft, why increase it one by one, when you can just take the entire array......
Title: Re: BO3 Zombie Counter
Post by: reckfullies on October 13, 2016, 04:33:38 pm
Dubcraft, why increase it one by one, when you can just take the entire array......

There is no point in using an array if you are still going to get the same results using an integer variable along with presumably better code performance.

It is essentially the same except you are getting the array every time when you could just be adding to a variable.
Title: Re: BO3 Zombie Counter
Post by: Minepro14 on November 12, 2016, 05:49:04 pm
what i should change if i want that the counter shows me the total amount of zombies of the round??
Title: Re: BO3 Zombie Counter
Post by: SponsoredByCloro on November 21, 2016, 05:28:34 pm
The script just counts how many zombies are alive, not how many left in the current round.
Title: Re: BO3 Zombie Counter
Post by: Rosasau100 on January 16, 2017, 05:09:23 pm
this script is to get the total amount of zombies for the round, not the total amount of zombies alive.

Then it is not doing what it is suppose to, it just counts the zombies that are currently alive