private void CharacterMaster_RespawnExtraLife(On.RoR2.CharacterMaster.orig_RespawnExtraLife orig, CharacterMaster self) { orig(self); if (playersToRespawn.Contains(self)) { playersToRespawn.Remove(self); var characterBody = self.GetBody(); CharacterBody component = characterBody; if (component) { var count = component.GetBuffCount(InitBuffs.maxHPDownStage); var added_count = (int)Mathf.Ceil(((100f - (float)component.GetBuffCount(InitBuffs.maxHPDownStage)) / 100f) * (float)purchaseInteraction.cost); //Debug.Log(count + added_count); if (count + added_count < 100) { for (var i = 0; i < added_count; i++) { component.AddBuff(InitBuffs.maxHPDownStage); } } } } }
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, RecalculateStatsAPI.StatHookEventArgs args) { if (sender.HasBuff(buffDef)) { args.moveSpeedMultAdd += boostPower / 100f * sender.GetBuffCount(buffDef); args.attackSpeedMultAdd += boostPower / 100f * sender.GetBuffCount(buffDef); } }
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, RecalculateStatsAPI.StatHookEventArgs args) { if (!sender) { return; } args.moveSpeedMultAdd += sender.GetBuffCount(engiSpeedBoostBuff) * engiSharedBuffFrac * buffFrac; args.moveSpeedMultAdd += sender.GetBuffCount(genericSpeedBoostBuff) * unhandledFrac * buffFrac; }
private void AddBFBuff(CharacterBody sender, StatHookEventArgs args) { var InventoryCount = GetCount(sender); if (sender.HasBuff(BFBuff)) { args.armorAdd += (2f * sender.GetBuffCount(BFBuff)) + (1f * sender.GetBuffCount(BFBuff) * (InventoryCount - 1)); } }
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, RecalculateStatsAPI.StatHookEventArgs args) { if (!sender) { return; } args.armorAdd += sender.GetBuffCount(armorBuff) * buffArmorAmt; args.attackSpeedMultAdd += sender.GetBuffCount(attackBuff) * buffAttackAmt; args.damageMultAdd += sender.GetBuffCount(damageBuff) * buffDamageAmt; args.moveSpeedMultAdd += sender.GetBuffCount(moveBuff) * buffMoveAmt; }
public static void ApplyBuff(this CharacterBody body, BuffIndex buff, Int32 stacks = 1, Single duration = -1f) { if (NetworkServer.active) { if (duration < 0f) { body.SetBuffCount(buff, body.GetBuffCount(buff) + stacks); } else { if (stacks < 0) { Log.Error("Cannot remove duration from a buff"); return; } for (Int32 i = 0; i < stacks; ++i) { body.AddTimedBuff(buff, duration); } } } else { new BuffMessage(body, buff, stacks, duration).Send(NetworkDestination.Server); } }
private void HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo) { if (damageInfo.damageType.HasFlag(DamageType.Freeze2s)) { this.frozenBy[self.gameObject] = damageInfo.attacker; } if (damageInfo.dotIndex == this.burnDot) { if (damageInfo.attacker) { CharacterBody attackerBody = damageInfo.attacker.GetComponent <CharacterBody>(); if (attackerBody) { Int32 buffCount = attackerBody.GetBuffCount(this.fireBuff); if (buffCount >= 0) { damageInfo.damage *= 1f + (AltArtiPassive.burnDamageMult * buffCount); } } } } orig(self, damageInfo); }
private static float GetArmorDelta(CharacterBody self) { float addedArmor = 0f; float lostArmor = 0f; float count; if (self.HasBuff(RoR2Content.Buffs.AffixHaunted) && Configuration.AspectHauntedBaseArmorGain.Value > 0f) { count = Catalog.GetStackMagnitude(self, RoR2Content.Buffs.AffixHaunted); addedArmor += Configuration.AspectHauntedBaseArmorGain.Value + Configuration.AspectHauntedStackArmorGain.Value * (count - 1f); } else if (self.HasBuff(RoR2Content.Buffs.AffixHauntedRecipient) && Configuration.AspectHauntedAllyArmorGain.Value > 0f) { addedArmor += Configuration.AspectHauntedAllyArmorGain.Value; } if (self.HasBuff(Catalog.Buff.AffixPlated) && Configuration.AspectPlatedBaseArmorGain.Value > 0f) { count = Catalog.GetStackMagnitude(self, Catalog.Buff.AffixPlated); addedArmor += Configuration.AspectPlatedBaseArmorGain.Value + Configuration.AspectPlatedStackArmorGain.Value * (count - 1f); } if (self.HasBuff(Catalog.Buff.ZetHeadHunter)) { addedArmor += Configuration.HeadHunterBuffArmor.Value * self.GetBuffCount(Catalog.Buff.ZetHeadHunter); } if (self.HasBuff(Catalog.Buff.ZetShredded)) { lostArmor += Mathf.Abs(Configuration.AspectHauntedShredArmor.Value); } //if (self.teamComponent.teamIndex == TeamIndex.Player) lostArmor *= Configuration.AspectEffectPlayerDebuffMult.Value; return(addedArmor - lostArmor); }
public void Update() { if (gameObject.GetComponent <CharacterMaster>() is CharacterMaster characterMaster) { trackerMaster = characterMaster; if (trackerMaster.GetBody() is CharacterBody characterBody) { trackerBody = characterBody; int tempCurseCount = 0; foreach (AffixTracker tracker in affixTrackers) { //If the buff is StageLock or CurseLock, give it to me if (tracker.isCurseLock || tracker.isStageLock) { //trackerBody.AddBuff(tracker.buffIndex); trackerBody.ApplyBuff(tracker.buffIndex, 1); } //If neither Lock, and also not Held nor Vulture, take it away else if (!tracker.isHeld && !tracker.isVultured) { //trackerBody.RemoveBuff(tracker.buffIndex); trackerBody.ApplyBuff(tracker.buffIndex, 0); } //Check is the buff is currently from Wake of Vultures if (tracker.isVultured) { //Reduce the amount of time and remove flag if no time left tracker.vultureTimeLeft -= Time.deltaTime; if (tracker.vultureTimeLeft <= 0) { tracker.isVultured = false; } } //Calculate the current curse count if (tracker.isCurseLock) { //If its cursed and neither staged nor held nor vultured, add a curse if (!tracker.isHeld && !tracker.isStageLock && !tracker.isVultured) { tempCurseCount++; } } } //Update curse count if its changed if (tempCurseCount != curseCount) { curseCount = tempCurseCount; //Chat.AddMessage("Current Curse Level is: " + curseCount.ToString()); } //Update the visual effect if needed if (trackerBody.GetBuffCount(CurseBuff.index) != curseCount) { trackerBody.ApplyBuff(CurseBuff.index, curseCount); } } } }
private static void ModifyCrit(CharacterBody self) { float addedCrit = 0f; if (self.HasBuff(Catalog.Buff.ZetHeadHunter)) { addedCrit += Configuration.HeadHunterBuffCritChance.Value * self.GetBuffCount(Catalog.Buff.ZetHeadHunter); } if (addedCrit > 0f) { Inventory inventory = self.inventory; if (inventory) { if (inventory.GetItemCount(DLC1Content.Items.ConvertCritChanceToCritDamage) == 0) { self.crit += addedCrit; } else { self.critMultiplier += addedCrit * 0.01f; } } } }
static void ReturnBuffList(CharacterBody body, ref string buffList, ref string debuffList) { BuffIndex buffIndex = (BuffIndex)0; BuffIndex buffCount = (BuffIndex)BuffCatalog.buffCount; while (buffIndex < buffCount) { int buffCount2 = body.GetBuffCount(buffIndex); bool flag3 = buffCount2 > 0; if (flag3) { BuffDef buffDef = BuffCatalog.GetBuffDef(buffIndex); string @string = Language.GetString(buffDef.name); string text5 = @string ?? ""; bool canStack = buffDef.canStack; if (canStack) { text5 += string.Format(" ({0})", buffCount2); } text5 += ", "; bool isDebuff = buffDef.isDebuff; if (isDebuff) { debuffList += text5; } else { buffList += text5; } } buffIndex++; } }
protected override bool PerformEquipmentAction(EquipmentSlot slot) { CharacterBody body = slot.characterBody; if (!body) { return(false); } HealthComponent health = body.healthComponent; if (!health) { return(false); } int MeatBunBoostCount = body.GetBuffCount(MeatbunBoost); if (MeatBunBoostCount < MaxBuffLimit) { body.AddBuff(MeatbunBoost); } if (PercentMaxHealthHealAmount > 0) { health.HealFraction(PercentMaxHealthHealAmount, default); } return(true); }
private void AddSpeedReward(CharacterBody sender, StatHookEventArgs args) { if (sender.HasBuff(SpeedBuff)) { args.moveSpeedMultAdd += moveSpeedPercentageBonusPerBuffStack * sender.GetBuffCount(SpeedBuff); } }
private void CharacterBody_OnClientBuffsChanged(On.RoR2.CharacterBody.orig_OnClientBuffsChanged orig, CharacterBody self) { orig(self); var component = self.GetComponent <MysticsItemsCoffeeBoostHelper>(); if (!component) { component = self.gameObject.AddComponent <MysticsItemsCoffeeBoostHelper>(); } var currentCount = self.GetBuffCount(buffDef); if (currentCount > component.oldCount) { Util.PlayAttackSpeedSound("Play_item_proc_coffee", self.gameObject, 1f + 0.2f * (float)(currentCount - 1)); EffectData effectData = new EffectData { origin = self.corePosition, scale = self.radius, rotation = Util.QuaternionSafeLookRotation(Vector3.forward) }; effectData.SetHurtBoxReference(self.gameObject); EffectManager.SpawnEffect(Items.CoffeeBoostOnItemPickup.visualEffect, effectData, false); } component.oldCount = currentCount; }
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); }
private void AddShellPlateStats(CharacterBody sender, StatHookEventArgs args) { var inventoryCount = GetCount(sender); if (inventoryCount > 0) { var shellStackTrackerComponent = sender.gameObject.GetComponent <ShellStackTracker>(); if (!shellStackTrackerComponent) { sender.gameObject.AddComponent <ShellStackTracker>(); } var currentShellStackMax = (((inventoryCount - 1) * (addMaxArmorGain / armorOnKillAmount)) + (baseMaxArmorGain / armorOnKillAmount)); if (shellStackTrackerComponent.shellStacks >= currentShellStackMax && sender.GetBuffCount(ShellStackMax) <= 0) { sender.AddBuff(ShellStackMax); } if (shellStackTrackerComponent.shellStacks < currentShellStackMax && sender.GetBuffCount(ShellStackMax) > 0) { sender.RemoveBuff(ShellStackMax); } var currentShellStack = shellStackTrackerComponent.shellStacks; args.armorAdd += (armorOnKillAmount * currentShellStack); } }
private void On_GEMOnHitEnemy(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim) { orig(self, damageInfo, victim); if (!NetworkServer.active || !damageInfo.attacker) { return; } CharacterBody body = damageInfo.attacker.GetComponent <CharacterBody>(); if (!body || !body.HasBuff(pillageBuff)) { return; } CharacterMaster chrm = body.master; if (!chrm) { return; } int mamt = Run.instance.GetDifficultyScaledCost(body.GetBuffCount(pillageBuff)); if (Compat_ShareSuite.enabled && Compat_ShareSuite.MoneySharing()) { Compat_ShareSuite.GiveMoney((uint)mamt); } else { chrm.GiveMoney((uint)mamt); } }
private void Evt_TILER2GetStatCoefficients(CharacterBody sender, StatHookEventArgs args) { if (sender.HasBuff(prescriptionsBuff)) { args.baseDamageAdd += dmgBoost; args.attackSpeedMultAdd += sender.GetBuffCount(prescriptionsBuff) * aSpdBoost; } }
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, RecalculateStatsAPI.StatHookEventArgs args) { if (sender.HasBuff(buffDef)) { var itemCount = sender.inventory ? sender.inventory.GetItemCount(MysticsItemsContent.Items.MysticsItems_Rhythm) : 0; args.critAdd += (comboCrit + comboCritPerStack * (itemCount - 1)) * sender.GetBuffCount(buffDef); } }
private void CharacterBody_RecalculateStats(On.RoR2.CharacterBody.orig_RecalculateStats orig, CharacterBody self) { orig(self); if (self == this.body && self.HasBuff(Modules.Buffs.kaminaBuff)) { var kaminBuffCount = self.GetBuffCount(Modules.Buffs.kaminaBuff); self.damage *= (1 + (Modules.Buffs.kaminaBuffDmgModifier * kaminBuffCount)); } }
internal unsafe BuffCounts(void *ptr, CharacterBody body) { this.maxValue = (UInt32)(BuffCatalog.buffCount - 1); this.counts = (UInt32 *)ptr; for (UInt32 i = 0; i < BuffCatalog.buffCount; ++i) { this.counts[i] = (UInt32)body.GetBuffCount((BuffIndex)i); } }
public void GiveCursedDebuffMinimum(CharacterBody characterBody, int curseAmount) { if (characterBody && characterBody.healthComponent) { var curseDebuffAmount = characterBody.GetBuffCount(RoR2Content.Buffs.PermanentCurse); if (curseDebuffAmount < curseAmount) { HelperUtil.AddBuffStacks(characterBody, RoR2Content.Buffs.PermanentCurse, curseAmount - curseDebuffAmount); } } }
/// <summary> /// Safely removes ALL of target buff from the target character body /// </summary> /// <param name="buffToRemove">The buff you want to safely remove all of</param> /// <param name="body">The body you safely want to remove buffs from.</param> public static void SafeRemoveAllOfBuff(BuffDef buffToRemove, CharacterBody body) { if (body) { int stacks = body.GetBuffCount(buffToRemove); for (int i = 0; i < stacks; i++) { body.RemoveBuff(buffToRemove); } } }
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, RecalculateStatsAPI.StatHookEventArgs args) { if (!sender) { return; } var buffCount = sender.GetBuffCount(loomBuff); args.attackSpeedMultAdd -= buffCount * stackAttack; args.damageMultAdd += buffCount * stackDamage; }
private void FixedUpdate_On(HooksCore.RoR2.CharacterBody.FixedUpdate.Orig orig, CharacterBody self) { orig(self); if (NetworkServer.active) { Int32 count = self.GetBuffCount(RW_flameChargeBuff); if (count > 0) { self.healthComponent.AddBarrier(Time.fixedDeltaTime * shieldRegenFrac * Mathf.Pow(count, 1f / rootNumber) * self.healthComponent.fullCombinedHealth); } } }
void UpdateGGBuff(CharacterBody cb) { var cpt = cb.GetComponent <GoldenGunComponent>(); int tgtBuffStacks = (cpt.cachedIcnt < 1) ? 0 : Mathf.Clamp(Mathf.FloorToInt(cpt.cachedMoney / (Run.instance.GetDifficultyScaledCost(goldAmt) * Mathf.Pow(goldReduc, cpt.cachedIcnt - 1)) * 100f), 0, 100); int currBuffStacks = cb.GetBuffCount(goldenGunBuff); if (tgtBuffStacks != currBuffStacks) { cb.SetBuffCount(goldenGunBuff, tgtBuffStacks); } }
////// Hooks ////// private void Evt_TILER2GetStatCoefficients(CharacterBody sender, StatHookEventArgs args) { if (!sender) { return; } var totalBuffs = Mathf.Max(sender.GetBuffCount(tacticsBuff) - 1, 0); args.moveSpeedMultAdd += totalBuffs * speedMod; args.baseDamageAdd += totalBuffs * damageMod; args.armorAdd += totalBuffs * armorMod; }
private static void FixedUpdate_On(HooksCore.RoR2.CharacterBody.FixedUpdate.Orig orig, CharacterBody self) { var dt = Time.fixedDeltaTime; try { orig(self); } catch { } if (self.hasEffectiveAuthority) { var maxHp = self.maxHealth; var bcount = self.GetBuffCount(CatalogModule.sporeHealBuff); if (bcount > 0) { self.healthComponent.Heal(bcount * maxHp * dt * SporeContext.healPercentBase, default); } var cbcount = self.GetBuffCount(CatalogModule.critSporeHealBuff); if (cbcount > 0) { var ogch = self.critHeal; self.critHeal = 100f; self.healthComponent.Heal(cbcount * maxHp * dt * SporeContext.healPercentBase, default); self.critHeal = ogch; } } }
private static void CharacterBody_RemoveBuff_BuffIndex(On.RoR2.CharacterBody.orig_RemoveBuff_BuffIndex orig, CharacterBody self, BuffIndex buffType) { if (NetworkServer.active) { BuffIndex buff = DLC1Content.Buffs.BearVoidCooldown.buffIndex; if (buffType == buff && self.GetBuffCount(buff) < 1) { return; } } orig(self, buffType); }
/// <summary> /// Refreshes stacks of a timed buff on a body for a specified duration. Will refresh the entire stack pool of the buff at once. /// </summary> /// <param name="body">The body to check.</param> /// <param name="buffDef">The buff to refresh.</param> /// <param name="duration">The duration all stacks should have.</param> public static void RefreshTimedBuffs(CharacterBody body, BuffDef buffDef, float duration) { if (!body || body.GetBuffCount(buffDef) <= 0) { return; } foreach (var buff in body.timedBuffs) { if (buffDef.buffIndex == buff.buffIndex) { buff.timer = duration; } } }