Possible reduction of excessive/unnecessary multiplayer controls?

MysticalMist

Well-known member
My current OpenBOR project so far, only enables 2 players max to play. However, the default options offer controls for up to 4 players (ex: setup player 3/4 controls), which isn't really what the current game's designed for. Is there a way to hide/remove those options as to not confuse new players? Or is this too hard-coded within the system to change?
 
My current OpenBOR project so far, only enables 2 players max to play. However, the default options offer controls for up to 4 players (ex: setup player 3/4 controls), which isn't really what the current game's designed for. Is there a way to hide/remove those options as to not confuse new players? Or is this too hard-coded within the system to change?
@MysticalMist Buddy, is something like this you are looking for? If yes, I can zip the script files for you.
I'm doing some experiments with the main menu, but this one only works for v4 builds. Also works in-game.

 
Last edited:
@MysticalMist @Skull Kingz

Hey guys, I attached the files for you and posted the code below. Everything works automatically, the code will detect the maxplayers variant and will act accordingly.
You can also customize some texts, positions, etc. The code is prepared to work for 1 to 3 players only, since for 4 players you can use the native engine menu.

The only minor drawback is that this menu will not cycle like the native one. I mean, if you are highlighting "Back" and pressing down, it will not go to "Setup player 1..." again like the native menu does. But IMO it is a small price if compared to having 4 players appearing in a 1 or 2 player game. I'm still working on a solution for that and will post here in case I find a good one.

And don't forget to put a "beep2.wav" sample in your sounds folder in order to work properly.

This is the code related to the update.c event.

Code:
void main()
{
    controlConfigScreen();
}

void controlConfigScreen()
{
    void str;
    int align;
    int maxPlayers        = openborvariant("maxplayers");
    int hRes            = openborvariant("hresolution");
    int vRes            = openborvariant("vresolution");
    int buttonConfig    = openborvariant("screen_status") & openborconstant("IN_SCREEN_BUTTON_CONFIG_MENU");
    int yPos            = vRes/3;
    int font0            = 0;
    int font1            = 0;
    int font2            = 0;
    int font3            = 0;
    int fontTitle        = 2;
    int yAdd            = 11;
    int layer            = 1000000003;
    int backLayer        = 1000000002;

    //CONTROL OPTIONS
    if(openborvariant("in_control_options") && !buttonConfig){

        //NECESSARY STEP TO RESET THE "MENU OPTION" VARIABLE
        if(getglobalvar("mainMenuOpt") == NULL()){setglobalvar("mainMenuOpt", 0);}

        //DRAW AN ADDITIONAL BACKGROUND TO COMPLETELY COVER THE MAIN SCREEN
        mainMenuBackground(backLayer);

        //DEFINE FONTS TO HIGHLIGHTED OPTIONS
        if(getglobalvar("mainMenuOpt") == 0){font0 = 1;}else    //IS SETUP PLAYER 1 HIGHLIGHTED??
        if(getglobalvar("mainMenuOpt") == 1){font1 = 1;}else    //IS SETUP PLAYER 2 HIGHLIGHTED??
        if(getglobalvar("mainMenuOpt") == 2){font2 = 1;}else    //IS SETUP PLAYER 3 HIGHLIGHTED??
        if(getglobalvar("mainMenuOpt") == 3){font3 = 1;}        //IS BACK HIGHLIGHTED??

        yPos = yPos+yAdd;
        str = "Control Options";align = (hRes-(strwidth(str, fontTitle)))/2;
        drawstring(align, yPos, fontTitle, str, layer);

        yPos = yPos+yAdd*2;
        str = "Setup Player 1...";align = (hRes-(strwidth(str, font0)))/2;
        drawstring(align, yPos, font0, str, layer);
        
        if(maxPlayers >= 2){
            yPos = yPos+yAdd;
            str = "Setup Player 2...";align = (hRes-(strwidth(str, font1)))/2;
            drawstring(align, yPos, font1, str, layer);
        }

        if(maxPlayers >= 3){
            yPos = yPos+yAdd;
            str = "Setup Player 3...";align = (hRes-(strwidth(str, font2)))/2;
            drawstring(align, yPos, font2, str, layer);
        }

        yPos = yPos+yAdd*2;
        str = "Back";align = (hRes-(strwidth(str, font3)))/2;
        drawstring(align, yPos, font3, str, layer);
    }
}

