mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
Fix first poison activation not counting damage.
This commit is contained in:
@@ -96,6 +96,8 @@ log.info("[MHR Overlay] loaded");
|
||||
-- #endregion
|
||||
------------------------INIT MODULES-------------------------
|
||||
|
||||
|
||||
|
||||
----------------------------LOOP-----------------------------
|
||||
-- #region
|
||||
local function main_loop()
|
||||
@@ -109,7 +111,6 @@ local function main_loop()
|
||||
time.tick();
|
||||
|
||||
player.update_player_list(quest_status.index >= 2);
|
||||
|
||||
if quest_status.index < 2 then
|
||||
quest_status.update_is_training_area();
|
||||
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
local ailments = {};
|
||||
local player;
|
||||
|
||||
--0 Paralyze
|
||||
--1 Sleep
|
||||
--2 Stun
|
||||
--3 Flash
|
||||
--4 Poison
|
||||
--5 Blast
|
||||
--6 Stamina
|
||||
--7 MarionetteStart
|
||||
--8 Water
|
||||
--9 Fire
|
||||
--10 Ice
|
||||
--11 Thunder
|
||||
--12 FallTrap
|
||||
--13 ShockTrap
|
||||
--14 Capture
|
||||
--15 Koyashi
|
||||
--16 SteelFang
|
||||
|
||||
ailments.poison_id = 4;
|
||||
ailments.blast_id = 5;
|
||||
|
||||
function ailments.apply_ailment_buildup(monster, attacker_id, ailment_type, ailment_buildup)
|
||||
if monster == nil or player == nil or (ailment_type ~= ailments.poison_id and ailment_type ~= ailments.blast_id) then
|
||||
return;
|
||||
end
|
||||
|
||||
-- get the buildup accumulator for this type
|
||||
if monster.ailment[ailment_type].buildup == nil then
|
||||
monster.ailment[ailment_type].buildup = {};
|
||||
end
|
||||
|
||||
-- accumulate this buildup for this attacker
|
||||
monster.ailment[ailment_type].buildup[attacker_id] = (monster.ailment[ailment_type].buildup[attacker_id] or 0) + ailment_buildup;
|
||||
end
|
||||
|
||||
-- Code by coavins
|
||||
function ailments.calculate_ailment_contribution(monster, ailment_type)
|
||||
-- get total
|
||||
local total = 0;
|
||||
for attacker_id, player_buildup in pairs(monster.ailment[ailment_type].buildup) do
|
||||
total = total + player_buildup;
|
||||
end
|
||||
|
||||
for attacker_id, player_buildup in pairs(monster.ailment[ailment_type].buildup) do
|
||||
-- update ratio for this attacker
|
||||
monster.ailment[ailment_type].share[attacker_id] = player_buildup / total;
|
||||
-- clear accumulated buildup for this attacker
|
||||
-- they have to start over to earn a share of next ailment trigger
|
||||
monster.ailment[ailment_type].buildup[attacker_id] = 0;
|
||||
end
|
||||
end
|
||||
|
||||
-- Code by coavins
|
||||
function ailments.apply_ailment_damage(monster, ailment_type, ailment_damage)
|
||||
-- we only track poison and blast for now
|
||||
if ailment_type == nil or ailment_damage == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local damage_source_type = "";
|
||||
if ailment_type == ailments.poison_id then
|
||||
damage_source_type = "poison";
|
||||
elseif ailment_type == ailments.blast_id then
|
||||
damage_source_type = "blast";
|
||||
else
|
||||
return;
|
||||
end
|
||||
|
||||
local damage = ailment_damage;
|
||||
|
||||
|
||||
-- split up damage according to ratio of buildup on boss for this type
|
||||
for attacker_id, percentage in pairs(monster.ailment[ailment_type].share) do
|
||||
local damage_portion = damage * percentage;
|
||||
|
||||
local damage_object = {};
|
||||
damage_object.total_damage = damage_portion;
|
||||
damage_object.physical_damage = 0;
|
||||
damage_object.elemental_damage = 0;
|
||||
damage_object.ailment_damage = damage_portion;
|
||||
|
||||
local attacking_player = player.get_player(attacker_id);
|
||||
|
||||
if attacking_player ~= nil then
|
||||
player.update_damage(attacking_player, damage_source_type, true, damage_object);
|
||||
end
|
||||
|
||||
player.update_damage(player.total, damage_source_type, true, damage_object);
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function ailments.init_module()
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
end
|
||||
|
||||
return ailments;
|
||||
@@ -4,9 +4,10 @@ local player;
|
||||
local small_monster;
|
||||
local large_monster;
|
||||
local ailments;
|
||||
local table_helpers;
|
||||
|
||||
local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase");
|
||||
local enemy_character_base_after_calc_damage_damage_side = enemy_character_base_type_def:get_method("afterCalcDamage_DamageSide");
|
||||
local enemy_character_base_after_calc_damage_damage_side_method = enemy_character_base_type_def:get_method("afterCalcDamage_DamageSide");
|
||||
|
||||
local is_boss_enemy_method = enemy_character_base_type_def:get_method("get_isBossEnemy");
|
||||
local check_die_method = enemy_character_base_type_def:get_method("checkDie");
|
||||
@@ -214,14 +215,29 @@ function damage_hook.cart(type, args)
|
||||
end
|
||||
end
|
||||
|
||||
--function damage_hook.on_get_finish_shoot_wall_hit_damage_rate(enemy, rate, is_part_damage)
|
||||
|
||||
--xy = string.format("enemy: %s\nrate: %s\nis_part_damage: %s", tostring(enemy), tostring(rate), tostring(is_part_damage));
|
||||
--end
|
||||
|
||||
|
||||
local get_finish_shoot_wall_hit_damage_rate_method = enemy_character_base_type_def:get_method("stockFinishShootHitDamage");
|
||||
|
||||
function damage_hook.init_module()
|
||||
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
small_monster = require("MHR_Overlay.Monsters.small_monster");
|
||||
large_monster = require("MHR_Overlay.Monsters.large_monster");
|
||||
ailments = require("MHR_Overlay.Monsters.ailments");
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
|
||||
sdk.hook(enemy_character_base_after_calc_damage_damage_side, function(args)
|
||||
--sdk.hook(get_finish_shoot_wall_hit_damage_rate_method, function(args)
|
||||
-- pcall(damage_hook.on_get_finish_shoot_wall_hit_damage_rate, sdk.to_managed_object(args[2]), sdk.to_float(args[3]), sdk.to_int64(args--[4]));
|
||||
--end, function(retval)
|
||||
-- return retval;
|
||||
--end);
|
||||
|
||||
sdk.hook(enemy_character_base_after_calc_damage_damage_side_method, function(args)
|
||||
pcall(damage_hook.update_damage, sdk.to_managed_object(args[2]), sdk.to_managed_object(args[3]));
|
||||
end, function(retval)
|
||||
return retval;
|
||||
|
||||
@@ -182,7 +182,7 @@ function player.update_damage(_player, damage_source_type, is_large_monster, dam
|
||||
if is_large_monster then
|
||||
player_monster_type = _player.large_monsters;
|
||||
end
|
||||
|
||||
|
||||
if damage_source_type == "player" then
|
||||
player.merge_damage(player_monster_type, damage_object);
|
||||
elseif damage_source_type == "bomb" then
|
||||
@@ -380,7 +380,6 @@ local hunter_info_type_def = hunter_info_field:get_type();
|
||||
local get_count_method = hunter_info_type_def:get_method("get_Count");
|
||||
local get_item_method = hunter_info_type_def:get_method("get_Item");
|
||||
|
||||
|
||||
local guid_type = hunter_unique_id_field:get_type();
|
||||
local guid_equals_method = guid_type:get_method("Equals(System.Guid)");
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ function ailment_hook.poison_proc(poison_param)
|
||||
monster = small_monster.get_monster(enemy);
|
||||
end
|
||||
|
||||
monster.ailments[ailments.poison_id].cached_buildup_share = monster.ailments[ailments.poison_id].buildup_share;
|
||||
monster.ailments[ailments.poison_id].cached_buildup_share = table_helpers.deep_copy(monster.ailments[ailments.poison_id].buildup_share);
|
||||
ailments.clear_ailment_contribution(monster, ailments.poison_id);
|
||||
end
|
||||
|
||||
|
||||
@@ -28,16 +28,16 @@ local table_helpers;
|
||||
--16 SteelFang
|
||||
|
||||
ailments.paralyze_id = 0;
|
||||
ailments.sleep_id = 1;
|
||||
ailments.stun_id = 2;
|
||||
ailments.flash_id = 3;
|
||||
ailments.poison_id = 4;
|
||||
ailments.blast_id = 5;
|
||||
ailments.exhaust_id = 6;
|
||||
ailments.ride_id = 7;
|
||||
ailments.water_id = 8;
|
||||
ailments.fire_id = 9;
|
||||
ailments.ice_id = 10;
|
||||
ailments.sleep_id = 1;
|
||||
ailments.stun_id = 2;
|
||||
ailments.flash_id = 3;
|
||||
ailments.poison_id = 4;
|
||||
ailments.blast_id = 5;
|
||||
ailments.exhaust_id = 6;
|
||||
ailments.ride_id = 7;
|
||||
ailments.water_id = 8;
|
||||
ailments.fire_id = 9;
|
||||
ailments.ice_id = 10;
|
||||
ailments.thunder_id = 11;
|
||||
ailments.fall_trap_id = 12;
|
||||
ailments.shock_trap_id = 13;
|
||||
@@ -1141,11 +1141,10 @@ function ailments.apply_ailment_damage(monster, ailment_type, ailment_damage)
|
||||
return;
|
||||
end
|
||||
|
||||
local damage = ailment_damage;
|
||||
-- split up damage according to ratio of buildup on boss for this type
|
||||
for attacker_id, percentage in pairs(buildup_share) do
|
||||
local damage_portion = damage * percentage;
|
||||
|
||||
local damage_portion = ailment_damage * percentage;
|
||||
|
||||
local damage_object = {};
|
||||
damage_object.total_damage = damage_portion;
|
||||
damage_object.physical_damage = 0;
|
||||
@@ -1157,9 +1156,15 @@ function ailments.apply_ailment_damage(monster, ailment_type, ailment_damage)
|
||||
if attacking_player ~= nil then
|
||||
player.update_damage(attacking_player, damage_source_type, true, damage_object);
|
||||
end
|
||||
|
||||
player.update_damage(player.total, damage_source_type, true, damage_object);
|
||||
end
|
||||
|
||||
local damage_object = {};
|
||||
damage_object.total_damage = ailment_damage;
|
||||
damage_object.physical_damage = 0;
|
||||
damage_object.elemental_damage = 0;
|
||||
damage_object.ailment_damage = ailment_damage;
|
||||
|
||||
player.update_damage(player.total, damage_source_type, true, damage_object);
|
||||
end
|
||||
|
||||
function ailments.init_module()
|
||||
|
||||
Reference in New Issue
Block a user