Creating a Method to make the character go to Coord Mouse Course

0

Good morning people, I want to create a method to make the character walk up to the coordinates of the mouse, this method will be done on the server, so I made him receive the coordinates of the mouse, but now I have to make the server recognize the coordinates and move character there.

Follow the process below.

Customer

if Mouse.trigger?(Mouse::Left)
    for i in 1..$game_temp.Player_HighIndex
        @cursor_sprite.visible = StructManager.Player(i)
        if @cursor_sprite.visible
            if StructManager.Player($game_system.MyIndex).X != (Mouse.x / 32).to_i || StructManager.Player($game_system.MyIndex).Y != (Mouse.y / 32).to_i
                @cursor_sprite.x = (Mouse.x + 16 / 32).to_i
                @cursor_sprite.y = (Mouse.y + 16 / 32).to_i
                Network.RequestCurso(i, @cursor_sprite.x, @cursor_sprite.y)
            end
        end
    end
end

Now I did this on the server, but it did not work.

    //*********************************************************************************************
    // ReceivedCurso / Revisto pela última vez em 01/08/2016, criado por LKS Florencio
    //*********************************************************************************************
    public static void ReceivedCurso(int index, string data)
    {
        //CÓDIGO
        if ((PStruct.tempplayer[index].InBank) || (PStruct.tempplayer[index].InCraft) || (PStruct.tempplayer[index].InTrade > 0) || (PStruct.tempplayer[index].InShop > 0) || (PStruct.tempplayer[index].Stunned) || (PStruct.tempplayer[index].Sleeping)) { return; }
        string[] splited = data.Replace("<99>", "").Split(';');

        if (splited.Length != 1) { return; }
        if (!IsNumeric(splited[0])) { return; }
        if ((Convert.ToInt32(splited[0]) > 10) || (Convert.ToInt32(splited[0]) < 0)) { return; }

        byte XDir = Convert.ToByte(splited[0]);
        byte YDir = Convert.ToByte(splited[1]);





        if ((PStruct.CanPlayerMove(index, XDir) == true) && (PStruct.tempplayer[index].MoveTimer < Loops.TickCount.ElapsedMilliseconds) || (PStruct.CanPlayerMove(index, YDir) == true) && (PStruct.tempplayer[index].MoveTimer < Loops.TickCount.ElapsedMilliseconds))
        {
            PStruct.PlayerCurso(index, XDir, YDir);
            PStruct.tempplayer[index].MoveTimer = Loops.TickCount.ElapsedMilliseconds + Convert.ToInt64((((8 + (4 - PStruct.tempplayer[index].movespeed) - PStruct.tempplayer[index].movespeed) * 64) - 25)); //25ms de tolerância
            WinsockAsync.Log(String.Format("Coord Selecionada"));
        }
        else
        {
        SendData.Send_PlayerXY(index);
        }



    }

Second step , as this system is to process keyboard arrows in relation to the character move, does not fuse with mouse.

        //*********************************************************************************************
    // PlayerMove / Revisto pela última vez em 01/08/2016, criado por Allyson S. Bacon
    // Move determinado jogador para determinada posição
    //*********************************************************************************************
            public static void PlayerCurso(int index, byte XDir, byte YDir)
    {
        //EXTEND
        if (Extensions.ExtensionApp.ExtendMyApp
            (MethodBase.GetCurrentMethod().Name, index, XDir, YDir) != null)
        {
            return;
        }

        //CÓDIGO
        //if (PStruct.tempplayer[index].Warping) { return; }
        //Tentamos nos mover
        int x = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].X), y = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].Y);


        switch (YDir)
        {
            case 8:
                y -= YDir;
                PStruct.character[index, PStruct.player[index].SelectedChar].Dir = Globals.DirUp;
                break;
            case 2:
                y += YDir;
                PStruct.character[index, PStruct.player[index].SelectedChar].Dir = Globals.DirDown;
                break;
            default:
                WinsockAsync.Log(String.Format("Direção nula"));
                break;
        }
        switch (XDir)
        {
            case 4:
                x -= XDir;
                PStruct.character[index, PStruct.player[index].SelectedChar].Dir = Globals.DirLeft;
                break;
            case 6:
                x += XDir;
                PStruct.character[index, PStruct.player[index].SelectedChar].Dir = Globals.DirRight;
                break;
            default:
                WinsockAsync.Log(String.Format("Direção nula"));
                break;
        }


        int map = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].Map);
        //int x = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].X);
        //int y = Convert.ToInt32(PStruct.character[index, PStruct.player[index].SelectedChar].Y);
        //Verifica os tipos de tiles
        if (MStruct.tile[map, x, y].Data1 == "2")
        {
            PStruct.tempplayer[index].Warping = true;
            PlayerWarp(index, Convert.ToInt32(MStruct.tile[map, x, y].Data2), Convert.ToByte(MStruct.tile[map, x, y].Data3), Convert.ToByte(MStruct.tile[map, x, y].Data4));
            return;
        }

        //Se nenhum tile tem ação, enviar as novas coordenadas do jogador após o movimento 
        SendData.Send_PlayerXY(index);
        SendData.Send_PlayerDir(index, 1);
        //return new PlayerCurso(x, y);
    }

My question: How can I convert to receive the mouse coordinates?

    
asked by anonymous 26.01.2018 / 11:24

0 answers