Part Break/Sever implemented. Fallback to default renderer if d2d is not available.

This commit is contained in:
GreenComfyTea
2022-06-17 14:24:46 +03:00
parent 7d0adc5139
commit 1a95634ec2
17 changed files with 9365 additions and 3941 deletions

View File

@@ -23,12 +23,6 @@ local check_current_area_training_area_method = village_area_manager_type_def:ge
local lobby_manager_type_definition = sdk.find_type_definition("snow.LobbyManager");
local is_quest_online_method = lobby_manager_type_definition:get_method("IsQuestOnline");
sdk.hook(on_changed_game_status, function(args)
pcall(quest_status.update(args));
end, function(retval)
return retval;
end);
function quest_status.update(args)
local new_quest_status = sdk.to_int64(args[3]);
if new_quest_status ~= nil then
@@ -47,6 +41,10 @@ function quest_status.update(args)
end
end
sdk.hook(on_changed_game_status, function(args)
pcall(quest_status.update, args);
end, function(retval) return retval; end);
function quest_status.init()
if singletons.quest_manager == nil then
return;

View File

@@ -1,12 +1,20 @@
local config = require "MHR_Overlay.Misc.config"
local screen = {};
local config;
local singletons;
screen.width = 1920;
screen.height = 1080;
function screen.update_window_size()
local width, height = d2d.surface_size();
local width;
local height;
if d2d ~= nil then
width, height = d2d.surface_size();
else
width, height = screen.get_game_window_size();
end
if width ~= nil then
screen.width = width;
@@ -17,6 +25,45 @@ function screen.update_window_size()
end
end
local scene_view;
local scene_view_type = sdk.find_type_definition("via.SceneView");
local get_size_method = scene_view_type:get_method("get_Size");
local size_type = get_size_method:get_return_type();
local width_field = size_type:get_field("w");
local height_field = size_type:get_field("h");
function screen.get_game_window_size()
if scene_view == nil then
scene_view = sdk.call_native_func(singletons.scene_manager, sdk.find_type_definition("via.SceneManager"), "get_MainView");
if scene_view == nil then
--log.error("[MHR_Overlay.lua] No scene view");
return;
end
end
local size = get_size_method:call(scene_view);
if size == nil then
--log.error("[MHR_Overlay.lua] No scene view size");
return;
end
local screen_width = width_field:get_data(size);
if screen_width == nil then
--log.error("[MHR_Overlay.lua] No screen width");
return;
end
local screen_height = height_field:get_data(size);
if screen_height == nil then
--log.error("[MHR_Overlay.lua] No screen height");
return;
end
return screen_width, screen_height;
end
function screen.calculate_absolute_coordinates(position)
local _position = {
x = position.x * config.current_config.global_settings.modifiers.global_position_modifier;
@@ -52,6 +99,7 @@ end
function screen.init_module()
config = require("MHR_Overlay.Misc.config");
singletons = require("MHR_Overlay.Game_Handler.singletons");
end
return screen;

View File

@@ -9,6 +9,7 @@ singletons.player_manager = nil;
singletons.village_area_manager = nil;
singletons.gui_manager = nil;
singletons.game_keyboard = nil;
singletons.scene_manager = nil;
function singletons.init()
singletons.init_message_manager();
@@ -19,7 +20,8 @@ function singletons.init()
singletons.init_player_manager();
singletons.init_village_area_manager();
singletons.init_gui_manager();
singletons.init_game_keyboard()
singletons.init_game_keyboard();
singletons.init_scene_manager();
end
function singletons.init_message_manager()
@@ -141,6 +143,19 @@ function singletons.init_game_keyboard()
return singletons.ggame_keyboard;
end
function singletons.init_scene_manager()
if singletons.scene_manager ~= nil then
return;
end
singletons.scene_manager = sdk.get_native_singleton("via.SceneManager");
if singletons.scene_manager == nil then
--log.error("[MHR Overlay] No enemy manager");
end
return singletons.scene_manager;
end
function singletons.init_module()
singletons.init();
end

File diff suppressed because it is too large Load Diff

View File

@@ -91,7 +91,9 @@ language.default_language = {
total_damage = "Total Damage",
player = "Player",
buildup = "Buildup:",
total_buildup = "Total Buildup"
total_buildup = "Total Buildup",
part_break = "Break",
part_sever = "Sever"
},
customization_menu = {
@@ -198,6 +200,8 @@ language.default_language = {
hide_undamaged_parts = "Hide Undamaged Parts",
part_name = "Part Name",
flinch_count = "Flinch Count",
break_count = "Break Count",
break_max_count = "Break Max Count",
orientation = "Orientation",
horizontal = "Horizontal",
@@ -317,7 +321,13 @@ language.default_language = {
filter = "Filter",
top_buildup = "Top Buildup",
total_buildup = "Total Buildup",
buildup_bars_are_relative_to = "Buildup Bars are relative to"
buildup_bars_are_relative_to = "Buildup Bars are relative to",
part_health = "Part Health",
break_health = "Break Health",
break_health_percentage = "Break Health Percentage",
loss_health = "Sever Health",
loss_health_percentage = "Sever Health Percentage"
}
};

View File

@@ -219,9 +219,11 @@ local damage_param_field = enemy_character_base_type_def:get_field("<DamageParam
local damage_param_type = damage_param_field:get_type();
local get_condition_param_method = damage_param_type:get_method("get_ConditionParam");
local stun_param_field = damage_param_type:get_field("_StunParam");
local poison_param_field = damage_param_type:get_field("_PoisonParam");
local blast_param_field = damage_param_type:get_field("_BlastParam");
local poison_param_type = poison_param_field:get_type();
local blast_param_type = blast_param_field:get_type();
@@ -250,6 +252,18 @@ function ailments.update_ailments(enemy, monster)
return;
end
ailments.update_stun_poison_blast_ailments(monster, damage_param);
if not config.current_config.large_monster_UI.dynamic.ailments.visibility
and not config.current_config.large_monster_UI.static.ailments.visibility
and not config.current_config.large_monster_UI.highlighted.ailments.visibility
and not config.current_config.small_monster_UI.ailments.visibility
and not config.current_config.large_monster_UI.dynamic.ailment_buildups.visibility
and not config.current_config.large_monster_UI.static.ailment_buildups.visibility
and not config.current_config.small_monster_UI.ailment_buildups.visibility then
return;
end
local condition_param = get_condition_param_method:call(damage_param);
if condition_param == nil then
@@ -264,7 +278,34 @@ function ailments.update_ailments(enemy, monster)
for index, ailment_param in ipairs(condition_param_table) do
local id = index - 1;
if id == ailments.stun_id or id == ailments.poison_id or id == ailments.blast_id then
goto continue;
end
ailments.update_ailment(monster, ailment_param, id);
::continue::
end
end
function ailments.update_stun_poison_blast_ailments(monster, damage_param)
local stun_param = stun_param_field:get_data(damage_param);
if stun_param ~= nil then
ailments.update_ailment(monster, stun_param, ailments.stun_id);
end
local poison_param = poison_param_field:get_data(damage_param);
if poison_param ~= nil then
ailments.update_ailment(monster, poison_param, ailments.poison_id);
end
local blast_param = blast_param_field:get_data(damage_param);
if blast_param ~= nil then
ailments.update_ailment(monster, blast_param, ailments.blast_id);
end
end
function ailments.update_ailment(monster, ailment_param, id)
local is_enable = get_is_enable_method:call(ailment_param);
local activate_count = get_activate_count_method:call(ailment_param):get_element(0):get_field("mValue");
local buildup = get_stock_method:call(ailment_param):get_element(0):get_field("mValue");
@@ -356,7 +397,6 @@ function ailments.update_ailments(enemy, monster)
monster.ailments[id].minutes_left = minutes_left;
monster.ailments[id].seconds_left = seconds_left;
end
end
end
function ailments.update_last_change_time(monster, id)

View File

@@ -14,25 +14,33 @@ local time;
body_part.list = {};
function body_part.new(REpart, name, id)
function body_part.new(id, name)
local part = {};
part.REpart = REpart;
part.id = id;
part.health = 99999;
part.health = 9999;
part.max_health = 99999;
part.health_percentage = 0;
part.break_health = 9999;
part.break_max_health = 99999;
part.break_health_percentage = 0;
part.lost_health = 9999;
part.loss_max_health = 99999;
part.loss_health_percentage = 0;
part.name = name;
part.flinch_count = 0;
part.break_count = 0;
part.break_max_count = 0;
part.last_change_time = time.total_elapsed_seconds;
body_part.init_dynamic_UI(part);
body_part.init_static_UI(part);
body_part.init_highlighted_UI(part);
return part;
end
@@ -40,62 +48,146 @@ end
function body_part.init_dynamic_UI(part)
part.body_part_dynamic_UI = body_part_UI_entity.new(
config.current_config.large_monster_UI.dynamic.parts.visibility,
config.current_config.large_monster_UI.dynamic.parts.bar,
config.current_config.large_monster_UI.dynamic.parts.part_name_label,
config.current_config.large_monster_UI.dynamic.parts.text_label,
config.current_config.large_monster_UI.dynamic.parts.value_label,
config.current_config.large_monster_UI.dynamic.parts.percentage_label
config.current_config.large_monster_UI.dynamic.parts.part_health.visibility,
config.current_config.large_monster_UI.dynamic.parts.part_health.bar,
config.current_config.large_monster_UI.dynamic.parts.part_health.text_label,
config.current_config.large_monster_UI.dynamic.parts.part_health.value_label,
config.current_config.large_monster_UI.dynamic.parts.part_health.percentage_label,
config.current_config.large_monster_UI.dynamic.parts.part_break.visibility,
config.current_config.large_monster_UI.dynamic.parts.part_break.bar,
config.current_config.large_monster_UI.dynamic.parts.part_break.text_label,
config.current_config.large_monster_UI.dynamic.parts.part_break.value_label,
config.current_config.large_monster_UI.dynamic.parts.part_break.percentage_label,
config.current_config.large_monster_UI.dynamic.parts.part_loss.visibility,
config.current_config.large_monster_UI.dynamic.parts.part_loss.bar,
config.current_config.large_monster_UI.dynamic.parts.part_loss.text_label,
config.current_config.large_monster_UI.dynamic.parts.part_loss.value_label,
config.current_config.large_monster_UI.dynamic.parts.part_loss.percentage_label
);
end
function body_part.init_static_UI(part)
part.body_part_static_UI = body_part_UI_entity.new(
config.current_config.large_monster_UI.static.parts.visibility,
config.current_config.large_monster_UI.static.parts.bar,
config.current_config.large_monster_UI.static.parts.part_name_label,
config.current_config.large_monster_UI.static.parts.text_label,
config.current_config.large_monster_UI.static.parts.value_label,
config.current_config.large_monster_UI.static.parts.percentage_label
config.current_config.large_monster_UI.static.parts.part_health.visibility,
config.current_config.large_monster_UI.static.parts.part_health.bar,
config.current_config.large_monster_UI.static.parts.part_health.text_label,
config.current_config.large_monster_UI.static.parts.part_health.value_label,
config.current_config.large_monster_UI.static.parts.part_health.percentage_label,
config.current_config.large_monster_UI.static.parts.part_break.visibility,
config.current_config.large_monster_UI.static.parts.part_break.bar,
config.current_config.large_monster_UI.static.parts.part_break.text_label,
config.current_config.large_monster_UI.static.parts.part_break.value_label,
config.current_config.large_monster_UI.static.parts.part_break.percentage_label,
config.current_config.large_monster_UI.static.parts.part_loss.visibility,
config.current_config.large_monster_UI.static.parts.part_loss.bar,
config.current_config.large_monster_UI.static.parts.part_loss.text_label,
config.current_config.large_monster_UI.static.parts.part_loss.value_label,
config.current_config.large_monster_UI.static.parts.part_loss.percentage_label
);
end
function body_part.init_highlighted_UI(part)
part.body_part_highlighted_UI = body_part_UI_entity.new(
config.current_config.large_monster_UI.highlighted.parts.visibility,
config.current_config.large_monster_UI.highlighted.parts.bar,
config.current_config.large_monster_UI.highlighted.parts.part_name_label,
config.current_config.large_monster_UI.highlighted.parts.text_label,
config.current_config.large_monster_UI.highlighted.parts.value_label,
config.current_config.large_monster_UI.highlighted.parts.percentage_label
config.current_config.large_monster_UI.highlighted.parts.part_health.visibility,
config.current_config.large_monster_UI.highlighted.parts.part_health.bar,
config.current_config.large_monster_UI.highlighted.parts.part_health.text_label,
config.current_config.large_monster_UI.highlighted.parts.part_health.value_label,
config.current_config.large_monster_UI.highlighted.parts.part_health.percentage_label,
config.current_config.large_monster_UI.highlighted.parts.part_break.visibility,
config.current_config.large_monster_UI.highlighted.parts.part_break.bar,
config.current_config.large_monster_UI.highlighted.parts.part_break.text_label,
config.current_config.large_monster_UI.highlighted.parts.part_break.value_label,
config.current_config.large_monster_UI.highlighted.parts.part_break.percentage_label,
config.current_config.large_monster_UI.highlighted.parts.part_loss.visibility,
config.current_config.large_monster_UI.highlighted.parts.part_loss.bar,
config.current_config.large_monster_UI.highlighted.parts.part_loss.text_label,
config.current_config.large_monster_UI.highlighted.parts.part_loss.value_label,
config.current_config.large_monster_UI.highlighted.parts.part_loss.percentage_label
);
end
function body_part.update(part, new_health, new_max_health)
function body_part.update(part, part_current, part_max, part_break_current, part_break_max, part_loss_current, part_loss_max, part_break_count, part_break_max_count, is_severed)
if part == nil then
return;
end
if new_health > part.health then
if part_current > part.health then
part.flinch_count = part.flinch_count + 1;
end
if part.health ~= new_health then
if part_break_current > part.break_health then
part.break_count = part.break_count + 1;
end
if part.health ~= part_current then
part.last_change_time = time.total_elapsed_seconds;
end
if part.break_health ~= part_break_current then
part.last_change_time = time.total_elapsed_seconds;
end
if part.loss_health ~= part_loss_current then
part.last_change_time = time.total_elapsed_seconds;
end
if part.break_count ~= part_break_count then
part.last_change_time = time.total_elapsed_seconds;
end
if part.break_max_count ~= part_break_max_count then
part.last_change_time = time.total_elapsed_seconds;
end
if part.is_severed ~= is_severed then
part.last_change_time = time.total_elapsed_seconds;
end
part.health = new_health;
part.max_health = new_max_health;
part.health = part_current;
part.max_health = part_max;
part.break_health = part_break_current;
part.break_max_health = part_break_max;
part.loss_health = part_loss_current;
part.loss_max_health = part_loss_max;
part.break_count = part_break_count;
part.break_max_count = part_break_max_count;
part.is_severed = is_severed;
if part.max_health ~= 0 then
part.health_percentage = part.health / part.max_health;
end
if part.break_max_health ~= 0 then
part.break_health_percentage = part.break_health / part.break_max_health;
end
if part.loss_max_health ~= 0 then
part.loss_health_percentage = part.loss_health / part.loss_max_health;
end
end
function body_part.draw_dynamic(monster, parts_position_on_screen, opacity_scale)
--sort parts here
local displayed_parts = {};
for REpart, part in pairs(monster.parts) do
if config.current_config.large_monster_UI.dynamic.parts.settings.hide_undamaged_parts and part.health == part.max_health and part.flinch_count == 0 then
if config.current_config.large_monster_UI.dynamic.parts.settings.hide_undamaged_parts
and part.health == part.max_health and part.flinch_count == 0
and ((part.break_health == part.break_max_health and part.break_count == 0) or part.break_max_health < 0)
and ((part.loss_health == part.loss_max_health and not part.is_severed) or part.loss_max_health < 0) then
goto continue;
end
if (not part.body_part_dynamic_UI.flinch_visibility)
and (not part.body_part_dynamic_UI.break_visibility or part.break_max_health < 0 or part.break_count >= part.break_max_count)
and (not part.body_part_dynamic_UI.loss_visibility or part.loss_max_health < 0 or part.is_severed) then
goto continue;
end
@@ -137,6 +229,66 @@ function body_part.draw_dynamic(monster, parts_position_on_screen, opacity_scale
return left.health_percentage < right.health_percentage;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Flinch Count" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.flinch_count > right.flinch_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.flinch_count < right.flinch_count;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Break Health" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health > right.break_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health < right.break_health;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Break Health Percentage" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage > right.break_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage < right.break_health_percentage;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Break Count" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_count > right.break_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_count < right.break_count;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Sever Health" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health > right.loss_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health < right.loss_health;
end);
end
elseif config.current_config.large_monster_UI.dynamic.parts.sorting.type == "Sever Health Percentage" then
if config.current_config.large_monster_UI.dynamic.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage > right.loss_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage < right.loss_health_percentage;
end);
end
end
local last_part_position_on_screen;
@@ -155,11 +307,19 @@ function body_part.draw_dynamic(monster, parts_position_on_screen, opacity_scale
end
function body_part.draw_static(monster, parts_position_on_screen, opacity_scale)
--sort parts here
local displayed_parts = {};
for REpart, part in pairs(monster.parts) do
if config.current_config.large_monster_UI.static.parts.settings.hide_undamaged_parts and part.health == part.max_health and part.flinch_count == 0 then
if config.current_config.large_monster_UI.static.parts.settings.hide_undamaged_parts
and part.health == part.max_health and part.flinch_count == 0
and ((part.break_health == part.break_max_health and part.break_count == 0) or part.break_max_health < 0)
and ((part.loss_health == part.loss_max_health and not part.is_severed) or part.loss_max_health < 0) then
goto continue;
end
if (not part.body_part_static_UI.flinch_visibility)
and (not part.body_part_static_UI.break_visibility or part.break_max_health < 0 or part.break_count >= part.break_max_count)
and (not part.body_part_static_UI.loss_visibility or part.loss_max_health < 0 or part.is_severed) then
goto continue;
end
@@ -201,6 +361,66 @@ function body_part.draw_static(monster, parts_position_on_screen, opacity_scale)
return left.health_percentage < right.health_percentage;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Flinch Count" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.flinch_count > right.flinch_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.flinch_count < right.flinch_count;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Break Health" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health > right.break_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health < right.break_health;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Break Health Percentage" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage > right.break_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage < right.break_health_percentage;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Break Count" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_count > right.break_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_count < right.break_count;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Sever Health" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health > right.loss_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health < right.loss_health;
end);
end
elseif config.current_config.large_monster_UI.static.parts.sorting.type == "Sever Health Percentage" then
if config.current_config.large_monster_UI.static.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage > right.loss_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage < right.loss_health_percentage;
end);
end
end
local last_part_position_on_screen;
@@ -219,10 +439,18 @@ function body_part.draw_static(monster, parts_position_on_screen, opacity_scale)
end
function body_part.draw_highlighted(monster, parts_position_on_screen, opacity_scale)
--sort parts here
local displayed_parts = {};
for REpart, part in pairs(monster.parts) do
if config.current_config.large_monster_UI.highlighted.parts.settings.hide_undamaged_parts and part.health == part.max_health and part.flinch_count == 0 then
if config.current_config.large_monster_UI.highlighted.parts.settings.hide_undamaged_parts
and part.health == part.max_health and part.flinch_count == 0
and ((part.break_health == part.break_max_health and part.break_count == 0) or part.break_max_health < 0)
and ((part.loss_health == part.loss_max_health and not part.is_severed) or part.loss_max_health < 0) then
goto continue;
end
if (not part.body_part_highlighted_UI.flinch_visibility)
and (not part.body_part_highlighted_UI.break_visibility or part.break_max_health < 0 or part.break_count >= part.break_max_count)
and (not part.body_part_highlighted_UI.loss_visibility or part.loss_max_health < 0 or part.is_severed) then
goto continue;
end
@@ -264,6 +492,66 @@ function body_part.draw_highlighted(monster, parts_position_on_screen, opacity_s
return left.health_percentage < right.health_percentage;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Flinch Count" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.flinch_count > right.flinch_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.flinch_count < right.flinch_count;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Break Health" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health > right.break_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health < right.break_health;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Break Health Percentage" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage > right.break_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_health_percentage < right.break_health_percentage;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Break Count" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.break_count > right.break_count;
end);
else
table.sort(displayed_parts, function(left, right)
return left.break_count < right.break_count;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Sever Health" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health > right.loss_health;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health < right.loss_health;
end);
end
elseif config.current_config.large_monster_UI.highlighted.parts.sorting.type == "Sever Health Percentage" then
if config.current_config.large_monster_UI.highlighted.parts.sorting.reversed_order then
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage > right.loss_health_percentage;
end);
else
table.sort(displayed_parts, function(left, right)
return left.loss_health_percentage < right.loss_health_percentage;
end);
end
end
local last_part_position_on_screen;

