Add the partner menu of streets of rage 2 by Kratus in all OpenBOR games.

Hi Kratus

Here is the OpenBorLog:

Script error: data/scripts/keyall.c, line 40: Unknown error 'void' (in production 20)

void self = getplayerproperty(player, "entity"); //GET THE CURRENT "SELF" ENTITY
    ^


********** An Error Occurred **********
*            Shutting Down            *

Failed to parse script file: 'data/scripts/keyall.c'!
Total Ram: 2147483647 Bytes
Free Ram: 2147483647 Bytes
Used Ram: 18223104 Bytes

Release level data........... Done!
Release graphics data........ Done!
Release game data............


Release game data............ Done!
Release timer................ Done!
Release input hardware....... Done!
Release sound system......... Done!
Release FileCaching System... Done!

**************** Done *****************

Failed to parse script file: 'data/scripts/keyall.c'!
 
Steven1985
Please, can you post your entire keyall.c file? It seems that some lines in your code are missing.
Check if you are getting the current player index before getting the "self" entity.

Code:
int player	= getlocalvar("player");
 
Kratus said:
Steven1985
Please, can you post your entire keyall.c file? It seems that some lines in your code are missing.
Check if you are getting the current player index before getting the "self" entity.

Code:
int player	= getlocalvar("player");

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

void menuPartners()
{//Change Partner Menu options

	int player	= getlocalvar("player");
	int highlight	= getglobalvar("highlight");
	int hasplayed	= getplayerproperty(player, "hasplayed"); //CHECK IF THE PLAYER ENTERED THE CURRENT GAME
	
	//MAIN COMMAND TO OPEN AND CLOSE PARTNER MENU
	if(playerkeys(player, 1, "screenshot") && hasplayed == 1){ //SELECT BUTTON IS PRESSED BY A PLAYER THAT ENTERED IN THE GAME??
		if(openborvariant("in_level")){ //CHECK IF THE GAME IS IN ANY LEVEL
			if(openborvariant("pause") == 0 && openborvariant("in_options") != 1){ //CHECK IF THE GAME IS NOT PAUSED OR IN OPTIONS
				if(getglobalvar("activeText") == 0){ //CHECK IF ANY MENU IS ALREADY ON
					playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
					changeopenborvariant("nopause", 1); //LOCK PAUSE COMMAND
					changeopenborvariant("textbox", 1); //CALL TEXTBOX TO FREEZE THE GAME
					setglobalvar("highlight", 0); //SET TO THE FIRST HIGHLIGHTED OPTION
					setglobalvar("activeText", "Partner"); //SET ACTIVE TEXT ON SCREEN TO "PARTNER MENU" TO ACTIVATE OTHER SCRIPTS
				}
				else
				if(getglobalvar("activeText") == "Partner"){ //CHECK IF EXTRA MENU IS ALREADY ON
					playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
					changeopenborvariant("nopause", 0); //UNLOCK PAUSE COMMAND
					changeopenborvariant("textbox", NULL()); //CLEAR TEXTBOX TO NOT FREEZE THE GAME
					setglobalvar("highlight", 0); //RESET HIGHLIGHT VARIABLE TO DEFAULT
					setglobalvar("activeText", 0); //SET ACTIVE TEXT ON SCREEN TO "0" TO DEACTIVATE OTHER SCRIPTS
				}
			}
		}
	}

	//HIGHLIGHT OPTIONS:
	//1 - PARTNER MODE
	//2 - PARTNER SPAWN
	
	void self	= getplayerproperty(player, "entity"); //GET THE CURRENT "SELF" ENTITY
	int lives	= getplayerproperty(player, "lives"); //GET THE CURRENT NUMBER OF LIVES
	int dir		= getentityproperty(self, "direction"); //GET THE CURRENT DIRECTION
	int min		= 0; //FIRST LINE OF THE MENU
	int max		= 1; //LAST LINE OF THE MENU
	int add		= 1; //HOW MUCH LINES IS ADDED EACH TIME THE DIRECTION BUTTON IS PRESSED
	float x		= getentityproperty(self, "x"); //CURRENT PLAYER X POSITION
	float y		= getentityproperty(self, "y"); //CURRENT PLAYER Y POSITION
	float z		= getentityproperty(self, "z"); //CURRENT PLAYER Z POSITION
	
	if(getglobalvar("activeText") == "Partner" && hasplayed == 1){ //PARTNER MENU IS ON?? RUN ALL TASKS BELOW

		//HIGHLIGHT OPTIONS WHEN MOVE DOWN
		if(playerkeys(player, 1, "movedown")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			if(highlight >= min && highlight < max){setglobalvar("highlight", highlight+1);}
			if(highlight == max){setglobalvar("highlight", min);}
		}
		
		//HIGHLIGHT OPTIONS WHEN MOVE UP
		if(playerkeys(player, 1, "moveup")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			if(highlight > min && highlight <= max){setglobalvar("highlight", highlight-1);}
			if(highlight == min){setglobalvar("highlight", max);}
		}
		
		//CHANGE ALL OPTIONS INSIDE THIS MENU WHEN MOVE RIGHT
		if(playerkeys(player, 1, "moveright")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			
			//IS PARTNER MODE HIGHLIGHTED??
			if(getglobalvar("highlight") == 0){
				if(getglobalvar("partnerMode") == "balanced"){setglobalvar("partnerMode", "aggressive");}else
				if(getglobalvar("partnerMode") == "aggressive"){setglobalvar("partnerMode", "defensive");}else
				if(getglobalvar("partnerMode") == "defensive"){setglobalvar("partnerMode", "balanced");}
			}
			
			//IS PARTNER NAME HIGHLIGHTED??
			if(getglobalvar("highlight") == 1){
				if(getglobalvar("selectPartner") == "Guy_"){setglobalvar("selectPartner", "Haggar_");}else
				if(getglobalvar("selectPartner") == "Haggar_"){setglobalvar("selectPartner", "Guy_");}
			}
		}
		
		//CHANGE ALL OPTIONS INSIDE THIS MENU WHEN MOVE LEFT
		if(playerkeys(player, 1, "moveleft")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			
			//IS PARTNER MODE HIGHLIGHTED??
			if(getglobalvar("highlight") == 0){
				if(getglobalvar("partnerMode") == "balanced"){setglobalvar("partnerMode", "defensive");}else
				if(getglobalvar("partnerMode") == "defensive"){setglobalvar("partnerMode", "aggressive");}else
				if(getglobalvar("partnerMode") == "aggressive"){setglobalvar("partnerMode", "balanced");}
			}
			
			//IS PARTNER NAME HIGHLIGHTED??
			if(getglobalvar("highlight") == 1){
				if(getglobalvar("selectPartner") == "Guy_"){setglobalvar("selectPartner", "Haggar_");}else
				if(getglobalvar("selectPartner") == "Haggar_"){setglobalvar("selectPartner", "Guy_");}
			}
		}
		
		//SPAWN CPU PARTNER IN-GAME
		if(playerkeys(player, 1, "attack")){ //ATTACK BUTTON IS PRESSED??
			if(getglobalvar("highlight") == max){ //IS PARTNER SPAWN OPTION HIGHLIGHTED??
				if(lives >= 2){ //HAVE THE PLAYER ENOUGH LIVES TO DEDUCT??

					void vSpawn; //START THE SPAWN OPERATION
					playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
					changeplayerproperty(player, "lives", lives-1); //DEDUCT PLAYER LIVES
					clearspawnentry(); //CLEAR CURRENT SPAWN ENTRY
					setspawnentry("name", getglobalvar("selectPartner")); //ACQUIRE SPAWN ENTITY BY NAME
					vSpawn = spawn(); //SPAWN IN ENTITY
					changeentityproperty(vSpawn, "position", x, z, y+300); //SET SPAWN POSITION
					changeentityproperty(vSpawn, "direction", dir); //SET SPAWN DIRECTION
					setglobalvar("highlight", 0); //RESET THE HIGHLIGHT OPTION
					
					return vSpawn; //RETURN SPAWN
				}
			}
		}
	}
}
 
