Example #1
0
 private void Update()
 {
     if (IsOn)
     {
         SpellCaster.RemoveStamina(Cost * Time.deltaTime);
         if (LocalPlayer.Stats.Stamina < 10)
         {
             Toggle();
         }
         if (GiveDamageBuff)
         {
             BuffDB.AddBuff(13, 44, 1.1f, 0.1f);
         }
     }
 }
Example #2
0
 private void Update()
 {
     if (IsOn)
     {
         if (ModdedPlayer.instance.DanceOfFiregod)
         {
             SpellCaster.RemoveStamina(Cost * 10 * Time.deltaTime);
         }
         else
         {
             SpellCaster.RemoveStamina(Cost * Time.deltaTime);
         }
         if (LocalPlayer.Stats.Stamina < 5)
         {
             Toggle();
         }
         if (GiveDamageBuff)
         {
             BuffDB.AddBuff(13, 44, 1.6f, 1f);
         }
     }
 }
        private void Update()
        {
            if (ModAPI.Input.GetButtonDown("EquipWeapon"))
            {
                if (Inventory.Instance.ItemList[-12] != null)
                {
                    if (Inventory.Instance.ItemList[-12].Equipped)
                    {
                        PlayerInventoryMod.ToEquipWeaponType = Inventory.Instance.ItemList[-12].weaponModel;
                        LocalPlayer.Inventory.StashEquipedWeapon(false);
                        LocalPlayer.Inventory.Equip(80, false);

                        if (BoltNetwork.isRunning)
                        {
                            Network.NetworkManager.SendLine("CE" + ModReferences.ThisPlayerPacked + ";" + (int)PlayerInventoryMod.ToEquipWeaponType, NetworkManager.Target.Others);
                        }


                        PlayerInventoryMod.ToEquipWeaponType = BaseItem.WeaponModelType.None;
                    }
                }
            }

            try
            {
                float dmgPerSecond = 0;
                int   poisonCount  = 0;
                int[] keys         = new List <int>(BuffDB.activeBuffs.Keys).ToArray();
                for (int i = 0; i < keys.Length; i++)
                {
                    Buff buff = BuffDB.activeBuffs[keys[i]];
                    if (DebuffImmune > 0 && buff.isNegative && buff.DispellAmount <= 2)
                    {
                        BuffDB.activeBuffs[keys[i]].ForceEndBuff(keys[i]);
                        continue;
                    }
                    else if (DebuffResistant > 0 && buff.isNegative && buff.DispellAmount <= 1)
                    {
                        BuffDB.activeBuffs[keys[i]].ForceEndBuff(keys[i]);
                        continue;
                    }
                    else
                    {
                        BuffDB.activeBuffs[keys[i]].UpdateBuff(keys[i]);
                        if (buff._ID == 3)
                        {
                            poisonCount++;
                            dmgPerSecond += buff.amount;
                        }
                    }
                }
                if (dmgPerSecond != 0)
                {
                    dmgPerSecond                   *= 1 - MagicResistance;
                    dmgPerSecond                   *= DamageReductionTotal;
                    LocalPlayer.Stats.Health       -= dmgPerSecond * Time.deltaTime;
                    LocalPlayer.Stats.HealthTarget -= dmgPerSecond * Time.deltaTime * 2;

                    if (poisonCount > 1)
                    {
                        BuffDB.AddBuff(1, 33, 0.7f, 1);
                    }
                }
                if (LocalPlayer.Stats.Health <= 0 && !LocalPlayer.Stats.Dead)
                {
                    LocalPlayer.Stats.Hit(1000, true, PlayerStats.DamageType.Drowning);
                }
            }
            catch (Exception e)
            {
                ModAPI.Log.Write("Poisoning player error" + e.ToString());
            }



            if (LocalPlayer.Stats != null)
            {
                if (LocalPlayer.Stats.Health < MaxHealth)
                {
                    if (LocalPlayer.Stats.Health < LocalPlayer.Stats.HealthTarget)
                    {
                        LocalPlayer.Stats.Health += LifeRegen * (HealthRegenPercent + 1) * HealingMultipier;
                    }
                    else
                    {
                        LocalPlayer.Stats.Health += LifeRegen * (HealthRegenPercent + 1) * HealingMultipier / 10;
                    }
                }

                if (Clock.Day > LastDayOfGeneration)
                {
                    for (int i = 0; i < Clock.Day - LastDayOfGeneration; i++)
                    {
                        foreach (KeyValuePair <int, int> pair in GeneratedResources)
                        {
                            LocalPlayer.Inventory.AddItem(pair.Key, pair.Value);
                        }
                    }
                    LastDayOfGeneration = Clock.Day;
                }
            }
            //if (UnityEngine.Input.GetKeyDown(KeyCode.F5))
            //{

            //    for (int i = 0; i < ModReferences.rightHandTransform.childCount; i++)
            //    {
            //        Transform trans = ModReferences.rightHandTransform.GetChild(i);


            //        try
            //        {
            //            Debug.LogWarning(trans.name);

            //        if (trans.gameObject.activeSelf)
            //        {
            //            var components = trans.gameObject.GetComponents<Component>();
            //            string s = trans.name+"\n\n\n";
            //            foreach (var item in components)
            //            {
            //                s += "\n" + item.ToString();
            //            }
            //            s += "\n\n\n" + ModReferences.ListAllChildren(trans, "");
            //            ModAPI.Log.Write(s);
            //           Debug.Log(s);

            //        }
            //        }
            //        catch (Exception e)
            //        {

            //            Debug.LogError(e.ToString());
            //        }
            //    }
            //}



            if (TimeUntillMassacreReset > 0)
            {
                TimeUntillMassacreReset -= Time.unscaledDeltaTime;
                if (TimeUntillMassacreReset <= 0)
                {
                    AddFinalExperience(Convert.ToInt64((double)NewlyGainedExp * MassacreMultipier));
                    NewlyGainedExp          = 0;
                    TimeUntillMassacreReset = 0;
                    MassacreKills           = 0;
                    CountMassacre();
                }
            }

            if (Effects.Multishot.IsOn)
            {
                if (!SpellCaster.RemoveStamina(3 * Time.deltaTime) || LocalPlayer.Stats.Stamina < 7)
                {
                    Effects.Multishot.IsOn = false;
                    Effects.Multishot.localPlayerInstance.SetActive(false);
                }
            }
            Berserker.Effect();

            if (Rooted)
            {
                if (StunImmune > 0 || RootImmune > 0)
                {
                    Rooted = false;
                    if (!Stunned)
                    {
                        LocalPlayer.FpCharacter.MovementLocked = false;
                        LocalPlayer.FpCharacter.CanJump        = true;
                        LocalPlayer.Rigidbody.isKinematic      = false;
                        LocalPlayer.Rigidbody.useGravity       = true;
                        LocalPlayer.Rigidbody.WakeUp();
                    }
                }

                RootDuration -= Time.deltaTime;
                if (RootDuration < 0)
                {
                    Rooted = false;
                    if (!Stunned)
                    {
                        LocalPlayer.Rigidbody.isKinematic = false;
                        LocalPlayer.Rigidbody.useGravity  = true;
                        LocalPlayer.Rigidbody.WakeUp();
                        LocalPlayer.FpCharacter.MovementLocked = false;
                        LocalPlayer.FpCharacter.CanJump        = true;
                    }
                }
            }
            if (Stunned)
            {
                if (StunImmune > 0)
                {
                    Stunned = false;
                    LocalPlayer.FpCharacter.Locked = false;
                    if (!Rooted)
                    {
                        LocalPlayer.FpCharacter.MovementLocked = false;
                        LocalPlayer.FpCharacter.CanJump        = true;
                        LocalPlayer.Rigidbody.isKinematic      = false;
                        LocalPlayer.Rigidbody.useGravity       = true;
                        LocalPlayer.Rigidbody.WakeUp();
                    }
                }
                StunDuration -= Time.deltaTime;
                if (StunDuration < 0)
                {
                    Stunned = false;
                    LocalPlayer.FpCharacter.Locked = false;
                    if (!Rooted)
                    {
                        LocalPlayer.FpCharacter.MovementLocked = false;
                        LocalPlayer.FpCharacter.CanJump        = true;
                        LocalPlayer.Rigidbody.isKinematic      = false;
                        LocalPlayer.Rigidbody.useGravity       = true;
                        LocalPlayer.Rigidbody.WakeUp();
                    }
                }
            }
            if (HexedPantsOfMrM_Enabled)
            {
                if (LocalPlayer.FpCharacter.velocity.sqrMagnitude < 0.1)//if standing still
                {
                    HexedPantsOfMrM_StandTime = Mathf.Clamp(HexedPantsOfMrM_StandTime - Time.deltaTime, -1.1f, 1.1f);
                    if (HexedPantsOfMrM_StandTime <= 1)
                    {
                        if (LocalPlayer.Stats.Health > 5)
                        {
                            LocalPlayer.Stats.Health -= Time.deltaTime * MaxHealth * 0.015f;
                        }
                    }
                }
                else //if moving
                {
                    HexedPantsOfMrM_StandTime = Mathf.Clamp(HexedPantsOfMrM_StandTime + Time.deltaTime, -1.1f, 1.1f);
                    if (HexedPantsOfMrM_StandTime >= 1)
                    {
                        AddBuff(9, 41, 1.2f, 1f);
                        AddBuff(11, 42, 1.2f, 1f);
                    }
                }
            }
            if (DeathPact_Enabled)
            {
                DamageOutputMult /= DeathPact_Amount;

                DeathPact_Amount = 1 + Mathf.RoundToInt((1 - (LocalPlayer.Stats.Health / MaxHealth)) * 100) * 0.03f;
                AddBuff(12, 43, DeathPact_Amount - 1, 1f);

                DamageOutputMult *= DeathPact_Amount;
            }
        }