View File

@@ -22,6 +22,7 @@ large_monster.list = {};
function large_monster.new(enemy)
local monster = {};
monster.enemy = enemy;
monster.is_large = true;
monster.id = 0;
@@ -330,6 +331,8 @@ end
local physical_param_field = enemy_character_base_type_def:get_field("<PhysicalParam>k__BackingField");
local stamina_param_field = enemy_character_base_type_def:get_field("<StaminaParam>k__BackingField");
local anger_param_field = enemy_character_base_type_def:get_field("<AngerParam>k__BackingField");
local damage_param_field = enemy_character_base_type_def:get_field("<DamageParam>k__BackingField");
local check_die_method = enemy_character_base_type_def:get_method("checkDie");
local is_disp_icon_mini_map_method = enemy_character_base_type_def:get_method("isDispIconMiniMap");
@@ -457,6 +460,12 @@ function large_monster.update(enemy)
return;
end
local damage_param = damage_param_field:get_data(enemy);
if damage_param == nil then
customization_menu.status = "No damage param";
return;
end
local health = get_current_method:call(vital_param);
local max_health = get_max_method:call(vital_param);
local capture_health = get_capture_hp_vital_method:call(physical_param);
@@ -490,7 +499,7 @@ function large_monster.update(enemy)
customization_menu.status = "No vital list";
return;
end
local vital_list_count = vital_list:call("get_Count");
if vital_list_count == nil or vital_list_count < 2 then
customization_menu.status = "No vital list count";
@@ -509,53 +518,79 @@ function large_monster.update(enemy)
return;
end
local last_REpart = part_list:call("get_Item", part_list_count - 1);
local last_REpart_health = 9999999;
if last_REpart ~= nil then
local _last_REpart_health = last_REpart:call("get_Current");
if last_REpart_health ~= nil then
last_REpart_health = _last_REpart_health;
end
local enemy_parts_damage_info = damage_param:get_field("_EnemyPartsDamageInfo");
local enemy_parts_info_array;
if enemy_parts_damage_info ~= nil then
enemy_parts_info_array = enemy_parts_damage_info:call("get_PartsInfo");
end
local part_id = 1;
for i = 0, part_list_count - 1 do
local REpart = part_list:call("get_Item", i);
if REpart == nil then
goto continue;
local enemy_parts_info;
if enemy_parts_info_array ~= nil then
enemy_parts_info = enemy_parts_info_array[i];
end
local part_health = REpart:call("get_Current");
if part_health == nil then
goto continue;
end
local part_max_health = REpart:call("get_Max");
if part_max_health == nil or part_max_health <= 0 then
goto continue;
end
local part = monster.parts[REpart];
local part = monster.parts[part_id];
if part == nil then
local part_name = part_names.get_part_name(monster.id, part_id);
if part_name ~= "" then
part = body_part.new(REpart, part_name, part_id);
monster.parts[REpart] = part;
if part_name == "" then
goto continue;
else
part = body_part.new(part_id, part_name);
monster.parts[part_id] = part;
end
end
local part_vital = physical_param:call("getVital", 1, i);
local part_current = -1;
local part_max = -1;
body_part.update(part, part_health, part_max_health);
if part_vital ~= nil then
part_current = part_vital:call("get_Current") or -1;
part_max = part_vital:call("get_Max") or -1;
end
local part_break_vital = physical_param:call("getVital", 2, i);
local part_break_current = -1;
local part_break_max = -1;
if part_break_vital ~= nil then
part_break_current = part_break_vital:call("get_Current") or -1;
part_break_max = part_break_vital:call("get_Max") or -1;
end
local part_loss_vital = physical_param:call("getVital", 3, i);
local part_loss_current = -1;
local part_loss_max = -1;
if part_loss_vital ~= nil then
part_loss_current = part_loss_vital:call("get_Current") or -1;
part_loss_max = part_loss_vital:call("get_Max") or -1;
end
local part_break_count = -1;
local part_break_max_count = -1;
local is_severed = false;
if enemy_parts_info ~= nil then
part_break_count = enemy_parts_info:call("get_PartsBreakDamageLevel") or -1;
part_break_max_count = enemy_parts_info:call("get_PartsBreakDamageMaxLevel") or -1;
is_severed = enemy_parts_info:call("get_PartsLossState") or false;
end
body_part.update(part, part_current, part_max, part_break_current, part_break_max, part_loss_current, part_loss_max, part_break_count, part_break_max_count, is_severed);
part_id = part_id + 1;
::continue::
end
if health ~= nil then
monster.health = health;
end
if max_health ~= nil then
monster.max_health = max_health;
end
@@ -747,7 +782,6 @@ function large_monster.draw_static(monster, position_on_screen, opacity_scale)
monster.health_static_UI.bar.colors = config.current_config.large_monster_UI.static.health.bar.normal_colors;
end
drawing.draw_label(monster.static_name_label, position_on_screen, opacity_scale, monster_name_text);
local health_position_on_screen = {
@@ -894,6 +928,7 @@ function large_monster.init_module()
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity");
ailment_UI_entity = require("MHR_Overlay.UI.UI_Entities.ailment_UI_entity");
screen = require("MHR_Overlay.Game_Handler.screen");
drawing = require("MHR_Overlay.UI.drawing");
part_names = require("MHR_Overlay.Misc.part_names");

View File

@@ -3,38 +3,84 @@ local config;
local table_helpers;
local drawing;
function body_part_UI_entity.new(visibility, bar, name_label, text_label, value_label, percentage_label)
function body_part_UI_entity.new(part_visibility, part_name_label,
flinch_visibility, flinch_bar, flinch_text_label, flinch_value_label, flinch_percentage_label,
break_visibility, break_bar, break_text_label, break_value_label, break_percentage_label,
loss_visibility, loss_bar, loss_text_label, loss_value_label, loss_health_percentage_label)
local entity = {};
entity.visibility = visibility;
entity.bar = table_helpers.deep_copy(bar);
entity.name_label = table_helpers.deep_copy(name_label);
entity.text_label = table_helpers.deep_copy(text_label);
entity.value_label = table_helpers.deep_copy(value_label);
entity.percentage_label = table_helpers.deep_copy(percentage_label);
entity.part_visibility = part_visibility;
entity.flinch_visibility = flinch_visibility;
entity.break_visibility = break_visibility;
entity.loss_visibility = loss_visibility;
entity.bar.offset.x = entity.bar.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.bar.offset.y = entity.bar.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.bar.size.width = entity.bar.size.width * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.bar.size.height = entity.bar.size.height * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.part_name_label = table_helpers.deep_copy(part_name_label);
entity.name_label.offset.x = entity.name_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.name_label.offset.y = entity.name_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.part_name_label.offset.x = entity.part_name_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.part_name_label.offset.y = entity.part_name_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.text_label.offset.x = entity.text_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.text_label.offset.y = entity.text_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_bar = table_helpers.deep_copy(flinch_bar);
entity.flinch_text_label = table_helpers.deep_copy(flinch_text_label);
entity.flinch_value_label = table_helpers.deep_copy(flinch_value_label);
entity.flinch_percentage_label = table_helpers.deep_copy(flinch_percentage_label);
entity.value_label.offset.x = entity.value_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.value_label.offset.y = entity.value_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_bar.offset.x = entity.flinch_bar.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_bar.offset.y = entity.flinch_bar.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_bar.size.width = entity.flinch_bar.size.width * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_bar.size.height = entity.flinch_bar.size.height * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.percentage_label.offset.x = entity.percentage_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.percentage_label.offset.y = entity.percentage_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_text_label.offset.x = entity.flinch_text_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_text_label.offset.y = entity.flinch_text_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_value_label.offset.x = entity.flinch_value_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_value_label.offset.y = entity.flinch_value_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_percentage_label.offset.x = entity.flinch_percentage_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.flinch_percentage_label.offset.y = entity.flinch_percentage_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_bar = table_helpers.deep_copy(break_bar);
entity.break_text_label = table_helpers.deep_copy(break_text_label);
entity.break_value_label = table_helpers.deep_copy(break_value_label);
entity.break_percentage_label = table_helpers.deep_copy(break_percentage_label);
entity.break_bar.offset.x = entity.break_bar.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_bar.offset.y = entity.break_bar.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_bar.size.width = entity.break_bar.size.width * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_bar.size.height = entity.break_bar.size.height * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_text_label.offset.x = entity.break_text_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_text_label.offset.y = entity.break_text_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_value_label.offset.x = entity.break_value_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_value_label.offset.y = entity.break_value_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_percentage_label.offset.x = entity.break_percentage_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.break_percentage_label.offset.y = entity.break_percentage_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_bar = table_helpers.deep_copy(loss_bar);
entity.loss_text_label = table_helpers.deep_copy(loss_text_label);
entity.loss_value_label = table_helpers.deep_copy(loss_value_label);
entity.loss_health_percentage_label = table_helpers.deep_copy(loss_health_percentage_label);
entity.loss_bar.offset.x = entity.loss_bar.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_bar.offset.y = entity.loss_bar.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_bar.size.width = entity.loss_bar.size.width * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_bar.size.height = entity.loss_bar.size.height * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_text_label.offset.x = entity.loss_text_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_text_label.offset.y = entity.loss_text_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_value_label.offset.x = entity.loss_value_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_value_label.offset.y = entity.loss_value_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_health_percentage_label.offset.x = entity.loss_health_percentage_label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
entity.loss_health_percentage_label.offset.y = entity.loss_health_percentage_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
return entity;
end
function body_part_UI_entity.draw_dynamic(part, position_on_screen, opacity_scale)
if not part.body_part_dynamic_UI.visibility then
if not part.body_part_dynamic_UI.part_visibility then
return;
end
@@ -43,19 +89,80 @@ function body_part_UI_entity.draw_dynamic(part, position_on_screen, opacity_scal
part_name = part.name .. " ";
end
if config.current_config.large_monster_UI.dynamic.parts.part_name_label.include.flinch_count and part.flinch_count ~= 0 then
part_name = part_name .. "x" .. tostring(part.flinch_count);
part_name = part_name .. "x" .. tostring(part.flinch_count) .. " ";
end
if part.break_max_count ~= 0 then
if config.current_config.large_monster_UI.dynamic.parts.part_name_label.include.break_count then
if config.current_config.large_monster_UI.dynamic.parts.part_name_label.include.break_max_count then
part_name = part_name .. tostring(part.break_count) .. "/" .. tostring(part.break_max_count);
elseif part.flinch_count ~= 0 then
part_name = part_name .. "x" .. tostring(part.break_count);
end
elseif config.current_config.large_monster_UI.dynamic.parts.part_name_label.include.break_max_count then
part_name = part_name .. "/" .. tostring(part.break_max_count);
end
end
drawing.draw_bar(part.body_part_dynamic_UI.bar, position_on_screen, opacity_scale, part.health_percentage);
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
local break_health_string = string.format("%.0f/%.0f", part.break_health, part.break_max_health);
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
local flinch_position_on_screen = {
x = position_on_screen.x + config.current_config.large_monster_UI.dynamic.parts.part_health.offset.x,
y = position_on_screen.y + config.current_config.large_monster_UI.dynamic.parts.part_health.offset.y,
visibility = part.body_part_dynamic_UI.flinch_visibility
};
drawing.draw_label(part.body_part_dynamic_UI.name_label, position_on_screen, opacity_scale, part_name);
drawing.draw_label(part.body_part_dynamic_UI.text_label, position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_dynamic_UI.value_label, position_on_screen, opacity_scale, part.health, part.max_health);
drawing.draw_label(part.body_part_dynamic_UI.percentage_label, position_on_screen, opacity_scale, 100 * part.health_percentage);
local break_position_on_screen = {
x = position_on_screen.x + config.current_config.large_monster_UI.dynamic.parts.part_break.offset.x,
y = position_on_screen.y + config.current_config.large_monster_UI.dynamic.parts.part_break.offset.y,
visibility = part.body_part_dynamic_UI.flinch_visibility
};
local loss_position_on_screen = {
x = position_on_screen.x + config.current_config.large_monster_UI.dynamic.parts.part_loss.offset.x,
y = position_on_screen.y + config.current_config.large_monster_UI.dynamic.parts.part_loss.offset.y,
};
if part.body_part_dynamic_UI.flinch_visibility then
drawing.draw_bar(part.body_part_dynamic_UI.flinch_bar, flinch_position_on_screen, opacity_scale, part.health_percentage);
end
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and part.break_count < part.break_max_count then
drawing.draw_bar(part.body_part_dynamic_UI.break_bar, break_position_on_screen, opacity_scale, part.break_health_percentage);
end
if part.body_part_dynamic_UI.loss_visibility and part.loss_max_health ~= -1 and not part.is_severed then
drawing.draw_bar(part.body_part_dynamic_UI.loss_bar, loss_position_on_screen, opacity_scale, part.loss_health_percentage);
end
drawing.draw_label(part.body_part_dynamic_UI.part_name_label, position_on_screen, opacity_scale, part_name);
if part.body_part_dynamic_UI.flinch_visibility then
drawing.draw_label(part.body_part_dynamic_UI.flinch_text_label, flinch_position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_dynamic_UI.flinch_value_label, flinch_position_on_screen, opacity_scale, health_string);
drawing.draw_label(part.body_part_dynamic_UI.flinch_percentage_label, flinch_position_on_screen, opacity_scale, 100 * part.health_percentage);
end
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and part.break_count < part.break_max_count then
drawing.draw_label(part.body_part_dynamic_UI.break_text_label, break_position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_dynamic_UI.break_value_label, break_position_on_screen, opacity_scale, break_health_string);
drawing.draw_label(part.body_part_dynamic_UI.break_percentage_label, break_position_on_screen, opacity_scale, 100 * part.break_health_percentage);
end
if part.body_part_dynamic_UI.loss_visibility and part.loss_max_health ~= -1 and not part.is_severed then
drawing.draw_label(part.body_part_dynamic_UI.loss_text_label, loss_position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_dynamic_UI.loss_value_label, loss_position_on_screen, opacity_scale, loss_health_string);
drawing.draw_label(part.body_part_dynamic_UI.loss_health_percentage_label, loss_position_on_screen, opacity_scale, 100 * part.loss_health_percentage);
end
end
function body_part_UI_entity.draw_static(part, position_on_screen, opacity_scale)
if not part.body_part_static_UI.visibility then
if not part.body_part_static_UI.part_visibility then
return;
end
@@ -64,19 +171,80 @@ function body_part_UI_entity.draw_static(part, position_on_screen, opacity_scale
part_name = part.name .. " ";
end
if config.current_config.large_monster_UI.static.parts.part_name_label.include.flinch_count and part.flinch_count ~= 0 then
part_name = part_name .. "x" .. tostring(part.flinch_count);
part_name = part_name .. "x" .. tostring(part.flinch_count) .. " ";
end
drawing.draw_bar(part.body_part_static_UI.bar, position_on_screen, opacity_scale, part.health_percentage);
drawing.draw_label(part.body_part_static_UI.name_label, position_on_screen, opacity_scale, part_name);
drawing.draw_label(part.body_part_static_UI.text_label, position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_static_UI.value_label, position_on_screen, opacity_scale, part.health, part.max_health);
drawing.draw_label(part.body_part_static_UI.percentage_label, position_on_screen, opacity_scale, 100 * part.health_percentage);
if part.break_max_count ~= 0 then
if config.current_config.large_monster_UI.static.parts.part_name_label.include.break_count then
if config.current_config.large_monster_UI.static.parts.part_name_label.include.break_max_count then
part_name = part_name .. tostring(part.break_count) .. "/" .. tostring(part.break_max_count);
elseif part.flinch_count ~= 0 then
part_name = part_name .. "x" .. tostring(part.break_count);
end
elseif config.current_config.large_monster_UI.static.parts.part_name_label.include.break_max_count then
part_name = part_name .. "/" .. tostring(part.break_max_count);
end
end
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
local break_health_string = string.format("%.0f/%.0f", part.break_health, part.break_max_health);
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
local flinch_position_on_screen = {
x = position_on_screen.x + config.current_config.large_monster_UI.static.parts.part_health.offset.x,
y = position_on_screen.y + config.current_config.large_monster_UI.static.parts.part_health.offset.y,
visibility = part.body_part_static_UI.flinch_visibility
};
local break_position_on_screen = {
x = position_on_screen.x + config.current_config.large_monster_UI.static.parts.part_break.offset.x,
y = position_on_screen.y + config.current_config.large_monster_UI.static.parts.part_break.offset.y,
visibility = part.body_part_static_UI.flinch_visibility
};
local loss_position_on_screen = {
x = position_on_screen.x + config.current_config.large_monster_UI.static.parts.part_loss.offset.x,
y = position_on_screen.y + config.current_config.large_monster_UI.static.parts.part_loss.offset.y,
};
if part.body_part_static_UI.flinch_visibility then
drawing.draw_bar(part.body_part_static_UI.flinch_bar, flinch_position_on_screen, opacity_scale, part.health_percentage);
end
if part.body_part_static_UI.break_visibility and part.break_max_health ~= -1 and part.break_count < part.break_max_count then
drawing.draw_bar(part.body_part_static_UI.break_bar, break_position_on_screen, opacity_scale, part.break_health_percentage);
end
if part.body_part_static_UI.loss_visibility and part.loss_max_health ~= -1 and not part.is_severed then
drawing.draw_bar(part.body_part_static_UI.loss_bar, loss_position_on_screen, opacity_scale, part.loss_health_percentage);
end
drawing.draw_label(part.body_part_static_UI.part_name_label, position_on_screen, opacity_scale, part_name);
if part.body_part_static_UI.flinch_visibility then
drawing.draw_label(part.body_part_static_UI.flinch_text_label, flinch_position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_static_UI.flinch_value_label, flinch_position_on_screen, opacity_scale, health_string);
drawing.draw_label(part.body_part_static_UI.flinch_percentage_label, flinch_position_on_screen, opacity_scale, 100 * part.health_percentage);
end
if part.body_part_static_UI.break_visibility and part.break_max_health ~= -1 and part.break_count < part.break_max_count then
drawing.draw_label(part.body_part_static_UI.break_text_label, break_position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_static_UI.break_value_label, break_position_on_screen, opacity_scale, break_health_string);
drawing.draw_label(part.body_part_static_UI.break_percentage_label, break_position_on_screen, opacity_scale, 100 * part.break_health_percentage);
end
if part.body_part_static_UI.loss_visibility and part.loss_max_health ~= -1 and not part.is_severed then
drawing.draw_label(part.body_part_static_UI.loss_text_label, loss_position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_static_UI.loss_value_label, loss_position_on_screen, opacity_scale, loss_health_string);
drawing.draw_label(part.body_part_static_UI.loss_health_percentage_label, loss_position_on_screen, opacity_scale, 100 * part.loss_health_percentage);
end
end
function body_part_UI_entity.draw_highlighted(part, position_on_screen, opacity_scale)
if not part.body_part_highlighted_UI.visibility then
if not part.body_part_highlighted_UI.part_visibility then
return;
end
@@ -85,15 +253,76 @@ function body_part_UI_entity.draw_highlighted(part, position_on_screen, opacity_
part_name = part.name .. " ";
end
if config.current_config.large_monster_UI.highlighted.parts.part_name_label.include.flinch_count and part.flinch_count ~= 0 then
part_name = part_name .. "x" .. tostring(part.flinch_count);
part_name = part_name .. "x" .. tostring(part.flinch_count) .. " ";
end
if part.break_max_count ~= 0 then
if config.current_config.large_monster_UI.highlighted.parts.part_name_label.include.break_count then
if config.current_config.large_monster_UI.highlighted.parts.part_name_label.include.break_max_count then
part_name = part_name .. tostring(part.break_count) .. "/" .. tostring(part.break_max_count);
elseif part.flinch_count ~= 0 then
part_name = part_name .. "x" .. tostring(part.break_count);
end
elseif config.current_config.large_monster_UI.highlighted.parts.part_name_label.include.break_max_count then
part_name = part_name .. "/" .. tostring(part.break_max_count);
end
end
drawing.draw_bar(part.body_part_highlighted_UI.bar, position_on_screen, opacity_scale, part.health_percentage);
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
local break_health_string = string.format("%.0f/%.0f", part.break_health, part.break_max_health);
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
local flinch_position_on_screen = {
x = position_on_screen.x + config.current_config.large_monster_UI.highlighted.parts.part_health.offset.x,
y = position_on_screen.y + config.current_config.large_monster_UI.highlighted.parts.part_health.offset.y,
visibility = part.body_part_highlighted_UI.flinch_visibility
};
drawing.draw_label(part.body_part_highlighted_UI.name_label, position_on_screen, opacity_scale, part_name);
drawing.draw_label(part.body_part_highlighted_UI.text_label, position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_highlighted_UI.value_label, position_on_screen, opacity_scale, part.health, part.max_health);
drawing.draw_label(part.body_part_highlighted_UI.percentage_label, position_on_screen, opacity_scale, 100 * part.health_percentage);
local break_position_on_screen = {
x = position_on_screen.x + config.current_config.large_monster_UI.highlighted.parts.part_break.offset.x,
y = position_on_screen.y + config.current_config.large_monster_UI.highlighted.parts.part_break.offset.y,
visibility = part.body_part_highlighted_UI.flinch_visibility
};
local loss_position_on_screen = {
x = position_on_screen.x + config.current_config.large_monster_UI.highlighted.parts.part_loss.offset.x,
y = position_on_screen.y + config.current_config.large_monster_UI.highlighted.parts.part_loss.offset.y,
};
if part.body_part_highlighted_UI.flinch_visibility then
drawing.draw_bar(part.body_part_highlighted_UI.flinch_bar, flinch_position_on_screen, opacity_scale, part.health_percentage);
end
if part.body_part_highlighted_UI.break_visibility and part.break_max_health ~= -1 and part.break_count < part.break_max_count then
drawing.draw_bar(part.body_part_highlighted_UI.break_bar, break_position_on_screen, opacity_scale, part.break_health_percentage);
end
if part.body_part_highlighted_UI.loss_visibility and part.loss_max_health ~= -1 and not part.is_severed then
drawing.draw_bar(part.body_part_highlighted_UI.loss_bar, loss_position_on_screen, opacity_scale, part.loss_health_percentage);
end
drawing.draw_label(part.body_part_highlighted_UI.part_name_label, position_on_screen, opacity_scale, part_name);
if part.body_part_highlighted_UI.flinch_visibility then
drawing.draw_label(part.body_part_highlighted_UI.flinch_text_label, flinch_position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_highlighted_UI.flinch_value_label, flinch_position_on_screen, opacity_scale, health_string);
drawing.draw_label(part.body_part_highlighted_UI.flinch_percentage_label, flinch_position_on_screen, opacity_scale, 100 * part.health_percentage);
end
if part.body_part_highlighted_UI.break_visibility and part.break_max_health ~= -1 and part.break_count < part.break_max_count then
drawing.draw_label(part.body_part_highlighted_UI.break_text_label, break_position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_highlighted_UI.break_value_label, break_position_on_screen, opacity_scale, break_health_string);
drawing.draw_label(part.body_part_highlighted_UI.break_percentage_label, break_position_on_screen, opacity_scale, 100 * part.break_health_percentage);
end
if part.body_part_highlighted_UI.loss_visibility and part.loss_max_health ~= -1 and not part.is_severed then
drawing.draw_label(part.body_part_highlighted_UI.loss_text_label, loss_position_on_screen, opacity_scale);
drawing.draw_label(part.body_part_highlighted_UI.loss_value_label, loss_position_on_screen, opacity_scale, loss_health_string);
drawing.draw_label(part.body_part_highlighted_UI.loss_health_percentage_label, loss_position_on_screen, opacity_scale, 100 * part.loss_health_percentage);
end
end
function body_part_UI_entity.init_module()

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,17 @@ function drawing.init_font()
drawing.font = d2d.Font.new(config.current_config.global_settings.UI_font.family, config.current_config.global_settings.UI_font.size, config.current_config.global_settings.UI_font.bold, config.current_config.global_settings.UI_font.italic);
end
function drawing.argb_color_to_abgr_color(argb_color)
local alpha = (argb_color >> 24) & 0xFF;
local red = (argb_color >> 16) & 0xFF;
local green = (argb_color >> 8) & 0xFF;
local blue = argb_color & 0xFF;
local abgr_color = 0x1000000 * alpha + 0x10000 * blue + 0x100 * green + red;
return abgr_color;
end
function drawing.color_to_argb(color)
local alpha = (color >> 24) & 0xFF;
local red = (color >> 16) & 0xFF;
@@ -68,14 +79,26 @@ function drawing.draw_label(label, position, opacity_scale, ...)
new_shadow_color = drawing.scale_color_opacity(new_shadow_color, opacity_scale);
end
d2d.text(drawing.font, text, position_x + label.shadow.offset.x, position_y + label.shadow.offset.y, new_shadow_color);
if d2d ~= nil then
d2d.text(drawing.font, text, position_x + label.shadow.offset.x, position_y + label.shadow.offset.y, new_shadow_color);
else
new_shadow_color = drawing.argb_color_to_abgr_color(new_shadow_color);
draw.text(text, position_x + label.shadow.offset.x, position_y + label.shadow.offset.y, new_shadow_color);
end
end
local new_color = label.color;
if opacity_scale < 1 then
new_color = drawing.scale_color_opacity(new_color, opacity_scale);
end
d2d.text(drawing.font, text, position_x, position_y, new_color);
if d2d ~= nil then
d2d.text(drawing.font, text, position_x, position_y, new_color);
else
new_color = drawing.argb_color_to_abgr_color(new_color);
draw.text(text, position_x, position_y, new_color);
end
end
function drawing.draw_bar(bar, position, opacity_scale, percentage)
@@ -106,9 +129,20 @@ function drawing.draw_bar(bar, position, opacity_scale, percentage)
end
-- foreground
d2d.fill_rect(position_x, position_y, foreground_width, bar.size.height, new_foreground_color);
if d2d ~= nil then
d2d.fill_rect(position_x, position_y, foreground_width, bar.size.height, new_foreground_color);
else
new_foreground_color = drawing.argb_color_to_abgr_color(new_foreground_color);
draw.filled_rect(position_x, position_y, foreground_width, bar.size.height, new_foreground_color)
end
-- background
d2d.fill_rect(position_x + foreground_width, position_y, background_width, bar.size.height, new_background_color);
if d2d ~= nil then
d2d.fill_rect(position_x + foreground_width, position_y, background_width, bar.size.height, new_background_color);
else
new_background_color = drawing.argb_color_to_abgr_color(new_background_color);
draw.filled_rect(position_x + foreground_width, position_y, background_width, bar.size.height, new_background_color)
end
end
function drawing.draw_capture_line(bar, position, opacity_scale, percentage)
@@ -130,9 +164,13 @@ function drawing.draw_capture_line(bar, position, opacity_scale, percentage)
if opacity_scale < 1 then
color = drawing.scale_color_opacity(color, opacity_scale);
end
d2d.fill_rect(position_x, position_y, bar.capture_line.size.width, bar.capture_line.size.height, color);
if d2d ~= nil then
d2d.fill_rect(position_x, position_y, bar.capture_line.size.width, bar.capture_line.size.height, color);
else
color = drawing.argb_color_to_abgr_color(color);
draw.filled_rect(position_x, position_y, bar.capture_line.size.width, bar.capture_line.size.height, color)
end
end
function drawing.init_module()