コード例 #1
0
ファイル: MineRock5.cs プロジェクト: ingvard/valheim-jserver
    // Token: 0x06000E26 RID: 3622 RVA: 0x0006500C File Offset: 0x0006320C
    private bool DamageArea(int hitAreaIndex, HitData hit)
    {
        ZLog.Log("hit mine rock " + hitAreaIndex);
        MineRock5.HitArea hitArea = this.GetHitArea(hitAreaIndex);
        if (hitArea == null)
        {
            ZLog.Log("Missing hit area " + hitAreaIndex);
            return(false);
        }
        this.LoadHealth();
        if (hitArea.m_health <= 0f)
        {
            ZLog.Log("Already destroyed");
            return(false);
        }
        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damageModifiers, out type);
        float totalDamage = hit.GetTotalDamage();

        if (hit.m_toolTier < this.m_minToolTier)
        {
            DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
            return(false);
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return(false);
        }
        hitArea.m_health -= totalDamage;
        this.SaveHealth();
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
        Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f);

        if (closestPlayer)
        {
            closestPlayer.AddNoise(100f);
        }
        if (hitArea.m_health <= 0f)
        {
            this.m_nview.InvokeRPC(ZNetView.Everybody, "SetAreaHealth", new object[]
            {
                hitAreaIndex,
                hitArea.m_health
            });
            this.m_destroyedEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
            foreach (GameObject original in this.m_dropItems.GetDropList())
            {
                Vector3 position = hit.m_point + UnityEngine.Random.insideUnitSphere * 0.3f;
                UnityEngine.Object.Instantiate <GameObject>(original, position, Quaternion.identity);
            }
            if (this.AllDestroyed())
            {
                this.m_nview.Destroy();
            }
            return(true);
        }
        return(false);
    }
コード例 #2
0
    // Token: 0x060003C2 RID: 962 RVA: 0x0001FD00 File Offset: 0x0001DF00
    public override void OnDamaged(HitData hit, Character attacker)
    {
        float totalDamage = hit.GetTotalDamage();

        this.m_damage += totalDamage;
        hit.ApplyModifier(0f);
        this.m_hitEffects.Create(hit.m_point, Quaternion.identity, null, 1f);
    }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
0
    // Token: 0x06000FC4 RID: 4036 RVA: 0x0006EF1C File Offset: 0x0006D11C
    private void RPC_Damage(long sender, HitData hit)
    {
        if (!this.m_nview.IsOwner())
        {
            return;
        }
        float num = this.m_nview.GetZDO().GetFloat("health", this.m_health);

        if (num <= 0f)
        {
            this.m_nview.Destroy();
            return;
        }
        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damageModifiers, out type);
        float totalDamage = hit.GetTotalDamage();

        if (hit.m_toolTier < this.m_minToolTier)
        {
            DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
            return;
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return;
        }
        num -= totalDamage;
        this.m_nview.GetZDO().Set("health", num);
        this.Shake();
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, base.transform, 1f);
        Player closestPlayer = Player.GetClosestPlayer(base.transform.position, 10f);

        if (closestPlayer)
        {
            closestPlayer.AddNoise(100f);
        }
        if (num <= 0f)
        {
            this.m_destroyedEffect.Create(base.transform.position, base.transform.rotation, base.transform, 1f);
            this.SpawnLog(hit.m_dir);
            List <GameObject> dropList = this.m_dropWhenDestroyed.GetDropList();
            for (int i = 0; i < dropList.Count; i++)
            {
                Vector2    vector   = UnityEngine.Random.insideUnitCircle * 0.5f;
                Vector3    position = base.transform.position + Vector3.up * this.m_spawnYOffset + new Vector3(vector.x, this.m_spawnYStep * (float)i, vector.y);
                Quaternion rotation = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f);
                UnityEngine.Object.Instantiate <GameObject>(dropList[i], position, rotation);
            }
            base.gameObject.SetActive(false);
            this.m_nview.Destroy();
        }
    }
