Esempio n. 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);
            }
        }
Esempio n. 2
0
        void OnEnemyCollision(GameObject other, Vector3 normal)
        {
            Dev.Where();
            HitInstance hit = ImpactHit;

            hit.DamageDealt = (int)(blowVelocity.magnitude * .25f);

            //1011
            //if( ( other.layer & 11 ) > 0 )
            {
                Rigidbody2D rb = other.GetComponentInParent <Rigidbody2D>();
                if (rb != null)
                {
                    bool isEnemy = rb.gameObject.IsGameEnemy();
                    if (!isEnemy)
                    {
                        return;
                    }

                    blowVelocity = normal * blowVelocity.magnitude;
                    rb.gameObject.GetOrAddComponent <TakeDamageFromImpact>().blowVelocity = blowVelocity;
                    rb.gameObject.GetOrAddComponent <PreventOutOfBounds>();
                    DamageEnemies dme = rb.gameObject.GetOrAddComponent <DamageEnemies>();
                    dme.damageDealt = (int)blowVelocity.magnitude;
                    HealthManager.Hit(hit);
                }
            }
        }
        private HitInstance playerHitTracker(Fsm owner, HitInstance hit)
        {
            //log("kin hp is " + enemyHM.hp);

            if (!didTakeDamage)
            {
                return(hit);
            }

            timeSinceLastHit = 0;

            //log("Hit enemy and did " + lastHitDamage + " dmg with a " + hit.AttackType.ToString());

            didTakeDamage = false;

            if (hit.DamageDealt != lastHitDamage)
            {
                return(hit);
            }

            AttackTypes a = hit.AttackType;

            if (a == AttackTypes.Nail || a == AttackTypes.Spell || a == AttackTypes.SharpShadow)
            {
                stunCounter++;
            }

            return(hit);
        }
Esempio n. 4
0
        //On hit effects
        private HitInstance OnHit(Fsm owner, HitInstance hit)
        {
            //Amplifies bee damage by combo.
            if (PlayerData.instance.GetBool("equippedCharm_44") && ((HeroController.instance.GetState("jumping") || HeroController.instance.GetState("falling"))))
            {
                hit.DamageDealt = (8 + beeCombo) * hit.DamageDealt / 10;
            }
            if (PlayerData.instance.GetBool("equippedCharm_42"))
            {
                //Does beetle bodyslam.
                if (PlayerData.instance.GetBool("equippedCharm_5") && (PlayerData.instance.blockerHits > 0) && ((hit.Source.name.Contains("SuperDash") || hit.Source.name.Contains("Trail Effect") || hit.Source.name.Contains("SD Burst") || hit.Source.name.Contains("Crystal Burst"))))
                {
                    hit.DamageDealt = 20 + PlayerData.instance.GetInt("nailSmithUpgrades") * 16;
                    hit.AttackType  = AttackTypes.Generic;
                    HeroController.instance.StartCoroutine(beetleBodyslam());
                    //PlayerData.instance.blockerHits -= 1;
                    //For testing.
                    //HeroController.instance.AddHealth(1);
                }
                //Multiplies beetle damage by 3 if they parried.
                else if (beetleParried)
                {
                    hit.DamageDealt = 3 * hit.DamageDealt;
                }
                //Reduces beetle damage by 20%.
                else
                {
                    hit.DamageDealt = 4 * hit.DamageDealt / 5;
                }
            }
            switch (hit.AttackType)
            {
            case AttackTypes.Nail:
            {
                //Cuts snail shaman damage in half.
                if (PlayerData.instance.GetBool("equippedCharm_41"))
                {
                    hit.DamageDealt = hit.DamageDealt / 2;
                }
                //Boosts mantis damage by 1/5th.
                if (PlayerData.instance.GetBool("equippedCharm_43"))
                {
                    hit.DamageDealt = 7 * hit.DamageDealt / 6;
                }
            }
            break;

            case AttackTypes.Spell:
            {
                //Cuts spell damage in half for mantis.
                if (PlayerData.instance.GetBool("equippedCharm_43"))
                {
                    hit.DamageDealt = hit.DamageDealt / 2;
                }
            }
            break;
            }
            return(hit);
        }
 public override void Hit(HitInstance damageInstance)
 {
     if (damageInstance.AttackType == AttackTypes.Nail)
     {
         base.Hit(damageInstance);
     }
     else
     {
         //float pitch = gameObject.GetComponent<MyTinkEffect>().pitch;
     }
 }
