Example #1
0
        public static void IssueOrderEx(this Obj_AI_Base hero, GameObjectOrder order, GameObject target,
                                        bool packet = false)
        {
            if (packet)
            {
                var p = new Packet.C2S.Move.Struct
                {
                    MoveType        = (byte)order,
                    SourceNetworkId = hero.NetworkId
                };

                switch (order)
                {
                case GameObjectOrder.AttackUnit:
                    p.TargetNetworkId = target.NetworkId;
                    break;
                }

                Packet.C2S.Move.Encoded(p).Send();
            }
            else
            {
                hero.IssueOrder(order, target);
            }
        }
Example #2
0
        public static void IssueOrderEx(this Obj_AI_Base hero, GameObjectOrder order, Vector3 point, bool packet = false)
        {
            if (packet)
            {
                var p = new Packet.C2S.Move.Struct
                {
                    MoveType        = (byte)order,
                    SourceNetworkId = hero.NetworkId,
                    X = point.X,
                    Y = point.Y
                };

                switch (order)
                {
                case GameObjectOrder.HoldPosition:
                    p.X = hero.ServerPosition.X;
                    p.Y = hero.ServerPosition.Y;
                    break;
                }

                Packet.C2S.Move.Encoded(p).Send();
            }
            else
            {
                hero.IssueOrder(order, point);
            }
        }
Example #3
0
 public IssueOrderEventArgs(int sourceId, GameObjectOrder order, Vector3 targetPosition, int targetId, bool isAttackMove, bool isPetCommand)
 {
     this.SourceId       = sourceId;
     this.Order          = order;
     this.TargetPosition = targetPosition;
     this.TargetId       = targetId;
     this.IsAttackMove   = isAttackMove;
     this.IsPetCommand   = isPetCommand;
 }
Example #4
0
 private static void Player_OnIssueOrder(Obj_AI_Base sender, PlayerIssueOrderEventArgs args)
 {
     if (!sender.IsMe)
     {
         return;
     }
     Order         = args.Order;
     OrderPosition = args.TargetPosition;
     OrderTarget   = args.Target;
 }
Example #5
0
        public static void IssueOrder(GameObjectOrder Order, Point Vector2D = new Point())
        {
            if (!Utils.IsGameOnDisplay())
            {
                return;
            }
            switch (Order)
            {
            case GameObjectOrder.HoldPosition:
                Keyboard.SendKey((short)Keyboard.KeyBoardScanCodes.KEY_S);
                break;

            case GameObjectOrder.MoveTo:
                if (Vector2D.X == 0 && Vector2D.Y == 0)
                {
                    Mouse.MouseClickRight();
                    break;
                }

                if (Vector2D == new Point(Cursor.Position.X, Cursor.Position.Y))
                {
                    Mouse.MouseClickRight();
                    break;
                }

                Mouse.MouseMove(Vector2D.X, Vector2D.Y);
                Mouse.MouseClickRight();
                break;

            case GameObjectOrder.AttackUnit:
                if (Vector2D.X == 0 && Vector2D.Y == 0)
                {
                    Mouse.MouseMove(Cursor.Position.X, Cursor.Position.Y);
                    Mouse.MouseClickRight();
                    break;
                }

                Mouse.MouseMove(Vector2D.X, Vector2D.Y);
                Mouse.MouseClickRight();
                break;

            case GameObjectOrder.AutoAttack:
                Keyboard.SendKey((short)Keyboard.KeyBoardScanCodes.KEY_OPENING_BRACKETS);
                break;

            case GameObjectOrder.Stop:
                Keyboard.SendKey((short)Keyboard.KeyBoardScanCodes.KEY_S);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(Order), Order, null);
            }
        }
Example #6
0
        private void UpdateSequence(GameObjectOrder order)
        {
            if (!_sequences.ContainsKey(order))
            {
                _sequences[order] = new Sequence();
            }
            var sequence = _sequences[order];

            if (sequence.Items == null || sequence.Index >= sequence.Items.Length)
            {
                sequence.Items = CreateSequence(_menu.Item(_menu.Name + ".orders.clicks").GetValue <Slider>().Value);
            }
        }
