Exemplo n.º 1
0
        private Boolean AddViewWithPreviousSlot(IMoveable go, ESize size, out Vector3 localPosition, Int32 p_comeFrom, EntityPositioning p_oldPositioning)
        {
            Boolean searchNearestSlot = false;

            if (p_oldPositioning != null)
            {
                EDirection direction = EDirectionFunctions.GetDirection(p_oldPositioning.Position, m_gridSlot.Position);
                if (direction != m_direction && direction != EDirectionFunctions.Add(m_direction, 2))
                {
                    searchNearestSlot = true;
                }
            }
            Boolean flag;

            if (size == ESize.MEDIUM)
            {
                flag = AddViewWithPreviousSlotMedium(go, out localPosition, p_comeFrom, p_oldPositioning, searchNearestSlot);
            }
            else if (size == ESize.BIG)
            {
                flag = AddViewWithPreviousSlotBig(go, out localPosition, p_comeFrom);
            }
            else
            {
                flag = AddViewWithPreviousSlotSmall(go, out localPosition, p_comeFrom, p_oldPositioning, searchNearestSlot);
            }
            return(!flag);
        }
Exemplo n.º 2
0
        protected void Drag(Monster p_monster, SpellEventArgs p_result)
        {
            if (p_monster.CurrentHealth <= 0)
            {
                return;
            }
            if (p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.LARGE) || p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.BOSS) || p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.STATIC_OBJECT))
            {
                return;
            }
            Party      party     = LegacyLogic.Instance.WorldManager.Party;
            Grid       grid      = LegacyLogic.Instance.MapLoader.Grid;
            EDirection direction = EDirectionFunctions.GetDirection(p_monster.Position, party.Position);
            Int32      num       = (Int32)Position.Distance(p_monster.Position, party.Position) - 1;

            for (Int32 i = 0; i < num; i++)
            {
                if (!grid.CanMoveEntity(p_monster, direction))
                {
                    break;
                }
                Position p_pos = p_monster.Position + direction;
                GridSlot slot  = grid.GetSlot(p_monster.Position);
                if (grid.GetSlot(p_pos).AddEntity(p_monster))
                {
                    slot.RemoveEntity(p_monster);
                }
            }
            if (Position.Distance(p_monster.Position, party.Position) > 1f)
            {
                LegacyLogic.Instance.WorldManager.Party.SelectedMonster = null;
            }
        }
Exemplo n.º 3
0
        public override void DoEffect(Monster p_monster, Character p_target, SpellEventArgs p_spellArgs)
        {
            Grid       grid      = LegacyLogic.Instance.MapLoader.Grid;
            Position   position  = LegacyLogic.Instance.WorldManager.Party.Position;
            Int32      num       = 0;
            EDirection direction = EDirectionFunctions.GetDirection(position, p_monster.Position);
            Position   position2 = p_monster.Position + direction;
            GridSlot   slot      = grid.GetSlot(position2);

            while (slot != null && slot.IsPassable(p_monster, false) && num < 4)
            {
                num++;
                position2 += direction;
                slot       = grid.GetSlot(position2);
            }
            Int32      num2       = 0;
            EDirection direction2 = EDirectionFunctions.GetDirection(p_monster.Position, position);

            position2 = position + direction2;
            slot      = grid.GetSlot(position2);
            while (slot != null && slot.IsPassable(p_monster, false) && num2 < 3)
            {
                num2++;
                position2 += direction2;
                slot       = grid.GetSlot(position2);
            }
            if (num2 > 0)
            {
                num2++;
            }
            Position position3 = p_monster.Position;

            if (num2 > num)
            {
                for (Int32 i = 0; i < num2; i++)
                {
                    position3 += direction2;
                }
            }
            else
            {
                for (Int32 i = 0; i < num; i++)
                {
                    position3 += direction;
                }
            }
            Position position4 = p_monster.Position;

            grid.GetSlot(p_monster.Position).RemoveEntity(p_monster);
            grid.GetSlot(position3).AddEntity(p_monster);
            p_monster.Position  = position3;
            p_monster.Direction = EDirectionFunctions.GetDirection(p_monster.Position, position);
            BaseObjectEventArgs p_eventArgs = new BaseObjectEventArgs(p_monster, p_monster.Position);

            LegacyLogic.Instance.EventManager.InvokeEvent(p_monster, EEventType.SET_ENTITY_POSITION, p_eventArgs);
        }
