Exemplo n.º 1
0
 public MonsterFighter(MonsterSpawnMapRecord spawn, FightTeam team)
     : base(team)
 {
     this.SpawnRecord = spawn;
     this.Template = MonsterRecord.GetMonster(SpawnRecord.MonsterId);
     this.ReadyToFight = true;
     this.Brain = new MonsterBrain(this, Template.IAActions);
 }
Exemplo n.º 2
0
        public void SetTeam(FightTeam team)
        {
            if (Team != null)
                throw new Exception("Team already defined !");

            Team = team;
            Team.AddFighter(this);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="team"></param>
        public override void StartFight(FightTeam team)
        {
            if (team.OpponentTeam.HasSomeoneAlive)
            {
                var randomIndex = Util.Next(0, team.OpponentTeam.AliveFighters.Count());
                var target = team.OpponentTeam.AliveFighters.ElementAt(randomIndex);

                TargetId = target.Id;
                base.FlagCell(target.Cell.Id, TargetId);
            }
        }
Exemplo n.º 4
0
 public CompanionFighter(CompanionRecord template, CharacterFighter master, FightTeam team)
     : base(team)
 {
     this.Template = template;
     this.Master = master;
     this.Spells = Template.GetSpellItems(Master.Client.Character);
     this.Shortcuts = GenerateShortcuts();
     if (this.Template.StartingSpellLevelId != 0)
     this.AutoCastSpell = SpellLevelRecord.GetLevel(Template.StartingSpellLevelId);
     this.ReadyToFight = true;
 }
Exemplo n.º 5
0
 /// <summary>
 /// For summons
 /// </summary>
 /// <param name="template"></param>
 /// <param name="team"></param>
 public MonsterFighter(MonsterRecord template, FightTeam team, sbyte grade, short cellid, int summonerid)
     : base(team)
 {
     this.Template = template;
     this.ReadyToFight = true;
     this.Brain = new MonsterBrain(this, Template.IAActions);
     this.SpawnRecord = new MonsterSpawnMapRecord(0, template.Id, -1, 0);
     this.SpawnRecord.ActualGrade = grade;
     this.Team = team;
     this.Team.AddSummon(this);
     InitializeSummon(summonerid, cellid);
 }
        public async void fight(short monsterId)
        {
            var action = new Action(() => {
                var newFight = FightProvider.Instance.CreateFreeFightInstancePvM(new MonsterRecord[] { MonsterRecord.GetMonster((ushort)monsterId) }, this.Character.Map);

                FightTeam characterTeam = newFight.GetTeam(TeamTypeEnum.TEAM_TYPE_PLAYER);
                FightTeam monsterTeam   = newFight.GetTeam(TeamTypeEnum.TEAM_TYPE_MONSTER);

                characterTeam.AddFighter(this.Character.CreateFighter(characterTeam));

                foreach (var monster in newFight.Group.CreateFighters(monsterTeam))
                {
                    monsterTeam.AddFighter(monster);
                }
            });

            await this.Execute(action);
        }
Exemplo n.º 7
0
        public CharacterFighter(Character character, FightTeam team)
            : base(team)
        {
            Character = character;

            Look = Character.Look.Clone();
            Look.RemoveAuras();

            Cell cell;

            if (!Fight.FindRandomFreeCell(this, out cell, false))
            {
                return;
            }

            Position = new ObjectPosition(character.Map, cell, character.Direction);

            InitializeCharacterFighter();
        }
Exemplo n.º 8
0
        public override bool CanJoin(FightTeam Team, Player Character)
        {
            if (Team.Leader is PrismFighter)
            {
                if (Character.Alignement != (Team.Leader as PrismFighter).Prisme.Alignement)
                {
                    return(false);
                }
            }

            if (Team.Leader is CharacterFighter)
            {
                if (Character.Alignement != (Team.Leader as CharacterFighter).Character.Alignement)
                {
                    return(false);
                }
            }
            return(base.CanJoin(Team, Character));
        }
Exemplo n.º 9
0
        private void OnWinnersDetermined(IFight fight, FightTeam winners, FightTeam losers, bool draw)
        {
            fight.WinnersDetermined -= OnWinnersDetermined;

            if (draw)
            {
                return;
            }

            // if players didn't win they don't get teleported
            if (!(winners is FightPlayerTeam) || !(losers is FightMonsterTeam))
            {
                return;
            }

            var group = ((MonsterFighter)losers.Leader).Monster.Group;

            if (!m_groupsSpawn.ContainsKey(@group))
            {
                logger.Error("Group {0} (Map {1}) has ended his fight but is not register in the pool", @group.Id, Map.Id);
                return;
            }

            var spawn = m_groupsSpawn[@group];

            if (!spawn.TeleportEvent)
            {
                return;
            }

            var pos = spawn.GetTeleportPosition();

            foreach (var fighter in winners.GetAllFighters <CharacterFighter>())
            {
                fighter.Character.NextMap   = pos.Map;
                fighter.Character.Cell      = pos.Cell;
                fighter.Character.Direction = pos.Direction;


                m_groupsSpawn.Remove(group);
            }
        }
Exemplo n.º 10
0
        public HermitChallenge(int id, IFight fight)
            : base(id, fight)
        {
            if (id == (int)ChallengeEnum.ANACHORÈTE)
            {
                BonusMin = 20;
                BonusMax = 30;
            }
            else
            {
                BonusMin = 30;
                BonusMax = 30;
            }

            m_team = Fight.DefendersTeam is FightMonsterTeam ? Fight.DefendersTeam : Fight.ChallengersTeam;
            if (id == (int)ChallengeEnum.ANACHORÈTE)
            {
                m_team = m_team.OpposedTeam;
            }
        }
Exemplo n.º 11
0
        protected override void OnWinnersDetermined(IFight fight, FightTeam winners, FightTeam losers, bool draw)
        {
            if (winners is FightMonsterTeam)
            {
                UpdateStatus(ChallengeStatusEnum.FAILED);
                return;
            }

            foreach (var winner in winners.Fighters.OfType <CharacterFighter>().Where(winner => !m_killers.Contains(winner)))
            {
                UpdateStatus(ChallengeStatusEnum.FAILED, winner);
            }

            UpdateStatus(ChallengeStatusEnum.SUCCESS);

            foreach (var fighter in Fight.GetAllFighters <MonsterFighter>())
            {
                fighter.Dead -= OnDead;
            }
        }
Exemplo n.º 12
0
        public ImpertinenceChallenge(int id, IFight fight)
            : base(id, fight)
        {
            if (id == (int)ChallengeEnum.HARDI)
            {
                BonusMin = 25;
                BonusMax = 25;
            }
            else
            {
                BonusMin = 40;
                BonusMax = 40;
            }

            m_team = Fight.DefendersTeam is FightMonsterTeam ? Fight.DefendersTeam : Fight.ChallengersTeam;
            if (id == (int)ChallengeEnum.COLLANT)
            {
                m_team = m_team.OpposedTeam;
            }
        }
Exemplo n.º 13
0
        void OnFighterAdded(FightTeam team, FightActor fighter)
        {
            if (fighter != Fighter)
            {
                return;
            }

            var spellHandler = SpellManager.Instance.GetSpellCastHandler(Fighter, new Spell((int)SpellIdEnum.SYNCHRONISATION, 0), Fighter.Cell, false);

            spellHandler.Initialize();

            var handlers = spellHandler.GetEffectHandlers().ToArray();

            using (Fighter.Fight.StartSequence(SequenceTypeEnum.SEQUENCE_SPELL))
            {
                handlers[1].Apply(); //SubAP Summoner
                handlers[2].Apply(); //BuffTrigger
                handlers[3].Apply(); //SpellImmunity
            }
        }
Exemplo n.º 14
0
 public BombFighter(MonsterRecord template, Fighter owner, FightTeam team, short summonCellId, sbyte gradeId, SpellLevelRecord summonSpellLevel)
     : base(team, 0)
 {
     this.Owner                 = owner;
     this.Template              = template;
     this.GradeId               = gradeId;
     this.Grade                 = Template.GetGrade(gradeId);
     this.SummonCellId          = summonCellId;
     this.BeforeSlideEvt       += BombFighter_BeforeSlideEvt;
     this.Owner.OnTurnStartEvt += OnOwnerTurnStart;
     this.AfterSlideEvt        += BombFighter_OnSlideEvt;
     this.OnTeleportEvt        += BombFighter_OnTeleportEvt;
     this.AfterDeadEvt         += BombFighter_AfterDeadEvt;
     this.OnDamageTaken        += BombFighter_OnDamageTaken;
     this.BeforeDeadEvt        += BombFighter_OnDeadEvt;
     this.Walls                 = new List <Wall>();
     this.SummonSpellLevel      = summonSpellLevel;
     this.SpellBombRecord       = SpellBombRecord.GetSpellBombRecord(summonSpellLevel.SpellId);
     this.WallSpellLevel        = SpellRecord.GetSpellRecord(SpellBombRecord.WallSpellId).GetLevel(GradeId);
     this.BuffTurnCount         = BUFF_TURN_COUNT;
 }
Exemplo n.º 15
0
        public TaxCollectorFighter(FightTeam team, TaxCollectorNpc taxCollector)
            : base(team, taxCollector.Guild.GetTaxCollectorSpells(), taxCollector.GlobalId)
        {
            Id = Fight.GetNextContextualId();
            TaxCollectorNpc = taxCollector;
            Look            = TaxCollectorNpc.Look.Clone();
            Items           = TaxCollectorNpc.Bag.SelectMany(x => Enumerable.Repeat(x.Template.Id, (int)x.Stack))
                              .Shuffle()
                              .ToList();
            Kamas = TaxCollectorNpc.GatheredKamas;

            m_stats = new StatsFields(this);
            m_stats.Initialize(TaxCollectorNpc);

            if (!Fight.FindRandomFreeCell(this, out var cell, false))
            {
                return;
            }

            Position = new ObjectPosition(TaxCollectorNpc.Map, cell, TaxCollectorNpc.Direction);
        }
Exemplo n.º 16
0
 protected override void OnFighterAdded(FightTeam team, FightActor actor)
 {
     if (actor is TaxCollectorFighter)
     {
         if (this.TaxCollector != null)
         {
             FightPvT.logger.Error("There is already a tax collector in this fight !");
         }
         else
         {
             this.TaxCollector = (actor as TaxCollectorFighter);
         }
     }
     if (base.State == FightState.Placement && team == this.AttackersTeam)
     {
         TaxCollectorHandler.SendGuildFightPlayersEnemiesListMessage(this.TaxCollector.TaxCollectorNpc.Guild.Clients, this.TaxCollector.TaxCollectorNpc,
                                                                     from x in this.AttackersTeam.Fighters.OfType <CharacterFighter>()
                                                                     select x.Character);
     }
     base.OnFighterAdded(team, actor);
 }
        public ControlableMonsterFighter(FightTeam team, MonsterRecord template, sbyte gradeId, CharacterFighter owner,
                                         short summonCellId)
            : base(team, 0)
        {
            this.Template = template;
            this.GradeId  = gradeId;
            this.Owner    = owner;
            this.Owner.OnLeavePreFightEvt += Owner_OnLeavePreFight;
            this.Owner.OnTurnEndEvt       += Owner_TurnEnd;
            this.OnTurnEndEvt             += ControlableMonsterFighter_TurnEnd;
            this.AfterDeadEvt             += ControlableMonsterFighter_OnDead;
            this.SummonCellId              = summonCellId;
            this.Spells = Array.ConvertAll(template.SpellRecords.ToArray(), x => new CharacterSpell(x.Id, x.GetLastLevelGrade()));

            this.Shortcuts = new ShortcutSpell[Spells.Length];

            for (int i = 0; i < Spells.Length; i++)
            {
                Shortcuts[i] = new ShortcutSpell((sbyte)i, Spells[i].SpellId);
            }
            this.IsReady = true;
        }
Exemplo n.º 18
0
        protected override void OnWinnersDetermined(FightTeam winners, FightTeam losers, bool draw)
        {
            TaxCollectorHandler.SendTaxCollectorAttackedResultMessage(this.TaxCollector.TaxCollectorNpc.Guild.Clients, base.Winners != this.DefendersTeam && !draw, this.TaxCollector.TaxCollectorNpc);
            if (base.Winners == this.DefendersTeam || draw)
            {
                this.TaxCollector.TaxCollectorNpc.RejoinMap();
                using (System.Collections.Generic.List <Character> .Enumerator enumerator = this.m_defendersQueue.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Character current = enumerator.Current;
                        if (this.m_defendersMaps.ContainsKey(current))
                        {
                            current.NextMap = this.m_defendersMaps[current];
                        }
                    }
                    goto IL_C4;
                }
            }
            this.TaxCollector.TaxCollectorNpc.Delete();
IL_C4:
            base.OnWinnersDetermined(winners, losers, draw);
        }