Example #7
0
        public static void IssueOrder(GameObjectOrder Order, Point Vector2D = new Point())
        {
            if (Utils.IsGameOnDisplay())
            {
                switch (Order)
                {
                case GameObjectOrder.HoldPosition:
                    Keyboard.SendKey((short)Keyboard.KeyBoardScanCodes.KEY_S);
                    break;

                case GameObjectOrder.MoveTo:
                    if (Vector2D.X == 0 && Vector2D.Y == 0)
                    {
                        Mouse.MouseClickRight();
                        break;
                    }
                    if (Vector2D == new Point(Cursor.Position.X, Cursor.Position.Y))
                    {
                        Mouse.MouseClickRight();
                        break;
                    }
                    Mouse.MouseMove(Vector2D.X, Vector2D.Y);
                    Mouse.MouseClickRight();
                    break;

                case GameObjectOrder.AttackUnit:
                    if (Vector2D.X == 0 && Vector2D.Y == 0)
                    {
                        Mouse.MouseMove(Cursor.Position.X, Cursor.Position.Y);
                        Mouse.MouseClickRight();
                        break;
                    }
                    Mouse.MouseMove(Vector2D.X, Vector2D.Y);
                    Mouse.MouseClickRight();
                    break;

                case GameObjectOrder.AutoAttack:
                    Keyboard.SendKey((short)Keyboard.KeyBoardScanCodes.KEY_OPENING_BRACKETS);
                    break;

                case GameObjectOrder.Stop:
                    Keyboard.SendKey((short)Keyboard.KeyBoardScanCodes.KEY_S);
                    break;
                }
            }
        }
Example #8
0
 /// <summary>
 /// Gives unit an order with specified parameters
 /// </summary>
 /// <param id="order">New game object order</param>
 /// <param id="orderParam">Order's EntryDb parameter</param>
 /// <param id="targetTile">Tracked tile at the moment of giving order</param>
 /// <param id="targetGameObject">Tracked game object at the moment of giving order</param>
 /// <returns>Returns true if the order was successfully applied to the game object</returns>
 public virtual bool SetOrder(GameObjectOrder order, EntryDb orderParam, Tile targetTile, GameObject targetGameObject)
 {
   if (Health == 0) return false;
   CancelOrders();
   if (targetTile == null && targetGameObject == null) return false;
   if (!CanDoOrder(order)) return false;
   return true;
 }
Example #9
0
    // PLAYER ORDERS

    /// <summary>
    /// Determines, whether game object can perform given order
    /// </summary>
    /// <param id="order">Order to check</param>
    /// <returns>Returns true if game object can perform given order</returns>
    public virtual bool CanDoOrder(GameObjectOrder order) { return false; }
Example #10
0
 private void UpdateSequence(GameObjectOrder order)
 {
     if (!_sequences.ContainsKey(order))
     {
         _sequences[order] = new Sequence();
     }
     var sequence = _sequences[order];
     if (sequence.Items == null || sequence.Index >= sequence.Items.Length ||
         Utils.GameTimeTickCount - sequence.LastItemsChange >
         _random.Next((int) (1000f * 0.975f), (int) (1000f * 1.025f)))
     {
         sequence.Items = CreateSequence(_menu.Item(_menu.Name + ".orders.clicks").GetValue<Slider>().Value);
     }
 }
Example #11
0
 public bool IssueOrder(GameObjectOrder order, Vector3 targetPos)
 {
 }
Example #12
0
 public bool IssueOrder(GameObjectOrder order, GameObject targetUnit)
 {
 }
Example #13
0
 public GameObjectIssueOrderEventArgs(int process, GameObjectOrder order, Vector3 targetPosition, GameObject target, [MarshalAs(UnmanagedType.U1)] bool attackMove)
 {
 }
Example #14
0
 public bool IssueOrder(GameObjectOrder order, IAttackable target)
 {
     return(this.CanRun(() => Fragment.IssueOrder(order, target)));
 }
Example #15
0
 public bool IssueOrder(GameObjectOrder order, Vector3 target)
 {
     return(this.CanRun(() => Fragment.IssueOrder(order, target)));
 }
