mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-25 04:48:22 -08:00
Change Player Cart Hook
This commit is contained in:
@@ -34,9 +34,7 @@ local stock_mystery_core_break_damage_type_def = sdk.find_type_definition("snow.
|
|||||||
|
|
||||||
local quest_manager_type_def = sdk.find_type_definition("snow.QuestManager");
|
local quest_manager_type_def = sdk.find_type_definition("snow.QuestManager");
|
||||||
|
|
||||||
local not_host_cart_method = quest_manager_type_def:get_method("netRecvForfeit");
|
local quest_forfeit_method = quest_manager_type_def:get_method("questForfeit");
|
||||||
local host_cart_method = quest_manager_type_def:get_method("netSendForfeit");
|
|
||||||
local offline_cart_method = quest_manager_type_def:get_method("notifyDeath");
|
|
||||||
|
|
||||||
local packet_quest_forfeit_type_def = sdk.find_type_definition("snow.QuestManager.PacketQuestForfeit");
|
local packet_quest_forfeit_type_def = sdk.find_type_definition("snow.QuestManager.PacketQuestForfeit");
|
||||||
local dead_player_id_field = packet_quest_forfeit_type_def:get_field("_DeadPlIndex");
|
local dead_player_id_field = packet_quest_forfeit_type_def:get_field("_DeadPlIndex");
|
||||||
@@ -194,28 +192,13 @@ end
|
|||||||
--end
|
--end
|
||||||
|
|
||||||
-- Coavins code
|
-- Coavins code
|
||||||
function damage_hook.cart(type, args)
|
function damage_hook.cart(dead_player_id, flag_cat_skill_insurance)
|
||||||
if not quest_status.is_online then --We reach here with notifyDeath when player is offline
|
local player_ = player.list[dead_player_id];
|
||||||
player.myself.cart_count = player.myself.cart_count + 1;
|
if player_ == nil then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
if player.myself.id == 0 then -- If player is host, netSendForfeit is always correct
|
player_.cart_count = player_.cart_count + 1;
|
||||||
if type == "host" then
|
|
||||||
local player_id = sdk.to_int64(args[3]);
|
|
||||||
player.list[player_id].cart_count = player.list[player_id].cart_count + 1;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if type == "not host" then
|
|
||||||
local packet_quest_forfeit = sdk.to_managed_object(args[3]);
|
|
||||||
local player_id = dead_player_id_field:get_data(packet_quest_forfeit);
|
|
||||||
local is_from_host = is_from_host_field:get_data(packet_quest_forfeit)
|
|
||||||
|
|
||||||
if is_from_host then -- Data is sent twice, 1 from host and 1 from dead player. Check if from host to only add 1
|
|
||||||
player.list[player_id].cart_count = player.list[player_id].cart_count + 1;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--function damage_hook.on_get_finish_shoot_wall_hit_damage_rate(enemy, rate, is_part_damage)
|
--function damage_hook.on_get_finish_shoot_wall_hit_damage_rate(enemy, rate, is_part_damage)
|
||||||
@@ -246,20 +229,8 @@ function damage_hook.init_module()
|
|||||||
return retval;
|
return retval;
|
||||||
end);
|
end);
|
||||||
|
|
||||||
sdk.hook(not_host_cart_method, function(args)
|
sdk.hook(quest_forfeit_method, function(args)
|
||||||
pcall(damage_hook.cart, "not host", args);
|
pcall(damage_hook.cart, sdk.to_int64(args[3]), (sdk.to_int64(args[4]) & 0xFFFFFFFF));
|
||||||
end, function(retval)
|
|
||||||
return retval;
|
|
||||||
end);
|
|
||||||
|
|
||||||
sdk.hook(host_cart_method, function(args)
|
|
||||||
pcall(damage_hook.cart, "host", args);
|
|
||||||
end, function(retval)
|
|
||||||
return retval;
|
|
||||||
end);
|
|
||||||
|
|
||||||
sdk.hook(offline_cart_method, function(args)
|
|
||||||
pcall(damage_hook.cart, "offline", args);
|
|
||||||
end, function(retval)
|
end, function(retval)
|
||||||
return retval;
|
return retval;
|
||||||
end);
|
end);
|
||||||
|
|||||||
Reference in New Issue
Block a user