Post by vyckstjudas on Dec 14, 2012 18:04:04 GMT -5
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:
Quote
...
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:
Quote
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:
Quote
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:
Quote
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:
Quote
...
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:
Quote
...
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: [Select]
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
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:
Quote
...
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:
Quote
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:
Quote
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:
Quote
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:
Quote
...
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:
Quote
...
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: [Select]
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