예제 #1
0
            static void Prefix(Character __instance, ref HitData hit)
            {
                if (!modEnabled.Value)
                {
                    return;
                }

                var attacker = hit.GetAttacker() ? Utils.GetPrefabName(hit.GetAttacker().gameObject) : "";
                var defender = Utils.GetPrefabName(__instance.gameObject);

                if (__instance.IsPlayer())
                {
                    hit.ApplyModifier(playerDamageMult.Value);
                }
                else if (__instance.IsTamed())
                {
                    hit.ApplyModifier(tameDamageMult.Value);
                }
                else
                {
                    hit.ApplyModifier(wildDamageMult.Value);
                }

                if (defenderMults.TryGetValue(defender, out float mult1))
                {
                    Dbgl($"Applying mult of {mult1} for defender {defender}");
                    hit.ApplyModifier(mult1);
                }
                else if (hit.GetAttacker() && attackerMults.TryGetValue(attacker, out float mult2))
                {
                    Dbgl($"Applying mult of {mult2} for attacker {attacker}");
                    hit.ApplyModifier(mult2);
                }
            }
예제 #2
0
 public static void ApplyDamageReduction(ref HitData hit, float value)
 {
     if (hit == null || hit.GetAttacker() == null)
     {
         return;
     }
     if (hit.GetAttacker().IsPlayer())
     {
         if (!configDamageReductionFromPlayers.Value)
         {
             return;
         }
     }
     else
     {
         if (!configDamageReductionFromMonsters.Value)
         {
             return;
         }
     }
     hit.m_damage.m_blunt     = hit.m_damage.m_blunt * (1 - value / 100);
     hit.m_damage.m_slash     = hit.m_damage.m_slash * (1 - value / 100);
     hit.m_damage.m_pierce    = hit.m_damage.m_pierce * (1 - value / 100);
     hit.m_damage.m_chop      = hit.m_damage.m_chop * (1 - value / 100);
     hit.m_damage.m_pickaxe   = hit.m_damage.m_pickaxe * (1 - value / 100);
     hit.m_damage.m_fire      = hit.m_damage.m_fire * (1 - value / 100);
     hit.m_damage.m_frost     = hit.m_damage.m_frost * (1 - value / 100);
     hit.m_damage.m_lightning = hit.m_damage.m_lightning * (1 - value / 100);
     hit.m_damage.m_poison    = hit.m_damage.m_poison * (1 - value / 100);
     hit.m_damage.m_spirit    = hit.m_damage.m_spirit * (1 - value / 100);
 }
예제 #3
0
        static void RockHitPrefix(ref HitData hit)
        {
            if (hit.GetAttacker() == null || !hit.GetAttacker().IsPlayer() || hit.GetAttacker().m_seman == null)
            {
                return;
            }

            if (hit.GetAttacker().GetSEMan().HaveStatusEffect("Mining Bonus"))
            {
                SE_MiningBonus effect = hit.GetAttacker().GetSEMan().GetStatusEffect("Mining Bonus") as SE_MiningBonus;
                hit.m_damage.Modify(1 + effect.getDamageBonus());
            }
        }
 public static void PlayerTamedWolfDamageReduction(Character targetCharacter, ref HitData hit,
                                                   ref bool showDamageText, ref bool triggerEffects, ref HitData.DamageModifier damageMod)
 {
     try
     {
         if (!AnimalConditionals.IsCharacterAWolf(targetCharacter))
         {
             return;
         }
         var wolf = new Wolf(targetCharacter);
         if (!wolf.IsTamed())
         {
             return;
         }
         var attacker = hit.GetAttacker();
         if (attacker == null || attacker.m_name
             .Contains(PlayerIdentifiers.Player[PlayerIdentifiers.PlayerType.PlayerNormal]))
         {
             hit.m_damage.Modify(1f - KeezyBetterWolves.ConfigTamedWolfPlayerDamageReduction.Value / 100f);
         }
         else
         {
             hit.m_damage.Modify(1f - KeezyBetterWolves.ConfigTamedWolfDamageReduction.Value / 100f);
         }
     }
     catch (Exception exception)
     {
         throw new Exception(ExceptionMessages.TamedWolfDamageReduce);
     }
 }
