Blade & Sorcery
0 of 0

File information

Last updated

Original upload

Created by

Ebediam

Uploaded by

Ebediam

Virus scan

Safe to use

Tags for this mod

About this mod

This game is severely lacking in Super Mario theme weapons, so I made the POW Hammer! Hit anything with the POW block and send enemies flying, just like in Super Mario!

Permissions and credits
Changelogs
Here's the code. I'll comment it if you guys are interested (tell me in the comments):

public class ItemPOW : MonoBehaviour
    {
        protected Item item;
        protected ItemModulePOW module;
        public float forceMultiplier;
        public Collider POW;
        public float POWTimer = 0f;
        public float POWCooldown = 0.5f;
        public int i = 0;

        protected void Awake()
        {
            item = this.GetComponent<Item>();
            POW = item.GetComponentsInChildren<Collider>()[2];


            item.OnCollisionEvent += OnPOWCollisionEvent;
            module = item.data.GetModule<ItemModulePOW>();
            forceMultiplier = module.forceMultiplier;
   

        }

        void OnPOWCollisionEvent(ref CollisionStruct collisionInstance)
        {
            if(collisionInstance.sourceCollider == POW || collisionInstance.targetCollider == POW)
            {
                if (POWTimer > POWCooldown)
                {
                    POWTimer = 0f;
                    foreach (Creature npc in Creature.list)
                    {
                        if (npc != Creature.player)
                        {
                            if (npc.state == Creature.State.Alive || (npc.state == Creature.State.KnockedOut && npc.ragdoll.isGrounded) || (npc.state == Creature.State.Dead && npc.ragdoll.state == BS.Ragdoll.State.Dead))
                            {
                                if (npc.state == Creature.State.Alive)
                                {
                                    npc.ragdoll.SetState(BS.Ragdoll.State.Fallen);
                                }
                                if(npc.state == Creature.State.Dead)
                                {
                                    npc.ragdoll.SetState(BS.Ragdoll.State.Fallen);
                                }
                                foreach (RagdollPart ragdollPart in npc.ragdoll.parts)
                                {
                                    ragdollPart.rb.AddForce(Vector3.up * forceMultiplier, ForceMode.Impulse);

                                }

                            }
                        }
                    }
                }
            }           
        }

        void FixedUpdate()
        {
            foreach (Creature npc in Creature.list)
            {
                if(npc.ragdoll.isGrounded && npc.state == Creature.State.Dead)
                {
                    npc.ragdoll.state = BS.Ragdoll.State.Dead;
                    npc.ragdoll.isGrounded = false;
                }
            }
            POWTimer += Time.deltaTime;
            
        }
}