mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-25 04:48:22 -08:00
Added Buddies to Damage Meter UI
This commit is contained in:
@@ -83,19 +83,17 @@ function damage_hook.update_damage(enemy, enemy_calc_damage_info)
|
||||
end
|
||||
|
||||
local attacker_id = get_attacker_id_method:call(enemy_calc_damage_info);
|
||||
local otomo_id = attacker_id;
|
||||
local attacker_type = get_damage_attacker_type_method:call(enemy_calc_damage_info);
|
||||
local is_marionette_attack = is_marionette_attack_method:call(enemy_calc_damage_info)
|
||||
|
||||
-- 4 is virtual player in singleplayer that "owns" 2nd otomo
|
||||
if not quest_status.is_online and attacker_id == 4 then
|
||||
--attacker_id = player.myself.id;
|
||||
end
|
||||
local is_otomo_attack = attacker_type >= 21 and attacker_type <= 23;
|
||||
|
||||
if is_marionette_attack then
|
||||
large_monster.update_all_riders();
|
||||
for enemy, monster in pairs(large_monster.list) do
|
||||
if monster.unique_id == attacker_id then
|
||||
--attacker_id = monster.rider_id;
|
||||
attacker_id = monster.rider_id;
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -154,24 +152,6 @@ function damage_hook.update_damage(enemy, enemy_calc_damage_info)
|
||||
|
||||
local damage_source_type = damage_hook.get_damage_source_type(attacker_type, is_marionette_attack);
|
||||
|
||||
local attacking_player = non_players.get_servant(attacker_id);
|
||||
if attacking_player == nil then
|
||||
attacking_player = player.get_player(attacker_id);
|
||||
end
|
||||
|
||||
--[[xy = xy .. "\nPlayer: " .. tostring(attacker_id) ..
|
||||
" " .. tostring(attacking_player.name) ..
|
||||
" Damage: " .. tostring(damage_object.total_damage) ..
|
||||
" Type: (" .. tostring(attacker_type) ..
|
||||
") " ..
|
||||
" Condition Damage: " .. tostring(condition_damage) ..
|
||||
" Condition Type: (" .. tostring(attacker_type) ..
|
||||
") " .. tostring(condition_type);
|
||||
|
||||
if string.len(xy) > 2300 then
|
||||
xy = "";
|
||||
end--]]
|
||||
|
||||
local monster;
|
||||
if is_large_monster then
|
||||
monster = large_monster.get_monster(enemy);
|
||||
@@ -179,24 +159,70 @@ function damage_hook.update_damage(enemy, enemy_calc_damage_info)
|
||||
monster = small_monster.get_monster(enemy);
|
||||
end
|
||||
|
||||
local stun_damage = stun_damage_field:get_data(enemy_calc_damage_info);
|
||||
if attacking_player ~= nil then
|
||||
ailments.apply_ailment_buildup(monster, attacker_id, ailments.stun_id, stun_damage);
|
||||
local attacking_player = nil;
|
||||
local attacking_otomo = nil;
|
||||
|
||||
ailments.apply_ailment_buildup(monster, attacker_id, condition_type, condition_damage);
|
||||
ailments.apply_ailment_buildup(monster, attacker_id, condition_type2, condition_damage2);
|
||||
ailments.apply_ailment_buildup(monster, attacker_id, condition_type3, condition_damage3);
|
||||
if not is_otomo_attack then
|
||||
attacking_player = player.get_player(attacker_id);
|
||||
|
||||
if attacking_player == nil then
|
||||
attacking_player = non_players.get_servant(attacker_id);
|
||||
end
|
||||
|
||||
local stun_damage = stun_damage_field:get_data(enemy_calc_damage_info);
|
||||
if attacking_player ~= nil then
|
||||
ailments.apply_ailment_buildup(monster, attacker_id, ailments.stun_id, stun_damage);
|
||||
|
||||
ailments.apply_ailment_buildup(monster, attacker_id, condition_type, condition_damage);
|
||||
ailments.apply_ailment_buildup(monster, attacker_id, condition_type2, condition_damage2);
|
||||
ailments.apply_ailment_buildup(monster, attacker_id, condition_type3, condition_damage3);
|
||||
end
|
||||
else
|
||||
if attacker_id < 4 then
|
||||
attacking_player = player.get_player(attacker_id);
|
||||
attacking_otomo = non_players.get_otomo(attacker_id);
|
||||
elseif attacker_id == 4 then
|
||||
attacking_player = player.myself
|
||||
attacking_otomo = non_players.get_otomo(non_players.my_second_otomo_id);
|
||||
else
|
||||
attacking_player = non_players.get_servant(attacker_id - 1);
|
||||
attacking_otomo = non_players.get_otomo(attacker_id - 1);
|
||||
end
|
||||
|
||||
player.update_damage(attacking_otomo, damage_source_type, is_large_monster, damage_object);
|
||||
end
|
||||
|
||||
player.update_damage(player.total, damage_source_type, is_large_monster, damage_object);
|
||||
player.update_damage(attacking_player, damage_source_type, is_large_monster, damage_object);
|
||||
|
||||
--xy = xy .. "\nPlayer: " .. tostring(attacker_id) ..
|
||||
--" " .. tostring(attacking_player.name) ..
|
||||
--" Damage: " .. tostring(damage_object.total_damage) ..
|
||||
--" Type: (" .. tostring(attacker_type);
|
||||
--") " ..
|
||||
--" Condition Damage: " .. tostring(condition_damage) ..
|
||||
--" Condition Type: (" .. tostring(attacker_type) ..
|
||||
--") " .. tostring(condition_type);
|
||||
|
||||
if is_otomo_attack then
|
||||
--xy = xy .. "\nOtomo Master: " .. tostring(attacking_player.id) ..
|
||||
--" " .. tostring(attacking_player.name) ..
|
||||
--" Damage: " .. tostring(damage_object.total_damage);
|
||||
|
||||
--xy = xy .. "\nOtomo: " .. tostring(attacking_otomo.id) ..
|
||||
--" " .. tostring(attacking_otomo.name) ..
|
||||
--" Damage: " .. tostring(damage_object.total_damage);
|
||||
end
|
||||
|
||||
if string.len(xy) > 2700 then
|
||||
--xy = "";
|
||||
end
|
||||
end
|
||||
|
||||
--function damage_hook.on_mystery_core_break(enemy)
|
||||
|
||||
--end
|
||||
|
||||
-- Coavins code
|
||||
function damage_hook.cart(dead_player_id, flag_cat_skill_insurance)
|
||||
-- flag_cat_skill_insurance = 0
|
||||
-- flag_cat_skill_insurance = 1
|
||||
|
||||
@@ -3,23 +3,28 @@ local config;
|
||||
local table_helpers;
|
||||
local singletons;
|
||||
local customization_menu;
|
||||
local non_player_damage_UI_entity;
|
||||
local damage_UI_entity;
|
||||
local time;
|
||||
local quest_status;
|
||||
local drawing;
|
||||
local language;
|
||||
local unicode_helpers;
|
||||
local player;
|
||||
|
||||
non_players.servant_list = {};
|
||||
non_players.otomo_list = {};
|
||||
|
||||
function non_players.new(id, name, is_otomo)
|
||||
non_players.my_second_otomo_id = -1;
|
||||
|
||||
function non_players.new(id, name, level, is_otomo, is_servant)
|
||||
local non_player = {};
|
||||
non_player.id = id;
|
||||
non_player.name = name;
|
||||
non_player.level = level;
|
||||
|
||||
non_player.is_player = false;
|
||||
non_player.is_otomo = is_otomo;
|
||||
non_player.is_servant = is_servant;
|
||||
|
||||
non_player.join_time = -1;
|
||||
non_player.first_hit_time = -1;
|
||||
@@ -56,9 +61,9 @@ local servant_manager_type_def = sdk.find_type_definition("snow.ai.ServantManage
|
||||
local get_quest_servant_id_list_method = servant_manager_type_def:get_method("getQuestServantIdList");
|
||||
local get_ai_control_by_servant_id_method = servant_manager_type_def:get_method("getAIControlByServantID");
|
||||
|
||||
local list_type_def = get_quest_servant_id_list_method:get_return_type();
|
||||
local get_count_method = list_type_def:get_method("get_Count");
|
||||
local get_item_method = list_type_def:get_method("get_Item");
|
||||
local servant_list_type_def = get_quest_servant_id_list_method:get_return_type();
|
||||
local servant_get_count_method = servant_list_type_def:get_method("get_Count");
|
||||
local servant_get_item_method = servant_list_type_def:get_method("get_Item");
|
||||
|
||||
local ai_control_type_def = get_ai_control_by_servant_id_method:get_return_type();
|
||||
local get_servant_info_method = ai_control_type_def:get_method("get_ServantInfo");
|
||||
@@ -67,7 +72,36 @@ local servant_info_type_def = get_servant_info_method:get_return_type();
|
||||
local get_servant_name_method = servant_info_type_def:get_method("get_ServantName");
|
||||
local get_servant_player_index_method = servant_info_type_def:get_method("get_ServantPlayerIndex");
|
||||
|
||||
local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager");
|
||||
local quest_otomo_info_field = lobby_manager_type_def:get_field("_questOtomoInfo");
|
||||
local otomo_info_field = lobby_manager_type_def:get_field("_OtomoInfo");
|
||||
|
||||
local otomo_manager_type_def = sdk.find_type_definition("snow.otomo.OtomoManager");
|
||||
local get_master_otomo_info_method = otomo_manager_type_def:get_method("getMasterOtomoInfo");
|
||||
|
||||
local otomo_create_data_type_def = get_master_otomo_info_method:get_return_type();
|
||||
local otomo_create_data_name_field = otomo_create_data_type_def:get_field("Name");
|
||||
local otomo_create_data_level_field = otomo_create_data_type_def:get_field("Level");
|
||||
|
||||
local get_servant_otomo_list_method = otomo_manager_type_def:get_method("getServantOtomoList");
|
||||
|
||||
local otomo_list_type_def = get_servant_otomo_list_method:get_return_type();
|
||||
local otomo_get_count_method = otomo_list_type_def:get_method("get_Count");
|
||||
local otomo_get_item_method = otomo_list_type_def:get_method("get_Item");
|
||||
|
||||
local otomo_info_list_type_def = quest_otomo_info_field:get_type();
|
||||
local otomo_info_get_count_method = otomo_info_list_type_def:get_method("get_Count");
|
||||
local otomo_info_get_item_method = otomo_info_list_type_def:get_method("get_Item");
|
||||
|
||||
|
||||
local otomo_info_type_def = otomo_info_get_item_method:get_return_type();
|
||||
local otomo_info_name_field = otomo_info_type_def:get_field("_Name");
|
||||
local otomo_info_level_field = otomo_info_type_def:get_field("_Level");
|
||||
local otomo_info_order_field = otomo_info_type_def:get_field("_Order");
|
||||
|
||||
function non_players.update_servant_list()
|
||||
local cached_config = config.current_config.damage_meter_UI;
|
||||
|
||||
if singletons.servant_manager == nil then
|
||||
return;
|
||||
end
|
||||
@@ -77,47 +111,220 @@ function non_players.update_servant_list()
|
||||
return;
|
||||
end
|
||||
|
||||
local servant_count = get_count_method:call(quest_servant_id_list);
|
||||
local servant_count = servant_get_count_method:call(quest_servant_id_list);
|
||||
if servant_count == nil then
|
||||
customization_menu.status = "No quest servant id list count";
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
for i = 0, servant_count - 1 do
|
||||
local servant_id = get_item_method:call(quest_servant_id_list, i);
|
||||
local servant_id = servant_get_item_method:call(quest_servant_id_list, i);
|
||||
if servant_id == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
|
||||
local servant_name = "Follower";
|
||||
local player_id = -1;
|
||||
local ai_control = get_ai_control_by_servant_id_method:call(singletons.servant_manager, servant_id);
|
||||
|
||||
if ai_control ~= nil then
|
||||
local servant_info = get_servant_info_method:call(ai_control);
|
||||
if servant_info ~= nil then
|
||||
local name = get_servant_name_method:call(servant_info);
|
||||
|
||||
if name ~= nil then
|
||||
servant_name = name;
|
||||
end
|
||||
if ai_control == nil then
|
||||
customization_menu.status = "No quest servant ai control";
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local id = get_servant_player_index_method:call(servant_info);
|
||||
|
||||
if id == nil then
|
||||
goto continue;
|
||||
end
|
||||
local servant_info = get_servant_info_method:call(ai_control);
|
||||
if servant_info == nil then
|
||||
customization_menu.status = "No quest servant info";
|
||||
goto continue;
|
||||
end
|
||||
|
||||
player_id = id;
|
||||
local name = get_servant_name_method:call(servant_info);
|
||||
if name == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local id = get_servant_player_index_method:call(servant_info);
|
||||
if id == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if non_players.servant_list[id] == nil then
|
||||
local servant = non_players.new(id, name, 0, false, true);
|
||||
non_players.servant_list[id] = servant;
|
||||
end
|
||||
|
||||
if not cached_config.settings.hide_servants then
|
||||
table.insert(player.display_list, non_players.servant_list[id]);
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
function non_players.update_otomo_list(is_on_quest, is_online)
|
||||
if is_online then
|
||||
if is_on_quest then
|
||||
--non_players.update_my_otomos();
|
||||
non_players.update_otomos(quest_otomo_info_field);
|
||||
else
|
||||
non_players.update_otomos(otomo_info_field);
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
if is_on_quest then
|
||||
non_players.update_my_otomos();
|
||||
non_players.update_servant_otomos();
|
||||
else
|
||||
non_players.update_my_otomos();
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function non_players.update_my_otomos()
|
||||
local cached_config = config.current_config.damage_meter_UI;
|
||||
|
||||
local first_otomo = get_master_otomo_info_method:call(singletons.otomo_manager, 0);
|
||||
if first_otomo ~= nil then
|
||||
local name = otomo_create_data_name_field:get_data(first_otomo);
|
||||
if name ~= nil and name ~= "" then
|
||||
local level = otomo_create_data_level_field:get_data(first_otomo) or 0;
|
||||
|
||||
if non_players.otomo_list[0] == nil then
|
||||
non_players.otomo_list[0] = non_players.new(0, name, level, true, false);
|
||||
end
|
||||
|
||||
if cached_config.settings.show_my_otomos_separately then
|
||||
table.insert(player.display_list, non_players.otomo_list[0]);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local second_otomo = get_master_otomo_info_method:call(singletons.otomo_manager, 1);
|
||||
if second_otomo ~= nil then
|
||||
local name = otomo_create_data_name_field:get_data(second_otomo);
|
||||
if name ~= nil and name ~= "" then
|
||||
local level = otomo_create_data_level_field:get_data(second_otomo) or 0;
|
||||
|
||||
-- the secondary otomo is actually the 4th one!
|
||||
if non_players.otomo_list[non_players.my_second_otomo_id] == nil then
|
||||
non_players.otomo_list[non_players.my_second_otomo_id] = non_players.new(non_players.my_second_otomo_id, name, level, true, false);
|
||||
end
|
||||
|
||||
if cached_config.settings.show_my_otomos_separately then
|
||||
table.insert(player.display_list, non_players.otomo_list[non_players.my_second_otomo_id]);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function non_players.update_servant_otomos()
|
||||
local cached_config = config.current_config.damage_meter_UI;
|
||||
|
||||
local servant_otomo_list = get_servant_otomo_list_method:call(singletons.otomo_manager);
|
||||
if servant_otomo_list == nil then
|
||||
customization_menu.status = "No servant otomo list";
|
||||
return;
|
||||
end
|
||||
|
||||
local count = otomo_get_count_method:call(servant_otomo_list);
|
||||
if count == nil then
|
||||
customization_menu.status = "No servant otomo list count";
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, count - 1 do
|
||||
local servant_otomo = otomo_get_item_method:call(servant_otomo_list, i);
|
||||
if servant_otomo == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
local otomo_create_data = servant_otomo:call("get_OtCreateData");
|
||||
if otomo_create_data ~= nil then
|
||||
local name = otomo_create_data_name_field:get_data(otomo_create_data);
|
||||
local level = otomo_create_data_level_field:get_data(otomo_create_data) or 0;
|
||||
local member_id = otomo_create_data:get_field("MemberID");
|
||||
|
||||
if name == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
--name = unicode_helpers.sub(name, 13);
|
||||
|
||||
if non_players.otomo_list[member_id] == nil then
|
||||
non_players.otomo_list[member_id] = non_players.new(member_id, name, level, true, true);
|
||||
end
|
||||
|
||||
if cached_config.settings.show_servant_otomos_separately then
|
||||
table.insert(player.display_list, non_players.otomo_list[member_id]);
|
||||
end
|
||||
end
|
||||
|
||||
if non_players.servant_list[player_id] == nil then
|
||||
local servant = non_players.new(player_id, servant_name, false);
|
||||
non_players.servant_list[player_id] = servant;
|
||||
::continue::
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function non_players.update_otomos(otomo_info_field_)
|
||||
local cached_config = config.current_config.damage_meter_UI;
|
||||
|
||||
if singletons.lobby_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
-- other players
|
||||
local otomo_info_list = otomo_info_field_:get_data(singletons.lobby_manager);
|
||||
if otomo_info_list == nil then
|
||||
customization_menu.status = "No otomo info list";
|
||||
return;
|
||||
end
|
||||
|
||||
local count = otomo_info_get_count_method:call(otomo_info_list);
|
||||
if count == nil then
|
||||
customization_menu.status = "No otomo info list count";
|
||||
return;
|
||||
end
|
||||
|
||||
for id = 0, count - 1 do
|
||||
local otomo_info = otomo_info_get_item_method:call(otomo_info_list, id);
|
||||
if otomo_info == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local is_servant = false;
|
||||
if id >= 4 then
|
||||
is_servant = true;
|
||||
end
|
||||
|
||||
|
||||
local name = otomo_info_name_field:get_data(otomo_info);
|
||||
if name == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local level = otomo_info_level_field:get_data(otomo_info) or 0;
|
||||
|
||||
local otomo_in_list = non_players.otomo_list[id];
|
||||
|
||||
if otomo_in_list == nil or (otomo_in_list.name ~= name and otomo_in_list.level) then
|
||||
local otomo = non_players.new(id, name, level, true, is_servant);
|
||||
non_players.otomo_list[id] = otomo;
|
||||
end
|
||||
|
||||
if id == player.myself.id then
|
||||
if cached_config.settings.show_my_otomos_separately then
|
||||
table.insert(player.display_list, non_players.otomo_list[id]);
|
||||
end
|
||||
elseif is_servant then
|
||||
if cached_config.settings.show_servant_otomos_separately then
|
||||
table.insert(player.display_list, non_players.otomo_list[id]);
|
||||
end
|
||||
else
|
||||
if cached_config.settings.show_other_player_otomos_separately then
|
||||
table.insert(player.display_list, non_players.otomo_list[id]);
|
||||
end
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
@@ -125,14 +332,13 @@ end
|
||||
function non_players.init_UI(non_player)
|
||||
local cached_config = config.current_config.damage_meter_UI;
|
||||
|
||||
non_player.damage_UI = non_player_damage_UI_entity.new(cached_config.damage_bar,
|
||||
cached_config.highlighted_damage_bar, cached_config.player_name_label, cached_config.dps_label,
|
||||
cached_config.damage_value_label, cached_config.damage_percentage_label);
|
||||
|
||||
non_player.damage_UI = damage_UI_entity.new(cached_config.damage_bar, cached_config.highlighted_damage_bar,
|
||||
cached_config.player_name_label, cached_config.dps_label, cached_config.master_hunter_rank_label,
|
||||
cached_config.damage_value_label, cached_config.damage_percentage_label, cached_config.cart_count_label);
|
||||
end
|
||||
|
||||
function non_players.draw(non_player, position_on_screen, opacity_scale, top_damage, top_dps)
|
||||
non_player_damage_UI_entity.draw(non_player, position_on_screen, opacity_scale, top_damage, top_dps);
|
||||
damage_UI_entity.draw(non_player, position_on_screen, opacity_scale, top_damage, top_dps);
|
||||
end
|
||||
|
||||
function non_players.init_module()
|
||||
@@ -140,12 +346,13 @@ function non_players.init_module()
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
non_player_damage_UI_entity = require("MHR_Overlay.UI.UI_Entities.non_player_damage_UI_entity");
|
||||
damage_UI_entity = require("MHR_Overlay.UI.UI_Entities.damage_UI_entity");
|
||||
time = require("MHR_Overlay.Game_Handler.time");
|
||||
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
language = require("MHR_Overlay.Misc.language");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
unicode_helpers = require("MHR_Overlay.Misc.unicode_helpers");
|
||||
|
||||
non_players.init();
|
||||
end
|
||||
|
||||
@@ -3,21 +3,23 @@ local config;
|
||||
local table_helpers;
|
||||
local singletons;
|
||||
local customization_menu;
|
||||
local player_damage_UI_entity;
|
||||
local damage_UI_entity;
|
||||
local time;
|
||||
local quest_status;
|
||||
local drawing;
|
||||
local language;
|
||||
local non_players;
|
||||
|
||||
player.list = {};
|
||||
player.myself = nil;
|
||||
player.myself_position = Vector3f.new(0, 0, 0);
|
||||
player.total = nil;
|
||||
|
||||
function player.new(id, guid, name, master_rank, hunter_rank)
|
||||
player.display_list = {}
|
||||
|
||||
function player.new(id, name, master_rank, hunter_rank)
|
||||
local new_player = {};
|
||||
new_player.id = id;
|
||||
new_player.guid = guid;
|
||||
new_player.name = name; -- 齁ODO
|
||||
new_player.hunter_rank = hunter_rank;
|
||||
new_player.master_rank = master_rank;
|
||||
@@ -188,7 +190,42 @@ function player.update_display(_player)
|
||||
end
|
||||
|
||||
if cached_config.tracked_damage_types.otomo_damage then
|
||||
player.merge_damage(_player.display, _player.small_monsters.otomo);
|
||||
if _player.is_otomo then
|
||||
if _player.id == player.myself.id or _player.id == non_players.my_second_otomo_id then
|
||||
|
||||
if cached_config.settings.show_my_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.small_monsters.otomo);
|
||||
end
|
||||
elseif _player.is_servant then
|
||||
|
||||
if cached_config.settings.show_servant_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.small_monsters.otomo);
|
||||
end
|
||||
else
|
||||
|
||||
if cached_config.settings.show_other_player_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.small_monsters.otomo);
|
||||
end
|
||||
end
|
||||
else
|
||||
if _player == player.myself then
|
||||
|
||||
if not cached_config.settings.show_my_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.small_monsters.otomo);
|
||||
end
|
||||
elseif _player.is_servant then
|
||||
|
||||
if not cached_config.settings.show_servant_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.small_monsters.otomo);
|
||||
end
|
||||
else
|
||||
|
||||
if not cached_config.settings.show_other_player_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.small_monsters.otomo);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
if cached_config.tracked_damage_types.wyvern_riding_damage then
|
||||
@@ -230,7 +267,42 @@ function player.update_display(_player)
|
||||
end
|
||||
|
||||
if cached_config.tracked_damage_types.otomo_damage then
|
||||
player.merge_damage(_player.display, _player.large_monsters.otomo);
|
||||
if _player.is_otomo then
|
||||
if _player.id == player.myself.id or _player.id == non_players.my_second_otomo_id then
|
||||
|
||||
if cached_config.settings.show_my_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.large_monsters.otomo);
|
||||
end
|
||||
elseif _player.is_servant then
|
||||
|
||||
if cached_config.settings.show_servant_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.large_monsters.otomo);
|
||||
end
|
||||
else
|
||||
|
||||
if cached_config.settings.show_other_player_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.large_monsters.otomo);
|
||||
end
|
||||
end
|
||||
else
|
||||
if _player == player.myself then
|
||||
|
||||
if not cached_config.settings.show_my_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.large_monsters.otomo);
|
||||
end
|
||||
elseif _player.is_servant then
|
||||
|
||||
if not cached_config.settings.show_servant_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.large_monsters.otomo);
|
||||
end
|
||||
else
|
||||
|
||||
if not cached_config.settings.show_other_player_otomos_separately then
|
||||
player.merge_damage(_player.display, _player.large_monsters.otomo);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
if cached_config.tracked_damage_types.wyvern_riding_damage then
|
||||
@@ -264,6 +336,99 @@ function player.merge_damage(first, second)
|
||||
return first;
|
||||
end
|
||||
|
||||
function player.update_dps(bypass_freeze)
|
||||
local cached_config = config.current_config.damage_meter_UI.settings;
|
||||
|
||||
if cached_config.freeze_dps_on_quest_end and quest_status.flow_state >= quest_status.flow_states.KILLCAM and not bypass_freeze then
|
||||
return;
|
||||
end
|
||||
|
||||
player.total.dps = 0;
|
||||
for _, _player in pairs(player.list) do
|
||||
player.update_player_dps(_player);
|
||||
end
|
||||
|
||||
for _, servant in pairs(non_players.servant_list) do
|
||||
player.update_player_dps(servant);
|
||||
end
|
||||
|
||||
for _, otomo in pairs(non_players.otomo_list) do
|
||||
player.update_player_dps(otomo);
|
||||
end
|
||||
end
|
||||
|
||||
function player.update_player_dps(_player)
|
||||
local cached_config = config.current_config.damage_meter_UI.settings;
|
||||
|
||||
if _player.join_time == -1 then
|
||||
_player.join_time = time.total_elapsed_script_seconds;
|
||||
end
|
||||
|
||||
if cached_config.dps_mode == "Quest Time" then
|
||||
if time.total_elapsed_seconds > 0 then
|
||||
_player.dps = _player.display.total_damage / time.total_elapsed_seconds;
|
||||
end
|
||||
elseif cached_config.dps_mode == "Join Time" then
|
||||
if time.total_elapsed_script_seconds - _player.join_time > 0 then
|
||||
_player.dps = _player.display.total_damage / (time.total_elapsed_script_seconds - _player.join_time);
|
||||
end
|
||||
elseif cached_config.dps_mode == "First Hit" then
|
||||
if time.total_elapsed_script_seconds - _player.first_hit_time > 0 then
|
||||
_player.dps = _player.display.total_damage / (time.total_elapsed_script_seconds - _player.first_hit_time);
|
||||
end
|
||||
end
|
||||
|
||||
player.total.dps = player.total.dps + _player.dps;
|
||||
end
|
||||
|
||||
function player.sort_players()
|
||||
local cached_config = config.current_config.damage_meter_UI;
|
||||
|
||||
if cached_config.settings.my_damage_bar_location == "Normal" then
|
||||
table.insert(player.display_list, player.myself);
|
||||
end
|
||||
|
||||
-- sort here
|
||||
if cached_config.sorting.type == "Normal" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(player.display_list, function(left, right)
|
||||
return left.id > right.id;
|
||||
end);
|
||||
else
|
||||
table.sort(player.display_list, function(left, right)
|
||||
return left.id < right.id;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "DPS" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(player.display_list, function(left, right)
|
||||
return left.dps < right.dps;
|
||||
end);
|
||||
else
|
||||
table.sort(player.display_list, function(left, right)
|
||||
return left.dps > right.dps;
|
||||
end);
|
||||
end
|
||||
else
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(player.display_list, function(left, right)
|
||||
return left.display.total_damage < right.display.total_damage;
|
||||
end);
|
||||
else
|
||||
table.sort(player.display_list, function(left, right)
|
||||
return left.display.total_damage > right.display.total_damage;
|
||||
end);
|
||||
end
|
||||
end
|
||||
|
||||
if cached_config.settings.my_damage_bar_location == "First" then
|
||||
table.insert(player.display_list, 1, player.myself);
|
||||
|
||||
elseif cached_config.settings.my_damage_bar_location == "Last" then
|
||||
table.insert(player.display_list, player.myself);
|
||||
end
|
||||
end
|
||||
|
||||
local player_manager_type_def = sdk.find_type_definition("snow.player.PlayerManager");
|
||||
local find_master_player_method = player_manager_type_def:get_method("findMasterPlayer");
|
||||
|
||||
@@ -290,8 +455,9 @@ end
|
||||
|
||||
function player.init()
|
||||
player.list = {};
|
||||
player.total = player.new(0, -2, "Total", 0, 0);
|
||||
player.myself = player.new(-1, -1, "Dummy", -1, -1);
|
||||
player.display_list = {};
|
||||
player.total = player.new(0, "Total", 0, 0);
|
||||
player.myself = player.new(-1, "Dummy", -1, -1);
|
||||
end
|
||||
|
||||
local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager");
|
||||
@@ -330,6 +496,8 @@ function player.update_player_list(is_on_quest)
|
||||
end
|
||||
|
||||
function player.update_player_list_(hunter_info_field_)
|
||||
local cached_config = config.current_config.damage_meter_UI;
|
||||
|
||||
if singletons.lobby_manager == nil then
|
||||
return;
|
||||
end
|
||||
@@ -354,33 +522,16 @@ function player.update_player_list_(hunter_info_field_)
|
||||
local myself_hunter_rank = get_hunter_rank_method:call(singletons.progress_manager) or 0;
|
||||
local myself_master_rank = get_master_rank_method:call(singletons.progress_manager) or 0;
|
||||
|
||||
local myself_id = get_master_player_id_method:call(singletons.player_manager) or -1;
|
||||
-- if quest_status.is_online then
|
||||
-- myself_id = get_master_player_id_method:call(singletons.player_manager) or -1;
|
||||
-- else
|
||||
-- myself_id = myself_quest_index_field:call(singletons.lobby_manager) or -1;
|
||||
-- end
|
||||
local myself_id = get_master_player_id_method:call(singletons.player_manager);
|
||||
|
||||
if myself_id == nil then
|
||||
customization_menu.status = "No myself player id";
|
||||
return;
|
||||
end
|
||||
|
||||
local myself_guid = hunter_unique_id_field:get_data(myself_player_info);
|
||||
if myself_guid == nil then
|
||||
customization_menu.status = "No myself guid";
|
||||
return;
|
||||
end
|
||||
|
||||
-- local myself_guid_string = guid_tostring_method:call(myself_guid);
|
||||
-- if myself_guid_string == nil then
|
||||
-- customization_menu.status = "No myself guid string";
|
||||
-- return;
|
||||
-- end
|
||||
|
||||
if myself_id ~= player.myself.id then
|
||||
if player.myself == nil or myself_id ~= player.myself.id then
|
||||
player.list[player.myself.id] = nil;
|
||||
player.myself = player.new(myself_id, myself_guid, myself_player_name, myself_master_rank, myself_hunter_rank);
|
||||
player.myself = player.new(myself_id, myself_player_name, myself_master_rank, myself_hunter_rank);
|
||||
player.list[myself_id] = player.myself;
|
||||
end
|
||||
|
||||
@@ -403,43 +554,35 @@ function player.update_player_list_(hunter_info_field_)
|
||||
goto continue
|
||||
end
|
||||
|
||||
local player_id = member_index_field:get_data(player_info);
|
||||
local id = member_index_field:get_data(player_info);
|
||||
|
||||
if player_id == nil then
|
||||
if id == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
local player_guid = hunter_unique_id_field:get_data(player_info);
|
||||
if player_guid == nil then
|
||||
customization_menu.status = "No player guid";
|
||||
return;
|
||||
end
|
||||
local hunter_rank = hunter_rank_field:get_data(player_info) or 0;
|
||||
local master_rank = master_rank_field:get_data(player_info) or 0;
|
||||
|
||||
-- local player_guid_string = guid_tostring_method:call(player_guid);
|
||||
-- if player_guid_string == nil then
|
||||
-- customization_menu.status = "No player guid string";
|
||||
-- return;
|
||||
-- end
|
||||
|
||||
local player_hunter_rank = hunter_rank_field:get_data(player_info) or 0;
|
||||
local player_master_rank = master_rank_field:get_data(player_info) or 0;
|
||||
|
||||
local player_name = name_field:get_data(player_info);
|
||||
if player_name == nil then
|
||||
local name = name_field:get_data(player_info);
|
||||
if name == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
if player.list[player_id] == nil or not guid_equals_method:call(player.list[player_id].guid, player_guid) -- player.list[player_id].guid ~= player_guid
|
||||
then
|
||||
local _player = player.new(player_id, player_guid, player_name, player_master_rank, player_hunter_rank);
|
||||
player.list[player_id] = _player;
|
||||
local player_in_list = player.list[id];
|
||||
|
||||
if player_name == player.myself.name and player_hunter_rank == player.myself.hunter_rank and player_master_rank ==
|
||||
player.myself.master_rank then
|
||||
player.myself = _player;
|
||||
if player_in_list == nil or (player_in_list.name ~= name and player_in_list.hunter_rank ~= hunter_rank and player_in_list.master_rank ~= master_rank) then
|
||||
local _player = player.new(id, name, master_rank, hunter_rank);
|
||||
player.list[id] = _player;
|
||||
|
||||
if player_in_list.name == player.myself.name then
|
||||
player.myself = _player
|
||||
end
|
||||
end
|
||||
|
||||
if player_in_list ~= player.myself then
|
||||
table.insert(player.display_list, player_in_list);
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
@@ -447,7 +590,7 @@ end
|
||||
function player.init_UI(_player)
|
||||
local cached_config = config.current_config.damage_meter_UI;
|
||||
|
||||
_player.damage_UI = player_damage_UI_entity.new(cached_config.damage_bar, cached_config.highlighted_damage_bar,
|
||||
_player.damage_UI = damage_UI_entity.new(cached_config.damage_bar, cached_config.highlighted_damage_bar,
|
||||
cached_config.player_name_label, cached_config.dps_label, cached_config.master_hunter_rank_label,
|
||||
cached_config.damage_value_label, cached_config.damage_percentage_label, cached_config.cart_count_label);
|
||||
end
|
||||
@@ -479,7 +622,7 @@ function player.init_total_UI(_player)
|
||||
end
|
||||
|
||||
function player.draw(_player, position_on_screen, opacity_scale, top_damage, top_dps)
|
||||
player_damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_damage, top_dps);
|
||||
damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_damage, top_dps);
|
||||
end
|
||||
|
||||
function player.draw_total(position_on_screen, opacity_scale)
|
||||
@@ -497,11 +640,12 @@ function player.init_module()
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
player_damage_UI_entity = require("MHR_Overlay.UI.UI_Entities.player_damage_UI_entity");
|
||||
damage_UI_entity = require("MHR_Overlay.UI.UI_Entities.damage_UI_entity");
|
||||
time = require("MHR_Overlay.Game_Handler.time");
|
||||
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
language = require("MHR_Overlay.Misc.language");
|
||||
non_players = require("MHR_Overlay.Damage_Meter.non_players");
|
||||
|
||||
player.init();
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user