예제 #5
0
        private static void Prefix(Character __instance, HitData hit)
        {
            var attacker = hit.GetAttacker();

            if (__instance is Player player && player.HasActiveMagicEffect(MagicEffectType.ReflectDamage) && attacker != null && attacker != __instance && !_isApplyingReflectiveDmg)
            {
                var reflectiveDamage = player.GetTotalActiveMagicEffectValue(MagicEffectType.ReflectDamage, 0.01f);
                if (reflectiveDamage > 0)
                {
                    var hitData = new HitData()
                    {
                        m_attacker = __instance.GetZDOID(),
                        m_dir      = hit.m_dir * -1,
                        m_point    = attacker.transform.localPosition,
                        m_damage   = { m_pierce = (hit.GetTotalPhysicalDamage() + hit.GetTotalElementalDamage()) * reflectiveDamage }
                    };
                    try
                    {
                        _isApplyingReflectiveDmg = true;
                        attacker.Damage(hitData);
                    }
                    finally
                    {
                        _isApplyingReflectiveDmg = false;
                    }
                }
            }
        }
예제 #6
0
파일: HitPatch.cs 프로젝트: jsza/Terraheim
        static void OnDamagedPrefix(Character __instance, ref HitData hit)
        {
            if (hit.HaveAttacker() && hit.GetAttacker().IsPlayer() && hit.GetAttacker().GetSEMan().HaveStatusEffect("Wyrdarrow"))
            {
                (hit.GetAttacker().GetSEMan().GetStatusEffect("Wyrdarrow") as SE_AoECounter).IncreaseCounter();
            }
            if (hit.HaveAttacker() && hit.GetAttacker().IsPlayer() && hit.GetAttacker().GetSEMan().HaveStatusEffect("Brassflesh Listener"))
            {
                if (hit.GetAttacker().GetSEMan().HaveStatusEffect("Brassflesh"))
                {
                    (hit.GetAttacker().GetSEMan().GetStatusEffect("Brassflesh") as SE_ArmorOnHit).OnHit();
                }
                else
                {
                    SEMan seman    = hit.GetAttacker().GetSEMan();
                    float maxArmor = (seman.GetStatusEffect("Brassflesh Listener") as SE_ArmorOnHitListener).GetMaxArmor();
                    seman.AddStatusEffect("Brassflesh");
                    (seman.GetStatusEffect("Brassflesh") as SE_ArmorOnHit).SetMaxArmor(maxArmor);
                }
            }

            if (__instance.IsPlayer() && __instance.GetSEMan().HaveStatusEffect("Challenge Move Speed"))
            {
                //Log.LogInfo($"starting damage: {hit.GetTotalDamage()}");
                float damageMod = 2f;
                hit.m_damage.m_blunt     *= damageMod;
                hit.m_damage.m_chop      *= damageMod;
                hit.m_damage.m_damage    *= damageMod;
                hit.m_damage.m_fire      *= damageMod;
                hit.m_damage.m_frost     *= damageMod;
                hit.m_damage.m_lightning *= damageMod;
                hit.m_damage.m_pickaxe   *= damageMod;
                hit.m_damage.m_pierce    *= damageMod;
                hit.m_damage.m_poison    *= damageMod;
                hit.m_damage.m_slash     *= damageMod;
                hit.m_damage.m_spirit    *= damageMod;
                //Log.LogInfo($"ending damage: {hit.GetTotalDamage()}");
            }

            if (__instance.IsPlayer() && __instance.GetSEMan().HaveStatusEffect("Brassflesh"))
            {
                //Log.LogInfo($"starting damage: {hit.GetTotalDamage()}");
                float damageMod = (__instance.GetSEMan().GetStatusEffect("Brassflesh") as SE_ArmorOnHit).GetCurrentDamageReduction();
                hit.m_damage.m_blunt     *= 1 - damageMod;
                hit.m_damage.m_chop      *= 1 - damageMod;
                hit.m_damage.m_damage    *= 1 - damageMod;
                hit.m_damage.m_fire      *= 1 - damageMod;
                hit.m_damage.m_frost     *= 1 - damageMod;
                hit.m_damage.m_lightning *= 1 - damageMod;
                hit.m_damage.m_pickaxe   *= 1 - damageMod;
                hit.m_damage.m_pierce    *= 1 - damageMod;
                hit.m_damage.m_poison    *= 1 - damageMod;
                hit.m_damage.m_slash     *= 1 - damageMod;
                hit.m_damage.m_spirit    *= 1 - damageMod;
                //Log.LogInfo($"ending damage: {hit.GetTotalDamage()}");
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        static void LogHitPrefix(ref HitData hit)
        {
            if (hit.GetAttacker() == null || !hit.GetAttacker().IsPlayer() || hit.GetAttacker().m_seman == null)
            {
                return;
            }

            //Log.LogWarning("Hit Tree!");
            if (hit.GetAttacker().GetSEMan().HaveStatusEffect("Tree Damage Bonus"))
            {
                SE_TreeDamageBonus effect = hit.GetAttacker().GetSEMan().GetStatusEffect("Tree Damage Bonus") as SE_TreeDamageBonus;
                //Log.LogMessage("Has Effect");
                //Log.LogMessage(hit.m_damage.GetTotalDamage());
                hit.m_damage.Modify(1 + effect.getDamageBonus());
                //Log.LogMessage(hit.m_damage.GetTotalDamage());
                //Log.LogWarning("Stamina Use: " + ___m_blockStaminaDrain);
            }
        }
예제 #9
0
        private static bool Prefix(Player __instance, HitData hit)
        {
            var attacker = GetPlayerInfo(hit.GetAttacker());

            var damage = hit.GetTotalDamage();

            Log.LogInfo($"{GetPlayerInfo(__instance)} hit by {attacker} for {damage}dmg");
            return(true);
        }
예제 #10
0
        public static void RPC_Damage_RP(this Character __instance, long sender, HitData hit)
        {
            if (__instance.IsDebugFlying() || !__instance.m_nview.IsOwner() || __instance.GetHealth() <= 0f || __instance.IsDead() || __instance.IsTeleporting() || __instance.InCutscene() || (hit.m_dodgeable && __instance.IsDodgeInvincible()))
            {
                return;
            }
            Character attacker = hit.GetAttacker();

            if ((hit.HaveAttacker() && attacker == null) || (__instance.IsPlayer() && !__instance.IsPVPEnabled() && attacker != null && attacker.IsPlayer()))
            {
                return;
            }
            if (attacker != null && !attacker.IsPlayer())
            {
                float difficultyDamageScale = Game.instance.GetDifficultyDamageScale(__instance.transform.position);
                hit.ApplyModifier(difficultyDamageScale);
            }
            __instance.m_seman.OnDamaged(hit, attacker);
            if (__instance.m_baseAI != null && !__instance.m_baseAI.IsAlerted() && hit.m_backstabBonus > 1f && Time.time - __instance.m_backstabTime > 300f)
            {
                __instance.m_backstabTime = Time.time;
                hit.ApplyModifier(hit.m_backstabBonus);
                __instance.m_backstabHitEffects.Create(hit.m_point, Quaternion.identity, __instance.transform);
            }
            if (__instance.IsStaggering() && !__instance.IsPlayer())
            {
                hit.ApplyModifier(2f);
                __instance.m_critHitEffects.Create(hit.m_point, Quaternion.identity, __instance.transform);
            }
            if (hit.m_blockable && __instance.IsBlocking())
            {
                __instance.BlockAttack(hit, attacker);
            }
            __instance.ApplyPushback(hit);
            if (!string.IsNullOrEmpty(hit.m_statusEffect))
            {
                StatusEffect statusEffect = __instance.m_seman.GetStatusEffect(hit.m_statusEffect);
                if (statusEffect == null)
                {
                    statusEffect = __instance.m_seman.AddStatusEffect(hit.m_statusEffect);
                }
                if (statusEffect != null && attacker != null)
                {
                    statusEffect.SetAttacker(attacker);
                }
            }
            HitData.DamageModifiers damageModifiers = __instance.GetDamageModifiers();
            hit.ApplyResistance(damageModifiers, out var significantModifier);
            if (__instance.IsPlayer())
            {
                float bodyArmor = __instance.GetBodyArmor();
                hit.ApplyArmor(bodyArmor);
                __instance.DamageArmorDurability(hit);
            }
            __instance.ApplyDamage(hit, showDamageText: true, triggerEffects: true, significantModifier);
        }
예제 #11
0
        private static bool ShouldSetStunned(Character character, Tameable tameable, HitData hit)
        {
            bool      tameIsEssential         = (TameableMortalityTypes)Configuration.Current.Tameable.mortality == TameableMortalityTypes.Essential;
            bool      tameShouldBeDead        = character.GetHealth() <= 0f;
            bool      tameOwnerDamageOverride = Configuration.Current.Tameable.ownerDamageOverride;
            Character attacker            = hit.GetAttacker();
            bool      tameAttackerIsOwner = attacker == tameable.GetPlayer(attacker.GetZDOID());

            return(tameIsEssential && tameShouldBeDead && !(tameOwnerDamageOverride && tameAttackerIsOwner));
        }
예제 #12
0
        private static bool ShouldIgnoreDamage(Character tame, Tameable tameable, HitData hit, ZDO zdo)
        {
            bool      tameIsImmortal          = (TameableMortalityTypes)Configuration.Current.Tameable.mortality == TameableMortalityTypes.Immortal;
            bool      tameOwnerDamageOverride = Configuration.Current.Tameable.ownerDamageOverride;
            Character attacker                 = hit.GetAttacker();
            bool      tameAttackerIsOwner      = attacker == tameable.GetPlayer(attacker.GetZDOID());
            bool      tameIsRecoveringFromStun = zdo.GetBool("isRecoveringFromStun");

            return((tameIsImmortal && !(tameOwnerDamageOverride && tameAttackerIsOwner)) || tameIsRecoveringFromStun);
        }
예제 #13
0
 static void Prefix(ref Character __instance, ref HitData hit)
 {
     if (__instance.name.Contains("Greyling") && __instance.IsTamed())
     {
         m_attacker = hit.GetAttacker();
         if (m_attacker != null && m_attacker.IsPlayer())
         {
             hit.m_damage.Modify(0.1f);
         }
     }
 }
예제 #14
0
 private static void Postfix(Character __instance, HitData hit)
 {
     if (!__instance.IsBoss() && hit.GetAttacker() is Player player && player.HasActiveMagicEffect(MagicEffectType.Slow))
     {
         var slowMultiplier = 1 - player.GetTotalActiveMagicEffectValue(MagicEffectType.Slow, 0.01f);
         if (!Mathf.Approximately(slowMultiplier, 1))
         {
             __instance.m_nview.InvokeRPC(ZRoutedRpc.Everybody, Slow.RPCKey, slowMultiplier);
         }
     }
 }
예제 #15
0
        public static void OnDamaged(Character __instance, HitData hit)
        {
            if (hit.GetAttacker()?.IsPlayer() != true)
            {
                return;
            }

            var player = (Player)hit.GetAttacker();

            if (player.HasActiveMagicEffect(MagicEffectType.Paralyze))
            {
                if (hit.GetTotalDamage() <= 0.0)
                {
                    return;
                }

                var seParalyze = __instance.m_seman.GetStatusEffect("Paralyze") as SE_Paralyzed;
                if (seParalyze == null)
                {
                    seParalyze = __instance.m_seman.AddStatusEffect("Paralyze") as SE_Paralyzed;
                    if (seParalyze == null)
                    {
                        EpicLoot.LogError("Could not add paralyze effect");
                        return;
                    }
                }

                // TODO: this does not work

                /*var fx = __instance.transform.Find("fx_Lightning(Clone)/Sparcs");
                 * if (fx != null)
                 * {
                 *  var ps = fx.GetComponent<ParticleSystem>();
                 *  var main = ps.main;
                 *  main.startColor = Color.yellow;
                 * }*/

                var totalParalyzeTime = player.GetTotalActiveMagicEffectValue(MagicEffectType.Paralyze);
                seParalyze.Setup(totalParalyzeTime);
            }
        }
예제 #16
0
 private static void Prefix(Character __instance, HitData hit)
 {
     if (!__instance.IsStaggering() && hit.m_skill != Skills.SkillType.Bows && hit.m_skill != Skills.SkillType.None)
     {
         var staggerValue = 1f;
         if (hit.GetAttacker() is Player player)
         {
             staggerValue += player.GetTotalActiveMagicEffectValue(MagicEffectType.ModifyStaggerDuration, 0.01f);
         }
         __instance.m_nview.GetZDO().Set(ModifyStaggerDuration.ZdoKey, staggerValue);
     }
 }
예제 #17
0
 private static void Prefix(Character __instance, HitData hit)
 {
     if (hit.GetAttacker() is Player player && player.HasActiveMagicEffect(MagicEffectType.Opportunist) && __instance.IsStaggering())
     {
         var chance = player.GetTotalActiveMagicEffectValue(MagicEffectType.Opportunist, 0.01f);
         if (Random.Range(0f, 1f) < chance)
         {
             __instance.m_backstabHitEffects.Create(hit.m_point, Quaternion.identity, __instance.transform);
             hit.ApplyModifier(hit.m_backstabBonus);
         }
     }
 }
예제 #18
0
        private static void Postfix(Character __instance, HitData hit)
        {
            var attacker = hit.GetAttacker();

            if (__instance is Player player && player.HasActiveMagicEffect(MagicEffectType.StaggerOnDamageTaken) && attacker != null && attacker != __instance && !attacker.IsStaggering())
            {
                var staggerChance = player.GetTotalActiveMagicEffectValue(MagicEffectType.StaggerOnDamageTaken, 0.01f);
                if (Random.Range(0f, 1f) < staggerChance)
                {
                    attacker.Stagger(-attacker.transform.forward);
                }
            }
        }
예제 #19
0
        private static void Prefix(Character __instance, HitData hit)
        {
            var attacker = hit.GetAttacker();

            if (attacker is Player player && __instance.IsStaggering())
            {
                if (HandlingProjectileDamage == null)
                {
                    HandlingProjectileDamage = ReadStaggerDamageValue(player);
                }
                hit.ApplyModifier((float)HandlingProjectileDamage);
            }
        }
예제 #20
0
            static bool Prefix(WearNTear __instance, HitData hit)
            {
                if (hit.GetTotalDamage() > 0)
                {
                    SeedTotem seedTotem = __instance.GetComponent <SeedTotem>();
                    if (seedTotem)
                    {
                        seedTotem.OnDamaged(hit.GetAttacker() as Player);
                        return(false);
                    }
                }

                return(true);
            }
예제 #21
0
        public static void ShowDeathAlert(Player player)
        {
            if (Settings.EnableShoutOnDeath.Value)
            {
                string text = Localization.instance.Localize(GetRandomDeathShout());
                Chat.instance.SendText(Talker.Type.Shout, text);
            }

            if (Settings.EnableAlertOnDeath.Value)
            {
                HitData   hit = lastHitData;
                string    lastAttackerName = "themself";
                Character attacker         = hit.GetAttacker();
                if (attacker)
                {
                    lastAttackerName = attacker.GetHoverName();
                }

                Traverse      tDamages         = Traverse.Create(hit.m_damage);
                List <string> damageFieldNames = tDamages.Fields();

                float  max = 0.0f;
                string highestDamageType = "m_damage";
                foreach (string fieldName in damageFieldNames)
                {
                    float value = tDamages.Field <float>(fieldName).Value;
                    if (value > max)
                    {
                        max = value;
                        highestDamageType = fieldName;
                    }
                }

                if (highestDamageType == "m_damage" && player.IsSwiming())
                {
                    highestDamageType = "m_drowning";
                }

                string damageTypeString = Localization.instance.Localize(GetRandomDeathAlert(highestDamageType));

                ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "ShowMessage", new object[]
                {
                    (int)MessageHud.MessageType.Center,
                    Localization.instance.Localize("$deathalert_killed_by_msg_peers", player.GetPlayerName(), lastAttackerName, damageTypeString)
                });
            }
        }
예제 #22
0
        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);
        }
