Beispiel #1
0
        public void spellDam(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitInstance)
        {
            if (hitInstance.AttackType == AttackTypes.Spell && hitInstance.Source.name.StartsWith("bullet"))
            {
                Log("Bullet impact with name " + hitInstance.Source.name);
                BulletBehavior b = fireball.GetComponent <BulletBehavior>();
                if (!b.enemyHit())
                {
                    return;
                }
                if (self.IsBlockingByDirection(
                        DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(self.transform)),
                        hitInstance.AttackType))
                {
                    orig(self, hitInstance);
                    return;
                }

                hitEnemy(self, b.bulletType.Damage, hitInstance, b.bulletType.SoulGain);
            }
            else
            {
                orig(self, hitInstance);
            }
        }
Beispiel #2
0
        public static HitInfo ConvertHitInstance(HitInstance hitInstance, Transform target = null)
        {
            int instanceAttackType = (int)hitInstance.AttackType;

            var attackType = (AttackType)instanceAttackType;

            return(new HitInfo()
            {
                Attacker = hitInstance.Source,
                AttackStrength = hitInstance.MagnitudeMultiplier,
                AttackType = attackType,
                Damage = hitInstance.DamageDealt,
                Direction = hitInstance.GetActualDirection(target),
                IgnoreInvincible = hitInstance.IgnoreInvulnerable
            });
        }
Beispiel #3
0
        // This function does damage to the enemy using the damage numbers given by the weapon type
        public static void HitEnemy(HealthManager targetHP, int expectedDamage, HitInstance hitInstance, int soulGain)
        {
            int realDamage = expectedDamage;

            //TODO: this specifics might add up later, Moss Charger is just one of the few except and there maybe many more
            int        cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform));
            GameObject blockHitPrefab    = targetHP.GetAttr <GameObject>("blockHitPrefab");

            bool specialEnemy = (targetHP.name.Contains("Charger"));

            if (targetHP.IsBlockingByDirection(cardinalDirection, AttackTypes.Nail) && !specialEnemy || realDamage <= 0)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "BLOCKED HIT", false);
                GameObject blockHit = blockHitPrefab.Spawn();
                blockHit.transform.position = targetHP.transform.position;
                blockHit.transform.Rotate(new Vector3(0, 0, 90 * cardinalDirection));
                return;
            }



            //bool specialEnemy = (targetHP.name.Contains("Moss Charger") || targetHP.name.Contains("Mushroom Brawler"));

            //if (targetHP.IsInvincible && !specialEnemy && !PlayerData.instance.equippedCharm_25)
            //{
            //    GameObject blockHit = blockHitPrefab.Spawn();
            //    blockHit.transform.position = targetHP.transform.position;
            //   return;
            //}

            if (targetHP.gameObject.name.Contains("Blocker"))
            {
                realDamage = realDamage * 4;
            }

            Recoil recoil = targetHP.gameObject.GetComponent <Recoil>();

            if (recoil != null && PlayerData.instance.equippedCharm_15)
            {
                recoil.RecoilByDirection(cardinalDirection, 0.8f);
            }

            if (realDamage <= 0)
            {
                return;
            }

            if (targetHP == null)
            {
                return;
            }

            /*
             * Play animations and such...
             * Mostly code copied from the healthmanager class itself.
             */

            //Modding.Logger.Log("Cardinal is " + cardinalDirection);
            FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO");

            if (sendHitGO != null)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            }

            GameObject HitPrefab    = targetHP.GetAttr <GameObject>("strikeNailPrefab");
            GameObject ImpactPrefab = targetHP.GetAttr <GameObject>("slashImpactPrefab");
            Vector3?   effectOrigin = targetHP.GetAttr <Vector3?>("effectOrigin");

            if (HitPrefab != null && effectOrigin != null)
            {
                HitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }
            if (ImpactPrefab != null && effectOrigin != null)
            {
                ImpactPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false);
            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TAKE DAMAGE", false);

            FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false);
            FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false);


            // Actually do damage to target.
            try
            {
                //TODO: change this audio source
                //HeroController.instance.spellControl.gameObject.GetComponent<AudioSource>().PlayOneShot(LoadAssets.enemyHurtSFX[soundRandom.Next(0, 2)]);
                LoadAssets.sfxDictionary.TryGetValue("enemyhurt" + soundRandom.Next(1, 4) + ".wav", out AudioClip ac);
                HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(ac);
            }
            catch (Exception e)
            {
                Modding.Logger.Log("Enemy Hurt Exception Thrown " + e);
            }

            if (targetHP.damageOverride)
            {
                targetHP.hp -= 1;
            }
            else
            {
                targetHP.hp -= realDamage; // the actual damage
                HeroController.instance.AddMPCharge(soulGain);
            }

            // Trigger Kill animation
            if (targetHP.hp <= 0f)
            {
                LoadAssets.sfxDictionary.TryGetValue("enemydead" + soundRandom.Next(1, 4) + ".wav", out AudioClip ac);
                HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(ac);
                targetHP.Die(cardinalDirection * 90, AttackTypes.Spell, true);
                HeroController.instance.AddMPCharge(3);
                return;
            }


            bool?  hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation");
            string alternateHitAnimation    = targetHP.GetAttr <string>("alternateHitAnimation");

            if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null)
            {
                targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation);
            }


            PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component =>
                                                                                                            component.FsmName == "Stun Control" || component.FsmName == "Stun");

            if (stunControlFSM != null)
            {
                //stunControlFSM.SendEvent("STUN DAMAGE");
            }

            /*
             * Uncomment below for a sick looking enter the gungeon style freeze frame or for camera shake.
             */
            //GameManager.instance.FreezeMoment(1);
            //GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
            SpriteFlash f = targetHP.gameObject.GetComponent <SpriteFlash>();

            if (f != null)
            {
                f.flashInfected();
            }
        }
