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); }
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); } }
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; }
/// <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); }
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(); }
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)); }
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); } }
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; } }
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; } }
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; } }
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 } }
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; }
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); }
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; }
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); }
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; }
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); }
public System.Collections.Generic.IEnumerable <MonsterFighter> CreateFighters(FightTeam team) { return (from monster in this.m_monsters select monster.CreateFighter(team)); }
public Zombie(ChallengeRecord template, FightTeam team) : base(template, team) { }
/// <summary> /// /// </summary> /// <param name="team"></param> public virtual void StartFight(FightTeam team) { }
public MinationMonsterFighter(FightTeam team, MonsterRecord template, sbyte gradeId, ushort minationLevel, CharacterFighter owner, short summonCellId) : base(team, template, gradeId, owner, summonCellId) { this.MinationLevel = minationLevel; }
public override bool CanLoot(FightTeam team) => Outcome == FightOutcomeEnum.RESULT_VICTORY && !Fighter.HasLeft() && ShowLoot;
protected override void OnWinnersDetermined(IFight fight, FightTeam winners, FightTeam losers, bool draw) { base.OnWinnersDetermined(fight, winners, losers, draw); Target.Dead -= OnDead; }
public MonsterFighter(FightTeam team, MonsterRecord template, sbyte gradeId, ushort mapCellId) : base( team, mapCellId, template, gradeId) { }
/// <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 }); } } }
public HealChallenge(Fight fight, FightTeam team) : base(fight, team, Enums.ChallengesTypeID.Heal) { }
public int getTotalTeamHealth(FightTeam team) { return(TotalTeamHealth[team]); }
public FightChallenge(Fight fight, FightTeam team, Enums.ChallengesTypeID type) { this.ChallengedFight = fight; this.ChallengedTeam = team; this.Type = type; }
public Nomade(ChallengeRecord template, FightTeam team) : base(template, team) { }
public FirstKillChallenge(Fight fight, FightTeam team, Fighter toKill) : base(fight, team, Enums.ChallengesTypeID.FirstDie) { this.Target = toKill; }
public Mystic(ChallengeRecord template, FightTeam team) : base(template, team) { }
public MonsterFighter(FightTeam team, Monster monster, ushort mapCellId) : base(team, mapCellId, monster.Template, monster.GradeId) { }
public NomadeChallenge(Fight fight, FightTeam team) : base(fight, team, Enums.ChallengesTypeID.Nomade) { }
public ZombieChallenge(Fight fight, FightTeam team) : base(fight, team, Enums.ChallengesTypeID.Zombie) { }
protected NamedFighter(FightTeam team) : base(team) { }
public Untouchable(ChallengeRecord template, FightTeam team) : base(template, team) { }
public CharacterFighter(Character character, FightTeam team, ushort mapPosition) : base(team, mapPosition) { this.Character = character; }
/// <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; }
public MonsterFighter CreateFighter(FightTeam team) { return(new MonsterFighter(this, team)); }
public FightArena(int id, MapRecord map, FightTeam blueTeam, FightTeam redTeam, short fightCellId) : base(id, map, blueTeam, redTeam, fightCellId) { }