示例#1
0
        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()}");
                }
            }
        }