예제 #23
0
            static void Prefix(ref Character __instance, ref ZNetView ___m_nview, ref HitData hit)
            {
                var uniqueId = ___m_nview.GetZDO().GetString(Constants.Z_CharacterId);

                if (string.IsNullOrEmpty(uniqueId))
                {
                    return;
                }

                if (MobManager.IsAliveMob(uniqueId))
                {
                    var attacker = hit.GetAttacker();
                    if (attacker != null && attacker.IsPlayer())
                    {
                        hit.m_damage.Modify(0.1f);
                    }
                }
            }
예제 #24
0
        public static bool Execute(HitData hit)
        {
            if (VACPlugin.AntiParams_IsEnabled.Value)
            {
                if (!VACPlugin.anti_debug_mode.Value &&
                    !VACPlugin.anti_damage_boost.Value)
                {
                    return(true);
                }

                Character senderChar = hit.GetAttacker();

                if (senderChar != null)
                {
                    if (VACPlugin.debugmode.Value)
                    {
                        ZLog.LogError("Send Char" + senderChar);
                    }
                }

                if (senderChar != null && senderChar.IsPlayer())
                {
                    ZNetPeer peer = ZNet.instance.GetPeer(senderChar.GetInstanceID());
                    if (VACPlugin.debugmode.Value)
                    {
                        ZLog.LogError("Player Detected, player:" + senderChar.GetInstanceID());
                        ZLog.LogError("Damage = " + hit.GetTotalDamage());
                    }

                    float damage = hit.GetTotalDamage();
                    if (peer != null &&
                        (!VACPlugin.admins_bypass.Value ||
                         !ZNet.instance.m_adminList.Contains(peer.m_rpc.GetSocket().GetHostName())) && damage > 1000f)
                    {
                        if (VACPlugin.debugmode.Value)
                        {
                            ZLog.LogError("Player Detected with Damage Boost.");
                        }
                        VACPlugin.toKick.Add(peer);
                    }
                }
            }
            return(true);
        }
