function FrenzyJewel_MadnessHandler() if env(GetSpEffectID, 392110) == FALSE or env(GetSpEffectID, 392120) == TRUE then return FALSE end act(AddSpEffect, 392120) -- Poise Break Timeout ForcePoiseBreak() return TRUE end local frenzyMonitorSpEffects = { [1] = 392131, -- FireDmg while frenzy is between 01% and 10% [2] = 392132, -- FireDmg while frenzy is between 11% and 20% [3] = 392133, -- FireDmg while frenzy is between 21% and 30% [4] = 392134, -- FireDmg while frenzy is between 31% and 40% [5] = 392135, -- FireDmg while frenzy is between 41% and 50% [6] = 392136, -- FireDmg while frenzy is between 51% and 60% [7] = 392137, -- FireDmg while frenzy is between 61% and 70% [8] = 392138, -- FireDmg while frenzy is between 71% and 80% [9] = 392139, -- FireDmg while frenzy is between 81% and 90% [10] = 392140, --FireDmg while frenzy is between 91% and 99% } function FrenzyJewel_FrenzyMonitor() if env(GetSpEffectID, Jewel_of_the_Mindless) == FALSE or env(GetSpEffectID, 312700) == TRUE -- Clarifying Horn Charm or env(GetSpEffectID, 511051) == TRUE -- Pyrifing Crystal Tear or env(GetSpEffectID, 1738000) == TRUE -- Heart of Chaos or env(GetSpEffectID, 7021101) == TRUE -- Scaled Armor or env(GetSpEffectID, 7001100) == TRUE then -- Verdigris Armor return end local max = GetPointerValue(CHR_INS_BASE.CHR_MODULES.AUX_EFFECT_MODULE.FRENZY_MAX) local buildup = max - GetPointerValue(CHR_INS_BASE.CHR_MODULES.AUX_EFFECT_MODULE.FRENZY) local ratioInTens = math.ceil(buildup / max * 10) for index, spEffectID in ipairs(frenzyMonitorSpEffects) do if index ~= ratioInTens and env(GetSpEffectID, spEffectID) == TRUE then act(ClearSpEffect, spEffectID) elseif index == ratioInTens and env(GetSpEffectID, spEffectID) == FALSE then act(AddSpEffect, spEffectID) end end end function IsFrenzyImmune() return env(GetSpEffectID, 312700) == TRUE -- Clarifying Horn Charm or env(GetSpEffectID, 511051) == TRUE -- Pyrifing Crystal Tear or env(GetSpEffectID, 1738000) == TRUE -- Heart of Chaos or env(GetSpEffectID, 7021101) == TRUE -- Scaled Armor or env(GetSpEffectID, 7001100) == TRUE -- Verdigris Armor end function FrenzyJewel_ImmuneCast() if env(GetSpEffectID, Jewel_of_the_Mindless) == FALSE or not IsFrenzyImmune() or LastCastMagicID == 0 then return end if LastCastMagicID ~= 7380 then -- 7380 = Heart of Chaos, the only spell that doesnt give frenzy buildup act(AddSpEffect, 392105) -- HP/FP Gain end end local frenzyApplyingWeaponArts = { [110] = true, -- Nomad's Kilij [127] = true, -- Vyke's War Spear [288] = true, -- Blade of Distant Light [296] = true, -- Maddening Brand [316] = true, -- Greatsword of Midra [373] = true, -- Fingerprint Hexmark [393] = true -- Three Finger Blade } function FrenzyJewel_ImmuneWeaponArt() if env(GetSpEffectID, Jewel_of_the_Mindless) == FALSE or not IsFrenzyImmune() then return end if frenzyApplyingWeaponArts[c_SwordArtsID] == true then act(AddSpEffect, 392105) -- HP/FP Gain end end local hasTurned = false local isRightHanded = math.random(10) ~= 10 -- 10% chance to be left handed, as per global statistics completedTurn = true function FearEffect(spEffect, immunitySpEffect) local fearActive = env(GetSpEffectID, spEffect) == TRUE -- Main Effects and env(GetSpEffectType, SP_EFFECT_TYPE_MADNESS) == TRUE -- Has Frenzy Effect and env(GetSpEffectID, immunitySpEffect) == FALSE -- Is not immune to fear and env(GetSpEffectID, "20297000") == FALSE -- Is not Spirit Summon and env(GetHP) > 0 -- Is not dead if not fearActive then if hasTurned then Log("Fear Effect Cleared, hasTurned is true") SetPointerValue(CHR_INS_BASE.CHR_FLAGS.NO_ATTACK, FALSE) SetPointerValue(CHR_INS_BASE.CHR_FLAGS.NO_MOVE, FALSE) hasTurned = false end return end if env(GetPoise) <= 0 then act(ClearSpEffect, spEffect) Log("Fear Effect Cleared due to Poise") return end local shouldAct = ((env(GetAITargetAwareState) == 6 and env(GetAITargetAwareStatePreviousFrame) == 6) or hasTurned) and completedTurn if not shouldAct then return end if hasTurned then Fire("W_RunBattle") Log("Already turned, running in place") -- WIP --Fire("W_Idle") --LookAtPlayer(180) return end SetPointerValue(CHR_INS_BASE.CHR_FLAGS.NO_ATTACK, TRUE) SetPointerValue(CHR_INS_BASE.CHR_FLAGS.NO_MOVE, TRUE) completedTurn = false EnemyAnimSlowdownLib() if isRightHanded then Log("Right Handed, turning right") Fire("W_TurnBattle_Right180") else Log("Left Handed, turning left") Fire("W_TurnBattle_Left180") end hasTurned = true end