Steven1985

I applied the same keyall.c script you are using on other games and worked correctly. The code is already added to the Beat'em Up Alliance and works with no problems too.

Maybe this Final_Fight_X game has another script causing conflicts, or the engine used by the original author is a custom or old build. In this case I need to take a look in the entire game to see what's causing the problem.
 
Kratus said:
Steven1985

I applied the same keyall.c script you are using on other games and worked correctly. The code is already added to the Beat'em Up Alliance and works with no problems too.

Maybe this Final_Fight_X game has another script causing conflicts, or the engine used by the original author is a custom or old build. In this case I need to take a look in the entire game to see what's causing the problem.

https://drive.google.com/file/d/17C2gRTDWoeX6KEQbHSMQknyrXJbsi2NN/view?usp=sharing
 
Steven1985

or the engine used by the original author is a custom or old build
As I suspected before, this game uses a old OpenBOR build and some new script will not work. I suggest to use a newer build, 6330 or 6391.

https://www.youtube.com/watch?v=ew41k104DgE
 
Kratus I noticed two things: the first one is when I spawn an ally I consume a life; the second one is when I finish a stage the ally disappears. Is possible to have the same number of lives and the ally make him stay alive?
 
Steven1985

I noticed two things: the first one is when I spawn an ally I consume a life;
Yeah, it's a default requiriment in SOR2X but can be easily removed. I updated the KEYALL.C script below without the "lives" requiriment.

the second one is when I finish a stage the ally disappears
The engine will automatically remove all npc (and other) entities once the level ends, in this case you will need to spawn the partner again. But it's possible to save the partner's name in a variable on the "endlevel.c" event and program a script to call him again on the "level.c" event. I suggest to use globalvars to this purpose, they are more persistent.

However, once you will not lose lives anymore at every partner spawn, I think that there's no problem if you need to call again when every level starts. Plus you will have the option to change the partner too.

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

