예제 #1
0
 public void OnGetHit()
 {
     if (stats.spell_chanceToParryOnHit.value && Random.value < 0.15f)
     {
         SpellActions.DoParry(LocalPlayer.Transform.forward + LocalPlayer.Transform.position);
     }
 }
예제 #2
0
 public void OnHit()
 {
     LocalPlayer.Stats.HealthTarget += stats.healthOnHit * stats.allRecoveryMult;
     LocalPlayer.Stats.Health       += stats.healthOnHit * stats.allRecoveryMult;
     LocalPlayer.Stats.Energy       += stats.energyOnHit * stats.TotalEnergyRecoveryMultiplier;
     LocalPlayer.Stats.Stamina      += stats.staminaOnHit * Stats.TotalEnergyRecoveryMultiplier;
     SpellActions.OnFrenzyAttack();
 }
예제 #3
0
        public bool checkHeadDamage(Transform arrow)
        {
            int num = this.returnNearestJointMidPoint(arrow);

            if (this.singleJointMode)
            {
                num = 0;
            }
            if (SpellActions.SeekingArrow_ChangeTargetOnHit)
            {
                SpellActions.SetSeekingArrowTarget(this.stickToJoints[num]);
            }
            return(this.stickToJoints.Length > 0 && this.stickToJoints[num] && this.stickToJoints[num].GetComponent <global::headShotObject>());
        }
예제 #4
0
        private bool COTFHit(Collider other)
        {
            //----------------HIT DAMAGE
            float outputdmg = 0;

            if (animControl.smashBool)
            {
                outputdmg = smashDamage;
            }
            else
            {
                outputdmg = weaponDamage;
            }
            outputdmg += ModdedPlayer.Stats.meleeFlatDmg + SpellActions.GetParryCounterStrikeDmg();

            outputdmg *= ModdedPlayer.Stats.RandomCritDamage * ModdedPlayer.Stats.MeleeDamageMult;

            if (hitReactions.kingHitBool || fsmHeavyAttackBool.Value)
            {
                outputdmg *= ModdedPlayer.Stats.heavyAttackDmg * 3;
            }
            if (animControl.smashBool)
            {
                outputdmg *= ModdedPlayer.Stats.smashDamage;
            }

            if (ModdedPlayer.Stats.perk_danceOfFiregod && Effects.BlackFlame.IsOn)
            {
                outputdmg *= 1 + LocalPlayer.Rigidbody.velocity.magnitude;
            }
            if (outputdmg < 0)
            {
                outputdmg = -outputdmg;
            }
            //----------------HIT DAMAGE

            if (other.CompareTag("enemyCollide") || other.CompareTag("enemyRoot"))
            {
                ModdedPlayer.instance.OnHit();
                ModdedPlayer.instance.OnHit_Melee(other.transform);
                if (GameSetup.IsMpClient)
                {
                    var entity = other.GetComponentInParent <BoltEntity>();
                    if (entity != null)
                    {
                        var phe = PlayerHitEnemy.Create(GlobalTargets.OnlyServer);
                        phe.Target             = entity;
                        phe.getAttackerType    = 4 + DamageMath.CONVERTEDFLOATattackerType;
                        phe.Hit                = DamageMath.GetSendableDamage(outputdmg);
                        phe.HitAxe             = axe;
                        phe.hitFallDown        = fsmHeavyAttackBool.Value && axe;
                        phe.getAttackDirection = animator.GetInteger("hitDirection");
                        phe.takeDamage         = 1;
                        phe.getCombo           = 3;
                        phe.Burn               = (fireStick && Random.value > 0.8f) || AlwaysIgnite || Effects.BlackFlame.IsOn;
                        phe.explosion          = fsmJumpAttackBool.Value && LocalPlayer.FpCharacter.jumpingTimer > 1.2f && !chainSaw;
                        phe.Send();

                        ulong packed = entity.networkId.PackedValue;
                        if (ModdedPlayer.Stats.TotalMeleeArmorPiercing > 0)
                        {
                            EnemyProgression.ReduceArmor(entity, ModdedPlayer.Stats.TotalMeleeArmorPiercing);
                        }
                        if ((hitReactions.kingHitBool || fsmHeavyAttackBool.Value) && ModdedPlayer.Stats.perk_chargedAtkKnockback)
                        {
                            using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(stream))
                                {
                                    Vector3 dir = other.transform.position - LocalPlayer.Transform.position;
                                    dir.y = 0;
                                    w.Write(43);
                                    w.Write(packed);
                                    w.Write(dir.x);
                                    w.Write(dir.y);
                                    w.Write(dir.z);
                                    w.Write(1f);
                                    w.Close();
                                }
                                Network.NetworkManager.SendLine(stream.ToArray(), NetworkManager.Target.OnlyServer);

                                stream.Close();
                            }
                        }
                        if (Effects.BlackFlame.IsOn)
                        {
                            using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(stream))
                                {
                                    w.Write(27);
                                    w.Write(packed);
                                    w.Write(Effects.BlackFlame.FireDamageBonus);
                                    w.Write(20f);
                                    w.Write(1);
                                    w.Close();
                                }
                                Network.NetworkManager.SendLine(stream.ToArray(), NetworkManager.Target.OnlyServer);

                                stream.Close();
                            }
                            if (BlackFlame.GiveAfterburn && Random.value < 0.1f)
                            {
                                int id = 121 + ModReferences.Players.IndexOf(LocalPlayer.GameObject);
                                using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                                {
                                    using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                    {
                                        w.Write(34);
                                        w.Write(packed);
                                        w.Write(id);
                                        w.Write(1.15f);
                                        w.Write(25f);
                                        w.Close();
                                    }
                                    AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), NetworkManager.Target.OnlyServer);
                                    answerStream.Close();
                                }
                            }
                        }
                        if (ModdedPlayer.Stats.perk_fireDmgIncreaseOnHit)
                        {
                            int   myID    = 2000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject);
                            float fireDmg = 1 + ModdedPlayer.Stats.spellFlatDmg / 3;
                            fireDmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier;
                            fireDmg *= ModdedPlayer.Stats.fireDamage + 1;
                            fireDmg *= 0.35f;
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(27);
                                    w.Write(packed);
                                    w.Write(fireDmg);
                                    w.Write(15);
                                    w.Write(myID);
                                    w.Close();
                                }
                                AsyncHit.SendCommandDelayed(2, answerStream.ToArray(), NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                        }
                        if (ModdedPlayer.Stats.i_HammerStun && PlayerInventoryMod.EquippedModel == BaseItem.WeaponModelType.Hammer)
                        {
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(22);
                                    w.Write(packed);
                                    w.Write(ModdedPlayer.Stats.i_HammerStunAmount);
                                    w.Write(ModdedPlayer.Stats.i_HammerStunDuration);
                                    w.Write(40);
                                    w.Close();
                                }
                                AsyncHit.SendCommandDelayed(2, answerStream.ToArray(), NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                        }
                        SpellActions.Bash(packed, outputdmg);

                        AfterHit();
                        return(true);
                    }
                }
                else                        //is singleplayer or host
                {
                    if (EnemyManager.enemyByTransform.ContainsKey(other.transform.root))
                    {
                        var progression = EnemyManager.enemyByTransform[other.transform.root];
                        progression.HitPhysical(outputdmg);

                        progression.HealthScript.getCombo(3);
                        var hitDirection = animator.GetInteger("hitDirection");
                        progression.HealthScript.getAttackDirection(hitDirection);
                        progression.setup.hitReceiver.getAttackDirection(hitDirection);
                        progression.setup.hitReceiver.getCombo(3);
                        if (fsmJumpAttackBool.Value && LocalPlayer.FpCharacter.jumpingTimer > 1.2f && !chainSaw)
                        {
                            progression.HealthScript.Explosion(-1f);
                        }


                        if (ModdedPlayer.Stats.TotalMeleeArmorPiercing > 0)
                        {
                            progression.ReduceArmor(ModdedPlayer.Stats.TotalMeleeArmorPiercing);
                        }

                        if ((hitReactions.kingHitBool || fsmHeavyAttackBool.Value) && ModdedPlayer.Stats.perk_chargedAtkKnockback)
                        {
                            Vector3 dir = other.transform.position - LocalPlayer.Transform.position;
                            progression.AddKnockbackByDistance(dir, 1);
                        }

                        if (Effects.BlackFlame.IsOn)
                        {
                            progression.FireDebuff(40, Effects.BlackFlame.FireDamageBonus, 20);
                            if (BlackFlame.GiveAfterburn && Random.value < 0.1f)
                            {
                                progression.DmgTakenDebuff(120, 1.15f, 25);
                            }
                        }
                        if (ModdedPlayer.Stats.perk_fireDmgIncreaseOnHit)
                        {
                            int   myID    = 2000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject);
                            float fireDmg = 1 + ModdedPlayer.Stats.spellFlatDmg / 3;
                            fireDmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier;
                            fireDmg *= ModdedPlayer.Stats.fireDamage + 1;
                            fireDmg *= 0.35f;
                            progression.FireDebuff(2000, fireDmg, 14);
                        }
                        if (ModdedPlayer.Stats.i_HammerStun && PlayerInventoryMod.EquippedModel == BaseItem.WeaponModelType.Hammer)
                        {
                            progression.Slow(40, ModdedPlayer.Stats.i_HammerStunAmount, ModdedPlayer.Stats.i_HammerStunDuration);
                        }

                        SpellActions.Bash(progression, outputdmg);


                        if ((fireStick && Random.value > 0.8f) || AlwaysIgnite || Effects.BlackFlame.IsOn)
                        {
                            progression.HealthScript.Burn();
                        }


                        AfterHit();
                        return(true);
                    }
                }
            }
            else if (other.gameObject.CompareTag("PlayerNet") && (mainTrigger || (!mainTrigger && (animControl.smashBool || chainSaw))))
            {
                if (ModSettings.FriendlyFire)
                {
                    BoltEntity component3 = other.GetComponent <BoltEntity>();
                    BoltEntity component4 = base.GetComponent <BoltEntity>();
                    if (!object.ReferenceEquals(component3, component4) && lastPlayerHit + 0.2f < Time.time)
                    {
                        other.transform.root.SendMessage("getClientHitDirection", animator.GetInteger("hitDirection"), SendMessageOptions.DontRequireReceiver);
                        other.transform.root.SendMessage("StartPrediction", SendMessageOptions.DontRequireReceiver);
                        lastPlayerHit = Time.time;
                        if (BoltNetwork.isRunning)
                        {
                            ModdedPlayer.instance.OnHit();
                            ModdedPlayer.instance.OnHit_Melee(other.transform);

                            DamageMath.ReduceDamageToSendOverNet(2f * (WeaponDamage + ModdedPlayer.Stats.meleeFlatDmg + SpellActions.GetParryCounterStrikeDmg()) * ModdedPlayer.Stats.MeleeDamageMult * ModdedPlayer.Stats.RandomCritDamage, out int dmg, out int repetitions);

                            HitPlayer hitPlayer = HitPlayer.Create(component3, EntityTargets.Everyone);
                            hitPlayer.damage = dmg;
                            for (int i = 0; i < repetitions; i++)
                            {
                                hitPlayer.Send();
                            }
                        }
                    }

                    AfterHit();
                }
                return(true);
            }
            return(false);
        }