예제 #25
0
        public static void OnDamaged(Character __instance, HitData hit)
        {
            var attacker = hit.GetAttacker() as Humanoid;

            if (attacker == null)
            {
                return;
            }

            var weapon = attacker.GetCurrentWeapon();

            if (weapon != null && weapon.IsMagic() && weapon.HasMagicEffect(MagicEffectType.Paralyze))
            {
                if (hit.GetTotalDamage() <= 0.0)
                {
                    return;
                }

                var seParalyze = __instance.m_seman.GetStatusEffect("Paralyze") as SE_Paralyzed;
                if (seParalyze == null)
                {
                    seParalyze = __instance.m_seman.AddStatusEffect("Paralyze") as SE_Paralyzed;
                    if (seParalyze == null)
                    {
                        EpicLoot.LogError("Could not add paralyze effect");
                        return;
                    }
                }

                // TODO: this does not work
                var fx = __instance.transform.Find("fx_Lightning(Clone)/Sparcs");
                if (fx != null)
                {
                    var ps   = fx.GetComponent <ParticleSystem>();
                    var main = ps.main;
                    main.startColor = Color.yellow;
                }

                var totalParalyzeTime = weapon.GetMagicItem().GetTotalEffectValue(MagicEffectType.Paralyze);
                seParalyze.Setup(totalParalyzeTime);
            }
        }