void menuPartners()
{//Change Partner Menu options

	int player	= getlocalvar("player");
	int highlight	= getglobalvar("highlight");
	int hasplayed	= getplayerproperty(player, "hasplayed"); //CHECK IF THE PLAYER ENTERED THE CURRENT GAME
	
	//MAIN COMMAND TO OPEN AND CLOSE PARTNER MENU
	if(playerkeys(player, 1, "screenshot") && hasplayed == 1){ //SELECT BUTTON IS PRESSED BY A PLAYER THAT ENTERED IN THE GAME??
		if(openborvariant("in_level")){ //CHECK IF THE GAME IS IN ANY LEVEL
			if(openborvariant("pause") == 0 && openborvariant("in_options") != 1){ //CHECK IF THE GAME IS NOT PAUSED OR IN OPTIONS
				if(getglobalvar("activeText") == 0){ //CHECK IF ANY MENU IS ALREADY ON
					playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
					changeopenborvariant("nopause", 1); //LOCK PAUSE COMMAND
					changeopenborvariant("textbox", 1); //CALL TEXTBOX TO FREEZE THE GAME
					setglobalvar("highlight", 0); //SET TO THE FIRST HIGHLIGHTED OPTION
					setglobalvar("activeText", "Partner"); //SET ACTIVE TEXT ON SCREEN TO "PARTNER MENU" TO ACTIVATE OTHER SCRIPTS
				}
				else
				if(getglobalvar("activeText") == "Partner"){ //CHECK IF EXTRA MENU IS ALREADY ON
					playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
					changeopenborvariant("nopause", 0); //UNLOCK PAUSE COMMAND
					changeopenborvariant("textbox", NULL()); //CLEAR TEXTBOX TO NOT FREEZE THE GAME
					setglobalvar("highlight", 0); //RESET HIGHLIGHT VARIABLE TO DEFAULT
					setglobalvar("activeText", 0); //SET ACTIVE TEXT ON SCREEN TO "0" TO DEACTIVATE OTHER SCRIPTS
				}
			}
		}
	}

	//HIGHLIGHT OPTIONS:
	//1 - PARTNER MODE
	//2 - PARTNER SPAWN
	
	void self	= getplayerproperty(player, "entity"); //GET THE CURRENT "SELF" ENTITY
	int dir		= getentityproperty(self, "direction"); //GET THE CURRENT DIRECTION
	int min		= 0; //FIRST LINE OF THE MENU
	int max		= 1; //LAST LINE OF THE MENU
	int add		= 1; //HOW MUCH LINES IS ADDED EACH TIME THE DIRECTION BUTTON IS PRESSED
	float x		= getentityproperty(self, "x"); //CURRENT PLAYER X POSITION
	float y		= getentityproperty(self, "y"); //CURRENT PLAYER Y POSITION
	float z		= getentityproperty(self, "z"); //CURRENT PLAYER Z POSITION
	
	if(getglobalvar("activeText") == "Partner" && hasplayed == 1){ //PARTNER MENU IS ON?? RUN ALL TASKS BELOW

		//HIGHLIGHT OPTIONS WHEN MOVE DOWN
		if(playerkeys(player, 1, "movedown")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			if(highlight >= min && highlight < max){setglobalvar("highlight", highlight+1);}
			if(highlight == max){setglobalvar("highlight", min);}
		}
		
		//HIGHLIGHT OPTIONS WHEN MOVE UP
		if(playerkeys(player, 1, "moveup")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			if(highlight > min && highlight <= max){setglobalvar("highlight", highlight-1);}
			if(highlight == min){setglobalvar("highlight", max);}
		}
		
		//CHANGE ALL OPTIONS INSIDE THIS MENU WHEN MOVE RIGHT
		if(playerkeys(player, 1, "moveright")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			
			//IS PARTNER MODE HIGHLIGHTED??
			if(getglobalvar("highlight") == 0){
				if(getglobalvar("partnerMode") == "balanced"){setglobalvar("partnerMode", "aggressive");}else
				if(getglobalvar("partnerMode") == "aggressive"){setglobalvar("partnerMode", "defensive");}else
				if(getglobalvar("partnerMode") == "defensive"){setglobalvar("partnerMode", "balanced");}
			}
			
			//IS PARTNER NAME HIGHLIGHTED??
			if(getglobalvar("highlight") == 1){
				if(getglobalvar("selectPartner") == "Guy_"){setglobalvar("selectPartner", "Haggar_");}else
				if(getglobalvar("selectPartner") == "Haggar_"){setglobalvar("selectPartner", "Guy_");}
			}
		}
		
		//CHANGE ALL OPTIONS INSIDE THIS MENU WHEN MOVE LEFT
		if(playerkeys(player, 1, "moveleft")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			
			//IS PARTNER MODE HIGHLIGHTED??
			if(getglobalvar("highlight") == 0){
				if(getglobalvar("partnerMode") == "balanced"){setglobalvar("partnerMode", "defensive");}else
				if(getglobalvar("partnerMode") == "defensive"){setglobalvar("partnerMode", "aggressive");}else
				if(getglobalvar("partnerMode") == "aggressive"){setglobalvar("partnerMode", "balanced");}
			}
			
			//IS PARTNER NAME HIGHLIGHTED??
			if(getglobalvar("highlight") == 1){
				if(getglobalvar("selectPartner") == "Guy_"){setglobalvar("selectPartner", "Haggar_");}else
				if(getglobalvar("selectPartner") == "Haggar_"){setglobalvar("selectPartner", "Guy_");}
			}
		}
		
		//SPAWN CPU PARTNER IN-GAME
		if(playerkeys(player, 1, "attack")){ //ATTACK BUTTON IS PRESSED??
			if(getglobalvar("highlight") == max){ //IS PARTNER SPAWN OPTION HIGHLIGHTED??

				void vSpawn; //START THE SPAWN OPERATION
				playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
				clearspawnentry(); //CLEAR CURRENT SPAWN ENTRY
				setspawnentry("name", getglobalvar("selectPartner")); //ACQUIRE SPAWN ENTITY BY NAME
				vSpawn = spawn(); //SPAWN IN ENTITY
				changeentityproperty(vSpawn, "position", x, z, y+300); //SET SPAWN POSITION
				changeentityproperty(vSpawn, "direction", dir); //SET SPAWN DIRECTION
				setglobalvar("highlight", 0); //RESET THE HIGHLIGHT OPTION
					
				return vSpawn; //RETURN SPAWN
			}
		}
	}
}
 
