Solved Branch in specific hole

Question that is answered or resolved.

dantedevil

Well-known member
I have a new level with two holes, one close to another.

The idea is this:
- In one hole if you fall, dies normally.
- In the other hole if you fall, you branch to the next level without losing any life.

I try to find a way to make this possible, buut I can't...
 
Solution
That is strange. I can record a video if you want.

Anyway, here is the optmized script. Now you can use it for more than one stage
http://www.chronocrash.com/forum/index.php?topic=3976.0

See the "case" block? Just copy and paste for more options, changing the value.
Dante, here is the code. I've tested it and it works.

Save it as checkhole.c in your scripts folder

Code:
// Jump to a specific branch based on hole type
// Thanks Bloodbane and White Dragon for the help
// Douglas Baldan / O Ilusionista - 2018.07.28
// www.brazilmugenteam.com
void main(){
	
int Type = getlocalvar("type"); // Get hole type
void self = getlocalvar("self"); // Get caller
int y = getentityproperty(self,"y"); // Get Y pos
int HP = getentityproperty(self,"health"); // Get caller health
int Vy = getentityproperty(self,"tossv"); // Get Y velocity

if (Type ==1 && Vy < 0 && y < -60 && HP > 10) {	
jumptobranch("branch", 1); 
}

}

Then call it on the header:
inholescript data/scripts/checkhole.c

Just be aware of something: this code will check for the hole Type and you need to set it (in this case, to type 1) or it won't work.
hole {xpos} {zpos} {upperleft} {lowerleft} {upperright} {lowerright} {depth} {alt} {type}

On my case, I am using like this:
hole 549 287 -180 -290 276 385 100 200 1

This could be better if we transform it into a funcion and call it, so you will have more freedom. I will do this later.
I already did it, but this will require to use a globalvar to identify the stage you are playing.

Or, even better, you can change the jumpbranch value based on the hole type:
type == 1 would be branch "port"
type == 2 would be branch "stadium"
and so on...
 
Sorry, but not work for me...

Code:
Script error: data/scripts/checkhole.c, line 19: Unknown error '' (in production 'opt_else')


^



Script error: data/scripts/checkhole.c, line 19: Unknown error '' (in production 'stmt_list2')


^



Script error: data/scripts/checkhole.c, line 19: Unknown error '' (in production 'decl_list2')


^



Script error: data/scripts/checkhole.c, line 19: Unknown error '' (in production 'decl_list2')


^



Script error: data/scripts/checkhole.c, line 19: Unknown error '' (in production 'decl_list2')


^



Script error: data/scripts/checkhole.c, line 19: Unknown error '' (in production 'decl_list2')


^



Script error: data/scripts/checkhole.c, line 19: Unknown error '' (in production 'comp_stmt3')


^


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

Failed to parse script file: 'data/scripts/checkhole.c'!
Total Ram: 4294967295 Bytes
 Free Ram: 4294967295 Bytes
 Used Ram: 41299968 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/checkhole.c'!
 
That is strange. I can record a video if you want.

Anyway, here is the optmized script. Now you can use it for more than one stage
http://www.chronocrash.com/forum/index.php?topic=3976.0

See the "case" block? Just copy and paste for more options, changing the value.
 
Solution
Not crash, but not work for me.
The player simply fall and die.

Player header:
Code:
name	CAROLINA
health	100
speed	10
type	player
grabdistance 30
gfxshadow  1
holdblock 1
bflash block
hmap 1 5
fmap 2
mp 100
mprate	2
dust		dust
risetime 100
projectilehit   player obstacle
falldie 2
makeinv 2 1


weapons       CARO1 CARO2 none CARO4 CAROLINA
load smenu

icon	data/chars/caro/icon.png

running		21 4 2 1 0

diesound  data/chars/caro/death.wav


animationscript data/scripts/script.h
script data/chars/caro/strail.c
onfallscript data/scripts/release.c
didhitscript data/scripts/fatal.c

inholescript data/scripts/checkhole.c

The script:
Code:
// Jump to a specific branch based on hole type
// Thanks Bloodbane and White Dragon for the help
// Douglas Baldan / O Ilusionista - 2018.07.28
// www.brazilmugenteam.com
void main()
{
	
int Type = getlocalvar("type"); // Get hole type
void self = getlocalvar("self"); // Get caller
int y = getentityproperty(self,"y"); // Get Y pos
int HP = getentityproperty(self,"health"); // Get caller health
int Vy = getentityproperty(self,"tossv"); // Get Y velocity

if (Vy < 0 && y < -60 && HP > 10)
	{	

	switch(Type)
	{ // check the hole Type
		case 1 : // Type 1
		jumptobranch("Stage8-5", 1); // change "branch1" for the desired branch name, between quotes
		break;
		
		case 2 : // Type 2
		jumptobranch("branch2", 1); // change "branch2" for the desired branch name, between quotes
		break;
		
		//just copy and past the block above and change its value for more options
		
		default : // in case of none of above, continue with the normal behaviour  (die)
		break;
	}

}

}

The holes:
Code:
Hole 107 281 31 -11 159 159 45 

Hole 267 281 0 0 78 123 45 0 1


Whats is wrong?
 
Well my friend, I try everything but not work.
The hero always dies.

The holes:
Code:
Hole 107 281 31 -11 159 159 45 
Hole 267 281 0 0 78 123 45 200 1

Hero's header with the line:
inholescript data/scripts/checkhole.c

The script checkhole.c:
Code:
#import "data/scripts/checkhole_actual.c"

void main()
{
    actual_main();
}