예제 #5
0
        public static void FillSpells()
        {
            Spell bh = new Spell(iD: 1, TextureID: 119, levelrequirement: 20, energyCost: 100, baseCooldown: 120, name: "Black Hole", () => $"Creates a black hole that pulls enemies in and damages over {ModdedPlayer.Stats.spell_blackhole_duration} seconds.\nScaling: {ModdedPlayer.Stats.spell_blackhole_damageScaling} spell damage")
            {
                active        = SpellActions.CreatePlayerBlackHole,
                CastOnRelease = true,
                aim           = SpellActions.BlackHoleAim,
                aimEnd        = SpellActions.BlackHoleAimEnd
            };
            Spell healingDome = new Spell(iD: 2, TextureID: 122, levelrequirement: 6, energyCost: 80, baseCooldown: 70, name: "Healing Dome", () => $"Creates a sphere of vaporized aloe that heals all allies inside.")
            {
                active        = SpellActions.CreateHealingDome,
                CastOnRelease = true,
                aim           = SpellActions.HealingDomeAim,
                aimEnd        = SpellActions.HealingDomeAimEnd
            };

            new Spell(iD: 3, TextureID: 121, levelrequirement: 3, energyCost: 25, baseCooldown: 14, name: "Blink", () => $"instantaneous short distance teleportation. Upgrades allow dealing damage to enemies that you pass through.\nScaling: {ModdedPlayer.Stats.spell_blinkDamageScaling}")
            {
                active        = SpellActions.DoBlink,
                CastOnRelease = true,
                aim           = SpellActions.DoBlinkAim,
            };
            new Spell(iD: 4, TextureID: 120, levelrequirement: 10, energyCost: 100, baseCooldown: 55, name: "Sun Flare", () => $"Intense light focuses onto a single spot. Heals allies, reduces all damage taken by 50% and gives movement speed. Slows down and damages enemies")
            {
                active = SpellActions.CastFlare,
            };
            new Spell(iD: 5, TextureID: 118, levelrequirement: 8, energyCost: 50, name: "Sustain Shield", () => $"Channeling this spell consumes energy but grants you a protective, absorbing shield, similiar to additional health. The shield's power increases every second untill reaching max value. The shield persists for {ModdedPlayer.Stats.spell_shieldPersistanceLifetime} seconds after channeling stops, and after that it rapidly disperses.")
            {
                active             = SpellActions.CastSustainShieldActive,
                passive            = SpellActions.CastSustainShielPassive,
                usePassiveOnUpdate = true,
            };
            new Spell(iD: 6, TextureID: 117, levelrequirement: 2, energyCost: 10, baseCooldown: 0.4f, name: "Wide Reach", () => "Picks up all items, including equipment, in a small radius around you.")
            {
                active        = AutoPickupItems.DoPickup,
                CastOnRelease = false,
            };
            new Spell(iD: 7, TextureID: 115, levelrequirement: 21, energyCost: 25, baseCooldown: 2.5f, name: "Black Flame", () => $"Ignites your melee weapon or your ranged projectile with a dark flame that burns enemies for a large amount of damage. Scaling: {ModdedPlayer.Stats.spell_blackFlameDamageScaling} spell damage")
            {
                active = BlackFlame.Toggle,
            };
            new Spell(iD: 8, TextureID: 123, levelrequirement: 14, energyCost: 85, baseCooldown: 180, name: "War Cry", () => "Empowers you and nearby allies for 2 minutes.")
            {
                active = SpellActions.CastWarCry,
            };
            new Spell(iD: 9, TextureID: 114, levelrequirement: 12, energyCost: 90, baseCooldown: 60, name: "Portal", () => "Creates a wormhole, that links 2 locations. Allows the player and items to pass through.")
            {
                CastOnRelease = true,
                aim           = SpellActions.DoPortalAim,
                active        = SpellActions.CastPortal,
            };
            new Spell(iD: 10, TextureID: 125, levelrequirement: 27, energyCost: 100, baseCooldown: 20, name: "Magic Arrow", () => $"A large spectral arrow is shot where you're looking at. The arrow pierces everything, slows any enemies hit and deals big damage. Scaling: {ModdedPlayer.Stats.spell_magicArrowDamageScaling} spell damage")
            {
                active        = SpellActions.CastMagicArrow,
                CastOnRelease = true,
                aim           = SpellActions.MagicArrowAim,
                aimEnd        = SpellActions.MagicArrowAimEnd
            };
            new Spell(iD: 11, TextureID: 127, levelrequirement: 40, energyCost: 30, baseCooldown: 12, name: "Multishot Enchantment", () => "Enchants your ranged weapons with a magic formation of copying. Every shot causes multipe projectiles to be created with a downside of heavy energy toll. Energy is consumed upon firing and depends on the amount of projectiles fired")
            {
                active = SpellActions.ToggleMultishot,
            };
            new Spell(iD: 12, TextureID: 133, levelrequirement: 35, energyCost: 65, baseCooldown: 160, name: "Golden Skin", () => "For 40 seconds you turn into solid gold, turning completely immune to stuns and your attacks are 20% faster")
            {
                active = GoldenSkin.Cast,
            };
            new Spell(iD: 13, TextureID: 132, levelrequirement: 7, energyCost: 40, baseCooldown: 16, name: "Purge", () => "Everyone in your surroudings gets cleansed of their negative debuffs. Negates poison.")
            {
                active = SpellActions.CastPurge,
            };
            new Spell(iD: 14, TextureID: 128, levelrequirement: 20, energyCost: 220, baseCooldown: 40, name: "Snap Freeze", () => $"Enemies around you get slowed for 12 seconds by 90% you deal magic damage to them.\nScaling{ModdedPlayer.Stats.spell_snapDamageScaling} spell damage")
            {
                active        = SpellActions.CastSnapFreeze,
                CastOnRelease = true,
                aim           = SpellActions.SnapFreezeAim,
                aimEnd        = SpellActions.SnapFreezeAimEnd
            };
            new Spell(iD: 15, TextureID: 131, levelrequirement: 25, energyCost: 10, baseCooldown: 200, name: "Berserk", () => "For short amount of time, gain increased damage dealt, attack speed and movement speed and have unlimited stamina, hovewer, you take increased damage.")
            {
                active = Berserker.Cast,
            };
            new Spell(iD: 16, TextureID: 130, levelrequirement: 44, energyCost: 350, baseCooldown: 100, name: "Ball Lightning", () => $"A slow moving, bouncing ball of lightning travels forward, dealing damage to hit enemies, and upon contact or when it lasts too long, it explodes. Scales with 320% spell damage.\nScaling: {ModdedPlayer.Stats.spell_ballLightning_DamageScaling} spell damage")
            {
                active = SpellActions.CastBallLightning,
            };
            new Spell(iD: 17, TextureID: 134, levelrequirement: 17, energyCost: 25, baseCooldown: 25, name: "Bash",
                      () => $"Passive: Every attack slows enemies for {ModdedPlayer.Stats.spell_bashDuration} seconds, and increases their damage taken by {ModdedPlayer.Stats.spell_bashExtraDamage}\nActive: Melee damage is increased for {ModdedPlayer.Stats.spell_bashDuration} seconds by {(ModdedPlayer.Stats.spell_bashExtraDamage-1):P}")
            {
                passive = SpellActions.BashPassiveEnabled,
                active  = SpellActions.BashActive
            };
            new Spell(18, 136, 1, 0, 60, "Frenzy", () => $"Passive: Every attack enrages you, increasing damage all damage by {ModdedPlayer.Stats.spell_frenzyDmg}. Up to {ModdedPlayer.Stats.spell_frenzyMaxStacks} stacks.\nActive: Consume all of your frenzy stacks and regenerate 5% of your max energy for every stack consumed.")
            {
                passive = x => ModdedPlayer.Stats.spell_frenzy.value = x,
                active  = () =>
                {
                    float f = ModdedPlayer.Stats.spell_frenzyStacks.valueAdditive;
                    LocalPlayer.Stats.Energy += ModdedPlayer.Stats.TotalMaxEnergy * f * 0.05f;
                    ModdedPlayer.Stats.attackSpeed.valueMultiplicative /= 1 + f * ModdedPlayer.Stats.spell_frenzyAtkSpeed;
                    ModdedPlayer.Stats.allDamage.valueMultiplicative   /= 1 + f * ModdedPlayer.Stats.spell_frenzyDmg;
                    if (ModdedPlayer.Stats.spell_frenzyMS)
                    {
                        ModdedPlayer.Stats.movementSpeed.valueMultiplicative /= 1 + f * 0.05f;
                    }

                    ModdedPlayer.Stats.spell_frenzyStacks.valueAdditive = 0;
                }
            };
            new Spell(19, 135, 27, 40, 10, "Seeking Arrow", () => "Casting spell empowers arrow, causing all arrows to head in the same direction for 10 seconds. While active, arrows deal more damage, the further target they hit, headshots deal double damage and bodyshots slow enemies by 20% for 4 seconds.")
            {
                active = SpellActions.SeekingArrow_Active,
            };
            new Spell(20, 137, 4, 50, 30, "Focus", () => "Passive: When landing a headshot, next projectile will deal 100% more damage and slow the enemy by 20%. When landing a body shot, next projectile will deal only 20% more damage, but attack speed is increased.\nActive: Gain 15% critical hit chance for 5 seconds")
            {
                passive = x => ModdedPlayer.Stats.spell_focus.value = x,
                active  = () => BuffDB.AddBuff(28, 102, 1.15f, 5f)
            };
            new Spell(21, 140, 8, 35, 60, "Parry", () => "Passive: When parrying an enemy, deal magic damage to enemies around the target. Additionally, gain energy, heal yourself for a small amount and get stun immunity for 10 seconds after parrying.\nActive: Gain 50% damage reduction for 10 seconds")
            {
                passive = x => ModdedPlayer.Stats.spell_parry.value = x,
                active  = () => BuffDB.AddBuff(26, 103, 0.5f, 10f)
            };
            new Spell(22, 141, 50, 500, 300, "Cataclysm", () => $"Creates a fire tornado that ignites enemies, slows them and deals damage. \nScaling{ModdedPlayer.Stats.spell_cataclysmDamageScaling} spell damage")
            {
                active        = () => SpellActions.CastCataclysm(),
                CastOnRelease = true,
                aim           = SpellActions.CataclysmAim,
                aimEnd        = SpellActions.CataclysmAimEnd
            };
            new Spell(23, 165, 11, 75, 8, "Blood Infused Arrow", () => "Sacrifice your own vitals to empower your next arrow. Drains your health and adds lost health as damage to the next projectile.")
            {
                active = () => SpellActions.CastBloodInfArr(),
            };
            new Spell(24, 182, 55, 400, 360, "Roaring Cheeks", () => "Release a powerful gust of toxic gas that poisons and knocks enemies back, or cast it mid air to perform a secondary jump, the damage and area of effect will be lower but 2/3 of the cooldown will be refunded")
            {
                active = () => SpellActions.RipAFatOne(),
            };
            new Spell(25, 189, 9, 40, 45, "Taunt", () => "Makes enemies hyper agressive and forces them to attack you. Taunted enemies move twice attack twice as fast and take 50% increased damage")
            {
                active        = Taunt.OnSpellUsed,
                CastOnRelease = true,
                aim           = Taunt.Aim,
                aimEnd        = Taunt.AimEnd
            };
            //new Spell(24, 165, 1, 1, 2, "Corpse Explosion", "")
            //{
            //    active = () => SpellActions.CastCorpseExplosion(),
            //};
            //new Spell(25, 165, 1, 1, "Devour", "...")
            //{
            //    active = () =>
            //};
        }
