public override float RecalculateDamage(float baseValue, CharacterBody character)
        {
            float BaseDamage = character.baseDamage + character.levelDamage * (character.level - 1);

            BaseDamage += ModItemManager.GetBonusForStat(character, StatIndex.Damage);

            float DamageBoost      = 0;
            int   DamageBoostCount = character.inventory ? character.inventory.GetItemCount(ItemIndex.BoostDamage) : 0;

            if (DamageBoostCount > 0)
            {
                DamageBoost += DamageBoostCount * DamageBoost;
            }
            DamageBoost -= 0.05f * character.GetBuffCount(BuffIndex.BeetleJuice);

            if (character.HasBuff(BuffIndex.GoldEmpowered))
            {
                DamageBoost += 1;
            }

            float DamageMult = DamageBoost + (character.CalcLunarDaggerPower());

            DamageMult += ModItemManager.GetMultiplierForStat(character, StatIndex.Damage);
            return(BaseDamage * DamageMult);
        }
        public override float RecalculateHealth(float baseValue, CharacterBody character)
        {
            float MaxHealth       = character.baseMaxHealth + (character.level - 1) * character.levelMaxHealth;
            float HealthBonusItem = 0;
            float hpbooster       = 1;
            float healthDivider   = 1;

            if ((bool)character.inventory)
            {
                HealthBonusItem += ModItemManager.GetBonusForStat(character, StatIndex.MaxHealth);

                if (character.inventory.GetItemCount(ItemIndex.Infusion) > 0)
                {
                    HealthBonusItem += character.inventory.infusionBonus;
                }
                hpbooster    += ModItemManager.GetMultiplierForStat(character, StatIndex.MaxHealth);
                healthDivider = character.CalcLunarDaggerPower();
            }
            MaxHealth += HealthBonusItem;
            MaxHealth *= hpbooster / healthDivider;
            return(MaxHealth);
        }