コード例 #6
0
    // Token: 0x06000CDD RID: 3293 RVA: 0x0005BF10 File Offset: 0x0005A110
    private void RPC_Damage(long sender, HitData hit)
    {
        if (!this.m_nview.IsValid() || !this.m_nview.IsOwner())
        {
            return;
        }
        if (this.m_destroyed)
        {
            return;
        }
        float num = this.m_nview.GetZDO().GetFloat("health", this.m_health);

        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damages, out type);
        float totalDamage = hit.GetTotalDamage();

        if (this.m_body)
        {
            this.m_body.AddForceAtPosition(hit.m_dir * hit.m_pushForce, hit.m_point, ForceMode.Impulse);
        }
        if (hit.m_toolTier < this.m_minToolTier)
        {
            DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
            return;
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return;
        }
        num -= totalDamage;
        this.m_nview.GetZDO().Set("health", num);
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, base.transform, 1f);
        if (this.m_onDamaged != null)
        {
            this.m_onDamaged();
        }
        if (this.m_hitNoise > 0f)
        {
            Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f);
            if (closestPlayer)
            {
                closestPlayer.AddNoise(this.m_hitNoise);
            }
        }
        if (num <= 0f)
        {
            this.Destroy();
        }
    }
コード例 #7
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);
            }
コード例 #8
0
ファイル: Paralyze.cs プロジェクト: shindomdt/ValheimMods
        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);
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
0
    // Token: 0x0600102D RID: 4141 RVA: 0x000722DC File Offset: 0x000704DC
    private void RPC_Damage(long sender, HitData hit)
    {
        if (!this.m_nview.IsOwner())
        {
            return;
        }
        if (this.m_nview.GetZDO().GetFloat("health", this.m_health) <= 0f)
        {
            return;
        }
        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damages, out type);
        float totalDamage = hit.GetTotalDamage();

        if (this.m_piece && this.m_piece.IsPlacedByPlayer())
        {
            PrivateArea.CheckInPrivateArea(base.transform.position, true);
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return;
        }
        this.ApplyDamage(totalDamage);
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, base.transform, 1f);
        if (this.m_hitNoise > 0f)
        {
            Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f);
            if (closestPlayer)
            {
                closestPlayer.AddNoise(this.m_hitNoise);
            }
        }
        if (this.m_onDamaged != null)
        {
            this.m_onDamaged();
        }
    }
コード例 #11
0
        static void Prefix(SEMan __instance, ref HitData hit, Character attacker)
        {
            if (hit == null)
            {
                return;
            }
            if (attacker == null)
            {
                return;
            }

            var prSteal = attacker.ExtendedCharacter(false)?.runicLifeSteal ?? 0;

            if (prSteal <= 0)
            {
                return;
            }

            var totalf = hit.GetTotalDamage();
            var back   = totalf * prSteal / 100f;

            attacker.Heal(back);
        }
コード例 #12
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();
                }
            }
        }