Esempio n. 6
0
        public bool trueTakeDamage(double trueDamage, int damageType, HitInstance ogHit, bool standardAttack)
        {
            if (trueImmortalityTimer > 0 && standardAttack)
            {
                Redwing.Knight.Log("Enemy immortal so no damage");
                return(false);
            }

            AttackTypes at;

            if (damageType < 8 && damageType > 0)
            {
                at = (AttackTypes)damageType;
            }
            else
            {
                at = AttackTypes.Spell;
            }

            bool invuln = connectedHM.IsBlockingByDirection((int)ogHit.Direction, at);

            if (invuln && !ogHit.IgnoreInvulnerable)
            {
                return(false);
            }
            Redwing.Knight.Log("Dealing " + trueDamage + " to enemy: " + gameObject.name + " via new health mgr");
            Redwing.Knight.Log("HP before dmg is " + trueHealth);
            Redwing.Knight.Log("trueImmortalityTimer is " + trueImmortalityTimer);
            trueHealth -= trueDamage;
            if (trueHealth <= 0)
            {
                connectedHM.Die(ogHit.Direction, at, true);
                return(true);
            }

            if (connectedHM.hp > (int)(trueHealth + 1.0) && damageTakenTimer < 0f)
            {
                ogHit.DamageDealt = (int)(connectedHM.hp - trueHealth);
                // Mutex locking.
                runningNewHMOH = true;
                connectedHM.Hit(ogHit);
                runningNewHMOH   = false;
                damageTakenTimer = 0.2f;
            }
            // In this special case the user actually healed the target.
            else if (connectedHM.hp < (int)(trueHealth))
            {
                connectedHM.hp = (int)trueHealth;
            }



            return(true);
        }
Esempio n. 7
0
        private HitInstance overrideAllNonFireDamage(Fsm owner, HitInstance hit)
        {
            //if (owner.GameObject.name.Contains("Plant Trap"))
            //    owner.GameObject.PrintSceneHierarchyTree("Plantmeme.txt");

            if (hit.AttackType != AttackTypes.Generic)
            {
                hit.DamageDealt = 1;
            }

            return(hit);
        }
Esempio n. 8
0
        //private void OldSetDamages()
        //{
        //    dashDamage = 5 + PlayerData.instance.nailSmithUpgrades * 4;
        //    if (PlayerData.instance.equippedCharm_16)
        //    {
        //        dashDamage *= 2;
        //    }
        //    if (PlayerData.instance.equippedCharm_25)
        //    {
        //        dashDamage = (int)((double)dashDamage * 1.5);
        //    }
        //    if (oldDashDamage != dashDamage)
        //    {
        //        Log($@"[Blackmoth] Sharp Shadow Damage set to {dashDamage}");
        //        oldDashDamage = dashDamage;
        //    }
        //    try
        //    {
        //        sharpShadowFSM.FsmVariables.GetFsmInt("damageDealt").Value = dashDamage;
        //        //sharpShadowFSM.FsmVariables.GetFsmInt("attackType").Value = 0;
        //        if (PlayerData.instance.defeatedNightmareGrimm) superDash.FsmVariables.GetFsmInt("DamageDealt").Value = dashDamage;
        //    }
        //    catch
        //    {
        //        Blackmoth.Instance.LogWarn("[Blackmoth] Sharp Shadow object not set!");
        //    }
        //    PlayerData.instance.nailDamage = 1;
        //    PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE");
        //}

        private HitInstance SetDamages(Fsm hitter, HitInstance hit)
        {
            LogDebug($@"Creating HitInstance for {hitter.Owner}");
            Fsm fsm = hitter;

            dashDamage = 5 + PlayerData.instance.GetInt("nailSmithUpgrades") * 4;
            float multiplier = 1;

            if (PlayerData.instance.hasShadowDash)
            {
                multiplier *= 2;
            }
            if (PlayerData.instance.equippedCharm_25)
            {
                multiplier *= 1.5f;
            }
            if (PlayerData.instance.equippedCharm_6 && PlayerData.instance.health == 1)
            {
                multiplier *= 1.75f;
            }
            if (oldDashDamage != dashDamage)
            {
                Log($@"[Blackmoth] Sharp Shadow Damage set to {dashDamage}");
                oldDashDamage = dashDamage;
            }
            if (sharpShadow != null && hitter.GameObject == sharpShadow)
            {
                LogDebug($@"Setting damage for {hitter.GameObject.name}");
                hit.DamageDealt         = dashDamage;
                hit.AttackType          = 0;
                hit.Multiplier          = multiplier;
                hit.Direction           = HeroController.instance.cState.facingRight ? 0 : 180;
                hit.MagnitudeMultiplier = PlayerData.instance.equippedCharm_15 ? 2f : 0f;
            }
            else if (hitter.GameObject.name.Contains("Slash"))
            {
                LogDebug($@"Setting damage for {hitter.GameObject.name}");
                hit.DamageDealt = 1;
            }
            else if (hitter.GameObject.name == superDash.gameObject.name && PlayerData.instance.GetBool("defeatedNightmareGrimm"))
            {
                LogDebug($@"Setting damage for {hitter.GameObject.name}");
                hit.DamageDealt = dashDamage;
            }
            FieldInfo[] pinfo = hit.GetType().GetFields();
            LogDebug($"{hitter.GameObject.name} HitInstance:");
            foreach (FieldInfo stat in pinfo)
            {
                LogDebug($"{stat.Name} = {stat.GetValue(hit)}");
            }
            return(hit);
        }
