Optimizations, fixed 'Allmother' quest bug

This commit is contained in:
GreenComfyTea
2022-04-25 16:59:01 +03:00
parent a96d141b6f
commit 3954717add
24 changed files with 245 additions and 189 deletions

View File

@@ -11,7 +11,7 @@ local language = require("MHR_Overlay.Misc.language");
local table_helpers = require("MHR_Overlay.Misc.table_helpers");
local part_names = require("MHR_Overlay.Misc.part_names");
local ailments = require("MHR_Overlay.Monsters.ailments");
local player = require("MHR_Overlay.Damage_Meter.player");
local damage_hook = require("MHR_Overlay.Damage_Meter.damage_hook");
@@ -22,6 +22,8 @@ local body_part = require("MHR_Overlay.Monsters.body_part");
local large_monster = require("MHR_Overlay.Monsters.large_monster");
local monster_hook = require("MHR_Overlay.Monsters.monster_hook");
local small_monster = require("MHR_Overlay.Monsters.small_monster");
local ailments = require("MHR_Overlay.Monsters.ailments");
local ailment_hook = require("MHR_Overlay.Monsters.ailment_hook");
local damage_meter_UI = require("MHR_Overlay.UI.Modules.damage_meter_UI");
local large_monster_UI = require("MHR_Overlay.UI.Modules.large_monster_UI");
@@ -67,7 +69,7 @@ ailments.init_module();
large_monster.init_module();
monster_hook.init_module();
small_monster.init_module();
ailment_hook.init_module();
customization_menu.init_module();
body_part_UI_entity.init_module();
@@ -105,8 +107,8 @@ re.on_frame(function()
end);
re.on_frame(function()
draw.text("xy: " .. tostring(xy), 551, 11, 0xFF000000);
draw.text("xy: " .. tostring(xy), 550, 10, 0xFFFFFFFF);
--draw.text("xy: " .. tostring(xy), 551, 11, 0xFF000000);
--draw.text("xy: " .. tostring(xy), 550, 10, 0xFFFFFFFF);
end);
-- #endregion
--------------------------RE_IMGUI---------------------------

View File

@@ -49,7 +49,7 @@ function damage_hook.update_damage(args)
return;
end
local enemy_calc_damage_info = sdk.to_managed_object(args[3]); -- snow.hit.EnemyCalcDamageInfo.AfterCalcInfo_DamageSide
local enemy_calc_damage_info = sdk.to_managed_object(args[3]); -- snow.hit.EnemyCalcDamageInfo.AfterCalcInfo_DamageSide -- snow.hit.DamageFlowInfoBase calcDamageResult?
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);
local is_marionette_attack = is_marionette_attack_method:call(enemy_calc_damage_info)

View File

@@ -44,6 +44,8 @@ local creature_is_inactive_field = environment_creature_base_type_def:get_field(
local message_manager_type_def = sdk.find_type_definition("snow.gui.MessageManager");
local get_env_creature_name_message_method = message_manager_type_def:get_method("getEnvCreatureNameMessage");
local get_pos_method = environment_creature_base_type_def:get_method("get_Pos");
function env_creature.init(creature, REcreature)
local creature_type = creature_type_field:get_data(REcreature);
if creature_type == nil then
@@ -64,17 +66,23 @@ function env_creature.init_UI(creature)
creature.name_label.offset.y = creature.name_label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
end
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 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 env_creature.update(REcreature)
if REcreature == nil then
if not config.current_config.endemic_life_UI.enabled then
return;
end
local creature = env_creature.get_creature(REcreature);
local position = get_pos_method:call(REcreature);
if position ~= nil then
creature.position = position;
end
--[[
if creature.game_object == nil then
creature.game_object = get_game_object_method:call(REcreature);
@@ -99,11 +107,13 @@ function env_creature.update(REcreature)
end
creature.position = position;
--]]
local is_inactive = creature_is_inactive_field:get_data(REcreature);
if is_inactive ~= nil then
creature.is_inactive = is_inactive;
end
end
function env_creature.draw(creature, position_on_screen, opacity_scale)

View File

@@ -1,6 +1,7 @@
local env_creature_hook = {};
local env_creature;
local config;
local time;
local environment_creature_base_type_def = sdk.find_type_definition("snow.envCreature.EnvironmentCreatureBase");
local environment_creature_base_update_method = environment_creature_base_type_def:get_method("update");
@@ -21,6 +22,7 @@ end
function env_creature_hook.init_module()
config = require("MHR_Overlay.Misc.config");
env_creature = require("MHR_Overlay.Endemic_Life.env_creature");
time = require("MHR_Overlay.Game_Handler.time");
end
return env_creature_hook;

View File

@@ -14,10 +14,15 @@ quest_status.update_is_result_screen = false;
local quest_manager_type_definition = sdk.find_type_definition("snow.QuestManager");
local on_changed_game_status = quest_manager_type_definition:get_method("onChangedGameStatus");
local get_status_method = quest_manager_type_definition:get_method("getStatus");
local is_result_demo_play_start_method = quest_manager_type_definition:get_method("isResultDemoPlayStart");
local village_area_manager_type_def = sdk.find_type_definition("snow.VillageAreaManager");
local check_current_area_training_area_method = village_area_manager_type_def:get_method("checkCurrentArea_TrainingArea");
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)
@@ -47,7 +52,7 @@ function quest_status.init()
return;
end
local new_quest_status = singletons.quest_manager:call("getStatus");
local new_quest_status = get_status_method:call(singletons.quest_manager);
if new_quest_status == nil then
customization_menu.status = "No quest status";
return;
@@ -64,7 +69,7 @@ function quest_status.update_is_online()
return;
end
local is_quest_online = singletons.lobby_manager:call("IsQuestOnline");
local is_quest_online = is_quest_online_method:call(singletons.lobby_manager);
if is_quest_online == nil then
return;
end
@@ -100,7 +105,7 @@ function quest_status.update_is_result_screen()
return;
end
local is_result_demo_play_start = singletons.quest_manager:call("isResultDemoPlayStart");
local is_result_demo_play_start = is_result_demo_play_start_method:call(singletons.quest_manager);
if is_result_demo_play_start == nil then
return;
end

