Esempio n. 1
0
        public override bool Apply()
        {
            FightActor target = this.Fight.GetOneFighter(this.TargetedCell);

            if (target == null)
            {
                return(false);
            }

            this.Caster.Carry(target);
            this.OnApply(target.Id);

            return(true);
        }
Esempio n. 2
0
        static void OnBuffTriggered(TriggerBuff buff, FightActor triggerrer, BuffTriggerType trigger, object token)
        {
            var damages = new Fights.Damage(buff.Dice, EffectSchoolEnum.Unknown, buff.Caster, buff.Spell, buff.Target.Cell)
            {
                Buff       = buff,
                IsCritical = buff.Critical,
            };

            damages.GenerateDamages();
            buff.Target.InflictDirectDamage(damages.Amount);

            var heal = (int)Math.Floor(damages.Amount / 2d);

            buff.Caster.Heal(heal, buff.Target, true);
        }
Esempio n. 3
0
        protected override void OnFighterRemoved(FightTeam team, FightActor actor)
        {
            if (State == FightState.Placement && team == ChallengersTeam && actor is CharacterFighter characterFighter)
            {
                TaxCollectorHandler.SendGuildFightPlayersEnemyRemoveMessage(
                    TaxCollector.TaxCollectorNpc.Guild.Clients, TaxCollector.TaxCollectorNpc, characterFighter.Character);
            }

            if (actor is TaxCollectorFighter taxCollector && taxCollector.IsAlive())
            {
                taxCollector.TaxCollectorNpc.RejoinMap();
            }

            base.OnFighterRemoved(team, actor);
        }
Esempio n. 4
0
 public static void HandleGameActionFightCastOnTargetRequestMessage(WorldClient client, GameActionFightCastOnTargetRequestMessage message)
 {
     if (client.Character.IsFighting())
     {
         CharacterSpell spell = client.Character.Spells.GetSpell((int)message.spellId);
         if (spell != null)
         {
             FightActor oneFighter = client.Character.Fight.GetOneFighter(message.targetId);
             if (oneFighter != null)
             {
                 client.Character.Fighter.CastSpell(spell, oneFighter.Cell);
             }
         }
     }
 }
Esempio n. 5
0
        void ReduceBuffsDuration(FightActor actor, short duration)
        {
            foreach (var buff in actor.GetBuffs().Where(buff => buff.Dispellable == FightDispellableEnum.DISPELLABLE).Where(buff => buff.Duration > 0 && buff.Delay == 0).ToArray())
            {
                buff.Duration -= duration;

                if (buff.Duration <= 0)
                {
                    actor.RemoveBuff(buff);
                }
            }

            actor.TriggerBuffs(actor, BuffTriggerType.OnDispelled);
            ContextHandler.SendGameActionFightModifyEffectsDurationMessage(Fight.Clients, Effect.Id, Caster, actor, (short)-duration);
        }
Esempio n. 6
0
        void DamageModifier(TriggerBuff buff, FightActor triggerer, BuffTriggerType trigger, object token)
        {
            var damage = token as Fights.Damage;

            if (damage == null)
            {
                return;
            }

            damage.EffectGenerationType = Dice.EffectId == EffectsEnum.Effect_RandDownModifier ?
                                          EffectGenerationType.MinEffects : EffectGenerationType.MaxEffects;

            damage.Generated = false;
            damage.GenerateDamages();
        }
Esempio n. 7
0
        void OnBeforeTurnStopped(IFight fight, FightActor fighter)
        {
            if (!(fighter is CharacterFighter) || fighter.IsDead())
            {
                return;
            }

            if (!fighter.Position.Point.GetAdjacentCells(x => m_team.GetOneFighter(y => y.IsAlive() && y.Cell == Fight.Map.GetCell(x)) != null).Any())
            {
                return;
            }

            UpdateStatus(ChallengeStatusEnum.FAILED);
            Fight.BeforeTurnStopped -= OnBeforeTurnStopped;
        }
