• All, I am currently in the process of migrating domain registrations. During this time there may be some intermittent outages or slowdowns. Please contact staff if you have any questions.

Setting Branch

aL BeasTie

Well-known member
Setting Branch: By Bloodbane

Intro: For those who have played PeaceKeepers and Rushing Beat Shura, you must have seen branches. Branches lead to different paths in game and some might lead to different story and ending. Having branches in a mod would give more replayability. This tutorial will explain how to set branches in a mod.
However bear in mind that type of branch explained here is only touch n go type. It means "Touch it then you'll go somewhere". Other type is possible with script but it won't be explained here.
Procedure: To implement a branch, there are 2 texts to edit. 1st, levels.txt to set branching path. 2nd, entity text to make branch to touch, let's name it branch entity.
1: In levels.txt, a command must be declared to define where the alternate path would be. For example:


...
file data/levels/levelA2.txt
branch PathB
file data/levels/levelB11.txt
file data/levels/levelB12.txt
next
file data/levels/levelB21.txt
file data/levels/levelB22.txt
end
...

'branch PathB' defines a path to go, in this sample are levelB1 and so on. This branch is accessible by touching branch entity which points to PathB. It doesn't matter in which level that entity is touched though, it could be in levelA2.txt or even in levelB11.txt.
Another thing to note, if levelA2.txt is cleared normally (not touching branch entity that is), 'branch' will be skipped as if it's not there so don't hesitate to use this command.
'end' defines end of path. From sample above it's accessed by clearing levelB22.txt. When it's accessed, game will end as if last level in a level set/game mode is cleared. It's optional but useful to create alternate ending .
'branch' and 'end' can be declared more than once for more branches and endings. Give unique name to branches so you won't be confused where to go.

Note:
            1. 'branch' declared in a level set or game mode is accessible from any level WITHIN that set only. You can't jump from a set to other set.
          2. This step is mandatory even if you are using script based branching.

2: To make branch entity, make an entity like this:


name BranchB
type endlevel
shadow 0
branch PathB

anim idle
delay 10
offset 1 1
bbox 0 0 20 20
frame data/chars/misc/empty.gif

This entity is endlevel type which means it will end current level if touched and brings players to next level. Branch PathB alters level to go to branch PathB defined in levels.txt above.
This entity only requires IDLE animation. In this example, it's using empty.gif which is invisible but any sprite can be used for better visual. Bbox defines that it's touchable. AFAIK setting longer and higher bbox has no effect so don't bother trying.

As usual, don't forget to load this entity in models.txt, like this:

know BranchB data/chars/misc/branch/branchB.txt

After both steps are done, the last thing to do is to spawn this branch entity in a level like this:

spawn BranchB
coords -110 165
at 1950

The branch effect is ready to use!
Oh yes, whatever sprite you're using for branch entity, give good visual or clue so players know that there's branch.

Issue: There are 3 issues related to this feature:
1. If a branch entity is already spawned before ending a level by defeating boss, that level will end instantly instead of after boss has fallen to ground.
2. Accessing branch entity at last level of level set or right before 'end', ends current game instead of going to other level pointed by branch entity. To solve this issue, simply put dummy level after that level:


...
file data/levels/roomX.txt # Branch here
file data/levels/room.txt # Dummy level

set ...

If branch entity is accessed in roomX.txt, it will work normally.
3. Accessing branch entity at level right before 'next', brings Stage Complete screen before going to other level instead of just go there. To solve this issue, simply put dummy level after that level:


...
file data/levels/roomX.txt # Branch here
file data/levels/room.txt # Dummy level
next

If branch entity is accessed in roomX.txt, it won't access 'next' too. Alternate method is by putting 'scene' after that level.

Extra: After you understand how to make normal touch n go branches, you could combine it with certain level types to make advanced branching effect. Here are some examples:
1. Combining Bonus Level with branch entity produces Time Based Branching. Timer in Bonus Level will be the time limit while branch entity will become the goal to touch.
2. Combining Endless Level with branch entity produces Room Branching (ala Splatter House 3). Endless level will be the room while branch entity will become door or portal to other room.

Script: There's a script function related to branching, it's:

Code:
jumptobranch({name}, {immediately});
{name} is branch's name made in #1 step above.
{immediately} is a flag which determine when players jump to that branch.
0 = After level ends
1 = Immediately or right when this function is run

Read more: http://openbor.boards.net/index.cgi?board=tutorials&action=display&thread=9#ixzz2FGsPypsd
 
whats the easiest way to setup different first stage and different last stage(plus ending) for every character ? Id like every character to have his own story so would start from different first stage and then follow normal main path from second stage until last level with different stage from other characters, you know so every chracter would have his own story and own ending.
 
Set script in very 1st level which checks used character then change level based on that.
Same thing in last stage or any stage if you want to change course there.
 