Exemplo n.º 19
0
        public SummonedBomb(int id, FightTeam team, SpellBombTemplate spellBombTemplate, MonsterGrade monsterBombTemplate, FightActor summoner, Cell cell)
            : base(team)
        {
            Id                  = id;
            Position            = summoner.Position.Clone();
            Look                = monsterBombTemplate.Template.EntityLook.Clone();
            Cell                = cell;
            MonsterBombTemplate = monsterBombTemplate;
            Summoner            = summoner;
            SpellBombTemplate   = spellBombTemplate;
            m_stats             = new StatsFields(this);
            m_stats.Initialize(monsterBombTemplate);
            WallSpell = new Spell((int)wallsSpells[SpellBombTemplate.WallId], (byte)MonsterBombTemplate.GradeId);
            m_color   = wallsColors[SpellBombTemplate.WallId];
            AdjustStats();

            ExplodSpell = new Spell(spellBombTemplate.ExplodReactionSpell, (byte)MonsterBombTemplate.GradeId);

            Fight.TurnStarted += OnTurnStarted;
            Team.FighterAdded += OnFighterAdded;

            m_initialized = true;
        }
Exemplo n.º 20
0
        public override void OnFightEnded(TeamColorEnum winner)
        {
            FightTeam winners = null;
            FightTeam loosers = null;

            if (winner == RedTeam.TeamColor)
            {
                winners = RedTeam;
                loosers = BlueTeam;
            }
            else if (winner == BlueTeam.TeamColor)
            {
                winners = BlueTeam;
                loosers = RedTeam;
            }

            GetAllCharacterFighters(true).ForEach(x => x.Client.Character.Record.ArenaFightCount++);

            winners.GetCharacterFighters(true).ForEach(x => x.Client.Character.Record.ArenaVictoryCount++);

            winners.GetCharacterFighters(true).ForEach(x => x.Client.Character.Record.ActualRank += (ushort)(x.Client.Character.Record.Level)); // Check for an algo

            foreach (var _winner in winners.GetCharacterFighters(true))
            {
                if (_winner.Client.Character.Record.ActualRank > _winner.Client.Character.Record.MaxRank)
                {
                    _winner.Client.Character.Record.MaxRank       = _winner.Client.Character.Record.ActualRank;
                    _winner.Client.Character.Record.BestDailyRank = _winner.Client.Character.Record.ActualRank;
                }
            }

            loosers.GetCharacterFighters(true).ForEach(x => x.Client.Character.Record.ActualRank -= (ushort)(x.Client.Character.Record.Level));


            GetAllCharacterFighters(true).ForEach(x => x.Client.Character.RefreshArenasInfos());
            base.OnFightEnded(winner);
        }