Exemplo n.º 4
0
        public override void DoEffect(Monster p_monster, Character p_target, SpellEventArgs p_spellArgs)
        {
            Grid     grid     = LegacyLogic.Instance.MapLoader.Grid;
            Position position = p_monster.Position;
            GridSlot slot     = grid.GetSlot(position);
            Int32    num;

            if (LegacyLogic.Instance.WorldManager.Party.InCombat)
            {
                num = Random.Range(0, 4);
            }
            else
            {
                List <GridSlot> list = new List <GridSlot>();
                for (Int32 i = 0; i < 4; i++)
                {
                    GridSlot slot2 = grid.GetSlot(position + (EDirection)i);
                    if (slot2 != null && p_monster.CanPassTerrain(slot2.TerrainType))
                    {
                        list.Add(slot2);
                    }
                }
                list.Sort((GridSlot a, GridSlot b) => Position.Distance(a.Position, LegacyLogic.Instance.WorldManager.Party.Position).CompareTo(Position.Distance(b.Position, LegacyLogic.Instance.WorldManager.Party.Position)));
                num = (Int32)EDirectionFunctions.GetDirection(position, list[0].Position);
            }
            EDirection p_dir = (EDirection)num;

            if (grid.AddMovingEntity(position + p_dir, p_monster))
            {
                slot.RemoveEntity(p_monster);
            }
            else
            {
                Int32 num2 = num - 1;
                while (num != num2)
                {
                    if (num2 < 0)
                    {
                        num2 = 3;
                    }
                    if (grid.AddMovingEntity(position + (EDirection)num2, p_monster))
                    {
                        slot.RemoveEntity(p_monster);
                        break;
                    }
                    num2--;
                }
            }
            if (position != p_monster.Position && LegacyLogic.Instance.WorldManager.Party.SelectedMonster == p_monster)
            {
                LegacyLogic.Instance.WorldManager.Party.SelectedMonster = null;
            }
        }
