/// <summary> /// A simplified version of Damage(), used for hero or enemy Fight attacks. /// Returns a Damage object (not an int), which contains 1 or more hits/misses, /// and info on whether each hit was a crit. /// </summary> /// <param name="attStats">BattleStats of the attacker</param> /// <param name="defStats">BattleStats of the defender</param> /// <returns></returns> public static Damage FightDamage(BattleStats attStats, BattleStats defStats) { // Calculate the number of hits int hits = CalcHitsOrMiss(attStats, defStats); // Create an empty Damage object Damage damage = new Damage(); // If no hits, return a Damage with a single value of 0 to signify a miss if (hits <= 0) { damage.Add(0); } else { // Calculate a crit for each hit for (int i = 0; i < hits; i++) { //if (i > 1) { Debug.Log("Hit No. " + (i + 1)); } // CalcCrit(). If crit, increase the multiplier to 2 bool isCrit = false; int critMultiplier = CalcCrit(attStats) ? 2 : 1; if (critMultiplier == 2) { isCrit = true; //Debug.Log("Critical"); } // Adds the value of a crit-modified hit to the list in Damage damage.Add(CalcDamage(attStats, defStats) * critMultiplier, isCrit); } } return(damage); }
// Combines damage type into total combined damage. public void Combine() { Damage total = new Damage(Nature.Source, DamageType.Total, 0, 0); foreach (DamageType type in DamageTypes) { List <Damage> deals = Deals.FindAll(d => d.Is(type)); if (deals.Count > 0) { if (deals.Count > 1) { for (int i = 1; i < deals.Count; ++i) { deals[0].Add(deals[i]); Deals.Remove(deals[i]); } } deals[0].Round(); total.Add(deals[0]); } } Deals.Add(total); }
public void Heal(int amount, GetBonusDto bonusDto) { var maxHp = GetMaxHp(bonusDto).GetValueAsInt(); var currentHp = GetCurrentHp(bonusDto).GetValueAsInt(); var maxAmountToHeal = Math.Min(maxHp - currentHp, amount); var currentNonLethal = GetNonLethal().GetValueAsInt(); var maxAmountToHealNl = currentNonLethal - Math.Max(0, currentNonLethal - amount); if (maxAmountToHeal != 0) { Damage.Add(new DamageTaken { Amount = maxAmountToHeal }); } if (maxAmountToHealNl != 0) { NonLethalDamage.Add(new DamageTaken { Amount = -maxAmountToHealNl }); } }
public void TakeDamage(DamageType damageType, int amount, GetBonusDto bonus, bool ignorreDmgReduction) { var onHitFeats = bonus.Feats.Where(x => x.Limit != null && x.Limit.Amount != null && x.Limit.Amount.ActionRequired == RoundAction.AutoOnTakeDamage).ToList(); foreach (var specialAbility in onHitFeats) { specialAbility.UseChargeIfPossible(amount, bonus); } var realDamge = ignorreDmgReduction ? amount : DamageRecuction.SubtractReduction(amount, damageType, bonus); if (realDamge <= 0) { return; } if (Damage == null) { Damage = new List <DamageTaken>(); } Damage.Add(new DamageTaken { Amount = -realDamge }); }
private void Start() { oscillator.enabled = false; lerper.enabled = true; lerper.Completed += LerpFinish; damage.Add(data.damage); timerIdle = new Timer(UtilRandom.RangeWithCenter(data.secondsToIdle, data.secondsToIdleVariance), TimerIdleFinish, false); timerIdle.Run(); }
private void Start() { timerWarning = new Timer(data.secondsOfWarning, WarningFinish, false); timerIdle = new Timer(data.secondsOfIdling, IdleFinish, false); timerWarning.Run(); GameObject warning = Instantiate(data.prefabWarning, transform); warning.transform.position = transform.position + Vector3.up * warningHeight; // Set the destroy time for the floor spike warning. warning.GetComponent <MonoTimer>().SetSecondsTarget(data.secondsOfWarning); damage.Add(data.damage); heightToRise = UtilRandom.RangeWithCenter(data.heightToRise, data.heightToRiseVariance); }
public DamageNPC(int whoami, int userid = -1, long damage = 0) { whoAmI = whoami; Damage.Add(userid, damage); }
// Combines damage type into total combined damage. public void Combine() { Damage total = new Damage(Nature.Source, DamageType.Total, 0, 0); foreach (DamageType type in DamageTypes) { List<Damage> deals = Deals.FindAll(d => d.Is(type)); if (deals.Count > 0) { if (deals.Count > 1) for (int i = 1; i < deals.Count; ++i) { deals[0].Add(deals[i]); Deals.Remove(deals[i]); } deals[0].Round(); total.Add(deals[0]); } } Deals.Add(total); }
// ----- Private Methods --- // private void BasicWeaponSetup(bool isMagic) { switch (Type) { case WeaponType.Club: Cost = 0.1; Weight = 2; Damage.Add(new DamageDice(new Die(1, 4), DamageType.Bludgeoning, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Light)); break; case WeaponType.Dagger: Cost = 2.0; Weight = 1; Damage.Add(new DamageDice(new Die(1, 4), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Finesse)); Properties.Add(new WeaponProperty(WeaponPropertyType.Light)); Properties.Add(new WeaponProperty(WeaponPropertyType.Thrown, 20, 60)); break; case WeaponType.Greatclub: Cost = 0.2; Weight = 10; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Bludgeoning, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Handaxe: Cost = 5.0; Weight = 2; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Light)); Properties.Add(new WeaponProperty(WeaponPropertyType.Thrown, 20, 60)); break; case WeaponType.Javelin: Cost = 0.5; Weight = 2; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Thrown, 30, 120)); break; case WeaponType.LightHammer: Cost = 2.0; Weight = 2; Damage.Add(new DamageDice(new Die(1, 4), DamageType.Bludgeoning, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Light)); Properties.Add(new WeaponProperty(WeaponPropertyType.Thrown, 20, 60)); break; case WeaponType.Mace: Cost = 5.0; Weight = 4; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Bludgeoning, isMagic)); break; case WeaponType.Quarterstaff: Cost = 0.2; Weight = 4; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Bludgeoning, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Versatile, new Die(1, 8))); break; case WeaponType.Sickle: Cost = 1.0; Weight = 2; Damage.Add(new DamageDice(new Die(1, 4), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Light)); break; case WeaponType.Spear: Cost = 1.0; Weight = 3; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Bludgeoning, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Thrown, 20, 60)); Properties.Add(new WeaponProperty(WeaponPropertyType.Versatile, new Die(1, 8))); break; case WeaponType.LightCrossbow: Cost = 25.0; Weight = 5; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Ammunition, 80, 320)); Properties.Add(new WeaponProperty(WeaponPropertyType.Loading)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Dart: Cost = 0.05; Weight = 0.25; Damage.Add(new DamageDice(new Die(1, 4), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Finesse)); Properties.Add(new WeaponProperty(WeaponPropertyType.Thrown, 20, 60)); break; case WeaponType.Shortbow: Cost = 25; Weight = 2; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Ammunition, 80, 320)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Sling: Cost = 0.1; Weight = 0.0; // Yes Jason, no weight Damage.Add(new DamageDice(new Die(1, 4), DamageType.Bludgeoning, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Ammunition, 30, 120)); break; case WeaponType.Battleaxe: Cost = 10; Weight = 4; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Versatile, new Die(1, 10))); break; case WeaponType.Flail: Cost = 10; Weight = 2; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Bludgeoning, isMagic)); break; case WeaponType.Glaive: Cost = 20; Weight = 6; Damage.Add(new DamageDice(new Die(1, 10), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Heavy)); Properties.Add(new WeaponProperty(WeaponPropertyType.Reach)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Greataxe: Cost = 30; Weight = 7; Damage.Add(new DamageDice(new Die(1, 12), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Heavy)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Greatsword: Cost = 50; Weight = 6; Damage.Add(new DamageDice(new Die(2, 6), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Heavy)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Halberd: Cost = 20; Weight = 6; Damage.Add(new DamageDice(new Die(1, 10), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Heavy)); Properties.Add(new WeaponProperty(WeaponPropertyType.Reach)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Lance: Cost = 10; Weight = 6; Damage.Add(new DamageDice(new Die(1, 12), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Reach)); Properties.Add(new WeaponProperty(WeaponPropertyType.Special)); break; case WeaponType.Longsword: Cost = 15; Weight = 3; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Versatile, new Die(1, 10))); break; case WeaponType.Maul: Cost = 10; Weight = 10; Damage.Add(new DamageDice(new Die(2, 6), DamageType.Bludgeoning, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Heavy)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Morningstar: Cost = 15; Weight = 4; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Piercing, isMagic)); break; case WeaponType.Pike: Cost = 5; Weight = 18; Damage.Add(new DamageDice(new Die(1, 10), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Light)); break; case WeaponType.Rapier: Cost = 25; Weight = 2; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Finesse)); break; case WeaponType.Scimitar: Cost = 25; Weight = 3; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Finesse)); Properties.Add(new WeaponProperty(WeaponPropertyType.Light)); break; case WeaponType.Shortsword: Cost = 10; Weight = 2; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Finesse)); Properties.Add(new WeaponProperty(WeaponPropertyType.Light)); break; case WeaponType.Trident: Cost = 5; Weight = 4; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Thrown, 20, 60)); Properties.Add(new WeaponProperty(WeaponPropertyType.Versatile, new Die(1, 8))); break; case WeaponType.WarPick: Cost = 5; Weight = 2; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Piercing, isMagic)); break; case WeaponType.Warhammer: Cost = 15; Weight = 2; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Bludgeoning, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Versatile, new Die(1, 10))); break; case WeaponType.Whip: Cost = 2; Weight = 3; Damage.Add(new DamageDice(new Die(1, 4), DamageType.Slashing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Finesse)); Properties.Add(new WeaponProperty(WeaponPropertyType.Reach)); break; case WeaponType.Blowgun: Cost = 10; Weight = 1; Damage.Add(new DamageDice(new Die(1, 1), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Ammunition, 25, 100)); Properties.Add(new WeaponProperty(WeaponPropertyType.Loading)); break; case WeaponType.HandCrossbow: Cost = 75; Weight = 3; Damage.Add(new DamageDice(new Die(1, 6), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Ammunition, 30, 120)); Properties.Add(new WeaponProperty(WeaponPropertyType.Light)); Properties.Add(new WeaponProperty(WeaponPropertyType.Loading)); break; case WeaponType.HeavyCrossbow: Cost = 50; Weight = 18; Damage.Add(new DamageDice(new Die(1, 10), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Ammunition, 100, 400)); Properties.Add(new WeaponProperty(WeaponPropertyType.Heavy)); Properties.Add(new WeaponProperty(WeaponPropertyType.Loading)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Longbow: Cost = 50; Weight = 2; Damage.Add(new DamageDice(new Die(1, 8), DamageType.Piercing, isMagic)); Properties.Add(new WeaponProperty(WeaponPropertyType.Ammunition, 150, 600)); Properties.Add(new WeaponProperty(WeaponPropertyType.Heavy)); Properties.Add(new WeaponProperty(WeaponPropertyType.TwoHanded)); break; case WeaponType.Net: Cost = 1; Weight = 3; Properties.Add(new WeaponProperty(WeaponPropertyType.Special)); Properties.Add(new WeaponProperty(WeaponPropertyType.Thrown, 5, 15)); break; default: throw new InvalidOperationException("Error: Weapon Type has not been properly set up"); } }
public void Add(int amount) { damage.Add(amount); }
public virtual void TakeDamage(T DamageToTake) { Damage = Damage.Add(DamageToTake); }
public void AddHeadbuttDamage(int amount) { damageHeadbutt.Add(amount); }
public void AddTongueDamage(int amount) { damageTongue.Add(amount); }
/// <summary> /// Creates a generic, type- and creature-agnostic calculation of Damage. Used /// by every non-Fight option where calculations are required (including healing). /// Returns a Damage object (not an int), which contains 1 or more hits/misses, /// and info on whether each hit was a crit. /// If a BattleAbility is supplied, modifies the results based on the ability's properties. /// </summary> /// <param name="userStats">The attacker's BattleStats</param> /// <param name="targetStats">The defender's BattleStats</param> /// <param name="ability">The BattleAbility being used</param> /// <returns></returns> public static Damage Damage(BattleStats userStats, BattleStats targetStats = null, BattleAbility ability = null) // BattleAbility Properties and their defaults: //float modifier = 1f, bool noMiss = false, int? overrideNumHits = null, bool noCrit = false) { // Negate targetStats if NoReduction if (ability != null && ability.NoReduction) { targetStats = null; } // if there is a HitNumOverride, use it for hits. // if not, if it is NoMiss, hits = 1. // if no HitNumOverride and NoMiss is false, calculate the number of hits. int hits = 1; if (ability.HitNumOverride == null) { if (!ability.NoMiss) { // calculate the num hits, 0 is a miss hits = CalcHitsOrMiss(userStats, targetStats); } //else hits remains at 1 } else { hits = (int)ability.HitNumOverride; } // Damage { list of damage amounts and whether each hit is a crit } // A Damage object contains all the occurences of damage towards a target from this action Damage damage = new Damage(); // a value of 0 is a miss // if hits = 0, damage remains 0, otherwise calculate damage hit times if (hits <= 0) { damage.Add(0); } else { // calculate once per hit for (int i = 0; i < hits; i++) { //if (i > 1) { Debug.Log("Hit No. " + (i + 1)); } // Get a single, initial damage value // if resist-free, targetStats = null as above // CalcDamage will choose which ability scores based on isPhysical float tempDamage = (float)CalcDamage(userStats, targetStats, ability.IsPhysical); // Calculate critMultiplier, leave as 1 if ability prevents crit via NoCrit bool isCrit = false; int critMultiplier = 1; if (!ability.NoCrit) { // Calculate if this hit is a crit. If crit, multiplier is 2, else 1 critMultiplier = CalcCrit(userStats) ? 2 : 1; if (critMultiplier == 2) { isCrit = true; //Debug.Log("Critical"); } } // factor in critModifier tempDamage *= (float)critMultiplier; // factor in ability modifier tempDamage *= ability.Modifier; // Convert to int, and add as an entry to the Damage object damage.Add(Mathf.CeilToInt(tempDamage), isCrit); } } return(damage); }
public void AddLaserDamage(int amount) { damageLaser.Add(amount); }
// Uses the selected item public void Click_UseButton() { if (selection == null) { return; } AudioManager.PlaySound(AudioClipName.UsePotion); // reference to hero and item InvItem item = partyStash.Contents[(int)selection]; BattleHero hero = BattleLoader.Party.Hero[BattleMath.ConvertHeroID(TurnCounter.CurrentID)]; // check for full hp/mp, display message and do not use. int hp = hero.HP; int hpMax = hero.HPMax; if (hp == hpMax && item.Type == InvType.Potion && item.Subtype == InvSubtype.Health) { previousMessage = messageText.text; messageText.text = "You are already at full health."; messageTimer.Run(); return; } int mp = hero.MP; int mpMax = hero.MPMax; if (mp == mpMax && item.Type == InvType.Potion && item.Subtype == InvSubtype.Mana) { previousMessage = messageText.text; messageText.text = "You are already at full mana."; messageTimer.Run(); return; } // create negative damage for restorative item Damage damage = new Damage(); switch (item.Type) { case InvType.Potion: int healing; switch (item.Subtype) { case InvSubtype.Health: switch (item.Name) { case InvNames.Potion_Health_Tiny: healing = 25; break; case InvNames.Potion_Health_Small: healing = 75; break; case InvNames.Potion_Health_Medium: healing = 250; break; case InvNames.Potion_Health_Large: healing = 600; break; case InvNames.Potion_Health_Huge: healing = 2000; break; case InvNames.Potion_Health_Epic: healing = 100000; break; default: healing = 25; break; } if (hp + healing > hpMax) { healing = hpMax - hp; } // remove item from stash and queue healing in Damage partyStash.RemoveInvItem(item.Name, 1); damage.Add(-healing, false, true, false); // amount, not crit, isItem, not MP break; case InvSubtype.Mana: switch (item.Name) { case InvNames.Potion_Mana_Tiny: healing = 10; break; case InvNames.Potion_Mana_Small: healing = 20; break; case InvNames.Potion_Mana_Medium: healing = 50; break; case InvNames.Potion_Mana_Large: healing = 125; break; case InvNames.Potion_Mana_Huge: healing = 250; break; case InvNames.Potion_Mana_Epic: healing = 100000; break; default: healing = 10; break; } if (mp + healing > mpMax) { healing = mpMax - mp; } // remove item from stash and queue healing in Damage partyStash.RemoveInvItem(item.Name, 1); damage.Add(-healing, false, true, true); // amount, not crit, isItem, is MP break; } break; default: damage.Add(null); break; } // disable ui once a choice is made uiEnabler.EnableUI(false); // Invoke a Player End Turn event // Use this event instead of triggering off a fight collision with enemy // TurnOver applies the damage queued in Damage turnInvoker.TurnOver(damage, TurnCounter.CurrentID); // Exit menu Destroy(gameObject); }