Example #1
0
        public override void Apply()
        {
            try
            {
                MonsterFighter monster = Result.Fighter.OposedTeam().GetFighters <MonsterFighter>(false).FindAll(x => !x.Template.IsBoss && !x.Template.IsMiniBoss && !ForbiddenMonsters.Contains(x.Template.Id)).Random();
                if (monster != null)
                {
                    if (new AsyncRandom().TriggerAleat(MinationDropPercentage))
                    {
                        AddMinationItem(monster);
                    }
                }

                var boss = Result.Fighter.OposedTeam().GetFighters <MonsterFighter>(false).FindAll(x => x.Template.IsBoss || x.Template.IsMiniBoss).Random();

                if (boss != null && new AsyncRandom().TriggerAleat(6))
                {
                    AddMinationItem(boss);
                }
            }
            catch (Exception ex)
            {
                Logger.Write <MinationLoot>(ex.ToString(), ConsoleColor.DarkRed);
            }
        }
        public override void Execute(MonsterFighter fighter)
        {
            var     martyrSpell = fighter.Template.Spells[0];
            Fighter lower       = fighter.Team.LowerFighter();

            fighter.CastSpellOnTarget(martyrSpell, lower.ContextualId);
        }
Example #3
0
        public override int ApplyEffect(EffectCast CastInfos)
        {
            // Possibilité de spawn une creature sur la case ?
            if (CastInfos.Caster.Fight.IsCellWalkable(CastInfos.CellId))
            {
                var InvocationId    = CastInfos.Value1;
                var InvocationLevel = CastInfos.Value2;
                var Monster         = MonsterTable.GetMonster(InvocationId);

                // Template de monstre existante
                if (Monster != null)
                {
                    Monster.Initialize();
                    var MonsterLevel = Monster.GetLevelOrNear(InvocationLevel);

                    // Level de monstre existant
                    if (MonsterLevel != null)
                    {
                        var MonsteFighter = new MonsterFighter(CastInfos.Caster.Fight, MonsterLevel, CastInfos.Caster.Fight.NextActorInvocationId(CastInfos.Caster), Invocator: CastInfos.Caster);
                        MonsteFighter.JoinFight();
                        MonsteFighter.Fight.JoinFightTeam(MonsteFighter, CastInfos.Caster.Team, false, CastInfos.CellId);
                        MonsteFighter.Fight.RemakeTurns();
                        MonsteFighter.Fight.SendToFight(new GameInformationCoordinateMessage(MonsteFighter.Fight.Fighters));
                        MonsteFighter.Fight.SendToFight(new GameTurnListMessage(MonsteFighter.Fight.getWorkerFighters()));
                        MonsteFighter.Fight.GetCell(CastInfos.CellId).GetObjects <FightGroundLayer>().ForEach(x => x.onWalkOnLayer(MonsteFighter, MonsteFighter.Fight.GetCell(CastInfos.CellId)));
                    }
                }
            }

            return(-1);
        }
Example #4
0
        public MonsterIA(MonsterFighter player)
        {
            Thread t = new Thread(() =>
            {
                switch (player.IA)
                {
                case 1:
                    while (!player.Dead)
                    {
                        Fighter enemy  = GetNearestEnnemy(player.Fight, player);
                        Fighter friend = GetNearestFriend(player.Fight, player);

                        //TODO play

                        break;
                    }
                    break;
                }

                System.Threading.Thread.Sleep(1000);

                player.Fight.State = FightState.WAITING;
                player.Fight.PlayerTurnReady(player);
            });

            t.Start();
        }
Example #5
0
        public MonsterFighter AddSummon(Fighter master, short monsterid, sbyte grade, short cellid, FightTeam team)
        {
            MonsterFighter summoned = new MonsterFighter(MonsterRecord.GetMonster((ushort)monsterid),
              team, grade, cellid, master.ContextualId);
            if (summoned.Template.UseSummonSlot && !summoned.Template.UseBombSlot)
            TimeLine.Insert(summoned, master);
            Send(new GameActionFightSummonMessage(181, summoned.ContextualId, summoned.FighterInformations));
            Send(new GameFightTurnListMessage(TimeLine.GenerateTimeLine(false), new int[0]));
            return summoned;

        }
