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:
@@ -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;
|
||||
Reference in New Issue
Block a user