예제 #6
0
        public override bool stickArrowToNearestBone(Transform arrow)
        {
            Transform parent = arrow.parent;

            TheForest.Items.Craft.WeaponStatUpgrade.Types types      = (TheForest.Items.Craft.WeaponStatUpgrade.Types)(-1);
            TheForest.Items.Inventory.ItemProperties      properties = parent.GetComponent <global::arrowTrajectory>()._pickup.GetComponent <TheForest.Items.World.PickUp>()._properties;
            if (properties != null && properties.ActiveBonus != (TheForest.Items.Craft.WeaponStatUpgrade.Types)(-1))
            {
                types = properties.ActiveBonus;
            }
            int  item = 0;
            bool flag = false;
            global::ArrowDamage component = arrow.GetComponent <global::ArrowDamage>();

            if (component.crossbowBoltType)
            {
                flag = true;
            }
            GameObject attached;

            if (flag)
            {
                attached = UnityEngine.Object.Instantiate <GameObject>(this.fakeBoltPickup, parent.transform.position, parent.transform.rotation);
                item     = 3;
            }
            else if (types != TheForest.Items.Craft.WeaponStatUpgrade.Types.BoneAmmo)
            {
                if (types != TheForest.Items.Craft.WeaponStatUpgrade.Types.ModernAmmo)
                {
                    attached = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowPickup, parent.transform.position, parent.transform.rotation);
                    item     = 0;
                }
                else
                {
                    attached = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowModernPickup, parent.transform.position, parent.transform.rotation);
                    item     = 2;
                }
            }
            else
            {
                attached = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowBonePickup, parent.transform.position, parent.transform.rotation);
                item     = 1;
            }

            Collider component2 = attached.GetComponent <Collider>();

            if (component2)
            {
                component2.enabled = false;
            }
            Transform tip = attached.GetComponent <global::fakeArrowSetup>().tip;
            int       num = this.returnNearestJointMidPoint(tip);

            if (this.singleJointMode)
            {
                num = 0;
                Vector3 vector = (attached.transform.position - this.baseJoint.position).normalized;
                vector = this.baseJoint.position + vector * 0.2f;
                attached.transform.parent   = this.baseJoint;
                attached.transform.position = vector;
                attached.transform.rotation = Quaternion.LookRotation(attached.transform.position - this.baseJoint.position) * Quaternion.Euler(-90f, 0f, 0f);
            }
            else
            {
                Transform tr = this.stickToJoints[num];
                foreach (Transform transform2 in this.stickToJoints[num])
                {
                    if (transform2.GetComponent <MonoBehaviour>() == null)
                    {
                        tr = transform2;
                        break;
                    }
                }
                Vector3 vector2 = (this.stickToJoints[num].position + tr.position) / 2f;
                Vector3 vector3 = (attached.transform.position - vector2).normalized;
                vector3 = vector2 + vector3 * 0.35f;
                attached.transform.parent   = this.stickToJoints[num];
                attached.transform.position = vector3;
                attached.transform.rotation = Quaternion.LookRotation(attached.transform.position - vector2) * Quaternion.Euler(-90f, 0f, 0f);
                if (SpellActions.SeekingArrow_ChangeTargetOnHit)
                {
                    SpellActions.SetSeekingArrowTarget(this.stickToJoints[num]);
                }
            }
            bool isHeadshot = false;

            if (this.stickToJoints.Length > 0 && this.stickToJoints[num] && this.stickToJoints[num].GetComponent <global::headShotObject>())
            {
                isHeadshot = true;
            }
            if (numStuckArrows < 20)
            {
                if (!this.stuckArrows.ContainsKey(attached.transform))
                {
                    this.stuckArrows.Add(attached.transform, num);
                    this.stuckArrowsTypeList.Add(item);
                    global::fakeArrowSetup component3 = attached.GetComponent <global::fakeArrowSetup>();
                    if (component3 && BoltNetwork.isRunning)
                    {
                        component3.storedIndex  = this.stuckArrows.Count - 1;
                        component3.entityTarget = base.transform.root.GetComponent <BoltEntity>();
                    }
                    this.numStuckArrows++;
                }
                if (BoltNetwork.isRunning)
                {
                    BoltEntity component4 = parent.GetComponent <BoltEntity>();
                    if (component4.isAttached && component4.isOwner)
                    {
                        if (this.IsCreature && BoltNetwork.isServer)
                        {
                            base.StartCoroutine(this.SendArrowMPDelayed(attached, num, types, flag));
                        }
                        else
                        {
                            this.sendArrowMP(attached, num, types, flag);
                        }
                    }
                }
            }
            else
            {
                Destroy(attached, 1f);
            }
            return(isHeadshot);
        }
예제 #7
0
        public static void FillSpells()
        {
            Spell bh = new Spell(1, 119, 20, 50, 120, "Black Hole", "Creates a black hole that pulls enemies in and damages them every second")
            {
                active = SpellActions.CreatePlayerBlackHole,
            };
            Spell healingDome = new Spell(2, 122, 6, 80, 70, "Healing Dome", "Creates a sphere of vaporized aloe that heals all allies inside. Items can further expand this ability to cleanese debuffs. Scales with healing multipier and spell amplification.")
            {
                active = SpellActions.CreateHealingDome,
            };

            new Spell(3, 121, 3, 25, 12, "Blink", "Short distance teleportation")
            {
                active        = SpellActions.DoBlink,
                CastOnRelease = true,
                aim           = SpellActions.DoBlinkAim,
            };
            new Spell(4, 120, 10, 100, 45, "Sun Flare", "A light column heals players inside and gives them +25% movement speed, while slowing damaging enemies. Slow amount is equal to 25%")
            {
                active = SpellActions.CastFlare,
            };
            new Spell(5, 118, 8, 50, "Sustain Shield", "Channeling this spell consumes energy but grants you a protective, absorbing shield. The shield's power increases every second untill reaching max value. Upon ending the channeling by any source, the shield persist for a short amount of time, and after that it rapidly decreases.")
            {
                active             = SpellActions.CastSustainShieldActive,
                passive            = SpellActions.CastSustainShielPassive,
                usePassiveOnUpdate = true,
            };
            new Spell(6, 117, 2, 10, 0.4f, "Wide Reach", "Picks up all resources in a small radius around you.")
            {
                active = AutoPickupItems.DoPickup,
            };
            new Spell(7, 115, 17, 25, 2f, "Black Flame", "Ignites your weapon with a dark flame that empowers all attacks.")
            {
                active = BlackFlame.Toggle,
            };
            new Spell(8, 123, 12, 80, 110, "War Cry", "Empowers you and nearby allies for 2 minutes.")
            {
                active = SpellActions.CastWarCry,
            };
            new Spell(9, 114, 15, 100, 35, "Portal", "Creates a wormhole, that links 2 locations. Allows the player and items to pass through.")
            {
                active = SpellActions.CastPortal,
            };
            new Spell(10, 125, 30, 90, 20, "Magic Arrow", "A large arrow is shot where you're looking at. Slows any enemies on hit and deals big damage")
            {
                active = SpellActions.CastMagicArrow,
            };
            new Spell(11, 127, 35, 10, 10, "Multishot", "An attack modifier. Enchants your ranged weapons to shoot multipe projectiles. Upgradeable by perks. Energy is consumed upon firing and depends on the amount of projectiles fired")
            {
                active = SpellActions.ToggleMultishot,
            };
            new Spell(12, 133, 40, 50, 150, "Gold", "For 40 seconds you turn completely immune to stuns and attack speed increases by 20%")
            {
                active = Gold.Cast,
            };
            new Spell(13, 132, 7, 40, 15, "Purge", "Everyone in your surroudings gets cleansed of their negative debuffs. Negates poison.")
            {
                active = SpellActions.CastPurge,
            };
            new Spell(14, 128, 20, 280, 40, "Snap Freeze", "Enemies around you get slowed for 12 seconds by 90% you deal magic damage to them")
            {
                active = SpellActions.CastSnapFreeze,
            };
            new Spell(15, 131, 25, 15, 180, "Berserk", "For short amount of time, gain damage, attack speed and movement speed, take additional damage and have unlimited stamina.")
            {
                active = Berserker.Cast,
            };
            new Spell(16, 130, 42, 300, 90, "Ball Lightning", "A slow moving, bouncing ball of lightning travels forward, dealing damage to hit enemies, and upon contact or when it lasts too long, it explodes. Scales with 320% spell damage.")
            {
                active = SpellActions.CastBallLightning,
            };
            new Spell(17, 134, 3, 0, 1, "Bash", "Attack modifier\nEvery attack slows enemies for 2 seconds, and increases their damage taken by 16%")
            {
                passive = SpellActions.BashPassiveEnabled,
            };
            new Spell(18, 136, 1, 0, 1, "Frenzy", "Attack modifier\nEvery attack enrages you, increasing damage all damage by 7.5%. Up to 5 stacks.")
            {
                passive = x => SpellActions.Frenzy = x,
            };
            new Spell(19, 135, 27, 40, 10, "Seeking Arrow", "Casting spell empowers arrow, causing all arrows to head in the same direction for 30 seconds. While active, arrows deal more damage, the further target they hit, headshots deal double damage and bodyshots slow enemies by 20% for 4 seconds.")
            {
                active = SpellActions.SeekingArrow_Active,
            };
            new Spell(20, 137, 4, 0, 1, "Focus", "Passively, when landing a headshot, next projectile will deal 100% more damage and slow the enemy by 20%. When landing a body shot, next projectile will deal only 20% more damage, but attack speed is increased.")
            {
                passive = x => SpellActions.Focus = x,
            };
            new Spell(21, 140, 8, 0, 1, "Parry", "Passively, when parrying an enemy, deal magic damage to enemies around the target. Additionally, gain energy, heal yourself for a small amount and get stun immunity for 10 seconds after parrying.")
            {
                passive = x => SpellActions.Parry = x,
            };
            new Spell(22, 141, 50, 400, 300, "Cataclysm", "Creates a fire tornado that ignites enemies, slows them and deals damage.")
            {
                active = () => SpellActions.CastCataclysm(),
            };
            new Spell(23, 165, 11, 75, 8, "Blood Infused Arrow", "Sacrifice your own vitals to empower your next arrow. Drains percent of your current health and adds lost health as damage.")
            {
                active = () => SpellActions.CastBloodInfArr(),
            };
            //new Spell(24, 165, 1, 1, 2, "Corpse Explosion", "")
            //{
            //    active = () => SpellActions.CastCorpseExplosion(),
            //};
            //new Spell(25, 165, 1, 1, "Devour", "...")
            //{
            //    active = () =>
            //};
        }
