/// <summary>
        /// Warning : this method says if this affect may affect this target. But NOT if the target can be the target of the spell 
        /// (cf épée divine, where you cast it on yourself despite it effects only enemies around you)
        /// </summary>
        /// <param name="spellEffect"></param>
        /// <param name="spell"></param>
        /// <param name="caster"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static bool canAffectTarget(EffectDice spellEffect, Spell spell, PlayedFighter caster, Fighter target)
        {
            if (spell.LevelTemplate.spellBreed == (uint)BreedEnum.Eniripsa && spell.Categories == Spell.SpellCategory.Healing && caster.HasState(76)) return false;
            //if (!spell.IsAvailable(target == null ? null : (int?)target.Id)) return false;
            //BiM.Behaviors.Game.Spells.Spell.SpellCategory categories = 0;
            uint surface = spellEffect.Surface;
            //categories = BiM.Behaviors.Game.Spells.Spell.GetEffectCategories((uint)spellEffect.Id, spell.LevelTemplate.id);
            if (spellEffect.Targets == SpellTargetType.NONE) spellEffect.Targets = SpellTargetType.ALL;
            //if (target == null) return !spell.LevelTemplate.needTakenCell;

            if (caster == target) // Self
                return ((spellEffect.Targets & (SpellTargetType.ONLY_SELF | SpellTargetType.SELF)) != 0);

           
            if (caster.Team == target.Team) // Ally
                if (target.Summoned)
                    return ((spellEffect.Targets & SpellTargetType.ALLIES_SUMMON) != 0);
                else
                    return ((spellEffect.Targets & SpellTargetType.ALLIES_NON_SUMMON) != 0);

            if (target.Summoned) // Enemies
                return ((spellEffect.Targets & SpellTargetType.ENEMIES_SUMMON) != 0);
            else
                return ((spellEffect.Targets & SpellTargetType.ENEMIES_NON_SUMMON) != 0);
        }
Example #2
0
 public bool Equals(EffectDice other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(base.Equals(other) && other.m_diceface == m_diceface && other.m_dicenum == m_dicenum);
 }
        /// <summary>
        /// Warning : this method says if this affect may affect this target. But NOT if the target can be the target of the spell
        /// (cf épée divine, where you cast it on yourself despite it effects only enemies around you)
        /// </summary>
        /// <param name="spellEffect"></param>
        /// <param name="spell"></param>
        /// <param name="caster"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static bool canAffectTarget(EffectDice spellEffect, Spell spell, PlayedFighter caster, Fighter target)
        {
            if (spell.LevelTemplate.spellBreed == (uint)BreedEnum.Eniripsa && spell.Categories == Spell.SpellCategory.Healing && caster.HasState(76))
            {
                return(false);
            }
            //if (!spell.IsAvailable(target == null ? null : (int?)target.Id)) return false;
            //BiM.Behaviors.Game.Spells.Spell.SpellCategory categories = 0;
            uint surface = spellEffect.Surface;

            //categories = BiM.Behaviors.Game.Spells.Spell.GetEffectCategories((uint)spellEffect.Id, spell.LevelTemplate.id);
            if (spellEffect.Targets == SpellTargetType.NONE)
            {
                spellEffect.Targets = SpellTargetType.ALL;
            }
            //if (target == null) return !spell.LevelTemplate.needTakenCell;

            if (caster == target) // Self
            {
                return((spellEffect.Targets & (SpellTargetType.ONLY_SELF | SpellTargetType.SELF)) != 0);
            }


            if (caster.Team == target.Team) // Ally
            {
                if (target.Summoned)
                {
                    return((spellEffect.Targets & SpellTargetType.ALLIES_SUMMON) != 0);
                }
                else
                {
                    return((spellEffect.Targets & SpellTargetType.ALLIES_NON_SUMMON) != 0);
                }
            }

            if (target.Summoned) // Enemies
            {
                return((spellEffect.Targets & SpellTargetType.ENEMIES_SUMMON) != 0);
            }
            else
            {
                return((spellEffect.Targets & SpellTargetType.ENEMIES_NON_SUMMON) != 0);
            }
        }
