private static void Prefix(Character ___m_character, ref Animator ___m_animator) { if (!___m_character.IsPlayer() || !___m_character.InAttack()) { return; } // check if our marker bit is present and not within float epsilon var currentSpeedMarker = ___m_animator.speed * 1e7 % 100; if ((currentSpeedMarker > 10 && currentSpeedMarker < 30) || ___m_animator.speed <= 0.001f) { return; } var player = (Player)___m_character; var currentAttack = player.m_currentAttack; if (currentAttack == null) { return; } var animationSpeedup = 0.0f; ModifyWithLowHealth.Apply(player, MagicEffectType.ModifyAttackSpeed, effect => { animationSpeedup += player.GetTotalActiveMagicEffectValue(effect, 0.01f); }); ___m_animator.speed = ___m_animator.speed * (1 + animationSpeedup) + 19e-7f; // number with single bit in mantissa set }
public static bool Prefix(Humanoid __instance, HitData hit, Character attacker) { Override = false; OriginalValue = -1; var currentBlocker = __instance.GetCurrentBlocker(); if (currentBlocker == null || !(__instance is Player player)) { return(true); } var totalParryBonusMod = 0f; ModifyWithLowHealth.Apply(player, MagicEffectType.ModifyParry, effect => { if (player.HasActiveMagicEffect(effect)) { if (!Override) { Override = true; OriginalValue = currentBlocker.m_shared.m_timedBlockBonus; } totalParryBonusMod += player.GetTotalActiveMagicEffectValue(effect, 0.01f); } }); currentBlocker.m_shared.m_timedBlockBonus *= 1.0f + totalParryBonusMod; return(true); }
public static void CheckAndDoLifeSteal(HitData hit) { try { if (!hit.HaveAttacker()) { return; } var attacker = hit.GetAttacker() as Humanoid; if (attacker == null) { return; } // TODO track actual weapon which made a hit for better life-steal calculation var weapon = attacker.GetCurrentWeapon(); // in case weapon's durability is destroyed after hit? // OR in case damage is delayed and player hides weapon - see to-do above if (weapon == null || !weapon.IsMagic() || !(attacker is Player player)) { return; } var lifeStealMultiplier = 0f; ModifyWithLowHealth.Apply(player, MagicEffectType.LifeSteal, effect => lifeStealMultiplier += player.GetTotalActiveMagicEffectValue(effect, 0.01f)); if (lifeStealMultiplier == 0) { return; } var healOn = hit.m_damage.GetTotalDamage() * lifeStealMultiplier; EpicLoot.Log("lifesteal " + healOn); var healFromQueue = false; if (attacker.IsPlayer()) { var healingQueue = attacker.GetComponent <HealingQueueMono>(); if (healingQueue) { healFromQueue = true; healingQueue.HealRequests.Add(healOn); } } if (!healFromQueue) { // mostly for NPC with lifeSteal weapon attacker.Heal(healOn); } } catch (Exception e) { EpicLoot.LogError(e.Message); } }
public static void Postfix(Player __instance) { foreach (var itemData in __instance.GetEquipment()) { DoSpeedCalc(__instance, itemData); } ModifyWithLowHealth.Apply(__instance, MagicEffectType.ModifyMovementSpeed, effect => { __instance.m_equipmentMovementModifier += __instance.GetTotalActiveMagicEffectValue(MagicEffectType.ModifyMovementSpeed, 0.01f); }); }
public static void Postfix(SEMan __instance, ref float staminaMultiplier) { if (__instance.m_character.IsPlayer()) { var player = __instance.m_character as Player; var regenValue = 0f; ModifyWithLowHealth.Apply(player, MagicEffectType.ModifyStaminaRegen, effect => { regenValue += player.GetTotalActiveMagicEffectValue(effect, 0.01f); }); staminaMultiplier += regenValue; } }
private static bool Prefix(Character __instance, HitData hit) { var attacker = hit.GetAttacker(); if (__instance is Player player && attacker != null && attacker != __instance) { var avoidanceChance = 0f; ModifyWithLowHealth.Apply(player, MagicEffectType.AvoidDamageTaken, effect => { avoidanceChance += player.GetTotalActiveMagicEffectValue(effect, 0.01f); }); return(!(Random.Range(0f, 1f) < avoidanceChance)); } return(true); }
public static void Postfix(ItemDrop.ItemData __instance, ref float __result) { var player = PlayerExtensions.GetPlayerWithEquippedItem(__instance); var totalParryMod = 0f; ModifyWithLowHealth.Apply(player, MagicEffectType.ModifyParry, effect => { totalParryMod += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, __instance, effect, 0.01f); }); __result *= 1.0f + totalParryMod; if (player != null && player.m_leftItem == null && player.HasActiveMagicEffect(MagicEffectType.Duelist)) { __result += __instance.GetDamage().GetTotalDamage() / 2 * player.GetTotalActiveMagicEffectValue(MagicEffectType.Duelist, 0.01f); } __result = (float)Math.Round(__result, 1); }
public static void Postfix(ItemDrop.ItemData __instance, ref HitData.DamageTypes __result) { if (!__instance.IsMagic()) { return; } var magicItem = __instance.GetMagicItem(); var magicItemskillType = __instance.m_shared.m_skillType; var player = PlayerExtensions.GetPlayerWithEquippedItem(__instance); // Add damages first __result.m_blunt += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddBluntDamage); __result.m_slash += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddSlashingDamage); __result.m_pierce += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddPiercingDamage); __result.m_fire += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddFireDamage); __result.m_frost += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddFrostDamage); __result.m_lightning += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddLightningDamage); __result.m_poison += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddPoisonDamage); __result.m_spirit += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddSpiritDamage); if (magicItemskillType == Skills.SkillType.Axes) { __result.m_chop += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddSlashingDamage); } else if (magicItemskillType == Skills.SkillType.Pickaxes) { __result.m_pickaxe += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.AddPiercingDamage); } // Then modify if (MagicEffectsHelper.HasActiveMagicEffect(player, magicItem, MagicEffectType.ModifyPhysicalDamage)) { var totalDamageMod = MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.ModifyPhysicalDamage, 0.01f); var modifier = 1.0f + totalDamageMod; __result.m_blunt *= modifier; __result.m_slash *= modifier; __result.m_pierce *= modifier; __result.m_chop *= modifier; __result.m_pickaxe *= modifier; } if (MagicEffectsHelper.HasActiveMagicEffect(player, magicItem, MagicEffectType.ModifyElementalDamage)) { var totalDamageMod = MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, MagicEffectType.ModifyElementalDamage, 0.01f); var modifier = 1.0f + totalDamageMod; __result.m_fire *= modifier; __result.m_frost *= modifier; __result.m_lightning *= modifier; __result.m_poison *= modifier; __result.m_spirit *= modifier; } var damageMod = 0f; ModifyWithLowHealth.Apply(player, MagicEffectType.ModifyDamage, effect => { if (MagicEffectsHelper.HasActiveMagicEffect(player, magicItem, effect)) { damageMod += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, magicItem, effect, 0.01f); } }); __result.Modify(1.0f + damageMod); if (player != null && player.GetSEMan().HaveStatusEffect("BerserkerStatusEffect")) { var percentLife = player.GetHealthPercentage(); var berserkerMod = Mathf.Lerp(2.0f, 0.5f, percentLife); __result.Modify(1.0f + berserkerMod); } }