Example #6
0
 protected override void OnFighterAdded(FightTeam team, FightActor actor)
 {
     base.OnFighterAdded(team, actor);
     if (team is FightMonsterTeam && !this.m_ageBonusDefined)
     {
         MonsterFighter monsterFighter = team.Leader as MonsterFighter;
         if (monsterFighter != null)
         {
             base.AgeBonus = monsterFighter.Monster.Group.AgeBonus;
         }
         this.m_ageBonusDefined = true;
     }
 }
Example #7
0
        public static void TryCast(MonsterFighter fighter, ushort spellid, Fighter target)
        {
            var level = fighter.GetSpellLevel(spellid);

            if (target != null && fighter.FighterStats.Stats.ActionPoints - level.ApCost >= 0)
            {
                var refreshedTarget = fighter.Fight.GetFighter(target.CellId);
                if (refreshedTarget != null && !fighter.HaveCooldown((short)spellid) && fighter.CanCast(target.CellId, level, refreshedTarget))
                {
                    fighter.CastSpellOnCell(spellid, target.CellId);
                }
            }
        }
Example #8
0
        [EffectHandler(EffectsEnum.Eff_405)] // Invocation Sadida
        public static void SadidaSummon(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castCellId)
        {
            if (affecteds.Count > 0)
            {
                MonsterFighter affected = affecteds.First() as MonsterFighter;

                if (affected != null && affected.FighterStats.SummonerId == fighter.ContextualId)
                {
                    MonsterFighter summoned = fighter.Fight.AddSummon(fighter, effect.BaseEffect.DiceNum, fighter.GetSpellLevel(level.SpellId).Grade, castCellId, fighter.Team);
                    summoned.AddBuff(new OnSadidaSummonDieEffect((uint)fighter.BuffIdProvider.Pop(), 0, -1, 0, 0, level.Grade, 0));
                    affected.Die();
                }
            }
        }
Example #9
0
        private Fighter GetNearestFriend(Fight fight, MonsterFighter player)
        {
            int     dist = 1000;
            Fighter curF = null;

            foreach (Fighter f in fight.GetFighters().Where(x => !x.Dead && x.Team == player.Team && !x.Buffs.HasBuff(EffectEnum.Invisible, BuffActiveType.ACTIVE_STATS)).ToList())
            {
                int d = Pathfinding.GetDistanceBetween(fight.Map, player.Cell, f.Cell);
                if (d < dist)
                {
                    dist = d;
                    curF = f;
                }
            }

            return(curF);
        }
        public override void Execute(MonsterFighter fighter)
        {
            var summonSpell = fighter.Template.Spells.ConvertAll <SpellRecord>(x => SpellRecord.GetSpell(x)).Find(x => x.Category == SpellCategoryEnum.Summon);

            if (summonSpell != null && fighter.SummonCount <= 1)
            {
                var cells = ShapesProvider.GetSquare(fighter.CellId, false);
                var cell  = cells.Find(x => !fighter.Fight.IsObstacle(x));
                if (cell != 0)
                {
                    fighter.CastSpellOnCell(summonSpell.Id, cell);
                }
                else
                {
                    fighter.Fight.Reply("Unable to summon");
                }
            }
        }
Example #11
0
        public Fighter AIGetNearestFighter(Fight fight, MonsterFighter fighter)
        {
            var map = fight.Map;

            var cellChallengers = fight.Challengers.Where(c => c.Life > 0).Select(x => map.MapData.Cells.ToList().FirstOrDefault(c => c.Id == x.CellId)).ToList();
            var cellData        = map.MapData.Cells.ToList().FirstOrDefault(x => x.Id == fighter.CellId);

            if (map != null)
            {
                var nearestChallengerCell = cellChallengers.OrderBy(x => MapManager.Instance.DistanceBetweenCell(new Point(cellData.X, cellData.Y), new Point(x.X, x.Y))).FirstOrDefault();

                if (nearestChallengerCell != null)
                {
                    Console.WriteLine("{0} is nearest cellId.", nearestChallengerCell.Id);
                    return(fight.Challengers.Find(x => x.CellId == nearestChallengerCell.Id));
                }
            }

            return(null);
        }