Example #4
0
 public EffectDice(EffectDice copy)
     : this(copy.Id, copy.Value, copy.DiceNum, copy.DiceFace, copy)
 {
 }
Example #5
0
        public EffectDice(EffectDice copy)
            : this(copy.Id, copy.Value, copy.DiceNum, copy.DiceFace, copy)
        {

        }
Example #6
0
 public bool Equals(EffectDice other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return base.Equals(other) && other.m_diceface == m_diceface && other.m_dicenum == m_dicenum;
 }
Example #7
0
        // Precise compute efficiency of a spell for a given category (beware to remove pc from friend and friendcells lists before calling this !)
        // Returns -1 if it would hit friends (todo : optimize if needed)
        public int GetFullAreaEffect(PlayedFighter pc, Cell source, Cell dest, IEnumerable<Fighter> actors, Spell.SpellCategory category, ref string comment)
        {
            SpellImpact spellImpact = new SpellImpact();

            foreach (EffectInstanceDice effect in LevelTemplate.effects)
                if ((Spell.GetEffectCategories((uint)effect.effectId, LevelTemplate.id) & category) > 0)
                {
                    comment += " Effect " + (EffectsEnum)(effect.effectId) + " : ";
                    EffectDice effectCl = new EffectDice(effect);
                    IEnumerable<Cell> cells = effectCl.GetArea(source, dest);
                    SpellTargetType targetType = (SpellTargetType)effect.targetId;
                    int nbAffectedTargets = 0;
                    if (EffectBase.canAffectTarget(effectCl, this, pc, pc) && cells.Contains(source))
                    {
                        // Caster would be affected
                        DamageType efficiency = Spell.CumulEffects(effect, ref spellImpact, pc, pc/*, category*/, this);
                        if (efficiency != 0)
                            comment += string.Format("{0} on {1} => {2}, ", (decimal)efficiency, pc, (decimal)spellImpact.Damage);
                        nbAffectedTargets++;
                        if (efficiency < 0) return 0; // The caster would be affected by a bad spell => give up     
                    }

                    foreach (var actor in actors.Where(act => cells.Contains(act.Cell))) // All actors within the area covered by the spell
                    {
                        if (!EffectBase.canAffectTarget(effectCl, this, pc, actor)) continue; // This actor is not affected by the spell
                        DamageType damage = Spell.CumulEffects(effect, ref spellImpact, pc, actor/*, category*/, this);
                        if (damage != 0)
                            comment += string.Format(" - {0} on {1} => {2}", (decimal)damage, actor, (decimal)spellImpact.Damage);

                        nbAffectedTargets++;
                        //if (damage > 0 && actor.Team == pc.Team) return 0; // Harmful on a friend => give up                        
                    }
                                        
                    //if (nbAffectedTargets > 1)
                    //{
                    //    pc.Character.SendWarning("Spell {0} : {1} targets affected for {2} damage - {3}", this, nbAffectedTargets, spellImpact.Damage, comment);
                    //}
                }

            if (Template.id == 139) // Mot d'altruisme : only use near end of fight or if lot of spellImpact to heal
            {
                int hpLeftOnFoes = actors.Where(actor => actor.Team.Id != pc.Team.Id).Sum(actor => actor.Stats.Health);
                comment += string.Format(" - special \"Mot d'altruisme\" processing : hpLeftOnFoes = {0}, efficiency = {1}", hpLeftOnFoes, (int)spellImpact.Damage);
                if (hpLeftOnFoes > 500) // Not the end of the fight
                    if (spellImpact.Damage < 300) return 0; // Do not cast it if less than 300 hp of healing
                    else
                        return (int)spellImpact.Damage / 3; // Otherwise, far from the end of the fight, divide efficiency by 3                
                // if close to the end of the fight, then returns full result. 
            }
            
            return (int)spellImpact.Damage;
        }