void mainMenuBackground(float layer, int rangeMin, int rangeMax)
{//Draw an additional screen using the same "main menu" background but with adjustable properties
    void vScreen    = openborvariant("vscreen");
    float x            = 0;
    float y            = 0;
    float z            = 0;

    //CREATE A SCREEN AND SAVE IN A VARIABLE
    if(getglobalvar("allocScr_menuScreen") == NULL()){
        setglobalvar("allocScr_menuScreen", allocscreen(openborvariant("hResolution"), openborvariant("vResolution")*4));
    }

    //CLEAR ANY PREVIOUS SCREEN VALUE
    clearscreen(getglobalvar("allocScr_menuScreen"));

    if(rangeMin == NULL()){rangeMin = openborconstant("MIN_INT");}
    if(rangeMax == NULL()){rangeMax = openborconstant("MIN_INT");}

    //DRAW EVERYTHING TO THE SCREEN
    drawspriteq(getglobalvar("allocScr_menuScreen"), 0, rangeMin, rangeMax, 0, 0);
    drawscreen(getglobalvar("allocScr_menuScreen"), x, y, layer);
    drawspriteq(vScreen, 0, openborconstant("MIN_INT"), openborconstant("MAX_INT"), 0, 0);
    clearspriteq();
}

And this one is related to the inputall.c event.

Code:
void main()
{
    controlConfigInputs(getlocalvar("player"));
}

void controlConfigInputs(int player)
{
    int buttonConfig = openborvariant("screen_status") & openborconstant("IN_SCREEN_BUTTON_CONFIG_MENU");

    if(openborvariant("in_control_options") && !buttonConfig){
        int maxPlayers    = openborvariant("maxplayers");
        int mainMenuOpt = getglobalvar("mainMenuOpt");
        int max            = 3;
        int min            = 0;
        int add            = 1;
        int volume        = openborvariant("effectvol");
        int speed        = 100;
        int loop        = 0;

        //HIGHLIGHT MENU OPTIONS
        if(playerkeys(player, 1, "movedown")){
            if(mainMenuOpt >= min && mainMenuOpt < max){setglobalvar("mainMenuOpt", mainMenuOpt+add);}
            if(mainMenuOpt == max){changeplayerproperty(player, "newkeys", 0);}
            mainMenuOpt = getglobalvar("mainMenuOpt");
            if(maxPlayers == 1 && (mainMenuOpt == 1 || mainMenuOpt == 2)){setglobalvar("mainMenuOpt", max);}
            if(maxPlayers == 2 && (mainMenuOpt == 2)){setglobalvar("mainMenuOpt", max);}
        }
        if(playerkeys(player, 1, "moveup")){
            if(mainMenuOpt > min && mainMenuOpt <= max){setglobalvar("mainMenuOpt", mainMenuOpt-add);}
            if(mainMenuOpt == min){changeplayerproperty(player, "newkeys", 0);}
            mainMenuOpt = getglobalvar("mainMenuOpt");
            if(maxPlayers == 1 && (mainMenuOpt == 1 || mainMenuOpt == 2)){setglobalvar("mainMenuOpt", min);}
            if(maxPlayers == 2 && (mainMenuOpt == 2)){setglobalvar("mainMenuOpt", min+add);}
        }

        //CONFIRM THE SELECTED OPTION
        if(playerkeys(player, 1, "anybutton")){
            if(mainMenuOpt == 3){
                playsample(openborvariant("global_sample_beep_2"), 0, volume, volume, speed, loop);
                setglobalvar("mainMenuOpt", 0);
                changeplayerproperty(player, "newkeys", openborconstant("FLAG_ESC"));
            }
        }
    }
    else
    if(!openborvariant("in_control_options") && !buttonConfig){
        setglobalvar("mainMenuOpt", 0);
    }
}
 

Attachments

@MysticalMist @Skull Kingz

Hey guys, I attached the files for you and posted the code below. Everything works automatically, the code will detect the maxplayers variant and will act accordingly.
You can also customize some texts, positions, etc. The code is prepared to work for 1 to 3 players only, since for 4 players you can use the native engine menu.

Works like a charm!! Thank you very much, I've already credited you for the script! :)
 
Hey guys, I attached the files for you and posted the code below. Everything works automatically, the code will detect the maxplayers variant and will act accordingly.
You can also customize some texts, positions, etc. The code is prepared to work for 1 to 3 players only, since for 4 players you can use the native engine menu.

Wow, this is priceless!! I have to add it to my previous games now. Thanks @Kratus !
 
Back
Top Bottom