Beispiel #4
0
        // This function does damage to the enemy using the damage numbers given by the weapon type
        public static void HitEnemy(HealthManager targetHP, int damageDealt, HitInstance hitInstance, int soulGain, BulletBehaviour hpbb)
        {
            //TODO: this specifics might add up later, Moss Charger is just one of the few except and there maybe many more
            if (targetHP == null)
            {
                return;
            }

            int        cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform));
            GameObject blockHitPrefab    = targetHP.GetAttr <GameObject>("blockHitPrefab");

            bool specialEnemy = (targetHP.name.Contains("Charger"));

            if (targetHP.IsBlockingByDirection(cardinalDirection, AttackTypes.Nail) && !specialEnemy || damageDealt <= 0)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "BLOCKED HIT", false);
                GameObject blockHit = blockHitPrefab.Spawn();
                blockHit.transform.position = targetHP.transform.position;
                blockHit.transform.Rotate(new Vector3(0, 0, 90 * cardinalDirection));
                return;
            }

            if (damageDealt <= 0)
            {
                return;
            }
            //bool specialEnemy = (targetHP.name.Contains("Moss Charger") || targetHP.name.Contains("Mushroom Brawler"));

            /*
             * if (targetHP.IsInvincible && !specialEnemy && !PlayerData.instance.equippedCharm_25)
             * {
             *  GameObject blockHit = blockHitPrefab.Spawn();
             *  blockHit.transform.position = targetHP.transform.position;
             * return;
             * }
             */

            if (targetHP.gameObject.name.Contains("Blocker")) //double damage baldurs
            {
                damageDealt = damageDealt * 4;
            }

            Recoil recoil = targetHP.gameObject.GetComponent <Recoil>();

            //if (recoil != null && PlayerData.instance.equippedCharm_15)
            if (recoil != null)
            {
                recoil.RecoilByDirection(cardinalDirection, 0.25f);
            }

            /*
             * Mostly code copied from the healthmanager class itself.
             */

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO");

            if (sendHitGO != null)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            }

            GameObject HitPrefab    = targetHP.GetAttr <GameObject>("strikeNailPrefab");
            GameObject ImpactPrefab = targetHP.GetAttr <GameObject>("slashImpactPrefab");
            Vector3?   effectOrigin = targetHP.GetAttr <Vector3?>("effectOrigin");

            if (HitPrefab != null && effectOrigin != null)
            {
                HitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }
            if (ImpactPrefab != null && effectOrigin != null)
            {
                ImpactPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }

            SpriteFlash f = targetHP.gameObject.GetComponent <SpriteFlash>();

            if (f != null)
            {
                f.flashWhiteQuick();
            }

            //Log("SEVERITY: " + ds + " DAMAGE: " + damageDealt);

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false);
            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TAKE DAMAGE", false);

            FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false);
            FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false);

            // Actually do damage to target.

            LoadAssets.sfxDictionary.TryGetValue("enemyhurt" + soundRandom.Next(1, 4) + ".wav", out AudioClip hurtSound);
            HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(hurtSound);

            if (targetHP.damageOverride)
            {
                targetHP.hp -= 1;
            }
            else
            {
                targetHP.hp -= damageDealt; // the actual damage

                //int sg = (ds.Equals(DamageSeverity.Minor)) ? 0 : soulGain;
                HeroController.instance.AddMPCharge(6);
                Stats.IncreaseAdrenalinePoints(damageDealt);
            }

            // Trigger Kill animation
            if (targetHP.hp <= 0f)
            {
                LoadAssets.sfxDictionary.TryGetValue("enemydead" + soundRandom.Next(1, 4) + ".wav", out AudioClip deadSound);
                HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(deadSound);
                targetHP.Die(cardinalDirection * 90, AttackTypes.Spell, true);
                HeroController.instance.AddMPCharge(4);
                GameManager.instance.FreezeMoment(1);
                return;
            }

            bool?  hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation");
            string alternateHitAnimation    = targetHP.GetAttr <string>("alternateHitAnimation");

            if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null)
            {
                targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation);
            }


            PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component =>
                                                                                                            component.FsmName == "Stun Control" || component.FsmName == "Stun");

            if (stunControlFSM != null)
            {
                //stunControlFSM.SendEvent("STUN DAMAGE");
            }

            /*
             * Uncomment below for a sick looking enter the gungeon style freeze frame or for camera shake.
             */
        }
