public static int RangedRepetitions() { int repeats = 1; if (Effects.Multishot.IsOn) { bool b = Stats.i_SoraBracers ? SpellCaster.RemoveStamina(Mathf.Pow(Stats.perk_multishotProjectileCount, 1.75f)) : SpellCaster.RemoveStamina(10 * Mathf.Pow(Stats.perk_multishotProjectileCount, 1.75f)); if (b) { repeats += Stats.perk_multishotProjectileCount; if (Stats.i_SoraBracers) { repeats += 4; } } else { Effects.Multishot.IsOn = false; Effects.Multishot.localPlayerInstance.SetActive(false); } } return(repeats); }
//RANGED MOD CHANGES--------------------------------------------------- // public override void Start() // { // base.Start(); // string log = ""; // foreach (var list in _inventoryItemViewsCache) // { // foreach (var item in list.Value) // { // try // { //string s = "• _inventoryItemViewsCache[" + list.Key + "][" + list.Value + "]\n" + // "\tItem: " + item.ItemCache._name + " " + item.ItemCache._id; // s += "\n\tHeld Gameobject" + item._held.name + "\n\n"; // log += s; // } // catch (System.Exception) // { // } // } // } // ModAPI.Log.Write(log); // } protected override void FireRangedWeapon() { if (ModSettings.IsDedicated) { return; } InventoryItemView inventoryItemView = _equipmentSlots[0]; TheForest.Items.Item itemCache = inventoryItemView.ItemCache; bool flag = itemCache._maxAmount < 0; bool flag2 = false; int repeats = 1; if (Effects.Multishot.IsOn) { if (SpellCaster.RemoveStamina(5 * ModdedPlayer.instance.MultishotCount * ModdedPlayer.instance.MultishotCount)) { repeats += ModdedPlayer.instance.MultishotCount; } else { Effects.Multishot.IsOn = false; Effects.Multishot.localPlayerInstance.SetActive(false); } } for (int i = 0; i < repeats; i++) { if (flag || RemoveItem(itemCache._ammoItemId, 1, false, true)) { ModdedPlayer.instance.lastShotProjectile = itemCache; InventoryItemView inventoryItemView2 = _inventoryItemViewsCache[itemCache._ammoItemId][0]; TheForest.Items.Item itemCache2 = inventoryItemView2.ItemCache; FakeParent component = inventoryItemView2._held.GetComponent <FakeParent>(); Vector3 pos = inventoryItemView2._held.transform.position; if (i > 0 && i < 9) { pos += inventoryItemView2._held.transform.right * Mathf.Cos(45 * (i - 1)) * 0.5f + inventoryItemView2._held.transform.up * Mathf.Sin(45 * (i + 1)) * 5f; } else if (i >= 9 && i < 22) { pos += inventoryItemView2._held.transform.right * Mathf.Cos(30 * (i + 5)) * 1f + inventoryItemView2._held.transform.up * Mathf.Sin(30 * (i + 5)) * 1f; } else if (i > 21) { pos += inventoryItemView2._held.transform.right * Mathf.Cos(25 * (i)) * 1.5f + inventoryItemView2._held.transform.up * Mathf.Sin(25 * (i)) * 1.5f; } GameObject gameObject = (!(bool)component || component.gameObject.activeSelf) ? Object.Instantiate(itemCache2._ammoPrefabs.GetPrefabForBonus(inventoryItemView.ActiveBonus, true).gameObject, pos, inventoryItemView2._held.transform.rotation) : Object.Instantiate(itemCache2._ammoPrefabs.GetPrefabForBonus(inventoryItemView.ActiveBonus, true).gameObject, component.RealPosition, component.RealRotation); gameObject.transform.localScale *= ModdedPlayer.instance.ProjectileSizeRatio; gameObject.AddComponent <ProjectileIgnoreCollision>(); if ((bool)gameObject.GetComponent <Rigidbody>()) { if (itemCache.MatchRangedStyle(TheForest.Items.Item.RangedStyle.Shoot)) { gameObject.GetComponent <Rigidbody>().AddForce(gameObject.transform.TransformDirection(Vector3.forward * (0.016666f / Time.fixedDeltaTime) * ModdedPlayer.instance.ProjectileSpeedRatio * itemCache._projectileThrowForceRange), ForceMode.VelocityChange); } else { float num = Time.time - _weaponChargeStartTime; if (ForestVR.Enabled) { gameObject.GetComponent <Rigidbody>().AddForce(inventoryItemView2._held.transform.up * ModdedPlayer.instance.ProjectileSpeedRatio * itemCache._projectileThrowForceRange); } else { gameObject.GetComponent <Rigidbody>().AddForce(inventoryItemView2._held.transform.up * ModdedPlayer.instance.ProjectileSpeedRatio * Mathf.Clamp01(num / itemCache._projectileMaxChargeDuration) * (0.016666f / Time.fixedDeltaTime) * itemCache._projectileThrowForceRange); } if (LocalPlayer.Inventory.HasInSlot(TheForest.Items.Item.EquipmentSlot.RightHand, LocalPlayer.AnimControl._bowId)) { gameObject.SendMessage("setCraftedBowDamage", SendMessageOptions.DontRequireReceiver); } } inventoryItemView._held.SendMessage("OnAmmoFired", gameObject, SendMessageOptions.DontRequireReceiver); } if (itemCache._attackReleaseSFX != 0) { LocalPlayer.Sfx.SendMessage(itemCache._attackReleaseSFX.ToString(), SendMessageOptions.DontRequireReceiver); } Mood.HitRumble(); } else { flag2 = true; if (itemCache._dryFireSFX != 0) { LocalPlayer.Sfx.SendMessage(itemCache._dryFireSFX.ToString(), SendMessageOptions.DontRequireReceiver); } } } if (flag) { UnequipItemAtSlot(itemCache._equipmentSlot, false, false, flag); } else { ToggleAmmo(inventoryItemView, true); } _weaponChargeStartTime = 0f; SetReloadDelay((!flag2) ? itemCache._reloadDuration : itemCache._dryFireReloadDuration); _isThrowing = false; }
private void Update() { if (ModAPI.Input.GetButtonDown("EquipWeapon")) { if (Inventory.Instance.ItemSlots[-12] != null && Inventory.Instance.ItemSlots[-12].Equipped) { PlayerInventoryMod.ToEquipWeaponType = Inventory.Instance.ItemSlots[-12].weaponModel; switch (Inventory.Instance.ItemSlots[-12].weaponModel) { case BaseItem.WeaponModelType.Polearm: LocalPlayer.Inventory.StashEquipedWeapon(false); LocalPlayer.Inventory.Equip(56, false); break; case BaseItem.WeaponModelType.Greatbow: LocalPlayer.Inventory.StashEquipedWeapon(false); if (CustomBowBase.baseBow == null) { PlayerInventoryMod.ToEquipWeaponType = BaseItem.WeaponModelType.None; LocalPlayer.Inventory.Equip(79, false); } else if (LocalPlayer.Inventory.Equip(79, false)) { CustomBowBase.baseBow.SetActive(false); if (GreatBow.instance != null) { GreatBow.instance.SetActive(true); } #if Debugging_Enabled else { ModAPI.Console.Write("No Greatbow instance"); } #endif } #if Debugging_Enabled else { ModAPI.Log.Write("Trying to equip a greatbow but no crafted bow in inventory"); } #endif break; default: LocalPlayer.Inventory.StashEquipedWeapon(false); LocalPlayer.Inventory.Equip(80, false); break; } PlayerInventoryMod.ToEquipWeaponType = BaseItem.WeaponModelType.None; } } try { float dmgPerSecond = 0; int poisonCount = 0; lostArmor = 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 (stats.debuffImmunity > 0 && buff.isNegative && buff.DispellAmount <= 2) { BuffDB.activeBuffs[keys[i]].ForceEndBuff(keys[i]); continue; } else if (stats.debuffResistance > 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; } else if (buff._ID == 21) { lostArmor -= buff.amount; } } } if (dmgPerSecond != 0) { dmgPerSecond *= stats.magicDamageTaken; dmgPerSecond *= Stats.allDamageTaken; 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(10, true, PlayerStats.DamageType.Drowning); } } catch (Exception e) { //ModAPI.Log.Write("Poisoning player error" + e.ToString()); } if (LocalPlayer.Stats != null) { if (Stats.perk_danceOfFiregod && Effects.BlackFlame.IsOn) { LocalPlayer.Animator.speed = 1.0f; return; } float ats = stats.attackSpeed; if (GreatBow.isEnabled) { ats /= 2f; } if (LocalPlayer.Stats.Stamina > 4) { LocalPlayer.Animator.speed = ats; } else { LocalPlayer.Animator.speed = Mathf.Min(0.5f, ats / 2); } if (LocalPlayer.Stats.Health < stats.TotalMaxHealth) { if (LocalPlayer.Stats.Health < LocalPlayer.Stats.HealthTarget) { LocalPlayer.Stats.Health += stats.healthRecoveryPerSecond * (stats.healthPerSecRate) * stats.allRecoveryMult; } else { LocalPlayer.Stats.Health += stats.healthRecoveryPerSecond * (stats.healthPerSecRate) * stats.allRecoveryMult / 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 (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 (stats.rooted) { if (stats.stunImmunity > 0 || stats.rootImmunity > 0) { stats.rooted.Reset(); if (!stats.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) { Stats.rooted.Reset(); if (!Stats.stunned) { LocalPlayer.Rigidbody.isKinematic = false; LocalPlayer.Rigidbody.useGravity = true; LocalPlayer.Rigidbody.WakeUp(); LocalPlayer.FpCharacter.MovementLocked = false; LocalPlayer.FpCharacter.CanJump = true; } } } if (Stats.stunned) { if (stats.stunImmunity > 0) { Stats.stunned.Reset(); LocalPlayer.FpCharacter.Locked = false; if (!Stats.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) { Stats.stunned.Reset(); LocalPlayer.FpCharacter.Locked = false; if (!Stats.rooted) { LocalPlayer.FpCharacter.MovementLocked = false; LocalPlayer.FpCharacter.CanJump = true; LocalPlayer.Rigidbody.isKinematic = false; LocalPlayer.Rigidbody.useGravity = true; LocalPlayer.Rigidbody.WakeUp(); } } } if (stats.i_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 * stats.TotalMaxHealth * 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.4f, 1f); AddBuff(11, 42, 1.4f, 1f); } } } if (stats.i_DeathPact_Enabled) { Stats.allDamage.Divide(_DeathPact_Amount); _DeathPact_Amount = 1 + Mathf.RoundToInt((1 - (LocalPlayer.Stats.Health / Stats.TotalMaxHealth)) * 100) * 0.03f; AddBuff(12, 43, _DeathPact_Amount, 1f); Stats.allDamage.Multiply(_DeathPact_Amount); } else if (_DeathPact_Amount != 1) { Stats.allDamage.Divide(_DeathPact_Amount); _DeathPact_Amount = 1; } if (stats.i_isGreed) { _greedCooldown -= Time.deltaTime; if (_greedCooldown < 0) { AutoPickupItems.DoPickup(); _greedCooldown = 1f; } } if (stats.perk_isShieldAutocast) { float mx = stats.TotalMaxEnergy * 0.90f; if (LocalPlayer.Stats.Energy >= mx) { if (LocalPlayer.Stats.Stamina >= mx) { var spell = SpellDataBase.spellDictionary[5]; if (spell.IsEquipped) { if (SpellCaster.RemoveStamina(10 * Time.deltaTime)) { spell.active(); } } } } } }
protected override void fireProjectile() { int repeats = 1; if (Effects.Multishot.IsOn) { if (SpellCaster.RemoveStamina(5 * ModdedPlayer.instance.MultishotCount * ModdedPlayer.instance.MultishotCount)) { repeats += ModdedPlayer.instance.MultishotCount; } else { Effects.Multishot.IsOn = false; Effects.Multishot.localPlayerInstance.SetActive(false); } } for (int i = 0; i < repeats; i++) { if (LocalPlayer.Inventory.RemoveItem(_ammoId, 1, false, true)) { Vector3 position = _ammoSpawnPosGo.transform.position; if (i > 0) { position += 0.5f * _ammoSpawnPosGo.transform.up * (i + 1) / 3; position += 0.5f * _ammoSpawnPosGo.transform.right * (((i - 1) % 3) - 1); } Quaternion rotation = _ammoSpawnPosGo.transform.rotation; GameObject gameObject = Object.Instantiate(_boltProjectile, position, rotation); gameObject.transform.localScale *= ModdedPlayer.instance.ProjectileSizeRatio; gameObject.AddComponent <ProjectileIgnoreCollision>(); Rigidbody component = gameObject.GetComponent <Rigidbody>(); if (BoltNetwork.isRunning) { BoltEntity component2 = gameObject.GetComponent <BoltEntity>(); if ((bool)component2) { BoltNetwork.Attach(gameObject); } } PickUp componentInChildren = gameObject.GetComponentInChildren <PickUp>(true); if ((bool)componentInChildren) { SheenBillboard[] componentsInChildren = gameObject.GetComponentsInChildren <SheenBillboard>(); SheenBillboard[] array = componentsInChildren; foreach (SheenBillboard sheenBillboard in array) { sheenBillboard.gameObject.SetActive(false); } componentInChildren.gameObject.SetActive(false); if (base.gameObject.activeInHierarchy) { base.StartCoroutine(enablePickupTrigger(componentInChildren.gameObject)); } } Vector3 up = gameObject.transform.up; component.AddForce(22000f * ModdedPlayer.instance.ProjectileSpeedRatio * (0.016666f / Time.fixedDeltaTime) * up); } } }