コード例 #13
0
ファイル: HitPatch.cs プロジェクト: jsza/Terraheim
        public static void DamagePrefix(Character __instance, ref HitData hit)
        {
            if (!hit.HaveAttacker() || !hit.GetAttacker().IsPlayer())
            {
                return;
            }
            Character attacker = hit.GetAttacker();

            if (attacker.GetSEMan().HaveStatusEffect("Damage Vs Low HP"))
            {
                SE_DamageVSLowHP effect = hit.GetAttacker().GetSEMan().GetStatusEffect("Damage Vs Low HP") as SE_DamageVSLowHP;
                if (__instance.GetHealthPercentage() <= effect.GetHealthThreshold())
                {
                    //Log.LogWarning("Haha get f****d");
                    hit.m_damage.m_blunt     += hit.m_damage.m_blunt * effect.GetDamageBonus();
                    hit.m_damage.m_chop      += hit.m_damage.m_chop * effect.GetDamageBonus();
                    hit.m_damage.m_damage    += hit.m_damage.m_damage * effect.GetDamageBonus();
                    hit.m_damage.m_fire      += hit.m_damage.m_fire * effect.GetDamageBonus();
                    hit.m_damage.m_frost     += hit.m_damage.m_frost * effect.GetDamageBonus();
                    hit.m_damage.m_lightning += hit.m_damage.m_lightning * effect.GetDamageBonus();
                    hit.m_damage.m_pickaxe   += hit.m_damage.m_pickaxe * effect.GetDamageBonus();
                    hit.m_damage.m_pierce    += hit.m_damage.m_pierce * effect.GetDamageBonus();
                    hit.m_damage.m_poison    += hit.m_damage.m_poison * effect.GetDamageBonus();
                    hit.m_damage.m_slash     += hit.m_damage.m_slash * effect.GetDamageBonus();
                    hit.m_damage.m_spirit    += hit.m_damage.m_spirit * effect.GetDamageBonus();

                    var executionVFX          = Object.Instantiate(AssetHelper.FXExecution, __instance.GetCenterPoint(), Quaternion.identity);
                    ParticleSystem[] children = executionVFX.GetComponentsInChildren <ParticleSystem>();
                    foreach (ParticleSystem particle in children)
                    {
                        particle.Play();
                    }

                    var audioSource = hit.GetAttacker().GetComponent <AudioSource>();
                    if (audioSource == null)
                    {
                        audioSource             = hit.GetAttacker().gameObject.AddComponent <AudioSource>();
                        audioSource.playOnAwake = false;
                    }
                    audioSource.PlayOneShot(AssetHelper.SFXExecution);
                }
            }

            if (__instance.GetSEMan().HaveStatusEffect("Marked For Death FX"))
            {
                Log.LogMessage("Increasing damage");
                var effect = __instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath;
                hit.m_damage.m_blunt     += hit.m_damage.m_blunt * effect.GetDamageBonus();
                hit.m_damage.m_chop      += hit.m_damage.m_chop * effect.GetDamageBonus();
                hit.m_damage.m_damage    += hit.m_damage.m_damage * effect.GetDamageBonus();
                hit.m_damage.m_fire      += hit.m_damage.m_fire * effect.GetDamageBonus();
                hit.m_damage.m_frost     += hit.m_damage.m_frost * effect.GetDamageBonus();
                hit.m_damage.m_lightning += hit.m_damage.m_lightning * effect.GetDamageBonus();
                hit.m_damage.m_pickaxe   += hit.m_damage.m_pickaxe * effect.GetDamageBonus();
                hit.m_damage.m_pierce    += hit.m_damage.m_pierce * effect.GetDamageBonus();
                hit.m_damage.m_poison    += hit.m_damage.m_poison * effect.GetDamageBonus();
                hit.m_damage.m_slash     += hit.m_damage.m_slash * effect.GetDamageBonus();
                hit.m_damage.m_spirit    += hit.m_damage.m_spirit * effect.GetDamageBonus();

                effect.DecreaseHitsRemaining();

                if ((bool)balance["enableMarkedForDeathFX"])
                {
                    var executionVFX          = Object.Instantiate(AssetHelper.FXMarkedForDeathHit, __instance.GetCenterPoint(), Quaternion.identity);
                    ParticleSystem[] children = executionVFX.GetComponentsInChildren <ParticleSystem>();
                    foreach (ParticleSystem particle in children)
                    {
                        particle.Play();
                    }
                }

                var audioSource = hit.GetAttacker().GetComponent <AudioSource>();
                if (audioSource == null)
                {
                    audioSource             = hit.GetAttacker().gameObject.AddComponent <AudioSource>();
                    audioSource.playOnAwake = false;
                }
                audioSource.PlayOneShot(AssetHelper.SFXExecution);
            }
            if (hit.m_statusEffect == "Marked For Death" && !__instance.GetSEMan().HaveStatusEffect("Marked For Death FX"))
            {
                __instance.GetSEMan().AddStatusEffect("Marked For Death FX");
            }
            if (attacker.GetSEMan().HaveStatusEffect("Death Mark"))
            {
                var effect = hit.GetAttacker().GetSEMan().GetStatusEffect("Death Mark") as SE_DeathMark;

                if (!__instance.GetSEMan().HaveStatusEffect("Marked For Death FX"))
                {
                    //Log.LogInfo(effect.GetLastHitThrowing());
                    if (__instance.GetSEMan().HaveStatusEffect("Marked For Death") && effect.GetLastHitThrowing())
                    {
                        //increase counter
                        (__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).IncreaseCounter();
                        //Log.LogMessage($"Death Mark Counter : {(__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).m_count}");
                    }
                    else if (effect.GetLastHitThrowing())
                    {
                        //Log.LogMessage("Adding Death Mark");
                        //add marked for death counter
                        __instance.GetSEMan().AddStatusEffect("Marked For Death");
                        //(__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).IncreaseCounter();
                        (__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).SetActivationCount(effect.GetThreshold());
                        (__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).SetDamageBonus(effect.GetDamageBonus());
                        (__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).SetHitDuration(effect.GetHitDuration());
                        //Log.LogInfo($"Death Mark Counter : {(__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).m_count}, " +
                        //$"Activation: {(__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).GetActivationCount()} " +
                        //$"Damage Bonus: {(__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).GetDamageBonus()} " +
                        //$"Hit Amount: {(__instance.GetSEMan().GetStatusEffect("Marked For Death") as SE_MarkedForDeath).GetHitDuration()}");
                    }
                }
            }

            if (__instance.GetHealth() <= hit.GetTotalDamage() && attacker.GetSEMan().HaveStatusEffect("Bloodrush Listener"))
            {
                if (attacker.GetSEMan().HaveStatusEffect("Bloodrush"))
                {
                    (attacker.GetSEMan().GetStatusEffect("Bloodrush") as SE_MoveSpeedOnKill).OnKill();
                }
                else
                {
                    attacker.GetSEMan().AddStatusEffect("Bloodrush");
                    (attacker.GetSEMan().GetStatusEffect("Bloodrush") as SE_MoveSpeedOnKill).SetSpeedBonus((attacker.GetSEMan().GetStatusEffect("Bloodrush Listener") as SE_MoveSpeedOnKillListener).GetSpeedBonus());
                }
            }

            if (attacker.GetSEMan().HaveStatusEffect("Pinning") && !__instance.GetSEMan().HaveStatusEffect("Pinned") && !__instance.GetSEMan().HaveStatusEffect("Pinned Cooldown"))
            {
                if (UtilityFunctions.CheckIfVulnerable(__instance, hit) || (attacker as Player).GetCurrentWeapon().m_shared.m_name.Contains("mace_fire"))
                {
                    var effect = attacker.GetSEMan().GetStatusEffect("Pinning") as SE_Pinning;
                    __instance.GetSEMan().AddStatusEffect("Pinned");
                    (__instance.GetSEMan().GetStatusEffect("Pinned") as SE_Pinned).SetPinTTL(effect.GetPinTTL());
                    (__instance.GetSEMan().GetStatusEffect("Pinned") as SE_Pinned).SetPinCooldownTTL(effect.GetPinCooldownTTL());
                }
            }

            if (attacker.GetSEMan().HaveStatusEffect("Poison Vulnerable"))
            {
                if (UtilityFunctions.CheckIfVulnerable(__instance, hit))
                {
                    var effect = attacker.GetSEMan().GetStatusEffect("Poison Vulnerable") as SE_PoisonVulnerable;
                    __instance.AddPoisonDamage(hit.GetTotalDamage() * effect.GetDamageBonus());
                    //hit.m_damage.m_poison += hit.GetTotalDamage() * effect.GetDamageBonus();
                    Log.LogInfo($"Poison damage {hit.GetTotalDamage() * effect.GetDamageBonus()} damage {hit.GetTotalDamage()}");
                }
            }
        }
