Revert back to update() hook.

This commit is contained in:
GreenComfyTea
2022-07-12 08:29:12 +03:00
parent fc9d6fa25f
commit 48205368e2
13 changed files with 204 additions and 279 deletions

View File

@@ -167,16 +167,8 @@ function damage_hook.update_damage(enemy, enemy_calc_damage_info)
local monster; local monster;
if is_large_monster then if is_large_monster then
monster = large_monster.get_monster(enemy); monster = large_monster.get_monster(enemy);
if quest_status.is_online and player.myself.id ~= 0 then
local physical_param = large_monster.update_health(enemy, monster);
large_monster.update_parts(enemy, monster, physical_param);
end
else else
if quest_status.is_online and player.myself.id ~= 0 then
monster = small_monster.get_monster(enemy); monster = small_monster.get_monster(enemy);
small_monster.update_health(enemy, monster);
end
end end
local stun_damage = enemy_calc_damage_info:get_field("<StunDamage>k__BackingField"); local stun_damage = enemy_calc_damage_info:get_field("<StunDamage>k__BackingField");

View File

@@ -47,7 +47,7 @@ function time.tick()
if time.total_elapsed_script_seconds - time.last_elapsed_script_seconds > 60 / config.current_config.global_settings.performance.update_rate then if time.total_elapsed_script_seconds - time.last_elapsed_script_seconds > 60 / config.current_config.global_settings.performance.update_rate then
time.last_elapsed_script_seconds = time.total_elapsed_script_seconds; time.last_elapsed_script_seconds = time.total_elapsed_script_seconds;
time.update_players_dps(); time.update_players_dps();
time.update_small_monsters(); --time.update_small_monsters();
end end
end end

View File

@@ -29,7 +29,9 @@ function config.init()
}, },
performance = { performance = {
update_rate = 60 max_monster_updates_per_tick = 2,
prioritize_large_monsters = false,
update_rate = 60,
}, },
module_visibility = { module_visibility = {

View File

@@ -379,6 +379,9 @@ language.default_language = {
update_rate = "Update Rate", update_rate = "Update Rate",
cart_count = "Cart Count", cart_count = "Cart Count",
cart_count_label = "Cart Count Label", cart_count_label = "Cart Count Label",
prioritize_large_monsters = "Large Monsters on High Priority",
max_monster_updates_per_tick = "Max Monster Updates per Tick",
} }
}; };

View File

