/// <summary> /// Have the player cleanse, restoring some willpower and reduce TF Energies, modified by the player's buffs /// </summary> /// <param name="buffs">Player's buffs</param> /// <returns>Cleanse amount</returns> public string Cleanse(BuffBox buffs) { CleansesMeditatesThisRound++; ActionPoints -= PvPStatics.CleanseCost; Mana -= PvPStatics.CleanseManaCost; LastActionTimestamp = DateTime.UtcNow; var result = ""; var cleanseBonusTFEnergyRemovalPercent = buffs.CleanseExtraTFEnergyRemovalPercent() + PvPStatics.CleanseTFEnergyPercentDecrease; var cleanseWPRestore = PvPStatics.CleanseHealthRestoreBase + buffs.CleanseExtraHealth(); var outOfCombat = false; // Increase the rate of cleansing outside of combat var lastAttackTimeAgo = Math.Abs(Math.Floor(GetLastCombatTimestamp().Subtract(DateTime.UtcNow).TotalSeconds)); if (lastAttackTimeAgo > 3 * TurnTimesStatics.GetTurnLengthInSeconds()) { outOfCombat = true; } if (cleanseWPRestore <= 0) { result = "You try to cleanse, but due to the magical effects on your body you fail to restore any willpower."; } else { if (outOfCombat) { AddHealth(cleanseWPRestore * 3); result = $"You take your time cleansing yourself, restoring {cleanseWPRestore * 3:#} willpower."; } else { AddHealth(cleanseWPRestore); result = $"You quickly cleanse, restoring {cleanseWPRestore:#} willpower."; } } if (cleanseBonusTFEnergyRemovalPercent > 0) { CleanseTFEnergies(buffs); } if (BotId == AIStatics.ActivePlayerBotId) { var location = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == Location); AddLog($"You cleansed at {location.Name}.", false); } return(result); }
/// <summary> /// Removes a percentage of TF energy that this player has, determined by the stats passed in /// </summary> /// <param name="buffs">Buffs owned by the player</param> public void CleanseTFEnergies(BuffBox buffs) { var cleansePercentage = buffs.CleanseExtraTFEnergyRemovalPercent() + PvPStatics.CleanseTFEnergyPercentDecrease; // Increase the rate of TFE cleansing outside of combat var lastAttackTimeAgo = Math.Abs(Math.Floor(GetLastCombatTimestamp().Subtract(DateTime.UtcNow).TotalSeconds)); if (lastAttackTimeAgo > 3 * TurnTimesStatics.GetTurnLengthInSeconds()) { cleansePercentage = (cleansePercentage * 5); } foreach (var energy in TFEnergies) { var newValue = energy.Amount - cleansePercentage; energy.SetAmount(newValue); } }