Esempio n. 9
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
            });
        }
Esempio n. 10
0
        private HitInstance SetDamages(Fsm owner, HitInstance hit)
        {
            bool isSpell;

            switch (hit.Source.name)
            {
            case "Fireball(Clone)":
            case "Fireball":
            case "Hit L":         // Dive
            case "Hit R":         // Dive
            case "Q Fall Damage": // Dive
            case "Hit U":         // Wraiths
                isSpell = true;
                break;

            default:
                isSpell = false;
                break;
            }

            if (isSpell)
            {
                LogDebug($"[Vanilla] Spell name: {hit.Source.name} - {hit.Source}. Damage: {hit.DamageDealt}");
                hit.DamageDealt = ls.SpellDamage(hit.DamageDealt, Settings.IntelligenceStat);
                LogDebug($"[Bonfire] Spell name: {hit.Source.name} - {hit.Source}. Damage: {hit.DamageDealt}");
            }

            if (hit.Source.name.Contains("lash"))
            {
                LogDebug($@"[Vanilla] Damage for {hit.Source.name} = {hit.DamageDealt}");
                hit.DamageDealt = ls.NailDamage(Settings.StrengthStat);
                LogDebug($@"[Bonfire] Damage for {hit.Source.name} = {hit.DamageDealt}");
                LogDebug($@"Crit chance: {ls.CritChance(Settings.LuckStat)}. Rolled {critRoll}.");
                Crit = (critRoll <= ls.CritChance(Settings.LuckStat));
                if (Crit)
                {
                    hit.DamageDealt = ls.CritDamage(Settings.DexterityStat, hit.DamageDealt);
                    LogDebug($@"[Crit] Damage for {hit.Source.name} = {hit.DamageDealt}");
                    spriteFlash.FlashGrimmflame();
                    hc.carefreeShield.SetActive(true);
                }
            }

            return(hit);
        }
Esempio n. 11
0
        void OnCollision(GameObject other, Vector3 normal)
        {
            HitInstance hit = ImpactHit;

            //hit.DamageDealt = (int)( blowVelocity.magnitude * .25f );
            hit.DamageDealt = 0;

            //1000
            if ((other.layer & (1 << 8)) > 0)
            {
                HealthManager.Hit(hit);
                if (!reflectedThisFrame)
                {
                    blowVelocity = normal * blowVelocity.magnitude;
                }
                reflectedThisFrame = true;
            }
        }
Esempio n. 12
0
        private HitInstance overrideBlackmothDamage(Fsm hitter, HitInstance hit)
        {
            if (!hitter.GameObject.name.Contains("Slash"))
            {
                return(hit);
            }
            var    nailDamage    = 5 + PlayerData.instance.GetInt("nailSmithUpgrades") * 4;
            double multiplier    = 1;
            float  fsmMultiplier = 1;

            if (PlayerData.instance.GetBool("equippedCharm_25"))
            {
                multiplier *= 1.5;
            }
            if (PlayerData.instance.GetBool("equippedCharm_6") && PlayerData.instance.GetInt("health") == 1)
            {
                fsmMultiplier = 1.75f;
            }

            if (hitter.GameObject.name.Contains("Great"))
            {
                multiplier    = 2.5 * fsmMultiplier;
                fsmMultiplier = 1;
            }

            if (hitter.GameObject.name.Contains("Dash"))
            {
                multiplier    = 2.5;
                fsmMultiplier = 1;
            }

            nailDamage = (int)Math.Round(nailDamage * multiplier);
            //log("game wants to do " + hit.DamageDealt + " dmg with multiplier " + hit.Multiplier);
            hit.DamageDealt = nailDamage;
            hit.Multiplier  = fsmMultiplier;


            //log("damage dealt is  " + nailDamage + " dmg with multiplier " + fsmMultiplier);

            //log("running override for hitter of name " + hitter.GameObject.name);

            return(hit);
        }
