1
0
mirror of https://github.com/JezuzLizard/BO2-Reimagined.git synced 2025-06-07 21:59:49 -05:00

HUD: convert enemy powerup overlay to LUI

This commit is contained in:
Jbleezy 2024-01-22 18:23:12 -08:00
parent 98ee48835a
commit cc619425c8
5 changed files with 571 additions and 132 deletions

View File

@ -96,6 +96,7 @@ main()
replaceFunc(maps\mp\zombies\_zm_powerups::nuke_powerup, scripts\zm\replaced\_zm_powerups::nuke_powerup);
replaceFunc(maps\mp\zombies\_zm_powerups::insta_kill_powerup, scripts\zm\replaced\_zm_powerups::insta_kill_powerup);
replaceFunc(maps\mp\zombies\_zm_powerups::double_points_powerup, scripts\zm\replaced\_zm_powerups::double_points_powerup);
replaceFunc(maps\mp\zombies\_zm_powerups::powerup_hud_monitor, scripts\zm\replaced\_zm_powerups::powerup_hud_monitor);
replaceFunc(maps\mp\zombies\_zm_pers_upgrades::is_pers_system_disabled, scripts\zm\replaced\_zm_pers_upgrades::is_pers_system_disabled);
replaceFunc(maps\mp\zombies\_zm_pers_upgrades_system::check_pers_upgrade, scripts\zm\replaced\_zm_pers_upgrades_system::check_pers_upgrade);
replaceFunc(maps\mp\zombies\_zm_traps::player_elec_damage, scripts\zm\replaced\_zm_traps::player_elec_damage);

View File

@ -830,4 +830,134 @@ start_fire_sale(item)
level.zombie_vars["zombie_powerup_fire_sale_on"] = 0;
level notify("fire_sale_off");
}
powerup_hud_monitor()
{
flag_wait("start_zombie_round_logic");
if (isdefined(level.current_game_module) && level.current_game_module == 2)
return;
flashing_timers = [];
flashing_values = [];
flashing_timer = 10;
flashing_delta_time = 0;
flashing_is_on = 0;
flashing_value = 3;
flashing_min_timer = 0.15;
while (flashing_timer >= flashing_min_timer)
{
if (flashing_timer < 5)
flashing_delta_time = 0.1;
else
flashing_delta_time = 0.2;
if (flashing_is_on)
{
flashing_timer = flashing_timer - flashing_delta_time - 0.05;
flashing_value = 2;
}
else
{
flashing_timer = flashing_timer - flashing_delta_time;
flashing_value = 3;
}
flashing_timers[flashing_timers.size] = flashing_timer;
flashing_values[flashing_values.size] = flashing_value;
flashing_is_on = !flashing_is_on;
}
client_fields = [];
powerup_keys = getarraykeys(level.zombie_powerups);
for (powerup_key_index = 0; powerup_key_index < powerup_keys.size; powerup_key_index++)
{
if (isdefined(level.zombie_powerups[powerup_keys[powerup_key_index]].client_field_name))
{
powerup_name = powerup_keys[powerup_key_index];
client_fields[powerup_name] = spawnstruct();
client_fields[powerup_name].client_field_name = level.zombie_powerups[powerup_name].client_field_name;
client_fields[powerup_name].enemy_client_field_name = level.zombie_powerups[powerup_name].enemy_client_field_name;
client_fields[powerup_name].solo = level.zombie_powerups[powerup_name].solo;
client_fields[powerup_name].time_name = level.zombie_powerups[powerup_name].time_name;
client_fields[powerup_name].on_name = level.zombie_powerups[powerup_name].on_name;
}
}
client_field_keys = getarraykeys(client_fields);
while (true)
{
wait 0.05;
waittillframeend;
players = get_players();
for (playerindex = 0; playerindex < players.size; playerindex++)
{
for (client_field_key_index = 0; client_field_key_index < client_field_keys.size; client_field_key_index++)
{
player = players[playerindex];
if (isdefined(level.powerup_player_valid))
{
if (![[level.powerup_player_valid]](player))
continue;
}
client_field_name = client_fields[client_field_keys[client_field_key_index]].client_field_name;
time_name = client_fields[client_field_keys[client_field_key_index]].time_name;
on_name = client_fields[client_field_keys[client_field_key_index]].on_name;
powerup_timer = undefined;
powerup_on = undefined;
enemy_client_field_name = client_fields[client_field_keys[client_field_key_index]].enemy_client_field_name;
enemy_powerup_timer = undefined;
enemy_powerup_on = undefined;
if (client_fields[client_field_keys[client_field_key_index]].solo)
{
if (isdefined(player._show_solo_hud) && player._show_solo_hud == 1)
{
powerup_timer = player.zombie_vars[time_name];
powerup_on = player.zombie_vars[on_name];
}
}
else if (isdefined(level.zombie_vars[player.team][time_name]))
{
powerup_timer = level.zombie_vars[player.team][time_name];
powerup_on = level.zombie_vars[player.team][on_name];
enemy_team = getotherteam(player.team);
if (isdefined(level.zombie_vars[enemy_team][time_name]))
{
enemy_powerup_timer = level.zombie_vars[enemy_team][time_name];
enemy_powerup_on = level.zombie_vars[enemy_team][on_name];
}
}
else if (isdefined(level.zombie_vars[time_name]))
{
powerup_timer = level.zombie_vars[time_name];
powerup_on = level.zombie_vars[on_name];
}
if (isdefined(powerup_timer) && isdefined(powerup_on))
{
player set_clientfield_powerups(client_field_name, powerup_timer, powerup_on, flashing_timers, flashing_values);
if (isdefined(enemy_powerup_timer) && isdefined(enemy_powerup_on))
{
player set_clientfield_powerups(enemy_client_field_name, enemy_powerup_timer, enemy_powerup_on, flashing_timers, flashing_values);
}
continue;
}
player setclientfieldtoplayer(client_field_name, 0);
}
}
}
}