Kratus I need your help with this, I got my hands on final fight x and I'm adding just a few things, one features is your partner script, oddly enough some else also attempted it with the same game, ok so 2 things.


how do I 1. make so only 1 partner is spawned, no more than 1
and 2. no same if I'm haggar I don't want to be able to spawn another haggar, so haggars partner spawning opions are either guy or cody.

also actually what about making the menu dissaper after keypress selection, so as soon as you select a partner you exit into game
 
danno said:
Kratus I need your help with this, I got my hands on final fight x and I'm adding just a few things, one features is your partner script, oddly enough some else also attempted it with the same game, ok so 2 things.

how do I 1. make so only 1 partner is spawned, no more than 1
and 2. no same if I'm haggar I don't want to be able to spawn another haggar, so haggars partner spawning opions are either guy or cody.

also actually what about making the menu dissaper after keypress selection, so as soon as you select a partner you exit into game

danno
Hey buddy! Yeah, some months ago I made a reduced version of the SOR2X partner's script for this game.
I need to take a look at the game's file, I don't remember how this script works. Please, can you send a copy?
 
thanks Kratus

heres the keyall

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

void menuPartners()
{//Change Partner Menu options

	int player	= getlocalvar("player");
	int highlight	= getglobalvar("highlight");
	int hasplayed	= getplayerproperty(player, "hasplayed"); //CHECK IF THE PLAYER ENTERED THE CURRENT GAME
	
	
	//MAIN COMMAND TO OPEN AND CLOSE PARTNER MENU
	if(playerkeys(player, 1, "screenshot") && hasplayed == 1){ //SELECT BUTTON IS PRESSED BY A PLAYER THAT ENTERED IN THE GAME??
		if(openborvariant("in_level")){ //CHECK IF THE GAME IS IN ANY LEVEL
			if(openborvariant("pause") == 0 && openborvariant("in_options") != 1){ //CHECK IF THE GAME IS NOT PAUSED OR IN OPTIONS
				if(getglobalvar("activeText") == 0){ //CHECK IF ANY MENU IS ALREADY ON
					playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
					changeopenborvariant("nopause", 1); //LOCK PAUSE COMMAND
					changeopenborvariant("textbox", 1); //CALL TEXTBOX TO FREEZE THE GAME
					setglobalvar("highlight", 0); //SET TO THE FIRST HIGHLIGHTED OPTION
					setglobalvar("activeText", "Partner"); //SET ACTIVE TEXT ON SCREEN TO "PARTNER MENU" TO ACTIVATE OTHER SCRIPTS
				}
				else
				if(getglobalvar("activeText") == "Partner"){ //CHECK IF EXTRA MENU IS ALREADY ON
					playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
					changeopenborvariant("nopause", 0); //UNLOCK PAUSE COMMAND
					changeopenborvariant("textbox", NULL()); //CLEAR TEXTBOX TO NOT FREEZE THE GAME
					setglobalvar("highlight", 0); //RESET HIGHLIGHT VARIABLE TO DEFAULT
					setglobalvar("activeText", 0); //SET ACTIVE TEXT ON SCREEN TO "0" TO DEACTIVATE OTHER SCRIPTS
				}
			}
		}
	}

	//HIGHLIGHT OPTIONS:
	//1 - PARTNER MODE
	//2 - PARTNER SPAWN
	
	void self	= getplayerproperty(player, "entity"); //GET THE CURRENT "SELF" ENTITY
	int dir		= getentityproperty(self, "direction"); //GET THE CURRENT DIRECTION
	int min		= 0; //FIRST LINE OF THE MENU
	int max		= 1; //LAST LINE OF THE MENU
	int add		= 1; //HOW MUCH LINES IS ADDED EACH TIME THE DIRECTION BUTTON IS PRESSED
	float x		= getentityproperty(self, "x"); //CURRENT PLAYER X POSITION
	float y		= getentityproperty(self, "y"); //CURRENT PLAYER Y POSITION
	float z		= getentityproperty(self, "z"); //CURRENT PLAYER Z POSITION
	
	if(getglobalvar("activeText") == "Partner" && hasplayed == 1){ //PARTNER MENU IS ON?? RUN ALL TASKS BELOW

		//HIGHLIGHT OPTIONS WHEN MOVE DOWN
		if(playerkeys(player, 1, "movedown")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			if(highlight >= min && highlight < max){setglobalvar("highlight", highlight+1);}
			if(highlight == max){setglobalvar("highlight", min);}
		}
		
		//HIGHLIGHT OPTIONS WHEN MOVE UP
		if(playerkeys(player, 1, "moveup")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			if(highlight > min && highlight <= max){setglobalvar("highlight", highlight-1);}
			if(highlight == min){setglobalvar("highlight", max);}
		}
		
		//CHANGE ALL OPTIONS INSIDE THIS MENU WHEN MOVE RIGHT
		if(playerkeys(player, 1, "moveright")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			
			//IS PARTNER MODE HIGHLIGHTED??
			if(getglobalvar("highlight") == 0){
				if(getglobalvar("partnerMode") == "balanced"){setglobalvar("partnerMode", "aggressive");}else
				if(getglobalvar("partnerMode") == "aggressive"){setglobalvar("partnerMode", "defensive");}else
				if(getglobalvar("partnerMode") == "defensive"){setglobalvar("partnerMode", "balanced");}
			}
			
			//IS PARTNER NAME HIGHLIGHTED??
			if(getglobalvar("highlight") == 1){
				if(getglobalvar("selectPartner") == "guy_"){setglobalvar("selectPartner", "haggar_");}else
				if(getglobalvar("selectPartner") == "cody_"){setglobalvar("selectPartner", "guy_");}else
				if(getglobalvar("selectPartner") == "haggar_"){setglobalvar("selectPartner", "cody_");}
			}
		}
		
		//CHANGE ALL OPTIONS INSIDE THIS MENU WHEN MOVE LEFT
		if(playerkeys(player, 1, "moveleft")){
			playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
			
			//IS PARTNER MODE HIGHLIGHTED??
			if(getglobalvar("highlight") == 0){
				if(getglobalvar("partnerMode") == "balanced"){setglobalvar("partnerMode", "defensive");}else
				if(getglobalvar("partnerMode") == "defensive"){setglobalvar("partnerMode", "aggressive");}else
				if(getglobalvar("partnerMode") == "aggressive"){setglobalvar("partnerMode", "balanced");}
			}
			
			//IS PARTNER NAME HIGHLIGHTED??
			if(getglobalvar("highlight") == 1){
				if(getglobalvar("selectPartner") == "guy_"){setglobalvar("selectPartner", "haggar_");}else
				if(getglobalvar("selectPartner") == "cody_"){setglobalvar("selectPartner", "guy_");}else
				if(getglobalvar("selectPartner") == "haggar_"){setglobalvar("selectPartner", "cody_");}
			}
		}
		
		//SPAWN CPU PARTNER IN-GAME
		if(playerkeys(player, 1, "attack")){ //ATTACK BUTTON IS PRESSED??
			if(getglobalvar("highlight") == max){ //IS PARTNER SPAWN OPTION HIGHLIGHTED??

				void vSpawn; //START THE SPAWN OPERATION
				playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
				clearspawnentry(); //CLEAR CURRENT SPAWN ENTRY
				setspawnentry("name", getglobalvar("selectPartner")); //ACQUIRE SPAWN ENTITY BY NAME
				vSpawn = spawn(); //SPAWN IN ENTITY
				changeentityproperty(vSpawn, "position", x, z, y+300); //SET SPAWN POSITION
				changeentityproperty(vSpawn, "direction", dir); //SET SPAWN DIRECTION
				setglobalvar("highlight", 0); //RESET THE HIGHLIGHT OPTION
					
				return vSpawn; //RETURN SPAWN
			}
		}
	}
}