コード例 #14
0
ファイル: Rune.cs プロジェクト: fiote/RunicPowerValheimMod
        // ================================================================
        // APPLY
        // ================================================================

        public void ApplyEffectOnCharacter(Character target)
        {
            if (target == null)
            {
                return;
            }

            IDestructible destructable = null;
            Player        player       = null;

            try { destructable = target; } catch (Exception) { }
            try { player = (Player)target; } catch (Exception) { }

            // ===== RESTORING HEALTH ========================================

            float healHP = 0;

            foreach (HitData.DamageType dmgType in dmgTypes)
            {
                healHP += GetHealHP(dmgType);
            }

            if (healHP != 0)
            {
                target.Heal(healHP, true);
            }

            // ===== RESTORING STAMINA =======================================

            float healST = 0;

            foreach (HitData.DamageType dmgType in dmgTypes)
            {
                healST += GetHealST(dmgType);
            }

            if (healST != 0)
            {
                player?.UseStamina(healST * -1);
            }

            // ===== DEALING DAMAGE =================================

            var hitDamage = new HitData();

            if (data.effect.DoDamage())
            {
                hitDamage.m_damage.m_blunt     = GetDamage(HitData.DamageType.Blunt);
                hitDamage.m_damage.m_pierce    = GetDamage(HitData.DamageType.Pierce);
                hitDamage.m_damage.m_slash     = GetDamage(HitData.DamageType.Slash);
                hitDamage.m_damage.m_fire      = GetDamage(HitData.DamageType.Fire);
                hitDamage.m_damage.m_frost     = GetDamage(HitData.DamageType.Frost);
                hitDamage.m_damage.m_lightning = GetDamage(HitData.DamageType.Lightning);
                hitDamage.m_damage.m_poison    = GetDamage(HitData.DamageType.Poison);
                hitDamage.m_damage.m_spirit    = GetDamage(HitData.DamageType.Spirit);
                hitDamage.m_statusEffect       = "applyRaw";
                target.Damage(hitDamage);
            }

            // ===== APPLYING ELEMENTAL EFFECTS =====================

            if (data.effect.burn)
            {
                var burning = ObjectDB.instance.m_StatusEffects.Find(x => x.name == "Burning").Clone() as SE_Burning;
                burning.m_ttl            = GetDuration();
                burning.m_damageInterval = 1f;
                // no spirit damage, this is a simple fire burn
                burning.m_damage.m_spirit = 0;
                burning.m_damage.m_fire   = hitDamage.GetTotalDamage() / 10f;
                target.m_seman.AddStatusEffect(burning);
            }

            if (data.effect.slow)
            {
                var frost = ObjectDB.instance.m_StatusEffects.Find(x => x.name == "Frost").Clone() as SE_Frost;
                frost.m_ttl = GetDuration();
                // no damage, just slow
                frost.m_freezeTimeEnemy  = 0;
                frost.m_freezeTimePlayer = 0;
                target.m_seman.AddStatusEffect(frost);
            }

            if (data.effect.poison)
            {
                var poison = ObjectDB.instance.m_StatusEffects.Find(x => x.name == "Poison").Clone() as SE_Poison;
                poison.m_ttl            = GetDuration();
                poison.m_damageInterval = 1f;
                poison.m_damagePerHit   = hitDamage.GetTotalDamage() / 10f;
                poison.m_damageLeft     = poison.m_damageInterval * poison.m_damagePerHit;

                target.m_seman.AddStatusEffect(poison);
            }

            // ===== STAGGER ========================================

            if (data.effect.stagger == true)
            {
                var staggerDir = -caster.m_lookDir;
                target.Stagger(staggerDir);
            }

            // ===== PUSH BACK ======================================

            if (data.effect.pushback == true)
            {
                var hitPushback = new HitData();
                hitPushback.m_pushForce = 500f;
                var from = caster.gameObject.transform.position;
                var to   = target.gameObject.transform.position;
                hitPushback.m_dir = (to - from).normalized;
                // TODO: RPC_Pushback
                target.ApplyPushback(hitPushback);
            }

            // ===== ADDING AS EFFFECT ======================================

            // if there is a duration, it means it'a buff. So let's apply it to targets
            if (data.effect.duration > 0)
            {
                var fxString = GetEffectString();
                target.m_seman.AddStatusEffect(fxString, true);
            }
        }
