Profiles for specific heroes within the same script

GPC2 script programming for Titan Two. Code examples, questions, requests.

Profiles for specific heroes within the same script

Postby Derivates » Fri Apr 19, 2019 9:15 pm

Hey, so I have a few scripts for some heroes, Soldier, Ana Junkrat, etc..
They're already made and I just have to load the slot and boom that's it; the thing is that I'm looking forward to make more hero scripts and you don't have many slots (and neither I'm willing to spend 9 slots just for one game).

I'm looking forward to make F keys specific for heroes (i.e F1 Soldier, F2 Ana, and so on) I just don't know how would I switch between them within the same script..? Do I have to make Heroes "bools" and then enable/disable them?
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Re: Profiles for specific heroes within the same script

Postby alanmcgregor » Fri Apr 19, 2019 10:41 pm

We don't have any idea how script handle so we can't suggest you anything in particular.

But basically, you have to consolidate all the scripts in one. Then, if every hero has different fire rate, anti-recoil or a particular set of mods, then yes make a bool for every profile (hero) and within this profile enable the mods (or change fire rate and antirecoil values) for that hero.
User avatar
alanmcgregor
Major
Major
 
Posts: 981
Joined: Tue Mar 27, 2018 8:38 am

Re: Profiles for specific heroes within the same script

Postby Derivates » Fri Apr 19, 2019 10:53 pm

alanmcgregor wrote:We don't have any idea how script handle so we can't suggest you anything in particular.

But basically, you have to consolidate all the scripts in one. Then, if every hero has different fire rate, anti-recoil or a particular set of mods, then yes make a bool for every profile (hero) and within this profile enable the mods (or change fire rate and antirecoil values) for that hero.

I got it to work, not sure if this is the most efficient way of doing it, but this is what I imagined..

Code: Select all
//> ALL HEROES PROFILES
    if(key_status(hSoldier_KEY)) {
        //> Enables Soldier:76
            soldier_rapidfire = TRUE; CrouchSpam = TRUE;
        //> Disables McCree//Junkrat
            mccree_macro1 = FALSE; junkrat_macro1 = FALSE; junkrat_macro2 = FALSE;
}
    if(key_status(hMcCree_KEY)) {
        //> Enables McCree
            mccree_macro1 = TRUE;
        //> Disables Soldier:76//Junkrat
            soldier_rapidfire = FALSE; CrouchSpam = FALSE; junkrat_macro1 = FALSE; junkrat_macro2 = FALSE;
}
    if(key_status(hJunkrat_KEY)) {
        //> Enables Junkrat
            junkrat_macro1 = TRUE; junkrat_macro2 = TRUE;
        //> Disables Soldier:76//McCree
            soldier_rapidfire = FALSE; CrouchSpam = FALSE; mccree_macro1 = FALSE;
}


Everything is a bool and if A wants to be enabled, B C are disabled, if B wants to enabled then A C are disabled..
this is gonna get really confusing once I reach 8 heroes, because if i want to enable 1, then 7 have to be disabled...

Like mentioned, not sure if the best way, but it's suiting me well, I think I'm prepared for Mortal Kombat 11 Combos for every character this Tuesday!
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Re: Profiles for specific heroes within the same script

Postby Scachi » Fri Apr 19, 2019 11:07 pm

Its hard to tell without seeing the scripts.
It depends on their sizes, if they use the same variable names and other stuff if you can merge them and use some variable to switch between the part of it to use easily.

Another approach would be using the script_load function.
https://www.consoletuner.com/wiki/index ... cript_load
The script_load function will load your script gbc file into the current active slot, so you can still keep each hero script seperate this way.

! Warning, untested code:
Example: Add the content of slotload.gpc to each of your scripts or save it to a seperate file, like "slotload.gpc" and add an include to all your hero scripts like this:
Code: Select all
#include "slotload.gpc"

Your script files need to be compiled as bytecode "Compiler->Build Bytecode", name them as in the array (or change it there) and manually copy the files over to the sd-card to path /TITAN TWO/MEMSLOT/
You need a sd-card reader for that, there is no automated way to install the gbc files to that path at the moment.

Install your default hero/favorite hero via gtuner IV to a single slot as you normally to.
Start that script/slot and use F1..F9 to switch to the heros/scripts.

slotload.gpc:
Code: Select all
// ! UNTESTED !
// add this content to each of your hero scripts
// name your hero scripts f1.gbc, f2.gpc , f3.gpc, ...
// they need to be compiled as bytecode and manually copied to sd-card path /TITAN TWO/MEMSLOT/
// Install your favorite/start hero script via gtuner
 
#include <keyboard.gph>
 
// list of script file names
char *gbcFiles[] = {
    "f1.gbc",
    "f2.gbc",
    "f3.gbc",
    "f4.gbc",
    "f5.gbc",
    "f6.gbc",
    "f7.gbc",
    "f8.gbc",
    "f9.gbc",
    };
 
 
main {
    gpc_select();
}
 
void gpc_select() {
    static bool keyActive=TRUE;
    if (key_check()) {
        if (!keyActive) {
            keyActive=TRUE;
 
            if (key_status(KEY_F1)) gbc_load(0);
            if (key_status(KEY_F2)) gbc_load(1);
            if (key_status(KEY_F3)) gbc_load(2);
            if (key_status(KEY_F4)) gbc_load(3);
            if (key_status(KEY_F5)) gbc_load(4);
            if (key_status(KEY_F6)) gbc_load(5);
            if (key_status(KEY_F7)) gbc_load(6);
            if (key_status(KEY_F8)) gbc_load(7);
            if (key_status(KEY_F9)) gbc_load(8);
 
            if (key_status(KEY_ESCAPE)) mslot_load(mslot_get()); // back to slot script
        }
    } else {
        keyActive=FALSE;
    }   
}
 
void gbc_load(uint8 igbc) {
    if(!script_load(gbcFiles[igbc])) {
        printf("Error loading compiled script file from sd card /TITAN TWO/MEMSLOT/");
        printf(gbcFiles[igbc]);
    }
}
 
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Profiles for specific heroes within the same script

Postby Derivates » Sat Apr 20, 2019 2:41 am

Scachi wrote:Its hard to tell without seeing the scripts.
It depends on their sizes, if they use the same variable names and other stuff if you can merge them and use some variable to switch between the part of it to use easily.

Another approach would be using the script_load function.
https://www.consoletuner.com/wiki/index ... cript_load
The script_load function will load your script gbc file into the current active slot, so you can still keep each hero script seperate this way.

! Warning, untested code:
Example: Add the content of slotload.gpc to each of your scripts or save it to a seperate file, like "slotload.gpc" and add an include to all your hero scripts like this:
Code: Select all
#include "slotload.gpc"

Your script files need to be compiled as bytecode "Compiler->Build Bytecode", name them as in the array (or change it there) and manually copy the files over to the sd-card to path /TITAN TWO/MEMSLOT/
You need a sd-card reader for that, there is no automated way to install the gbc files to that path at the moment.

Install your default hero/favorite hero via gtuner IV to a single slot as you normally to.
Start that script/slot and use F1..F9 to switch to the heros/scripts.

slotload.gpc:
Code: Select all
// ! UNTESTED !
// add this content to each of your hero scripts
// name your hero scripts f1.gbc, f2.gpc , f3.gpc, ...
// they need to be compiled as bytecode and manually copied to sd-card path /TITAN TWO/MEMSLOT/
// Install your favorite/start hero script via gtuner
 
#include <keyboard.gph>
 
// list of script file names
char *gbcFiles[] = {
    "f1.gbc",
    "f2.gbc",
    "f3.gbc",
    "f4.gbc",
    "f5.gbc",
    "f6.gbc",
    "f7.gbc",
    "f8.gbc",
    "f9.gbc",
    };
 
 
main {
    gpc_select();
}
 
void gpc_select() {
    static bool keyActive=TRUE;
    if (key_check()) {
        if (!keyActive) {
            keyActive=TRUE;
 
            if (key_status(KEY_F1)) gbc_load(0);
            if (key_status(KEY_F2)) gbc_load(1);
            if (key_status(KEY_F3)) gbc_load(2);
            if (key_status(KEY_F4)) gbc_load(3);
            if (key_status(KEY_F5)) gbc_load(4);
            if (key_status(KEY_F6)) gbc_load(5);
            if (key_status(KEY_F7)) gbc_load(6);
            if (key_status(KEY_F8)) gbc_load(7);
            if (key_status(KEY_F9)) gbc_load(8);
 
            if (key_status(KEY_ESCAPE)) mslot_load(mslot_get()); // back to slot script
        }
    } else {
        keyActive=FALSE;
    }   
}
 
void gbc_load(uint8 igbc) {
    if(!script_load(gbcFiles[igbc])) {
        printf("Error loading compiled script file from sd card /TITAN TWO/MEMSLOT/");
        printf(gbcFiles[igbc]);
    }
}
 
 

Wouldn't all this require me to store every hero script in a slot? What if I do a script for 20 heroes?

I finished my work with 8 heroes already, it hurt to do it, but feels good to have it done, and it's working flawlessly..
It's a huge project I'm planning on releasing when it's better.
Code: Select all
 
cut
 
Last edited by Derivates on Sat Apr 20, 2019 7:53 am, edited 1 time in total.
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Re: Profiles for specific heroes within the same script

Postby Buffy » Sat Apr 20, 2019 5:50 am

You could put the scripts onto an SD card and use script_load.
ConsoleTuner Support Team || Discord || Custom Scripts
User avatar
Buffy
Lieutenant
Lieutenant
 
Posts: 422
Joined: Wed Jul 20, 2016 5:23 am

Re: Profiles for specific heroes within the same script

Postby Scachi » Sat Apr 20, 2019 7:03 am

Derivates wrote:
Scachi wrote:..cut..
The script_load function will load your script gbc file into the current active slot, so you can still keep each hero script seperate this way.
Install your default hero/favorite hero via gtuner IV to a single slot as you normally to.
Start that script/slot and use F1..F9 to switch to the heros/scripts.
..cut.. 

Wouldn't all this require me to store every hero script in a slot? What if I do a script for 20 heroes?

As mentioned above, this will only require one slot. It will load the selected script into the same slot, unloadng the current hero script, when the key is pressed.
The big downside is the required manual copying of the files onto the sd-card as this can't be automated via GTuner IV at the moment.
The good thing about this approach is you have all available scripts maximum size available for each single script/hero.

Stay with your solution as it works and you don't need to copy files around :smile0517:
Last edited by Scachi on Sun Apr 21, 2019 9:01 am, edited 1 time in total.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Profiles for specific heroes within the same script

Postby Derivates » Sat Apr 20, 2019 7:57 am

Scachi wrote:
Derivates wrote:
Scachi wrote:..cut..
The script_load function will load your script gbc file into the current active slot, so you can still keep each hero script seperate this way.
Install your default hero/favorite hero via gtuner IV to a single slot as you normally to.
Start that script/slot and use F1..F9 to switch to the heros/scripts.
..cut.. 

Wouldn't all this require me to store every hero script in a slot? What if I do a script for 20 heroes?

As mentioned above, this will only require one slot. It will load the selected script into the same slot, unloadng the current hero script, when the key is pressed.
The big downside is the required manual copying of the files onto the sd-card as this can be automated via GTuner IV at the moment.
The good thing about this approach is you have all available scripts maximum size available for each single script/hero.

Stay with your solution as it works and you don't need to copy files around :smile0517:

Do you have any examples of a script using this? maybe a guide?
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Re: Profiles for specific heroes within the same script

Postby Scachi » Sat Apr 20, 2019 7:32 pm

Derivates wrote:Do you have any examples of a script using this? maybe a guide?

Well, my first reply already did include allmost everything you need, but there is your example:
viewtopic.php?f=23&t=12422
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 118 guests