updated.c

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

void menuPartners()
{//Draw a CPU Partner Menu in game
	
	//DRAW MENU IN-GAME
	if(getglobalvar("activeText") == "Partner"){
		void str;			//USED TO DEFINE THE CURRENT "STRING" TEXT
		int screen	= openborvariant("hresolution"); //CURRENT SCREEN RESOLUTION
		int align;			//USED BY THE "STRWIDTH" FUNCTION TO ALIGN TEXT AUTOMATICALLY
		int xCol1	= 231;		//BASE X POSITION, FIRST COLUMN (HIGHLIGHTED OPTIONS NAME)
		int xDif	= 20;		//DIFFERENCE BETWEEN THE FIRST AND THE SECOND COLUMNS
		int xCol2	= xCol1+xDif;	//BASE X POSITION, SECOND COLUMN (HIGHLIGHTED OPTIONS VALUE)
		int fontTitle	= 2;		//FONT USED ONLY FOR THE MENU TITLE
		int yPos	= 90;		//BASE Y POSITION FOR ALL MENU CONTENT IN GAME, USE THIS TO MOVE ALL OPTIONS TOGETHER
		int font0	= 0;		//THIS FONT CHANGES FROM 0 TO 1 IF THE OPTION IS HIGHLIGHTED
		int font1	= 0;		//THIS FONT CHANGES FROM 0 TO 1 IF THE OPTION IS HIGHLIGHTED
		int yLine	= 11;		//SPACE BETWEEN TEXT LINES
		int layer	= 1000000003;	//DEFAULT TEXT LAYER
		
		//DEFINE FONTS TO HIGHLIGHTED OPTIONS
		if(getglobalvar("highlight") == 0){font0 = 1;}else	//IS PARTNER MODE HIGHLIGHTED??
		if(getglobalvar("highlight") == 1){font1 = 1;}		//IS PARTNER SPAWN HIGHLIGHTED??
		
		//DRAW MENU TITLE
		drawstring((screen-strwidth("partner_menu", fontTitle))/2, yPos-yLine*2, fontTitle, "partner_menu", layer);

		//DRAW MENU CONTENT
		str  = "fighting_mode:";align = xCol1-strwidth(str, font0);
		drawstring(align, yPos, font0, str, layer);
		drawstring(xCol2, yPos, font0, getglobalvar("partnerMode"), layer);
		
		str  = "spawn:";align = xCol1-strwidth(str, font0);
		yPos = yPos+yLine;
		drawstring(align, yPos, font1, str, layer);
		drawstring(xCol2, yPos, font1, getglobalvar("selectPartner"), layer);
	}
}