IIRC you can even do that in select screen, if you have the right animation script.
 
yeah i think i prefere select screen option, well i have to try it depends how long it will take for that blank stage to load and take the proper branch
 
well if you change player in last stage you see the ending of character that you picked, theres no problem really, only first and last stage would be different.
 
"well i have to try it depends how long it will take for that blank stage to load and take the proper branch"

It depends on how complex that blank stage would be.
And you also need to set nofadeout in that blank stage so it ends immediately if you're using blank stage.
 
Bloodbane said:
"well i have to try it depends how long it will take for that blank stage to load and take the proper branch"

It depends on how complex that blank stage would be.
And you also need to set nofadeout in that blank stage so it ends immediately if you're using blank stage.

What should be the settings that should have this blank screen to ends immediately?
Can you give an example?

I try, but you can see the players and bars for a moment, then go to "complete" screeen.

Thanks.
 
make an empty stage with a pure black background.

then create this panel entity and spawn into the stage.

Code:
name	BLACKSCREEN
type    panel
speed   10
alpha   0
setlayer   4999999999999
noquake 1
palette none

anim	idle
	loop  	0
	offset	0 0
	frame	data/bgs/panel/black.png

setlayer  4999999999999  - this will make sure it covers the player, health bars etc.
 
Beastie, I did share my discovery of setlayer with dantedevil over at Atlas about the reaching value point that covers the entire HUD. I know everybody ignores me on the reaching point for covering HUD.

For covering everything:

Code:
setlayer 268435341

It doesn't have to be just 999999999. It's too much, but it's okay. I think there can be 1 billion and over that cover possibly. The higher the value, the more concealing setlayer goes. So, 268435341 is the lowest and most reaching value/point for covering everything, but when it comes to one entity that's higher than that as over 270000000 for example, it covers the one with lowest. It's never documented in the manual so I thought of pointing out for documentation. Test it and see it for yourself.

Here's what I said over at Atlas when the setlayer cover lifebar but not its borders:

I tested the setlayer values again and this time the value 10178 covers the lifebar but not the white borders. However, I just set the value with 10177 a moment ago that the lifebar is not covered. That means, 10177 and below won't be covered by sprite if setlayer is used. Over 10178 value covers the whole life bar. I only tested on the default lifebars but not the custom ones yet.
 
Of course you don't have that, Beastie, and I'm not going to lie to you. I know you set it to 499999999 as an example and it's a good example you set before I posted, BUT, (for the 999999999 part) I was only letting those who are not aware or do not know of the reaching number of the setlayer value, to know that 999999999 is not the only option or value to use when hiding HUD. I learned about hiding HUD using higher value of setlayer from you though. Sorry for jumping on into this, but I was only letting people (like viewers/readers in this topic) about the use of setlayer after testing. Yeah, I think the higher value for setlayer need to be mentioned for documenting the manual. I only see it says this.

This entity will be displayed as if it were at z position {int}, regardless of it's actual position.
 
What should I put where next says, so that it jumps to the next level, without specifying what it is?

anim freespecial1
            delay  2
            offset  1 1
            frame  data/chars/misc/empty.png
            @cmd  jumptobranch "next" 1
            frame  data/chars/misc/empty.png


Minutes later:

I just realized that if you put the branch name that does not exist between the "", it automatically sends you to the next level.
 
dantedevil said:
What should I put where next says, so that it jumps to the next level, without specifying what it is?

anim freespecial1
            delay  2
            offset  1 1
            frame  data/chars/misc/empty.png
            @cmd  jumptobranch "next" 1
            frame  data/chars/misc/empty.png


Minutes later:

I just realized that if you put the branch name that does not exist between the "", it automatically sends you to the next level.

That "next" is the branch name - and its a very bad idea to name a branch as next, just saying.
If you use a name that doesn't exits, the engine will send you to the next level available.
 
For my branch I'm making I've set a spot on the ground you walk into to branch you to pathb- so it's a secret branch level. But this is spawned before the boss so it doesn't function perfectly... It makes it so after you beat the boss you'll be taken to the branch no matter if you touched the branch entity or not  :-\ I saw this:

Issue: There are 3 issues related to this feature:
1. If a branch entity is already spawned before ending a level by defeating boss, that level will end instantly instead of after boss has fallen to ground.

-which sums up my problem I think, is there a way around this?
 
-which sums up my problem I think, is there a way around this?

I've been using Generic Portal and other scripted portal for years so I am spared from that bug
Here's how to make that: Generic Portal

For my branch I'm making I've set a spot on the ground you walk into to branch you to pathb- so it's a secret branch level

Use Generic portal instead then :)
The version in that tutorial can't be accessed when player is invincible. I have scripted version which can be accessed even when invincible if you need it
 
Back
Top Bottom