Пример #1
0
        public void OnActorItemDrop(CM_ACTOR_ITEM_DROP p)
        {
            if (chara.HoldingItem != null)
            {
                ActorItem item = chara.HoldingItem;
                Tasks.Actor.ItemDeleteTask deleteTask = new Tasks.Actor.ItemDeleteTask(item);
                deleteTask.Activate();
                SendHoldItemCancel(chara.HoldingItem.ObjectID, false);

                MoveArgument arg = new MoveArgument()
                {
                    X           = p.X,
                    Y           = p.Y,
                    Z           = p.Z,
                    BNSMoveType = SagaBNS.GameServer.Map.MoveType.Run
                };
                map.MoveActor(item, arg);

                Tasks.Player.ActorItemPickDropTask task = new Tasks.Player.ActorItemPickDropTask(chara, item, Tasks.Player.ActorItemPickDropTask.ActionTypes.Drop);
                chara.Tasks["ActorItemPickDropTask"] = task;
                task.Activate();

                UpdateEvent evt = new UpdateEvent()
                {
                    UpdateType = UpdateTypes.ItemShow,
                    Actor      = chara,
                    Target     = item,
                    X          = p.X,
                    Y          = p.Y,
                    Z          = p.Z,
                    UserData   = 200
                };
                map.SendEventToAllActorsWhoCanSeeActor(MapEvents.EVENT_BROADCAST, evt, chara, true);
            }
        }
Пример #2
0
        public void OnActorTurn(CM_ACTOR_TURN p)
        {
            UpdateEvent evt = new UpdateEvent()
            {
                Actor      = chara,
                Target     = chara,
                UpdateType = UpdateTypes.Actor
            };

            evt.AddActorPara(PacketParameter.Dir, p.Dir);
            map.SendEventToAllActorsWhoCanSeeActor(MapEvents.EVENT_BROADCAST, evt, chara, true);

            MoveArgument arg = new MoveArgument()
            {
                X           = chara.X,
                Y           = chara.Y,
                Z           = chara.Z,
                Dir         = p.Dir,
                BNSMoveType = SagaBNS.GameServer.Map.MoveType.Run,
                Speed       = 0
            };

            map.MoveActor(chara, arg, true);

            if (chara.Party != null)
            {
                Party.PartyManager.Instance.PartyMemberDirUpdate(chara.Party, chara);
            }
        }
        /// <summary>
        /// Updates parent project relationships of the project asynchronous.
        /// </summary>
        /// <param name="moveArgument">The move entry.</param>
        /// <returns>
        /// Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="moveArgument" /> is <see langword="null" /></exception>
        /// <exception cref="HttpRequestException">API exception.</exception>
        /// <exception cref="AggregateException">Command execution exception.</exception>
        public Task MoveAsync(MoveArgument moveArgument)
        {
            if (moveArgument == null)
            {
                throw new ArgumentNullException(nameof(moveArgument));
            }

            return(ExecuteCommandAsync(new Command(CommandType.MoveProject, moveArgument)));
        }
Пример #4
0
 public override void DoUpdate()
 {
     if (!updated)
     {
         MoveArgument arg = new MoveArgument()
         {
             X           = x,
             Y           = y,
             Z           = z,
             Dir         = dir,
             Speed       = speed,
             DashID      = dashID,
             DashUnknown = dashUnknown,
             BNSMoveType = moveType
         };
         NPCMap.MoveActor(ScriptHandler.NPC, arg, false);
         updated = true;
     }
 }
Пример #5
0
 public void Update()
 {
     if (currentPath == null)
     {
         ReCalculatePath();
     }
     if (self.DistanceToPoint(x, y, z) > 30)
     {
         if (currentPath.Count > curPathIdx)
         {
             PathNode     node = currentPath[curPathIdx++];
             MoveArgument arg  = new MoveArgument()
             {
                 X = node.X,
                 Y = node.Y,
                 Z = map.HeightMapBuilder.GetZ((short)node.X, (short)node.Y, (short)node.Z)
             };
             if (arg.Z == 0)
             {
                 status = CommandStatus.Finished;
                 return;
             }
             arg.Dir         = self.DirectionFromTarget(node.X, node.Y);
             arg.Speed       = (ushort)((500 * ((float)500 / self.Speed)) * 2);
             arg.DashID      = 0;
             arg.DashUnknown = 0;
             arg.BNSMoveType = MoveType.Walk;
             map.MoveActor(self, arg);
         }
         else
         {
             status = CommandStatus.Finished;
         }
     }
     else
     {
         status = CommandStatus.Finished;
     }
 }