Exemplo n.º 5
0
        internal Boolean TryMove(List <GridSlot> p_targets, Grid p_grid, GridSlot p_startSlot, Party p_party)
        {
            if (m_owner.CombatHandler.CanMove)
            {
                List <GridSlot> pathBuffer = m_PathBuffer;
                GridSlot        gridSlot   = null;
                Int32           num        = 999;
                GridSlot        gridSlot2  = null;
                foreach (GridSlot gridSlot3 in p_targets)
                {
                    pathBuffer.Clear();
                    if (CalculatePath(p_startSlot, gridSlot3, pathBuffer) && pathBuffer.Count < num)
                    {
                        gridSlot  = gridSlot3;
                        num       = pathBuffer.Count;
                        gridSlot2 = pathBuffer[1];
                    }
                }
                if (gridSlot != null)
                {
                    EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(p_startSlot.Position, gridSlot2.Position);
                    if (lineOfSightDirection != EDirection.CENTER)
                    {
                        m_owner.Direction = EDirectionFunctions.GetDirection(gridSlot2.Position, p_party.Position);
                        if (p_grid.MoveEntity(m_owner, lineOfSightDirection))
                        {
                            m_targetSlot = gridSlot;
                            GridSlot slot  = p_grid.GetSlot(m_owner.Position);
                            GridSlot slot2 = p_grid.GetSlot(p_party.Position);
                            Int32    num2  = AStarHelper <GridSlot> .Calculate(slot, slot2, GameConfig.MaxSteps, m_owner, true, null);

                            if (num2 > 0)
                            {
                                m_owner.DistanceToParty = num2;
                            }
                            else
                            {
                                m_owner.DistanceToParty = 99f;
                            }
                            m_owner.StartMovement.Trigger();
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 6
0
 private void Appear()
 {
     if (m_targetSlot != null)
     {
         Grid     grid     = LegacyLogic.Instance.MapLoader.Grid;
         Position position = m_owner.Position;
         grid.GetSlot(m_owner.Position).RemoveEntity(m_owner);
         m_targetSlot.AddEntity(m_owner);
         m_owner.Position  = m_targetSlot.Position;
         m_owner.Direction = EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position);
         m_state           = EErebosState.APPEARING;
         UpdateDistanceToParty(LegacyLogic.Instance.WorldManager.Party, grid);
         m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
         BaseObjectEventArgs p_eventArgs = new BaseObjectEventArgs(m_owner, m_owner.Position, "APPEARING");
         LegacyLogic.Instance.EventManager.InvokeEvent(m_owner, EEventType.SET_ENTITY_POSITION, p_eventArgs);
     }
 }
        protected override void DoExecute()
        {
            InteractiveObject interactiveObject = Grid.FindInteractiveObject(m_targetSpawnID);

            if (interactiveObject == null)
            {
                throw new InvalidOperationException("Tried to find the position of something that is not an object!");
            }
            Party      party      = LegacyLogic.Instance.WorldManager.Party;
            EDirection edirection = EDirection.COUNT;

            if (party.Position != interactiveObject.Position)
            {
                edirection = EDirectionFunctions.GetDirection(party.Position, interactiveObject.Position);
            }
            else
            {
                GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position);
                foreach (Spawn spawn in slot.SpawnObjects)
                {
                    if (spawn.ID == m_targetSpawnID)
                    {
                        edirection = spawn.Direction;
                        break;
                    }
                }
            }
            Int32 num = party.Direction - edirection;

            if (num == 1 || num == -3)
            {
                RotateCommand p_command = RotateCommand.Left;
                LegacyLogic.Instance.CommandManager.AddCommand(p_command);
            }
            if (num == 2 || num == -2)
            {
                RotateCommand p_command = RotateCommand.TurnAround;
                LegacyLogic.Instance.CommandManager.AddCommand(p_command);
            }
            if (num == 3 || num == -1)
            {
                RotateCommand p_command = RotateCommand.Right;
                LegacyLogic.Instance.CommandManager.AddCommand(p_command);
            }
            FinishExecution();
        }
Exemplo n.º 8
0
        private void HandlePhase1()
        {
            m_subStateFinished = false;
            switch (m_roundSubState)
            {
            case 1:
                if (!LegacyLogic.Instance.WorldManager.Party.InCombat)
                {
                    MonsterSpell p_spell = m_owner.SpellHandler.SelectSpellByID(37);
                    m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                    CastSpell(p_spell);
                }
                else if (m_owner.Direction == EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position))
                {
                    m_roundSubState++;
                    m_subStateFinished = true;
                }
                else
                {
                    m_owner.Rotate(EDirectionFunctions.RotationCount(m_owner.Direction, EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position)), true);
                }
                break;

            case 2:
            case 3:
                if (LegacyLogic.Instance.WorldManager.Party.InCombat)
                {
                    m_owner.CombatHandler.CastSpell = false;
                    m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                    m_owner.CombatHandler.DoAttack();
                    if (m_roundSubState == 3)
                    {
                        m_isFinished = true;
                    }
                }
                else
                {
                    m_subStateFinished = true;
                    m_isFinished       = true;
                    m_owner.m_stateMachine.ChangeState(Monster.EState.ACTION_FINISHED);
                }
                break;
            }
        }
Exemplo n.º 9
0
        private void CalculateRotation()
        {
            Position position = LegacyLogic.Instance.WorldManager.Party.Position;

            if (m_lastPartyPos == position)
            {
                return;
            }
            m_lastPartyPos = position;
            Position   position2  = m_gridSlot.Position;
            EDirection edirection = EDirectionFunctions.GetDirection(ref position2, ref position);

            if (edirection == EDirection.COUNT)
            {
                edirection = EDirection.NORTH;
            }
            m_direction = edirection;
            Position   position3  = position - m_gridSlot.Position;
            Quaternion quaternion = Helper.GridDirectionToQuaternion(edirection);

            if (Mathf.Abs(position3.X) == Mathf.Abs(position3.Y))
            {
                Single angle;
                if (position3.Y > 0)
                {
                    angle = ((position3.X >= 0) ? 45f : -45f);
                }
                else
                {
                    angle = ((position3.X >= 0) ? -45f : 45f);
                }
                quaternion *= Quaternion.AngleAxis(angle, Vector3.up);
                m_diagonal  = true;
            }
            else
            {
                m_diagonal = false;
            }
            m_rotation = quaternion;
        }
Exemplo n.º 10
0
 private Int32 GetNearestSlotByDirection(EntityPositioning p_otherPositioning, Int32 p_fromSlot)
 {
     if (p_otherPositioning.Direction == m_direction)
     {
         Position   position   = p_otherPositioning.Position;
         Position   position2  = Position;
         EDirection edirection = EDirectionFunctions.Add(m_direction, -(Int32)EDirectionFunctions.GetDirection(ref position2, ref position));
         if (edirection == EDirection.EAST)
         {
             return(2);
         }
         if (edirection == EDirection.WEST)
         {
             return(0);
         }
     }
     else if (p_otherPositioning.Direction == EDirectionFunctions.Add(m_direction, 2))
     {
         return(p_fromSlot);
     }
     return(0);
 }
Exemplo n.º 11
0
        private void DoFlee(Party p_party, Grid p_grid, GridSlot startSlot)
        {
            EDirection direction;

            if (p_party.Position.X == m_owner.Position.X || p_party.Position.Y == m_owner.Position.Y)
            {
                direction = EDirectionFunctions.GetDirection(p_party.Position, m_owner.Position);
            }
            else
            {
                direction = m_owner.Direction;
            }
            GridSlot neighborSlot = p_grid.GetSlot(m_owner.Position).GetNeighborSlot(p_grid, direction);

            if (neighborSlot != null)
            {
                m_owner.Direction = direction;
                if (p_grid.MoveEntity(m_owner, m_owner.Direction))
                {
                    m_targetSlot = neighborSlot;
                    m_owner.StartMovement.Trigger();
                }
            }
        }
Exemplo n.º 12
0
 protected virtual void DoMelee(Boolean p_isMelee, Party p_party, Grid p_grid, GridSlot p_startSlot)
 {
     if (p_isMelee)
     {
         m_decision = EMonsterStrategyDecision.MELEE;
         if (m_owner.DistanceToParty <= 1f)
         {
             EDirection direction = EDirectionFunctions.GetDirection(m_owner.Position, p_party.Position);
             if (p_startSlot.GetTransition(direction).TransitionType == EGridTransitionType.CLOSED)
             {
                 if (m_canOpenDoors)
                 {
                     TryOpenDoor(p_startSlot, direction);
                 }
                 return;
             }
             m_owner.RangedAttack = false;
             m_owner.CombatHandler.Attack();
             return;
         }
         else
         {
             if (m_owner.DistanceToParty <= 1.6f)
             {
                 return;
             }
             List <GridSlot> meleeTargets = GetMeleeTargets(p_grid, p_party);
             meleeTargets.Sort(new Comparison <GridSlot>(DistSortAsc));
             if (meleeTargets.Count > 0)
             {
                 if (TryMove(meleeTargets, p_grid, p_startSlot, p_party))
                 {
                     return;
                 }
             }
             else
             {
                 Party    party = LegacyLogic.Instance.WorldManager.Party;
                 GridSlot slot  = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position + new Position(1, 1));
                 if (slot != null && slot.IsPassable(m_owner, false))
                 {
                     meleeTargets.Add(slot);
                 }
                 GridSlot slot2 = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position + new Position(-1, -1));
                 if (slot2 != null && slot2.IsPassable(m_owner, false))
                 {
                     meleeTargets.Add(slot2);
                 }
                 GridSlot slot3 = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position + new Position(-1, 1));
                 if (slot3 != null && slot3.IsPassable(m_owner, false))
                 {
                     meleeTargets.Add(slot3);
                 }
                 GridSlot slot4 = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position + new Position(1, -1));
                 if (slot4 != null && slot4.IsPassable(m_owner, false))
                 {
                     meleeTargets.Add(slot4);
                 }
                 slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position + new Position(0, 2));
                 if (slot != null && slot.IsPassable(m_owner, false))
                 {
                     meleeTargets.Add(slot);
                 }
                 slot2 = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position + new Position(2, 0));
                 if (slot2 != null && slot2.IsPassable(m_owner, false))
                 {
                     meleeTargets.Add(slot2);
                 }
                 slot3 = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position + new Position(-2, 0));
                 if (slot3 != null && slot3.IsPassable(m_owner, false))
                 {
                     meleeTargets.Add(slot3);
                 }
                 slot4 = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position + new Position(0, -2));
                 if (slot4 != null && slot4.IsPassable(m_owner, false))
                 {
                     meleeTargets.Add(slot4);
                 }
                 meleeTargets.RemoveAll((GridSlot t) => t.Position == m_owner.Position);
                 if (meleeTargets.Count > 0 && TryMove(meleeTargets, p_grid, p_startSlot, p_party))
                 {
                     return;
                 }
             }
         }
     }
 }