예제 #26
0
        private static bool CheckCanDamage(GameObject gameObject, HitData hit)
        {
            Dbgl("Checking can damage");

            if (!CheckNameKeyReq(gameObject.name, mineKeyReqList.Value))
            {
                return(false);
            }


            Character c = hit.GetAttacker();

            if (c is Player)
            {
                Inventory inv = (c as Player).GetInventory();
                return(CheckNameItemReq(gameObject.name, mineItemReqList.Value, inv));
            }

            return(true);
        }
예제 #27
0
            static void Prefix(ref ZNetView ___m_nview, ref HitData hit)
            {
                if (!___m_nview.IsValid() || !___m_nview.IsOwner())
                {
                    return;
                }
                var uniqueId = ___m_nview.GetZDO().GetString(Constants.Z_CharacterId);

                if (string.IsNullOrEmpty(uniqueId))
                {
                    return;
                }

                if (MobManager.IsAliveMob(uniqueId))
                {
                    var attacker = hit.GetAttacker();
                    if (MobManager.IsAliveMob(uniqueId))
                    {
                        MobManager.AliveMobs[uniqueId].Attacker = attacker;
                    }
                }
            }
예제 #28
0
        private static void Prefix(Character __instance, HitData hit)
        {
            if (hit?.GetAttacker() is Player player && __instance != null)
            {
                if (__instance.GetComponent <ZNetView>().GetZDO().GetBool("epic loot executioner flag " + player.GetZDO().m_uid))
                {
                    return;
                }

                if (ExecutionerMultiplier == null)
                {
                    ExecutionerMultiplier = ReadExecutionerValue(player);
                }

                if (ExecutionerMultiplier is float multiplier && __instance.GetHealth() / __instance.GetMaxHealth() < 0.2f)
                {
                    hit.m_damage.Modify(multiplier);
                    __instance.GetComponent <ZNetView>().GetZDO().Set("epic loot executioner flag " + player.GetZDO().m_uid, true);
                }
            }

            ExecutionerMultiplier = null;
        }