예제 #3
0
        public void Recalulate(On.RoR2.CharacterBody.orig_RecalculateStats orig, CharacterBody character) //Here we go again
        {
            character.SetPropertyValue("experience", (float)TeamManager.instance.GetTeamExperience(character.teamComponent.teamIndex));
            character.SetPropertyValue("level", (float)TeamManager.instance.GetTeamLevel(character.teamComponent.teamIndex));
            int            InfusionCount            = 0;
            int            HealWhileSafeCount       = 0;
            int            PersonalShieldCount      = 0;
            int            HoofCount                = 0;
            int            RedWimpCount             = 0;
            int            FeatherCount             = 0;
            int            SyringeCount             = 0;
            int            GlassesCount             = 0;
            int            AttackSpeedCritCount     = 0;
            int            CoolDownCritCount        = 0;
            int            HealOnCritCount          = 0;
            int            BettleJuiceCount         = 0;
            int            ShieldOnlyCount          = 0;
            int            AlienHeadCount           = 0;
            int            KnurlCount               = 0;
            int            BoostHpCount             = 0;
            int            CritHealCount            = 0;
            int            SodaCount                = 0;
            int            newBonusStockFromBody    = 0;
            int            BucklerCount             = 0;
            int            UtilityMagazineCount     = 0;
            int            HealthDecayCount         = 0;
            int            DrizzlePlayerHelperCount = 0;
            float          GlassCanonPower          = 1f;
            EquipmentIndex equipmentIndex           = EquipmentIndex.None;
            uint           InfusionPower            = 0;

            if ((bool)character.inventory)
            {
                character.SetPropertyValue("level", character.level + (float)character.inventory.GetItemCount(ItemIndex.LevelBonus));
                InfusionCount            = character.inventory.GetItemCount(ItemIndex.Infusion);
                HealWhileSafeCount       = character.inventory.GetItemCount(ItemIndex.HealWhileSafe);
                PersonalShieldCount      = character.inventory.GetItemCount(ItemIndex.PersonalShield);
                HoofCount                = character.inventory.GetItemCount(ItemIndex.Hoof);
                RedWimpCount             = character.inventory.GetItemCount(ItemIndex.SprintOutOfCombat);
                FeatherCount             = character.inventory.GetItemCount(ItemIndex.Feather);
                SyringeCount             = character.inventory.GetItemCount(ItemIndex.Syringe);
                GlassesCount             = character.inventory.GetItemCount(ItemIndex.CritGlasses);
                AttackSpeedCritCount     = character.inventory.GetItemCount(ItemIndex.AttackSpeedOnCrit);
                CoolDownCritCount        = character.inventory.GetItemCount(ItemIndex.CooldownOnCrit);
                HealOnCritCount          = character.inventory.GetItemCount(ItemIndex.HealOnCrit);
                BettleJuiceCount         = character.GetBuffCount(BuffIndex.BeetleJuice);
                ShieldOnlyCount          = character.inventory.GetItemCount(ItemIndex.ShieldOnly);
                AlienHeadCount           = character.inventory.GetItemCount(ItemIndex.AlienHead);
                KnurlCount               = character.inventory.GetItemCount(ItemIndex.Knurl);
                BoostHpCount             = character.inventory.GetItemCount(ItemIndex.BoostHp);
                CritHealCount            = character.inventory.GetItemCount(ItemIndex.CritHeal);
                SodaCount                = character.inventory.GetItemCount(ItemIndex.SprintBonus);
                newBonusStockFromBody    = character.inventory.GetItemCount(ItemIndex.SecondarySkillMagazine);
                BucklerCount             = character.inventory.GetItemCount(ItemIndex.SprintArmor);
                UtilityMagazineCount     = character.inventory.GetItemCount(ItemIndex.UtilitySkillMagazine);
                HealthDecayCount         = character.inventory.GetItemCount(ItemIndex.HealthDecay);
                GlassCanonPower          = character.CalcLunarDaggerPower();
                equipmentIndex           = character.inventory.currentEquipmentIndex;
                InfusionPower            = character.inventory.infusionBonus;
                DrizzlePlayerHelperCount = character.inventory.GetItemCount(ItemIndex.DrizzlePlayerHelper);
            }
            float Level = character.level - 1f;

            character.SetPropertyValue("isElite", character.GetFieldValue <BuffMask>("buffMask").containsEliteBuff);

            float preHealth = character.baseMaxHealth;
            float preShield = character.baseMaxShield;

            //Health
            float MaxHealth        = character.baseMaxHealth;
            float additionalHealth = 0;

            if (character.inventory.GetItemCount(ItemIndex.Infusion) > 0)
            {
                additionalHealth += character.inventory.infusionBonus;
            }
            additionalHealth += character.inventory.GetItemCount(ItemIndex.Knurl) * 40;

            float hpbooster = 1 + character.inventory.GetItemCount(ItemIndex.BoostHp) * 0.1f;

            MaxHealth = Utils.exponentialFormula(MaxHealth, character.levelMaxHealth, HExpo, character.level, 0) * hpbooster / character.CalcLunarDaggerPower();
            character.SetPropertyValue("maxHealth", MaxHealth);


            //regen
            float BaseRegen = (character.baseRegen + character.levelRegen * Level) * 2.5f;

            if (character.outOfDanger && HealWhileSafeCount > 0)
            {
                BaseRegen *= (float)(2.5 + (double)(HealWhileSafeCount - 1) * 1.5);
            }

            float LifeRegen = BaseRegen + (float)KnurlCount * 1.6f;

            if (HealthDecayCount > 0)
            {
                LifeRegen -= character.maxHealth / (float)HealthDecayCount;
            }

            character.SetPropertyValue("regen", LifeRegen);


            //Shield
            float MaxShield = character.baseMaxShield + character.levelMaxShield * (character.level - 1);

            if (character.inventory.GetItemCount(ItemIndex.ShieldOnly) > 0)
            {
                MaxShield += character.maxHealth * (1.5f + (character.inventory.GetItemCount(ItemIndex.ShieldOnly) - 1) * 0.25f);
                character.SetPropertyValue("maxHealth", 1);
            }
            if (character.HasBuff(BuffIndex.EngiShield))
            {
                MaxShield += character.maxHealth * 1f;
            }
            if (character.HasBuff(BuffIndex.EngiTeamShield))
            {
                MaxShield += character.maxHealth * 0.5f;
            }
            MaxShield += character.inventory.GetItemCount(ItemIndex.PersonalShield) * (25 + ShieldBoost * (character.level - 1));
            if (character.GetFieldValue <BuffMask>("buffMask").HasBuff(BuffIndex.AffixBlue))
            {
                character.SetPropertyValue("maxHealth", character.maxHealth * 0.5f);
                MaxShield += character.maxHealth;
            }
            character.SetPropertyValue("maxShield", MaxShield);

            //moveSpeed
            float BaseMoveSpeed = character.baseMoveSpeed + character.levelMoveSpeed * Level;
            float RedWinpBOnus  = 1f;

            if (Run.instance.enabledArtifacts.HasArtifact(ArtifactIndex.Spirit))
            {
                float num33 = 1f;
                if ((bool)character.healthComponent)
                {
                    num33 = character.healthComponent.combinedHealthFraction;
                }
                RedWinpBOnus += 1f - num33;
            }
            if (equipmentIndex == EquipmentIndex.AffixYellow)
            {
                BaseMoveSpeed += 2f;
            }
            if (character.isSprinting)
            {
                BaseMoveSpeed *= character.GetFieldValue <float>("sprintingSpeedMultiplier");
            }
            if (character.outOfCombat && character.outOfDanger && RedWimpCount > 0)
            {
                RedWinpBOnus += (float)RedWimpCount * 0.3f;
            }
            float SpeedBonus = RedWinpBOnus + (float)HoofCount * 0.14f;

            if (character.isSprinting && SodaCount > 0)
            {
                SpeedBonus += (float)(0.100000001490116 + 0.200000002980232 * (double)SodaCount) / character.GetFieldValue <float>("sprintingSpeedMultiplier");
            }
            if (character.HasBuff(BuffIndex.BugWings))
            {
                SpeedBonus += 0.2f;
            }
            if (character.HasBuff(BuffIndex.Warbanner))
            {
                SpeedBonus += 0.3f;
            }
            if (character.HasBuff(BuffIndex.EnrageAncientWisp))
            {
                SpeedBonus += 0.4f;
            }
            if (character.HasBuff(BuffIndex.CloakSpeed))
            {
                SpeedBonus += 0.4f;
            }
            if (character.HasBuff(BuffIndex.TempestSpeed))
            {
                ++SpeedBonus;
            }
            if (character.HasBuff(BuffIndex.WarCryBuff))
            {
                SpeedBonus += 0.5f;
            }
            if (character.HasBuff(BuffIndex.EngiTeamShield))
            {
                SpeedBonus += 0.3f;
            }
            float SpeedMalus = 1f;

            if (character.HasBuff(BuffIndex.Slow50))
            {
                SpeedMalus += 0.5f;
            }
            if (character.HasBuff(BuffIndex.Slow60))
            {
                SpeedMalus += 0.6f;
            }
            if (character.HasBuff(BuffIndex.Slow80))
            {
                SpeedMalus += 0.8f;
            }
            if (character.HasBuff(BuffIndex.ClayGoo))
            {
                SpeedMalus += 0.5f;
            }
            if (character.HasBuff(BuffIndex.Slow30))
            {
                SpeedMalus += 0.3f;
            }
            if (character.HasBuff(BuffIndex.Cripple))
            {
                ++SpeedMalus;
            }
            float MoveSpeed = BaseMoveSpeed * (SpeedBonus / SpeedMalus);

            if (BettleJuiceCount > 0)
            {
                MoveSpeed *= (float)(1.0 - 0.0500000007450581 * (double)BettleJuiceCount);
            }
            character.SetPropertyValue("moveSpeed", MoveSpeed);

            //OtherMovement Bonus
            character.SetPropertyValue("acceleration", character.moveSpeed / character.baseMoveSpeed * character.baseAcceleration);
            character.SetPropertyValue("jumpPower", character.baseJumpPower + character.levelJumpPower * Level);
            character.SetPropertyValue("maxJumpHeight", Trajectory.CalculateApex(character.jumpPower));
            character.SetPropertyValue("maxJumpCount", character.baseJumpCount + FeatherCount);

            //Damage
            float BaseDamage       = character.baseDamage + character.levelDamage * Level;
            float DamageBoost      = 1f;
            int   DamageBoostCount = character.inventory ? character.inventory.GetItemCount(ItemIndex.BoostDamage) : 0;

            if (DamageBoostCount > 0)
            {
                DamageBoost += DamageBoostCount * 0.1f;
            }
            if (BettleJuiceCount > 0)
            {
                DamageBoost -= 0.05f * BettleJuiceCount;
            }
            if (character.HasBuff(BuffIndex.GoldEmpowered))
            {
                ++DamageBoost;
            }
            float DamageMult = DamageBoost + (GlassCanonPower - 1f);

            character.SetPropertyValue("damage", BaseDamage * DamageMult);

            //Attack Speed
            float BaseAttackSpeed  = character.baseAttackSpeed + character.levelAttackSpeed * Level;
            float AttackSpeedBonus = 1f + SyringeCount * 0.15f;

            if (equipmentIndex == EquipmentIndex.AffixYellow)
            {
                AttackSpeedBonus += 0.5f;
            }
            float AttackSpeedMult = AttackSpeedBonus + character.GetFieldValue <int[]>("buffs")[2] * 0.12f;

            if (character.HasBuff(BuffIndex.Warbanner))
            {
                AttackSpeedMult += 0.3f;
            }
            if (character.HasBuff(BuffIndex.EnrageAncientWisp))
            {
                AttackSpeedMult += 2f;
            }
            if (character.HasBuff(BuffIndex.WarCryBuff))
            {
                ++AttackSpeedMult;
            }
            float AttackSpeed = BaseAttackSpeed * AttackSpeedMult;

            if (BettleJuiceCount > 0)
            {
                AttackSpeed *= (float)(1.0 - 0.05 * BettleJuiceCount);
            }
            character.SetPropertyValue("attackSpeed", AttackSpeed);

            //Crit
            float CriticalChance = character.baseCrit + character.levelCrit * Level + GlassesCount * 10f;

            if (AttackSpeedCritCount > 0)
            {
                CriticalChance += 5f;
            }
            if (CoolDownCritCount > 0)
            {
                CriticalChance += 5f;
            }
            if (HealOnCritCount > 0)
            {
                CriticalChance += 5f;
            }
            if (CritHealCount > 0)
            {
                CriticalChance += 5f;
            }
            if (character.HasBuff(BuffIndex.FullCrit))
            {
                CriticalChance += 100f;
            }
            character.SetPropertyValue("crit", CriticalChance);


            //Armor
            character.SetPropertyValue("armor", value: (float)(character.baseArmor + character.levelArmor * (double)Level + (character.HasBuff(BuffIndex.ArmorBoost) ? 200.0 : 0.0)));
            character.SetPropertyValue("armor", character.armor + DrizzlePlayerHelperCount * 70f);
            if (character.HasBuff(BuffIndex.Cripple))
            {
                character.SetPropertyValue("armor", character.armor - 20f);
            }
            if (character.isSprinting && BucklerCount > 0)
            {
                character.SetPropertyValue("armor", character.armor + BucklerCount * 30);
            }



            //CoolDown
            float CoolDownMultiplier = 1f;

            if (character.HasBuff(BuffIndex.GoldEmpowered))
            {
                CoolDownMultiplier *= 0.25f;
            }
            for (int index = 0; index < AlienHeadCount; ++index)
            {
                CoolDownMultiplier *= 0.75f;
            }
            if (character.HasBuff(BuffIndex.NoCooldowns))
            {
                CoolDownMultiplier = 0.0f;
            }
            if ((bool)character.GetFieldValue <SkillLocator>("skillLocator").primary)
            {
                character.GetFieldValue <SkillLocator>("skillLocator").primary.cooldownScale = CoolDownMultiplier;
            }
            if ((bool)character.GetFieldValue <SkillLocator>("skillLocator").secondary)
            {
                character.GetFieldValue <SkillLocator>("skillLocator").secondary.cooldownScale = CoolDownMultiplier;
                character.GetFieldValue <SkillLocator>("skillLocator").secondary.SetBonusStockFromBody(newBonusStockFromBody);
            }
            if ((bool)character.GetFieldValue <SkillLocator>("skillLocator").utility)
            {
                float num33 = CoolDownMultiplier;
                if (UtilityMagazineCount > 0)
                {
                    num33 *= 0.6666667f;
                }
                character.GetFieldValue <SkillLocator>("skillLocator").utility.cooldownScale = num33;
                character.GetFieldValue <SkillLocator>("skillLocator").utility.SetBonusStockFromBody(UtilityMagazineCount * 2);
            }
            if ((bool)character.GetFieldValue <SkillLocator>("skillLocator").special)
            {
                character.GetFieldValue <SkillLocator>("skillLocator").special.cooldownScale = CoolDownMultiplier;
            }


            //CriticalHeal
            character.SetPropertyValue("critHeal", 0.0f);
            if (CritHealCount > 0)
            {
                float crit = character.crit;
                character.SetPropertyValue("crit", character.crit / (CritHealCount + 1));
                character.SetPropertyValue("critHeal", crit - character.crit);
            }

            //UpdateHealth/Shield Value
            if (NetworkServer.active)
            {
                float HealthOffset = character.maxHealth - preHealth;
                float ShieldOffset = character.maxShield - preShield;
                if (HealthOffset > 0)
                {
                    double num47 = character.healthComponent.Heal(HealthOffset, new ProcChainMask(), false);
                }
                else if (character.healthComponent.health > character.maxHealth)
                {
                    character.healthComponent.Networkhealth = character.maxHealth;
                }
                if (ShieldOffset > 0)
                {
                    character.healthComponent.RechargeShield(ShieldOffset);
                }
            }
            character.SetFieldValue("statsDirty", false);
        }