level.c

Code:
void main()
{
	menuPartners();

}

void menuPartners()
{//Run some necessary tasks for the menu when any level starts
	
	//TURN OFF THE SCREENSHOT BUTTON
	if(openborvariant("noscreenshot") != 1){changeopenborvariant("noscreenshot", 1);}

	//LOAD ALL NECESSARY VARIABLES BY THE FIRST TIME
	if(getglobalvar("activeText") == NULL()){setglobalvar("activeText", 0);}
	if(getglobalvar("highlight") != 0){setglobalvar("highlight", 0);}
	if(getglobalvar("partnerMode") == NULL()){setglobalvar("partnerMode", "balanced");}
	if(getglobalvar("selectPartner") == NULL()){setglobalvar("selectPartner", "guy_");}
}


void loadPartner()
{//Load and spawn defined CPU partner in game if he completed the last level alive
	void player1 = getplayerproperty(0, "entity");
	void player2 = getplayerproperty(1, "entity");
	void player3 = getplayerproperty(2, "entity");
	void player4 = getplayerproperty(3, "entity");
	float x;
	float y;
	float z;
	int dir;
	
	if(player1 != NULL()){
		x 	= getentityproperty(player1, "x");
		y 	= getentityproperty(player1, "y");
		z 	= getentityproperty(player1, "z");
		dir = getentityproperty(player1, "direction");
	}
	else
	if(player2 != NULL()){
		x 	= getentityproperty(player2, "x");
		y 	= getentityproperty(player2, "y");
		z 	= getentityproperty(player2, "z");
		dir = getentityproperty(player2, "direction");
	}
	else
	if(player3 != NULL()){
		x 	= getentityproperty(player3, "x");
		y 	= getentityproperty(player3, "y");
		z 	= getentityproperty(player3, "z");
		dir = getentityproperty(player3, "direction");
	}
	else
	if(player4 != NULL()){
		x 	= getentityproperty(player4, "x");
		y 	= getentityproperty(player4, "y");
		z 	= getentityproperty(player4, "z");
		dir = getentityproperty(player4, "direction");
	}
	
	if(getglobalvar("partnerFull") == 1){
		if(getglobalvar("fullEnergy") == "always" || getglobalvar("fullEnergy") == "each_new_stage"){
			setglobalvar("partnerMp", 120);
		}
		setglobalvar("partnerHealth", 400);
		setglobalvar("partnerFull", 0);
	}
	
	if(getglobalvar("partnerAlive") == 1){ //CPU PARTNER COMPLETED THE LAST LEVEL ALIVE OR IS SPAWNED FROM SELECT SCREEN??
		void pName = getglobalvar("partnerName");
		void vSpawn;
		
		loadmodel(pName, 1);
		clearspawnentry(); //CLEAR CURRENT SPAWN ENTRY
		setspawnentry("name", pName); //ACQUIRE SPAWN ENTITY BY NAME
		vSpawn = spawn(); //SPAWN IN ENTITY
		changeentityproperty(vSpawn, "position", x, z, y+300);  //SET SPAWN POSITION
		changeentityproperty(vSpawn, "direction", dir);  //SET SPAWN DIRECTION
		changeentityproperty(vSpawn, "health", getglobalvar("partnerHealth"));  //SET SPAWN HEALTH
		changeentityproperty(vSpawn, "mp", getglobalvar("partnerMp"));  //SET SPAWN MP
		setglobalvar("currentPartner", vSpawn); //SET AS CURRENT SPAWNED PARTNER
		
		return vSpawn; //RETURN SPAWN
	}
}
 