예제 #29
0
        static bool Prefix(long sender, HitData hit, Character __instance)
        {
            if (__instance.IsDebugFlying() || !__instance.m_nview.IsOwner() || __instance.GetHealth() <= 0f || __instance.IsDead() || __instance.IsTeleporting() || __instance.InCutscene() || (hit.m_dodgeable && __instance.IsDodgeInvincible()))
            {
                return(false);
            }

            Character attacker = hit.GetAttacker();

            if ((hit.HaveAttacker() && attacker == null) || (__instance.IsPlayer() && !__instance.IsPVPEnabled() && attacker != null && attacker.IsPlayer()))
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(hit.m_statusEffect))
            {
                if (hit.m_statusEffect.StartsWith("Challenged"))
                {
                    if (__instance.IsPlayer() && attacker != null && attacker.IsPlayer() && attacker.IsPVPEnabled())
                    {
                        ((Player)__instance).m_intro = true;
                        var webSocketClient = Mod.WebSocketObject.GetComponent <WebSocketClient>();

                        StatusEffect statusEffect = __instance.m_seman.GetStatusEffect(hit.m_statusEffect);
                        if (statusEffect == null)
                        {
                            statusEffect = __instance.m_seman.AddStatusEffect(hit.m_statusEffect);
                        }
                        if (statusEffect != null)
                        {
                            // start game in here
                            statusEffect.SetAttacker(attacker);
                        }
                        Debug.Log("Challenge open for user id: " + hit.m_attacker.userID);
                        //dynamic message = new JObject();
                        var isAttacker = hit.m_attacker.userID == ZDOMan.instance.GetMyID();

                        var gameId = !isAttacker?Guid.NewGuid().ToString() : hit.m_statusEffect.Split(':').Last();

                        var message = new Message
                        {
                            type    = "connectValheim",
                            isWhite = isAttacker,
                            gameId  = gameId
                        };

                        //message.type = "connectValheim";
                        //message.gameId = ZDOMan.instance.GetMyID().ToString();
                        webSocketClient.Send(JsonMapper.ToJson(message));

                        if (!isAttacker)
                        {
                            //webSocketClient.Send("Challenged by id: " + hit.m_attacker.userID);
                            hit.m_statusEffect = $"Challenged:{gameId}";
                            attacker.Damage(hit);
                        }

                        Application.OpenURL($"{Mod.SiteUrl.Value}/game/{gameId}?isWhite={isAttacker}");
                    }
                    return(false);
                }
            }

            return(true);
        }