Esempio n. 13
0
 private void OnHit(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitinstance)
 {
     if (self.name.Contains("Shade"))
     {
         if (!_attacking)
         {
             _attacking = true;
             //float offset = FaceHero();
             Vector2 tmp = _target.transform.position;
             Vector2 pos = new Vector2(tmp.x + side * 8.5f, tmp.y);
             Teleport(pos, 20f);
         }
         _hitShade = true;
         if (_life < 0)
         {
             _control.SetState("Killed");
         }
         _life--;
         hitinstance.Multiplier = 0;
     }
     orig(self, hitinstance);
 }
        public override void OnEnter()
        {
            HitInstance hit = new HitInstance
            {
                Source              = base.Owner,
                AttackType          = (AttackTypes)this.AttackType.Value,
                CircleDirection     = this.CircleDirection.Value,
                DamageDealt         = this.DamageDealt.Value,
                Direction           = this.Direction.Value,
                IgnoreInvulnerable  = this.IgnoreInvulnerable.Value,
                MagnitudeMultiplier = this.MagnitudeMultiplier.Value,
                MoveAngle           = this.MoveAngle.Value,
                MoveDirection       = this.MoveDirection.Value,
                Multiplier          = ((!this.Multiplier.IsNone) ? this.Multiplier.Value : 1f),
                SpecialType         = (SpecialTypes)this.SpecialType.Value,
                IsExtraDamage       = false
            };

            hit = ModHooks.Instance.OnHitInstanceBeforeHit(this.Fsm, hit);
            HitTaker.Hit(this.Target.Value, hit, 3);
            base.Finish();
        }
Esempio n. 15
0
        public static void CustomEnemyHit(GameObject target, HitInstance hi, double damage = -1.0)
        {
            if (target.GetComponent <HealthManager>() == null)
            {
                Redwing.Knight.Log("Cannot target enemy, no hm for enemy named " + target.name);
                return;
            }

            newhealth nh = target.GetComponent <newhealth>();

            if (nh == null)
            {
                Redwing.Knight.Log("ERROR: No new healthmanager found on enemy with health manager " + target.gameObject.name);
                Redwing.Knight.Log("Please report to the mod author. Also adding one now...");
                target.gameObject.GetOrAddComponent <newhealth>();
                return;
            }
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (damage == -1.0)
            {
                damage = (double)(hi.DamageDealt) * hi.Multiplier;
            }
            nh.trueTakeDamage(damage, 10, hi, false);
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
 private void HealthManager_Hit(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitInstance)
 {
     if (self.name.Contains("zomb") && !isHit)
     {
         isHit = true;
         StartCoroutine(OnHit());
     }
     orig(self, hitInstance);
 }
Esempio n. 18
0
        private void HealthManagerOnHit(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitinstance)
        {
            // Mutex lock checking.
            if (newhealth.runningNewHMOH)
            {
                orig(self, hitinstance);
                return;
            }
            newhealth nh = self.gameObject.GetComponent <newhealth>();

            if (nh == null)
            {
                Redwing.Knight.Log("ERROR: No new healthmanager found on enemy with health manager " + self.gameObject.name);
                Redwing.Knight.Log("Please report to the mod author. Also adding one now...");
                self.gameObject.GetOrAddComponent <newhealth>();
                orig(self, hitinstance);
                return;
            }

            bool b = nh.trueTakeDamage(((double)hitinstance.DamageDealt) * hitinstance.Multiplier,
                                       (int)hitinstance.AttackType, hitinstance, true);

            if (b) // make enemy immune
            {
                nh.trueImmortalityTimer = 0.2f;
            }
            else if (nh.trueImmortalityTimer <= 0f) // enemy blocked and wasn't immune
            {
                nh.trueImmortalityTimer = 0.15f;
            }
            if (nh.trueHealth <= 0)
            {
                enemyHealths.Remove(nh);
            }
        }
Esempio n. 19
0
        public static void CustomEnemyHit(GameObject target, GameObject source, double damage)
        {
            HitInstance hi = newhealth.generateHitInstance(source, damage);

            CustomEnemyHit(target, hi, damage);
        }
Esempio n. 20
0
 public override void Hit(HitInstance damageInstance)
 {
     ;
 }
Esempio n. 21
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();
            }
        }