예제 #8
0
        private void NewHitAi(Transform target, bool hitDelay, bool headDamage)
        {
            float dmgUnclamped = this.OutputDmg;

            ModAPI.Console.Write("dmgUnclamped: " + dmgUnclamped);
            if (ModdedPlayer.Stats.spell_seekingArrow)
            {
                float dist = Vector3.Distance(target.position, startposition);
                dmgUnclamped *= 1 + dist * ModdedPlayer.Stats.spell_seekingArrow_DamagePerDistance;
            }
            if (spearType)
            {
                if (ModdedPlayer.Stats.perk_thrownSpearhellChance > 0 && Random.value <= ModdedPlayer.Stats.perk_thrownSpearhellChance && OutputDmg > 1)
                {
                    var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(PhysicBody.position - Camera.main.transform.position));
                    obj.velocity = PhysicBody.velocity.normalized * 90f * ModdedPlayer.Stats.projectileSpeed;
                    Destroy(obj.gameObject, 18);
                }
            }
            else
            {
                if (headDamage)
                {
                    if (ModdedPlayer.Stats.i_EruptionBow && GreatBow.isEnabled)
                    {
                        //if (GameSetup.IsMultiplayer)
                        //{
                        BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position, Quaternion.identity);
                        //}
                    }
                }
            }

            if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.Stats.perk_bulletCritChance) || (spearType && Random.value <= ModdedPlayer.Stats.perk_thrownSpearCritChance))
            {
                headDamage    = true;
                dmgUnclamped *= ModdedPlayer.Stats.headShotDamage;
                dmgUnclamped *= SpellActions.FocusOnHeadShot();
                if (ModdedPlayer.Stats.spell_seekingArrow)
                {
                    dmgUnclamped *= ModdedPlayer.Stats.spell_seekingArrow_HeadDamage;
                }
            }
            else
            {
                dmgUnclamped *= SpellActions.FocusOnBodyShot();
            }



            if (target)
            {
                Vector3    vector             = target.transform.root.GetChild(0).InverseTransformPoint(base.transform.position);
                float      targetAngle        = Mathf.Atan2(vector.x, vector.z) * 57.29578f;
                int        animalHitDirection = animalHealth.GetAnimalHitDirection(targetAngle);
                BoltEntity entity             = target.GetComponentInParent <BoltEntity>();
                if (!entity)
                {
                    entity = target.GetComponent <BoltEntity>();
                }

                if (BoltNetwork.isClient && entity)
                {
                    ModdedPlayer.instance.OnHitEffectsClient(entity, dmgUnclamped);
                    if (ignite)
                    {
                        using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                        {
                            using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                            {
                                w.Write(27);
                                w.Write(entity.networkId.PackedValue);
                                w.Write(Effects.BlackFlame.FireDamageBonus);
                                w.Write(20f);
                                w.Write(2200);
                                w.Close();
                            }
                            AsyncHit.SendCommandDelayed(3, answerStream.ToArray(), NetworkManager.Target.OnlyServer);
                            answerStream.Close();
                        }
                    }
                    if (ModdedPlayer.Stats.spell_focus && headDamage)
                    {
                        if (ModdedPlayer.Stats.spell_focusBonusDmg == 0)
                        {
                            //slow enemy by 80%
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(22);
                                    w.Write(entity.networkId.PackedValue);
                                    w.Write(ModdedPlayer.Stats.spell_focusSlowAmount);
                                    w.Write(ModdedPlayer.Stats.spell_focusSlowDuration);
                                    w.Write(90);
                                    w.Close();
                                }
                                AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                            //Network.NetworkManager.SendLine(s, Network.NetworkManager.Target.OnlyServer);
                        }
                    }
                    else if (ModdedPlayer.Stats.spell_seekingArrow)
                    {
                        //slow enemy by 80%
                        using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                        {
                            using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                            {
                                w.Write(22);
                                w.Write(entity.networkId.PackedValue);
                                w.Write(ModdedPlayer.Stats.spell_seekingArrow_SlowAmount);
                                w.Write(ModdedPlayer.Stats.spell_seekingArrow_SlowDuration);
                                w.Write(91);
                                w.Close();
                            }
                            AsyncHit.SendCommandDelayed(2, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer);
                            answerStream.Close();
                        }
                    }
                    if (ignite)
                    {
                        if (BlackFlame.GiveAfterburn && Random.value < 0.1f)
                        {
                            int id = 120 + ModReferences.Players.IndexOf(LocalPlayer.GameObject);
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(34);
                                    w.Write(entity.networkId.PackedValue);
                                    w.Write(id);
                                    w.Write(1.15f);
                                    w.Write(25f);
                                    w.Close();
                                }
                                AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                        }
                    }
                    if (hitDelay)
                    {
                        target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver);
                        target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver);
                        BoltEntity     component      = this.parent.GetComponent <BoltEntity>();
                        PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer);
                        playerHitEnemy.Target      = entity;
                        playerHitEnemy.Weapon      = component;
                        playerHitEnemy.getAttacker = 10;
                        if (target.gameObject.CompareTag("animalRoot"))
                        {
                            playerHitEnemy.getAttackDirection = animalHitDirection;
                        }
                        else
                        {
                            playerHitEnemy.getAttackDirection = 3;
                        }
                        playerHitEnemy.getAttackerType = 4;
                        playerHitEnemy.Hit             = DamageMath.GetSendableDamage(dmgUnclamped);
                        if ((GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites) || (ignite && Random.value < 0.5f))
                        {
                            playerHitEnemy.Burn = true;
                        }
                        playerHitEnemy.getAttackerType += 1000000;
                        playerHitEnemy.Send();
                    }
                    else
                    {
                        target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver);
                        target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver);
                        PlayerHitEnemy playerHitEnemy2 = PlayerHitEnemy.Create(GlobalTargets.OnlyServer);
                        playerHitEnemy2.Target = entity;
                        if (target.gameObject.CompareTag("animalRoot"))
                        {
                            playerHitEnemy2.getAttackDirection = animalHitDirection;
                        }
                        else
                        {
                            playerHitEnemy2.getAttackDirection = 3;
                        }
                        playerHitEnemy2.getAttackerType = 4;
                        if ((ignite && Random.value < 0.5f) || GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites)
                        {
                            playerHitEnemy2.Burn = true;
                        }
                        playerHitEnemy2.Hit              = DamageMath.GetSendableDamage(dmgUnclamped);
                        playerHitEnemy2.getAttackerType += DamageMath.CONVERTEDFLOATattackerType;
                        playerHitEnemy2.Send();
                    }
                    goto afterdamage;
                }
                else
                {
                    if (target.gameObject.CompareTag("enemyRoot") || target.gameObject.CompareTag("enemyCollide"))
                    {
                        if (EnemyManager.enemyByTransform.ContainsKey(target.root))
                        {
                            var ep = EnemyManager.enemyByTransform[target.root];

                            if (ignite)
                            {
                                if ((ignite && Random.value < 0.5f) || GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites)
                                {
                                    ep.HealthScript.Burn();
                                }
                                ep.FireDebuff(2200, Effects.BlackFlame.FireDamageBonus, 20);
                                if (BlackFlame.GiveAfterburn && Random.value < 0.1f)
                                {
                                    if (ep != null)
                                    {
                                        int id = 120 + ModReferences.Players.IndexOf(LocalPlayer.GameObject);
                                        ep.DmgTakenDebuff(id, 1.15f, 25);
                                    }
                                }
                            }
                            ModdedPlayer.instance.OnHitEffectsHost(ep, dmgUnclamped);
                            if (ModdedPlayer.Stats.spell_focus && headDamage)
                            {
                                if (ModdedPlayer.Stats.spell_focusBonusDmg == 0)
                                {
                                    //slow enemy by 80%
                                    ep.Slow(90, ModdedPlayer.Stats.spell_focusSlowAmount, ModdedPlayer.Stats.spell_focusSlowDuration);
                                }
                            }
                            else if (ModdedPlayer.Stats.spell_seekingArrow)
                            {
                                ep.Slow(91, ModdedPlayer.Stats.spell_seekingArrow_SlowAmount, ModdedPlayer.Stats.spell_seekingArrow_SlowDuration);
                            }
                            ep.HealthScript.getAttackDirection(3);
                            ep.HitPhysical(dmgUnclamped);
                            Debug.Log("HIT PHYSICAL");
                            goto afterdamage;
                        }
                    }
                    target.gameObject.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver);
                    target.gameObject.SendMessageUpwards("getAttackerType", 4, SendMessageOptions.DontRequireReceiver);
                    GameObject closestPlayerFromPos = TheForest.Utils.Scene.SceneTracker.GetClosestPlayerFromPos(base.transform.position);
                    target.gameObject.SendMessageUpwards("getAttacker", closestPlayerFromPos, SendMessageOptions.DontRequireReceiver);
                    if (target.gameObject.CompareTag("enemyRoot") || target.gameObject.CompareTag("lb_bird") || target.gameObject.CompareTag("animalRoot"))
                    {
                        Debug.Log("HIT NORMAL");
                        if (target.gameObject.CompareTag("enemyRoot"))
                        {
                            EnemyHealth targetEnemyHealth = target.GetComponentInChildren <EnemyHealth>();
                            if (targetEnemyHealth)
                            {
                                targetEnemyHealth.getAttackDirection(3);
                                targetEnemyHealth.setSkinDamage(2);
                                mutantTargetSwitching componentInChildren2 = target.GetComponentInChildren <mutantTargetSwitching>();
                                if (componentInChildren2)
                                {
                                    componentInChildren2.getAttackerType(4);
                                    componentInChildren2.getAttacker(closestPlayerFromPos);
                                }

                                targetEnemyHealth.Hit((int)Mathf.Min((float)int.MaxValue, dmgUnclamped));

                                if ((ignite && Random.value < 0.5f) || GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites)
                                {
                                    targetEnemyHealth.Burn();
                                }
                            }
                        }
                        else
                        {
                            if (target.gameObject.CompareTag("animalRoot"))
                            {
                                target.gameObject.SendMessage("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver);
                            }
                            target.SendMessageUpwards("Hit", (int)Mathf.Min(dmgUnclamped, int.MaxValue / 2), SendMessageOptions.DontRequireReceiver);
                            if ((ignite && Random.value < 0.5f) || GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites)
                            {
                                target.gameObject.SendMessage("Burn", SendMessageOptions.DontRequireReceiver);
                            }
                            target.gameObject.SendMessage("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver);
                        }
                    }
                    else
                    {
                        if (target.gameObject.CompareTag("animalCollide"))
                        {
                            target.gameObject.SendMessageUpwards("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver);
                        }
                        target.SendMessageUpwards("Hit", (int)Mathf.Min(dmgUnclamped, int.MaxValue / 2), SendMessageOptions.DontRequireReceiver);
                        if (GreatBow.isEnabled && ModdedPlayer.Stats.i_greatBowIgnites || (ignite && Random.value < 0.5f))
                        {
                            target.gameObject.SendMessage("Burn", SendMessageOptions.DontRequireReceiver);
                        }
                        target.gameObject.SendMessageUpwards("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver);
                    }
                }
            }
afterdamage:

            if (ModdedPlayer.Stats.perk_projectileNoConsumeChance > 0.35f)
            {
                FMODCommon.PlayOneshotNetworked(this.hitAiEvent, base.transform, FMODCommon.NetworkRole.Any);
            }
        }
예제 #9
0
        public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider)
        {
            if (ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot"))
            {
                return;
            }
            if (!isTrigger)
            {
                Molotov componentInParent = transform.GetComponentInParent <Molotov>();
                if ((bool)componentInParent)
                {
                    componentInParent.IncendiaryBreak();
                    return;
                }
            }
            bool headDamage = false;

            if (target.gameObject.layer == LayerMask.NameToLayer("Water"))
            {
                FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any);
                return;
            }
            else if (target.CompareTag("SmallTree"))
            {
                FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any);
                return;
            }
            else if (target.CompareTag("PlaneHull"))
            {
                FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any);
                return;
            }
            else if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target"))
            {
                if (spearType)
                {
                    base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f));
                }
                else if (hitPointUpdated)
                {
                    base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f));
                }
                else
                {
                    base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f));
                }
                disableLive();
                if (target.CompareTag("Tree") || target.root.CompareTag("Tree"))
                {
                    TreeHealth component = target.GetComponent <TreeHealth>();
                    if (!(bool)component)
                    {
                        component = target.root.GetComponent <TreeHealth>();
                    }
                    if ((bool)component)
                    {
                        component.LodTree.AddTreeCutDownTarget(base.gameObject);
                    }
                }
                return;
            }
            else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot"))
            {
                if (lastPierced != null)
                {
                    if (target.root == lastPierced)
                    {
                        Physics.IgnoreCollision(base.GetComponent <Collider>(), targetCollider);
                        return;
                    }
                }
                bool  pierce       = false;
                float pierceChance = ModdedPlayer.Stats.projectilePierceChance - pierceCount;
                if (pierceChance > 0)
                {
                    if (pierceChance >= 1 || pierceChance < Random.value)
                    {
                        Physics.IgnoreCollision(base.GetComponent <Collider>(), targetCollider);
                        pierceCount++;
                        lastPierced = target.root;
                        Invoke("ForgetLastPierced", 0.125f);
                        pierce = true;
                    }
                }
                if (crossbowBoltType)
                {
                }
                else if (flintLockAmmoType)
                {
                }
                else if (spearType)
                {
                }
                else
                {
                    if (ModdedPlayer.Stats.i_CrossfireQuiver.value)
                    {
                        if (Time.time - ModdedPlayer.instance._lastCrossfireTime > 10 * ModdedPlayer.Stats.cooldown)
                        {
                            ModdedPlayer.instance._lastCrossfireTime = Time.time;
                            Vector3 pos = Camera.main.transform.position + Camera.main.transform.right * 5;
                            Vector3 dir = transform.position - pos;
                            dir.Normalize();
                            SpellActions.CastMagicArrow(pos, dir);
                        }
                    }
                }

                arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>();
                if (!(bool)arrowStickToTarget)
                {
                    arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>();
                }

                bool isbird   = target.tag == "lb_bird" || target.CompareTag("lb_bird");
                bool isfish   = target.CompareTag("Fish");
                bool isanimal = target.CompareTag("animalCollide") || target.CompareTag("animalRoot");
                if (!spearType && !flintLockAmmoType && !isfish)
                {
                    if (arrowStickToTarget && arrowStickToTarget.enabled)
                    {
                        if (isbird)
                        {
                            EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null);
                        }
                        arrowStickToTarget.CreatureType(isanimal, isbird, isfish);
                        if (SpellActions.SeekingArrow_ChangeTargetOnHit)
                        {
                            startposition = transform.position;
                        }

                        if (BoltNetwork.isRunning)
                        {
                            if (at && at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner)
                            {
                                if (pierce)
                                {
                                    headDamage = ((XArrowStickToTargetMod)arrowStickToTarget).checkHeadDamage(transform);
                                }
                                else
                                {
                                    headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                                }
                            }
                        }
                        else
                        {
                            if (pierce)
                            {
                                headDamage = ((XArrowStickToTargetMod)arrowStickToTarget).checkHeadDamage(transform);
                            }
                            headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                        }
                    }
                    if ((bool)arrowStickToTarget && !pierce)
                    {
                        Destroy(parent.gameObject);
                    }
                }
                else
                {
                    if (SpellActions.SeekingArrow_ChangeTargetOnHit)
                    {
                        ModdedPlayer.Stats.spell_seekingArrow.value = true;
                        SpellActions.SeekingArrow_Target.gameObject.SetActive(true);
                        SpellActions.SeekingArrow_Target.parent   = target.transform;
                        SpellActions.SeekingArrow_Target.position = new Vector3(target.transform.position.x, transform.position.y - 0.075f, target.transform.position.z);
                        SpellActions.SeekingArrow_TimeStamp       = Time.time;
                        startposition = transform.position;
                        SpellActions.SeekingArrow_ChangeTargetOnHit = false;
                    }
                }
                if (headDamage && !flintLockAmmoType && ModdedPlayer.Stats.perk_trueAim && ModdedPlayer.Stats.spell_seekingArrow)
                {
                    //True aim ability
                    float dist = (startposition - transform.position).sqrMagnitude;
                    if (dist >= 3600f)
                    {
                        OutputDmg *= 4;
                        NewHitAi(target, isbird || isanimal, headDamage);
                        ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg);
                        ModdedPlayer.instance.OnHit();
                        ModdedPlayer.instance.OnHit_Ranged(target);
                        BuffDB.AddBuff(28, 104, 1.20f, 5);                              //crit chance
                        if (ModdedPlayer.Stats.perk_trueAimUpgrade && dist >= 14400f)
                        {
                            OutputDmg *= 10;

                            NewHitAi(target, isbird || isanimal, headDamage);
                            NewHitAi(target, isbird || isanimal, headDamage);
                            ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg);
                            ModdedPlayer.instance.OnHit();
                            ModdedPlayer.instance.OnHit_Ranged(target);
                            ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg);
                            ModdedPlayer.instance.OnHit();
                            ModdedPlayer.instance.OnHit_Ranged(target);
                        }
                    }
                }



                NewHitAi(target, isbird || isanimal, headDamage);
                ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg);
                ModdedPlayer.instance.OnHit();
                ModdedPlayer.instance.OnHit_Ranged(target);
                BoltEntity be = target.GetComponentInParent <BoltEntity>();
                if (be == null)
                {
                    be = target.GetComponent <BoltEntity>();
                }

                if (ModdedPlayer.Stats.perk_fireDmgIncreaseOnHit)
                {
                    int   myID = 1000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject);
                    float dmg  = 1 + ModdedPlayer.Stats.spellFlatDmg / 3;
                    dmg *= ModdedPlayer.Stats.TotalMagicDamageMultiplier;
                    dmg *= ModdedPlayer.Stats.fireDamage + 1;
                    dmg *= 0.3f;
                    if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer)
                    {
                        target.GetComponentInParent <EnemyProgression>()?.FireDebuff(myID, dmg, 14);
                    }
                    else
                    {
                        if (be != null)
                        {
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(27);
                                    w.Write(be.networkId.PackedValue);
                                    w.Write(dmg);
                                    w.Write(14.5f);
                                    w.Write(1);
                                    w.Close();
                                }
                                ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                        }
                    }
                }
                if (ModdedPlayer.Stats.TotalRangedArmorPiercing > 0 && target.gameObject.CompareTag("enemyCollide"))
                {
                    if (ModdedPlayer.Stats.perk_thrownSpearExtraArmorReduction && spearType)
                    {
                        if (BoltNetwork.isClient)
                        {
                            if (be != null)
                            {
                                EnemyProgression.ReduceArmor(be, ModdedPlayer.Stats.TotalRangedArmorPiercing * 2 + ModdedPlayer.Stats.TotalMeleeArmorPiercing);
                            }
                        }
                        else if (EnemyManager.enemyByTransform.ContainsKey(target.root))
                        {
                            var prog = EnemyManager.enemyByTransform[target.root];
                            prog.ReduceArmor(ModdedPlayer.Stats.TotalRangedArmorPiercing * 2 + ModdedPlayer.Stats.TotalMeleeArmorPiercing);
                        }
                    }
                    else
                    {
                        if (BoltNetwork.isClient)
                        {
                            if (be != null)
                            {
                                EnemyProgression.ReduceArmor(be, ModdedPlayer.Stats.TotalRangedArmorPiercing);
                            }
                        }
                        else if (EnemyManager.enemyByTransform.ContainsKey(target.root))
                        {
                            var prog = EnemyManager.enemyByTransform[target.root];
                            prog.ReduceArmor(ModdedPlayer.Stats.TotalRangedArmorPiercing);
                        }
                    }
                }
                if (isfish)
                {
                    base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f));
                }
                //check piercing

                if (pierce)
                {
                    return;
                }
                Live = false;
                disableLive();
                DisableFlight();
            }
            else if (target.CompareTag("PlayerNet"))
            {
                if (BoltNetwork.isRunning)
                {
                    BoltEntity be = target.GetComponentInParent <BoltEntity>();
                    if (!(bool)be)
                    {
                        be = target.GetComponent <BoltEntity>();
                    }

                    if (be)
                    {
                        if (ModdedPlayer.Stats.i_ArchangelBow && GreatBow.isEnabled)
                        {
                            float lifePerSecond = (ModdedPlayer.Stats.healthRecoveryPerSecond) * ModdedPlayer.Stats.allRecoveryMult * (ModdedPlayer.Stats.healthPerSecRate) * 2;
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(39);
                                    w.Write(be.GetState <IPlayerState>().name);
                                    w.Write(lifePerSecond);
                                    w.Write(ModdedPlayer.Stats.TotalMaxHealth * 0.2f);
                                    w.Close();
                                }
                                AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                            BuffDB.AddBuff(25, 91, lifePerSecond, 10);
                        }
                        else if (ModSettings.FriendlyFire)
                        {
                            float dmgUnclamped = this.OutputDmg;
                            if (ModdedPlayer.Stats.spell_seekingArrow)
                            {
                                float dist = Vector3.Distance(target.position, startposition);
                                dmgUnclamped *= 1 + dist * ModdedPlayer.Stats.spell_seekingArrow_DamagePerDistance;
                            }
                            if (spearType)
                            {
                                if (ModdedPlayer.Stats.perk_thrownSpearhellChance > 0 && Random.value <= ModdedPlayer.Stats.perk_thrownSpearhellChance && OutputDmg > 1)
                                {
                                    var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(PhysicBody.position - Camera.main.transform.position));
                                    obj.velocity = PhysicBody.velocity.normalized * 90f * ModdedPlayer.Stats.projectileSpeed;
                                    Destroy(obj.gameObject, 18);
                                }
                            }

                            if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.Stats.perk_bulletCritChance) || (spearType && Random.value <= ModdedPlayer.Stats.perk_thrownSpearhellChance))
                            {
                                headDamage    = true;
                                dmgUnclamped *= ModdedPlayer.Stats.headShotDamage;
                                dmgUnclamped *= SpellActions.FocusOnHeadShot();
                                if (ModdedPlayer.Stats.spell_seekingArrow)
                                {
                                    dmgUnclamped *= ModdedPlayer.Stats.spell_seekingArrow_HeadDamage;
                                }
                            }
                            else
                            {
                                dmgUnclamped *= SpellActions.FocusOnBodyShot();
                            }

                            DamageMath.ReduceDamageToSendOverNet(dmgUnclamped, out int sendDamage, out int reps);

                            HitPlayer HP = HitPlayer.Create(be, EntityTargets.Everyone);
                            HP.damage = sendDamage;
                            for (int i = 0; i < reps; i++)
                            {
                                HP.Send();
                            }
                            //check piercing
                            float pierceChance = ModdedPlayer.Stats.projectilePierceChance - pierceCount;
                            if (pierceChance > 0)
                            {
                                if (pierceChance >= 1 || pierceChance < Random.value)
                                {
                                    Physics.IgnoreCollision(base.GetComponent <Collider>(), targetCollider);
                                    pierceCount++;
                                    return;
                                }
                            }
                            disableLive();
                            DisableFlight();
                        }
                    }
                }
            }
            else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves)
            {
                if (ignoreTerrain)
                {
                    ignoreTerrain = false;
                    base.StartCoroutine(RevokeIgnoreTerrain());
                }
                else
                {
                    if (spearType)
                    {
                        if ((bool)bodyCollider)
                        {
                            bodyCollider.isTrigger = true;
                        }
                        base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false));
                    }
                    else
                    {
                        Vector3 position2 = base.transform.position - base.transform.forward * -0.8f;
                        float   num       = Terrain.activeTerrain.SampleHeight(base.transform.position);
                        Vector3 position3 = Terrain.activeTerrain.transform.position;
                        float   num2      = num + position3.y;
                        Vector3 position4 = base.transform.position;
                        if (position4.y < num2)
                        {
                            position2.y = num2 + 0.5f;
                        }
                        base.StartCoroutine(HitStructure(position2, false));
                    }
                    disableLive();
                    FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any);
                }
            }
            else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood"))
            {
                if ((bool)target.transform.parent)
                {
                    if ((bool)target.transform.parent.GetComponent <StickFenceChunkArchitect>())
                    {
                        return;
                    }
                    if ((bool)target.transform.parent.GetComponent <BoneFenceChunkArchitect>())
                    {
                        return;
                    }
                }
                if (!isTrigger)
                {
                    if (spearType)
                    {
                        base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true));
                    }
                    else
                    {
                        base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true));
                    }
                    disableLive();
                }
            }
            else if (target.CompareTag("CaveDoor"))
            {
                ignoreTerrain = true;
                Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true);
            }
            else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock")))
            {
                target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver);
            }
            if (!Live)
            {
                destroyThisAmmo();
                parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver);
            }
        }