예제 #30
0
        public static void DamagePostfix(Character __instance, ref HitData hit)
        {
            SEMan seman = __instance.GetSEMan();

            Character attacker = hit.GetAttacker();

            if (attacker == null || attacker.IsPlayer() || attacker.m_seman == null)
            {
                return;
            }

            if (seman.HaveStatusEffect("Thorns") && !seman.m_character.IsBlocking())
            {
                SE_Thorns effect = seman.GetStatusEffect("Thorns") as SE_Thorns;
                Log.LogMessage($"Damage dealt: {hit.GetTotalDamage()} thorns %${effect.GetReflectPercent()}");
                HitData reflectedDamage = new HitData();
                reflectedDamage.m_damage.Add(hit.m_damage);
                reflectedDamage.m_damage.m_blunt     *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_chop      *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_damage    *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_fire      *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_frost     *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_lightning *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_pickaxe   *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_pierce    *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_poison    *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_slash     *= effect.GetReflectPercent();
                reflectedDamage.m_damage.m_spirit    *= effect.GetReflectPercent();
                reflectedDamage.m_staggerMultiplier   = 0;

                Log.LogMessage($"Reflected Damage ${reflectedDamage.m_damage.GetTotalDamage()}");
                if (attacker.GetHealth() <= reflectedDamage.GetTotalDamage() && attacker.GetHealthPercentage() >= (float)balance["thornsKillThreshold"])
                {
                    var totalDamage = attacker.GetHealth() - 1;
                    reflectedDamage.m_damage.m_blunt     = totalDamage * (reflectedDamage.m_damage.m_blunt / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_chop      = totalDamage * (reflectedDamage.m_damage.m_chop / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_damage    = totalDamage * (reflectedDamage.m_damage.m_damage / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_fire      = totalDamage * (reflectedDamage.m_damage.m_fire / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_frost     = totalDamage * (reflectedDamage.m_damage.m_frost / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_lightning = totalDamage * (reflectedDamage.m_damage.m_lightning / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_pickaxe   = totalDamage * (reflectedDamage.m_damage.m_pickaxe / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_pierce    = totalDamage * (reflectedDamage.m_damage.m_pierce / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_poison    = totalDamage * (reflectedDamage.m_damage.m_poison / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_slash     = totalDamage * (reflectedDamage.m_damage.m_slash / reflectedDamage.GetTotalDamage());
                    reflectedDamage.m_damage.m_spirit    = totalDamage * (reflectedDamage.m_damage.m_spirit / reflectedDamage.GetTotalDamage());
                    //Log.LogMessage($"Would Kill attacker! New damage: {reflectedDamage.m_damage.GetTotalDamage()}, attacker health: {attacker.GetHealth()}");
                }

                attacker.ApplyDamage(reflectedDamage, true, false);

                var vfx = Object.Instantiate(AssetHelper.FXThorns, attacker.GetCenterPoint(), Quaternion.identity);
                ParticleSystem[] children = vfx.GetComponentsInChildren <ParticleSystem>();
                foreach (ParticleSystem particle in children)
                {
                    particle.Play();
                    //Log.LogMessage("Playing particle");
                }
            }

            if (__instance.GetSEMan().HaveStatusEffect("Wolftears"))
            {
                var effect = __instance.GetSEMan().GetStatusEffect("Wolftears") as SE_Wolftears;
                effect.SetIcon();
                if (seman.m_character.GetHealth() <= hit.m_damage.GetTotalDamage() && !seman.HaveStatusEffect("Tear Protection Exhausted"))
                {
                    Log.LogInfo($"Would Kill defender! Damage: {hit.m_damage.GetTotalDamage()}, attacker health: {__instance.GetHealth()}");

                    hit.m_damage.Modify(0);
                    seman.AddStatusEffect("Tear Protection Exhausted");
                    __instance.SetHealth(1f);
                }
            }
            if (__instance.GetSEMan().HaveStatusEffect("Battle Furor"))
            {
                var effect = __instance.GetSEMan().GetStatusEffect("Battle Furor") as SE_FullHPDamageBonus;
                //Log.LogWarning("HP Percentage " + __instance.m_character.GetHealthPercentage() + " Activation Threshold " + effect.GetActivationHP());
                if (__instance.GetHealthPercentage() < effect.GetActivationHP())
                {
                    effect.ClearIcon();
                }
            }
        }