コード例 #15
0
ファイル: Patches.cs プロジェクト: WiseHorror/Veinmine
        public static bool MineRock5_DamageArea_Prefix(MineRock5 __instance, HitData hit, int hitAreaIndex, ref EffectList ___m_destroyedEffect, ref EffectList ___m_hitEffect, out float __state, ref bool __result)
        {
            bool isVeinmined = false;

            MineRock5.HitArea hitArea = __instance.GetHitArea(hitAreaIndex);
            __state = hitArea.m_health;

            if (VeinMine.enableSpreadDamage.Value)
            {
                hit = SpreadDamage(hit);
            }
            if (Input.GetKey(VeinMine.veinMineKey.Value))
            {
                isVeinmined = true;
            }

            ZLog.Log("hit mine rock " + hitAreaIndex);
            if (hitArea == null)
            {
                ZLog.Log("Missing hit area " + hitAreaIndex);
                __result = false;
                return(false);
            }
            __instance.LoadHealth();
            if (hitArea.m_health <= 0f)
            {
                ZLog.Log("Already destroyed");
                __result = false;
                return(false);
            }
            HitData.DamageModifier type;
            hit.ApplyResistance(__instance.m_damageModifiers, out type);
            float totalDamage = hit.GetTotalDamage();

            if (hit.m_toolTier < __instance.m_minToolTier)
            {
                DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
                __result = false;
                return(false);
            }
            DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
            if (totalDamage <= 0f)
            {
                __result = false;
                return(false);
            }
            hitArea.m_health -= totalDamage;
            __instance.SaveHealth();
            if (!VeinMine.removeEffects.Value)
            {
                __instance.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
            }
            Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f);

            if (closestPlayer)
            {
                closestPlayer.AddNoise(100f);
            }
            if (hitArea.m_health <= 0f)
            {
                __instance.m_nview.InvokeRPC(ZNetView.Everybody, "SetAreaHealth", new object[]
                {
                    hitAreaIndex,
                    hitArea.m_health
                });
                if (!VeinMine.removeEffects.Value)
                {
                    __instance.m_destroyedEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
                }
                foreach (GameObject gameObject in __instance.m_dropItems.GetDropList())
                {
                    if (isVeinmined)
                    {
                        Vector3 position = Player.m_localPlayer.GetTransform().position + new Vector3 {
                            x = 0, y = 2, z = 0
                        } +UnityEngine.Random.insideUnitSphere * 0.3f;
                        UnityEngine.Object.Instantiate <GameObject>(gameObject, position, Quaternion.identity);
                        hit.m_point = Player.m_localPlayer.GetTransform().position + new Vector3 {
                            x = 0, y = 2, z = 0
                        };
                    }
                    else if (!isVeinmined)
                    {
                        Vector3 position = hit.m_point + UnityEngine.Random.insideUnitSphere * 0.3f;
                        UnityEngine.Object.Instantiate <GameObject>(gameObject, position, Quaternion.identity);
                    }
                }
                if (__instance.AllDestroyed())
                {
                    __instance.m_nview.Destroy();
                }
                __result = true;
                return(false);
            }
            __result = false;
            return(false);
        }