Hi @Steven1985,

I didn't understand, the scripts are not working? In which game you want to add it?
What problem you have? I took a look in your drive but there's no game on it, only script files.
 
Hi @Steven1985,

I didn't understand, the scripts are not working? In which game you want to add it?
What problem you have? I took a look in your drive but there's no game on it, only script files.
Dear Kratus, I only wanted you to check the scripts I created (fix errors because I added the options written above, that is, "get food" ect.) to insert to games in general, that's why I didn't put one. I did what you wrote in this post on May 21st, that is, I opened SORX game, looked through all the codes and took the ones I want in the game and fixed them with the basic scripts you very kindly had created. I've noticed so far that the basic scripts in one way or another have problems with some games and not being me expert but a beginner that he is learning to use and create a game with OpenBOR, I should have contacted you all the time but I didn't because I didn't want to bother you. Some time ago I wanted to play Final Fight and Cadillacs and adding well your basic scripts to the game, the CPU partner just walked, he didn't attack enemies at all; recently I did the same thing with Street Fighter '89 but in this case when I started the game it stopped and in OpenBORLog.txt it showed suicide error.
I wish that in all the games I want to play I can easily (that is, without errors) put the partner menu like the one in your YouTube video
, in which the partner is automatically spawned if he ended the previous level alive, to change the HUD of partners in progress and to choose the partner in game (even more than one like the basic scripts). :)
 
Hey @Kratus can you help me with this?


I have the idea to implement your great "Partner menu" system, but only to make it work at some specific levels,
If I'm not mistaken, what I should do is modify the "keyall.c" right?

Could you show me how?

KEYALL.C
Code:
void main()
{
    menuPartners();
}

