if not rawget(_G, "PARRY_MODIFIED_SPEF") then math.randomseed(tonumber(string.format("%.0f", os.time()))) -- Seed random number generator g_debugMode = false --json = require "json" --urlencode = require "urlencode" --minhkssuccess, minhkslib = pcall(require, "minhkslib") minhkssuccess = false if not g_debugMode then if not minhkssuccess then -- Define minhkslib as a table with one attribute "puts" minhkslib = { puts = function() -- Do nothing end } end end local script_dir = debug.getinfo(1, "S").source:sub(2):gsub("/", "\\"):match("(.*\\)"):sub(1, -2):match("(.*\\)"):sub(1, -2):match("(.*\\)") -- pcall(loadfile) ElaDiDu-SE here pcall(loadfile(script_dir .. "crossbowParryForTheModernManAndHisHKS\\hksModule-ElaDiDu-SE\\NewHksInfo.lua")) -- pcall(loadfile) settings here pcall(loadfile(script_dir .. "crossbowParryForTheModernManAndHisHKS\\hksModule-CrossbowParry\\settings.lua")) -- Define a variable to store the last time the crossbowParry function was called successfully g_lastParryCalledTime = 0 -- Define the getCrossbowParried function function canGetCrossbowParried() -- Get the current time local currentTime = os.clock() -- Check if the function was called within the last 1 seconds if currentTime - g_lastParryCalledTime <= 1 then return false end -- Check if the parry spef is active if env(1116, PARRY_MODIFIED_SPEF) ~= TRUE then return false end -- Check if counters spef active local counterSpefActive = false for i = 1, #SPEFFECT_PARAM_COUNTER_SPEFS do if env(1116, SPEFFECT_PARAM_COUNTER_SPEFS[i]) == TRUE then counterSpefActive = true end end if not counterSpefActive then return false end -- Update the last called time to the current time g_lastParryCalledTime = currentTime -- If not called within the last 0.5 seconds, you can perform other logic here -- For example, return true return true end -- Save the original env() function original_env = env ANIME_ID_PARRY_DAMAGE_ENEMY3 = 8502 -- local damage_type = env(GetReceivedDamageType) function crossbowParryLogic() local damageType = DAMAGE_TYPE_PARRY if IsPlayer() == TRUE then damageType = DAMAGE_TYPE_PARRY else if TRUE == IsExistAnime(ANIME_ID_PARRY_DAMAGE_ENEMY1) then damageType = DAMAGE_TYPE_PARRY_ENEMY1 end if TRUE == IsExistAnime(ANIME_ID_PARRY_DAMAGE_ENEMY2) then damageType = DAMAGE_TYPE_PARRY_ENEMY2 end if TRUE == IsExistAnime(ANIME_ID_PARRY_DAMAGE_ENEMY3) then damageType = DAMAGE_TYPE_PARRY_ENEMY3 end if BORDER_PARRY_RESIST < POINT_PARRY_RESIST then damageType = DAMAGE_TYPE_PARRY end end if canGetCrossbowParried() then -- Define the new env() function with the detour function env(...) local args = {...} -- Check if the function was called with a single argument equal to 3 if #args == 1 and args[1] == GetReceivedDamageType then return damageType else -- Call the original env() function for all other cases return original_env(...) end end else -- Define the new env() function with the detour function env(...) -- Call the original env() function for all other cases return original_env(...) end end end ExecDamage = createDetour(ExecDamage, crossbowParryLogic) if g_debugMode then function debugShit() pcall(loadfile(script_dir .. "crossbowParryForTheModernManAndHisHKS\\hksModule-CrossbowParry\\debugthing.lua")) end Update = createDetour(Update, debugShit) end function changeParamsForBullets() if rawget(_G, "PARAMS_PARRY_CROSSBOW_EDITED") then return end if IsPlayer() == TRUE and not rawget(_G, "PARAMS_PARRY_CROSSBOW_EDITED") then copyRow(SpEffectParam_Offsets, SPEFFECT_PARAM_PROTOTYPE_GENERIC, PARRY_MODIFIED_SPEF) SetParamRowValue(SpEffectParam_Offsets, PARRY_MODIFIED_SPEF, "stateInfo", 0) SetParamRowValue(SpEffectParam_Offsets, PARRY_MODIFIED_SPEF, "thrustDamageCutRate", 1) PARAMS_PARRY_CROSSBOW_EDITED = TRUE if GetParamRowValue(BulletParam_Offsets, PARRYING_PROJECTILES[1], "spEffectId4") == PARRY_MODIFIED_SPEF or GetParamRowValue(BulletParam_Offsets, PARRYING_PROJECTILES[1], "spEffectId3") == PARRY_MODIFIED_SPEF or GetParamRowValue(BulletParam_Offsets, PARRYING_PROJECTILES[1], "spEffectId2") == PARRY_MODIFIED_SPEF or GetParamRowValue(BulletParam_Offsets, PARRYING_PROJECTILES[1], "spEffectId1") == PARRY_MODIFIED_SPEF or GetParamRowValue(BulletParam_Offsets, PARRYING_PROJECTILES[1], "spEffectId0") == PARRY_MODIFIED_SPEF then return end for i = 1, #PARRYING_PROJECTILES do local bullet = PARRYING_PROJECTILES[i] if GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId4") ~= nil then if GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId4") == 0 or GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId4") == -1 then SetParamRowValue(BulletParam_Offsets, bullet, "spEffectId4", PARRY_MODIFIED_SPEF) elseif GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId3") == 0 or GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId3") == -1 then SetParamRowValue(BulletParam_Offsets, bullet, "spEffectId3", PARRY_MODIFIED_SPEF) elseif GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId2") == 0 or GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId2") == -1 then SetParamRowValue(BulletParam_Offsets, bullet, "spEffectId2", PARRY_MODIFIED_SPEF) elseif GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId1") == 0 or GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId1") == -1 then SetParamRowValue(BulletParam_Offsets, bullet, "spEffectId1", PARRY_MODIFIED_SPEF) elseif GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId0") == 0 or GetParamRowValue(BulletParam_Offsets, bullet, "spEffectId0") == -1 then SetParamRowValue(BulletParam_Offsets, bullet, "spEffectId0", PARRY_MODIFIED_SPEF) end end end end end Update = createDetour(Update, changeParamsForBullets) end