@@ -39,7 +39,6 @@ function large_monster.new(enemy)
monster.dead_or_captured = false; monster.dead_or_captured = false;
monster.is_disp_icon_mini_map = true; monster.is_disp_icon_mini_map = true;
monster.is_tired = false;
monster.stamina = 0; monster.stamina = 0;
monster.max_stamina = 1000; monster.max_stamina = 1000;
monster.stamina_percentage = 0; monster.stamina_percentage = 0;
@@ -56,11 +55,10 @@ function large_monster.new(enemy)
monster.is_in_rage = false; monster.is_in_rage = false;
monster.rage_point = 0; monster.rage_point = 0;
monster.rage_limit = 3000; monster.rage_limit = 3000;
monster.rage_count = 0;
monster.rage_percentage = 0;
monster.rage_timer = 0; monster.rage_timer = 0;
monster.rage_duration = 600; monster.rage_duration = 600;
monster.rage_count = 0;
monster.rage_percentage = 0;
monster.rage_total_seconds_left = 0; monster.rage_total_seconds_left = 0;
monster.rage_minutes_left = 0; monster.rage_minutes_left = 0;
@@ -80,7 +78,6 @@ function large_monster.new(enemy)
monster.parts = {}; monster.parts = {};
monster.ailments = ailments.init_ailments(); monster.ailments = ailments.init_ailments();
monster.rider_id = -1; monster.rider_id = -1;
large_monster.init(monster, enemy); large_monster.init(monster, enemy);
@@ -91,17 +88,6 @@ function large_monster.new(enemy)
if large_monster.list[enemy] == nil then if large_monster.list[enemy] == nil then
large_monster.list[enemy] = monster; large_monster.list[enemy] = monster;
end end
large_monster.update_position(enemy, monster);
large_monster.update(enemy, monster);
local physical_param = large_monster.update_health(enemy, monster);
large_monster.update_parts(enemy, monster, physical_param);
large_monster.update_stamina(enemy, monster, nil);
large_monster.update_stamina_timer(enemy, monster, nil);
large_monster.update_rage(enemy, monster, nil);
large_monster.update_rage_timer(enemy, monster, nil);
return monster; return monster;
end end
@@ -114,7 +100,6 @@ function large_monster.get_monster(enemy)
end 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 enemy_type_field = enemy_character_base_type_def:get_field("<EnemyType>k__BackingField"); local enemy_type_field = enemy_character_base_type_def:get_field("<EnemyType>k__BackingField");
local get_monster_list_register_scale_method = enemy_character_base_type_def:get_method("get_MonsterListRegisterScale"); local get_monster_list_register_scale_method = enemy_character_base_type_def:get_method("get_MonsterListRegisterScale");
@@ -378,9 +363,9 @@ local get_current_method = vital_param_type:get_method("get_Current");
local get_max_method = vital_param_type:get_method("get_Max"); local get_max_method = vital_param_type:get_method("get_Max");
local stamina_param_type = stamina_param_field:get_type(); local stamina_param_type = stamina_param_field:get_type();
local is_tired_method = stamina_param_type:get_method("isTired");
local get_stamina_method = stamina_param_type:get_method("getStamina"); local get_stamina_method = stamina_param_type:get_method("getStamina");
local get_max_stamina_method = stamina_param_type:get_method("getMaxStamina"); local get_max_stamina_method = stamina_param_type:get_method("getMaxStamina");
local is_tired_method = stamina_param_type:get_method("isTired");
local get_remaining_tired_time_method = stamina_param_type:get_method("getStaminaRemainingTime"); local get_remaining_tired_time_method = stamina_param_type:get_method("getStaminaRemainingTime");
local get_total_tired_time_method = stamina_param_type:get_method("get_TiredSec"); local get_total_tired_time_method = stamina_param_type:get_method("get_TiredSec");
@@ -389,7 +374,6 @@ local anger_param_type = anger_param_field:get_type();
local is_anger_method = anger_param_type:get_method("isAnger"); local is_anger_method = anger_param_type:get_method("isAnger");
local get_anger_point_method = anger_param_type:get_method("get_AngerPoint"); 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 get_limit_anger_method = anger_param_type:get_method("get_LimitAnger");
local get_remaining_anger_time_method = anger_param_type:get_method("getAngerRemainingTime"); local get_remaining_anger_time_method = anger_param_type:get_method("getAngerRemainingTime");
local get_total_anger_time_method = anger_param_type:get_method("get_TimerAnger"); local get_total_anger_time_method = anger_param_type:get_method("get_TimerAnger");
@@ -401,15 +385,18 @@ local get_mario_player_index_method = mario_param_type:get_method("get_MarioPlay
local get_pos_field = enemy_character_base_type_def:get_method("get_Pos"); local get_pos_field = enemy_character_base_type_def:get_method("get_Pos");
function large_monster.update_position(enemy, monster) function large_monster.update_position(enemy)
if not config.current_config.large_monster_UI.dynamic.enabled then if not config.current_config.large_monster_UI.dynamic.enabled then
return; return;
end end
local position = get_pos_field:call(enemy); local monster = large_monster.get_monster(enemy);
if position ~= nil then if monster == nil then
monster.position = position; return;
end end
local position = get_pos_field:call(enemy) or monster.position;
monster.position = position;
end end
-- Code by coavins -- Code by coavins
@@ -430,7 +417,7 @@ function large_monster.update_all_riders()
end end
function large_monster.update(enemy, monster) function large_monster.update(enemy)
local cached_config = config.current_config.large_monster_UI; local cached_config = config.current_config.large_monster_UI;
if not cached_config.dynamic.enabled if not cached_config.dynamic.enabled
@@ -443,24 +430,26 @@ function large_monster.update(enemy, monster)
return; return;
end end
local monster = large_monster.get_monster(enemy);
local dead_or_captured = check_die_method:call(enemy); local dead_or_captured = check_die_method:call(enemy);
monster.dead_or_captured = (dead_or_captured == nil and false) or dead_or_captured; monster.dead_or_captured = (dead_or_captured == nil and false) or dead_or_captured;
local is_disp_icon_mini_map = is_disp_icon_mini_map_method:call(enemy); local is_disp_icon_mini_map = is_disp_icon_mini_map_method:call(enemy)
monster.is_disp_icon_mini_map = (is_disp_icon_mini_map == nil and false) or is_disp_icon_mini_map; monster.is_disp_icon_mini_map = (is_disp_icon_mini_map == nil and false) or is_disp_icon_mini_map;
ailments.update_ailments(enemy, monster); local physical_param = large_monster.update_health(enemy, monster);
large_monster.update_stamina(enemy, monster);
large_monster.update_rage(enemy, monster);
large_monster.update_parts(enemy, monster, physical_param);
ailments.update_ailments(enemy, monster);
end end
function large_monster.update_health(enemy, monster) function large_monster.update_health(enemy, monster)
local cached_config = config.current_config.large_monster_UI; local cached_config = config.current_config.large_monster_UI;
if not cached_config.dynamic.enabled
and not cached_config.static.enabled
and not cached_config.highlighted.enabled then
return;
end
if not cached_config.dynamic.health.visibility if not cached_config.dynamic.health.visibility
and not cached_config.static.health.visibility and not cached_config.static.health.visibility
and not cached_config.highlighted.health.visibility then and not cached_config.highlighted.health.visibility then
@@ -492,33 +481,20 @@ function large_monster.update_health(enemy, monster)
return physical_param; return physical_param;
end end
function large_monster.update_stamina(enemy, monster, stamina_param) function large_monster.update_stamina(enemy, monster)
local cached_config = config.current_config.large_monster_UI; local cached_config = config.current_config.large_monster_UI;
if not cached_config.dynamic.enabled
and not cached_config.static.enabled
and not cached_config.highlighted.enabled then
return;
end
if not cached_config.dynamic.stamina.visibility if not cached_config.dynamic.stamina.visibility
and not cached_config.static.stamina.visibility and not cached_config.static.stamina.visibility
and not cached_config.highlighted.stamina.visibility then and not cached_config.highlighted.stamina.visibility then
return; return;
end end
if stamina_param == nil then local stamina_param = stamina_param_field:get_data(enemy)
stamina_param = stamina_param_field:get_data(enemy);
if stamina_param == nil then if stamina_param == nil then
customization_menu.status = "No stamina param"; customization_menu.status = "No stamina param";
return; return;
end end
end
local is_tired = is_tired_method:call(stamina_param, false);
if is_tired ~= nil then
monster.is_tired = is_tired;
end
monster.stamina = get_stamina_method:call(stamina_param) or monster.stamina; monster.stamina = get_stamina_method:call(stamina_param) or monster.stamina;
monster.max_stamina = get_max_stamina_method:call(stamina_param) or monster.max_stamina; monster.max_stamina = get_max_stamina_method:call(stamina_param) or monster.max_stamina;
@@ -527,37 +503,12 @@ function large_monster.update_stamina(enemy, monster, stamina_param)
if monster.max_stamina ~= 0 then if monster.max_stamina ~= 0 then
monster.stamina_percentage = monster.stamina / monster.max_stamina; monster.stamina_percentage = monster.stamina / monster.max_stamina;
end end
end
function large_monster.update_stamina_timer(enemy, monster, stamina_param)
local cached_config = config.current_config.large_monster_UI;
if not cached_config.dynamic.enabled
and not cached_config.static.enabled
and not cached_config.highlighted.enabled then
return;
end
if not cached_config.dynamic.stamina.visibility
and not cached_config.static.stamina.visibility
and not cached_config.highlighted.stamina.visibility then
return;
end
if stamina_param == nil then
stamina_param = stamina_param_field:get_data(enemy);
if stamina_param == nil then
customization_menu.status = "No stamina param";
return;
end
end
local is_tired = is_tired_method:call(stamina_param, false); local is_tired = is_tired_method:call(stamina_param, false);
if is_tired ~= nil then if is_tired ~= nil then
monster.is_tired = is_tired; monster.is_tired = is_tired;
end end
monster.tired_timer = get_remaining_tired_time_method:call(stamina_param) or monster.tired_timer; monster.tired_timer = get_remaining_tired_time_method:call(stamina_param) or monster.tired_timer;
monster.tired_duration = get_total_tired_time_method:call(stamina_param) or monster.tired_duration; monster.tired_duration = get_total_tired_time_method:call(stamina_param) or monster.tired_duration;
@@ -576,68 +527,32 @@ function large_monster.update_stamina_timer(enemy, monster, stamina_param)
end end
end end
function large_monster.update_rage(enemy, monster, anger_param) function large_monster.update_rage(enemy, monster)
local cached_config = config.current_config.large_monster_UI; local cached_config = config.current_config.large_monster_UI;
if not cached_config.dynamic.enabled
and not cached_config.static.enabled
and not cached_config.highlighted.enabled then
return;
end
if not cached_config.dynamic.rage.visibility if not cached_config.dynamic.rage.visibility
and not cached_config.static.rage.visibility and not cached_config.static.rage.visibility
and not cached_config.highlighted.rage.visibility then and not cached_config.highlighted.rage.visibility then
return; return;
end end
if anger_param == nil then local anger_param = anger_param_field:get_data(enemy);
anger_param = anger_param_field:get_data(enemy);
if anger_param == nil then if anger_param == nil then
customization_menu.status = "No anger param"; customization_menu.status = "No anger param";
return; return;
end end
end
local is_in_rage = is_anger_method:call(anger_param);
monster.is_in_rage = (is_in_rage == nil and false) or is_in_rage;
monster.rage_point = get_anger_point_method:call(anger_param) or monster.rage_point; monster.rage_point = get_anger_point_method:call(anger_param) or monster.rage_point;
monster.rage_limit = get_limit_anger_method:call(anger_param)or monster.rage_limit; monster.rage_limit = get_limit_anger_method:call(anger_param)or monster.rage_limit;
monster.rage_timer = get_remaining_anger_time_method:call(anger_param) or monster.rage_timer;
monster.rage_duration = get_total_anger_time_method:call(anger_param) or monster.rage_duration;
if monster.rage_limit ~= 0 then if monster.rage_limit ~= 0 then
monster.rage_percentage = monster.rage_point / monster.rage_limit; monster.rage_percentage = monster.rage_point / monster.rage_limit;
end end
end
function large_monster.update_rage_timer(enemy, monster, anger_param)
local cached_config = config.current_config.large_monster_UI;
if not cached_config.dynamic.enabled
and not cached_config.static.enabled
and not cached_config.highlighted.enabled then
return;
end
if not cached_config.dynamic.rage.visibility
and not cached_config.static.rage.visibility
and not cached_config.highlighted.rage.visibility then
return;
end
if anger_param == nil then
anger_param = anger_param_field:get_data(enemy);
if anger_param == nil then
customization_menu.status = "No anger param";
return;
end
end
local is_in_rage = is_anger_method:call(anger_param);
if is_in_rage ~= nil then
monster.is_in_rage = is_in_rage;
end
monster.rage_timer = get_remaining_anger_time_method:call(anger_param) or monster.rage_timer;
monster.rage_duration = get_total_anger_time_method:call(anger_param) or monster.rage_duration;
if monster.is_in_rage then if monster.is_in_rage then
monster.rage_total_seconds_left = monster.rage_timer; monster.rage_total_seconds_left = monster.rage_timer;
@@ -657,12 +572,6 @@ end
function large_monster.update_parts(enemy, monster, physical_param) function large_monster.update_parts(enemy, monster, physical_param)
local cached_config = config.current_config.large_monster_UI; local cached_config = config.current_config.large_monster_UI;
if not cached_config.dynamic.enabled
and not cached_config.static.enabled
and not cached_config.highlighted.enabled then
return;
end
if not cached_config.dynamic.body_parts.visibility if not cached_config.dynamic.body_parts.visibility
and not cached_config.static.body_parts.visibility and not cached_config.static.body_parts.visibility
and not cached_config.highlighted.body_parts.visibility then and not cached_config.highlighted.body_parts.visibility then

View File

@@ -3,157 +3,148 @@ local small_monster;
local large_monster; local large_monster;
local config; local config;
local ailments; local ailments;
local quest_status;
local character_base_type_def = sdk.find_type_definition("snow.CharacterBase");
local character_base_start_method = character_base_type_def:get_method("start");
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 enemy_character_base_update_method = enemy_character_base_type_def:get_method("update"); local enemy_character_base_update_method = enemy_character_base_type_def:get_method("update");
local is_boss_enemy_method = enemy_character_base_type_def:get_method("get_isBossEnemy"); local is_boss_enemy_method = enemy_character_base_type_def:get_method("get_isBossEnemy");
local enemy_damage_check_type_def = sdk.find_type_definition("snow.enemy.EnemyDamageCheck"); local tick_count = 0;
local damage_check_update_param_update_method = enemy_damage_check_type_def:get_method("updateParam"); local last_update_tick = 0;
local recorded_monsters = {};
local updated_monsters = {};
local known_big_monsters = {};
local num_known_monsters = 0;
local num_updated_monsters = 0;
local anger_param_type_def = sdk.find_type_definition("snow.enemy.EnemyAngerParam"); local updates_this_tick = 0;
local anger_add_method = anger_param_type_def:get_method("add");
local anger_update_method = anger_param_type_def:get_method("updateNormal");
local stamina_param_type_def = sdk.find_type_definition("snow.enemy.EnemyStaminaParam"); -- run every tick to keep track of msonsters
local stamina_sub_method = stamina_param_type_def:get_method("sub"); -- whenever we've updated enough monsters to surpass how many we've seen,
local stamina_update_method = stamina_param_type_def:get_method("updateParam"); -- we reset and start over
-- this allows us to only update N monsters per tick to save on performance
-- the reason for this is that the hooks on all the monsters' update functions
-- causes a HUGE performance hit (adds ~3+ ms to UpdateBehavior and frame time)
re.on_pre_application_entry("UpdateBehavior", function()
tick_count = tick_count + 1;
updates_this_tick = 0;
--snow.enemy.EnemyDamageStockParam if num_known_monsters ~= 0 and num_updated_monsters >= num_known_monsters or tick_count >= num_known_monsters * 2 then
function monster_hook.update_health(enemy_damage_stock_param) recorded_monsters = {};
local enemy = enemy_damage_stock_param:call("get_RefEnemy"); updated_monsters = {};
if enemy == nil then known_big_monsters = {};
return; last_update_tick = 0;
end tick_count = 0;
num_known_monsters = 0;
local is_large = is_boss_enemy_method:call(enemy); num_updated_monsters = 0;
updates_this_tick = 0;
if is_large == nil then
return;
end
if is_large then
local monster = large_monster.get_monster(enemy);
local physical_param = large_monster.update_health(enemy, monster);
large_monster.update_parts(enemy, monster, physical_param);
else
local monster = small_monster.get_monster(enemy);
small_monster.update_health(enemy, monster);
end
end
function monster_hook.update_stamina(stamina_param, stamina_sub)
local enemy = stamina_param:call("get_Em");
if enemy == nil then
return;
end
local monster = large_monster.get_monster(enemy);
if stamina_sub > 0 then
large_monster.update_stamina(enemy, monster, stamina_param);
return;
end
-- stamina sub gets called periodically at low rate for large monsters even without damage
large_monster.update(enemy, monster);
large_monster.update_stamina_timer(enemy, monster, stamina_param);
large_monster.update_rage_timer(enemy, monster, nil);
end
function monster_hook.update_stamina_timer(stamina_param, enemy)
local monster = large_monster.get_monster(enemy);
large_monster.update_stamina_timer(enemy, monster, stamina_param);
end
function monster_hook.update_rage(anger_param, anger_add, enemy)
if anger_add == 0 then
return;
end
local monster = large_monster.get_monster(enemy);
large_monster.update_rage(enemy, monster, anger_param);
end
function monster_hook.update_rage_timer(anger_param, enemy)
local monster = large_monster.get_monster(enemy);
large_monster.update_rage_timer(enemy, monster, anger_param);
end end
end)
function monster_hook.update_monster(enemy) function monster_hook.update_monster(enemy)
local is_large = is_boss_enemy_method:call(enemy); if enemy == nil then
return;
end
if not recorded_monsters[enemy] then
num_known_monsters = num_known_monsters + 1;
recorded_monsters[enemy] = true;
end
-- saves on a method call.
if not known_big_monsters[enemy] then
known_big_monsters[enemy] = is_boss_enemy_method:call(enemy);
end
local is_large = known_big_monsters[enemy];
if is_large == nil then if is_large == nil then
return; return;
end end
if is_large then if is_large then
local cached_config = config.current_config.large_monster_UI; monster_hook.update_large_monster(enemy);
local monster = large_monster.get_monster(enemy); else
monster_hook.update_small_monster(enemy);
end
end
if not cached_config.dynamic.enabled then function monster_hook.update_large_monster(enemy)
local cached_config = config.current_config.large_monster_UI;
if not cached_config.dynamic.enabled and
not cached_config.static.enabled and
not cached_config.highlighted.enabled then
return; return;
end end
large_monster.update_position(enemy, monster); -- this is the VERY LEAST thing we should do all the time
else -- so the position doesn't lag all over the place
-- due to how infrequently we update the monster(s).
large_monster.update_position(enemy);
if not config.current_config.global_settings.performance.prioritize_large_monsters and updated_monsters[enemy] then
return;
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 not config.current_config.global_settings.performance.prioritize_large_monsters then
updates_this_tick = updates_this_tick + 1;
last_update_tick = tick_count;
num_updated_monsters = num_updated_monsters + 1;
updated_monsters[enemy] = true;
end
large_monster.update(enemy);
end
function monster_hook.update_small_monster(enemy)
if not config.current_config.small_monster_UI.enabled then if not config.current_config.small_monster_UI.enabled then
return; return;
end end
local monster = small_monster.get_monster(enemy); -- this is the VERY LEAST thing we should do all the time
small_monster.update_position(enemy, monster); -- so the position doesn't lag all over the place
-- due to how infrequently we update the monster(s).
small_monster.update_position(enemy);
if updated_monsters[enemy] then
return;
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.
updates_this_tick = updates_this_tick + 1;
last_update_tick = tick_count;
num_updated_monsters = num_updated_monsters + 1;
updated_monsters[enemy] = true;
small_monster.update(enemy);
end end
function monster_hook.init_module() function monster_hook.init_module()
small_monster = require("MHR_Overlay.Monsters.small_monster"); small_monster = require("MHR_Overlay.Monsters.small_monster");
large_monster = require("MHR_Overlay.Monsters.large_monster"); large_monster = require("MHR_Overlay.Monsters.large_monster");
config = require("MHR_Overlay.Misc.config"); config = require("MHR_Overlay.Misc.config");
quest_status = require("MHR_Overlay.Game_Handler.quest_status"); ailments = require("MHR_Overlay.Monsters.ailments");
sdk.hook(enemy_character_base_update_method, function(args) sdk.hook(enemy_character_base_update_method, function(args)
pcall(monster_hook.update_monster, sdk.to_managed_object(args[2])); pcall(monster_hook.update_monster, sdk.to_managed_object(args[2]));
end, function(retval) end, function(retval)
return retval; return retval;
end); end);
sdk.hook(damage_check_update_param_update_method, function(args)
pcall(monster_hook.update_health, sdk.to_managed_object(args[2]));
end, function(retval)
return retval;
end);
sdk.hook(stamina_sub_method, function(args)
pcall(monster_hook.update_stamina, sdk.to_managed_object(args[2]), sdk.to_float(args[3]));
end, function(retval)
return retval;
end);
--sdk.hook(stamina_update_method, function(args)
-- pcall(monster_hook.update_stamina_timer, sdk.to_managed_object(args[2]), -1, sdk.to_managed_object(args[3]));
--end, function(retval)
-- return retval;
--end);
sdk.hook(anger_add_method, function(args)
pcall(monster_hook.update_rage, sdk.to_managed_object(args[2]), sdk.to_float(args[3]), sdk.to_managed_object(args[4]));
end, function(retval)
return retval;
end);
--sdk.hook(anger_update_method, function(args)
-- pcall(monster_hook.update_rage_timer, sdk.to_managed_object(args[2]), sdk.to_managed_object(args[3]));
--end, function(retval)
-- return retval;
--end);
end end
return monster_hook; return monster_hook;

View File

@@ -37,10 +37,6 @@ function small_monster.new(enemy)
small_monster.list[enemy] = monster; small_monster.list[enemy] = monster;
end end
small_monster.update_position(enemy, monster);
small_monster.update(enemy, monster);
small_monster.update_health(enemy, monster);
return monster; return monster;
end end
@@ -116,31 +112,41 @@ local get_max_method = vital_param_type:get_method("get_Max");
local get_pos_field = enemy_character_base_type_def:get_method("get_Pos"); local get_pos_field = enemy_character_base_type_def:get_method("get_Pos");
function small_monster.update_position(enemy, monster) function small_monster.update_position(enemy)
local cached_config = config.current_config.small_monster_UI; local cached_config = config.current_config.small_monster_UI;
if not cached_config.enabled or not cached_config.dynamic_positioning.enabled then if not cached_config.enabled or not cached_config.dynamic_positioning.enabled then
return; return;
end end
local position = get_pos_field:call(enemy); local monster = small_monster.get_monster(enemy);
if position ~= nil then if monster == nil then
monster.position = position; return;
end
end end
function small_monster.update(enemy, monster) local position = get_pos_field:call(enemy) or monster.position;
monster.position = position;
end
function small_monster.update(enemy)
if not config.current_config.small_monster_UI.enabled then if not config.current_config.small_monster_UI.enabled then
return; return;
end end
if enemy == nil then
return;
end
local monster = small_monster.get_monster(enemy);
local dead_or_captured = check_die_method:call(enemy); local dead_or_captured = check_die_method:call(enemy);
monster.dead_or_captured = (dead_or_captured == nil and false) or dead_or_captured; monster.dead_or_captured = (dead_or_captured == nil and false) or dead_or_captured;
small_monster.update_health(enemy, monster);
ailments.update_ailments(enemy, monster); ailments.update_ailments(enemy, monster);
end end
function small_monster.update_health(enemy, monster) function small_monster.update_health(enemy, monster)
if not config.current_config.small_monster_UI.enabled or not config.current_config.small_monster_UI.health.visibility then if not config.current_config.small_monster_UI.health.visibility then
return; return;
end end
@@ -188,8 +194,10 @@ function small_monster.draw(monster, position_on_screen, opacity_scale)
}; };
health_UI_entity.draw(monster, monster.health_UI, health_position_on_screen, opacity_scale); health_UI_entity.draw(monster, monster.health_UI, health_position_on_screen, opacity_scale);
ailments.draw_small(monster, ailments_position_on_screen, opacity_scale); ailments.draw_small(monster, ailments_position_on_screen, opacity_scale);
ailment_buildup.draw_small(monster, ailment_buildups_position_on_screen, opacity_scale); ailment_buildup.draw_small(monster, ailment_buildups_position_on_screen, opacity_scale);
end end
function small_monster.init_list() function small_monster.init_list()