void menuPartners()
{//Change Partner Menu options

    int player    = getlocalvar("player");
    int highlight    = getglobalvar("highlight");
    int hasplayed    = getplayerproperty(player, "hasplayed"); //CHECK IF THE PLAYER ENTERED THE CURRENT GAME
    
    //MAIN COMMAND TO OPEN AND CLOSE PARTNER MENU
    if(playerkeys(player, 1, "screenshot") && hasplayed == 1){ //SELECT BUTTON IS PRESSED BY A PLAYER THAT ENTERED IN THE GAME??
        if(openborvariant("in_level")){ //CHECK IF THE GAME IS IN ANY LEVEL
            if(openborvariant("pause") == 0 && openborvariant("in_options") != 1){ //CHECK IF THE GAME IS NOT PAUSED OR IN OPTIONS
                if(getglobalvar("activeText") == 0){ //CHECK IF ANY MENU IS ALREADY ON
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
                    changeopenborvariant("nopause", 1); //LOCK PAUSE COMMAND
                    changeopenborvariant("textbox", 1); //CALL TEXTBOX TO FREEZE THE GAME
                    setglobalvar("highlight", 0); //SET TO THE FIRST HIGHLIGHTED OPTION
                    setglobalvar("activeText", "Partner"); //SET ACTIVE TEXT ON SCREEN TO "PARTNER MENU" TO ACTIVATE OTHER SCRIPTS
                }
                else
                if(getglobalvar("activeText") == "Partner"){ //CHECK IF EXTRA MENU IS ALREADY ON
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
                    changeopenborvariant("nopause", 0); //UNLOCK PAUSE COMMAND
                    changeopenborvariant("textbox", NULL()); //CLEAR TEXTBOX TO NOT FREEZE THE GAME
                    setglobalvar("highlight", 0); //RESET HIGHLIGHT VARIABLE TO DEFAULT
                    setglobalvar("activeText", 0); //SET ACTIVE TEXT ON SCREEN TO "0" TO DEACTIVATE OTHER SCRIPTS
                }
            }
        }
    }

    //HIGHLIGHT OPTIONS:
    //1 - PARTNER MODE
    //2 - PARTNER SPAWN
    
    void self    = getplayerproperty(player, "entity"); //GET THE CURRENT "SELF" ENTITY
    int lives    = getplayerproperty(player, "lives"); //GET THE CURRENT NUMBER OF LIVES
    int dir        = getentityproperty(self, "direction"); //GET THE CURRENT DIRECTION
    int min        = 0; //FIRST LINE OF THE MENU
    int max        = 1; //LAST LINE OF THE MENU
    int add        = 1; //HOW MUCH LINES IS ADDED EACH TIME THE DIRECTION BUTTON IS PRESSED
    float x        = getentityproperty(self, "x"); //CURRENT PLAYER X POSITION
    float y        = getentityproperty(self, "y"); //CURRENT PLAYER Y POSITION
    float z        = getentityproperty(self, "z"); //CURRENT PLAYER Z POSITION
    
    if(getglobalvar("activeText") == "Partner" && hasplayed == 1){ //PARTNER MENU IS ON?? RUN ALL TASKS BELOW

        //HIGHLIGHT OPTIONS WHEN MOVE DOWN
        if(playerkeys(player, 1, "movedown")){
            playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
            if(highlight >= min && highlight < max){setglobalvar("highlight", highlight+1);}
            if(highlight == max){setglobalvar("highlight", min);}
        }
        
        //HIGHLIGHT OPTIONS WHEN MOVE UP
        if(playerkeys(player, 1, "moveup")){
            playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
            if(highlight > min && highlight <= max){setglobalvar("highlight", highlight-1);}
            if(highlight == min){setglobalvar("highlight", max);}
        }
        
        //CHANGE ALL OPTIONS INSIDE THIS MENU WHEN MOVE RIGHT
        if(playerkeys(player, 1, "moveright")){
            playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
            
            //IS PARTNER MODE HIGHLIGHTED??
            if(getglobalvar("highlight") == 0){
                if(getglobalvar("partnerMode") == "balanced"){setglobalvar("partnerMode", "aggressive");}else
                if(getglobalvar("partnerMode") == "aggressive"){setglobalvar("partnerMode", "defensive");}else
                if(getglobalvar("partnerMode") == "defensive"){setglobalvar("partnerMode", "balanced");}
            }
            
            //IS PARTNER NAME HIGHLIGHTED??
            if(getglobalvar("highlight") == 1){
                if(getglobalvar("selectPartner") == "Galsia_"){setglobalvar("selectPartner", "Donovan_");}else
                if(getglobalvar("selectPartner") == "Donovan_"){setglobalvar("selectPartner", "Galsia_");}
            }
        }
        
        //CHANGE ALL OPTIONS INSIDE THIS MENU WHEN MOVE LEFT
        if(playerkeys(player, 1, "moveleft")){
            playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
            
            //IS PARTNER MODE HIGHLIGHTED??
            if(getglobalvar("highlight") == 0){
                if(getglobalvar("partnerMode") == "balanced"){setglobalvar("partnerMode", "defensive");}else
                if(getglobalvar("partnerMode") == "defensive"){setglobalvar("partnerMode", "aggressive");}else
                if(getglobalvar("partnerMode") == "aggressive"){setglobalvar("partnerMode", "balanced");}
            }
            
            //IS PARTNER NAME HIGHLIGHTED??
            if(getglobalvar("highlight") == 1){
                if(getglobalvar("selectPartner") == "Galsia_"){setglobalvar("selectPartner", "Donovan_");}else
                if(getglobalvar("selectPartner") == "Donovan_"){setglobalvar("selectPartner", "Galsia_");}
            }
        }
        
        //SPAWN CPU PARTNER IN-GAME
        if(playerkeys(player, 1, "attack")){ //ATTACK BUTTON IS PRESSED??
            if(getglobalvar("highlight") == max){ //IS PARTNER SPAWN OPTION HIGHLIGHTED??
                if(lives >= 2){ //HAVE THE PLAYER ENOUGH LIVES TO DEDUCT??

                    void vSpawn; //START THE SPAWN OPERATION
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
                    changeplayerproperty(player, "lives", lives-1); //DEDUCT PLAYER LIVES
                    clearspawnentry(); //CLEAR CURRENT SPAWN ENTRY
                    setspawnentry("name", getglobalvar("selectPartner")); //ACQUIRE SPAWN ENTITY BY NAME
                    vSpawn = spawn(); //SPAWN IN ENTITY
                    changeentityproperty(vSpawn, "position", x, z, y+300); //SET SPAWN POSITION
                    changeentityproperty(vSpawn, "direction", dir); //SET SPAWN DIRECTION
                    setglobalvar("highlight", 0); //RESET THE HIGHLIGHT OPTION
                    
                    return vSpawn; //RETURN SPAWN
                }
            }
        }
    }
}
 
@Steven1985

I thought that you need the script to apply in a specific project, but if I'm not wrong you want a "portable" version of the latest partner menu to apply into every game you want to play, right?

It can be a bit complicated because every game was developed in different ways, some can be easier to apply and others can be hard, causing bugs.
The scripts I posted before were a basic example that is already portable for any game. All you need to do is to repeat the process adding more options to it.

The full version of the latest partner menu used on SORX contains a lot of other codes that affect many aspects of the game, you can find some conflicts depending on the game you try to apply because this menu was designed specifically for SORX.

However, I can create a portable version of the latest partner menu further, but I need to finish some things on the game first. Currently I'm not having too much time due to my job, but I will do it as soon as I can.


@dantedevil

Same as I said to Steven, I will develop a portable version of the latest partner menu soon.
But if you want to simply change the level where the menu works, try replacing the openborvariant("in_level") by a branch inside the keyall.c file, like this:

C:
if(openborvariant("current_branch") == "desired_branch")
 
Back
Top Bottom