Exemple #1
0
 public static void SendGameActionFightSpellCastMessage(IPacketReceiver client, ActionsEnum actionId, FightActor caster, FightActor target,
                                                        Cell cell, FightSpellCastCriticalEnum critical, bool silentCast,
                                                        Spell spell)
 {
     client.Send(new GameActionFightSpellCastMessage((short)actionId, caster.Id, silentCast, spell.Template.VerboseCast, target == null ? 0 : target.Id, silentCast ? (short)-1 : cell.Id, (sbyte)(critical),
                                                     (short)spell.Id, (sbyte)spell.CurrentLevel, new short[0]));
 }
Exemple #2
0
        public Cell GetCellToCastSpell(TargetCell target, Spell spell, bool LoS, bool nearFirst = true)
        {
            var moveZone = GetMoveZone();
            Set castRange;

            if (spell.CurrentSpellLevel.CastInLine || spell.CurrentSpellLevel.CastInDiagonal)
            {
                castRange = new CrossSet(target.Point, Fighter.GetSpellRange(spell.CurrentSpellLevel),
                                         spell.CurrentSpellLevel.MinRange != 0 ? (int)spell.CurrentSpellLevel.MinRange : CellInformationProvider.IsCellWalkable(target.Cell.Id) ? 0 : 1)
                {
                    Diagonal      = spell.CurrentSpellLevel.CastInDiagonal,
                    AllDirections = spell.CurrentSpellLevel.CastInLine && spell.CurrentSpellLevel.CastInDiagonal
                }
            }
            ;
            else
            {
                castRange = new LozengeSet(target.Point, Fighter.GetSpellRange(spell.CurrentSpellLevel),
                                           spell.CurrentSpellLevel.MinRange != 0 ? (int)spell.CurrentSpellLevel.MinRange : CellInformationProvider.IsCellWalkable(target.Cell.Id) ? 0 : 1);
            }

            var intersection = castRange.EnumerateValidPoints().Intersect(moveZone);

            var closestPoint = intersection.Where(x => Fight.Cells[x.CellId].Walkable &&
                                                  (target.Direction == DirectionFlagEnum.ALL_DIRECTIONS || target.Direction == DirectionFlagEnum.NONE || (x.OrientationTo(target.Point).GetFlag() & target.Direction) != 0) &&
                                                  (!LoS || Fight.CanBeSeen(x, MapPoint.GetPoint(target.Cell), false, Fighter))).
                               OrderBy(x => (nearFirst ? 1 : -1) * x.ManhattanDistanceTo(Fighter.Position.Point)).FirstOrDefault();

            return(closestPoint != null ? Fighter.Fight.Cells[closestPoint.CellId] : null);
        }
Exemple #3
0
        static Color GetGlyphColorBySpell(Spell spell)
        {
            switch (spell.Id)
            {
            case (int)SpellIdEnum.GLYPHE_ENFLAMMÉ:
                return(Color.FromArgb(202, 19, 48));

            case (int)SpellIdEnum.GLYPHE_OPTIQUE:
                return(Color.FromArgb(4, 117, 142));

            case (int)SpellIdEnum.GLYPHE_D_AVEUGLEMENT:
                return(Color.FromArgb(166, 91, 42));

            case (int)SpellIdEnum.GLYPHE_GRAVITATIONNEL:
                return(Color.FromArgb(238, 223, 105));

            case (int)SpellIdEnum.GLYPHE_DE_RÉPULSION:
                return(Color.FromArgb(49, 45, 134));

            case (int)SpellIdEnum.GLYPHE_AGRESSIF_17:
                return(Color.FromArgb(53, 200, 120));

            case (int)SpellIdEnum.DAIPIPAY:
            case (int)SpellIdEnum.CAWOTTE_367:
                return(Color.White);

            default:
                return(Color.Red);
            }
        }
Exemple #4
0
 protected MarkTrigger(short id, FightActor caster, Spell castedSpell, EffectDice originEffect, Cell centerCell, MarkShape shape)
 {
     Id           = id;
     Caster       = caster;
     CastedSpell  = castedSpell;
     OriginEffect = originEffect;
     CenterCell   = centerCell;
     Shape        = shape;
 }
Exemple #5
0
        protected override bool InternalApply()
        {
            var trapSpell = new Spell(Dice.DiceNum, (byte)Dice.DiceFace);

            if (trapSpell.Template == null || !trapSpell.ByLevel.ContainsKey(Dice.DiceFace))
            {
                logger.Error("Cannot find trap spell id = {0}, level = {1}. Casted Spell = {2}", Dice.DiceNum, Dice.DiceFace, Spell.Id);
                return(false);
            }

            var trap = new Trap((short)Fight.PopNextTriggerId(), Caster, Spell, Dice, trapSpell, TargetedCell, EffectZone.ShapeType, (byte)Effect.ZoneMinSize, (byte)Effect.ZoneSize);

            if (Spell.Id == (int)SpellIdEnum.PIÈGE_RÉPULSIF)
            {
                trap.Priority = -1;
            }

            Fight.AddTriger(trap);
            return(true);
        }
