protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) { float localDmgMult = 0; // is a fish if (spellToReactTo.Target.Look.Breed == Characters.Breed.FISH) { localDmgMult = FISHY_TARGET_MULTIPLIER; } else // not a fish { localDmgMult = OTHER_TARGET_MULTIPLIER; } SpellEffect healthDamage = null; for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthDamage == null); i++) { SpellEffect se = spellToReactTo.Result.Effects[i]; AddToModStat addToModStat = se as AddToModStat; if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value < 0) { healthDamage = addToModStat; } } if (healthDamage != null) { healthDamage.Value = (int)Math.Floor(healthDamage.Value * localDmgMult); } }
/// <summary> /// The owner of the buff (the clone) is hit by an offensive spell that deals damage. /// </summary> public override bool IsReact(SingleSpell spellToReactTo, Stats owner) { return(spellToReactTo.SpellBook.SpellType == SpellType.OFFENSE && spellToReactTo.Target.Stats == owner && spellToReactTo.Result.Type.IsSuccessfulType && spellToReactTo.Result.IsDealDamage); }
protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) { spellToReactTo.Result.Effects.Clear(); spellToReactTo.Result.AddEffect( new AddToModStat( spellToReactTo.Caster.Stats, StatType.HEALTH, -spellToReactTo.Caster.Stats.GetStatCount(Stats.Get.MOD, StatType.STRENGTH) * DAMAGE_RATIO_FROM_ATTACK) ); }
public override string ReactToSpell(SingleSpell spell) { if (spell.SpellBook.SpellType == SpellType.OFFENSE && spell.ResultType.IsSuccessfulType && spell.Result.IsDealDamage) { return (Util.PickRandom( "One step closer to death./Do you feel the end coming?/Madness does not die./You slay merely a simulacrum of myself./Merely a replication of my true self./Once again you've fallen for a clone./Maddening, is it not?")); } return(string.Empty); }
public override string ReactToSpell(SingleSpell spell) { int cloneCount = CloneCount; if (cloneCount > 0 && spell.SpellBook.SpellType == SpellType.OFFENSE && spell.ResultType.IsSuccessfulType && brainOwner.Stats.State == State.ALIVE) { return(Util.PickRandom("YOUR NEXT ATTEMPT WILL NOT BE AS SUCCESSFUL./FOOL! YOU DELAY THE INEVITABLE!/MADNESS WILL CONSUME YOU!/DROWN IN INSANITY!")); } return(string.Empty); }
protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) { foreach (SpellEffect se in spellToReactTo.Result.Effects) { AddToModStat addToModStat = se as AddToModStat; if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value < 0) { addToModStat.Value = (int)(addToModStat.Value * DAMAGE_REDUCTION); } } }
public void ReactToSpell(Page page, SingleSpell spellToReactTo, Character buffHolder) { if (this.IsReact(spellToReactTo, buffHolder.Stats)) { page.AddText(new TextBox( string.Format(BUFF_REACT_TEXT, spellToReactTo.CasterName, spellToReactTo.SpellBook.Name, buffHolder.Look.DisplayName, this.Name ), this.Tooltip)); this.React(spellToReactTo, buffHolder.Stats); } }
public void SpellsAreSortedCorrectly() { Character fast = CharacterList.TestEnemy(); fast.Stats.AddToStat(StatType.AGILITY, Stats.Set.MOD_UNBOUND, 100); Character slow = CharacterList.TestEnemy(); Battle dummy = new Battle(new Page("dummy"), new Page("dummy"), Music.NORMAL, "Dummy", new Character[] { fast }, new Character[] { slow }); Spell lowPriorityWithSlowCaster = new SingleSpell(new Scripts.Game.Defined.Unserialized.Spells.ReflectiveClone(), new Result(), slow, fast); Spell lowPriorityWithFastCaster = new SingleSpell(new Scripts.Game.Defined.Unserialized.Spells.ReflectiveClone(), new Result(), fast, slow); Spell normalPriorityWithSlowCaster = new SingleSpell(new Attack(), new Result(), slow, fast); Spell normalPriorityWithFastCaster = new SingleSpell(new Attack(), new Result(), fast, slow); Spell highPriorityWithSlowCaster = new SingleSpell(new Scripts.Game.Defined.Unserialized.Spells.EnemyHeal(), new Result(), slow, slow); Spell highPriorityWithFastCaster = new SingleSpell(new Scripts.Game.Defined.Unserialized.Spells.EnemyHeal(), new Result(), fast, slow); Spell[] expectedOrder = new Spell[] { highPriorityWithFastCaster, highPriorityWithSlowCaster, normalPriorityWithFastCaster, normalPriorityWithSlowCaster, lowPriorityWithFastCaster, lowPriorityWithSlowCaster }; List <Spell> actualOrder = new List <Spell>(); actualOrder.Add(normalPriorityWithSlowCaster); actualOrder.Add(normalPriorityWithFastCaster); actualOrder.Add(highPriorityWithSlowCaster); actualOrder.Add(highPriorityWithFastCaster); actualOrder.Add(lowPriorityWithSlowCaster); actualOrder.Add(lowPriorityWithFastCaster); actualOrder.Sort(); for (int i = 0; i < expectedOrder.Length; i++) { Spell expected = expectedOrder[i]; Spell actual = actualOrder[i]; Debug.Log(string.Format("Index {0}\nExpected: {1}\nActual: {2}\n", i, expected, actual)); Assert.AreSame(expected, actual); } }
/// <summary> /// Add a self damage effect, reflecting the same amount as the attack. /// </summary> protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) { int damageToReflect = 0; foreach (SpellEffect se in spellToReactTo.Result.Effects) { AddToModStat damageHealth = se as AddToModStat; if (damageHealth != null && damageHealth.AffectedStat == StatType.HEALTH) { damageToReflect = damageHealth.Value * REFLECT_DAMAGE_RATIO; } } spellToReactTo.Result.AddEffect( new AddToModStat( spellToReactTo.Caster.Stats, StatType.HEALTH, damageToReflect) ); }
protected override void ReactHelper(SingleSpell spellToReactTo, Stats buffHolder) { SpellEffect healthDamage = null; for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthDamage == null); i++) { SpellEffect se = spellToReactTo.Result.Effects[i]; AddToModStat addToModStat = se as AddToModStat; if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value < 0) { healthDamage = addToModStat; } } if (healthDamage != null) { buffHolder.AddToStat(StatType.HEALTH, Stats.Set.MOD, healthDamage.Value); } }
/// <summary> /// Casts the specified spell from the local spell inventory /// based on the relevent SpellCastData /// </summary> /// <param name="spell"></param> /// <param name="data"></param> public void CastSpell(int spell, SpellCastData data) { //Check if spell number is valid if (spell <= 0 && spell < 2) { SpellKeyDown[spell] = true; //Set the hold figure to tue Spell s = EquiptSpells[spell]; if (s == null) { return; } if (s is SingleSpell) { Debug.Log("single spell"); //If the spell is a single cast, ensure the cool down and mana costs are valid. SingleSpell singSpe = s as SingleSpell; if (CurrentMana > s.ManaCost && SpellTimers[spell].ElapsedMilliseconds > singSpe.CoolDown * 1000) { singSpe.CastSpell(data); AddXp(s); CurrentMana -= s.ManaCost; SpellTimers[spell].Restart(); } else { Debug.Log("Cur man/Cost: " + CurrentMana + "/" + s.ManaCost + " elapsed/cooldown: " + SpellTimers[spell].ElapsedMilliseconds + "/" + singSpe.CoolDown * 1000); } } else { //If the spell is a hold spell, check if we've started casting it. HoldSpell holdSpel = s as HoldSpell; if (!holdSpel.IsCast) { Debug.Log("Casting"); holdSpel.SpellStart(data); AddXp(s); CurrentMana -= s.ManaCost * Time.deltaTime; } //If we are casting, it is dealth with in the u[ } } }
protected override void ReactHelper(SingleSpell spellToReactTo, Stats owner) { SpellEffect healthDamage = null; for (int i = 0; (i < spellToReactTo.Result.Effects.Count) && (healthDamage == null); i++) { SpellEffect se = spellToReactTo.Result.Effects[i]; AddToModStat addToModStat = se as AddToModStat; if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value < 0) { healthDamage = addToModStat; } } if (healthDamage != null) { int tempValue = healthDamage.Value; healthDamage.Value = (int)Math.Floor(healthDamage.Value * DAMAGE_MULTIPLIER); } }
public override bool IsReact(SingleSpell incomingSpell, Stats statsOfTheCharacterTheBuffIsOn) { bool isDealDamageToBuffCaster = false; // Intercepting adds an add to mod stat, so the spell technically does damage even after we wipe it // isDealDamage returns true regardless of whether the caster or target is taking damage // But we want to stop adding damage after the first tentacle intercepts the attack // which wipes the spell's effects and replaces it with a single addToModStat health damage foreach (SpellEffect se in incomingSpell.Result.Effects) { AddToModStat addToModStat = se as AddToModStat; if (addToModStat != null && addToModStat.AffectedStat == StatType.HEALTH && addToModStat.Value < 0 && addToModStat.Target == BuffCaster) { isDealDamageToBuffCaster = true; } } return(incomingSpell.Target.Stats == BuffCaster && isDealDamageToBuffCaster); }
/// <summary> /// Reaction to a spell targeting this character. /// </summary> /// <param name="spellThatTargetsThisCharacter"></param> /// <returns>String that is converted into an avatarbox.</returns> public virtual string ReactToSpell(SingleSpell spellThatTargetsThisCharacter) { return(string.Empty); }
public override bool IsReact(SingleSpell spellToReactTo, Stats owner) { return(spellToReactTo.SpellBook is Attack && spellToReactTo.Target.Stats == owner); }
protected override void ReactHelper(SingleSpell s, Stats owner) { s.Result.Effects.Clear(); s.Result.AddEffect(new AddToModStat(s.Caster.Stats, StatType.HEALTH, -INTERCEPTION_DAMAGE)); }
/// <summary> /// If true, buff will react to the spells being cast in battle. This can be any spell. /// The one who has the buff doesn't have to be targeted. /// </summary> /// <param name="incomingSpell">Spell cast on character</param> /// <param name="ownerOfThisBuff">Stats of the character who is the target of the spell</param> /// <returns>True if the buff will react.</returns> public virtual bool IsReact(SingleSpell incomingSpell, Characters.Stats ownerOfThisBuff) { return(false); }
/// <summary> /// Respond to a spell cast in battle. /// </summary> /// <param name="incomingSpell">Spell cast on character</param> /// <param name="ownerOfThisBuff">Stats of the character who is the target of the spell</param> private void React(SingleSpell incomingSpell, Characters.Stats ownerOfThisBuff) { ReactHelper(incomingSpell, ownerOfThisBuff); }
public override bool IsReact(SingleSpell spellToReactTo, Stats owner) { return(spellToReactTo.Target.Stats == owner && spellToReactTo.Result.IsDealDamage); }
public override bool IsReact(SingleSpell spellToReactTo, Stats owner) { return(spellToReactTo.SpellBook is Attack && spellToReactTo.Result.IsDealDamage && spellToReactTo.Caster.Stats == owner); }
/// <see cref="React(Spell, Characters.Stats)"/> protected virtual void ReactHelper(SingleSpell spellCast, Characters.Stats ownerOfThisBuff) { }
public bool Reg(SingleSpell mod) { return(Reg(mod.GetType())); }