예제 #4
0
        // Token: 0x060021C0 RID: 8640 RVA: 0x0009F160 File Offset: 0x0009D360
        private void UpdateHealthbar(float deltaTime)
        {
            float num  = 0f;
            float num2 = 1f;
            float num3 = 1f;

            if (this.source)
            {
                CharacterBody component = this.source.GetComponent <CharacterBody>();
                if (component)
                {
                    float num4 = component.CalcLunarDaggerPower();
                    num3 /= num4;
                }
                float fullHealth = this.source.fullHealth;
                float f          = this.source.health + this.source.shield;
                float num5       = this.source.fullHealth + this.source.fullShield;
                num = Mathf.Clamp01(this.source.health / num5 * num3);
                float num6 = Mathf.Clamp01(this.source.shield / num5 * num3);
                if (!this.hasCachedInitialValue)
                {
                    this.cachedFractionalValue = num;
                    this.hasCachedInitialValue = true;
                }
                if (this.eliteBackdropRectTransform)
                {
                    if (component.equipmentSlot && EliteCatalog.IsEquipmentElite(component.equipmentSlot.equipmentIndex) != EliteIndex.None)
                    {
                        num2 += 1f;
                        this.eliteBackdropRectTransform.gameObject.SetActive(true);
                    }
                    else
                    {
                        this.eliteBackdropRectTransform.gameObject.SetActive(false);
                    }
                }
                if (this.frozenCullThresholdRectTransform)
                {
                    this.frozenCullThresholdRectTransform.gameObject.SetActive(this.source.isFrozen);
                }
                bool active = false;
                if (this.source.fullShield > 0f)
                {
                    active = true;
                }
                this.shieldFillRectTransform.gameObject.SetActive(active);
                if (this.scaleHealthbarWidth && component)
                {
                    float num7 = Util.Remap(Mathf.Clamp((component.baseMaxHealth + component.baseMaxShield) * num2, 0f, this.maxHealthbarHealth), this.minHealthbarHealth, this.maxHealthbarHealth, this.minHealthbarWidth, this.maxHealthbarWidth);
                    this.healthbarScale          = num7 / this.minHealthbarWidth;
                    this.rectTransform.sizeDelta = new Vector2(num7, this.rectTransform.sizeDelta.y);
                }
                Color           color  = this.originalFillColor;
                CharacterMaster master = component.master;
                if (master && (master.isBoss || master.inventory.GetItemCount(ItemIndex.Infusion) > 0))
                {
                    color = ColorCatalog.GetColor(ColorCatalog.ColorIndex.Teleporter);
                }
                this.fillImage.color = color;
                if (this.fillRectTransform)
                {
                    this.fillRectTransform.anchorMin        = new Vector2(0f, 0f);
                    this.fillRectTransform.anchorMax        = new Vector2(num, 1f);
                    this.fillRectTransform.anchoredPosition = Vector2.zero;
                    this.fillRectTransform.sizeDelta        = new Vector2(1f, 1f);
                }
                if (this.shieldFillRectTransform)
                {
                    this.shieldFillRectTransform.anchorMin        = new Vector2(num, 0f);
                    this.shieldFillRectTransform.anchorMax        = new Vector2(num + num6, 1f);
                    this.shieldFillRectTransform.anchoredPosition = Vector2.zero;
                    this.shieldFillRectTransform.sizeDelta        = new Vector2(1f, 1f);
                }
                if (this.delayfillRectTransform)
                {
                    this.delayfillRectTransform.anchorMin        = new Vector2(0f, 0f);
                    this.delayfillRectTransform.anchorMax        = new Vector2(this.cachedFractionalValue, 1f);
                    this.delayfillRectTransform.anchoredPosition = Vector2.zero;
                    this.delayfillRectTransform.sizeDelta        = new Vector2(1f, 1f);
                }
                if (this.flashRectTransform)
                {
                    this.flashRectTransform.anchorMin = new Vector2(0f, 0f);
                    this.flashRectTransform.anchorMax = new Vector2(num, 1f);
                    float num8 = 1f - num;
                    float num9 = 2f * num8;
                    this.theta += deltaTime * num9;
                    if (this.theta > 1f)
                    {
                        this.theta -= this.theta - this.theta % 1f;
                    }
                    float num10 = 1f - Mathf.Cos(this.theta * 3.1415927f * 0.5f);
                    this.flashRectTransform.sizeDelta = new Vector2(num10 * 20f * num8, num10 * 20f * num8);
                    Image component2 = this.flashRectTransform.GetComponent <Image>();
                    if (component2)
                    {
                        Color color2 = component2.color;
                        color2.a         = (1f - num10) * num8 * 0.7f;
                        component2.color = color2;
                    }
                }
                if (this.currentHealthText)
                {
                    float num11 = Mathf.Ceil(f);
                    if (num11 != this.displayStringCurrentHealth)
                    {
                        this.displayStringCurrentHealth = num11;
                        this.currentHealthText.text     = num11.ToString();
                    }
                }
                if (this.fullHealthText)
                {
                    float num12 = Mathf.Ceil(fullHealth);
                    if (num12 != this.displayStringFullHealth)
                    {
                        this.displayStringFullHealth = num12;
                        this.fullHealthText.text     = num12.ToString();
                    }
                }
                if (this.criticallyHurtImage)
                {
                    if (num + num6 < HealthBar.criticallyHurtThreshold && this.source.alive)
                    {
                        this.criticallyHurtImage.enabled = true;
                        this.criticallyHurtImage.color   = HealthBar.GetCriticallyHurtColor();
                        this.fillImage.color             = HealthBar.GetCriticallyHurtColor();
                    }
                    else
                    {
                        this.criticallyHurtImage.enabled = false;
                    }
                }
                if (this.deadImage)
                {
                    this.deadImage.enabled = !this.source.alive;
                }
            }
            this.cachedFractionalValue = Mathf.SmoothDamp(this.cachedFractionalValue, num, ref this.healthFractionVelocity, 0.05f, float.PositiveInfinity, deltaTime);
        }