Beispiel #5
0
        //Intercepts HealthManager's Hit method and allows me to override it with my own calculation
        public void HealthManager_HitHook(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitInstance)
        {
            //Alternative hit damages from other sources like weaver or explosions

            string srcName = hitInstance.Source.name;

            Log("[DamageOverride] Source Name is " + srcName);
            if (srcName.Contains("Gas"))
            {
                //Explosion damage
                hitInstance.DamageDealt = 15 + (PlayerData.instance.nailSmithUpgrades * 5);
                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Damager"))
            {
                //Glowing Womblings
                HeroController.instance.AddMPCharge(15);
                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Slash"))
            {
                Log("Player is slashing!");
                hitInstance.DamageDealt = 2 + (PlayerData.instance.nailSmithUpgrades * 2);
                orig(self, hitInstance);
                return;
            }
            else if (!srcName.Contains("bullet"))
            {
                orig(self, hitInstance);
                return;
            }

            BulletBehaviour hpbb = hitInstance.Source.GetComponent <BulletBehaviour>();
            Vector3         bulletOriginPosition = hitInstance.Source.GetComponent <BulletBehaviour>().bulletOriginPosition;
            int             cardinalDirection    = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(self.transform));

            int damage      = Stats.CalculateDamage(bulletOriginPosition, self.transform.position, hpbb);
            int soulGainAmt = Stats.CalculateSoulGain();

            //Log("DamageCalculator, damage dealt is " + damage + " against " + self.name);
            StartCoroutine(SplatterBlood(self.gameObject, 1, cardinalDirection * 90));

            HealthManagerOverride.HitEnemy(self, damage, BulletBehaviour.bulletDummyHitInstance, soulGainAmt, hpbb);
        }
Beispiel #6
0
        // This function does damage to the enemy using the damage numbers given by the weapon type
        public static void hitEnemy(HealthManager targetHP, int expectedDamage, HitInstance hitInstance, int soulGain)
        {
            int realDamage = expectedDamage;

            // TODO: Add possible optional damage multiplier information below.

            /*
             * double multiplier = 1;
             * if (PlayerData.instance.GetBool("equippedCharm_25"))
             * {
             *  multiplier *= 1.5;
             * }
             * if (PlayerData.instance.GetBool("equippedCharm_6") && PlayerData.instance.GetInt("health") == 1)
             * {
             *  multiplier *= 1.75f;
             * }
             *
             * if (gng_bindings.hasNailBinding())
             * {
             *  multiplier *= 0.3;
             * }
             * realDamage = (int) Math.Round(realDamage * multiplier);
             *
             */

            if (realDamage <= 0)
            {
                return;
            }

            if (targetHP == null)
            {
                return;
            }


            /*
             * Play animations and such...
             * Mostly code copied from the healthmanager class itself.
             */

            int cardinalDirection =
                DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform));

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);


            GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO");

            if (sendHitGO != null)
            {
                Log("Wow I did reflection correctly");
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            }

            GameObject fireballHitPrefab = targetHP.GetAttr <GameObject>("fireballHitPrefab");
            Vector3?   effectOrigin      = targetHP.GetAttr <Vector3?>("effectOrigin");

            if (fireballHitPrefab != null && effectOrigin != null)
            {
                Log("Wow I did reflection correctly x2");
                fireballHitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }


            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false);

            if ((UnityEngine.Object)targetHP.GetComponent <Recoil>() != (UnityEngine.Object)null)
            {
                targetHP.GetComponent <Recoil>().RecoilByDirection(cardinalDirection, hitInstance.MagnitudeMultiplier);
            }

            FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false);
            FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false);



            // Actually do damage to target.
            if (targetHP.damageOverride)
            {
                targetHP.hp -= 1;
            }
            else
            {
                targetHP.hp -= realDamage;
                HeroController.instance.AddMPCharge(soulGain);
            }

            // Trigger Kill animation
            if (targetHP.hp <= 0f)
            {
                targetHP.Die(0f, AttackTypes.Nail, true);
                return;
            }

            bool?  hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation");
            string alternateHitAnimation    = targetHP.GetAttr <string>("alternateHitAnimation");

            if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null)
            {
                Log("Wow I did reflection correctly x3");
                targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation);
            }

            PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component =>
                                                                                                            component.FsmName == "Stun Control" || component.FsmName == "Stun");

            if (stunControlFSM != null)
            {
                stunControlFSM.SendEvent("STUN DAMAGE");
            }

            /*
             * Uncomment below for a sick looking enter the gungeon style freeze frame or for camera shake.
             */

            //GameManager.instance.FreezeMoment(1);
            //GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
        }
