Author Topic: Center the screen on the character script  (Read 5122 times)

Center the screen on the character script
« on: March 13, 2025, 12:35:53 am »
Hello everyone. I'm currently working on FOnline Reloaded Season 2, and I'd like to know if anyone knows a command to center the screen on the player character. I've searched high and low in the scripts and haven't found anything.

Thanks for your help!

Re: Center the screen on the character script
« Reply #1 on: Today at 01:42:31 am »
Hi everyone! I managed to center the screen on the player when the dialog box appears:

In client_interface.fos, i added this :

void CenterPlayerOnScreenDialog() // Le téléport, marche
{
    CritterCl@ player = GetChosen();
    if (valid(player)) {
        RunServerScriptUnsafe("dev_menu@unsafe_TeleportPlayer", 0, player.HexX, player.HexY, null, null);
    }
}

And changed this :

void screen_change(bool show, int screen, int p0, int p1, int p2)
{
    if(show && screen == CLIENT_SCREEN_DIALOG) //Here
    {
        CenterPlayerOnScreenDialog();
    }

    if(DialogImage.Exists() && recheckDialogImage &&
       show && screen != CLIENT_SCREEN_DIALOG &&
       !(screen == CLIENT_SCREEN_BARTER || screen == CLIENT_SCREEN_SAY))
    {
        DialogImage.Unset();
        recheckDialogImage = false;
    }

    if(!show && DialogImage.Exists() && screen == CLIENT_SCREEN_DIALOG)
    {
        recheckDialogImage = true;
    }

    if(show)
        GUI_ShowScreen(screen, p0, p1, p2);
    else
        GUI_HideScreen(screen, p0, p1, p2);
}

And in dev_menu.fos :

void unsafe_TeleportPlayer(Critter& player, int dummy, int x, int y, string@ param3, array<int>@ param4)
{
    Map@ map = player.GetMap();
    if (valid(map)) {
        uint16 hexX = player.HexX;
        uint16 hexY = player.HexY;
        player.TransitToHex(hexX + 1, hexY, 0xff); // Téléporte le joueur sur une case voisine
        player.TransitToHex(hexX, hexY, 0xff); // Téléporte le joueur sur sa case d'origine
    }
}

It's really not clean, but it works!  ;D