예제 #10
0
        private void NewHitAi(Transform target, bool hitDelay, bool headDamage)
        {
            float dmgUnclamped = this.OutputDmg;

            if (SpellActions.SeekingArrow)
            {
                float dist = Vector3.Distance(target.position, startposition);
                dmgUnclamped *= 1 + dist * SpellActions.SeekingArrow_DamagePerDistance;
            }
            if (spearType)
            {
                if (ModdedPlayer.instance.SpearhellChance > 0 && Random.value <= ModdedPlayer.instance.SpearhellChance && OutputDmg > 1)
                {
                    var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(Camera.main.transform.forward));
                    obj.velocity = PhysicBody.velocity * 1.05f;
                    Destroy(obj.gameObject, 30);
                }
            }
            else
            {
                if (headDamage)
                {
                    if (ModdedPlayer.instance.EruptionBow && GreatBow.isEnabled)
                    {
                        //if (GameSetup.IsMultiplayer)
                        //{
                        BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position, Quaternion.identity);
                        //}
                    }
                }
            }

            if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.instance.BulletCritChance) || (spearType && Random.value <= ModdedPlayer.instance.SpearCritChance))
            {
                headDamage    = true;
                dmgUnclamped *= ModdedPlayer.instance.HeadShotDamage;
                dmgUnclamped *= SpellActions.FocusOnHeadShot();
                if (SpellActions.SeekingArrow)
                {
                    dmgUnclamped *= SpellActions.SeekingArrow_HeadDamage;
                }
            }
            else
            {
                dmgUnclamped *= SpellActions.FocusOnBodyShot();
            }
            if (GreatBow.isEnabled)
            {
                dmgUnclamped *= 2.1f;
            }
            dmgUnclamped *= ModdedPlayer.instance.RangedAMP * ModdedPlayer.instance.CritDamageBuff;
            if (ModdedPlayer.instance.ProjectileDamageIncreasedBySize)
            {
                dmgUnclamped *= ModdedPlayer.instance.ProjectileSizeRatio;
            }
            DamageMath.DamageClamp(dmgUnclamped, out int sendDamage, out Repetitions);


            if (this.PhysicBody)
            {
                this.PhysicBody.velocity = Vector3.zero;
            }

            if (this.spearType)
            {
                this.PhysicBody.isKinematic = false;
                this.PhysicBody.useGravity  = true;
                this.disableLive();
                if (this.MyPickUp)
                {
                    this.MyPickUp.SetActive(true);
                }
            }
            if (target)
            {
                Vector3    vector             = target.transform.root.GetChild(0).InverseTransformPoint(base.transform.position);
                float      targetAngle        = Mathf.Atan2(vector.x, vector.z) * 57.29578f;
                int        animalHitDirection = animalHealth.GetAnimalHitDirection(targetAngle);
                BoltEntity componentInParent  = target.GetComponentInParent <BoltEntity>();
                if (!componentInParent)
                {
                    componentInParent = target.GetComponent <BoltEntity>();
                }



                if (BoltNetwork.isClient && componentInParent)
                {
                    ModdedPlayer.instance.OnHitEffectsClient(componentInParent, dmgUnclamped);
                    if (ignite)
                    {
                        using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                        {
                            using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                            {
                                w.Write(27);
                                w.Write(componentInParent.networkId.PackedValue);
                                w.Write(Effects.BlackFlame.FireDamageBonus);
                                w.Write(20f);
                                w.Write(2200);
                                w.Close();
                            }
                            AsyncHit.SendCommandDelayed(3, answerStream.ToArray(), NetworkManager.Target.OnlyServer);
                            answerStream.Close();
                        }
                    }
                    if (SpellActions.Focus && headDamage)
                    {
                        if (SpellActions.FocusBonusDmg == 0)
                        {
                            //slow enemy by 80%
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(22);
                                    w.Write(componentInParent.networkId.PackedValue);
                                    w.Write(SpellActions.FocusSlowAmount);
                                    w.Write(SpellActions.FocusSlowDuration);
                                    w.Write(90);
                                    w.Close();
                                }
                                AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                            //Network.NetworkManager.SendLine(s, Network.NetworkManager.Target.OnlyServer);
                        }
                    }
                    else if (SpellActions.SeekingArrow)
                    {
                        //slow enemy by 80%
                        using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                        {
                            using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                            {
                                w.Write(22);
                                w.Write(componentInParent.networkId.PackedValue);
                                w.Write(SpellActions.SeekingArrow_SlowAmount);
                                w.Write(SpellActions.SeekingArrow_SlowDuration);
                                w.Write(91);
                                w.Close();
                            }
                            AsyncHit.SendCommandDelayed(2, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer);
                            answerStream.Close();
                        }
                    }
                    if (ignite)
                    {
                        if (BlackFlame.GiveAfterburn && Random.value < 0.1f)
                        {
                            int id = 120 + ModReferences.Players.IndexOf(LocalPlayer.GameObject);
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(34);
                                    w.Write(componentInParent.networkId.PackedValue);
                                    w.Write(id);
                                    w.Write(1.15f);
                                    w.Write(25f);
                                    w.Close();
                                }
                                AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                        }
                    }
                    if (hitDelay)
                    {
                        target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver);
                        target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver);
                        BoltEntity     component      = this.parent.GetComponent <BoltEntity>();
                        PlayerHitEnemy playerHitEnemy = PlayerHitEnemy.Create(GlobalTargets.OnlyServer);
                        playerHitEnemy.Target      = componentInParent;
                        playerHitEnemy.Weapon      = component;
                        playerHitEnemy.getAttacker = 10;
                        if (target.gameObject.CompareTag("animalRoot"))
                        {
                            playerHitEnemy.getAttackDirection = animalHitDirection;
                        }
                        else
                        {
                            playerHitEnemy.getAttackDirection = 3;
                        }
                        playerHitEnemy.getAttackerType = 4;
                        playerHitEnemy.Hit             = sendDamage;
                        if (GreatBow.isEnabled && ModdedPlayer.instance.GreatBowIgnites)
                        {
                            playerHitEnemy.Burn = true;
                        }
                        AsyncHit.SendPlayerHitEnemy(playerHitEnemy, Repetitions);
                    }
                    else
                    {
                        target.transform.SendMessageUpwards("getClientHitDirection", 6, SendMessageOptions.DontRequireReceiver);
                        target.transform.SendMessageUpwards("StartPrediction", SendMessageOptions.DontRequireReceiver);
                        PlayerHitEnemy playerHitEnemy2 = PlayerHitEnemy.Create(GlobalTargets.OnlyServer);
                        playerHitEnemy2.Target = componentInParent;
                        if (target.gameObject.CompareTag("animalRoot"))
                        {
                            playerHitEnemy2.getAttackDirection = animalHitDirection;
                        }
                        else
                        {
                            playerHitEnemy2.getAttackDirection = 3;
                        }
                        playerHitEnemy2.getAttackerType = 4;
                        if (ignite || GreatBow.isEnabled && ModdedPlayer.instance.GreatBowIgnites)
                        {
                            playerHitEnemy2.Burn = true;
                        }
                        playerHitEnemy2.Hit = sendDamage;
                        AsyncHit.SendPlayerHitEnemy(playerHitEnemy2, Repetitions);
                    }
                }
                else
                {
                    if (target.gameObject.CompareTag("enemyRoot") || target.gameObject.CompareTag("enemyCollide"))
                    {
                        var ep = target.gameObject.GetComponentInParent <EnemyProgression>();
                        if (ep == null)
                        {
                            ep = target.gameObject.GetComponent <EnemyProgression>();
                            if (ep == null)
                            {
                                ep = target.gameObject.GetComponentInChildren <EnemyProgression>();
                            }
                        }
                        if (ignite)
                        {
                            ep.FireDebuff(2200, Effects.BlackFlame.FireDamageBonus, 20);
                            if (BlackFlame.GiveAfterburn && Random.value < 0.1f)
                            {
                                if (ep != null)
                                {
                                    int id = 120 + ModReferences.Players.IndexOf(LocalPlayer.GameObject);
                                    ep.DmgTakenDebuff(id, 1.15f, 25);
                                }
                            }
                        }
                        ModdedPlayer.instance.OnHitEffectsHost(ep, dmgUnclamped);
                        if (SpellActions.Focus && headDamage)
                        {
                            if (SpellActions.FocusBonusDmg == 0)
                            {
                                //slow enemy by 80%
                                ep.Slow(90, SpellActions.FocusSlowAmount, SpellActions.FocusSlowDuration);
                            }
                        }
                        else if (SpellActions.SeekingArrow)
                        {
                            ep.Slow(91, SpellActions.SeekingArrow_SlowAmount, SpellActions.SeekingArrow_SlowDuration);
                        }
                    }
                    target.gameObject.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver);
                    target.gameObject.SendMessageUpwards("getAttackerType", 4, SendMessageOptions.DontRequireReceiver);
                    GameObject closestPlayerFromPos = TheForest.Utils.Scene.SceneTracker.GetClosestPlayerFromPos(base.transform.position);
                    target.gameObject.SendMessageUpwards("getAttacker", closestPlayerFromPos, SendMessageOptions.DontRequireReceiver);
                    if (target.gameObject.CompareTag("lb_bird") || target.gameObject.CompareTag("animalRoot") || target.gameObject.CompareTag("enemyRoot") || target.gameObject.CompareTag("PlayerNet"))
                    {
                        if (target.gameObject.CompareTag("enemyRoot"))
                        {
                            EnemyHealth componentInChildren = target.GetComponentInChildren <EnemyHealth>();
                            if (componentInChildren)
                            {
                                componentInChildren.getAttackDirection(3);
                                componentInChildren.setSkinDamage(2);
                                mutantTargetSwitching componentInChildren2 = target.GetComponentInChildren <mutantTargetSwitching>();
                                if (componentInChildren2)
                                {
                                    componentInChildren2.getAttackerType(4);
                                    componentInChildren2.getAttacker(closestPlayerFromPos);
                                }
                                for (int i = 0; i < Repetitions; i++)
                                {
                                    componentInChildren.Hit(sendDamage);
                                }
                            }
                        }
                        else
                        {
                            if (target.gameObject.CompareTag("animalRoot"))
                            {
                                Repetitions = 1;
                                target.gameObject.SendMessage("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver);
                            }
                            AsyncHit.SendPlayerHitEnemy(target, Repetitions, sendDamage);
                            if (ignite || GreatBow.isEnabled && ModdedPlayer.instance.GreatBowIgnites)
                            {
                                target.gameObject.SendMessage("Burn", SendMessageOptions.DontRequireReceiver);
                            }
                            target.gameObject.SendMessage("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver);
                        }
                    }
                    else
                    {
                        if (target.gameObject.CompareTag("animalCollide"))
                        {
                            Repetitions = 1;
                            target.gameObject.SendMessageUpwards("ApplyAnimalSkinDamage", animalHitDirection, SendMessageOptions.DontRequireReceiver);
                        }
                        AsyncHit.SendPlayerHitEnemy(target, Repetitions, sendDamage);
                        if (GreatBow.isEnabled && ModdedPlayer.instance.GreatBowIgnites)
                        {
                            target.gameObject.SendMessage("Burn", SendMessageOptions.DontRequireReceiver);
                        }
                        target.gameObject.SendMessageUpwards("getSkinHitPosition", base.transform, SendMessageOptions.DontRequireReceiver);
                    }
                }
            }
            if (this.MyPickUp)
            {
                this.MyPickUp.SetActive(true);
            }
            FMODCommon.PlayOneshotNetworked(this.hitAiEvent, base.transform, FMODCommon.NetworkRole.Any);
        }