Example #16
0
 public bool IssueOrder(GameObjectOrder order, IAttackable target)
 {
     return(this.player.IssueOrder((EnsoulSharp.GameObjectOrder)order, EnsoulSharp.ObjectManager.GetUnitByNetworkId <EnsoulSharp.AttackableUnit>(target.Id)));
 }
Example #17
0
 public bool IssueOrder(GameObjectOrder order, Vector3 target)
 {
     return(this.player.IssueOrder((EnsoulSharp.GameObjectOrder)order, target));
 }
Example #18
0
 private static void Player_OnIssueOrder(Obj_AI_Base sender, PlayerIssueOrderEventArgs args)
 {
     if (!sender.IsMe) return;
     Order = args.Order;
     OrderPosition = args.TargetPosition;
     OrderTarget = args.Target;
 }
Example #19
0
 public IssueOrder(DateTime time, Vector3 pos, GameObjectOrder order)
 {
     Order = order;
     Time  = time;
     Pos   = pos;
 }
Example #20
0
    /// <summary>
    /// Gives unit an order with specified parameters
    /// </summary>
    /// <param id="order">New game object order</param>
    /// <param id="orderParam">Order's EntryDb parameter</param>
    /// <param id="targetTile">Tracked tile at the moment of giving order</param>
    /// <param id="targetGameObject">Tracked game object at the moment of giving order</param>
    /// <returns>Returns true if the order was successfully applied to the game object</returns>
    public override bool SetOrder(GameObjectOrder order, EntryDb orderParam, Tile targetTile, GameObject targetGameObject)
    {
      if (this.game.IsServer) Debug.Fail("Server isn't supposed to call this routine");

      if (!base.SetOrder(order, orderParam, targetTile, targetGameObject))
      {
        game.SendData(Network.MakeClientMessage(MessageType.GameObjUpdate, this));
        return false;
      }

      if (!CanDoOrder(order))
      {
        GameEffect ge = new ScrollTextEffect("Unit cannot attack", Position, 50, new Vector2(0, -1f));
        ge.Initialize(game, NearestTile);
        this.game.Effects.Add(ge);

        CancelOrders(true);
        return false;
      }

      BuildingDb bldgEntry;

      switch (order)
      {
        case GameObjectOrder.Idle:
          #region
          if (targetTile == null) return false;
          OrderTarget = null;
          OrderRange = MOVEMENT_RANGE;
          OrderPosition = targetTile.MapPosition + new Vector2(MapBoard.TILE_XSPACING, MapBoard.TILE_YSPACING) / 2;
          #endregion
          break;
        case GameObjectOrder.Attack:
          #region
          if (targetGameObject == null) return false; // Hit something
          if (targetGameObject == this) return false; // Don't hit yourself
          OrderTarget = targetGameObject;
          OrderRange = entry.AttackRange;
          OrderTimeout = entry.AttackSpeed;
          #endregion
          break;
        case GameObjectOrder.Construct:
          #region
          OrderRange = entry.ConstructRange;
          OrderTimeout = entry.ConstructSpeed;

          if (targetGameObject != null && targetGameObject.GetEntityType == GameEntityType.Building)
          {
            OrderTarget = targetGameObject;
            OrderEntry = null;
          }
          else if (targetGameObject == null || targetGameObject.GetEntityType == GameEntityType.Unit)
          {
            if (orderParam == null) return false;
            bldgEntry = (BuildingDb)orderParam;
            if (bldgEntry.OnlyOneAllowed && Owner.Buildings.Any(q => q.Entry == orderParam))
            {
              ScrollUpMessage("Only one such building allowed at a time", 50, false);
              CancelOrders(true);
              return false;
            }
            if (bldgEntry.UnlockedBy != null)
            {
              Building bldg = Owner.Buildings.FirstOrDefault(q => q.Entry == bldgEntry.UnlockedBy);
              if (bldg == null || !bldg.Constructed)
              {
                ScrollUpMessage("Building unavailable", 100, true);
                CancelOrders(true);
                return false;
              }
            }

            OrderTarget = null;
            OrderEntry = (BuildingDb)orderParam;
            OrderPosition = targetTile.MapPosition + new Vector2(MapBoard.TILE_XSPACING, MapBoard.TILE_YSPACING) / 2;
          }
          #endregion
          break;
        case GameObjectOrder.Spell:
          #region

          EffectDb effect = (EffectDb)orderParam;

          if (effect.UnlockedBy != null)
          {
            Building bldg = Owner.Buildings.FirstOrDefault(q => q.Entry == effect.UnlockedBy);
            if (bldg == null || !bldg.Constructed)
            {
              ScrollUpMessage("Spell unavailable", 100, true);
              CancelOrders(true);
              return false;
            }
          }

          OrderEntry = effect;
          OrderRange = effect.CastRange;
          OrderTimeout = effect.Cooldown;
          switch (effect.Spell.Target)
          {
            case SpellEntry.TargetType.Tile:
              if (targetTile == null) return false;
              OrderRange = effect.CastRange;
              OrderPosition = targetTile.MapPosition + new Vector2(MapBoard.TILE_XSPACING, MapBoard.TILE_YSPACING) / 2;
              break;
            case SpellEntry.TargetType.GameEntity:
              if (targetGameObject == null) return false;
              OrderTarget = targetGameObject;
              break;
          }
          #endregion
          break;
        case GameObjectOrder.Gather:
          #region
          if (targetGameObject == null) return false;
          OrderTarget = targetGameObject;
          if (targetGameObject.GetEntityType == GameEntityType.Resource)
          {
            lastGatheredResource = (Resource)targetGameObject;
          }
          else if (targetTile != null && targetTile.Resource != null)
          {
            lastGatheredResource = targetTile.Resource;
          }
          else
          {
            CancelOrders(true);
            return false;
          }
          OrderRange = entry.GatherRange;
          OrderTimeout = entry.GatherSpeed;
          #endregion
          break;
        case GameObjectOrder.Train:
          #region
          if (targetGameObject == null) return false;
          if (targetGameObject.GetEntityType != GameEntityType.Building) return false;
          bldgEntry = (BuildingDb)((Building)targetGameObject).Entry;
          if (bldgEntry.Trains == null) return false;
          if (bldgEntry.Trains.All(p=>p.TrainFrom != this.Entry)) return false;

          OrderTarget = targetGameObject;
          OrderRange = MOVEMENT_RANGE;
          OrderTimeout = TRAIN_QUEUE_CHECK_TIMEOUT;
          #endregion
          break;
        default:
          break;
      }
      State = GameObjectState.MovingToOrder;
      this.Order = order;
      game.SendData(Network.MakeClientMessage(MessageType.GameObjUpdate, this));
      return true;
    }