View File

@@ -820,6 +820,16 @@ function customization_menu.draw()
end end
if imgui.tree_node(language.current_language.customization_menu.performance) then if imgui.tree_node(language.current_language.customization_menu.performance) then
changed, config.current_config.global_settings.performance.max_monster_updates_per_tick = imgui.slider_int(
language.current_language.customization_menu.max_monster_updates_per_tick,
config.current_config.global_settings.performance.max_monster_updates_per_tick, 1, 150);
config_changed = config_changed or changed;
changed, config.current_config.global_settings.performance.prioritize_large_monsters = imgui.checkbox(
language.current_language.customization_menu.prioritize_large_monsters,
config.current_config.global_settings.performance.prioritize_large_monsters);
config_changed = config_changed or changed;
changed, config.current_config.global_settings.performance.update_rate = imgui.slider_int(language.current_language changed, config.current_config.global_settings.performance.update_rate = imgui.slider_int(language.current_language
.customization_menu.update_rate, .customization_menu.update_rate,
config.current_config.global_settings.performance.update_rate, 1, 400); config.current_config.global_settings.performance.update_rate, 1, 400);

View File

@@ -142,6 +142,7 @@
"loss_health_percentage": "Sever Health Percentage", "loss_health_percentage": "Sever Health Percentage",
"master_rank": "Master Rank", "master_rank": "Master Rank",
"max_distance": "Max Distance", "max_distance": "Max Distance",
"max_monster_updates_per_tick": "Max Monster Updates per Tick",
"me": "Me", "me": "Me",
"menu_font": "Menu Font", "menu_font": "Menu Font",
"menu_font_change_disclaimer": "Changing Language and Menu Font Size several times will cause a crash!", "menu_font_change_disclaimer": "Changing Language and Menu Font Size several times will cause a crash!",
@@ -178,6 +179,7 @@
"poison_damage": "Poison Damage", "poison_damage": "Poison Damage",
"position": "Position", "position": "Position",
"press_any_key": "Press any key...", "press_any_key": "Press any key...",
"prioritize_large_monsters": "Large Monsters on High Priority",
"quest_result_screen": "Quest Result Screen", "quest_result_screen": "Quest Result Screen",
"quest_time": "Quest Time", "quest_time": "Quest Time",
"rage": "Rage", "rage": "Rage",