View File

@@ -2677,7 +2677,7 @@ function config.init()
},
endemic_life_UI = {
enabled = true,
enabled = false,
settings = {
hide_inactive_creatures = true,

View File

@@ -65,7 +65,7 @@ language.default_language = {
poison = "Poison",
blast = "Blast",
exhaust ="Exhaust",
mount = "Mount",
ride = "Wyvern Riding",
waterblight = "Waterblight",
fireblight = "Fireblight",
iceblight = "Iceblight",

View File

@@ -0,0 +1,96 @@
local ailment_hook = {};
local small_monster;
local large_monster;
local config;
local ailments;
local table_helpers;
local enemy_poison_damage_param_type_def = sdk.find_type_definition("snow.enemy.EnemyPoisonDamageParam");
local on_poison_activate_proc_method = enemy_poison_damage_param_type_def:get_method("onActivateProc");
local enemy_condition_damage_param_base_type_def = sdk.find_type_definition("snow.enemy.EnemyConditionDamageParamBase");
local get_enemy_method = enemy_condition_damage_param_base_type_def:get_method("get_Em");
local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase");
local damage_param_field = enemy_character_base_type_def:get_field("<DamageParam>k__BackingField");
local is_boss_enemy_method = enemy_character_base_type_def:get_method("get_isBossEnemy");
local enemy_damage_param_type_def = sdk.find_type_definition("snow.enemy.EnemyDamageParam");
local stock_damage_method = enemy_damage_param_type_def:get_method("stockDamage");
local poison_param_field = enemy_damage_param_type_def:get_field("_PoisonParam");
local blast_param_field = enemy_damage_param_type_def:get_field("_BlastParam");
sdk.hook(stock_damage_method, function(args)
pcall(ailment_hook.stock_damage);
end, function(retval)
return retval;
end);
sdk.hook(on_poison_activate_proc_method, function(args)
pcall(ailment_hook.poison_proc, sdk.to_managed_object(args[2]));
end, function(retval)
return retval;
end);
function ailment_hook.poison_proc(poison_param)
if poison_param == nil then
return;
end
local enemy = get_enemy_method:call(poison_param);
if enemy == nil then
return;
end
local is_large = is_boss_enemy_method:call(enemy);
if is_large == nil then
return;
end
local monster;
if is_large then
monster = large_monster.get_monster(enemy);
else
monster = small_monster.get_monster(enemy);
end
ailments.calculate_ailment_contribution(monster, ailments.poison_id);
end
function ailment_hook.stock_damage()
for enemy, monster in pairs(large_monster.list) do
local damage_param = damage_param_field:get_data(enemy);
if damage_param == nil then
goto continue;
end
local poison_param = poison_param_field:get_data(damage_param);
local blast_param = blast_param_field:get_data(damage_param);
ailments.update_poison_blast(monster, poison_param, blast_param);
::continue::
end
for enemy, monster in pairs(small_monster.list) do
local damage_param = damage_param_field:get_data(enemy);
if damage_param == nil then
goto continue;
end
local poison_param = poison_param_field:get_data(damage_param);
local blast_param = blast_param_field:get_data(damage_param);
ailments.update_poison_blast(monster, poison_param, blast_param);
::continue::
end
end
function ailment_hook.init_module()
small_monster = require("MHR_Overlay.Monsters.small_monster");
large_monster = require("MHR_Overlay.Monsters.large_monster");
config = require("MHR_Overlay.Misc.config");
ailments = require("MHR_Overlay.Monsters.ailments");
table_helpers = require("MHR_Overlay.Misc.table_helpers");
end
return ailment_hook;

View File

@@ -33,7 +33,7 @@ ailments.flash_id = 3;
ailments.poison_id = 4;
ailments.blast_id = 5;
ailments.exhaust_id = 6;
ailments.mount_id = 7;
ailments.ride_id = 7;
ailments.water_id = 8;
ailments.fire_id = 9;
ailments.ice_id = 10;
@@ -83,8 +83,8 @@ function ailments.new(_ailments, ailment_id)
_ailments[ailment_id].name = language.current_language.ailments.blast;
elseif ailment_id == ailments.exhaust_id then
_ailments[ailment_id].name = language.current_language.ailments.exhaust;
elseif ailment_id == ailments.mount_id then
_ailments[ailment_id].name = language.current_language.ailments.mount;
elseif ailment_id == ailments.ride_id then
_ailments[ailment_id].name = language.current_language.ailments.ride;
elseif ailment_id == ailments.water_id then
_ailments[ailment_id].name = language.current_language.ailments.waterblight;
elseif ailment_id == ailments.fire_id then
@@ -122,7 +122,7 @@ function ailments.init_ailments()
ailments.new(_ailments, ailments.poison_id);
ailments.new(_ailments, ailments.blast_id);
ailments.new(_ailments, ailments.exhaust_id);
ailments.new(_ailments, ailments.mount_id);
ailments.new(_ailments, ailments.ride_id);
ailments.new(_ailments, ailments.water_id);
ailments.new(_ailments, ailments.fire_id);
ailments.new(_ailments, ailments.ice_id);
@@ -261,7 +261,6 @@ function ailments.update_ailments(enemy, monster)
if duration ~= nil and not monster.ailments[id].is_active then
if duration ~= monster.ailments[id].duration then
xy = tostring(monster.ailments[id].is_active) .. " " .. tostring(monster.ailments[id].duration) .. " -> " .. tostring(duration);
ailments.update_last_change_time(monster, id);
end
@@ -303,54 +302,33 @@ function ailments.update_last_change_time(monster, id)
end
-- Code by coavins
function ailments.update_poison_blast(enemy, is_large)
if enemy == nil then
function ailments.update_poison_blast(monster, poison_param, blast_param)
if monster == nil then
return;
end
local monster;
if is_large then
monster = large_monster.get_monster(enemy);
else
monster = small_monster.get_monster(enemy);
end
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 = get_activate_count_method:call(poison_param):get_element(0):get_field("mValue");
if activate_count > monster.ailments[ailments.poison_id].activate_count then
monster.ailments[ailments.poison_id].activate_count = activate_count;
ailments.calculate_ailment_contribution(monster, ailments.poison_id);
end
-- if poison tick, apply damage
if poison_param ~= nil then
--if poison tick, apply damage
local is_damage = poison_get_is_damage_method:call(poison_param);
if is_damage then
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
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 = get_activate_count_method:call(blast_param):get_element(0):get_field("mValue");
if blast_param ~= nil then
-- if applied, then calculate share for blast and apply damage
local activate_count = get_activate_count_method:call(blast_param):get_element(0):get_field("mValue");
if activate_count > monster.ailments[ailments.blast_id].activate_count then
monster.ailments[ailments.blast_id].activate_count = activate_count;
ailments.calculate_ailment_contribution(monster, ailments.blast_id);
if activate_count > monster.ailments[ailments.blast_id].activate_count then
monster.ailments[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
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

View File

@@ -35,6 +35,7 @@ function large_monster.new(enemy)
monster.capture_percentage = 0;
monster.dead_or_captured = false;
monster.is_disp_icon_mini_map = true;
monster.stamina = 0;
monster.max_stamina = 1000;
@@ -323,6 +324,7 @@ local physical_param_field = enemy_character_base_type_def:get_field("<PhysicalP
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 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");
local physical_param_type = physical_param_field:get_type();
local get_vital_method = physical_param_type:get_method("getVital");
@@ -351,15 +353,15 @@ 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");
local get_pos_field = enemy_character_base_type_def:get_method("get_Pos");
--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
if not config.current_config.large_monster_UI.dynamic.enabled then
return;
end
@@ -368,6 +370,13 @@ function large_monster.update_position(enemy)
return;
end
local position = get_pos_field:call(enemy);
if position ~= nil then
monster.position = position;
end
--[[
-- cac
-- cache off the game object and transform
-- as these are pretty much guaranteed to stay constant
-- as long as the enemy is alive
@@ -395,7 +404,7 @@ function large_monster.update_position(enemy)
if position ~= nil then
monster.position = position;
end
end--]]
end
-- Code by coavins
@@ -444,11 +453,8 @@ function large_monster.update(enemy)
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);
local dead_or_captured = check_die_method:call(enemy);
if dead_or_captured == nil then
return;
end
local is_disp_icon_mini_map = is_disp_icon_mini_map_method:call(enemy);
local stamina_param = stamina_param_field:get_data(enemy)
if stamina_param == nil then
@@ -567,6 +573,9 @@ function large_monster.update(enemy)
if dead_or_captured ~= nil then
monster.dead_or_captured = dead_or_captured;
end
if is_disp_icon_mini_map ~= nil then
monster.is_disp_icon_mini_map = is_disp_icon_mini_map;
end
if stamina ~= nil then
monster.stamina = stamina;
@@ -833,6 +842,8 @@ function large_monster.draw_highlighted(monster, position_on_screen, opacity_sca
local last_part_position_on_screen = body_part.draw_highlighted(monster, parts_position_on_screen, opacity_scale);
if config.current_config.large_monster_UI.highlighted.ailments.settings.offset_is_relative_to_parts then
if last_part_position_on_screen ~= nil then
ailments_position_on_screen = {

View File

@@ -7,7 +7,7 @@ local ailments;
local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase");
local enemy_character_base_update_method = enemy_character_base_type_def:get_method("update");
local is_boss_enemy_method = sdk.find_type_definition("snow.enemy.EnemyCharacterBase"):get_method("get_isBossEnemy");
local is_boss_enemy_method = enemy_character_base_type_def:get_method("get_isBossEnemy");
sdk.hook(enemy_character_base_update_method, function(args)
pcall(monster_hook.update_monster, sdk.to_managed_object(args[2]));
@@ -68,8 +68,6 @@ function monster_hook.update_monster(enemy)
return;
end
ailments.update_poison_blast(enemy, is_large);
if is_large then
monster_hook.update_large_monster(enemy);
else

View File

@@ -118,26 +118,34 @@ 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 get_hp_vital_method = enemy_character_base_type_def:get_method("getHpVital");
local get_hp_max_vital_method = enemy_character_base_type_def:get_method("getHpMaxVital");
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 get_pos_field = enemy_character_base_type_def:get_method("get_Pos");
--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
if not config.current_config.small_monster_UI.enabled or not config.current_config.small_monster_UI.dynamic_positioning.enabled then
return;
end
local monster = small_monster.get_monster(enemy);
if not monster then return end
local position = get_pos_field:call(enemy);
if position ~= nil then
monster.position = position;
end
--[[
-- cache off the game object and transform
-- as these are pretty much guaranteed to stay constant
-- as long as the enemy is alive
@@ -166,6 +174,7 @@ function small_monster.update_position(enemy)
if position ~= nil then
monster.position = position;
end
--]]
end
function small_monster.update(enemy)
@@ -201,20 +210,18 @@ function small_monster.update(enemy)
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)
local health = get_hp_vital_method:call(enemy);
local max_health = get_hp_max_vital_method:call(enemy);
local capture_health = get_capture_hp_vital_method:call(physical_param);
local stamina = get_stamina_method:call(stamina_param)
local max_stamina = get_max_stamina_method:call(stamina_param)
local stamina = get_stamina_method:call(stamina_param);
local max_stamina = get_max_stamina_method:call(stamina_param);
local dead_or_captured = check_die_method:call(enemy);
if dead_or_captured == nil then
return;
end
small_monster.update_position(enemy)
local monster = small_monster.get_monster(enemy);
if health ~= nil then
@@ -255,7 +262,7 @@ function small_monster.update(enemy)
end
end
ailments.update_ailments(enemy, monster)
ailments.update_ailments(enemy, monster);
end
function small_monster.draw(monster, position_on_screen, opacity_scale)

View File

@@ -62,7 +62,7 @@ function large_monster_UI.draw(dynamic_enabled, static_enabled, highlighted_enab
goto continue;
end
if monster.dead_or_captured then
if monster.dead_or_captured or not monster.is_disp_icon_mini_map then
monster_id_shift = monster_id_shift + 1;
elseif i == highlighted_id + monster_id_shift then
highlighted_monster = monster;