Beispiel #1
0
        //Modify the damage
        public void spellDam(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitInstance)
        {
            if (hitInstance.AttackType == AttackTypes.Spell && hitInstance.Source.name.StartsWith("bullet"))
            {
                BulletBehavior b;
                Log("Bullet impact with name " + hitInstance.Source.name);

                b = fireball.GetComponent <BulletBehavior>();

                /*
                 * if (!b.enemyHit())
                 *  return;
                 * if (self.IsBlockingByDirection(
                 *  DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(self.transform)),
                 *  hitInstance.AttackType))
                 * {
                 *  orig(self, hitInstance);
                 *  return;
                 * }
                 */
                DamageEnemies.hitEnemy(self, b.bulletType.Damage, hitInstance, b.bulletType.SoulGain);
            }
            else
            {
                orig(self, hitInstance);
            }
        }
        //Intercepts HealthManager's Hit method and allows me to override it with my own calculation
        public void HealthManager_Hit_Hook(On.HealthManager.orig_Hit orig, HealthManager self, HitInstance hitInstance)
        {
            //Modding.Logger.Log(self.gameObject.name + " " + hitInstance.Source.name);
            //Alternative hit damages from other sources like weaver or explosions
            Modding.Logger.Log(self.name);

            if (hitInstance.Source.name.Contains("Gas"))
            {
                //Explosion damage
                hitInstance.DamageDealt = 15 + (PlayerData.instance.nailSmithUpgrades * 5);
                orig(self, hitInstance);
                return;
            }
            else if (hitInstance.Source.name.Contains("Damager"))
            {
                //Glowing Womblings
                HeroController.instance.AddMPCharge(15);
                orig(self, hitInstance);
                return;
            }
            if (!hitInstance.Source.name.Contains("bullet"))
            {
                //Nail Damage TODO: Change this because this apparently affects environmental damage that are supposed to be OHKO
                hitInstance.DamageDealt = 3 + PlayerData.instance.nailSmithUpgrades * 3;
                orig(self, hitInstance);
                return;
            }

            HP_BulletBehaviour hpbb = hitInstance.Source.GetComponent <HP_BulletBehaviour>();
            Vector3            bulletOriginPosition = hitInstance.Source.GetComponent <HP_BulletBehaviour>().bulletOriginPosition;

            //==============Soul Gain Amount============
            int soulGainAmt = HP_Stats.CalculateSoulGain();

            //==============Damage=================
            int damage = HP_Stats.CalculateDamage(bulletOriginPosition, self.transform.position);

            DamageEnemies.HitEnemy(self, damage, HP_BulletBehaviour.bulletHitInstance, soulGainAmt);
            Modding.Logger.Log("DamageCalculator, damage dealt is " + damage + " against " + self.name);

            //==============Blood Splatter Effect=================
            //int cardinalDirection = DirectionUtils.GetCardinalDirection(hitInstance.GetActualDirection(self.transform));
            //if (!self.IsInvincible) StartCoroutine(SplatterBlood(self.gameObject, 1, cardinalDirection * 90));
        }