コード例 #16
0
 public static string GetTotals(this HitData __instance)
 {
     return(__instance.GetTotalDamage() + " (P: " + __instance.GetTotalPhysicalDamage() + ", E: " + __instance.GetTotalElementalDamage() + ")");
 }
コード例 #17
0
ファイル: MineRock.cs プロジェクト: ingvard/valheim-jserver
    // Token: 0x06000E15 RID: 3605 RVA: 0x000644D0 File Offset: 0x000626D0
    private void RPC_Hit(long sender, HitData hit, int hitAreaIndex)
    {
        if (!this.m_nview.IsOwner())
        {
            return;
        }
        Collider hitArea = this.GetHitArea(hitAreaIndex);

        if (hitArea == null)
        {
            ZLog.Log("Missing hit area " + hitAreaIndex);
            return;
        }
        string name = "Health" + hitAreaIndex.ToString();
        float  num  = this.m_nview.GetZDO().GetFloat(name, this.m_health);

        if (num <= 0f)
        {
            ZLog.Log("Already destroyed");
            return;
        }
        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damageModifiers, out type);
        float totalDamage = hit.GetTotalDamage();

        if (hit.m_toolTier < this.m_minToolTier)
        {
            DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
            return;
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return;
        }
        num -= totalDamage;
        this.m_nview.GetZDO().Set(name, num);
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
        Player closestPlayer = Player.GetClosestPlayer(base.transform.position, 10f);

        if (closestPlayer)
        {
            closestPlayer.AddNoise(100f);
        }
        if (this.m_onHit != null)
        {
            this.m_onHit();
        }
        if (num <= 0f)
        {
            this.m_destroyedEffect.Create(hitArea.bounds.center, Quaternion.identity, null, 1f);
            this.m_nview.InvokeRPC(ZNetView.Everybody, "Hide", new object[]
            {
                hitAreaIndex
            });
            foreach (GameObject original in this.m_dropItems.GetDropList())
            {
                Vector3 position = hit.m_point - hit.m_dir * 0.2f + UnityEngine.Random.insideUnitSphere * 0.3f;
                UnityEngine.Object.Instantiate <GameObject>(original, position, Quaternion.identity);
            }
            if (this.m_removeWhenDestroyed && this.AllDestroyed())
            {
                this.m_nview.Destroy();
            }
        }
    }