예제 #11
0
        public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider)
        {
            if (ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot"))
            {
                return;
            }
            if (!isTrigger)
            {
                Molotov componentInParent = transform.GetComponentInParent <Molotov>();
                if ((bool)componentInParent)
                {
                    componentInParent.IncendiaryBreak();
                }
            }
            bool headDamage = false;

            if (target.gameObject.layer == LayerMask.NameToLayer("Water"))
            {
                FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any);
            }
            else if (target.CompareTag("SmallTree"))
            {
                FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any);
            }
            if (target.CompareTag("PlaneHull"))
            {
                FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any);
            }
            if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target"))
            {
                if (spearType)
                {
                    base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f));
                }
                else if (hitPointUpdated)
                {
                    base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f));
                }
                else
                {
                    base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f));
                }
                disableLive();
                if (target.CompareTag("Tree") || target.root.CompareTag("Tree"))
                {
                    TreeHealth component = target.GetComponent <TreeHealth>();
                    if (!(bool)component)
                    {
                        component = target.root.GetComponent <TreeHealth>();
                    }
                    if ((bool)component)
                    {
                        component.LodTree.AddTreeCutDownTarget(base.gameObject);
                    }
                }
            }
            else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot"))
            {
                if (crossbowBoltType)
                {
                }
                else if (flintLockAmmoType)
                {
                }
                else if (spearType)
                {
                }
                else
                {
                    if (ModdedPlayer.instance.IsCrossfire)
                    {
                        if (Time.time - ModdedPlayer.instance.LastCrossfireTime > 10)
                        {
                            ModdedPlayer.instance.LastCrossfireTime = Time.time;
                            float damage1 = 55 + ModdedPlayer.instance.SpellDamageBonus * 1.25f;
                            damage1 = damage1 * ModdedPlayer.instance.SpellAMP;
                            Vector3 pos = Camera.main.transform.position + Camera.main.transform.right * 5;
                            Vector3 dir = transform.position - pos;
                            dir.Normalize();
                            if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer)
                            {
                                MagicArrow.Create(pos, dir, damage1, ModReferences.ThisPlayerID, SpellActions.MagicArrowDuration, SpellActions.MagicArrowDoubleSlow, SpellActions.MagicArrowDmgDebuff);
                                if (BoltNetwork.isRunning)
                                {
                                    using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                                    {
                                        using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                        {
                                            w.Write(3);
                                            w.Write(7);
                                            w.Write(pos.x);
                                            w.Write(pos.y);
                                            w.Write(pos.z);
                                            w.Write(dir.x);
                                            w.Write(dir.y);
                                            w.Write(dir.z);
                                            w.Write(damage1);
                                            w.Write(ModReferences.ThisPlayerID);
                                            w.Write(SpellActions.MagicArrowDuration);
                                            w.Write(SpellActions.MagicArrowDoubleSlow);
                                            w.Write(SpellActions.MagicArrowDmgDebuff);

                                            w.Close();
                                        }
                                        ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.Others);
                                        answerStream.Close();
                                    }
                                }
                            }
                            else if (GameSetup.IsMpClient)
                            {
                                MagicArrow.CreateEffect(pos, dir, SpellActions.MagicArrowDmgDebuff, SpellActions.MagicArrowDuration);
                                using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                                {
                                    using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                    {
                                        w.Write(3);
                                        w.Write(7);
                                        w.Write(pos.x);
                                        w.Write(pos.y);
                                        w.Write(pos.z);
                                        w.Write(dir.x);
                                        w.Write(dir.y);
                                        w.Write(dir.z);
                                        w.Write(damage1);
                                        w.Write(ModReferences.ThisPlayerID);
                                        w.Write(SpellActions.MagicArrowDuration);
                                        w.Write(SpellActions.MagicArrowDoubleSlow);
                                        w.Write(SpellActions.MagicArrowDmgDebuff);

                                        w.Close();
                                    }
                                    ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.Others);
                                    answerStream.Close();
                                }
                            }
                        }
                    }
                }
                bool flag  = target.tag == "lb_bird" || target.CompareTag("lb_bird");
                bool flag2 = target.CompareTag("Fish");
                bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot");
                arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>();
                if (!(bool)arrowStickToTarget)
                {
                    arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>();
                }
                if (!spearType && !flintLockAmmoType && !flag2)
                {
                    if (arrowStickToTarget && arrowStickToTarget.enabled)
                    {
                        if (flag)
                        {
                            EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null);
                        }
                        arrowStickToTarget.CreatureType(flag3, flag, flag2);
                        if (BoltNetwork.isRunning)
                        {
                            if (at && at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner)
                            {
                                headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                            }
                        }
                        else
                        {
                            headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                        }
                    }
                    if ((bool)arrowStickToTarget)
                    {
                        base.Invoke("destroyMe", 0.1f);
                    }
                }
                if (SpellActions.SeekingArrow_ChangeTargetOnHit)
                {
                    SpellActions.SeekingArrow = true;
                    SpellActions.SeekingArrow_Target.gameObject.SetActive(true);
                    SpellActions.SeekingArrow_Target.transform.parent   = target.transform;
                    SpellActions.SeekingArrow_Target.transform.position = new Vector3(target.transform.position.x, transform.position.y - 0.075f, target.transform.position.z);
                    SpellActions.SeekingArrow_TimeStamp = Time.time;
                    startposition = transform.position;
                    SpellActions.SeekingArrow_ChangeTargetOnHit = false;
                }
                if (headDamage && !flintLockAmmoType && ModdedPlayer.instance.TrueAim && SpellActions.SeekingArrow)
                {
                    float dist = (startposition - transform.position).sqrMagnitude;
                    if (dist >= 3600f)
                    {
                        OutputDmg *= 4;
                        NewHitAi(target, flag || flag3, headDamage);
                        ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg);
                        ModdedPlayer.instance.OnHit();
                        ModdedPlayer.instance.OnHit_Ranged(target);
                        if (ModdedPlayer.instance.TrueAimUpgrade && dist >= 14400f)
                        {
                            OutputDmg *= 10;

                            NewHitAi(target, flag || flag3, headDamage);
                            NewHitAi(target, flag || flag3, headDamage);
                            ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg);
                            ModdedPlayer.instance.OnHit();
                            ModdedPlayer.instance.OnHit_Ranged(target);
                            ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg);
                            ModdedPlayer.instance.OnHit();
                            ModdedPlayer.instance.OnHit_Ranged(target);
                        }
                    }
                }

                NewHitAi(target, flag || flag3, headDamage);
                ModdedPlayer.instance.DoAreaDamage(target.root, OutputDmg);
                ModdedPlayer.instance.OnHit();
                ModdedPlayer.instance.OnHit_Ranged(target);
                BoltEntity be = target.GetComponentInParent <BoltEntity>();
                if (be == null)
                {
                    be = target.GetComponent <BoltEntity>();
                }

                if (ModdedPlayer.instance.SpellAmpFireDmg)
                {
                    int   myID = 1000 + ModReferences.Players.IndexOf(LocalPlayer.GameObject);
                    float dmg  = 1 + ModdedPlayer.instance.SpellDamageBonus / 3;
                    dmg *= ModdedPlayer.instance.SpellAMP;
                    dmg *= ModdedPlayer.instance.FireAmp + 1;
                    dmg *= 0.3f;
                    if (GameSetup.IsSinglePlayer || GameSetup.IsMpServer)
                    {
                        target.GetComponentInParent <EnemyProgression>()?.FireDebuff(myID, dmg, 14);
                    }
                    else
                    {
                        if (be != null)
                        {
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(27);
                                    w.Write(be.networkId.PackedValue);
                                    w.Write(dmg);
                                    w.Write(14.5f);
                                    w.Write(1);
                                    w.Close();
                                }
                                ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                        }
                    }
                }
                if (ModdedPlayer.instance.RangedArmorReduction > 0 && target.gameObject.CompareTag("enemyCollide"))
                {
                    if (BoltNetwork.isClient)
                    {
                        if (be != null)
                        {
                            EnemyProgression.ReduceArmor(be, ModdedPlayer.instance.RangedArmorReduction);
                        }
                    }
                    else
                    {
                        target.transform.SendMessageUpwards("ReduceArmor", ModdedPlayer.instance.RangedArmorReduction, SendMessageOptions.DontRequireReceiver);
                    }
                }
                if (flag2)
                {
                    base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f));
                }
                disableLive();
            }
            else if (target.CompareTag("PlayerNet"))
            {
                if (BoltNetwork.isRunning)
                {
                    BoltEntity be = target.GetComponentInParent <BoltEntity>();
                    if (!(bool)be)
                    {
                        be = target.GetComponent <BoltEntity>();
                    }



                    if (be)
                    {
                        if (ModdedPlayer.instance.ArchangelBow && GreatBow.isEnabled)
                        {
                            using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream())
                            {
                                using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream))
                                {
                                    w.Write(39);
                                    w.Write(be.GetState <IPlayerState>().name);
                                    w.Write((ModdedPlayer.instance.LifeRegen) * ModdedPlayer.instance.HealingMultipier * (1 + ModdedPlayer.instance.HealthRegenPercent));
                                    w.Write(ModdedPlayer.instance.MaxHealth * 0.25f);
                                    w.Close();
                                }
                                AsyncHit.SendCommandDelayed(1, answerStream.ToArray(), Network.NetworkManager.Target.OnlyServer);
                                answerStream.Close();
                            }
                        }
                        else if (ModSettings.FriendlyFire)
                        {
                            float dmgUnclamped = this.OutputDmg;
                            if (SpellActions.SeekingArrow)
                            {
                                float dist = Vector3.Distance(target.position, startposition);
                                dmgUnclamped *= 1 + dist * SpellActions.SeekingArrow_DamagePerDistance;
                            }
                            if (spearType)
                            {
                                if (ModdedPlayer.instance.SpearhellChance > 0 && Random.value <= ModdedPlayer.instance.SpearhellChance && OutputDmg > 1)
                                {
                                    var obj = Instantiate(PhysicBody, Camera.main.transform.position + Vector3.up * 2f, Quaternion.LookRotation(Camera.main.transform.forward));
                                    obj.velocity = PhysicBody.velocity * 1.05f;
                                    Destroy(obj.gameObject, 30);
                                }
                            }
                            else
                            {
                                if (headDamage)
                                {
                                    if (ModdedPlayer.instance.EruptionBow && GreatBow.isEnabled)
                                    {
                                        //if (GameSetup.IsMultiplayer)
                                        //{
                                        BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position, Quaternion.identity);
                                        //}
                                    }
                                }
                            }

                            if (headDamage || (flintLockAmmoType && Random.value <= ModdedPlayer.instance.BulletCritChance) || (spearType && Random.value <= ModdedPlayer.instance.SpearCritChance))
                            {
                                headDamage    = true;
                                dmgUnclamped *= ModdedPlayer.instance.HeadShotDamage;
                                dmgUnclamped *= SpellActions.FocusOnHeadShot();
                                if (SpellActions.SeekingArrow)
                                {
                                    dmgUnclamped *= SpellActions.SeekingArrow_HeadDamage;
                                }
                            }
                            else
                            {
                                dmgUnclamped *= SpellActions.FocusOnBodyShot();
                            }
                            if (GreatBow.isEnabled)
                            {
                                dmgUnclamped *= 2.1f;
                            }
                            dmgUnclamped *= ModdedPlayer.instance.RangedAMP * ModdedPlayer.instance.CritDamageBuff;
                            if (ModdedPlayer.instance.ProjectileDamageIncreasedBySize)
                            {
                                dmgUnclamped *= ModdedPlayer.instance.ProjectileSizeRatio;
                            }

                            DamageMath.DamageClamp(dmgUnclamped, out int sendDamage, out Repetitions);



                            HitPlayer HP = HitPlayer.Create(be, EntityTargets.Everyone);
                            HP.damage = sendDamage;
                            for (int i = 0; i < Repetitions; i++)
                            {
                                HP.Send();
                            }
                            disableLive();
                        }
                    }
                }
            }
            else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves)
            {
                if (ignoreTerrain)
                {
                    ignoreTerrain = false;
                    base.StartCoroutine(RevokeIgnoreTerrain());
                }
                else
                {
                    if (spearType)
                    {
                        if ((bool)bodyCollider)
                        {
                            bodyCollider.isTrigger = true;
                        }
                        base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false));
                    }
                    else
                    {
                        Vector3 position2 = base.transform.position - base.transform.forward * -0.8f;
                        float   num       = Terrain.activeTerrain.SampleHeight(base.transform.position);
                        Vector3 position3 = Terrain.activeTerrain.transform.position;
                        float   num2      = num + position3.y;
                        Vector3 position4 = base.transform.position;
                        if (position4.y < num2)
                        {
                            position2.y = num2 + 0.5f;
                        }
                        base.StartCoroutine(HitStructure(position2, false));
                    }
                    disableLive();
                    FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any);
                }
            }
            else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood"))
            {
                if ((bool)target.transform.parent)
                {
                    if ((bool)target.transform.parent.GetComponent <StickFenceChunkArchitect>())
                    {
                        return;
                    }
                    if ((bool)target.transform.parent.GetComponent <BoneFenceChunkArchitect>())
                    {
                        return;
                    }
                }
                if (!isTrigger)
                {
                    if (spearType)
                    {
                        base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true));
                    }
                    else
                    {
                        base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true));
                    }
                    disableLive();
                }
            }
            else if (target.CompareTag("CaveDoor"))
            {
                ignoreTerrain = true;
                Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true);
            }
            else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock")))
            {
                target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver);
            }
            if (!Live)
            {
                destroyThisAmmo();
                parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver);
            }
        }