mirror of
https://github.com/JezuzLizard/BO2-Reimagined.git
synced 2025-06-07 13:49:33 -05:00
HUD: convert enemy counter to LUI
This commit is contained in:
parent
b53e0768ad
commit
29b59cf044
@ -167,6 +167,8 @@ init()
|
||||
|
||||
level thread on_player_connect();
|
||||
|
||||
level thread on_intermission();
|
||||
|
||||
level thread post_all_players_spawned();
|
||||
|
||||
level thread enemy_counter_hud();
|
||||
@ -175,8 +177,6 @@ init()
|
||||
|
||||
level thread swap_staminup_perk();
|
||||
|
||||
level thread remove_status_icons_on_intermission();
|
||||
|
||||
if (isDedicated())
|
||||
{
|
||||
scripts\zm\server\_zm_reimagined_server::init();
|
||||
@ -190,6 +190,7 @@ precache_strings()
|
||||
precacheString(&"r_fog");
|
||||
precacheString(&"r_fog_settings");
|
||||
|
||||
precacheString(&"hud_update_enemy_counter");
|
||||
precacheString(&"hud_update_health_bar");
|
||||
precacheString(&"hud_update_zone_name");
|
||||
|
||||
@ -378,7 +379,7 @@ add_fire_sale_vox()
|
||||
|
||||
on_player_connect()
|
||||
{
|
||||
while (true)
|
||||
while (1)
|
||||
{
|
||||
level waittill("connecting", player);
|
||||
|
||||
@ -401,7 +402,7 @@ on_player_spawned()
|
||||
|
||||
self.initial_spawn = true;
|
||||
|
||||
for (;;)
|
||||
while (1)
|
||||
{
|
||||
self waittill("spawned_player");
|
||||
|
||||
@ -440,6 +441,8 @@ on_player_spawned()
|
||||
self set_client_dvars();
|
||||
self set_perks();
|
||||
self set_favorite_wall_weapons();
|
||||
|
||||
self thread lui_notify_events();
|
||||
}
|
||||
}
|
||||
|
||||
@ -515,6 +518,19 @@ on_player_fake_revive()
|
||||
}
|
||||
}
|
||||
|
||||
on_intermission()
|
||||
{
|
||||
level waittill("intermission");
|
||||
|
||||
players = get_players();
|
||||
|
||||
foreach (player in players)
|
||||
{
|
||||
player.statusicon = "";
|
||||
player setclientuivisibilityflag("hud_visible", 0);
|
||||
}
|
||||
}
|
||||
|
||||
post_all_players_spawned()
|
||||
{
|
||||
flag_wait("start_zombie_round_logic");
|
||||
@ -716,6 +732,15 @@ set_favorite_wall_weapons()
|
||||
}
|
||||
}
|
||||
|
||||
lui_notify_events()
|
||||
{
|
||||
self endon("disconnect");
|
||||
|
||||
wait 0.05;
|
||||
|
||||
self luinotifyevent(&"hud_update_enemy_counter", 1, level.enemy_counter_hud_value);
|
||||
}
|
||||
|
||||
enemy_counter_hud()
|
||||
{
|
||||
if (getDvar("g_gametype") == "zgrief")
|
||||
@ -723,73 +748,49 @@ enemy_counter_hud()
|
||||
return;
|
||||
}
|
||||
|
||||
hud = newHudElem();
|
||||
hud.alignx = "left";
|
||||
hud.aligny = "top";
|
||||
hud.horzalign = "user_left";
|
||||
hud.vertalign = "user_top";
|
||||
hud.x += 5;
|
||||
hud.y += 2;
|
||||
hud.fontscale = 1.4;
|
||||
hud.alpha = 0;
|
||||
hud.color = (1, 1, 1);
|
||||
hud.hidewheninmenu = 1;
|
||||
hud.foreground = 1;
|
||||
hud.label = &"ZOMBIE_HUD_ENEMIES_REMAINING";
|
||||
|
||||
hud endon("death");
|
||||
|
||||
hud thread destroy_on_intermission();
|
||||
|
||||
flag_wait("hud_visible");
|
||||
|
||||
hud.alpha = 1;
|
||||
level.enemy_counter_hud_value = 0;
|
||||
|
||||
vars = [];
|
||||
players = get_players();
|
||||
|
||||
foreach (player in players)
|
||||
{
|
||||
player luinotifyevent(&"hud_update_enemy_counter", 1, level.enemy_counter_hud_value);
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
vars["enemies"] = get_round_enemy_array().size + level.zombie_total;
|
||||
enemies = get_round_enemy_array().size + level.zombie_total;
|
||||
|
||||
if (level flag_exists("spawn_ghosts") && flag("spawn_ghosts"))
|
||||
if (level flag_exists("spawn_ghosts") && flag("spawn_ghosts") && isdefined(level.get_current_ghost_count_func))
|
||||
{
|
||||
vars["enemies"] = get_current_ghost_count();
|
||||
enemies = [[level.get_current_ghost_count_func]]();
|
||||
}
|
||||
else if (level flag_exists("sq_tpo_special_round_active") && flag("sq_tpo_special_round_active"))
|
||||
{
|
||||
vars["enemies"] = 0;
|
||||
enemies = 0;
|
||||
}
|
||||
|
||||
if (vars["enemies"] == 0)
|
||||
if (level.enemy_counter_hud_value == enemies)
|
||||
{
|
||||
hud setText("");
|
||||
wait 0.05;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
||||
level.enemy_counter_hud_value = enemies;
|
||||
|
||||
players = get_players();
|
||||
|
||||
foreach (player in players)
|
||||
{
|
||||
hud setValue(vars["enemies"]);
|
||||
player luinotifyevent(&"hud_update_enemy_counter", 1, level.enemy_counter_hud_value);
|
||||
}
|
||||
|
||||
wait 0.05;
|
||||
}
|
||||
}
|
||||
|
||||
get_current_ghost_count()
|
||||
{
|
||||
vars = [];
|
||||
vars["ghost_count"] = 0;
|
||||
vars["ais"] = getaiarray(level.zombie_team);
|
||||
|
||||
for (i = 0; i < vars["ais"].size; i++)
|
||||
{
|
||||
vars["ai"] = vars["ais"][i];
|
||||
|
||||
if (isdefined(vars["ai"].is_ghost) && vars["ai"].is_ghost)
|
||||
vars["ghost_count"]++;
|
||||
}
|
||||
|
||||
return vars["ghost_count"];
|
||||
}
|
||||
|
||||
timer_hud()
|
||||
{
|
||||
level thread round_timer_hud();
|
||||
@ -2587,7 +2588,7 @@ give_additional_perks()
|
||||
{
|
||||
self endon("disconnect");
|
||||
|
||||
for (;;)
|
||||
while (1)
|
||||
{
|
||||
self waittill_any("perk_acquired", "perk_lost");
|
||||
|
||||
@ -3412,7 +3413,7 @@ electric_cherry_unlimited()
|
||||
{
|
||||
self endon("disconnect");
|
||||
|
||||
for (;;)
|
||||
while (1)
|
||||
{
|
||||
self.consecutive_electric_cherry_attacks = 0;
|
||||
|
||||
@ -3504,18 +3505,6 @@ setclientdvarall(dvar, value)
|
||||
}
|
||||
}
|
||||
|
||||
remove_status_icons_on_intermission()
|
||||
{
|
||||
level waittill("intermission");
|
||||
|
||||
players = get_players();
|
||||
|
||||
foreach (player in players)
|
||||
{
|
||||
player.statusicon = "";
|
||||
}
|
||||
}
|
||||
|
||||
destroy_on_end_game()
|
||||
{
|
||||
self endon("death");
|
||||
|
@ -69,6 +69,7 @@ init()
|
||||
|
||||
level.zombie_init_done = ::zombie_init_done;
|
||||
level.special_weapon_magicbox_check = ::buried_special_weapon_magicbox_check;
|
||||
level.get_current_ghost_count_func = maps\mp\zombies\_zm_ai_ghost::get_current_ghost_count;
|
||||
|
||||
if (is_gametype_active("zgrief"))
|
||||
{
|
||||
|
@ -4,6 +4,43 @@ LUI.createMenu.ReimaginedArea = function(LocalClientIndex)
|
||||
local safeArea = CoD.Menu.NewSafeAreaFromState("ReimaginedArea", LocalClientIndex)
|
||||
safeArea:setOwner(LocalClientIndex)
|
||||
|
||||
local x = 7
|
||||
local y = 3
|
||||
|
||||
local enemyCounterWidget = LUI.UIElement.new()
|
||||
enemyCounterWidget:setLeftRight(true, false, x, x)
|
||||
enemyCounterWidget:setTopBottom(true, false, y, y)
|
||||
enemyCounterWidget:setAlpha(0)
|
||||
enemyCounterWidget.width = width
|
||||
enemyCounterWidget.height = height
|
||||
safeArea:addElement(enemyCounterWidget)
|
||||
|
||||
local enemyCounterText = LUI.UIText.new()
|
||||
enemyCounterText:setLeftRight(true, false, 0, 1000)
|
||||
enemyCounterText:setTopBottom(true, false, 0, CoD.textSize.Default)
|
||||
enemyCounterText:setFont(CoD.fonts.Big)
|
||||
enemyCounterText:setAlignment(LUI.Alignment.Left)
|
||||
enemyCounterWidget:addElement(enemyCounterText)
|
||||
enemyCounterWidget.enemyCounterText = enemyCounterText
|
||||
|
||||
enemyCounterWidget:registerEventHandler("hud_update_refresh", CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_HUD_VISIBLE, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_EMP_ACTIVE, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_DEMO_CAMERA_MODE_MOVIECAM, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_DEMO_ALL_GAME_HUD_HIDDEN, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IN_VEHICLE, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IN_GUIDED_MISSILE, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IN_REMOTE_KILLSTREAK_STATIC, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_AMMO_COUNTER_HIDE, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IS_FLASH_BANGED, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_UI_ACTIVE, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_SPECTATING_CLIENT, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_SCOREBOARD_OPEN, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_PLAYER_DEAD, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IS_SCOPED, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IS_PLAYER_ZOMBIE, CoD.Reimagined.EnemyCounterArea.UpdateVisibility)
|
||||
enemyCounterWidget:registerEventHandler("hud_update_enemy_counter", CoD.Reimagined.EnemyCounterArea.UpdateEnemyCounter)
|
||||
|
||||
local x = 7
|
||||
local y = -163
|
||||
local width = 169
|
||||
@ -120,6 +157,30 @@ LUI.createMenu.ReimaginedArea = function(LocalClientIndex)
|
||||
return safeArea
|
||||
end
|
||||
|
||||
CoD.Reimagined.EnemyCounterArea = {}
|
||||
CoD.Reimagined.EnemyCounterArea.UpdateVisibility = function(Menu, ClientInstance)
|
||||
local controller = ClientInstance.controller
|
||||
if UIExpression.IsVisibilityBitSet(controller, CoD.BIT_HUD_VISIBLE) == 1 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_EMP_ACTIVE) == 0 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_DEMO_CAMERA_MODE_MOVIECAM) == 0 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_DEMO_ALL_GAME_HUD_HIDDEN) == 0 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_IN_VEHICLE) == 0 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_IN_GUIDED_MISSILE) == 0 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_IN_REMOTE_KILLSTREAK_STATIC) == 0 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_AMMO_COUNTER_HIDE) == 0 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_IS_FLASH_BANGED) == 0 and (UIExpression.IsVisibilityBitSet(controller, CoD.BIT_UI_ACTIVE) == 0 or UIExpression.IsVisibilityBitSet(controller, CoD.BIT_SCOREBOARD_OPEN) == 1) and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_IN_KILLCAM) == 0 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_IS_SCOPED) == 0 and UIExpression.IsVisibilityBitSet(controller, CoD.BIT_IS_PLAYER_ZOMBIE) == 0 and (not CoD.IsShoutcaster(controller) or CoD.ExeProfileVarBool(controller, "shoutcaster_scorestreaks") and Engine.IsSpectatingActiveClient(controller)) and CoD.FSM_VISIBILITY(controller) == 0 then
|
||||
if Menu.visible ~= true then
|
||||
Menu:setAlpha(1)
|
||||
Menu.visible = true
|
||||
end
|
||||
elseif Menu.visible == true then
|
||||
Menu:setAlpha(0)
|
||||
Menu.visible = nil
|
||||
end
|
||||
end
|
||||
|
||||
CoD.Reimagined.EnemyCounterArea.UpdateEnemyCounter = function(Menu, ClientInstance)
|
||||
local enemyCount = ClientInstance.data[1]
|
||||
|
||||
if enemyCount == 0 then
|
||||
enemyCount = ""
|
||||
end
|
||||
|
||||
Menu.enemyCounterText:setText(Engine.Localize("ZOMBIE_HUD_ENEMIES_REMAINING") .. enemyCount)
|
||||
end
|
||||
|
||||
CoD.Reimagined.HealthBarArea = {}
|
||||
CoD.Reimagined.HealthBarArea.UpdateVisibility = function(Menu, ClientInstance)
|
||||
local controller = ClientInstance.controller
|
||||
|
Loading…
x
Reference in New Issue
Block a user