View File

@@ -233,7 +233,9 @@
"wyvern_riding_damage": "Wyvern Riding Damage", "wyvern_riding_damage": "Wyvern Riding Damage",
"x": "X", "x": "X",
"y": "Y", "y": "Y",
"z": "Z" "z": "Z",
"prioritize_large_monsters": "대형 몬스터를 우선적으로",
"max_monster_updates_per_tick": "틱당 갱신할 최대 몬스터",
}, },
"font_name": "NotoSansKR-Bold.otf", "font_name": "NotoSansKR-Bold.otf",
"parts": { "parts": {

View File

@@ -142,6 +142,7 @@
"loss_health_percentage": "Отсечение части в процентах", "loss_health_percentage": "Отсечение части в процентах",
"master_rank": "Ранг мастера", "master_rank": "Ранг мастера",
"max_distance": "Макс. расстояние", "max_distance": "Макс. расстояние",
"max_monster_updates_per_tick": "Макс. кол-во обновлений за тик",
"me": "Я", "me": "Я",
"menu_font": "Шрифт меню", "menu_font": "Шрифт меню",
"menu_font_change_disclaimer": "Изменение языка и размера шрифта меню несколько раз приведёт к вылету!", "menu_font_change_disclaimer": "Изменение языка и размера шрифта меню несколько раз приведёт к вылету!",
@@ -178,6 +179,7 @@
"poison_damage": "Урон от отравления", "poison_damage": "Урон от отравления",
"position": "Расположение", "position": "Расположение",
"press_any_key": "Нажмите любую клавишу...", "press_any_key": "Нажмите любую клавишу...",
"prioritize_large_monsters": "Большие монстры в приоритете",
"quest_result_screen": "Экран результатов квеста", "quest_result_screen": "Экран результатов квеста",
"quest_time": "Время квеста", "quest_time": "Время квеста",
"rage": "Ярость", "rage": "Ярость",

View File

@@ -142,6 +142,7 @@
"loss_health_percentage": "Sever Health Percentage", "loss_health_percentage": "Sever Health Percentage",
"master_rank": "Master Rank", "master_rank": "Master Rank",
"max_distance": "最大距离", "max_distance": "最大距离",
"max_monster_updates_per_tick": "每次更新的最大怪物数量",
"me": "我", "me": "我",
"menu_font": "菜单字体", "menu_font": "菜单字体",
"menu_font_change_disclaimer": "Changing Language and Menu Font Size several times will cause a crash!", "menu_font_change_disclaimer": "Changing Language and Menu Font Size several times will cause a crash!",
@@ -178,6 +179,7 @@
"poison_damage": "中毒伤害", "poison_damage": "中毒伤害",
"position": "位置", "position": "位置",
"press_any_key": "按任意键...", "press_any_key": "按任意键...",
"prioritize_large_monsters": "大型怪物优先",
"quest_result_screen": "任务结果页", "quest_result_screen": "任务结果页",
"quest_time": "任务时间", "quest_time": "任务时间",
"rage": "愤怒", "rage": "愤怒",

View File

@@ -233,7 +233,9 @@
"wyvern_riding_damage": "Wyvern Riding Damage", "wyvern_riding_damage": "Wyvern Riding Damage",
"x": "X軸", "x": "X軸",
"y": "Y軸", "y": "Y軸",
"z": "Z軸" "z": "Z軸",
"prioritize_large_monsters": "大型魔物優先",
"max_monster_updates_per_tick": "每次更新的最大魔物數量",
}, },
"font_name": "NotoSansTC-Bold.otf", "font_name": "NotoSansTC-Bold.otf",
"parts": { "parts": {