Example #12
0
        public override async Task Handle()
        {
            var account = _account;

            string[] separador = _package.Substring(4).Split('|');

            for (int i = 0; i < separador.Length; ++i)
            {
                string[]        _loc6_  = separador[i].Split(';');
                int             id      = int.Parse(_loc6_[0]);
                AbstractFighter fighter = account.Character.Fight.GetFighterById(id);

                if (_loc6_.Length != 0)
                {
                    int   healt_current = int.Parse(_loc6_[2]);
                    byte  pa            = byte.Parse(_loc6_[3]);
                    byte  pm            = byte.Parse(_loc6_[4]);
                    short cell          = short.Parse(_loc6_[5]);
                    int   healt_max     = int.Parse(_loc6_[7]);

                    if (cell > 0)//son espectadores
                    {
                        byte equipo = Convert.ToByte(id > 0 ? 0 : 1);
                        if (fighter != null)
                        {
                            account.Character.Fight.UpdateFighter(fighter, healt_current, _loc6_[1].Equals("0"), pa, pm, healt_max, cell);
                        }
                        else
                        {
                            var newFighter = new MonsterFighter(id, equipo, _loc6_[1].Equals("0"), healt_current, healt_max, account.Character.Fight.Map.GetCellFromId(cell), pa, pm);
                            account.Character.Fight.AddFighter(newFighter);
                        }
                    }
                }
            }
        }
Example #13
0
        public override void Execute(MonsterFighter fighter)
        {
            if (fighter.FighterStats.Stats.MovementPoints <= 0)
            {
                return;
            }

            Fighter lower = fighter.Team.LowerFighter();
            var     path  = new Pathfinder(fighter.Fight.Map, fighter.CellId);

            path.PutEntities(fighter.Fight.GetAllFighters());
            var cells = path.FindPath(lower.CellId);

            if (cells == null || cells.Count() <= 1)
            {
                return;
            }
            cells.Remove(cells.Last());
            cells.Insert(0, fighter.CellId);
            cells = cells.Take(fighter.FighterStats.Stats.MovementPoints + 1).ToList();
            sbyte direction = PathParser.GetDirection(cells.Last());

            fighter.Move(cells, cells.Last(), direction);
        }
Example #14
0
        public override void Execute(MonsterFighter fighter)
        {
            Fighter lower = fighter.GetOposedTeam().LowerFighter();

            if (lower == null)
            {
                return;
            }
            var spells = fighter.Template.Spells.ConvertAll <SpellRecord>(x => SpellRecord.GetSpell(x));


            foreach (var spell in spells.FindAll(x => x.Category == SpellCategoryEnum.Damages))
            {
                TryCast(fighter, spell.Id, lower);
            }
            foreach (var spell in spells.FindAll(x => x.Category == SpellCategoryEnum.Agress))
            {
                TryCast(fighter, spell.Id, lower);
            }
            foreach (var spell in spells.FindAll(x => x.Category == SpellCategoryEnum.Undefined))
            {
                TryCast(fighter, spell.Id, lower);
            }
        }
 public abstract void Execute(MonsterFighter fighter);
Example #16
0
 public override void Execute(MonsterFighter fighter)
 {
 }
Example #17
0
 public FightResultMonster(MonsterFighter fighter, TeamColorEnum winner)
     : base(fighter, winner)
 {
 }
 public MonsterBrain(MonsterFighter fighter, List <int> actions)
 {
     this.m_fighter = fighter;
     this.Actions   = actions.ConvertAll <AbstractIAAction>(x => IAActionsProvider.GetAction((IAActionsEnum)x));
 }
Example #19
0
        private void AddMinationItem(MonsterFighter monster)
        {
            CharacterItemRecord minationItem = CreateMinationItem(MinationItemTemplate, 1, Result.Character.Id, monster.Template, monster.GradeId);

            this.Add(minationItem);
        }