Modme Forums
Menu:

edit zombie counter script for custom hud

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: KillJoyYT

function _INIT_ZCOUNTER()
{
 ZombieCounterHuds = [];
 ZombieCounterHuds["LastZombieText"]  = "Kramer Left";
 ZombieCounterHuds["ZombieText"]   = "Kramer's Left";
 ZombieCounterHuds["LastDogText"]  = "Dog Left";
 ZombieCounterHuds["DogText"]   = "Dog's Left";
 ZombieCounterHuds["DefaultColor"]  = (255, 0, 0);
 ZombieCounterHuds["HighlightColor"]  = (255, 0, 0);
 ZombieCounterHuds["FontScale"]   = 2;
 ZombieCounterHuds["DisplayType"]  = 0; // 0 = Shows Total Zombies and Counts down, 1 = Shows Currently spawned zombie count
 ZombieCounterHuds["counter"] = createNewHudElement("middle", "top", 2, 10, 1, 1.5);
 ZombieCounterHuds["text"] = createNewHudElement("middle", "top", 2, 10, 1, 1.5);
 ZombieCounterHuds["counter"] hudRGBA(ZombieCounterHuds["DefaultColor"], 0);
 ZombieCounterHuds["text"] hudRGBA(ZombieCounterHuds["DefaultColor"], 0);
 level thread _THINK_ZCOUNTER(ZombieCounterHuds);
}
function _THINK_ZCOUNTER(hudArray)
{
 level endon("end_game");
 for(;;)
 {
  level waittill("start_of_round");
  level _ROUND_COUNTER(hudArray);
  hudArray["counter"] SetValue(0);
  hudArray["text"] thread hudMoveTo((2, 10, 0), 4);
  
  hudArray["counter"] thread hudRGBA(hudArray["DefaultColor"], 0, 1);
  hudArray["text"] SetText("End of round"); hudArray["text"] thread hudRGBA(hudArray["DefaultColor"], 0, 3);
 }
}
function _ROUND_COUNTER(hudArray)
{
 level endon("end_of_round");
 lastCount = 0;
 numberToString = "";
 hudArray["counter"] thread hudRGBA(hudArray["DefaultColor"], 1.0, 1);
 hudArray["text"] thread hudRGBA(hudArray["DefaultColor"], 1.0, 1);
 hudArray["text"] SetText(hudArray["ZombieText"]);
 if(level flag::get("dog_round"))
  hudArray["text"] SetText(hudArray["DogText"]);
 for(;;)
 {
  zm_count = (zombie_utility::get_current_zombie_count() + level.zombie_total);
  if(hudArray["DisplayType"] == 1) zm_count = zombie_utility::get_current_zombie_count();
  if(zm_count == 0) {wait(1); continue;}
  hudArray["counter"] SetValue(zm_count);
  if(lastCount != zm_count)
  {
   lastCount = zm_count;
   numberToString = "" + zm_count;
   hudArray["text"] thread hudMoveTo((10 + (4 * numberToString.Size), 10, 0), 4);
   if(zm_count == 1 && !level flag::get("dog_round")) hudArray["text"] SetText(hudArray["LastZombieText"]);
   else if(zm_count == 1 && level flag::get("dog_round")) hudArray["text"] SetText(hudArray["LastDogText"]);
   hudArray["counter"].color = hudArray["HighlightColor"]; hudArray["counter"].fontscale = (hudArray["FontScale"] + 0.5);
   hudArray["text"].color = hudArray["HighlightColor"]; hudArray["text"].fontscale = (hudArray["FontScale"] + 0.5);
   hudArray["counter"] thread hudRGBA(hudArray["DefaultColor"], 1, 0.5); hudArray["counter"] thread hudFontScale(hudArray["FontScale"], 0.5);
   hudArray["text"] thread hudRGBA(hudArray["DefaultColor"], 1, 0.5); hudArray["text"] thread hudFontScale(hudArray["FontScale"], 0.5);
  }
  wait(0.1);
 }
}
function createNewHudElement(xAlign, yAlign, posX, posY, foreground, fontScale)
{
 hud = newHudElem();
 hud.horzAlign = xAlign; hud.alignX = xAlign;
 hud.vertAlign = yAlign; hug.alignY = yAlign;
 hud.x = posX; hud.y = posY;
 hud.foreground = foreground;
 hud.fontscale = fontScale;
 return hud;
}
function hudRGBA(newColor, newAlpha, fadeTime)
{
 if(isDefined(fadeTime))
  self FadeOverTime(fadeTime);
 self.color = newColor;
 self.alpha = newAlpha;
}
function hudFontScale(newScale, fadeTime)
{
 if(isDefined(fadeTime))
  self ChangeFontScaleOverTime(fadeTime);
 self.fontscale = newScale;
}
function hudMoveTo(posVector, fadeTime) // Just because MoveOverTime doesn't always work as wanted
{
 initTime = GetTime();
 hudX = self.x;
 hudY = self.y;
 hudVector = (hudX, hudY, 0);
 while(hudVector != posVector)
 {
  time = GetTime();
  hudVector = VectorLerp(hudVector, posVector, (time - initTime) / (fadeTime * 1000));
  self.x = hudVector[0];
  self.y = hudVector[1];
  wait(0.0001);
 }
}






I think I've found where you need to edit but I'm not sure how to link the hud to my custom picture in texture assets

any help is appreciated as always thanks


ModmeBot:

Reply By: TrueGamerCalls
Please use the "Insert Code" button


ModmeBot:

Reply By: iAr7uRo

KillJoyYT

The code you paste only is to show the zombie counter. And you can only edit the alignment, color font and edit the text. But if you mean that an image appears on the zombie counter, I still do not know how to do it, I hope you help!

With this video you can create your own D PAD:
Here Der Eisendrache HUD you can modify: https://wiki.ardivee.com/article/der-eisendrache-hud/


ModmeBot:

Reply By: KillJoyYT
yeah that's what I meant a custom picture on the screen when its counting down the zombie spawn count.


I've seen this done in maps like ski resort and evil xmas


already have a custom dpad hud :-)


ModmeBot:

Reply By: KillJoyYT
would this script be easier to implement a custom hud?




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

Open zm_yourmapname.gsc

Find the following function
Code: [Select]
function main()

add the following line inside 
Code: [Select]
zombiesleft_hud();

so it should look like this
Code: [Select]
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

Code: [Select]
// 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; 
}


ModmeBot:

Reply By: iAr7uRo

KillJoyYT
yeah that's what I meant a custom picture on the screen when its counting down the zombie spawn count. I've seen this done in maps like ski resort and evil xmas already have a custom hud :-)

Ohh, if I imagined that you wanted that. The only ones that could know and how you comment they have used it in their maps are: Jbird623, Zeroy, Ardivee and Madgaz Gaming. maybe other users more, hopefully see the post and you respond. :D