コード例 #1
0
ファイル: WorldHandler.cs プロジェクト: hakanaku2009/svn-dump
        /// Request to walk
        /// 0x00A7 9:
        public static void WalkToXY(NetState state, PacketReader reader)
        {
            if (state.IsValid(EAccountState.World) == false)
            {
                state.Disconnect();
                return;
            }

            // TODO: this is the worst system i've ever seen..
            //		 we receive the FINAL position instead of step by step packets
            //		 and have to search a path to the final position
            //		 if a path has been found, we walk it step by step
            //		 this is done using a Timer..
            Character c = state.Account.ActiveChar;

            int unkInt = reader.ReadInt32();
            // Since 2008-08-27aRagexeRE, X/Y starts at pos 6
            byte b1 = reader.ReadByte();
            byte b2 = reader.ReadByte();
            byte b3 = reader.ReadByte();
            int  x  = b1 * 4 + (b2 >> 6);
            int  y  = ((b2 & 63) << 4) + (b3 >> 4);

            ServerConsole.DebugLine("WalkToXY: from " + c.Location.X + "/" + c.Location.Y + " to " + x + "/" + y);
            WalkingHelper.WalkToXY(c, new Point2D(x, y));
        }
コード例 #2
0
        /// <summary>
        /// Caused the target object to stop moving.
        /// </summary>
        /// <param name="type">
        /// <para>0x1: Issue a fixpos packet afterwards</para>
        /// <para>0x2: Force the unit to move one cell if it hasn't yet</para>
        /// <para>0x4: Enable moving to the next cell when unit was already half-way there (may cause on-touch/place side-effects, such as a scripted map change)</para>
        /// </param>
        public void StopWalking(byte type)
        {
            if (Timer.IsValid(WalkTimer) == false)
            {
                return;
            }

            long timerTick = 0;

            if (WalkTimer != null)
            {
                //timerTick = WalkTimer.Tick;
                WalkTimer.Stop();
            }
            WalkTimer = null;
            UState.ChangeWalkTarget = false;

            long tick = Timer.Ticks;

            if (((type & 0x02) == 0x02 && Walkpath != null && Walkpath.path_pos == 0)             //Force moving at least one cell.
                //|| ((type & 0x04 ) == 0x04&& DIFF_TICK(td->tick, tick) <= td->data / 2) //Enough time has passed to cover half-cell
                )
            {
                Walkpath.path_len = Walkpath.path_pos + 1;
                WalkingHelper.WalkToXY_Tick(this);
            }

            if ((type & 0x01) == 0x01)
            {
                World.Send(new Network.Packets.WorldFixpos(this), this, ESendTarget.Area);
            }

            if (Walkpath != null)
            {
                Walkpath.path_len = 0;
                Walkpath.path_pos = 0;
            }
            TargetLocation = Location.Point;

            // TODO: wtf?
            if (Type == EDatabaseType.Pet && (type & ~0xff) == ~0xff)
            {
                CanMoveTick = (long)(Timer.Ticks + (type >> 8));
            }

            // the check in unit_set_walkdelay means dmg during running won't fall through to this place in code
            if (UState.Running == true)
            {
                //status_change_end(bl, SC_RUN, INVALID_TIMER);
            }
        }