UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: InFInIX on March 21, 2014, 07:19:31 pm

Title: [Tutorial]Zombie counter
Post by: InFInIX on March 21, 2014, 07:19:31 pm
Go to mapname.gsc

and add this to the bottom

Code Snippet
Plaintext
zombiesleft_hud()
{   
Remaining = create_simple_hud();
  Remaining.horzAlign = "center";
  Remaining.vertAlign = "middle";
    Remaining.alignX = "Left";
    Remaining.alignY = "middle";
    Remaining.y = 230;
    Remaining.x = 60;
    Remaining.foreground = 1;
    Remaining.fontscale = 8.0;
    Remaining.alpha = 1;
    Remaining.color = ( 0.423, 0.004, 0 );


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


while(1)
{
remainingZombies = get_enemy_count() + level.zombie_total;
Remaining SetValue(remainingZombies);

if(remainingZombies == 0 )
{
Remaining.alpha = 0;
while(1)
{
remainingZombies = get_enemy_count() + level.zombie_total;
if(remainingZombies != 0 )
{
Remaining.alpha = 1;
break;
}
wait 0.5;
}
}
wait 0.5;
}
}

now call the function after

Code Snippet
Plaintext
maps\_zombiemode::main(); 

with

Code Snippet
Plaintext
thread zombiesleft_hud();

If you want to change the text

search for

Code Snippet
Plaintext
ZombiesLeft SetText("Zombies Left: ");

And change the Zombies left:

WARNIG:

Leave the "" or you will get a bad syntax error

[Script by: Mrhankey91]
Title: Re: [Tutorial]Zombie counter
Post by: YaPh1l on March 21, 2014, 07:45:15 pm
I could be wrong, but I don't think this tutorial was made by you. In that case, you might want to credit the original creator.

- Phil.
Title: Re: [Tutorial]Zombie counter
Post by: daedra descent on March 21, 2014, 09:08:20 pm
Code Snippet
Plaintext
get_enemy_count()

Wouldn't this get all Axis characters in a level? Wouldn't it be more accurate to make it like this:

Code Snippet
Plaintext
zombiesleft_hud()
{   
Remaining = create_simple_hud();
  Remaining.horzAlign = "center";
  Remaining.vertAlign = "middle";
    Remaining.alignX = "Left";
    Remaining.alignY = "middle";
    Remaining.y = 230;
    Remaining.x = 60;
    Remaining.foreground = 1;
    Remaining.fontscale = 8.0;
    Remaining.alpha = 1;
    Remaining.color = ( 0.423, 0.004, 0 );


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


while(1)
{
level.zombie_total SetValue(level.zombie_total);

if(level.zombie_total == 0 )
{
Remaining.alpha = 0;
while(1)
{
if(level.zombie_total != 0 )
{
Remaining.alpha = 1;
break;
}
wait 0.5;
}
}
wait 0.5;
}
}
Title: Re: [Tutorial]Zombie counter
Post by: YaPh1l on March 21, 2014, 10:04:14 pm
Well, first of all, this is not going to work anyway:
Code Snippet
Plaintext
level.zombie_total SetValue(level.zombie_total);
And yes, get_enemy_count() returns all living axis AI, which is most likely what you want, as zombie_total is decremented when an AI spawns. That means, zombie_total + get_enemy_count() gives the number of zombies yet to spawn in this round plus the number of zombies currently alive, which is, in total, the number of zombies remaining to be killed this round.

- Phil.
Title: Re: [Tutorial]Zombie counter
Post by: treminaor on March 22, 2014, 08:28:34 am
Either your authorship needs to be proven or the original author needs to be credited before this can be moved to the tutorials section.