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); }
public override List <GridSlot> GetRangedTargets(Grid p_grid, Party p_party) { List <GridSlot> list = new List <GridSlot>(); GridSlot slot = p_grid.GetSlot(p_party.Position); GridSlot slot2 = p_grid.GetSlot(new Position(slot.Position.X, slot.Position.Y + (Position.Up * m_owner.StaticData.AttackRange).Y)); if (slot2.IsPassable(m_owner, false) && p_grid.LineOfSight(slot2.Position, p_party.Position, true)) { list.Add(slot2); } GridSlot slot3 = p_grid.GetSlot(new Position(slot.Position.X + (Position.Right * m_owner.StaticData.AttackRange).X, slot.Position.Y)); if (slot3.IsPassable(m_owner, false) && p_grid.LineOfSight(slot3.Position, p_party.Position, true)) { list.Add(slot3); } GridSlot slot4 = p_grid.GetSlot(new Position(slot.Position.X, slot.Position.Y + (Position.Down * m_owner.StaticData.AttackRange).Y)); if (slot4.IsPassable(m_owner, false) && p_grid.LineOfSight(slot4.Position, p_party.Position, true)) { list.Add(slot4); } GridSlot slot5 = p_grid.GetSlot(new Position(slot.Position.X + (Position.Left * m_owner.StaticData.AttackRange).X, slot.Position.Y)); if (slot5.IsPassable(m_owner, false) && p_grid.LineOfSight(slot5.Position, p_party.Position, true)) { list.Add(slot5); } return(list); }
public override Boolean CheckSpellConditions(Character p_sorcerer) { if (SpellType == ECharacterSpell.WARFARE_CRIPPLING_TRAP) { Grid grid = LegacyLogic.Instance.MapLoader.Grid; GridSlot slot = grid.GetSlot(LegacyLogic.Instance.WorldManager.Party.Position); foreach (MovingEntity movingEntity in slot.Entities) { Summon summon = movingEntity as Summon; if (summon != null && summon.StaticID == 6) { return(false); } } return(true); } if (SpellType == ECharacterSpell.SPELL_PRIME_TIME_STOP || SpellType == ECharacterSpell.WARFARE_CRIPPLING_TRAP) { return(true); } Party party = LegacyLogic.Instance.WorldManager.Party; Grid grid2 = LegacyLogic.Instance.MapLoader.Grid; GridSlot slot2 = grid2.GetSlot(party.Position + party.Direction); GridSlot slot3 = grid2.GetSlot(LegacyLogic.Instance.WorldManager.Party.Position); return(slot2 != null && slot2.IsPassable(m_testEntity, false, true) && slot3.GetTransition(party.Direction).NextState != EGridTransitionType.CLOSED); }
public override List <GridSlot> GetMeleeTargets(Grid p_grid, Party p_party) { List <GridSlot> list = new List <GridSlot>(); GridSlot slot = p_grid.GetSlot(p_party.Position); for (Int32 i = 0; i <= 3; i++) { GridSlot neighborSlot = slot.GetNeighborSlot(p_grid, (EDirection)i); if (neighborSlot.IsPassable(m_owner, false)) { list.Add(neighborSlot); } } return(list); }
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); }
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; } } } } }