Пример #6
0
        public unsafe override void OnActorStartsMoving(Actor mActor, MoveArg arg)
        {
            if (mActor.ActorType == ActorType.ITEM || client.BroadcastService == null)
            {
                return;
            }

            if (mActor.ActorType != ActorType.NPC || ((MoveArgument)arg).BNSMoveType != Map.MoveType.Dash)
            {
                MoveArgument move = arg as MoveArgument;
                switch (move.BNSMoveType)
                {
                case Map.MoveType.StepForward:
                {
                    UpdateEvent evt = new UpdateEvent()
                    {
                        UpdateType        = UpdateTypes.Actor,
                        AdditionSession   = 0x7001,
                        Actor             = mActor,
                        Target            = mActor,
                        SkillSession      = move.SkillSession,
                        ExtraActivateMode = UpdateEvent.ExtraUpdateModes.Activate
                    };
                    evt.AddActorPara(Common.Packets.GameServer.PacketParameter.X, move.X);
                    evt.AddActorPara(Common.Packets.GameServer.PacketParameter.Y, move.Y);
                    evt.AddActorPara(Common.Packets.GameServer.PacketParameter.Z, move.Z);
                    evt.AddActorPara(Common.Packets.GameServer.PacketParameter.Dir, move.Dir);
                    byte[] buf = new byte[11];
                    fixed(byte *p = buf)
                    {
                        p[0] = 5;
                        short *ptr = (short *)&p[1];

                        ptr[0] = (short)move.X;
                        ptr[1] = (short)move.Y;
                        ptr[2] = (short)move.Z;
                        ptr[3] = (short)move.Dir;
                        ptr[4] = 1;
                    }

                    evt.UserData = buf;
                    client.BroadcastService.EnqueueUpdateEvent(evt);
                    evt = new UpdateEvent()
                    {
                        Actor           = mActor,
                        AdditionSession = 0x7001,
                        UpdateType      = UpdateTypes.ActorExtension
                    };
                    //client.BroadcastService.EnqueueUpdateEvent(evt);
                }
                break;

                case Map.MoveType.PushBack:
                {
                    UpdateEvent evt = new UpdateEvent()
                    {
                        UpdateType        = UpdateTypes.Actor,
                        AdditionSession   = 0x1001,
                        Actor             = ((MoveArgument)arg).PushBackSource,
                        Target            = mActor,
                        SkillSession      = move.SkillSession,
                        ExtraActivateMode = UpdateEvent.ExtraUpdateModes.Activate
                    };
                    //evt.AddActorPara(Common.Packets.GameServer.PacketParameter.Unk7A, 0x2000);
                    //evt.AddActorPara(Common.Packets.GameServer.PacketParameter.UnkD5, 1);
                    evt.AddActorPara(Common.Packets.GameServer.PacketParameter.X, move.X);
                    evt.AddActorPara(Common.Packets.GameServer.PacketParameter.Y, move.Y);
                    evt.AddActorPara(Common.Packets.GameServer.PacketParameter.Dir, move.Dir);
                    byte[] buf = new byte[20];
                    fixed(byte *p = buf)
                    {
                        short *ptr = (short *)p;

                        ptr[0] = 6;
                        ptr[1] = (short)move.X;
                        ptr[2] = (short)move.Y;
                        ptr[3] = (short)move.Z;
                        ptr[4] = (short)move.Dir;
                        ptr[5] = 1;
                    }

                    evt.UserData = buf;
                    client.BroadcastService.EnqueueUpdateEvent(evt);
                }
                break;

                default:
                {
                    UpdateEvent evt = new UpdateEvent()
                    {
                        UpdateType   = UpdateTypes.Movement,
                        Actor        = mActor,
                        MoveArgument = (MoveArgument)arg
                    };
                    client.BroadcastService.EnqueueUpdateEvent(evt);
                }
                break;
                }
            }
            else
            {
                UpdateEvent evt = new UpdateEvent()
                {
                    UpdateType   = UpdateTypes.NPCDash,
                    Actor        = mActor,
                    MoveArgument = new MoveArgument()
                };
                client.BroadcastService.EnqueueUpdateEvent(evt);

                evt = new UpdateEvent()
                {
                    UpdateType   = UpdateTypes.NPCDash,
                    Actor        = mActor,
                    MoveArgument = (MoveArgument)arg
                };
                client.BroadcastService.EnqueueUpdateEvent(evt);

                /*evt = new UpdateEvent();
                 * evt.UpdateType = UpdateTypes.Unknown423;
                 * evt.Actor = mActor;
                 * evt.MoveArgument = (MoveArgument)arg;
                 *
                 * client.BroadcastService.EnqueueUpdateEvent(evt);*/

                /*evt = new UpdateEvent();
                 * evt.UpdateType = UpdateTypes.Unknown50E;
                 * evt.Actor = mActor;
                 * evt.MoveArgument = (MoveArgument)arg;
                 *
                 * client.BroadcastService.EnqueueUpdateEvent(evt);*/
            }
        }
