mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
Merge pull request #45 from GreenComfyTea/Experimental
This commit is contained in:
@@ -82,7 +82,7 @@ function damage_hook.update_damage(enemy, 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)
|
||||
|
||||
-- 4 is virtual player in singleplayer that 'owns' 2nd otomo
|
||||
-- 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
|
||||
|
||||
@@ -4062,10 +4062,10 @@ end
|
||||
function config.load()
|
||||
local loaded_config = json.load_file(config.config_file_name);
|
||||
if loaded_config ~= nil then
|
||||
log.info('[MHR Overlay] config.json loaded successfully');
|
||||
log.info("[MHR Overlay] config.json loaded successfully");
|
||||
config.current_config = table_helpers.merge(config.default_config, loaded_config);
|
||||
else
|
||||
log.error('[MHR Overlay] Failed to load config.json');
|
||||
log.error("[MHR Overlay] Failed to load config.json");
|
||||
config.current_config = table_helpers.deep_copy(config.default_config);
|
||||
end
|
||||
end
|
||||
@@ -4074,9 +4074,9 @@ function config.save()
|
||||
-- save current config to disk, replacing any existing file
|
||||
local success = json.dump_file(config.config_file_name, config.current_config);
|
||||
if success then
|
||||
log.info('[MHR Overlay] config.json saved successfully');
|
||||
log.info("[MHR Overlay] config.json saved successfully");
|
||||
else
|
||||
log.error('[MHR Overlay] Failed to save config.json');
|
||||
log.error("[MHR Overlay] Failed to save config.json");
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ language.default_language = {
|
||||
wingclaw = "Wingclaw",
|
||||
left_wingclaw = "Wingclaw L",
|
||||
right_wingclaw = "Wingclaw R",
|
||||
wingclaws = "Wingclaws",
|
||||
antenna = "Antenna",
|
||||
|
||||
hind_leg = "Hind Leg",
|
||||
@@ -85,7 +86,7 @@ language.default_language = {
|
||||
left_foreleg = "Foreleg L",
|
||||
right_foreleg = "Foreleg R",
|
||||
chest = "Chest",
|
||||
shell = "Shell"
|
||||
shell = "Shell",
|
||||
},
|
||||
|
||||
ailments = {
|
||||
@@ -418,9 +419,9 @@ end
|
||||
function language.save(file_name, language_table)
|
||||
local success = json.dump_file(file_name, language_table);
|
||||
if success then
|
||||
log.info('[MHR Overlay] en-us.json saved successfully');
|
||||
log.info("[MHR Overlay] en-us.json saved successfully");
|
||||
else
|
||||
log.error('[MHR Overlay] Failed to save en-us.json');
|
||||
log.error("[MHR Overlay] Failed to save en-us.json");
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -579,8 +579,8 @@ function part_names.init()
|
||||
{
|
||||
language.current_language.parts.head,
|
||||
language.current_language.parts.torso,
|
||||
language.current_language.parts.left_wing,
|
||||
language.current_language.parts.right_wing,
|
||||
language.current_language.parts.wings,
|
||||
language.current_language.parts.wingclaws,
|
||||
language.current_language.parts.forelegs,
|
||||
language.current_language.parts.hind_legs,
|
||||
language.current_language.parts.tail,
|
||||
@@ -628,8 +628,8 @@ function part_names.init()
|
||||
{
|
||||
language.current_language.parts.head,
|
||||
language.current_language.parts.torso,
|
||||
language.current_language.parts.left_wing,
|
||||
language.current_language.parts.right_wing,
|
||||
language.current_language.parts.wings,
|
||||
language.current_language.parts.wingclaws,
|
||||
language.current_language.parts.forelegs,
|
||||
language.current_language.parts.hind_legs,
|
||||
language.current_language.parts.tail
|
||||
|
||||
@@ -4,7 +4,7 @@ function table_helpers.deep_copy(original, copies)
|
||||
copies = copies or {};
|
||||
local original_type = type(original);
|
||||
local copy;
|
||||
if original_type == 'table' then
|
||||
if original_type == "table" then
|
||||
if copies[original] then
|
||||
copy = copies[original];
|
||||
else
|
||||
@@ -62,15 +62,15 @@ function table_helpers.merge(...)
|
||||
end
|
||||
|
||||
function table_helpers.tostring(table)
|
||||
if type(table) == 'table' then
|
||||
local s = '{ \n';
|
||||
if type(table) == "table" then
|
||||
local s = "{ \n";
|
||||
for k,v in pairs(table) do
|
||||
if type(k) ~= 'number' then
|
||||
if type(k) ~= "number" then
|
||||
k = '"' .. k .. '"';
|
||||
end
|
||||
s = s .. '\t['..k..'] = ' .. table_helpers.tostring(v) .. ',\n';
|
||||
s = s .. "\t["..k.."] = " .. table_helpers.tostring(v) .. ",\n";
|
||||
end
|
||||
return s .. '} \n';
|
||||
return s .. "} \n";
|
||||
else
|
||||
return tostring(table);
|
||||
end
|
||||
|
||||
@@ -3,12 +3,23 @@ local small_monster;
|
||||
local large_monster;
|
||||
local config;
|
||||
local ailments;
|
||||
local player;
|
||||
local quest_status;
|
||||
|
||||
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 = enemy_character_base_type_def:get_method("get_isBossEnemy");
|
||||
|
||||
local enemy_damage_check_type_def = sdk.find_type_definition("snow.enemy.EnemyDamageCheck");
|
||||
local damage_check_update_param_update_method = enemy_damage_check_type_def:get_method("updateParam");
|
||||
|
||||
local anger_param_type_def = sdk.find_type_definition("snow.enemy.EnemyAngerParam");
|
||||
local anger_add_method = anger_param_type_def:get_method("add");
|
||||
|
||||
local stamina_param_type_def = sdk.find_type_definition("snow.enemy.EnemyStaminaParam");
|
||||
local stamina_sub_method = stamina_param_type_def:get_method("sub");
|
||||
|
||||
local tick_count = 0;
|
||||
local last_update_tick = 0;
|
||||
local recorded_monsters = {};
|
||||
@@ -104,12 +115,13 @@ function monster_hook.update_large_monster(enemy)
|
||||
end
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
function monster_hook.update_small_monster(enemy)
|
||||
@@ -142,7 +154,67 @@ function monster_hook.update_small_monster(enemy)
|
||||
updated_monsters[enemy] = true;
|
||||
|
||||
small_monster.update(enemy, monster);
|
||||
small_monster.update_health(enemy, monster);
|
||||
|
||||
if quest_status.is_online and player.myself.id ~= 0 then
|
||||
small_monster.update_health(enemy, monster);
|
||||
end
|
||||
end
|
||||
|
||||
function monster_hook.update_health(enemy_damage_stock_param)
|
||||
local enemy = enemy_damage_stock_param:call("get_RefEnemy");
|
||||
if enemy == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local is_large = is_boss_enemy_method:call(enemy);
|
||||
|
||||
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)
|
||||
if stamina_sub <= 0 then
|
||||
return;
|
||||
end
|
||||
|
||||
local enemy = stamina_param:call("get_Em");
|
||||
if enemy == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local monster = large_monster.get_monster(enemy);
|
||||
large_monster.update_stamina(enemy, monster, stamina_param);
|
||||
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
|
||||
|
||||
function monster_hook.init_module()
|
||||
@@ -150,12 +222,32 @@ function monster_hook.init_module()
|
||||
large_monster = require("MHR_Overlay.Monsters.large_monster");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
ailments = require("MHR_Overlay.Monsters.ailments");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||
|
||||
sdk.hook(enemy_character_base_update_method, function(args)
|
||||
pcall(monster_hook.update_monster, sdk.to_managed_object(args[2]));
|
||||
end, function(retval)
|
||||
return retval;
|
||||
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(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);
|
||||
end
|
||||
|
||||
return monster_hook;
|
||||
@@ -301,6 +301,7 @@
|
||||
"upper_back": "Upper Back",
|
||||
"upper_body": "Upper Body",
|
||||
"wingclaw": "Wingclaw",
|
||||
"wingclaws": "Wingclaws",
|
||||
"wings": "Wings"
|
||||
}
|
||||
}
|
||||
@@ -301,6 +301,7 @@
|
||||
"upper_back": "윗등",
|
||||
"upper_body": "윗몸",
|
||||
"wingclaw": "Wingclaw",
|
||||
"wingclaws": "Wingclaws",
|
||||
"wings": "날개"
|
||||
}
|
||||
}
|
||||
@@ -301,6 +301,7 @@
|
||||
"upper_back": "Верхняя часть спины",
|
||||
"upper_body": "Верхняя часть тела",
|
||||
"wingclaw": "Wingclaw",
|
||||
"wingclaws": "Wingclaws",
|
||||
"wings": "Крылья"
|
||||
}
|
||||
}
|
||||
@@ -301,6 +301,7 @@
|
||||
"upper_back": "上背部",
|
||||
"upper_body": "上半身",
|
||||
"wingclaw": "Wingclaw",
|
||||
"wingclaws": "Wingclaws",
|
||||
"wings": "翼"
|
||||
}
|
||||
}
|
||||
@@ -301,6 +301,7 @@
|
||||
"upper_back": "上方背部",
|
||||
"upper_body": "上半身",
|
||||
"wingclaw": "Wingclaw",
|
||||
"wingclaws": "Wingclaws",
|
||||
"wings": "翅膀"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user