Example #21
0
 public bool IssueOrder(GameObjectOrder order, GameObject targetUnit, [MarshalAs(UnmanagedType.U1)] bool triggerEvent)
 {
 }
Example #22
0
    // ORDERS

    /// <summary>
    /// Determines, whether game object can perform given order
    /// </summary>
    /// <param id="order">Order to check</param>
    /// <returns>Returns true if game object can perform given order</returns>
    public override bool CanDoOrder(GameObjectOrder order)
    {
      switch (order)
      {
        case GameObjectOrder.Idle:
          return (entry.Speed > 0);
        case GameObjectOrder.Attack:
          return (entry.AttackAmount > 0);
        case GameObjectOrder.Construct:
          return (entry.ConstructAmount > 0);
        case GameObjectOrder.Spell:
          return (entry.Shaman);
        case GameObjectOrder.Gather:
          return (entry.GatherAmount > 0 || entry.GatherCapacity > 0);
        case GameObjectOrder.Train:
          return true;
      }
      return false;
    }
Example #23
0
 public IssueOrder(DateTime time, Vector3 pos, GameObjectOrder order)
 {
     Order = order;
     Time = time;
     Pos = pos;
 }
 private void UpdateSequence(GameObjectOrder order)
 {
     if (!_sequences.ContainsKey(order))
     {
         _sequences[order] = new Sequence();
     }
     var sequence = _sequences[order];
     if (sequence.Items == null || sequence.Index >= sequence.Items.Length)
     {
         sequence.Items = CreateSequence(_menu.Item(_menu.Name + ".orders.clicks").GetValue<Slider>().Value);
     }
 }
Example #25
0
 public bool IssueOrder(GameObjectOrder order, Vector3 targetPos, [MarshalAs(UnmanagedType.U1)] bool triggerEvent)
 {
 }