Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
        }