public override void HandleAttacks(List <Attack> p_attackList, Monster p_monster, Character p_character, Boolean p_isMagic) { if (p_monster.DistanceToParty > 1f) { return; } Party party = LegacyLogic.Instance.WorldManager.Party; Grid grid = LegacyLogic.Instance.MapLoader.Grid; Position position = party.Position; Position position2 = position + EDirectionFunctions.GetLineOfSightDirection(p_monster.Position, party.Position); GridSlot slot = grid.GetSlot(position2); if (slot == null) { return; } party.IsPushed = true; if (!slot.HasEntities && grid.CanMoveEntity(party, p_monster.Direction)) { GridSlot slot2 = grid.GetSlot(position); slot2.RemoveEntity(party); party.Position = position2; grid.GetSlot(position2).AddEntity(party); MoveEntityEventArgs p_eventArgs = new MoveEntityEventArgs(position, position2); LegacyLogic.Instance.EventManager.InvokeEvent(party, EEventType.MOVE_ENTITY, p_eventArgs); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ENTITY_ABILITY_ADDED, new AbilityEventArgs(p_monster, this)); AbilityTriggeredEventArgs p_args = new AbilityTriggeredEventArgs(p_monster, this); LegacyLogic.Instance.ActionLog.PushEntry(p_args); } else { party.IsPushed = false; } }
private void ShowHitEffect(Monster mob) { if (mob != null) { Party party = LegacyLogic.Instance.WorldManager.Party; EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(party.Position, mob.Position); if (lineOfSightDirection != party.Direction) { if (EDirectionFunctions.Add(lineOfSightDirection, 2) == party.Direction) { m_bottomEffect.Stop(); m_bottomEffect.Play(); } if (EDirectionFunctions.Add(lineOfSightDirection, 1) == party.Direction) { m_leftEffect.Stop(); m_leftEffect.Play(); } if (EDirectionFunctions.Add(lineOfSightDirection, -1) == party.Direction) { m_rightEffect.Stop(); m_rightEffect.Play(); } } } }
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); }
private void GetMeleePosition(Grid p_grid, Party p_party, List <GridSlot> p_slots) { EDirection oppositeDir = EDirectionFunctions.GetOppositeDir(p_party.Direction); EDirection p_dir = EDirectionFunctions.Add(p_party.Direction, 3); EDirection p_dir2 = EDirectionFunctions.Add(p_party.Direction, 1); EDirection direction = p_party.Direction; Int32 num = Random.Range(0, 13); GridSlot neighborSlot; if (num >= 5) { neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, oppositeDir); } else if (num >= 3) { neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, p_dir); } else if (num >= 1) { neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, p_dir2); } else { neighborSlot = p_grid.GetSlot(p_party.Position).GetNeighborSlot(p_grid, direction); } if (neighborSlot.IsPassable(m_owner, false)) { m_targetSlot = neighborSlot; } else { m_targetSlot = p_slots[Random.Range(0, p_slots.Count)]; } }
private Boolean TryOpenDoor(GridSlot p_slot, EDirection p_dir) { List <InteractiveObject> doors = p_slot.GetDoors(); for (Int32 i = 0; i < doors.Count; i++) { Door door = (Door)doors[i]; if (door.Location == p_dir && door.State == EInteractiveObjectState.DOOR_CLOSED && door.Commands.Count > 0) { door.Execute(LegacyLogic.Instance.MapLoader.Grid); door.Update(); return(true); } } GridSlot neighborSlot = p_slot.GetNeighborSlot(LegacyLogic.Instance.MapLoader.Grid, p_dir); doors = neighborSlot.GetDoors(); for (Int32 j = 0; j < doors.Count; j++) { Door door2 = (Door)doors[j]; if (door2.Location == EDirectionFunctions.GetOppositeDir(p_dir) && door2.State == EInteractiveObjectState.DOOR_CLOSED && door2.Commands.Count > 0) { door2.Execute(LegacyLogic.Instance.MapLoader.Grid); door2.Update(); return(true); } } return(false); }
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; } }
protected override void DoExecute() { Boolean flag = false; Party party = LegacyLogic.Instance.WorldManager.Party; for (Int32 i = 0; i < 4; i++) { Character member = party.GetMember(i); BaseItem itemAt = member.Equipment.Equipment.GetItemAt(6); if (itemAt != null) { flag = true; break; } } if (flag) { Grid grid = LegacyLogic.Instance.MapLoader.Grid; grid.MoveEntity(party, EDirectionFunctions.GetOppositeDir(party.Direction)); } FinishExecution(); if (flag) { m_stateMachine.ChangeState(3); } else { m_stateMachine.ChangeState(2); } }
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); }
private Boolean IsMonsterInFrontOfParty() { if (MyController != null) { Monster monster = (Monster)MyController; Party party = LegacyLogic.Instance.WorldManager.Party; GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position); return(Position.Distance(monster.Position, party.Position) <= 1f && EDirectionFunctions.GetLineOfSightDirection(party.Position, monster.Position) == party.Direction && slot != null && slot.GetConnection(party.Direction, false, true) != null); } return(false); }
private void Update() { if (!enabled) { return; } if (!Input.GetMouseButtonUp(0)) { return; } if (UICamera.hoveredObject != null) { return; } if (FXMainCamera.Instance == null) { return; } Camera camera = FXMainCamera.Instance.DefaultCamera.camera; if (camera == null) { return; } Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit raycastHit; if (Physics.Raycast(ray, out raycastHit, 50f)) { InteractiveObjectHighlight component = raycastHit.collider.GetComponent <InteractiveObjectHighlight>(); if (component != null && component.IsClickable) { InteractiveObject myController = component.MyController; LegacyLogic.Instance.WorldManager.Party.SelectedInteractiveObject = myController; LegacyLogic.Instance.CommandManager.AddCommand(new InteractCommand(myController)); return; } if (raycastHit.rigidbody != null) { BaseView component2 = raycastHit.rigidbody.GetComponent <BaseView>(); if (component2 != null && component2.MyController is Monster) { Monster monster = (Monster)component2.MyController; Party party = LegacyLogic.Instance.WorldManager.Party; Single num = Position.Distance(monster.Position, party.Position); if (num == 1f && EDirectionFunctions.GetLineOfSightDirection(party.Position, monster.Position) == party.Direction && monster.CurrentHealth > 0) { party.SelectedMonster = monster; } return; } } } }
public override Boolean CanDoAction(Command p_command) { if (Party.SelectedMonster != null) { EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(Party.Position, Party.SelectedMonster.Position); if (lineOfSightDirection != Party.Direction) { return(false); } } return(true); }
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; } }
protected Boolean Move(List <GridSlot> p_movePath) { if (p_movePath.Count > 0) { GridSlot gridSlot = p_movePath[0]; Grid grid = LegacyLogic.Instance.MapLoader.Grid; EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(Controller.Position, gridSlot.Position); if (grid.MoveEntity(Controller, lineOfSightDirection)) { p_movePath.RemoveAt(0); return(true); } } return(false); }
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); }
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(); }
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); } }
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; } }
public BaseDoorInteraction(SpawnCommand p_command, Int32 p_parentID, Int32 p_commandIndex) : base(p_command, p_parentID, p_commandIndex) { m_parent = Grid.FindInteractiveObject(m_parentID); m_targetDoor = (Door)Grid.FindInteractiveObject(m_targetSpawnID); if (m_targetDoor == null) { m_valid = false; return; } GridSlot slot = Grid.GetSlot(m_targetDoor.Position); m_leaveTransition = slot.GetTransition(m_targetDoor.Location); Position p_pos = m_targetDoor.Position + m_targetDoor.Location; GridSlot slot2 = Grid.GetSlot(p_pos); if (slot2 != null) { m_enterTransition = slot2.GetTransition(EDirectionFunctions.GetOppositeDir(m_targetDoor.Location)); } }
protected override void SetStates() { if (m_targetDoor == null) { throw new InvalidOperationException("Tried to open or close something that is not a door!"); } if (!m_delayStateChange) { m_targetDoor.ToggleState(); m_leaveTransition.ToggleState(); if (m_enterTransition != null) { m_enterTransition.ToggleState(); } GridSlot neighborSlot = Grid.GetSlot(m_targetDoor.Position).GetNeighborSlot(Grid, m_targetDoor.Location); if (neighborSlot != null) { List <InteractiveObject> doors = neighborSlot.GetDoors(); for (Int32 i = 0; i < doors.Count; i++) { if (doors[i].Type == EObjectType.DOOR && EDirectionFunctions.GetOppositeDir(doors[i].Location) == m_targetDoor.Location) { Door door = (Door)doors[i]; if (m_targetDoor.State == EInteractiveObjectState.DOOR_OPEN) { door.Open(); } else { door.Close(); } break; } } } } else { m_delayStateChange = true; } }
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; }
public virtual List <GridSlot> GetMeleeTargets(Grid p_grid, Party p_party) { List <GridSlot> list = new List <GridSlot>(); Int32 num = Math.Min(p_party.Position.X, m_owner.Position.X); Int32 num2 = Math.Min(p_party.Position.Y, m_owner.Position.Y); Int32 num3 = Math.Max(p_party.Position.X, m_owner.Position.X); Int32 num4 = Math.Max(p_party.Position.Y, m_owner.Position.Y); if (num == p_party.Position.X) { num--; num3 = num + 2; } if (num2 == p_party.Position.Y) { num2--; num4 = num2 + 2; } for (Int32 i = num; i <= num3; i++) { for (Int32 j = num2; j <= num4; j++) { Position position = new Position(i, j); if (!(position == p_party.Position) && !(position == m_owner.Position)) { GridSlot slot = p_grid.GetSlot(position); if (slot != null && slot.IsPassable(m_owner, false) && Position.Distance(position, p_party.Position) == 1f) { EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(slot.Position, p_party.Position); if (slot.GetTransition(lineOfSightDirection).TransitionType == EGridTransitionType.OPEN) { list.Add(slot); } } } } } return(list); }
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); }
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(); } } }
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; } } } } }
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; } } } }
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; } }
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; } } }
public override void HandleAttacks(List <Attack> p_attackList, Monster p_monster, Character p_character, Boolean p_isMagic) { if (p_monster.DistanceToParty > 1f) { return; } Grid grid = LegacyLogic.Instance.MapLoader.Grid; Position position = LegacyLogic.Instance.WorldManager.Party.Position; EDirection direction = LegacyLogic.Instance.WorldManager.Party.Direction; EDirection p_dir = (direction - EDirection.EAST != -1) ? (direction - 1) : EDirection.WEST; EDirection p_dir2 = (direction + 1 != EDirection.COUNT) ? (direction + 1) : EDirection.NORTH; Boolean flag = true; if (direction != EDirectionFunctions.GetOppositeDir(p_monster.Direction) && direction != p_monster.Direction) { p_dir = direction; p_dir2 = EDirectionFunctions.GetOppositeDir(direction); flag = false; } p_monster.CombatHandler.MeleeStrikes = 3; Position position2 = p_monster.Position; Position p_pos = position + p_dir; Position position3 = position + p_dir2; Boolean flag2 = Random.Range(0, 2) == 1; if (flag2) { if (grid.GetSlot(p_pos).AddEntity(p_monster)) { grid.GetSlot(position2).RemoveEntity(p_monster); p_monster.Rotate(EDirectionFunctions.RotationCount(p_monster.Direction, EDirectionFunctions.GetOppositeDir(direction)), false); if (flag) { p_monster.Rotate(-1, false); } } else { flag2 = false; } } if (!flag2) { if (Position.Distance(p_monster.Position, position3) < 2f) { if (grid.GetSlot(position3).AddEntity(p_monster)) { grid.GetSlot(position2).RemoveEntity(p_monster); p_monster.Rotate(EDirectionFunctions.RotationCount(p_monster.Direction, EDirectionFunctions.GetOppositeDir(direction)), false); if (flag) { p_monster.Rotate(1, false); } } } else if (grid.GetSlot(p_pos).AddEntity(p_monster)) { grid.GetSlot(position2).RemoveEntity(p_monster); p_monster.Rotate(EDirectionFunctions.RotationCount(p_monster.Direction, EDirectionFunctions.GetOppositeDir(direction)), false); if (flag) { p_monster.Rotate(-1, false); } } } if (position2 != p_monster.Position) { MoveEntityEventArgs p_eventArgs = new MoveEntityEventArgs(position2, p_monster.Position); LegacyLogic.Instance.EventManager.InvokeEvent(p_monster, EEventType.MOVE_ENTITY, p_eventArgs); AbilityTriggeredEventArgs p_args = new AbilityTriggeredEventArgs(p_monster, this); LegacyLogic.Instance.ActionLog.PushEntry(p_args); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ENTITY_ABILITY_ADDED, new AbilityEventArgs(p_monster, this)); } }
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)); } }