Esempio n. 22
0
        private HitInstance damage(Fsm isGrimm, HitInstance hit)
        {
            if (infinite_globals.oneHitMode && PlayerData.instance.GetBool("equippedCharm_6"))
            {
                hit.DamageDealt = (int)(hit.DamageDealt * 1.75);
            }

            if (!didTakeDamage)
            {
                return(hit);
            }

            if (infinite_globals.timeAttackMode && !addedTimeAttack)
            {
                addedTimeAttack = true;
                GameManager.instance.gameObject.AddComponent <time_attack>();
            }

            if (infinite_globals.hardmode)
            {
                actualTimeScale = (float)getTimeScaleMod();
                if (actualTimeScale > 1.0001f)
                {
                    Time.timeScale = ((lastTimeScale <= 0.01f) ? 0f : 1.0f) * actualTimeScale;
                }

                for (int j = 0; j < infinite_globals.difficultyIncreaseValues.Length; j++)
                {
                    if (damageDone <= infinite_globals.difficultyIncreaseValues[j] ||
                        (difficultyState & (int)(Math.Round(Math.Pow(2, j)))) != 0)
                    {
                        continue;
                    }

                    difficultyState += (int)Math.Round(Math.Pow(2, j));
                    switch (j)
                    {
                    case 0:
                        infinite_globals.log("Adding NGG spike randomness");
                        addNGGSpikeRNG();
                        break;

                    case 1:
                        StartCoroutine(addGodSpikes());
                        break;

                    case 2:
                        infinite_globals.log("Adding death walls...");
                        setupDeathWalls();
                        break;

                    case 3:
                        infinite_globals.log("Adding infinite difficulty increase through speedup...");
                        On.GameManager.SetTimeScale_float += hookSetTimeScale1;
                        break;

                    default:
                        infinite_globals.log("Nothing setup for difficulty increase " + j);
                        break;
                    }
                }
            }

            didTakeDamage = false;
            if (hit.DamageDealt != lastHitDamage)
            {
                return(hit);
            }
            attacksToStun = startingAttacksToStun + (damageDone / stunIncAfterDmg);
            if (attacksToStun > MAX_HITS_TO_STUN)
            {
                attacksToStun = MAX_HITS_TO_STUN;
            }

            AttackTypes a = hit.AttackType;

            if (a == AttackTypes.Nail || a == AttackTypes.Spell || a == AttackTypes.SharpShadow)
            {
                stunCounter++;
            }

            return(hit);
        }
Esempio n. 23
0
        private void addNapalm(On.HealthManager.orig_TakeDamage orig, HealthManager self, HitInstance hitinstance)
        {
            if (hitinstance.DamageDealt * hitinstance.Multiplier >= self.hp)
            {
                orig(self, hitinstance);
                return;
            }

            if (hitinstance.Source.name.Contains("Slash") &&
                (hitinstance.Source.name.Contains("Dash") || hitinstance.Source.name.Contains("Great")))
            {
                if (PlayerData.instance.GetBool("equippedCharm_6") && PlayerData.instance.GetInt("health") == 1)
                {
                    redwing_game_objects.addNapalm(self.gameObject, 6.0 * (PlayerData.instance.nailSmithUpgrades + 1.0),
                                                   Color.green);
                }
                else
                {
                    redwing_game_objects.addNapalm(self.gameObject, 3.0 * (PlayerData.instance.nailSmithUpgrades + 1.0),
                                                   Color.green);
                }
            }
            else if (hitinstance.Source.name.Contains("Slash"))
            {
                if (PlayerData.instance.GetBool("equippedCharm_6") && PlayerData.instance.GetInt("health") == 1)
                {
                    redwing_game_objects.addNapalm(self.gameObject, 2.0 * (PlayerData.instance.nailSmithUpgrades + 1.0),
                                                   Color.red);
                }
                else
                {
                    redwing_game_objects.addNapalm(self.gameObject, PlayerData.instance.nailSmithUpgrades + 1.0,
                                                   Color.white);
                }
            }
            else if (hitinstance.Source.name.Contains("Fireball2"))
            {
                redwing_game_objects.addNapalm(self.gameObject,
                                               PlayerData.instance.GetBool("equippedCharm_19") ? 30.0 : 24.0, Color.black);
            }
            else if (hitinstance.Source.name.Contains("Fireball"))
            {
                redwing_game_objects.addNapalm(self.gameObject,
                                               PlayerData.instance.GetBool("equippedCharm_19") ? 20.0 : 15.0, Color.white);
            }
            else if (hitinstance.Source.name.Contains("Q Fall Damage"))
            {
                redwing_game_objects.addNapalm(self.gameObject,
                                               PlayerData.instance.GetBool("equippedCharm_19") ? 20.0 : 15.0, Color.white);
            }
            else if (hitinstance.Source.name.Contains("Hit"))
            {
                redwing_game_objects.addNapalm(self.gameObject, hitinstance.DamageDealt * 0.15, Color.yellow);
            }

            orig(self, hitinstance);
        }