Exemple #6
0
        protected override bool InternalApply()
        {
            var runeSpell = new Spell(Dice.DiceNum, (byte)Dice.DiceFace);

            if (runeSpell.Template == null || !runeSpell.ByLevel.ContainsKey(Dice.DiceFace))
            {
                logger.Error("Cannot find rune spell id = {0}, level = {1}. Casted Spell = {2}", Dice.DiceNum, Dice.DiceFace, Spell.Id);
                return(false);
            }

            foreach (var trigger in Fight.GetTriggersByCell(TargetedCell).OfType <Rune>().Where(x => x.Caster.IsFriendlyWith(Caster)))
            {
                trigger.Remove();
            }

            var rune = new Rune((short)Fight.PopNextTriggerId(), Caster, Spell, Dice, runeSpell, TargetedCell, EffectZone.ShapeType, (byte)Effect.ZoneMinSize, (byte)Effect.ZoneSize);

            Fight.AddTriger(rune);

            return(true);
        }
Exemple #7
0
        protected override bool InternalApply()
        {
            var glyphSpell = new Spell(Dice.DiceNum, (byte)Dice.DiceFace);

            if (glyphSpell.Template == null || !glyphSpell.ByLevel.ContainsKey(Dice.DiceFace))
            {
                logger.Error("Cannot find glyph spell id = {0}, level = {1}. Casted Spell = {2}", Dice.DiceNum, Dice.DiceFace, Spell.Id);
                return(false);
            }

            var spell = Spell;

            if (spell.Id == (int)SpellIdEnum.DAIPIPAY)
            {
                spell = glyphSpell;
            }

            Glyph glyph;

            if (Effect.EffectId == EffectsEnum.Effect_GlyphAura)
            {
                glyph = new GlyphAura((short)Fight.PopNextTriggerId(), Caster, spell, Dice, glyphSpell, TargetedCell,
                                      EffectZone.ShapeType, (byte)Effect.ZoneMinSize, (byte)Effect.ZoneSize, GetGlyphColorBySpell(Spell));
            }
            else
            {
                glyph = new Glyph((short)Fight.PopNextTriggerId(), Caster, spell, Dice, glyphSpell, TargetedCell,
                                  EffectZone.ShapeType, (byte)Effect.ZoneMinSize, (byte)Effect.ZoneSize,
                                  GetGlyphColorBySpell(Spell), Effect.EffectId == EffectsEnum.Effect_Glyph,
                                  Effect.EffectId == EffectsEnum.Effect_Glyph_402 ? TriggerType.OnTurnEnd : TriggerType.OnTurnBegin);
            }

            Fight.AddTriger(glyph);

            return(true);
        }
Exemple #8
0
 protected void NotifyTriggered(FightActor target, Spell triggeredSpell)
 {
     Triggered?.Invoke(this, target, triggeredSpell);
 }
Exemple #9
0
        public static void SendGameActionFightTriggerGlyphTrapMessage(IPacketReceiver client, MarkTrigger trigger, FightActor target, Spell triggeredSpell)
        {
            var action = trigger.Type == GameActionMarkTypeEnum.GLYPH ? ActionsEnum.ACTION_FIGHT_TRIGGER_GLYPH : ActionsEnum.ACTION_FIGHT_TRIGGER_TRAP;

            client.Send(new GameActionFightTriggerGlyphTrapMessage((short)action, trigger.Caster.Id, trigger.Id, target.Id, (short)triggeredSpell.Id));
        }
Exemple #10
0
 public static void SendGameActionFightNoSpellCastMessage(IPacketReceiver client, Spell spell)
 {
     client.Send(new GameActionFightNoSpellCastMessage(spell.Id == 0 ? 0 : (int)spell.CurrentSpellLevel.Id));
 }
Exemple #11
0
        public SpellEffectHandler GetSpellEffectHandler(EffectDice effect, FightActor caster, Stump.Server.WorldServer.Game.Spells.Spell spell, Cell targetedCell, bool critical)
        {
            EffectManager.SpellEffectConstructor spellEffectConstructor;
            SpellEffectHandler result;

            if (this.m_spellsEffectHandler.TryGetValue(effect.EffectId, out spellEffectConstructor))
            {
                result = spellEffectConstructor(effect, caster, spell, targetedCell, critical);
            }
            else
            {
                result = new DefaultSpellEffect(effect, caster, spell, targetedCell, critical);
            }
            return(result);
        }