Beispiel #7
0
        //Intercepts HealthManager's Hit method and allows me to override it with my own calculation
        public void HealthManager_HitHook(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitInstance)
        {
            //Alternative hit damages from other sources like weaver or explosions
            string srcName = hitInstance.Source.name;

            if (srcName.Contains("Gas"))
            {
                //Explosion damage
                hitInstance.DamageDealt = 3 + (PlayerData.instance.nailSmithUpgrades * 5);
                orig(self, hitInstance);
                return;
            }
            if (srcName.Contains("Dung"))
            {
                //Explosion damage
                Log("Dung damage!");
                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Damager"))
            {
                //Glowing Womblings
                //HeroController.instance.AddMPCharge(15);
                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Great Slash") || srcName.Contains("Dash Slash"))
            {
                Log("Player is nail art... ing?");


                orig(self, hitInstance);
                return;
            }
            else if (srcName.Contains("Slash"))
            {
                Log("Player is slashing!");
                hitInstance.DamageDealt = 3 + (PlayerData.instance.nailSmithUpgrades * 3);
                orig(self, hitInstance);
                return;
            }
            else if (!srcName.Contains("bullet"))
            {
                orig(self, hitInstance);
                return;
            }

            BulletBehaviour hpbb = hitInstance.Source.GetComponent <BulletBehaviour>();
            Vector3         bulletOriginPosition = hitInstance.Source.GetComponent <BulletBehaviour>().bulletOriginPosition;
            int             cardinalDirection    = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(self.transform));

            int damage      = hpbb.bulletDamage + (PlayerData.instance.nailSmithUpgrades * hpbb.bulletDamageScale);
            int soulGainAmt = Stats.SoulGainPerHit();

            //StartCoroutine(SplatterBlood(self.gameObject.transform.position, 1, cardinalDirection * 90));
            if (hpbb.appliesDamageOvertime)
            {
                EnemyDamageOvertime edo = self.gameObject.GetComponent <EnemyDamageOvertime>();

                if (edo == null)
                {
                    self.gameObject.AddComponent <EnemyDamageOvertime>();
                }
                else
                {
                    edo.IncreaseStack();
                }
            }
            DamageEnemyOverride(self, damage, BulletBehaviour.bulletDummyHitInstance, soulGainAmt, hpbb);
        }
Beispiel #8
0
        //+++DAMAGE OVERRIDE+++
        public static void DamageEnemyOverride(HealthManager targetHP, int damageDealt, HitInstance hitInstance, int soulGain, BulletBehaviour hpbb)
        {
            //TODO: this specifics might add up later, Moss Charger is just one of the few except and there maybe many more
            if (targetHP == null)
            {
                return;
            }

            int        cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(targetHP.transform));
            GameObject blockHitPrefab    = targetHP.GetAttr <GameObject>("blockHitPrefab");

            bool specialEnemy = (targetHP.name.Contains("Charger"));

            if (targetHP.IsBlockingByDirection(cardinalDirection, AttackTypes.Nail) && !specialEnemy)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "BLOCKED HIT", false);
                GameObject blockHit = blockHitPrefab.Spawn();
                blockHit.transform.position = targetHP.transform.position;
                blockHit.transform.Rotate(new Vector3(0, 0, 90 * cardinalDirection));
                return;
            }

            if (false && !targetHP.IsInvincible) //enable disable damage overtime
            {
                EnemyDamageOvertime dm = targetHP.gameObject.GetComponent <EnemyDamageOvertime>();
                if (dm == null)
                {
                    targetHP.gameObject.AddComponent <EnemyDamageOvertime>();
                }
                else
                {
                    dm.IncreaseStack();
                }
            }

            //bool specialEnemy = (targetHP.name.Contains("Moss Charger") || targetHP.name.Contains("Mushroom Brawler"));

            /*
             * if (targetHP.IsInvincible && !specialEnemy && !PlayerData.instance.equippedCharm_25)
             * {
             *  GameObject blockHit = blockHitPrefab.Spawn();
             *  blockHit.transform.position = targetHP.transform.position;
             * return;
             * }
             */
            if (targetHP.gameObject.name.Contains("Blocker")) //double damage baldurs
            {
                damageDealt = damageDealt * 4;
            }

            Recoil recoil = targetHP.gameObject.GetComponent <Recoil>();

            //if (recoil != null && PlayerData.instance.equippedCharm_15)
            if (recoil != null)
            {
                recoil.RecoilByDirection(cardinalDirection, 0.25f);
            }

            /*
             * Mostly code copied from the healthmanager class itself.
             */

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            GameObject sendHitGO = targetHP.GetAttr <GameObject>("sendHitGO");

            if (sendHitGO != null)
            {
                FSMUtility.SendEventToGameObject(targetHP.gameObject, "HIT", false);
            }

            GameObject HitPrefab    = targetHP.GetAttr <GameObject>("strikeNailPrefab");
            GameObject ImpactPrefab = targetHP.GetAttr <GameObject>("slashImpactPrefab");
            Vector3?   effectOrigin = targetHP.GetAttr <Vector3?>("effectOrigin");

            if (HitPrefab != null && effectOrigin != null)
            {
                HitPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }
            if (ImpactPrefab != null && effectOrigin != null)
            {
                ImpactPrefab.Spawn(targetHP.transform.position + (Vector3)effectOrigin, Quaternion.identity).transform.SetPositionZ(0.0031f);
            }
            SpriteFlash f = targetHP.gameObject.GetComponent <SpriteFlash>();

            if (f != null)
            {
                f.flashWhiteQuick();
            }

            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TOOK DAMAGE", false);
            FSMUtility.SendEventToGameObject(targetHP.gameObject, "TAKE DAMAGE", false);
            FSMUtility.SendEventToGameObject(hitInstance.Source, "HIT LANDED", false);
            FSMUtility.SendEventToGameObject(hitInstance.Source, "DEALT DAMAGE", false);

            // Actually do damage to target.
            LoadAssets.sfxDictionary.TryGetValue("enemyhurt" + rand.Next(1, 4) + ".wav", out AudioClip hurtSound);
            HeroController.instance.spellControl.gameObject.GetComponent <AudioSource>().PlayOneShot(hurtSound);

            if (targetHP.damageOverride)
            {
                targetHP.hp -= 1;
            }
            else
            {
                targetHP.hp -= damageDealt; // the actual damage
                if (hpbb.canGainEnergyCharges)
                {
                    HeroController.instance.AddMPCharge(Stats.instance.current_soulGainedPerHit);
                }
                Stats.instance.IncreaseAdrenalineChargeEnergy();
                //TODO: change this audio source location to the sound handler
                AudioHandler.instance.PlayMiscSoundEffect(AudioHandler.HollowPointSoundType.EnemyHitSFXGO);
            }
            // Trigger Enemy Kill
            if (targetHP.hp <= 0f)
            {
                EnemyDeathEvent(targetHP, cardinalDirection, true);
                return;
            }

            bool?  hasAlternateHitAnimation = targetHP.GetAttr <bool?>("hasAlternateHitAnimation");
            string alternateHitAnimation    = targetHP.GetAttr <string>("alternateHitAnimation");

            if (hasAlternateHitAnimation != null && (bool)hasAlternateHitAnimation && targetHP.GetComponent <tk2dSpriteAnimator>() && alternateHitAnimation != null)
            {
                targetHP.GetComponent <tk2dSpriteAnimator>().Play(alternateHitAnimation);
            }

            PlayMakerFSM stunControlFSM = targetHP.gameObject.GetComponents <PlayMakerFSM>().FirstOrDefault(component => component.FsmName == "Stun Control" || component.FsmName == "Stun");
            //if (stunControlFSM != null) stunControlFSM.SendEvent("STUN DAMAGE");
        }