Esempio n. 24
0
 public void RemoveCycloneKnockback(On.HealthManager.orig_TakeDamage orig, HealthManager self, HitInstance instance)
 {
     if (instance.Source.transform.parent.parent.gameObject.name == "Cyclone Slash")
     {
         var recoil = self.GetAttr <Recoil>("recoil");
         self.SetAttr <Recoil>("recoil", null);
         orig(self, instance);
         self.SetAttr("recoil", recoil);
         return;
     }
     orig(self, instance);
 }
 public void Hit(HitInstance damageInstance)
 {
     Logger.LogDebug("zoteHit");
     au.PlayOneShot(zote_hit);
 }
Esempio n. 26
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.
             */
        }
Esempio n. 27
0
        private void OnTakeDamage(On.HealthManager.orig_TakeDamage orig, HealthManager self, HitInstance hitInstance)
        {
            if (self.gameObject.name.Contains("Cagney Carnation"))
            {
                _he.RecieveHitEffect(hitInstance.Direction);
                _sf.flashFocusHeal();
            }

            orig(self, hitInstance);
        }
Esempio n. 28
0
        private void HealthManagerOnHit(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitinstance)
        {
            if (isBerserk)
            {
                hitinstance.DamageDealt = 10;
            }
            else
            {
                return;
            }

            orig(self, hitinstance);
        }
Esempio n. 29
0
        private void SetDamages(On.HealthManager.orig_TakeDamage orig, HealthManager owner, HitInstance
                                hit)
        {
            Log($@"Creating HitInstance {hit.AttackType}, {hit.Source}, {hit.DamageDealt}, {hit.Multiplier} for {owner.name}");
            _dashDamage = 5 + PlayerData.instance.GetInt("nailSmithUpgrades") * 4;
            float multiplier = 1;

            if (PlayerData.instance.GetBool("hasShadowDash"))
            {
                multiplier *= 2;
            }
            if (PlayerData.instance.GetBool("equippedCharm_25"))
            {
                multiplier *= 1.5f;
            }
            if (PlayerData.instance.GetBool("equippedCharm_6") && PlayerData.instance.GetInt("health") == 1)
            {
                multiplier *= 1.75f;
            }
            if (_oldDashDamage != _dashDamage)
            {
                LogDebug($@"[Blackmoth] Sharp Shadow Damage set to {_dashDamage}");
                _oldDashDamage = _dashDamage;
            }
            if (hit.AttackType == AttackTypes.SharpShadow || hit.Source.name == "SuperDash Damage" && PlayerData.instance.GetBool("defeatedNightmareGrimm"))
            {
                LogDebug($@"Setting damage for {owner.name}");
                hit.DamageDealt         = _dashDamage;
                hit.AttackType          = 0;
                hit.Multiplier          = multiplier;
                hit.Direction           = HeroController.instance.cState.facingRight ? 0 : 180;
                hit.MagnitudeMultiplier = PlayerData.instance.GetBool("equippedCharm_15") ? 2f : 0f;
            }
            else if (hit.AttackType == AttackTypes.Nail)
            {
                LogDebug($@"Setting damage for {owner.name}");
                hit.DamageDealt = 1;
            }
            LogDebug($@"Creating HitInstance {hit.AttackType}, {hit.Source}, {hit.DamageDealt}, {hit.Multiplier} for 
            {owner.name}");
            orig(owner, hit);
        }
Esempio n. 30
0
            static HitInstance HitInstance(Fsm owner, HitInstance hit)
            {
                hit.DamageDealt = 1 << 8;

                return(hit);
            }