View File

@ -4,4 +4,15 @@
main()
{
replaceFunc(clientscripts\mp\gametypes\zgrief::onprecachegametype, scripts\zm\replaced\zgrief::onprecachegametype);
enemy_powerup_hud();
}
enemy_powerup_hud()
{
registerclientfield("toplayer", "powerup_instant_kill_enemy", 1, 2, "int", undefined, 0, 1);
registerclientfield("toplayer", "powerup_double_points_enemy", 1, 2, "int", undefined, 0, 1);
setupclientfieldcodecallbacks("toplayer", 1, "powerup_instant_kill_enemy");
setupclientfieldcodecallbacks("toplayer", 1, "powerup_double_points_enemy");
}

View File

@ -41,9 +41,9 @@ init()
if (level.script == "zm_prison")
{
level._effect["afterlife_teleport"] = loadfx("maps/zombie_alcatraz/fx_alcatraz_afterlife_zmb_tport");
level.player_spawn_fx = "afterlife_teleport";
level.player_spawn_sound = "zmb_afterlife_zombie_warp_in";
level._effect["afterlife_teleport"] = loadfx("maps/zombie_alcatraz/fx_alcatraz_afterlife_zmb_tport");
}
else
{
@ -68,9 +68,9 @@ init()
setteamscore("allies", 0);
set_grief_vars();
powerup_hud_overlay();
grief_gamemode_hud();
grief_score_hud();
enemy_powerup_hud();
if (level.scr_zm_ui_gametype_obj == "zcontainment")
{
@ -320,6 +320,26 @@ grief_score_hud_set_obj_icon(team)
}
}
enemy_powerup_hud()
{
registerclientfield("toplayer", "powerup_instant_kill_enemy", 1, 2, "int");
registerclientfield("toplayer", "powerup_double_points_enemy", 1, 2, "int");
powerup = level.zombie_powerups["insta_kill"];
if (isdefined(powerup))
{
powerup.enemy_client_field_name = powerup.client_field_name + "_enemy";
}
powerup = level.zombie_powerups["double_points"];
if (isdefined(powerup))
{
powerup.enemy_client_field_name = powerup.client_field_name + "_enemy";
}
}
set_grief_vars()
{
if (getDvar("ui_gametype_obj") == "")
@ -427,136 +447,6 @@ set_grief_vars()
}
}
powerup_hud_overlay()
{
level.active_powerup_hud_array = [];
level.active_powerup_hud_array["axis"] = [];
level.active_powerup_hud_array["allies"] = [];
struct_array = [];
struct = spawnStruct();
struct.on = "zombie_powerup_point_halfer_on";
struct.time = "zombie_powerup_point_halfer_time";
struct.shader = "specialty_doublepoints_zombies";
struct_array[struct_array.size] = struct;
struct = spawnStruct();
struct.on = "zombie_powerup_half_damage_on";
struct.time = "zombie_powerup_half_damage_time";
struct.shader = "specialty_instakill_zombies";
struct_array[struct_array.size] = struct;
foreach (struct in struct_array)
{
foreach (team in level.teams)
{
hudelem = newTeamHudElem(team);
hudelem.hidewheninmenu = 1;
hudelem.alignX = "center";
hudelem.alignY = "bottom";
hudelem.horzAlign = "user_center";
hudelem.vertAlign = "user_bottom";
hudelem.y = -37;
hudelem.color = (0.21, 0, 0);
hudelem.alpha = 0;
hudelem.team = team;
hudelem.on_string = struct.on;
hudelem.time_string = struct.time;
hudelem setShader(struct.shader, 32, 32);
hudelem thread powerup_hud_think();
hudelem thread powerup_hud_destroy_on_intermission();
}
}
}
powerup_hud_think()
{
level endon("intermission");
while (1)
{
if (level.zombie_vars[self.team][self.time_string] < 5)
{
wait(0.1);
self fadeOverTime(0.1);
self.alpha = 0;
wait(0.1);
self fadeOverTime(0.1);
self.alpha = 1;
}
else if (level.zombie_vars[self.team][self.time_string] < 10)
{
wait(0.2);
self fadeOverTime(0.2);
self.alpha = 0;
wait(0.2);
self fadeOverTime(0.2);
self.alpha = 1;
}
if (level.zombie_vars[self.team][self.on_string])
{
if (!isInArray(level.active_powerup_hud_array[self.team], self))
{
level.active_powerup_hud_array[self.team][level.active_powerup_hud_array[self.team].size] = self;
self thread powerup_hud_move();
self.alpha = 1;
}
}
else
{
if (isInArray(level.active_powerup_hud_array[self.team], self))
{
arrayRemoveValue(level.active_powerup_hud_array[self.team], self);
self thread powerup_hud_move();
self thread powerup_fade_over_time();
}
}
wait 0.05;
}
}
powerup_hud_destroy_on_intermission()
{
level waittill("intermission");
self destroy();
}
powerup_hud_move()
{
offset_x = 37;
if ((level.active_powerup_hud_array[self.team].size % 2) == 0)
{
offset_x /= 2;
}
start_x = int(level.active_powerup_hud_array[self.team].size / 2) * (-1 * offset_x);
for (i = 0; i < level.active_powerup_hud_array[self.team].size; i++)
{
level.active_powerup_hud_array[self.team][i] moveOverTime(0.5);
level.active_powerup_hud_array[self.team][i].x = start_x + (i * 37);
}
}
powerup_fade_over_time()
{
wait 0.1;
if (!level.zombie_vars[self.team][self.on_string])
{
self fadeOverTime(0.5);
self.alpha = 0;
}
}
grief_onplayerconnect()
{
self setclientdvar("ui_gametype_obj", level.scr_zm_ui_gametype_obj);

View File

@ -0,0 +1,407 @@
CoD.PowerUps = {}
CoD.PowerUps.IconSize = 48
CoD.PowerUps.UpgradeIconSize = 36
CoD.PowerUps.EnemyIconSize = 48
CoD.PowerUps.Spacing = 8
CoD.PowerUps.STATE_OFF = 0
CoD.PowerUps.STATE_ON = 1
CoD.PowerUps.STATE_FLASHING_OFF = 2
CoD.PowerUps.STATE_FLASHING_ON = 3
CoD.PowerUps.FLASHING_STAGE_DURATION = 500
CoD.PowerUps.MOVING_DURATION = 500
CoD.PowerUps.UpGradeIconColorRed = {
r = 1,
g = 0,
b = 0,
}
CoD.PowerUps.EnemyIconColorRed = {
r = 0.21,
g = 0,
b = 0,
}
CoD.PowerUps.ClientFieldNames = {}
CoD.PowerUps.ClientFieldNames[1] = {
clientFieldName = "powerup_instant_kill",
material = RegisterMaterial("specialty_instakill_zombies"),
}
CoD.PowerUps.ClientFieldNames[2] = {
clientFieldName = "powerup_double_points",
material = RegisterMaterial("specialty_doublepoints_zombies"),
z_material = RegisterMaterial("specialty_doublepoints_zombies_blue"),
}
CoD.PowerUps.ClientFieldNames[3] = {
clientFieldName = "powerup_fire_sale",
material = RegisterMaterial("specialty_firesale_zombies"),
}
CoD.PowerUps.ClientFieldNames[4] = {
clientFieldName = "powerup_bon_fire",
material = RegisterMaterial("zom_icon_bonfire"),
}
CoD.PowerUps.ClientFieldNames[5] = {
clientFieldName = "powerup_mini_gun",
material = RegisterMaterial("zom_icon_minigun"),
}
CoD.PowerUps.ClientFieldNames[6] = {
clientFieldName = "powerup_zombie_blood",
material = RegisterMaterial("specialty_zomblood_zombies"),
}
CoD.PowerUps.UpgradeClientFieldNames = {}
CoD.PowerUps.UpgradeClientFieldNames[1] = {
clientFieldName = CoD.PowerUps.ClientFieldNames[1].clientFieldName .. "_ug",
material = RegisterMaterial("specialty_instakill_zombies"),
color = CoD.PowerUps.UpGradeIconColorRed,
}
CoD.PowerUps.EnemyClientFieldNames = {}
CoD.PowerUps.EnemyClientFieldNames[1] = {
clientFieldName = CoD.PowerUps.ClientFieldNames[1].clientFieldName .. "_enemy",
material = RegisterMaterial("specialty_instakill_zombies"),
color = CoD.PowerUps.EnemyIconColorRed,
}
CoD.PowerUps.EnemyClientFieldNames[2] = {
clientFieldName = CoD.PowerUps.ClientFieldNames[2].clientFieldName .. "_enemy",
material = RegisterMaterial("specialty_doublepoints_zombies"),
color = CoD.PowerUps.EnemyIconColorRed,
}
LUI.createMenu.PowerUpsArea = function(LocalClientIndex)
local PowerupsAreaWidget = CoD.Menu.NewSafeAreaFromState("PowerUpsArea", LocalClientIndex)
PowerupsAreaWidget:setOwner(LocalClientIndex)
PowerupsAreaWidget.scaleContainer = CoD.SplitscreenScaler.new(nil, CoD.Zombie.SplitscreenMultiplier)
PowerupsAreaWidget.scaleContainer:setLeftRight(false, false, 0, 0)
PowerupsAreaWidget.scaleContainer:setTopBottom(false, true, 0, 0)
PowerupsAreaWidget:addElement(PowerupsAreaWidget.scaleContainer)
local f1_local1 = CoD.PowerUps.IconSize * 0.5
local f1_local2 = CoD.PowerUps.IconSize + CoD.PowerUps.UpgradeIconSize + 10
local Widget = nil
PowerupsAreaWidget.powerUps = {}
for ClientFieldIndex = 1, #CoD.PowerUps.ClientFieldNames, 1 do
Widget = LUI.UIElement.new()
Widget:setLeftRight(false, false, -f1_local1, f1_local1)
Widget:setTopBottom(false, true, -f1_local2, 0)
Widget:registerEventHandler("transition_complete_off_fade_out", CoD.PowerUps.PowerUpIcon_UpdatePosition)
local powerUpIcon = LUI.UIImage.new()
powerUpIcon:setLeftRight(true, true, 0, 0)
powerUpIcon:setTopBottom(false, true, -CoD.PowerUps.IconSize, 0)
powerUpIcon:setAlpha(0)
Widget:addElement(powerUpIcon)
Widget.powerUpIcon = powerUpIcon
local upgradePowerUpIcon = LUI.UIImage.new()
upgradePowerUpIcon:setLeftRight(false, false, -CoD.PowerUps.UpgradeIconSize / 2, CoD.PowerUps.UpgradeIconSize / 2)
upgradePowerUpIcon:setTopBottom(true, false, 0, CoD.PowerUps.UpgradeIconSize)
upgradePowerUpIcon:setAlpha(0)
Widget:addElement(upgradePowerUpIcon)
Widget.upgradePowerUpIcon = upgradePowerUpIcon
Widget.powerupId = nil
PowerupsAreaWidget.scaleContainer:addElement(Widget)
PowerupsAreaWidget.powerUps[ClientFieldIndex] = Widget
PowerupsAreaWidget:registerEventHandler(CoD.PowerUps.ClientFieldNames[ClientFieldIndex].clientFieldName, CoD.PowerUps.Update)
PowerupsAreaWidget:registerEventHandler(CoD.PowerUps.ClientFieldNames[ClientFieldIndex].clientFieldName .. "_ug", CoD.PowerUps.UpgradeUpdate)
end
PowerupsAreaWidget.enemyPowerUps = {}
for ClientFieldIndex = 1, #CoD.PowerUps.EnemyClientFieldNames, 1 do
Widget = LUI.UIElement.new()
Widget:setLeftRight(false, false, -f1_local1, f1_local1)
Widget:setTopBottom(false, true, -f1_local2, 0)
Widget:registerEventHandler("transition_complete_off_fade_out", CoD.PowerUps.PowerUpIcon_UpdatePosition)
local enemyPowerUpIcon = LUI.UIImage.new()
enemyPowerUpIcon:setLeftRight(false, false, -CoD.PowerUps.EnemyIconSize / 2, CoD.PowerUps.EnemyIconSize / 2)
enemyPowerUpIcon:setTopBottom(true, false, 0 - CoD.PowerUps.Spacing, CoD.PowerUps.EnemyIconSize - CoD.PowerUps.Spacing)
enemyPowerUpIcon:setAlpha(0)
Widget:addElement(enemyPowerUpIcon)
Widget.enemyPowerUpIcon = enemyPowerUpIcon
Widget.powerupId = nil
PowerupsAreaWidget.scaleContainer:addElement(Widget)
PowerupsAreaWidget.enemyPowerUps[ClientFieldIndex] = Widget
PowerupsAreaWidget:registerEventHandler(CoD.PowerUps.EnemyClientFieldNames[ClientFieldIndex].clientFieldName, CoD.PowerUps.EnemyUpdate)
end
PowerupsAreaWidget.activePowerUpCount = 0
PowerupsAreaWidget.activeEnemyPowerUpCount = 0
PowerupsAreaWidget:registerEventHandler("hud_update_refresh", CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_HUD_VISIBLE, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IS_PLAYER_IN_AFTERLIFE, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_EMP_ACTIVE, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_UI_ACTIVE, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_SPECTATING_CLIENT, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_SCOREBOARD_OPEN, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IN_VEHICLE, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IN_GUIDED_MISSILE, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IN_REMOTE_KILLSTREAK_STATIC, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IS_SCOPED, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_IS_FLASH_BANGED, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_DEMO_CAMERA_MODE_MOVIECAM, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("hud_update_bit_" .. CoD.BIT_DEMO_ALL_GAME_HUD_HIDDEN, CoD.PowerUps.UpdateVisibility)
PowerupsAreaWidget:registerEventHandler("powerups_update_position", CoD.PowerUps.UpdatePosition)
PowerupsAreaWidget.visible = true
return PowerupsAreaWidget
end
CoD.PowerUps.UpdateVisibility = function(Menu, ClientInstance)
local LocalClientIndex = ClientInstance.controller
if UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_HUD_VISIBLE) == 1 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_IS_PLAYER_IN_AFTERLIFE) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_EMP_ACTIVE) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_DEMO_CAMERA_MODE_MOVIECAM) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_DEMO_ALL_GAME_HUD_HIDDEN) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_UI_ACTIVE) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_IN_KILLCAM) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_SCOREBOARD_OPEN) == 0 and (not CoD.IsShoutcaster(LocalClientIndex) or CoD.ExeProfileVarBool(LocalClientIndex, "shoutcaster_teamscore")) and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_IN_GUIDED_MISSILE) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_IN_REMOTE_KILLSTREAK_STATIC) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_IS_SCOPED) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_IN_VEHICLE) == 0 and UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_IS_FLASH_BANGED) == 0 then
if not Menu.visible then
Menu:setAlpha(1)
Menu.visible = true
end
elseif Menu.visible then
Menu:setAlpha(0)
Menu.visible = nil
end
end
CoD.PowerUps.Update = function(Menu, ClientInstance)
CoD.PowerUps.UpdateState(Menu, ClientInstance)
CoD.PowerUps.UpdatePosition(Menu, ClientInstance)
end
CoD.PowerUps.UpdateState = function(Menu, ClientInstance)
local PowerUpWidget = nil
local ExistingPowerUpIndex = CoD.PowerUps.GetExistingPowerUpIndex(Menu, ClientInstance.name)
if ExistingPowerUpIndex ~= nil then
PowerUpWidget = Menu.powerUps[ExistingPowerUpIndex]
if ClientInstance.newValue == CoD.PowerUps.STATE_ON then
PowerUpWidget.powerUpId = ClientInstance.name
PowerUpWidget.powerUpIcon:setImage(CoD.PowerUps.GetMaterial(Menu, ClientInstance.controller, ClientInstance.name))
PowerUpWidget.powerUpIcon:setAlpha(1)
elseif ClientInstance.newValue == CoD.PowerUps.STATE_OFF then
PowerUpWidget.powerUpIcon:beginAnimation("off_fade_out", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidget.powerUpIcon:setAlpha(0)
PowerUpWidget.upgradePowerUpIcon:beginAnimation("off_fade_out", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidget.upgradePowerUpIcon:setAlpha(0)
PowerUpWidget.powerUpId = nil
Menu.activePowerUpCount = Menu.activePowerUpCount - 1
elseif ClientInstance.newValue == CoD.PowerUps.STATE_FLASHING_OFF then
PowerUpWidget.powerUpIcon:beginAnimation("fade_out", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidget.powerUpIcon:setAlpha(0)
elseif ClientInstance.newValue == CoD.PowerUps.STATE_FLASHING_ON then
PowerUpWidget.powerUpIcon:beginAnimation("fade_in", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidget.powerUpIcon:setAlpha(1)
end
elseif ClientInstance.newValue == CoD.PowerUps.STATE_ON or ClientInstance.newValue == CoD.PowerUps.STATE_FLASHING_ON then
local f4_local2 = CoD.PowerUps.GetFirstAvailablePowerUpIndex(Menu)
if f4_local2 ~= nil then
PowerUpWidget = Menu.powerUps[f4_local2]
PowerUpWidget.powerUpId = ClientInstance.name
PowerUpWidget.powerUpIcon:setImage(CoD.PowerUps.GetMaterial(Menu, ClientInstance.controller, ClientInstance.name))
PowerUpWidget.powerUpIcon:setAlpha(1)
Menu.activePowerUpCount = Menu.activePowerUpCount + 1
end
end
end
CoD.PowerUps.UpgradeUpdate = function(Menu, ClientInstance)
CoD.PowerUps.UpgradeUpdateState(Menu, ClientInstance)
end
CoD.PowerUps.UpgradeUpdateState = function(Menu, ClientInstance)
local PowerUpWidgetIcon = nil
local ExistingPowerUpIndex = CoD.PowerUps.GetExistingPowerUpIndex(Menu, string.sub(ClientInstance.name, 0, -4))
if ExistingPowerUpIndex ~= nil then
PowerUpWidgetIcon = Menu.powerUps[ExistingPowerUpIndex].upgradePowerUpIcon
if ClientInstance.newValue == CoD.PowerUps.STATE_ON then
PowerUpWidgetIcon:setImage(CoD.PowerUps.GetUpgradeMaterial(Menu, ClientInstance.name))
PowerUpWidgetIcon:setAlpha(1)
CoD.PowerUps.SetUpgradeColor(PowerUpWidgetIcon, ClientInstance.name)
elseif ClientInstance.newValue == CoD.PowerUps.STATE_OFF then
PowerUpWidgetIcon:beginAnimation("off_fade_out", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidgetIcon:setAlpha(0)
elseif ClientInstance.newValue == CoD.PowerUps.STATE_FLASHING_OFF then
PowerUpWidgetIcon:beginAnimation("fade_out", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidgetIcon:setAlpha(0)
elseif ClientInstance.newValue == CoD.PowerUps.STATE_FLASHING_ON then
PowerUpWidgetIcon:beginAnimation("fade_in", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidgetIcon:setAlpha(1)
end
end
end
CoD.PowerUps.EnemyUpdate = function(Menu, ClientInstance)
CoD.PowerUps.EnemyUpdateState(Menu, ClientInstance)
CoD.PowerUps.EnemyUpdatePosition(Menu, ClientInstance)
end
CoD.PowerUps.EnemyUpdateState = function(Menu, ClientInstance)
local PowerUpWidget = nil
local ExistingPowerUpIndex = CoD.PowerUps.GetExistingEnemyPowerUpIndex(Menu, ClientInstance.name)
if ExistingPowerUpIndex ~= nil then
PowerUpWidget = Menu.enemyPowerUps[ExistingPowerUpIndex]
if ClientInstance.newValue == CoD.PowerUps.STATE_ON then
PowerUpWidget.powerupId = ClientInstance.name
PowerUpWidget.enemyPowerUpIcon:setImage(CoD.PowerUps.GetEnemyMaterial(Menu, ClientInstance.controller, ClientInstance.name))
PowerUpWidget.enemyPowerUpIcon:setAlpha(1)
elseif ClientInstance.newValue == CoD.PowerUps.STATE_OFF then
PowerUpWidget.enemyPowerUpIcon:beginAnimation("off_fade_out", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidget.enemyPowerUpIcon:setAlpha(0)
PowerUpWidget.powerupId = nil
Menu.activeEnemyPowerUpCount = Menu.activeEnemyPowerUpCount - 1
elseif ClientInstance.newValue == CoD.PowerUps.STATE_FLASHING_OFF then
PowerUpWidget.enemyPowerUpIcon:beginAnimation("fade_out", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidget.enemyPowerUpIcon:setAlpha(0)
elseif ClientInstance.newValue == CoD.PowerUps.STATE_FLASHING_ON then
PowerUpWidget.enemyPowerUpIcon:beginAnimation("fade_in", CoD.PowerUps.FLASHING_STAGE_DURATION)
PowerUpWidget.enemyPowerUpIcon:setAlpha(1)
end
elseif ClientInstance.newValue == CoD.PowerUps.STATE_ON or ClientInstance.newValue == CoD.PowerUps.STATE_FLASHING_ON then
local f4_local2 = CoD.PowerUps.GetFirstAvailableEnemyPowerUpIndex(Menu)
if f4_local2 ~= nil then
PowerUpWidget = Menu.enemyPowerUps[f4_local2]
PowerUpWidget.powerupId = ClientInstance.name
PowerUpWidget.enemyPowerUpIcon:setImage(CoD.PowerUps.GetEnemyMaterial(Menu, ClientInstance.controller, ClientInstance.name))
PowerUpWidget.enemyPowerUpIcon:setAlpha(1)
CoD.PowerUps.SetEnemyColor(PowerUpWidget.enemyPowerUpIcon, ClientInstance.name)
Menu.activeEnemyPowerUpCount = Menu.activeEnemyPowerUpCount + 1
end
end
end
CoD.PowerUps.GetMaterial = function(Menu, LocalClientIndex, ClientFieldName)
local f7_local0 = nil
for f7_local1 = 1, #CoD.PowerUps.ClientFieldNames, 1 do
if CoD.PowerUps.ClientFieldNames[f7_local1].clientFieldName == ClientFieldName then
f7_local0 = CoD.PowerUps.ClientFieldNames[f7_local1].material
if UIExpression.IsVisibilityBitSet(LocalClientIndex, CoD.BIT_IS_PLAYER_ZOMBIE) == 1 and CoD.PowerUps.ClientFieldNames[f7_local1].z_material then
f7_local0 = CoD.PowerUps.ClientFieldNames[f7_local1].z_material
break
end
end
end
return f7_local0
end
CoD.PowerUps.GetUpgradeMaterial = function(Menu, ClientFieldName)
local f8_local0 = nil
for PowerUpIndex = 1, #CoD.PowerUps.UpgradeClientFieldNames, 1 do
if CoD.PowerUps.UpgradeClientFieldNames[PowerUpIndex].clientFieldName == ClientFieldName then
f8_local0 = CoD.PowerUps.UpgradeClientFieldNames[PowerUpIndex].material
break
end
end
return f8_local0
end
CoD.PowerUps.GetEnemyMaterial = function(Menu, LocalClientIndex, ClientFieldName)
local f8_local0 = nil
for PowerUpIndex = 1, #CoD.PowerUps.EnemyClientFieldNames, 1 do
if CoD.PowerUps.EnemyClientFieldNames[PowerUpIndex].clientFieldName == ClientFieldName then
f8_local0 = CoD.PowerUps.EnemyClientFieldNames[PowerUpIndex].material
break
end
end
return f8_local0
end
CoD.PowerUps.SetUpgradeColor = function(Menu, ClientFieldName)
local f9_local0 = nil
for PowerUpIndex = 1, #CoD.PowerUps.UpgradeClientFieldNames, 1 do
if CoD.PowerUps.UpgradeClientFieldNames[PowerUpIndex].clientFieldName == ClientFieldName then
if CoD.PowerUps.UpgradeClientFieldNames[PowerUpIndex].color then
Menu:setRGB(CoD.PowerUps.UpgradeClientFieldNames[PowerUpIndex].color.r, CoD.PowerUps.UpgradeClientFieldNames[PowerUpIndex].color.g, CoD.PowerUps.UpgradeClientFieldNames[PowerUpIndex].color.b)
break
end
end
end
end
CoD.PowerUps.SetEnemyColor = function(Menu, ClientFieldName)
local f9_local0 = nil
for PowerUpIndex = 1, #CoD.PowerUps.EnemyClientFieldNames, 1 do
if CoD.PowerUps.EnemyClientFieldNames[PowerUpIndex].clientFieldName == ClientFieldName then
if CoD.PowerUps.EnemyClientFieldNames[PowerUpIndex].color then
Menu:setRGB(CoD.PowerUps.EnemyClientFieldNames[PowerUpIndex].color.r, CoD.PowerUps.EnemyClientFieldNames[PowerUpIndex].color.g, CoD.PowerUps.EnemyClientFieldNames[PowerUpIndex].color.b)
break
end
end
end
end
CoD.PowerUps.GetExistingPowerUpIndex = function(Menu, PowerUpId)
for PowerUpIndex = 1, #CoD.PowerUps.ClientFieldNames, 1 do
if Menu.powerUps[PowerUpIndex].powerUpId == PowerUpId then
return PowerUpIndex
end
end
return nil
end
CoD.PowerUps.GetExistingEnemyPowerUpIndex = function(Menu, PowerUpId)
for PowerUpIndex = 1, #CoD.PowerUps.EnemyClientFieldNames, 1 do
if Menu.enemyPowerUps[PowerUpIndex].powerupId == PowerUpId then
return PowerUpIndex
end
end
return nil
end
CoD.PowerUps.GetFirstAvailablePowerUpIndex = function(Menu)
for PowerUpIndex = 1, #CoD.PowerUps.ClientFieldNames, 1 do
if not Menu.powerUps[PowerUpIndex].powerUpId then
return PowerUpIndex
end
end
return nil
end
CoD.PowerUps.GetFirstAvailableEnemyPowerUpIndex = function(Menu)
for PowerUpIndex = 1, #CoD.PowerUps.EnemyClientFieldNames, 1 do
if not Menu.enemyPowerUps[PowerUpIndex].powerupId then
return PowerUpIndex
end
end
return nil
end
CoD.PowerUps.PowerUpIcon_UpdatePosition = function(Menu, ClientInstance)
if ClientInstance.interrupted ~= true then
Menu:dispatchEventToParent({
name = "powerups_update_position",
})
end
end
CoD.PowerUps.UpdatePosition = function(Menu, ClientInstance)
local PowerUpWidget = nil
local f13_local1 = 0
local f13_local2 = 0
local f13_local3 = nil
for PowerUpIndex = 1, #CoD.PowerUps.ClientFieldNames, 1 do
PowerUpWidget = Menu.powerUps[PowerUpIndex]
if PowerUpWidget.powerUpId ~= nil then
if not f13_local3 then
f13_local1 = -(CoD.PowerUps.IconSize * 0.5 * Menu.activePowerUpCount + CoD.PowerUps.Spacing * 0.5 * (Menu.activePowerUpCount - 1))
else
f13_local1 = f13_local3 + CoD.PowerUps.IconSize + CoD.PowerUps.Spacing
end
f13_local2 = f13_local1 + CoD.PowerUps.IconSize
PowerUpWidget:beginAnimation("move", CoD.PowerUps.MOVING_DURATION)
PowerUpWidget:setLeftRight(false, false, f13_local1, f13_local2)
f13_local3 = f13_local1
end
end
end
CoD.PowerUps.EnemyUpdatePosition = function(Menu, ClientInstance)
local PowerUpWidget = nil
local f13_local1 = 0
local f13_local2 = 0
local f13_local3 = nil
for PowerUpIndex = 1, #CoD.PowerUps.EnemyClientFieldNames, 1 do
PowerUpWidget = Menu.enemyPowerUps[PowerUpIndex]
if PowerUpWidget.powerupId ~= nil then
if not f13_local3 then
f13_local1 = -(CoD.PowerUps.EnemyIconSize * 0.5 * Menu.activeEnemyPowerUpCount + CoD.PowerUps.Spacing * 0.5 * (Menu.activeEnemyPowerUpCount - 1))
else
f13_local1 = f13_local3 + CoD.PowerUps.EnemyIconSize + CoD.PowerUps.Spacing
end
f13_local2 = f13_local1 + CoD.PowerUps.EnemyIconSize
PowerUpWidget:beginAnimation("move", CoD.PowerUps.MOVING_DURATION)
PowerUpWidget:setLeftRight(false, false, f13_local1, f13_local2)
f13_local3 = f13_local1
end
end
end