Exemplo n.º 13
0
 protected virtual void DoRanged(Boolean p_isMagic, Party p_party, Grid p_grid, GridSlot p_startSlot, out Boolean p_isMelee)
 {
     p_isMelee = true;
     if (m_decision == EMonsterStrategyDecision.RANGED || m_decision == EMonsterStrategyDecision.CALCULATE_STRATEGY)
     {
         if (m_owner.DistanceToParty <= 1.6f)
         {
             m_decision = EMonsterStrategyDecision.MELEE;
             p_isMelee  = true;
         }
         if (!p_isMagic && m_owner.StaticData.SpellRanges > m_owner.CombatHandler.AttackRange && m_owner.DistanceToParty > 1.6f)
         {
             if (m_targetSlot == null)
             {
                 List <GridSlot> rangedTargets = GetRangedTargets(p_grid, p_party, m_owner.StaticData.SpellRanges);
                 if (rangedTargets.Count > 0)
                 {
                     rangedTargets.Sort(new Comparison <GridSlot>(DistSortAsc));
                     if (TryMove(rangedTargets, p_grid, p_startSlot, p_party))
                     {
                         p_isMelee = false;
                         return;
                     }
                     p_isMelee  = true;
                     m_decision = EMonsterStrategyDecision.MELEE;
                 }
                 else
                 {
                     p_isMelee  = true;
                     m_decision = EMonsterStrategyDecision.MELEE;
                 }
             }
         }
         else
         {
             m_decision = EMonsterStrategyDecision.MELEE;
             p_isMelee  = true;
         }
         if (!p_isMagic && m_owner.CombatHandler.AttackRange > 1f && m_owner.DistanceToParty > 1.6f)
         {
             p_isMelee  = false;
             m_decision = EMonsterStrategyDecision.RANGED;
             if (p_grid.LineOfSight(m_owner.Position, p_party.Position, true) && Position.Distance(m_owner.Position, p_party.Position) <= m_owner.CombatHandler.AttackRange && m_owner.DistanceToParty >= 2f)
             {
                 m_owner.CombatHandler.AttackRanged();
                 return;
             }
             if (m_targetSlot == null && (m_owner.Position.X == p_party.Position.X || m_owner.Position.Y == p_party.Position.Y))
             {
                 EDirection direction = EDirectionFunctions.GetDirection(p_party.Position, m_owner.Position);
                 GridSlot   gridSlot  = p_grid.GetSlot(p_party.Position);
                 for (Int32 i = 0; i < m_owner.StaticData.AttackRange; i++)
                 {
                     GridSlot neighborSlot = gridSlot.GetNeighborSlot(p_grid, direction);
                     if (neighborSlot == null)
                     {
                         break;
                     }
                     gridSlot = neighborSlot;
                 }
                 if (gridSlot != null)
                 {
                     m_targetSlot = gridSlot;
                 }
             }
             if (m_targetSlot == null)
             {
                 List <GridSlot> rangedTargets2 = GetRangedTargets(p_grid, p_party);
                 if (rangedTargets2.Count > 0)
                 {
                     rangedTargets2.Sort(new Comparison <GridSlot>(DistSortAsc));
                     if (TryMove(rangedTargets2, p_grid, p_startSlot, p_party))
                     {
                         return;
                     }
                     p_isMelee  = true;
                     m_decision = EMonsterStrategyDecision.MELEE;
                 }
                 else
                 {
                     p_isMelee  = true;
                     m_decision = EMonsterStrategyDecision.MELEE;
                 }
             }
             else
             {
                 if (!(m_owner.Position != m_targetSlot.Position))
                 {
                     p_isMelee  = true;
                     m_decision = EMonsterStrategyDecision.MELEE;
                     return;
                 }
                 if (TryMove(new List <GridSlot>
                 {
                     m_targetSlot
                 }, p_grid, p_startSlot, p_party))
                 {
                     return;
                 }
                 p_isMelee    = true;
                 m_targetSlot = null;
                 m_decision   = EMonsterStrategyDecision.CALCULATE_STRATEGY;
             }
         }
     }
 }
        protected virtual void PushBack(Monster p_monster, SpellEventArgs p_result)
        {
            if (p_monster.CurrentHealth <= 0)
            {
                return;
            }
            if (p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.LARGE) || p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.BOSS) || p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.STATIC_OBJECT) || p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.SPIRIT_BOUND))
            {
                p_result.SpellTargets.Add(new PushedTarget(p_monster, p_monster.Position, false));
                if (p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.LARGE))
                {
                    MonsterAbilityBase        ability = p_monster.AbilityHandler.GetAbility(EMonsterAbilityType.LARGE);
                    AbilityTriggeredEventArgs p_args  = new AbilityTriggeredEventArgs(p_monster, ability);
                    p_monster.AbilityHandler.AddEntry(ability.ExecutionPhase, p_args);
                }
                else if (p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.BOSS))
                {
                    MonsterAbilityBase        ability2 = p_monster.AbilityHandler.GetAbility(EMonsterAbilityType.BOSS);
                    AbilityTriggeredEventArgs p_args2  = new AbilityTriggeredEventArgs(p_monster, ability2);
                    p_monster.AbilityHandler.AddEntry(ability2.ExecutionPhase, p_args2);
                }
                else if (p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.STATIC_OBJECT))
                {
                    MonsterAbilityBase        ability3 = p_monster.AbilityHandler.GetAbility(EMonsterAbilityType.STATIC_OBJECT);
                    AbilityTriggeredEventArgs p_args3  = new AbilityTriggeredEventArgs(p_monster, ability3);
                    p_monster.AbilityHandler.AddEntry(ability3.ExecutionPhase, p_args3);
                }
                else if (p_monster.AbilityHandler.HasAbility(EMonsterAbilityType.SPIRIT_BOUND))
                {
                    MonsterAbilityBase        ability4 = p_monster.AbilityHandler.GetAbility(EMonsterAbilityType.SPIRIT_BOUND);
                    AbilityTriggeredEventArgs p_args4  = new AbilityTriggeredEventArgs(p_monster, ability4);
                    p_monster.AbilityHandler.AddEntry(ability4.ExecutionPhase, p_args4);
                }
                return;
            }
            Position   position  = p_monster.Position;
            Party      party     = LegacyLogic.Instance.WorldManager.Party;
            Grid       grid      = LegacyLogic.Instance.MapLoader.Grid;
            EDirection direction = EDirectionFunctions.GetDirection(party.Position, p_monster.Position);

            for (Int32 i = 0; i < m_PushCount; i++)
            {
                if (!grid.CanMoveEntity(p_monster, direction))
                {
                    break;
                }
                Position p_pos = p_monster.Position + direction;
                GridSlot slot  = grid.GetSlot(p_monster.Position);
                if (grid.GetSlot(p_pos).AddEntity(p_monster))
                {
                    if (party.SelectedMonster == p_monster)
                    {
                        party.SelectedMonster = null;
                    }
                    slot.RemoveEntity(p_monster);
                }
            }
            if (position != p_monster.Position)
            {
                p_result.SpellTargets.Add(new PushedTarget(p_monster, p_monster.Position, true));
            }
        }