Пример #7
0
        public void OnActorMovement(CM_ACTOR_MOVEMENT p)
        {
            if (chara == null || chara.Status.Down)
            {
                return;
            }
            //Logger.Log.Info(p.ToString());
            MoveArgument arg = new MoveArgument()
            {
                BNSMoveType = p.MoveType
            };

            if (p.MoveType == SagaBNS.GameServer.Map.MoveType.Jump)
            {
                if (p.Unknown82 > 0)
                {
                    if (p.XDiff == 0 && p.YDiff == 0)
                    {
                        arg.BNSMoveType = SagaBNS.GameServer.Map.MoveType.Run;
                    }
                    else
                    {
                        arg.BNSMoveType = SagaBNS.GameServer.Map.MoveType.Falling;
                    }
                }
            }
            if (p.MoveType == SagaBNS.GameServer.Map.MoveType.DashJump)
            {
                if (p.Unknown82 > 0)
                {
                    arg.BNSMoveType = SagaBNS.GameServer.Map.MoveType.Falling;
                }
            }
            arg.X = p.X2;
            arg.Y = p.Y2;
            arg.Z = p.Z2;
            int xDiff = p.XDiff;
            int yDiff = p.YDiff;
            int zDiff = p.ZDiff;

            arg.PosDiffs.Enqueue(new sbyte[] { p.XDiff, p.YDiff, p.ZDiff });
            arg.Dir   = p.Dir;
            arg.Speed = p.Speed;
            int distance = chara.DistanceToPoint(p.X2, p.Y2, p.Z2);

            //Logger.Log.Info(string.Format("Distance:{0} Diff: {1},{2},{3}", distance, p.XDiff, p.YDiff, p.ZDiff));
            if (account.GMLevel == 0 && ((distance > 40 && p.MoveType == SagaBNS.GameServer.Map.MoveType.Run) || (distance > 65 && p.MoveType == SagaBNS.GameServer.Map.MoveType.Dash)))
            {
                if (account.GMLevel > 0)
                {
                    Logger.Log.Debug("Skip movement");
                }

                arg.X           = chara.X;
                arg.Y           = chara.Y;
                arg.Z           = chara.Z;
                arg.BNSMoveType = SagaBNS.GameServer.Map.MoveType.StepForward;
            }

            map.MoveActor(chara, arg, true);

            if (chara.Tasks.TryGetValue("SwordBlocking", out Task task))
            {
                Buff buf = (Buff)task;
                if ((buf.TotalLifeTime - buf.RestLifeTime) > 500)
                {
                    task.Deactivate();
                }
            }
            if (chara.Tasks.TryGetValue("FoodRecovery", out task))
            {
                task.Deactivate();
            }
            if (chara.Tasks.TryGetValue("Teleport", out task))
            {
                task.Deactivate();
            }
            if (chara.Party != null)
            {
                Party.PartyManager.Instance.PartyMemberPositionUpdate(chara.Party, chara);
            }
        }