Exemplo n.º 21
0
 public System.Collections.Generic.IEnumerable <MonsterFighter> CreateFighters(FightTeam team)
 {
     return
         (from monster in this.m_monsters
          select monster.CreateFighter(team));
 }
Exemplo n.º 22
0
 public Zombie(ChallengeRecord template, FightTeam team)
     : base(template, team)
 {
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="team"></param>
 public virtual void StartFight(FightTeam team)
 {
 }
Exemplo n.º 24
0
 public MinationMonsterFighter(FightTeam team, MonsterRecord template, sbyte gradeId, ushort minationLevel, CharacterFighter owner, short summonCellId) : base(team, template, gradeId, owner, summonCellId)
 {
     this.MinationLevel = minationLevel;
 }
Exemplo n.º 25
0
 public override bool CanLoot(FightTeam team) => Outcome == FightOutcomeEnum.RESULT_VICTORY && !Fighter.HasLeft() && ShowLoot;
Exemplo n.º 26
0
        protected override void OnWinnersDetermined(IFight fight, FightTeam winners, FightTeam losers, bool draw)
        {
            base.OnWinnersDetermined(fight, winners, losers, draw);

            Target.Dead -= OnDead;
        }
Exemplo n.º 27
0
 public MonsterFighter(FightTeam team, MonsterRecord template, sbyte gradeId, ushort mapCellId)
     : base(
         team, mapCellId, template, gradeId)
 {
 }
Exemplo n.º 28
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fight"></param>
        /// <param name="team"></param>
        public override void JoinFight(AbstractFight fight, FightTeam team)
        {
            Life = MaxLife;

            base.JoinFight(fight, team);
        }
        public override void Execute(TriggerBase trigger)
        {
            Character target = base.GetTarget(trigger);
            Fight     fight  = trigger.Get <Fight>("fight");
            string    text   = trigger.Get <string>("team");

            if (!text.Equals("blue", System.StringComparison.InvariantCultureIgnoreCase) && !text.Equals("red", System.StringComparison.InvariantCultureIgnoreCase))
            {
                trigger.ReplyError("Specify a team (red or blue)");
            }
            else
            {
                bool flag = text.Equals("red", System.StringComparison.InvariantCultureIgnoreCase);
                if (target.IsFighting())
                {
                    if (target.Fight == fight)
                    {
                        trigger.ReplyError("{0} is already in the given fight", new object[]
                        {
                            target
                        });
                        return;
                    }
                    target.Fighter.LeaveFight();
                }
                FightTeam        fightTeam        = flag ? fight.RedTeam : fight.BlueTeam;
                CharacterFighter characterFighter = target.CreateFighter(fightTeam);
                Cell             cell;
                if (!fight.FindRandomFreeCell(characterFighter, out cell, true))
                {
                    foreach (FightActor current in fightTeam.Fighters)
                    {
                        using (System.Collections.Generic.IEnumerator <MapPoint> enumerator2 = current.Position.Point.GetAdjacentCells((short x) => fight.IsCellFree(fight.Map.Cells[(int)x])).GetEnumerator())
                        {
                            if (enumerator2.MoveNext())
                            {
                                MapPoint current2 = enumerator2.Current;
                                cell = fight.Map.GetCell((int)current2.CellId);
                            }
                        }
                        if (cell != null)
                        {
                            break;
                        }
                    }
                }
                if (cell == null)
                {
                    target.RejoinMap();
                    trigger.ReplyError("{0} cannot join fight {1}, no free cell were found !", new object[]
                    {
                        target,
                        fight.Id
                    });
                }
                else
                {
                    characterFighter.Cell = cell;
                    fightTeam.AddFighter(characterFighter);
                    trigger.ReplyBold("{0} joined fight {1}", new object[]
                    {
                        target,
                        fight.Id
                    });
                }
            }
        }
Exemplo n.º 30
0
 public HealChallenge(Fight fight, FightTeam team)
     : base(fight, team, Enums.ChallengesTypeID.Heal)
 {
 }
Exemplo n.º 31
0
 public int getTotalTeamHealth(FightTeam team)
 {
     return(TotalTeamHealth[team]);
 }
Exemplo n.º 32
0
 public FightChallenge(Fight fight, FightTeam team, Enums.ChallengesTypeID type)
 {
     this.ChallengedFight = fight;
     this.ChallengedTeam = team;
     this.Type = type;
 }
Exemplo n.º 33
0
 public Nomade(ChallengeRecord template, FightTeam team)
     : base(template, team)
 {
 }
Exemplo n.º 34
0
 public FirstKillChallenge(Fight fight, FightTeam team, Fighter toKill)
     : base(fight, team, Enums.ChallengesTypeID.FirstDie)
 {
     this.Target = toKill;
 }
Exemplo n.º 35
0
 public Mystic(ChallengeRecord template, FightTeam team)
     : base(template, team)
 {
 }
Exemplo n.º 36
0
 public MonsterFighter(FightTeam team, Monster monster, ushort mapCellId)
     : base(team, mapCellId, monster.Template, monster.GradeId)
 {
 }
Exemplo n.º 37
0
 public NomadeChallenge(Fight fight, FightTeam team)
     : base(fight, team, Enums.ChallengesTypeID.Nomade)
 {
 }
Exemplo n.º 38
0
 public ZombieChallenge(Fight fight, FightTeam team)
     : base(fight, team, Enums.ChallengesTypeID.Zombie)
 {
 }
Exemplo n.º 39
0
 protected NamedFighter(FightTeam team)
     : base(team)
 {
 }
Exemplo n.º 40
0
 public Untouchable(ChallengeRecord template, FightTeam team)
     : base(template, team)
 {
 }
Exemplo n.º 41
0
 public CharacterFighter(Character character, FightTeam team, ushort mapPosition)
     : base(team, mapPosition)
 {
     this.Character = character;
 }
Exemplo n.º 42
0
        /// <summary>
        /// Define the fighter team. Throws Exception if already defined.
        /// </summary>
        /// <param name="team">Fighter team</param>
        public void SetTeam(FightTeam team)
        {
            if (Team != null && Team != team)
                throw new Exception("Team already defined !");

            Team = team;
        }
Exemplo n.º 43
0
 public MonsterFighter CreateFighter(FightTeam team)
 {
     return(new MonsterFighter(this, team));
 }
Exemplo n.º 44
0
 public FightArena(int id, MapRecord map, FightTeam blueTeam, FightTeam redTeam, short fightCellId)
     : base(id, map, blueTeam, redTeam, fightCellId)
 {
 }