Exemplo n.º 15
0
        private void HandlePhase3()
        {
            m_subStateFinished = false;
            if (!m_strategyA)
            {
                switch (m_roundSubState)
                {
                case 0:
                    if (LegacyLogic.Instance.WorldManager.Party.InCombat)
                    {
                        if (m_owner.Direction != EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position))
                        {
                            m_owner.Rotate(EDirectionFunctions.RotationCount(m_owner.Direction, EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position)), true);
                        }
                        else
                        {
                            m_roundSubState++;
                            m_subStateFinished = true;
                        }
                    }
                    else
                    {
                        m_roundSubState++;
                        m_subStateFinished = true;
                    }
                    break;

                case 1:
                    if (!LegacyLogic.Instance.WorldManager.Party.InCombat)
                    {
                        m_strategyA     = true;
                        m_roundSubState = 0;
                    }
                    else if (!m_owner.BuffHandler.HasBuff(EMonsterBuffType.FLICKERING_LIGHT))
                    {
                        MonsterSpell p_spell = m_owner.SpellHandler.SelectSpellByID(36);
                        m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                        CastSpell(p_spell);
                    }
                    else
                    {
                        m_owner.CombatHandler.CastSpell = false;
                        m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                        m_owner.CombatHandler.DoAttack();
                    }
                    break;

                case 2:
                    m_owner.CombatHandler.CastSpell = false;
                    m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                    m_owner.CombatHandler.DoAttack();
                    break;

                case 3:
                {
                    MonsterSpell p_spell2 = m_owner.SpellHandler.SelectSpellByID(37);
                    m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                    CastSpell(p_spell2);
                    break;
                }
                }
                if (m_roundSubState >= 4)
                {
                    m_isFinished = true;
                    m_owner.m_stateMachine.ChangeState(Monster.EState.IDLE);
                    LegacyLogic.Instance.WorldManager.Party.InCombat = LegacyLogic.Instance.MapLoader.Grid.CheckInCombat(LegacyLogic.Instance.WorldManager.Party.Position);
                    m_strategyA = !m_strategyA;
                    return;
                }
            }
            if (m_strategyA)
            {
                switch (m_roundSubState)
                {
                case 0:
                    if (!m_owner.BuffHandler.HasBuff(EMonsterBuffType.FLICKERING_LIGHT))
                    {
                        MonsterSpell p_spell3 = m_owner.SpellHandler.SelectSpellByID(36);
                        m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                        CastSpell(p_spell3);
                    }
                    else
                    {
                        m_roundSubState++;
                        m_subStateFinished = true;
                    }
                    break;

                case 1:
                    if (LegacyLogic.Instance.WorldManager.Party.InCombat || LegacyLogic.Instance.MapLoader.Grid.LineOfSight(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position))
                    {
                        if (m_owner.Direction != EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position))
                        {
                            m_owner.Rotate(EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position), true);
                        }
                        else
                        {
                            m_roundSubState++;
                            m_subStateFinished = true;
                        }
                    }
                    else
                    {
                        m_roundSubState++;
                        m_subStateFinished = true;
                    }
                    break;

                case 2:
                    if (!LegacyLogic.Instance.MapLoader.Grid.LineOfSight(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position))
                    {
                        MonsterSpell p_spell4 = m_owner.SpellHandler.SelectSpellByID(37);
                        m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                        CastSpell(p_spell4);
                        m_castedFlicker = true;
                    }
                    else
                    {
                        MonsterSpell p_spell5 = m_owner.SpellHandler.SelectSpellByID(34);
                        m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                        CastSpell(p_spell5);
                    }
                    break;

                case 3:
                    if (m_owner.Direction != EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position))
                    {
                        m_owner.Rotate(EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position), true);
                    }
                    if (LegacyLogic.Instance.MapLoader.Grid.LineOfSight(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position))
                    {
                        MonsterSpell p_spell6 = m_owner.SpellHandler.SelectSpellByID(34);
                        m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                        CastSpell(p_spell6);
                    }
                    else
                    {
                        m_roundSubState++;
                        m_subStateFinished = true;
                    }
                    break;
                }
                if (m_roundSubState >= 4)
                {
                    m_isFinished = true;
                    m_owner.m_stateMachine.ChangeState(Monster.EState.IDLE);
                    m_strategyA = !m_strategyA;
                }
            }
        }