The script checkhole_actual.c:
Code:
// Jump to a specific branch based on hole type
// Thanks Bloodbane and White Dragon for the help
// Douglas Baldan / O Ilusionista - 2018.07.28
// www.brazilmugenteam.com
void actual_main()
{
int Type = getlocalvar("type"); // Get hole type
void self = getlocalvar("self"); // Get caller
int y = getentityproperty(self,"y"); // Get Y pos
int HP = getentityproperty(self,"health"); // Get caller health
int Vy = getentityproperty(self,"tossv"); // Get Y velocity

if (Vy < 0 && y < -60 && HP > 10)
	{	
	switch(Type)
		{ // check the hole Type
		case 1 : // Type 1
		jumptobranch("Stage8-5", 1); // change "branch1" for the desired branch name, between quotes
		break;
		
		case 2 : // Type 2
		jumptobranch("branch2", 1); // change "branch2" for the desired branch name, between quotes
		break;
		
		//just copy and past the block above and change its value for more options
		
		default : // in case of none of above, continue with the normal behaviour  (die)
		break;
		}
	}
}

Everything seems to be ok, but not work.


The rare is your previous antihole script works ok:
Code:
void main()
{ // Performs FOLLOW50 if character falls to hole and reduces 10 HP
// Won't perform if HP is below 10
    void self = getlocalvar("self");
    float x = getentityproperty(self,"x"); //get your current x value
    int y = getentityproperty(self,"y");
    int HP = getentityproperty(self,"health");
    int Vy = getentityproperty(self,"tossv");

    if(Vy < 0 && y < -120 && HP > 10 && x>=307 ){ //the x should be where the hole starts
    jumptobranch("Stage8-5", 1); //replace branch with name of the branch
    }
}

 
Apparently I found something about why it does not work ...

if i use the script without  memory sake, I mean only one file:


inholescript data/scripts/checkhole.c

checkhole.c
Code:
// Jump to a specific branch based on hole type
// Thanks Bloodbane and White Dragon for the help
// Douglas Baldan / O Ilusionista - 2018.07.28
// www.brazilmugenteam.com
void actual_main()
{
int Type = getlocalvar("type"); // Get hole type
void self = getlocalvar("self"); // Get caller
int y = getentityproperty(self,"y"); // Get Y pos
int HP = getentityproperty(self,"health"); // Get caller health
int Vy = getentityproperty(self,"tossv"); // Get Y velocity

if (Vy < 0 && y < -60 && HP > 10)
	{	
	switch(Type)
		{ // check the hole Type
		case 1 : // Type 1
		jumptobranch("Stage8-5", 1); // change "branch1" for the desired branch name, between quotes
		break;
		
		case 2 : // Type 2
		jumptobranch("branch2", 1); // change "branch2" for the desired branch name, between quotes
		break;
		
		//just copy and past the block above and change its value for more options
		
		default : // in case of none of above, continue with the normal behaviour  (die)
		break;
		}
	}
}

Then when the player falls in any hole (no matter type), OpenBor freeze and close.

The log only say:
There's an exception while executing script 'inholescript' data/chars/caro/caro.txt



Then... if I use 2 files for memory sake, you can see something is wrong.

If I use this checkhole.c:
Code:
#import "data/scripts/checkhole_actual.c"

void main()
{
    actual_main();
}

Then OpenBor not crash, but nothing happens when players fall in any hole, simply dies.


But... if I remove the part marked in red, the same problem again, OpenBor freeze and close.
#import "data/scripts/checkhole_actual.c"

void main()
{
    actual_main();
}
 
For sure it will close. All event scripts, excluding animationscript, needs a main() to run.
If you remove it, it will close.

I don't know what it could be. I tested it in other characters without the anithole code and it works perfectly.
Have you tried in other builds?
 
O Ilusionista said:
For sure it will close. All event scripts, excluding animationscript, needs a main() to run.
If you remove it, it will close.

I don't know what it could be. I tested it in other characters without the anithole code and it works perfectly.
Have you tried in other builds?

I use OpenBOR_v3.0_Build_4432.

What are you using?

 
Ah, It's the version I was using for quite some time, but there is an issue with holes on that version (try to throw a bomb on a hole and you will see). WD had fixed it in some builds after that. This code won't work on that version, sorry.

I suggest you to use a more recent build. Since you are using the same build I was using, I can suggest you the same build I am using right now - 6315. I haven't tested the other two builds yet, bur so far it works without any issue. And you will be able to using some cool things like victory pose, boomerang, etc. Remember of deleting your saves folder (or the files related with your mod).

Just a reminder: maybe you will need to check all your scripted slams. Because since long time ago, now the OFFENSE setting will be applied when you damage an entity with script. So if you have a 20% more offense, this 20% will be applied on the slams, causing more damage.
 
Bravo!!!

You are my hero!  ;D
Thank you for all the time you dedicated to help me and find a solution, I appreciate it a lot.

Just a reminder: maybe you will need to check all your scripted slams. Because since long time ago, now the OFFENSE setting will be applied when you damage an entity with script. So if you have a 20% more offense, this 20% will be applied on the slams, causing more damage.
About this, right now I'm going to check this, to correct the damage of each slam.


About victory pose,  I currently use a custom system, they are an item that applies damage to all the players and there the players use the pain or fall animation like a victory pose.
But I will definitely look for how to use the new system, because there is no doubt that it should be better.

About the boomerang, It would be a great addition for Batman to look even better, with the most real batrang.

Thanks for all my friend!

PD: Now I just need to solve this problem and I can focus to finish the new demo ......
http://www.chronocrash.com/forum/index.php?topic=3971.msg54831#msg54831
 
Back
Top Bottom