Hi @Steven1985Hi @Kratus , my friend !
I'd like to know why cpu partner, beyond a certain distance, does not detect food.
Thank youHi @Steven1985
I did some tests and can confirm that by default in the engine an item will be only detected by an A.I. character if the range is below half of the screen resolution.
So, using the partner menu template as an example, Billy will only detect the apple item beyond the middle of the screen. If you want to confirm, just change the resolution in the video.txt to type 6 (960x540) without changing the apple position, then you will see that Billy will detect it instantly after losing some health.
View attachment 10534
Hello @Kratus !Hey @Kratus !
I'd like to take this opportunity to ask you about another change I've been meaning to make, so maybe you can help me sort both things out.
In addition to this I wanted to know how to create an exception, so that a special partner does not appear available in the selection, if a specific player is present in the game.
My idea is to include 6 special partners.
Special partners (NPCs) have exactly the same name as the heroes, with a "_" at the end.
"TUSK_"
"RAIDEN_"
"LIU_KANG_"
"CAROLINA_"
"KITANA_"
"MIDAS_"
"JAGO_"
So for example, if you are playing with "TUSK", the special partner "TUSK_" should not appear to select.
I hope you can help me with this, and I'm sure it can be useful to other members who want to implement this great system you've created.
Thanks my friend!![]()
@dantedevil Hi friend! Sorry, I forgot to post an answer.
//IS PARTNER NAME HIGHLIGHTED??
if(getglobalvar("highlight") == 6){
void playerName = getplayerproperty(player, "name");
if(playerName == "Billy"){
if(getglobalvar("selectPartner") == "Terry_"){setglobalvar("selectPartner", "Kyo_");}else
if(getglobalvar("selectPartner") == "Kyo_"){setglobalvar("selectPartner", "Maxima_");}else
if(getglobalvar("selectPartner") == "Maxima_"){setglobalvar("selectPartner", "Terry_");}
}
if(playerName == "Terry"){
if(getglobalvar("selectPartner") == "Billy_"){setglobalvar("selectPartner", "Kyo_");}else
if(getglobalvar("selectPartner") == "Kyo_"){setglobalvar("selectPartner", "Maxima_");}else
if(getglobalvar("selectPartner") == "Maxima_"){setglobalvar("selectPartner", "Billy_");}
}
if(playerName == "Kyo"){
if(getglobalvar("selectPartner") == "Billy_"){setglobalvar("selectPartner", "Terry_");}else
if(getglobalvar("selectPartner") == "Terry_"){setglobalvar("selectPartner", "Maxima_");}else
if(getglobalvar("selectPartner") == "Maxima_"){setglobalvar("selectPartner", "Billy_");}
}
if(playerName == "Maxima"){
if(getglobalvar("selectPartner") == "Billy_"){setglobalvar("selectPartner", "Terry_");}else
if(getglobalvar("selectPartner") == "Terry_"){setglobalvar("selectPartner", "Kyo_");}else
if(getglobalvar("selectPartner") == "Kyo_"){setglobalvar("selectPartner", "Billy_");}
}
}
In my game, there are some very complex puzzle levels where it would be better if the NPC weren't present.
I wanted to know how I can add an exception so that the partner doesn't appear in those specific levels, but reappears in subsequent levels.![]()
You can try to skip some levels by adding an condition before loading the cpu partner in the level.c file.Sorry but the only thing left for me to find a solution is the following:![]()
void main()
{
void branch = openborvariant("current_branch");
//IF NOT IN THE LEVELS BELOW, LOAD PARTNER NORMALLY
if(branch != "level1" && branch != "level2" && branch != "level3" && branch != "level4")
{
loadPartner();
}
}
//IS PARTNER NAME HIGHLIGHTED??
if(getglobalvar("highlight") == 6){
void playerName = getplayerproperty(player, "name");
if(playerName == "Billy"){
if(getglobalvar("selectPartner") == "Terry_"){setglobalvar("selectPartner", "Kyo_");}else
if(getglobalvar("selectPartner") == "Kyo_"){setglobalvar("selectPartner", "Maxima_");}else
if(getglobalvar("selectPartner") == "Maxima_"){setglobalvar("selectPartner", "Terry_");}
}
if(playerName == "Terry"){
if(getglobalvar("selectPartner") == "Billy_"){setglobalvar("selectPartner", "Kyo_");}else
if(getglobalvar("selectPartner") == "Kyo_"){setglobalvar("selectPartner", "Maxima_");}else
if(getglobalvar("selectPartner") == "Maxima_"){setglobalvar("selectPartner", "Billy_");}
}
if(playerName == "Kyo"){
if(getglobalvar("selectPartner") == "Billy_"){setglobalvar("selectPartner", "Terry_");}else
if(getglobalvar("selectPartner") == "Terry_"){setglobalvar("selectPartner", "Maxima_");}else
if(getglobalvar("selectPartner") == "Maxima_"){setglobalvar("selectPartner", "Billy_");}
}
if(playerName == "Maxima"){
if(getglobalvar("selectPartner") == "Billy_"){setglobalvar("selectPartner", "Terry_");}else
if(getglobalvar("selectPartner") == "Terry_"){setglobalvar("selectPartner", "Kyo_");}else
if(getglobalvar("selectPartner") == "Kyo_"){setglobalvar("selectPartner", "Billy_");}
}
}
//IS PARTNER NAME HIGHLIGHTED??
if(getglobalvar("highlight") == 6){
void playerName = getplayerproperty(player, "name");
if(playerName == "TUSK"){
if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else
if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else
if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "BALROG_");}
}
if(playerName == "LIU_KANG"){
if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else
if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else
if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else
if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");}
}
if(playerName == "RAIDEN"){
if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else
if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else
if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else
if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");}
}
if(playerName == "CAROLINA"){
if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else
if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else
if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else
if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");}
}
if(playerName == "KITANA"){
if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else
if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else
if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else
if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");}
}
if(playerName == "MIDAS"){
if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else
if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else
if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else
if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");}
}
if(playerName == "JAGO"){
if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else
if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else
if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else
if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");}
}
if(playerName == "CHOSEN_ONE" || "BATMAN" || "DREDD" || "FULGORE" || "ORCHID" || "ROBOCOP" || "SCORPION" || "SUB-ZERO"){
if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else
if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else
if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else
if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");}
}
}
if(playerName == "CHOSEN_ONE" || "BATMAN" || "DREDD" || "FULGORE" || "ORCHID" || "ROBOCOP" || "SCORPION" || "SUB-ZERO"){
if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else
if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else
if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else
if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");}
void main()
{
void branch = openborvariant("current_branch");
//IF NOT IN THE LEVELS BELOW, LOAD PARTNER NORMALLY
if(branch != "level1" && branch != "level2" && branch != "level3" && branch != "level4")
{
loadPartner();
}
}
branch test
z 200 272 200 #
file data/levels/testB.txt
branch parking
z 220 270 220 #1-1-1
file data/levels/story/easy/parking.txt
branch basketfield
z 175 270 175 #1-2
file data/levels/story/easy/basketfield.txt
void loadAll()
{//Load all necessary variables
//SCRIPT USED TO CLEAR ALL VARIABLES AND ASSETS
if(getglobalvar("clearAll") != NULL()){clearAssets();clearlocalvar();clearglobalvar();}
//PARTNER MENU FUNCTIONS
if(getglobalvar("activeText") == NULL()){
setglobalvar("highlight", 0);
setglobalvar("selectPartner", "BALROG_");
setglobalvar("partnerAlive", 0);
setglobalvar("partnerMode", "balanced");
setglobalvar("partnerAggression", "*****");
setglobalvar("partnerGetFood", "yes");
setglobalvar("partnerFollow", "automatic");
setglobalvar("partnerRespawn", "instantly");
setglobalvar("partnerLifeBar", "full_hud");
setglobalvar("activeText", 0);
}
//LOAD ALL NECESSARY ASSETS (SPRITES, SOUNDS, ETC)
saveAssets();
}
@dantedevil Buddy, please when posting a question, try to focus in one problem at a time, if it's possible. Posting multiple questions mainly with big codes at once will make the post a bit confuse to understand.Well @Kratus , I finally implemented the 2 updates without getting errors in the log and performed several tests with the 2 scripts.
I will detail the results.
About this script:
C++://IS PARTNER NAME HIGHLIGHTED?? if(getglobalvar("highlight") == 6){ void playerName = getplayerproperty(player, "name"); if(playerName == "Billy"){ if(getglobalvar("selectPartner") == "Terry_"){setglobalvar("selectPartner", "Kyo_");}else if(getglobalvar("selectPartner") == "Kyo_"){setglobalvar("selectPartner", "Maxima_");}else if(getglobalvar("selectPartner") == "Maxima_"){setglobalvar("selectPartner", "Terry_");} } if(playerName == "Terry"){ if(getglobalvar("selectPartner") == "Billy_"){setglobalvar("selectPartner", "Kyo_");}else if(getglobalvar("selectPartner") == "Kyo_"){setglobalvar("selectPartner", "Maxima_");}else if(getglobalvar("selectPartner") == "Maxima_"){setglobalvar("selectPartner", "Billy_");} } if(playerName == "Kyo"){ if(getglobalvar("selectPartner") == "Billy_"){setglobalvar("selectPartner", "Terry_");}else if(getglobalvar("selectPartner") == "Terry_"){setglobalvar("selectPartner", "Maxima_");}else if(getglobalvar("selectPartner") == "Maxima_"){setglobalvar("selectPartner", "Billy_");} } if(playerName == "Maxima"){ if(getglobalvar("selectPartner") == "Billy_"){setglobalvar("selectPartner", "Terry_");}else if(getglobalvar("selectPartner") == "Terry_"){setglobalvar("selectPartner", "Kyo_");}else if(getglobalvar("selectPartner") == "Kyo_"){setglobalvar("selectPartner", "Billy_");} } }
I made this modification with the NPCS I have created, since I still don't have all the heroes finished in NPC version.
The problem I'm having is that when I open the menu, I can scroll through the names, but it won't let me choose any, no matter who I'm playing with.C++://IS PARTNER NAME HIGHLIGHTED?? if(getglobalvar("highlight") == 6){ void playerName = getplayerproperty(player, "name"); if(playerName == "TUSK"){ if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "BALROG_");} } if(playerName == "LIU_KANG"){ if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");} } if(playerName == "RAIDEN"){ if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");} } if(playerName == "CAROLINA"){ if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");} } if(playerName == "KITANA"){ if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");} } if(playerName == "MIDAS"){ if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");} } if(playerName == "JAGO"){ if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");} } if(playerName == "CHOSEN_ONE" || "BATMAN" || "DREDD" || "FULGORE" || "ORCHID" || "ROBOCOP" || "SCORPION" || "SUB-ZERO"){ if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");} } }
When I press the ATTACK button to choose a partner, nothing happens.
I'm sure this part is wrong, because if I choose any of these heroes, "TUSK_" doesn't appear as the first partner in the menu, even though it's first.C++:if(playerName == "CHOSEN_ONE" || "BATMAN" || "DREDD" || "FULGORE" || "ORCHID" || "ROBOCOP" || "SCORPION" || "SUB-ZERO"){ if(getglobalvar("selectPartner") == "TUSK_"){setglobalvar("selectPartner", "BALROG_");}else if(getglobalvar("selectPartner") == "BALROG_"){setglobalvar("selectPartner", "VEGA_");}else if(getglobalvar("selectPartner") == "VEGA_"){setglobalvar("selectPartner", "ZANGIEF_");}else if(getglobalvar("selectPartner") == "ZANGIEF_"){setglobalvar("selectPartner", "TUSK_");}
I tried to open this part, but the same problem persists: I can't choose a partner when I press ATTACK.
I attach my KEYALL.C
About this script:
C++:void main() { void branch = openborvariant("current_branch"); //IF NOT IN THE LEVELS BELOW, LOAD PARTNER NORMALLY if(branch != "level1" && branch != "level2" && branch != "level3" && branch != "level4") { loadPartner(); } }
To start, use this script without the modified key to avoid any errors.
I performed the following test:
I started the game with the NPC in the first stage and added a parameter to the script so that it wouldn't appear in the "parking" branch.
But when I finish the "parking" level and start the "basketfield" level, the NPC is not present and when I open the menu to bring the NPC again, when I press the ATTACK button, nothing happens, as happened to me with the other script.
And finally, I wanted to share a question that came to me when I checked all the files involved in the NPC partner system.
I noticed that in the UPDATED.C file there's a section where the name of the first partner appears.
I don't know if this is something that could be causing the problem, but I thought it was important to share it.
I tried changing the name, putting "TUSK_ " or "BALROG_", but the bug persists..
C++:void loadAll() {//Load all necessary variables //SCRIPT USED TO CLEAR ALL VARIABLES AND ASSETS if(getglobalvar("clearAll") != NULL()){clearAssets();clearlocalvar();clearglobalvar();} //PARTNER MENU FUNCTIONS if(getglobalvar("activeText") == NULL()){ setglobalvar("highlight", 0); setglobalvar("selectPartner", "BALROG_"); setglobalvar("partnerAlive", 0); setglobalvar("partnerMode", "balanced"); setglobalvar("partnerAggression", "*****"); setglobalvar("partnerGetFood", "yes"); setglobalvar("partnerFollow", "automatic"); setglobalvar("partnerRespawn", "instantly"); setglobalvar("partnerLifeBar", "full_hud"); setglobalvar("activeText", 0); } //LOAD ALL NECESSARY ASSETS (SPRITES, SOUNDS, ETC) saveAssets(); }
I hope I've been as clear as possible, my friend.
If you have any questions, don't hesitate to ask.
Thanks my friend!![]()
The first problem I see is in this line, the correct way is the one below:if(playerName == "CHOSEN_ONE" || "BATMAN" || "DREDD" || "FULGORE" || "ORCHID" || "ROBOCOP" || "SCORPION" || "SUB-ZERO"){
if(playerName == "CHOSEN_ONE" || playerName == "BATMAN" || playerName == "DREDD" || playerName == "FULGORE" || playerName == "ORCHID" || playerName == "ROBOCOP" || playerName == "SCORPION" || playerName == "SUB-ZERO"){
To perform this major update, I start everything from the beginning, step by step.But my main recommendation is, during the implementation of the partner menu in your game, if anything goes wrong I suggest back some steps, check the logic in the template I made and then only after getting the flow, try to implement in your game again.
Sorry friend, I don't have a deep knowledge about your game to fix the issues for you. I suggest to rollback everything and restart with simple tasks, like adding 1 cpu partner, spawning him in the game, making every desired event to work as planned, then add more partners, more events, etc.Upps, sorry my friend, I will take this into account and try to be as brief and clear as possible.
To perform this major update, I start everything from the beginning, step by step.
Now just made the fix you mentioned, and the main problem persists.
There are two errors, and I'll explain them separately:
1) Before performing the big update in keyall.c, I decided to start the update to skip some levels by adding an condition before loading the cpu partner in the level.c file.
I started the game and call one NPC partner in the first stage and added a parameter to the script so the partner it wouldn't appear in the next level ("parking" branch).
But then when I finish the "parking" level and go to the next level (level without branch condition) , the NPC is not present and when I open the menu to bring the NPC again, when I press the ATTACK button, nothing happens.
2) After performing the big update in keyall.c, the same bug as the end of point 1 occurs when I open the menu, I can scroll through the names, but it won't let me choose any, no matter who I'm playing with.
When I press the ATTACK button to choose a partner, nothing happens.
After having performed the entire process from the beginning several times, I can't find the problem, but it's definitely in keyall.c, because when updating this file, the bug from point 2 was generated.
Although in point 1, the same bug occurs later when skipping next levels by adding a condition in level.c, but at this point the error occurs without having performed the update of keyall.c.
I attach all my files.
I hope I have been clearer in my explanation, my friend, and I hope you understand me.
Thanks!
I have some questions here:But then when I finish the "parking" level and go to the next level (level without branch condition) , the NPC is not present and when I open the menu to bring the NPC again, when I press the ATTACK button, nothing happens.
If the required steps in the previous question are not met, the cpu partner will not spawn.2) After performing the big update in keyall.c, the same bug as the end of point 1 occurs when I open the menu, I can scroll through the names, but it won't let me choose any, no matter who I'm playing with.
When I press the ATTACK button to choose a partner, nothing happens.
drawstring(100, 100, 0, getglobalvar("partnerAlive")); //WRITE THE VARIABLE VALUE ON THE SCREEN
Yes.1). Did you name all levels with branch names in the levels.txt file?
I didn't make any changes to that part of the script, if I had to, I wouldn't know where to start.2). Did you check every required step in the //SPAWN CPU PARTNER IN-GAME part? Is the partnerIndex variable empty?
As in the previous point, I didn't make any changes to that part of the script, if I had to, I wouldn't know where to start.3). Did you check the level.c requirements (partnerAlive/partnerrespawn)?
And regarding this, it is not clear to me in which part of the updated.c I have to add that check.If the required steps in the previous question are not met, the cpu partner will not spawn.
To check all the variables, I suggest to use drawstring in the updated.c.
Example:
drawstring(100, 100, 0, getglobalvar("partnerAlive")); //WRITE THE VARIABLE VALUE ON THE SCREEN
And finally, if you think it would be more helpful to have my game so you can fully test it yourself, let me know and I'll provide you with a link right away.Sorry friend, I don't have a deep knowledge about your game to fix the issues for you.