Exemplo n.º 16
0
        private void HandlePhase2()
        {
            m_subStateFinished = false;
            switch (m_roundSubState)
            {
            case 0:
                if (!m_owner.BuffHandler.HasBuff(EMonsterBuffType.FLICKERING_LIGHT))
                {
                    MonsterSpell p_spell = m_owner.SpellHandler.SelectSpellByID(36);
                    m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                    m_castedFlickeringLight = true;
                    CastSpell(p_spell);
                }
                else
                {
                    m_roundSubState++;
                    m_subStateFinished = true;
                }
                break;

            case 1:
                if (!LegacyLogic.Instance.WorldManager.Party.InCombat)
                {
                    MonsterSpell p_spell2 = m_owner.SpellHandler.SelectSpellByID(37);
                    m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                    CastSpell(p_spell2);
                }
                else
                {
                    m_roundSubState++;
                    m_subStateFinished = true;
                }
                break;

            case 2:
                if (m_owner.Direction != EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position))
                {
                    m_owner.Rotate(EDirectionFunctions.RotationCount(m_owner.Direction, EDirectionFunctions.GetDirection(m_owner.Position, LegacyLogic.Instance.WorldManager.Party.Position)), true);
                }
                else
                {
                    m_roundSubState++;
                    m_subStateFinished = true;
                }
                break;

            case 3:
                if (!m_castedFlickeringLight && LegacyLogic.Instance.WorldManager.Party.InCombat)
                {
                    MonsterSpell p_spell3 = m_owner.SpellHandler.SelectSpellByID(34);
                    m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                    CastSpell(p_spell3);
                }
                else
                {
                    m_roundSubState++;
                    m_subStateFinished = true;
                }
                break;

            case 4:
                if (LegacyLogic.Instance.WorldManager.Party.InCombat)
                {
                    m_owner.CombatHandler.CastSpell = false;
                    m_owner.m_stateMachine.ChangeState(Monster.EState.MOVING);
                    m_owner.CombatHandler.DoAttack();
                }
                else
                {
                    m_isFinished = true;
                    m_owner.m_stateMachine.ChangeState(Monster.EState.ACTION_FINISHED);
                }
                break;

            case 5:
                m_owner.m_stateMachine.ChangeState(Monster.EState.ACTION_FINISHED);
                m_isFinished = true;
                break;
            }
        }