Initial Sunbreak update.

- Added Monster Rank.
- Fixed Poison and Blast Damage.
This commit is contained in:
GreenComfyTea
2022-07-02 14:16:58 +03:00
parent c506a3073b
commit 9a5e05d229
9 changed files with 206 additions and 91 deletions

View File

@@ -8,6 +8,9 @@ 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_poison_damage_param_type_def = sdk.find_type_definition("snow.enemy.EnemyBlastDamageParam");
local on_blast_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");
@@ -17,9 +20,14 @@ local is_boss_enemy_method = enemy_character_base_type_def:get_method("get_isBos
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");
local blast_param_type = blast_param_field:get_type();
local blast_damage_method = blast_param_type:get_method("get_BlastDamage");
local blast_adjust_rate_method = blast_param_type:get_method("get_BlastDamageAdjustRateByEnemyLv");
function ailment_hook.poison_proc(poison_param)
if poison_param == nil then
return;
@@ -46,6 +54,37 @@ function ailment_hook.poison_proc(poison_param)
ailments.clear_ailment_contribution(monster, ailments.poison_id);
end
function ailment_hook.blast_proc(blast_param)
if blast_param == nil then
return;
end
local enemy = get_enemy_method:call(blast_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
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);
ailments.clear_ailment_contribution(monster, ailments.blast_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);
@@ -54,9 +93,8 @@ function ailment_hook.stock_damage()
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);
ailments.update_poison(monster, poison_param);
::continue::
end
@@ -67,9 +105,8 @@ function ailment_hook.stock_damage()
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);
ailments.update_poison(monster, poison_param);
::continue::
end
end
@@ -82,7 +119,7 @@ function ailment_hook.init_module()
table_helpers = require("MHR_Overlay.Misc.table_helpers");
sdk.hook(stock_damage_method, function(args)
pcall(ailment_hook.stock_damage);
pcall(ailment_hook.stock_damage, sdk.to_managed_object(args[2]));
end, function(retval)
return retval;
end);
@@ -92,6 +129,12 @@ function ailment_hook.init_module()
end, function(retval)
return retval;
end);
sdk.hook(on_blast_activate_proc_method, function(args)
pcall(ailment_hook.blast_proc, sdk.to_managed_object(args[2]));
end, function(retval)
return retval;
end);
end
return ailment_hook;

View File

@@ -247,9 +247,6 @@ local get_active_timer_method = enemy_condition_damage_param_base_type_def:get_m
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_damage_method = blast_param_type:get_method("get_BlastDamage");
local blast_adjust_rate_method = blast_param_type:get_method("get_BlastDamageAdjustRateByEnemyLv");
function ailments.update_ailments(enemy, monster)
if enemy == nil then
return;
@@ -416,7 +413,7 @@ function ailments.update_last_change_time(monster, id)
end
-- Code by coavins
function ailments.update_poison_blast(monster, poison_param, blast_param)
function ailments.update_poison(monster, poison_param)
if monster == nil then
return;
end
@@ -430,20 +427,6 @@ function ailments.update_poison_blast(monster, poison_param, blast_param)
ailments.apply_ailment_damage(monster, ailments.poison_id, poison_damage);
end
end
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;
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);
ailments.clear_ailment_contribution(monster, ailments.blast_id);
end
end
end
function ailments.draw_dynamic(monster, ailments_position_on_screen, opacity_scale)
@@ -815,7 +798,7 @@ function ailments.apply_ailment_damage(monster, ailment_type, ailment_damage)
local buildup_share = monster.ailments[ailment_type].buildup_share;
if ailment_type == ailments.poison_id then
damage_source_type = "poison";
buildup_share = monster.ailments[ailment_type]._cached_buildup_share;
buildup_share = monster.ailments[ailment_type].cached_buildup_share;
elseif ailment_type == ailments.blast_id then
damage_source_type = "blast";
else
@@ -823,9 +806,8 @@ function ailments.apply_ailment_damage(monster, ailment_type, ailment_damage)
end
local damage = ailment_damage;
-- split up damage according to ratio of buildup on boss for this type
xy = "." .. tostring(buildup_share);
for attacker_id, percentage in pairs(buildup_share) do
local damage_portion = damage * percentage;
@@ -843,8 +825,6 @@ function ailments.apply_ailment_damage(monster, ailment_type, ailment_damage)
player.update_damage(player.total, damage_source_type, true, damage_object);
end
end
function ailments.init_module()

View File

@@ -87,10 +87,11 @@ function large_monster.new(enemy)
end
function large_monster.get_monster(enemy)
if large_monster.list[enemy] == nil then
return large_monster.new(enemy);
local monster = large_monster.list[enemy];
if monster == nil then
monster = large_monster.new(enemy);
end
return large_monster.list[enemy];
return monster;
end
local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase");

View File

@@ -48,11 +48,12 @@ function small_monster.new(enemy)
end
function small_monster.get_monster(enemy)
if small_monster.list[enemy] == nil then
small_monster.list[enemy] = small_monster.new(enemy);
local monster = small_monster.list[enemy];
if monster == nil then
monster = small_monster.new(enemy);
end
return small_monster.list[enemy];
return monster;
end
local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase");