/// <summary> /// /// </summary> public MonsterFight(MapInstance map, long id, CharacterEntity character, MonsterGroupEntity monsterGroup) : base(FightTypeEnum.TYPE_PVM, map, id, character.Id, -1, character.CellId, monsterGroup.Id, -1, monsterGroup.CellId, WorldConfig.PVM_START_TIMEOUT, WorldConfig.PVM_TURN_TIME, false, false, new LootMonsterBehavior()) { Character = character; MonsterGroup = monsterGroup; JoinFight(Character, Team0); foreach(var monster in monsterGroup.Monsters) JoinFight(monster, Team1); foreach (var challenge in ChallengeManager.Instance.Generate(WorldConfig.PVM_CHALLENGE_COUNT)) Team0.AddChallenge(challenge); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="id"></param> /// <param name="monsters"></param> /// <param name="victim"></param> public AlignmentFight(MapInstance map, long id, MonsterGroupEntity monsters, CharacterEntity victim) : base(FightTypeEnum.TYPE_AGGRESSION, map, id, monsters.Id, monsters.AlignmentId, monsters.CellId, victim.Id, victim.AlignmentId, victim.CellId, WorldConfig.AGGRESSION_START_TIMEOUT, WorldConfig.AGGRESSION_TURN_TIME, false, true) { IsNeutralAgression = victim.AlignmentId == (int)AlignmentTypeEnum.ALIGNMENT_NEUTRAL; Monsters = monsters; foreach (var monster in monsters.Monsters) JoinFight(monster, Team0); JoinFight(victim, Team1); }
/// <summary> /// /// </summary> public override void Dispose() { Character = null; MonsterGroup = null; m_serializedFlag = null; base.Dispose(); }
/// <summary> /// /// </summary> /// <param name="monsters"></param> /// <param name="victim"></param> /// <returns></returns> public bool StartAggression(MonsterGroupEntity monsters, CharacterEntity victim) { if (CanStartFight(victim)) { monsters.StopAction(GameActionTypeEnum.MAP); Add(new AlignmentFight(m_map, m_fightId++, monsters, victim)); return true; } return false; }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="monsterGroup"></param> public bool StartMonsterFight(CharacterEntity character, MonsterGroupEntity monsterGroup) { if (!CanStartFight(character)) return false; if (!character.CanGameAction(GameActionTypeEnum.FIGHT)) { character.Dispatch(WorldMessage.IM_ERROR_MESSAGE(InformationEnum.ERROR_YOU_ARE_AWAY)); return false; } monsterGroup.StopAction(GameActionTypeEnum.MAP); Add(new MonsterFight(m_map, m_fightId++, character, monsterGroup)); return true; }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="cellId"></param> /// <param name="monsters"></param> /// <returns></returns> public bool CanBeAggro(CharacterEntity character, int cellId, MonsterGroupEntity monsters) { return Pathfinding.GoalDistance(this, cellId, monsters.CellId) <= monsters.AggressionRange && ((character.AlignmentId == (int)AlignmentTypeEnum.ALIGNMENT_NEUTRAL && monsters.AlignmentId == -1) || (character.AlignmentId != (int)AlignmentTypeEnum.ALIGNMENT_NEUTRAL && monsters.AlignmentId != character.AlignmentId)); }