Esempio n. 8
0
        void OnDead(FightActor victim, FightActor killer)
        {
            if (Target == null)
            {
                return;
            }

            if (victim == Target || victim.Level == Target.Level)
            {
                Target = GetNextTarget();
                return;
            }

            UpdateStatus(ChallengeStatusEnum.FAILED, killer);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        private void Enter(FightActor actor)
        {
            var handler = SpellManager.Instance.GetSpellCastHandler(Caster, GlyphSpell, actor.Cell, false);

            handler.MarkTrigger = this;
            handler.Initialize();
            foreach (var effectHandler in handler.GetEffectHandlers())
            {
                effectHandler.SetAffectedActors(new [] { actor });
            }
            handler.Execute();

            actor.PositionChanged += OnPositionChanged;
            m_actorsInside.Add(actor);
        }
Esempio n. 11
0
        private void OnBeforeTurnStopped(IFight fight, FightActor fighter)
        {
            if (!(fighter is CharacterFighter))
            {
                return;
            }

            if (fighter.UsedMP == 1)
            {
                return;
            }

            UpdateStatus(ChallengeStatusEnum.FAILED);
            Fight.BeforeTurnStopped -= OnBeforeTurnStopped;
        }
Esempio n. 12
0
        private void TriggerBuff(TriggerBuff buff, FightActor triggerrer, BuffTriggerType trigger, object token)
        {
            var spellId  = Dice.DiceNum;
            var cooldown = Dice.Value;

            var spell = buff.Target.GetSpell(spellId);

            if (spell == null)
            {
                return;
            }

            buff.Target.SpellHistory.RegisterCastedSpell(new SpellHistoryEntry(buff.Target.SpellHistory, spell.CurrentSpellLevel,
                                                                               Caster, buff.Target, Fight.TimeLine.RoundNumber, cooldown));
            ActionsHandler.SendGameActionFightSpellCooldownVariationMessage(buff.Target.Fight.Clients, Caster, buff.Target, spell, cooldown);
        }
Esempio n. 13
0
        public override bool IsTargetValid(FightActor actor, SpellEffectHandler handler)
        {
            if (Caster)
            {
                actor = handler.Caster;
            }

            if (actor is CharacterFighter)
            {
                return(Required ? (int)((CharacterFighter)actor).Character.BreedId == Breed : (int)((CharacterFighter)actor).Character.BreedId != Breed);
            }
            else
            {
                return(Required ? (int)BreedEnum.MONSTER == Breed : (int)BreedEnum.MONSTER != Breed);
            }
        }
Esempio n. 14
0
        public bool InsertFighter(FightActor fighter, int index)
        {
            if (index > Fighters.Count)
            {
                return(false);
            }

            Fighters.Insert(index, fighter);

            if (index <= Index)
            {
                Index++;
            }

            return(true);
        }
Esempio n. 15
0
        protected override void OnFighterAdded(FightTeam team, FightActor actor)
        {
            base.OnFighterAdded(team, actor);

            if (!(team is FightMonsterTeam) || m_ageBonusDefined)
            {
                return;
            }

            if (team.Leader is MonsterFighter monsterFighter)
            {
                AgeBonus = monsterFighter.Monster.Group.AgeBonus;
            }

            m_ageBonusDefined = true;
        }
Esempio n. 16
0
        public void UpdateStatus(ChallengeStatusEnum status, FightActor from = null)
        {
            if (Status != ChallengeStatusEnum.RUNNING)
            {
                return;
            }

            Status = status;

            ContextHandler.SendChallengeResultMessage(Fight.Clients, this);

            if (Status == ChallengeStatusEnum.FAILED && @from is CharacterFighter)
            {
                BasicHandler.SendTextInformationMessage(Fight.Clients, TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 188, ((CharacterFighter)from).Name, Id);
            }
        }
Esempio n. 17
0
 public override bool Apply()
 {
     System.Collections.Generic.IEnumerable <FightActor> allFighters = base.Fight.GetAllFighters((FightActor f) => f.IsAlive());
     foreach (FightActor current in allFighters)
     {
         Cell       cell       = current.FightStartPosition.Cell;
         FightActor oneFighter = base.Fight.GetOneFighter(cell);
         if (oneFighter != null)
         {
             this.MoveOldFighter(oneFighter);
         }
         current.Position.Cell = cell;
         ActionsHandler.SendGameActionFightTeleportOnSameMapMessage(base.Fight.Clients, base.Caster, current, cell);
     }
     return(true);
 }
Esempio n. 18
0
        void OnWeaponUsed(FightActor fighter, WeaponTemplate weapon, Cell cell, FightSpellCastCriticalEnum critical, bool silentCast)
        {
            if (critical == FightSpellCastCriticalEnum.CRITICAL_FAIL)
            {
                return;
            }

            if (m_weaponsUsed.Any(x => x.First == fighter && x.Second == Fight.TimeLine.RoundNumber))
            {
                UpdateStatus(ChallengeStatusEnum.FAILED);
            }
            else
            {
                m_weaponsUsed.Add(new Pair <FightActor, int>(fighter, Fight.TimeLine.RoundNumber));
            }
        }
Esempio n. 19
0
        void OnDead(FightActor fighter, FightActor killer)
        {
            fighter.Dead -= OnDead;

            if (!(killer is CharacterFighter))
            {
                return;
            }

            if (killer.Team.Fighters.OrderBy(x => x.Level).FirstOrDefault() == killer)
            {
                return;
            }

            UpdateStatus(ChallengeStatusEnum.FAILED);
        }
Esempio n. 20
0
        void OnBuffTriggered(TriggerBuff buff, FightActor triggerer, BuffTriggerType trigger, object token)
        {
            var damage = token as Fights.Damage;

            if (damage == null)
            {
                return;
            }

            if (damage.Spell != null && Caster.IsPoisonSpellCast(damage.Spell))
            {
                return;
            }

            damage.Amount = (int)Math.Round(damage.Amount * (Dice.DiceNum / 100.0));
        }
Esempio n. 21
0
        void OnSpellCasting(FightActor caster, SpellCastHandler spellCastHandler)
        {
            if (spellCastHandler.Informations.Critical == FightSpellCastCriticalEnum.CRITICAL_FAIL)
            {
                return;
            }

            var entries = caster.SpellHistory.GetEntries(x => x.Spell.SpellId == spellCastHandler.Spell.Id);

            if (!entries.Any())
            {
                return;
            }

            UpdateStatus(ChallengeStatusEnum.FAILED);
        }
Esempio n. 22
0
        void OnWeaponUsed(FightActor fighter, WeaponTemplate weapon, Cell cell, FightSpellCastCriticalEnum critical, bool silentCast)
        {
            if (critical == FightSpellCastCriticalEnum.CRITICAL_FAIL)
            {
                return;
            }

            if (m_weaponsUsed.Contains(fighter))
            {
                UpdateStatus(ChallengeStatusEnum.FAILED);
            }
            else
            {
                m_weaponsUsed.Add(fighter);
            }
        }
Esempio n. 23
0
        void OnTurnStopped(IFight fight, FightActor player)
        {
            if (fight.TimeLine.Next != this)
            {
                return;
            }

            var characterFighter = Summoner as CharacterFighter;

            if (characterFighter == null)
            {
                return;
            }

            ContextHandler.SendSlaveSwitchContextMessage(characterFighter.Character.Client, this);
        }
Esempio n. 24
0
        void OnTurnStarted(IFight fight, FightActor fighter)
        {
            if (!(fighter is CharacterFighter))
            {
                return;
            }

            int round;

            m_contaminedFighters.TryGetValue(fighter, out round);

            if ((Fight.TimeLine.RoundNumber - round) >= 5)
            {
                UpdateStatus(ChallengeStatusEnum.FAILED, fighter);
            }
        }
Esempio n. 25
0
        void OnTurnStopped(IFight fight, FightActor fighter)
        {
            if (!(fighter is CharacterFighter))
            {
                return;
            }

            if (fighter.Position?.Cell.Id == fighter.TurnStartPosition?.Cell.Id)
            {
                return;
            }

            UpdateStatus(ChallengeStatusEnum.FAILED);

            Fight.TurnStopped -= OnTurnStopped;
        }
Esempio n. 26
0
        public override void Trigger(FightActor trigger, Cell triggerCell)
        {
            NotifyTriggered(trigger, GlyphSpell);

            var handler = SpellManager.Instance.GetSpellCastHandler(Caster, GlyphSpell, trigger.Cell, false);

            handler.MarkTrigger = this;
            handler.TriggerCell = triggerCell;
            handler.Initialize();

            foreach (var effectHandler in handler.GetEffectHandlers())
            {
                effectHandler.SetAffectedActors(effectHandler.IsValidTarget(trigger) ? new[] { trigger } : new FightActor[0]);
            }

            handler.Execute();
        }
Esempio n. 27
0
        protected override void OnDead(FightActor killedBy, bool passTurn = true)
        {
            Fight.TurnStarted        -= OnTurnStarted;
            Summoner.DamageInflicted -= OnCasterDamageInflicted;

            using (Fight.StartSequence(SequenceTypeEnum.SEQUENCE_SPELL))
            {
                ActionsHandler.SendGameActionFightVanishMessage(Fight.Clients, Summoner, this);

                Summoner.RemoveSummon(this);

                if (!Summoner.Summons.Any(x => x is SummonedImage))
                {
                    Summoner.SetInvisibilityState(GameActionFightInvisibilityStateEnum.VISIBLE);
                }
            }
        }
Esempio n. 28
0
        void OnBuffTriggered(TriggerBuff buff, FightActor triggerrer, BuffTriggerType trigger, object token)
        {
            var damage = token as Fights.Damage;

            if (damage == null)
            {
                return;
            }

            if (damage.Spell != null && Caster.IsPoisonSpellCast(damage.Spell))
            {
                return;
            }

            buff.Target.Heal(damage.Amount, damage.Source, true);
            damage.Amount = 0;
        }
        public Cell GetCellToCastSpell(FightActor target, Spell spell)
        {
            MapPoint mapPoint = (
                from entry in target.Position.Point.GetAdjacentCells(new Func <short, bool>(this.CellInformationProvider.IsCellWalkable))
                orderby entry.DistanceToCell(this.Fighter.Position.Point)
                select entry).FirstOrDefault <MapPoint>();
            Cell result;

            if (mapPoint == null)
            {
                result = null;
            }
            else
            {
                result = this.CellInformationProvider.GetCellInformation(mapPoint.CellId).Cell;
            }
            return(result);
        }
Esempio n. 30
0
        public override void Trigger(FightActor trigger)
        {
            base.NotifyTriggered(trigger, this.TrapSpell);
            MarkShape[] shapes = base.Shapes;
            for (int i = 0; i < shapes.Length; i++)
            {
                MarkShape        markShape        = shapes[i];
                SpellCastHandler spellCastHandler = Singleton <SpellManager> .Instance.GetSpellCastHandler(base.Caster, this.TrapSpell, markShape.Cell, false);

                spellCastHandler.MarkTrigger = this;
                spellCastHandler.Initialize();
                foreach (SpellEffectHandler current in spellCastHandler.GetEffectHandlers())
                {
                    current.EffectZone = new Zone((markShape.Shape == GameActionMarkCellsTypeEnum.CELLS_CROSS) ? SpellShapeEnum.Q : current.Effect.ZoneShape, markShape.Size);
                }
                spellCastHandler.Execute();
            }
        }