mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
Fixed player id issues, refactored monster update function, implemented blast, poison and wyvern riding damage
This commit is contained in:
101
reframework/autorun/MHR_Overlay/Damage_Meter/ailments.lua
Normal file
101
reframework/autorun/MHR_Overlay/Damage_Meter/ailments.lua
Normal file
@@ -0,0 +1,101 @@
|
||||
local ailments = {};
|
||||
local player;
|
||||
|
||||
--0 Paralyze
|
||||
--1 Sleep
|
||||
--2 Stun
|
||||
--3 Flash
|
||||
--4 Poison
|
||||
--5 Blast
|
||||
--6 Stamina
|
||||
--7 MarionetteStart
|
||||
--8 Water
|
||||
--9 Fire
|
||||
--10 Ice
|
||||
--11 Thunder
|
||||
--12 FallTrap
|
||||
--13 ShockTrap
|
||||
--14 Capture
|
||||
--15 Koyashi
|
||||
--16 SteelFang
|
||||
|
||||
ailments.poison_id = 4;
|
||||
ailments.blast_id = 5;
|
||||
|
||||
function ailments.apply_ailment_buildup(monster, attacker_id, ailment_type, ailment_buildup)
|
||||
if monster == nil or player == nil or (ailment_type ~= ailments.poison_id and ailment_type ~= ailments.blast_id) then
|
||||
return;
|
||||
end
|
||||
|
||||
-- get the buildup accumulator for this type
|
||||
if monster.ailment[ailment_type].buildup == nil then
|
||||
monster.ailment[ailment_type].buildup = {};
|
||||
end
|
||||
|
||||
-- accumulate this buildup for this attacker
|
||||
monster.ailment[ailment_type].buildup[attacker_id] = (monster.ailment[ailment_type].buildup[attacker_id] or 0) + ailment_buildup;
|
||||
end
|
||||
|
||||
-- Code by coavins
|
||||
function ailments.calculate_ailment_contribution(monster, ailment_type)
|
||||
-- get total
|
||||
local total = 0;
|
||||
for attacker_id, player_buildup in pairs(monster.ailment[ailment_type].buildup) do
|
||||
total = total + player_buildup;
|
||||
end
|
||||
|
||||
for attacker_id, player_buildup in pairs(monster.ailment[ailment_type].buildup) do
|
||||
-- update ratio for this attacker
|
||||
monster.ailment[ailment_type].share[attacker_id] = player_buildup / total;
|
||||
-- clear accumulated buildup for this attacker
|
||||
-- they have to start over to earn a share of next ailment trigger
|
||||
monster.ailment[ailment_type].buildup[attacker_id] = 0;
|
||||
end
|
||||
end
|
||||
|
||||
-- Code by coavins
|
||||
function ailments.apply_ailment_damage(monster, ailment_type, ailment_damage)
|
||||
-- we only track poison and blast for now
|
||||
if ailment_type == nil or ailment_damage == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local damage_source_type = "";
|
||||
if ailment_type == ailments.poison_id then
|
||||
damage_source_type = "poison";
|
||||
elseif ailment_type == ailments.blast_id then
|
||||
damage_source_type = "blast";
|
||||
else
|
||||
return;
|
||||
end
|
||||
|
||||
local damage = ailment_damage;
|
||||
|
||||
|
||||
-- split up damage according to ratio of buildup on boss for this type
|
||||
for attacker_id, percentage in pairs(monster.ailment[ailment_type].share) do
|
||||
local damage_portion = damage * percentage;
|
||||
|
||||
local damage_object = {};
|
||||
damage_object.total_damage = damage_portion;
|
||||
damage_object.physical_damage = 0;
|
||||
damage_object.elemental_damage = 0;
|
||||
damage_object.ailment_damage = damage_portion;
|
||||
|
||||
local attacking_player = player.get_player(attacker_id);
|
||||
|
||||
if attacking_player ~= nil then
|
||||
player.update_damage(attacking_player, damage_source_type, true, damage_object);
|
||||
end
|
||||
|
||||
player.update_damage(player.total, damage_source_type, true, damage_object);
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function ailments.init_module()
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
end
|
||||
|
||||
return ailments;
|
||||
@@ -1,6 +1,9 @@
|
||||
local damage_hook = {};
|
||||
local quest_status;
|
||||
local player;
|
||||
local small_monster;
|
||||
local large_monster;
|
||||
local ailments;
|
||||
|
||||
local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase");
|
||||
local enemy_character_base_after_calc_damage_damage_side = enemy_character_base_type_def:get_method("afterCalcDamage_DamageSide");
|
||||
@@ -11,11 +14,13 @@ local check_die_method = enemy_character_base_type_def:get_method("checkDie");
|
||||
local enemy_calc_damage_info_type_def = sdk.find_type_definition("snow.hit.EnemyCalcDamageInfo.AfterCalcInfo_DamageSide");
|
||||
local get_attacker_id_method = enemy_calc_damage_info_type_def:get_method("get_AttackerID");
|
||||
local get_damage_attacker_type_method = enemy_calc_damage_info_type_def:get_method("get_DamageAttackerType");
|
||||
local is_marionette_attack_method = enemy_calc_damage_info_type_def:get_method("get_IsMarionetteAttack");
|
||||
|
||||
local get_total_damage_method = enemy_calc_damage_info_type_def:get_method("get_TotalDamage");
|
||||
local get_physical_damage_method = enemy_calc_damage_info_type_def:get_method("get_PhysicalDamage");
|
||||
local get_elemental_damage_method = enemy_calc_damage_info_type_def:get_method("get_ElementDamage");
|
||||
local get_condition_damage_method = enemy_calc_damage_info_type_def:get_method("get_ConditionDamage");
|
||||
local get_condition_type_method = enemy_calc_damage_info_type_def:get_method("get_ConditionDamageType");
|
||||
|
||||
sdk.hook(enemy_character_base_after_calc_damage_damage_side, function(args)
|
||||
pcall(damage_hook.update_damage, args);
|
||||
@@ -47,21 +52,31 @@ function damage_hook.update_damage(args)
|
||||
local enemy_calc_damage_info = sdk.to_managed_object(args[3]); -- snow.hit.EnemyCalcDamageInfo.AfterCalcInfo_DamageSide
|
||||
local attacker_id = get_attacker_id_method:call(enemy_calc_damage_info);
|
||||
local attacker_type = get_damage_attacker_type_method:call(enemy_calc_damage_info);
|
||||
|
||||
if attacker_id >= 100 then
|
||||
return;
|
||||
end
|
||||
|
||||
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.player_id;
|
||||
end
|
||||
|
||||
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;
|
||||
break;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local damage_object = {}
|
||||
damage_object.total_damage = get_total_damage_method:call(enemy_calc_damage_info);
|
||||
damage_object.physical_damage = get_physical_damage_method:call(enemy_calc_damage_info);
|
||||
damage_object.elemental_damage = get_elemental_damage_method:call(enemy_calc_damage_info);
|
||||
damage_object.ailment_damage = get_condition_damage_method:call(enemy_calc_damage_info);
|
||||
damage_object.ailment_damage = 0;
|
||||
|
||||
local condition_damage = get_condition_damage_method:call(enemy_calc_damage_info);
|
||||
local condition_type = tonumber(get_condition_type_method:call(enemy_calc_damage_info));
|
||||
|
||||
-- -1 - bombs
|
||||
-- 0 - player
|
||||
@@ -95,9 +110,28 @@ function damage_hook.update_damage(args)
|
||||
|
||||
local attacking_player = player.get_player(attacker_id);
|
||||
if attacking_player == nil then
|
||||
return;
|
||||
--return;
|
||||
end
|
||||
|
||||
local monster;
|
||||
if is_large_monster then
|
||||
monster = large_monster.get_monster(enemy);
|
||||
else
|
||||
monster = small_monster.get_monster(enemy);
|
||||
end
|
||||
|
||||
--xy =
|
||||
-- "type: " .. tostring(damage_source_type) .. "\n" ..
|
||||
-- "total damage: " .. tostring(damage_object.total_damage) .. "\n" ..
|
||||
-- "physical damage: " .. tostring(damage_object.physical_damage) .. "\n" ..
|
||||
-- "elemental damage: " .. tostring(damage_object.elemental_damage) .. "\n" ..
|
||||
-- "condition damage: " .. tostring(condition_damage) .. "\n" ..
|
||||
-- "condition type: " .. tostring(condition_type) .. "\n" ..
|
||||
-- "is mario attack: " .. tostring(is_marionette_attack) .. "\n" ..
|
||||
-- "attacker id: " .. tostring(attacker_id) .. "\n";
|
||||
|
||||
ailments.apply_ailment_buildup(monster, attacker_id, condition_type, condition_damage);
|
||||
|
||||
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);
|
||||
end
|
||||
@@ -105,6 +139,9 @@ end
|
||||
function damage_hook.init_module()
|
||||
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
small_monster = require("MHR_Overlay.Monsters.small_monster");
|
||||
large_monster = require("MHR_Overlay.Monsters.large_monster");
|
||||
ailments = require("MHR_Overlay.Damage_Meter.ailments");
|
||||
end
|
||||
|
||||
return damage_hook;
|
||||
@@ -61,6 +61,18 @@ function player.new(player_id, player_name, player_hunter_rank)
|
||||
new_player.small_monsters.monster.elemental_damage = 0;
|
||||
new_player.small_monsters.monster.ailment_damage = 0;
|
||||
|
||||
new_player.small_monsters.poison = {};
|
||||
new_player.small_monsters.poison.total_damage = 0;
|
||||
new_player.small_monsters.poison.physical_damage = 0;
|
||||
new_player.small_monsters.poison.elemental_damage = 0;
|
||||
new_player.small_monsters.poison.ailment_damage = 0;
|
||||
|
||||
new_player.small_monsters.blast = {};
|
||||
new_player.small_monsters.blast.total_damage = 0;
|
||||
new_player.small_monsters.blast.physical_damage = 0;
|
||||
new_player.small_monsters.blast.elemental_damage = 0;
|
||||
new_player.small_monsters.blast.ailment_damage = 0;
|
||||
|
||||
new_player.large_monsters = {};
|
||||
|
||||
new_player.large_monsters.total_damage = 0;
|
||||
@@ -98,6 +110,18 @@ function player.new(player_id, player_name, player_hunter_rank)
|
||||
new_player.large_monsters.monster.elemental_damage = 0;
|
||||
new_player.large_monsters.monster.ailment_damage = 0;
|
||||
|
||||
new_player.large_monsters.poison = {};
|
||||
new_player.large_monsters.poison.total_damage = 0;
|
||||
new_player.large_monsters.poison.physical_damage = 0;
|
||||
new_player.large_monsters.poison.elemental_damage = 0;
|
||||
new_player.large_monsters.poison.ailment_damage = 0;
|
||||
|
||||
new_player.large_monsters.blast = {};
|
||||
new_player.large_monsters.blast.total_damage = 0;
|
||||
new_player.large_monsters.blast.physical_damage = 0;
|
||||
new_player.large_monsters.blast.elemental_damage = 0;
|
||||
new_player.large_monsters.blast.ailment_damage = 0;
|
||||
|
||||
new_player.display = {};
|
||||
new_player.display.total_damage = 0;
|
||||
new_player.display.physical_damage = 0;
|
||||
@@ -146,8 +170,12 @@ function player.update_damage(_player, damage_source_type, is_large_monster, dam
|
||||
player.merge_damage(player_monster_type.otomo, damage_object);
|
||||
elseif damage_source_type == "monster" then
|
||||
player.merge_damage(player_monster_type.monster, damage_object);
|
||||
elseif damage_source_type == "poison" then
|
||||
player.merge_damage(player_monster_type.poison, damage_object);
|
||||
elseif damage_source_type == "blast" then
|
||||
player.merge_damage(player_monster_type.blast, damage_object);
|
||||
else
|
||||
player.merge_damage(_player, damage_object);
|
||||
player.merge_damage(player_monster_type, damage_object);
|
||||
end
|
||||
|
||||
player.update_display(_player);
|
||||
@@ -187,6 +215,14 @@ function player.update_display(_player)
|
||||
if config.current_config.damage_meter_UI.tracked_damage_types.monster_damage then
|
||||
player.merge_damage(_player.display, _player.small_monsters.monster);
|
||||
end
|
||||
|
||||
if config.current_config.damage_meter_UI.tracked_damage_types.poison_damage then
|
||||
player.merge_damage(_player.display, _player.small_monsters.poison);
|
||||
end
|
||||
|
||||
if config.current_config.damage_meter_UI.tracked_damage_types.blast_damage then
|
||||
player.merge_damage(_player.display, _player.small_monsters.blast);
|
||||
end
|
||||
end
|
||||
|
||||
if config.current_config.damage_meter_UI.tracked_monster_types.large_monsters then
|
||||
@@ -213,6 +249,14 @@ function player.update_display(_player)
|
||||
if config.current_config.damage_meter_UI.tracked_damage_types.monster_damage then
|
||||
player.merge_damage(_player.display, _player.large_monsters.monster);
|
||||
end
|
||||
|
||||
if config.current_config.damage_meter_UI.tracked_damage_types.poison_damage then
|
||||
player.merge_damage(_player.display, _player.large_monsters.poison);
|
||||
end
|
||||
|
||||
if config.current_config.damage_meter_UI.tracked_damage_types.blast_damage then
|
||||
player.merge_damage(_player.display, _player.large_monsters.blast);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -273,8 +317,6 @@ end
|
||||
|
||||
local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager");
|
||||
local my_hunter_info_field = lobby_manager_type_def:get_field("_myHunterInfo");
|
||||
local myself_index_field = lobby_manager_type_def:get_field("_myselfIndex");
|
||||
local myself_quest_index_field = lobby_manager_type_def:get_field("_myselfQuestIndex");
|
||||
|
||||
local quest_hunter_info_field = lobby_manager_type_def:get_field("_questHunterInfo");
|
||||
local hunter_info_field = lobby_manager_type_def:get_field("_hunterInfo");
|
||||
@@ -291,6 +333,9 @@ local get_item_method = hunter_info_type_def:get_method("get_Item");
|
||||
local progress_manager_type_def = sdk.find_type_definition("snow.progress.ProgressManager");
|
||||
local get_hunter_rank_method = progress_manager_type_def:get_method("get_HunterRank");
|
||||
|
||||
local player_manager_type_def = sdk.find_type_definition("snow.player.PlayerManager");
|
||||
local get_master_player_id_method = player_manager_type_def:get_method("getMasterPlayerID");
|
||||
|
||||
function player.update_player_list_in_village()
|
||||
if singletons.lobby_manager == nil then
|
||||
return;
|
||||
@@ -318,12 +363,12 @@ function player.update_player_list_in_village()
|
||||
customization_menu.status = "No myself hunter rank";
|
||||
myself_hunter_rank = 0;
|
||||
end
|
||||
|
||||
local myself_id = myself_index_field:get_data(singletons.lobby_manager);
|
||||
|
||||
local myself_id = get_master_player_id_method:call(singletons.player_manager);
|
||||
if myself_id == nil then
|
||||
customization_menu.status = "No myself player id";
|
||||
elseif player.myself == nil or myself_id ~= player.myself.id then
|
||||
player.myself = player.new(myself_id, myself_player_name, myself_hunter_rank);
|
||||
player.myself = player.new(myself_id, myself_player_name, myself_hunter_rank);
|
||||
player.list[myself_id] = player.myself;
|
||||
end
|
||||
|
||||
@@ -399,14 +444,13 @@ function player.update_player_list_on_quest()
|
||||
myself_hunter_rank = 0;
|
||||
end
|
||||
|
||||
local myself_id = myself_quest_index_field:get_data(singletons.lobby_manager);
|
||||
local myself_id = get_master_player_id_method:call(singletons.player_manager);
|
||||
if myself_id == nil then
|
||||
customization_menu.status = "No myself player quest id";
|
||||
customization_menu.status = "No myself player id";
|
||||
elseif player.myself == nil or myself_id ~= player.myself.id then
|
||||
player.myself = player.new(myself_id, myself_player_name, myself_hunter_rank);
|
||||
player.list[myself_id] = player.myself;
|
||||
end
|
||||
|
||||
|
||||
-- other players
|
||||
local player_info_list = quest_hunter_info_field:get_data(singletons.lobby_manager);
|
||||
@@ -427,7 +471,6 @@ function player.update_player_list_on_quest()
|
||||
goto continue
|
||||
end
|
||||
|
||||
|
||||
local player_id = member_index_field:get_data(player_info);
|
||||
|
||||
if player_id == nil then
|
||||
|
||||
@@ -87,6 +87,10 @@ function quest_status.update_is_training_area()
|
||||
return;
|
||||
end
|
||||
|
||||
if quest_status.is_training_area == true and _is_training_area == false then
|
||||
player.init();
|
||||
end
|
||||
|
||||
quest_status.is_training_area = _is_training_area;
|
||||
end
|
||||
|
||||
|
||||
2
reframework/autorun/MHR_Overlay/Misc/Buffs.txt
Normal file
2
reframework/autorun/MHR_Overlay/Misc/Buffs.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Buffs location:
|
||||
snow.player.PlayerManager -> <PlayerData> k_BackingField -> [0]
|
||||
@@ -1796,7 +1796,9 @@ function config.init()
|
||||
kunai_damage = true,
|
||||
installation_damage = true, -- hunting_installations like ballista, cannon, etc.
|
||||
otomo_damage = true,
|
||||
monster_damage = true -- note that installations during narwa fight are counted as monster damage
|
||||
monster_damage = true, -- note that installations during narwa fight are counted as monster damage
|
||||
poison_damage = true,
|
||||
blast_damage = true,
|
||||
},
|
||||
|
||||
spacing = {
|
||||
@@ -2073,7 +2075,7 @@ function config.init_module()
|
||||
|
||||
config.init();
|
||||
config.load();
|
||||
config.current_config.version = "v1.9.1";
|
||||
config.current_config.version = "v1.10";
|
||||
|
||||
language.update(table_helpers.find_index(language.language_names, config.current_config.global_settings.language, false));
|
||||
|
||||
|
||||
@@ -228,6 +228,8 @@ language.default_language = {
|
||||
installation_damage = "Installation Damage",
|
||||
otomo_damage = "Otomo Damage",
|
||||
monster_damage = "Monster Damage",
|
||||
poison_damage = "Poison Damage",
|
||||
blast_damage = "Blast Damage",
|
||||
|
||||
damage = "Damage",
|
||||
|
||||
@@ -253,7 +255,7 @@ language.default_language = {
|
||||
hotkeys = "Hotkeys",
|
||||
all_UI = "All UI",
|
||||
assign_new_key = "Assign new key",
|
||||
press_any_key = "Press any key..."
|
||||
press_any_key = "Press any key...",
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ local stamina_UI_entity;
|
||||
local rage_UI_entity;
|
||||
local screen;
|
||||
local drawing;
|
||||
local ailments;
|
||||
local player;
|
||||
|
||||
local body_part;
|
||||
local part_names;
|
||||
@@ -18,7 +20,9 @@ large_monster.list = {};
|
||||
function large_monster.new(enemy)
|
||||
local monster = {};
|
||||
monster.is_large = true;
|
||||
|
||||
monster.id = 0;
|
||||
monster.unique_id = 0;
|
||||
|
||||
monster.health = 0;
|
||||
monster.max_health = 999999;
|
||||
@@ -61,7 +65,20 @@ function large_monster.new(enemy)
|
||||
monster.crown = "";
|
||||
|
||||
monster.parts = {};
|
||||
|
||||
|
||||
monster.ailment = {};
|
||||
monster.ailment[ailments.poison_id] = {};
|
||||
monster.ailment[ailments.poison_id].buildup = {};
|
||||
monster.ailment[ailments.poison_id].share = {};
|
||||
monster.ailment[ailments.poison_id].activate_count = 0;
|
||||
|
||||
monster.ailment[ailments.blast_id] = {};
|
||||
monster.ailment[ailments.blast_id].buildup = {};
|
||||
monster.ailment[ailments.blast_id].share = {};
|
||||
monster.ailment[ailments.blast_id].activate_count = 0;
|
||||
|
||||
monster.rider_id = -1;
|
||||
|
||||
large_monster.init(monster, enemy);
|
||||
large_monster.init_static_UI(monster);
|
||||
large_monster.init_dynamic_UI(monster);
|
||||
@@ -76,7 +93,6 @@ end
|
||||
function large_monster.get_monster(enemy)
|
||||
if large_monster.list[enemy] == nil then
|
||||
return large_monster.new(enemy);
|
||||
|
||||
end
|
||||
return large_monster.list[enemy];
|
||||
end
|
||||
@@ -96,6 +112,11 @@ local get_small_border_method = size_info_type:get_method("get_SmallBorder");
|
||||
local get_big_border_method = size_info_type:get_method("get_BigBorder");
|
||||
local get_king_border_method = size_info_type:get_method("get_KingBorder");
|
||||
|
||||
local get_set_info_method = enemy_character_base_type_def:get_method("get_SetInfo");
|
||||
|
||||
local set_info_type = get_set_info_method:get_return_type();
|
||||
local get_unique_id_method = set_info_type:get_method("get_UniqueId");
|
||||
|
||||
function large_monster.init(monster, enemy)
|
||||
local enemy_type = enemy_type_field:get_data(enemy);
|
||||
if enemy_type == nil then
|
||||
@@ -110,6 +131,14 @@ function large_monster.init(monster, enemy)
|
||||
monster.name = enemy_name;
|
||||
end
|
||||
|
||||
local set_info = get_set_info_method:call(enemy);
|
||||
if set_info ~= nil then
|
||||
local unique_id = get_unique_id_method:call(set_info);
|
||||
if unique_id ~= nil then
|
||||
monster.unique_id = unique_id;
|
||||
end
|
||||
end
|
||||
|
||||
local size_info = find_enemy_size_info_method:call(singletons.enemy_manager, enemy_type);
|
||||
if size_info ~= nil then
|
||||
local small_border = get_small_border_method:call(size_info);
|
||||
@@ -268,37 +297,58 @@ function large_monster.init_highlighted_UI(monster)
|
||||
end
|
||||
|
||||
local physical_param_field = enemy_character_base_type_def:get_field("<PhysicalParam>k__BackingField");
|
||||
local status_param_field = enemy_character_base_type_def:get_field("<StatusParam>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 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 physical_param_type = physical_param_field:get_type();
|
||||
local get_vital_method = physical_param_type:get_method("getVital")
|
||||
local get_capture_hp_vital_method = physical_param_type:get_method("get_CaptureHpVital")
|
||||
local vital_list_field = physical_param_type:get_field("_VitalList")
|
||||
local get_vital_method = physical_param_type:get_method("getVital");
|
||||
local get_capture_hp_vital_method = physical_param_type:get_method("get_CaptureHpVital");
|
||||
local vital_list_field = physical_param_type:get_field("_VitalList");
|
||||
|
||||
local vital_param_type = get_vital_method:get_return_type();
|
||||
local get_current_method = vital_param_type:get_method("get_Current")
|
||||
local get_max_method = vital_param_type:get_method("get_Max")
|
||||
local get_current_method = vital_param_type:get_method("get_Current");
|
||||
local get_max_method = vital_param_type:get_method("get_Max");
|
||||
|
||||
local stamina_param_type = stamina_param_field:get_type();
|
||||
local get_stamina_method = stamina_param_type:get_method("getStamina")
|
||||
local get_max_stamina_method = stamina_param_type:get_method("getMaxStamina")
|
||||
local get_stamina_method = stamina_param_type:get_method("getStamina");
|
||||
local get_max_stamina_method = stamina_param_type:get_method("getMaxStamina");
|
||||
|
||||
local anger_param_type = anger_param_field:get_type();
|
||||
local is_anger_method = anger_param_type:get_method("isAnger")
|
||||
local get_anger_point_method = anger_param_type:get_method("get_AngerPoint")
|
||||
local get_limit_anger_method = anger_param_type:get_method("get_LimitAnger")
|
||||
local anger_param_get_timer_method = anger_param_type:get_method("get_Timer")
|
||||
local get_timer_anger_method = anger_param_type:get_method("get_TimerAnger")
|
||||
local get_count_anger_method = anger_param_type:get_method("get_CountAnger")
|
||||
local is_anger_method = anger_param_type:get_method("isAnger");
|
||||
local get_anger_point_method = anger_param_type:get_method("get_AngerPoint");
|
||||
local get_limit_anger_method = anger_param_type:get_method("get_LimitAnger");
|
||||
local anger_param_get_timer_method = anger_param_type:get_method("get_Timer");
|
||||
local get_timer_anger_method = anger_param_type:get_method("get_TimerAnger");
|
||||
local get_count_anger_method = anger_param_type:get_method("get_CountAnger");
|
||||
|
||||
local get_game_object_method = sdk.find_type_definition("via.Component"):get_method("get_GameObject")
|
||||
local get_transform_method = sdk.find_type_definition("via.GameObject"):get_method("get_Transform")
|
||||
local get_position_method = sdk.find_type_definition("via.Transform"):get_method("get_Position")
|
||||
local damage_param_type = damage_param_field:get_type();
|
||||
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 poison_get_activate_count_method = poison_param_type:get_method("get_ActivateCount");
|
||||
local poison_damage_field = poison_param_type:get_field("<Damage>k__BackingField");
|
||||
local poison_get_is_damage_method = poison_param_type:get_method("get_IsDamage");
|
||||
|
||||
local blast_param_type = blast_param_field:get_type();
|
||||
local blast_get_activate_count_method = blast_param_type:get_method("get_ActivateCount");
|
||||
local blast_damage_method = blast_param_type:get_method("get_BlastDamage");
|
||||
local blast_adjust_rate_method = blast_param_type:get_method("get_BlastDamageAdjustRateByEnemyLv");
|
||||
|
||||
local mario_param_field = enemy_character_base_type_def:get_field("<MarioParam>k__BackingField");
|
||||
|
||||
local mario_param_type = mario_param_field:get_type();
|
||||
local get_is_marionette_method = mario_param_type:get_method("get_IsMarionette");
|
||||
local get_mario_player_index_method = mario_param_type:get_method("get_MarioPlayerIndex");
|
||||
|
||||
local get_game_object_method = sdk.find_type_definition("via.Component"):get_method("get_GameObject");
|
||||
local get_transform_method = sdk.find_type_definition("via.GameObject"):get_method("get_Transform");
|
||||
local get_position_method = sdk.find_type_definition("via.Transform"):get_method("get_Position");
|
||||
|
||||
function large_monster.update_position(enemy)
|
||||
|
||||
if not config.current_config.large_monster_UI.dynamic.enabled
|
||||
and not config.current_config.large_monster_UI.static.enabled
|
||||
and not config.current_config.large_monster_UI.highlighted.enabled then
|
||||
@@ -340,8 +390,71 @@ function large_monster.update_position(enemy)
|
||||
end
|
||||
end
|
||||
|
||||
-- Code by coavins
|
||||
function large_monster.update_all_riders()
|
||||
for enemy, monster in pairs(large_monster.list) do
|
||||
-- get marionette rider
|
||||
local mario_param = enemy:get_field("<MarioParam>k__BackingField");
|
||||
if mario_param ~= nil then
|
||||
local is_marionette = get_is_marionette_method:call(mario_param);
|
||||
if is_marionette then
|
||||
local player_id = get_mario_player_index_method:call(mario_param);
|
||||
if monster.rider_id ~= player_id then
|
||||
monster.rider_id = player_id;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Code by coavins
|
||||
function large_monster.update_ailments(enemy)
|
||||
if enemy == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local monster = large_monster.get_monster(enemy);
|
||||
|
||||
local damage_param = damage_param_field:get_data(enemy);
|
||||
if damage_param ~= nil then
|
||||
|
||||
local poison_param = poison_param_field:get_data(damage_param);
|
||||
if poison_param ~= nil then
|
||||
-- if applied, then calculate share for poison
|
||||
local activate_count = poison_get_activate_count_method:call(poison_param):get_element(0):get_field("mValue");
|
||||
if activate_count > monster.ailment[ailments.poison_id].activate_count then
|
||||
monster.ailment[ailments.poison_id].activate_count = activate_count;
|
||||
ailments.calculate_ailment_contribution(monster, ailments.poison_id);
|
||||
end
|
||||
-- if poison tick, apply damage
|
||||
local poison_damage = poison_damage_field:get_data(poison_param);
|
||||
local is_damage = poison_get_is_damage_method:call(poison_param);
|
||||
|
||||
if is_damage then
|
||||
ailments.apply_ailment_damage(monster, ailments.poison_id, poison_damage);
|
||||
end
|
||||
end
|
||||
|
||||
local blast_param = blast_param_field:get_data(damage_param);
|
||||
if blast_param ~= nil then
|
||||
-- if applied, then calculate share for blast and apply damage
|
||||
local activate_count = blast_get_activate_count_method:call(blast_param):get_element(0):get_field("mValue");
|
||||
|
||||
if activate_count > monster.ailment[ailments.blast_id].activate_count then
|
||||
monster.ailment[ailments.blast_id].activate_count = activate_count;
|
||||
ailments.calculate_ailment_contribution(monster, ailments.blast_id);
|
||||
|
||||
local blast_damage = blast_damage_method:call(blast_param);
|
||||
local blast_adjust_rate = blast_adjust_rate_method:call(blast_param);
|
||||
|
||||
ailments.apply_ailment_damage(monster, ailments.blast_id, blast_damage * blast_adjust_rate);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster.update(enemy)
|
||||
-- maybe more checks are needed here i'm not fully aware of how the code flows here
|
||||
if not config.current_config.large_monster_UI.dynamic.enabled
|
||||
and not config.current_config.large_monster_UI.static.enabled
|
||||
and not config.current_config.large_monster_UI.highlighted.enabled then
|
||||
@@ -464,7 +577,7 @@ function large_monster.update(enemy)
|
||||
::continue::
|
||||
end
|
||||
|
||||
large_monster.update_position(enemy);
|
||||
--large_monster.update_position(enemy);
|
||||
|
||||
if health ~= nil then
|
||||
monster.health = health;
|
||||
@@ -710,7 +823,7 @@ function large_monster.draw_static(monster, position_on_screen, opacity_scale)
|
||||
|
||||
stamina_UI_entity.draw(monster, monster.stamina_static_UI, stamina_position_on_screen, opacity_scale);
|
||||
rage_UI_entity.draw(monster, monster.rage_static_UI, rage_position_on_screen, opacity_scale);
|
||||
|
||||
|
||||
--sort parts here
|
||||
local displayed_parts = {};
|
||||
for REpart, part in pairs(monster.parts) do
|
||||
@@ -886,6 +999,8 @@ function large_monster.init_module()
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
part_names = require("MHR_Overlay.Misc.part_names");
|
||||
ailments = require("MHR_Overlay.Damage_Meter.ailments");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
end
|
||||
|
||||
return large_monster;
|
||||
@@ -67,42 +67,33 @@ function monster.update_monster(enemy)
|
||||
return;
|
||||
end
|
||||
|
||||
-- this is the VERY LEAST thing we should do all the time
|
||||
-- so the position doesn't lag all over the place
|
||||
-- due to how infrequently we update the monster(s).
|
||||
if is_large then
|
||||
large_monster.update_position(enemy);
|
||||
large_monster.update_ailments(enemy);
|
||||
else
|
||||
small_monster.update_position(enemy);
|
||||
small_monster.update_ailments(enemy);
|
||||
end
|
||||
|
||||
if updated_monsters[enemy] then
|
||||
-- this is the VERY LEAST thing we should do all the time
|
||||
-- so the position doesn't lag all over the place
|
||||
-- due to how infrequently we update the monster(s).
|
||||
if is_large then
|
||||
large_monster.update_position(enemy);
|
||||
if not config.current_config.global_settings.performance.prioritize_large_monsters then
|
||||
return;
|
||||
end
|
||||
else
|
||||
small_monster.update_position(enemy);
|
||||
else
|
||||
return;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- only updates N monsters per tick to increase performance
|
||||
if tick_count == last_update_tick then
|
||||
if updates_this_tick >= config.current_config.global_settings.performance.max_monster_updates_per_tick then
|
||||
-- this is the VERY LEAST thing we should do all the time
|
||||
-- so the position doesn't lag all over the place
|
||||
-- due to how infrequently we update the monster(s).
|
||||
if is_large then
|
||||
large_monster.update_position(enemy);
|
||||
if not config.current_config.global_settings.performance.prioritize_large_monsters then
|
||||
return
|
||||
end
|
||||
else
|
||||
small_monster.update_position(enemy);
|
||||
return;
|
||||
end
|
||||
end
|
||||
end
|
||||
-- is it old tick?
|
||||
-- is update limit reached?
|
||||
if tick_count == last_update_tick and updates_this_tick >= config.current_config.global_settings.performance.max_monster_updates_per_tick then
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- actually update the enemy now. we don't do this very often
|
||||
-- due to how much CPU time it takes to update each monster.
|
||||
if is_large then
|
||||
|
||||
@@ -7,6 +7,7 @@ local health_UI_entity;
|
||||
local stamina_UI_entity;
|
||||
local screen;
|
||||
local drawing;
|
||||
local ailments;
|
||||
|
||||
small_monster.list = {};
|
||||
|
||||
@@ -31,6 +32,17 @@ function small_monster.new(enemy)
|
||||
monster.distance = 0;
|
||||
|
||||
monster.name = "Small Monster";
|
||||
|
||||
monster.ailment = {};
|
||||
monster.ailment[ailments.poison_id] = {};
|
||||
monster.ailment[ailments.poison_id].buildup = {};
|
||||
monster.ailment[ailments.poison_id].share = {};
|
||||
monster.ailment[ailments.poison_id].activate_count = 0;
|
||||
|
||||
monster.ailment[ailments.blast_id] = {};
|
||||
monster.ailment[ailments.blast_id].buildup = {};
|
||||
monster.ailment[ailments.blast_id].share = {};
|
||||
monster.ailment[ailments.blast_id].activate_count = 0;
|
||||
|
||||
small_monster.init(monster, enemy);
|
||||
small_monster.init_UI(monster);
|
||||
@@ -86,27 +98,42 @@ function small_monster.init_UI(monster)
|
||||
);
|
||||
end
|
||||
|
||||
local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase")
|
||||
local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase");
|
||||
local physical_param_field = enemy_character_base_type_def:get_field("<PhysicalParam>k__BackingField");
|
||||
local status_param_field = enemy_character_base_type_def:get_field("<StatusParam>k__BackingField")
|
||||
local stamina_param_field = enemy_character_base_type_def:get_field("<StaminaParam>k__BackingField")
|
||||
local status_param_field = enemy_character_base_type_def:get_field("<StatusParam>k__BackingField");
|
||||
local stamina_param_field = enemy_character_base_type_def:get_field("<StaminaParam>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 physical_param_type = physical_param_field:get_type()
|
||||
local get_vital_method = physical_param_type:get_method("getVital")
|
||||
local get_capture_hp_vital_method = physical_param_type:get_method("get_CaptureHpVital")
|
||||
local physical_param_type = physical_param_field:get_type();
|
||||
local get_vital_method = physical_param_type:get_method("getVital");
|
||||
local get_capture_hp_vital_method = physical_param_type:get_method("get_CaptureHpVital");
|
||||
|
||||
local vital_param_type = get_vital_method:get_return_type()
|
||||
local get_current_method = vital_param_type:get_method("get_Current")
|
||||
local get_max_method = vital_param_type:get_method("get_Max")
|
||||
local vital_param_type = get_vital_method:get_return_type();
|
||||
local get_current_method = vital_param_type:get_method("get_Current");
|
||||
local get_max_method = vital_param_type:get_method("get_Max");
|
||||
|
||||
local stamina_param_type = stamina_param_field:get_type()
|
||||
local get_stamina_method = stamina_param_type:get_method("getStamina")
|
||||
local get_max_stamina_method = stamina_param_type:get_method("getMaxStamina")
|
||||
local stamina_param_type = stamina_param_field:get_type();
|
||||
local get_stamina_method = stamina_param_type:get_method("getStamina");
|
||||
local get_max_stamina_method = stamina_param_type:get_method("getMaxStamina");
|
||||
|
||||
local get_gameobject_method = sdk.find_type_definition("via.Component"):get_method("get_GameObject")
|
||||
local get_transform_method = sdk.find_type_definition("via.GameObject"):get_method("get_Transform")
|
||||
local get_position_method = sdk.find_type_definition("via.Transform"):get_method("get_Position")
|
||||
local damage_param_type = damage_param_field:get_type();
|
||||
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 poison_get_activate_count_method = poison_param_type:get_method("get_ActivateCount");
|
||||
local poison_damage_field = poison_param_type:get_field("<Damage>k__BackingField");
|
||||
local poison_get_is_damage_method = poison_param_type:get_method("get_IsDamage");
|
||||
|
||||
local blast_param_type = blast_param_field:get_type();
|
||||
local blast_get_activate_count_method = blast_param_type:get_method("get_ActivateCount");
|
||||
local blast_damage_method = blast_param_type:get_method("get_BlastDamage");
|
||||
local blast_adjust_rate_method = blast_param_type:get_method("get_BlastDamageAdjustRateByEnemyLv");
|
||||
|
||||
local get_gameobject_method = sdk.find_type_definition("via.Component"):get_method("get_GameObject");
|
||||
local get_transform_method = sdk.find_type_definition("via.GameObject"):get_method("get_Transform");
|
||||
local get_position_method = sdk.find_type_definition("via.Transform"):get_method("get_Position");
|
||||
|
||||
function small_monster.update_position(enemy)
|
||||
if not config.current_config.small_monster_UI.enabled then
|
||||
@@ -146,6 +173,53 @@ function small_monster.update_position(enemy)
|
||||
end
|
||||
end
|
||||
|
||||
-- Code by coavins
|
||||
function small_monster.update_ailments(enemy)
|
||||
if enemy == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local monster = small_monster.get_monster(enemy);
|
||||
|
||||
local damage_param = damage_param_field:get_data(enemy);
|
||||
if damage_param ~= nil then
|
||||
|
||||
local poison_param = poison_param_field:get_data(damage_param);
|
||||
if poison_param ~= nil then
|
||||
-- if applied, then calculate share for poison
|
||||
local activate_count = poison_get_activate_count_method:call(poison_param):get_element(0):get_field("mValue");
|
||||
if activate_count > monster.ailment[ailments.poison_id].activate_count then
|
||||
monster.ailment[ailments.poison_id].activate_count = activate_count;
|
||||
ailments.calculate_ailment_contribution(monster, ailments.poison_id);
|
||||
end
|
||||
-- if poison tick, apply damage
|
||||
local poison_damage = poison_damage_field:get_data(poison_param);
|
||||
local is_damage = poison_get_is_damage_method:call(poison_param);
|
||||
|
||||
if is_damage then
|
||||
ailments.apply_ailment_damage(monster, ailments.poison_id, poison_damage);
|
||||
end
|
||||
end
|
||||
|
||||
--xy = "test"
|
||||
local blast_param = blast_param_field:get_data(damage_param);
|
||||
if blast_param ~= nil then
|
||||
-- if applied, then calculate share for blast and apply damage
|
||||
local activate_count = blast_get_activate_count_method:call(blast_param):get_element(0):get_field("mValue");
|
||||
|
||||
if activate_count > monster.ailment[ailments.blast_id].activate_count then
|
||||
monster.ailment[ailments.blast_id].activate_count = activate_count;
|
||||
ailments.calculate_ailment_contribution(monster, ailments.blast_id);
|
||||
|
||||
local blast_damage = blast_damage_method:call(blast_param);
|
||||
local blast_adjust_rate = blast_adjust_rate_method:call(blast_param);
|
||||
|
||||
ailments.apply_ailment_damage(monster, ailments.blast_id, blast_damage * blast_adjust_rate);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function small_monster.update(enemy)
|
||||
if enemy == nil then
|
||||
return;
|
||||
@@ -264,6 +338,7 @@ function small_monster.init_module()
|
||||
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
ailments = require("MHR_Overlay.Damage_Meter.ailments");
|
||||
end
|
||||
|
||||
return small_monster;
|
||||
@@ -6341,6 +6341,18 @@ function customization_menu.draw()
|
||||
damage_meter_UI_changed = damage_meter_UI_changed or changed;
|
||||
tracked_damage_types_changed = tracked_damage_types_changed or changed;
|
||||
|
||||
changed, config.current_config.damage_meter_UI.tracked_damage_types.poison_damage =
|
||||
imgui.checkbox(language.current_language.customization_menu.poison_damage, config.current_config.damage_meter_UI.tracked_damage_types.poison_damage);
|
||||
config_changed = config_changed or changed;
|
||||
damage_meter_UI_changed = damage_meter_UI_changed or changed;
|
||||
tracked_damage_types_changed = tracked_damage_types_changed or changed;
|
||||
|
||||
changed, config.current_config.damage_meter_UI.tracked_damage_types.blast_damage =
|
||||
imgui.checkbox(language.current_language.customization_menu.blast_damage, config.current_config.damage_meter_UI.tracked_damage_types.blast_damage);
|
||||
config_changed = config_changed or changed;
|
||||
damage_meter_UI_changed = damage_meter_UI_changed or changed;
|
||||
tracked_damage_types_changed = tracked_damage_types_changed or changed;
|
||||
|
||||
if tracked_damage_types_changed then
|
||||
for player_id, _player in pairs(player.list) do
|
||||
player.update_display(_player);
|
||||
|
||||
Reference in New Issue
Block a user