private static void TryCharge(SpellCasterHand hand) { if (hand && hand.currentSpell is SpellLightning) { if (hand.bodyHand && hand.bodyHand.interactor && hand.bodyHand.interactor.grabbedHandle) { bool tryCast = hand.caster.creature == Creature.player && PlayerControl.GetHand(hand.bodyHand.side).indexCurl > 0.5f; SpellLightning spell = hand.currentSpell as SpellLightning; if (hand.bodyHand.interactor.grabbedHandle.item) { if (tryCast || Electrical.ItemChargeSettings.autoCharge || hand.caster.creature != Creature.player) { float manaCost = Electrical.ItemChargeSettings.manaPerSec * Time.deltaTime; if (hand.caster.currentMana > manaCost) { hand.caster.currentMana -= manaCost; Item item = hand.bodyHand.interactor.grabbedHandle.item; ChargeItem(item); // If we're holding a bow, charge nocked arrows too var bowString = item.GetComponentInChildren <BowString>(); if (bowString) { if (bowString.nockedArrow) { ChargeItem(bowString.nockedArrow); } } } } } if (hand.bodyHand.interactor.grabbedHandle is RagdollHandle && tryCast) { float manaCost = Electrical.RagdollChargeSettings.manaPerSec * Time.deltaTime; if (hand.caster.currentMana > manaCost) { var ragdollHandle = hand.bodyHand.interactor.grabbedHandle as RagdollHandle; DamageStruct shockDamage = spell.damageStruct; shockDamage.damage = Electrical.RagdollChargeSettings.damagePerSec * Time.deltaTime; shockDamage.hitRagdollPart = ragdollHandle.ragdollPart; CollisionStruct spellCollision = new CollisionStruct(shockDamage); ragdollHandle.ragdollPart.ragdoll.creature.health.Damage(ref spellCollision); } } } } }
private static void TryLevitate(SpellCasterHand casterHand) { var hand = casterHand.bodyHand; if (casterHand.force > 0.1f && !Player.local.locomotion.isGrounded && hand.interactor.grabbedHandle == null) { Vector3 direction = (hand.bone.parent.position - hand.bone.position).normalized; var thrustMod = Electrical.LevitationSettings.thrust * Time.deltaTime * casterHand.force; if (casterHand.caster.currentMana < 5f) { thrustMod *= 0.5f; } Player.local.locomotion.rb.AddForceAtPosition(direction * thrustMod, hand.bone.transform.position, ForceMode.VelocityChange); } }
public override void Load(SpellData.Instance spellDataInstance, SpellCasterHand handCaster) { spellCasterHand = handCaster; base.Load(spellDataInstance, handCaster); }