Trying to develop XOR for RnD

All about creating levels and level sets, custom elements and custom artwork.

Moderators: Flumminator, Zomis

Post Reply
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Trying to develop XOR for RnD

Post by r0lZ »

Hi! This is my first post in this forum.

I would like to express my gratitude to the authors of this wonderful piece of software! I'm a BD fan since the first CBM64 version, and I'm very glad to see that this good game concept is still alive, and well! Thanks to everybody involved in this project, and to the designers of levels and artwork!

Now onto my question. I've learned how to use the editor and particularly the CEs and that gave me the idea to try to clone the old good Amiga game XOR (aka "Prospector in the Mazes of XOR".) I have almost finished it, but I'm stuck with a particular problem. In XOR, there are, among other things, falling rocks (almost like in BD) but there are also Zeppelins that are "falling" horizontally, from right to left. They have precedence over the rocks. Let's explain the problem with an example.




(Where is the Zeppelin)

When the player moves up to take the diamond and then back, in XOR, the zeppelin moves first and is immediately stopped by the wall. The rock cannot fall, and the player can escape. But in R'n'D, the rock moves first, and kills the player.

I've read here that this behavior can probably be changed with "Set engine scan mode = reverse". But I don't know where I have to configure this setting. I guess it's in a config file, but which one? Where should I put it, and what is the correct syntax of the file? I've searched the documentation and this forum, but I can't find the answers. Is it a doc file I've missed?


I have also a similar problem with the teleports. Normally, the player should appear at the right side of the teleport, unless that cell is already occupied by something else. In that case, it should appear on top of the teleport, and if that doesn't work neither, to the left and finally beneath it. Can I control that precisely? How?

The already mentioned thread gives some good tricks, but is it another, more flexible method?

Thanks for any pointer. And sorry for my approximative english!
Last edited by r0lZ on Mon Oct 29, 2007 6:56 pm, edited 4 times in total.
Daniel H.
Posts: 535
Joined: Sun Apr 02, 2006 7:13 pm
Location: USA

Re: Reverse engine scan mode: how?

Post by Daniel H. »

r0lZ wrote:I've read here that this behavior can probably be changed with "Set engine scan mode = reverse". But I don't know where I have to configure this setting. I guess it's in a config file, but which one? Where should I put it, and what is the correct syntax of the file? I've searched the documentation and this forum, but I can't find the answers. Is it a doc file I've missed?
This is not done in a configuration file. You have to use a CE action. To do this, place a custom element on to the playing field. Press the question mark ("?") button at the right side of the screen to configure the custom element. Under the "change" tab, you can set the CE action at the bottom to "SET ENGINE SCAN MODE" "=" "REVERSE" and check the check box. If you want this to happen instantly when the level is started, then also check the check box next to "Delay".

r0lZ wrote:I have also a similar problem with the teleports. Normally, the player should appear at the right side of the teleport, unless that cell is already occupied by something else. In that case, it should appear on top of the teleport, and if that doesn't work neither, to the left and finally beneath it. Can I control that precisely? How?

The already mentioned thread gives some good tricks, but is it another, more flexible method?
It's not true that there is any "normal" place for the player to end up in after teleportation. To teleport the player above a custom element, you have the element's extended change target look something like this:


Or, to teleport below:



Hope this helps. If you have trouble with any of this or don't understand it, let us know! :)
The H. World levelset can be downloaded from http://www.bd-fans.com/RnD.html -- search The H. World on that page.
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Post by r0lZ »

Thanks!

Indeed, I've found the action in the CE and managed to have it enabled immediately when the level begins. That solved the first problem.

But I still have the problem with the teleports. Sorry if I was not clear enough. What I call "normal" is what happens in the game XOR, and I have to duplicate that exactly. Your first example cannot work if the tile above the teleport is not empty. So, in this case, I have to try to place the player on the left. If I use only one position for the player, as you suggest, I cannot be sure in advance that there will never be something that blocks the position. So, I have to find a way to try each position, until a place is free, in the "correct" order. (Again "correct" refers to XOR.) The order I need is:




Unfortunately, R'n'D uses another order:




That cannot work for me. I have also tried to modify the scan mode, but nothing changes here.

If I set 4 players around the CE, the player appears briefly in positions 1, 2 and 3 (unless there is something else at that position of course), and he is finally materialized at position 4. The worst one for me!

To explain clearly, here is a concrete example. In XOR, when the player is teleported, he appears at the right side of the wall:



But in R'n'D, using the "4 players" technique explained in the other thread, he appears at the left side, and the level is unsolvable.

I have then tried to do a teleport with the player to the right, and an action to change it to another CE with the player on top when the right side of the teleport is touched by something, and similarly to replace it by another CE if the top position is also occupied, etc..., but that's incredibly complex to do, especially as I have to modify also the other teleport's target. And I need a bi-directional teleport! As you can imagine, it's not easy! So, I'm still hoping that someone has a trick to suggest to solve this problem.

Note that I understand that I can modify each teleport manually to remove the position that the player cannot occupy (the left position in the example above) but I try to do an universal teleport, that could be used freely in custom made levels. Ideally, it should act exactly like in XOR.
Last edited by r0lZ on Sat Oct 27, 2007 3:11 pm, edited 1 time in total.
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

Hello and Welcome to the forum, r0lZ!

I must say that this was a nice challenge. I have reached success now. There's a maximum delay of 4 frames of the teleportation, but I hope that is acceptable. I tried to solve it without those delays but I couldn't.

See level 14 in this, just updated, level pack:
http://www.zomis.net/rnd/download.php?id=327
To teleport, press the copyright character in the middle.
Picking up the custom element gives you sand you can drop around the teleporter, to test all the combinations.
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Post by r0lZ »

Zomis wrote:I have reached success now.
:) Thanks very much, Zomis!

I will try your solution as soon as possible, but I cannot do that now. You know, there are some obligations in the life, and I can't play R'n'D all the time! :(

BTW, as you like challenges, I have still a couple things I try to improve. For example, in XOR, everything is normally static, except when the user does something that frees a rock, a zeppelin or a bomb. At this point, the user cannot move any more until all moving objects are either stopped or exploded. Currently, I can't duplicate that behavior in R'n'D. The trick I use is to set the speed of the moving objects to "very fast" so that the user has less chances to move, but in some circumstances (for example when a bomb has a long way to do before exploding and freeing another bomb that falls on the player) that's still not sufficient. And due to the fast speed, it is also difficult to see what happens exactly in complex situations. I don't think it is possible to change that, but as you are a R'n'D guru, you might have an idea.

Also, there are always two players on the gameplay of XOR. The human player can switch the current "hero" at any time by pressing the joystick button. It is possible to change the setups of R'n'D to play in multiplayer mode and use the F5 and F6 keys to select the other "hero", but since the game is not playable in single player mode, I would like to enable the multiplayer mode automatically. Is it possible? And is it possible to define a key or joystick button to toggle the heroes automatically? Again, I don't think so. No big deal anyway. I can add an envelope in the first level to explain that.
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Post by r0lZ »

Well, I have had a look at your level 14, and I must say that I'm very impressed, but I must also confess that I don't understand exactly how it works. (I haven't understood the "Page" thing yet.)

I like especially your method because you cannot see the player during a short moment trying all positions, as with the standard "4 player" method. (Of course, you have to change the display of the tiles 1 to 4 to the empty space, but that works fine.)

I have modified your level easily to do a two-ways teleport, and that works fine too. Great job!

BUT I have still a problem with your method. It doesn't work with player 2. I have of course tried to replace the reference to player 1 in the CE by the Player Triggering Change ref, but that doesn't work. When player 2 activates the teleport, it's player 1 that is teleported. I guess that's because the reference to the current player is lost when the "test tiles" 1 to 4 are replaced by the player. I have tried various things to solve this problem, but without success. So, Zomis, if you wish, you have still a challenge to complete! ;)

BTW, in your example, tile "4" has a delay of 4 frames. 3 is sufficient. But anyway I have modified all delays to add 10 frames, as, with a short delay and a two-ways teleport, an odd problem occurs when the player activates the teleport from a side and is teleported to the same side of the other teleport. Since the user has not enough time to release the button, the destination teleport gets activated again, and the player jumps to the other teleport, where the problem occurs again until the user releases the button (without knowing where he will finally be teleported.) With a delay of 10 frames or so, things are OK.
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

>Thanks very much, Zomis!

No problems :)

>I will try your solution as soon as possible, but I cannot do that now.
>You know, there are some obligations in the life, and I can't play R'n'D
>all the time! :(

Yeah, I know the feeling :/

>BTW, as you like challenges, I have still a couple things I try to improve.
> For example, in XOR, everything is normally static, except when the
>user does something that frees a rock, a zeppelin or a bomb. At this
>point, the user cannot move any more until all moving objects are
> either stopped or exploded. Currently, I can't duplicate that behavior in
> R'n'D. The trick I use is to set the speed of the moving objects to "very
>fast" so that the user has less chances to move, but in some
>circumstances (for example when a bomb has a long way to do before
>exploding and freeing another bomb that falls on the player) that's still
>not sufficient. And due to the fast speed, it is also difficult to see what
>happens exactly in complex situations. I don't think it is possible to
>change that, but as you are a R'n'D guru, you might have an idea.

There is actually a speed which is faster than "very fast" (1 step per 2 frames), named "even faster" (1 step per 1 frame). But that wouldn't solve it, it would still be possible to move if the distance was long enough.
There is however another way, using a CE and two change page conditions:
1. (No change) when delay 8 frames, CE Action: Set player speed = Normal
2. Change to CE1 when Move of <Zeppelin>, CE Action: Set player speed = Frozen
Then you can add additional CE change pages, that looks exactly like the second change page but with other CEs (or you could put all the active CEs into a group element and put when move of <Group Element> instead... but maybe you aren't familiar with Group Elements).
See this level: http://www.zomis.net/rnd/info.php?f=692


>Also, there are always two players on the gameplay of XOR. The human
> player can switch the current "hero" at any time by pressing the joystick
> button. It is possible to change the setups of R'n'D to play in
>multiplayer mode and use the F5 and F6 keys to select the other "hero",
>but since the game is not playable in single player mode, I would like to
>enable the multiplayer mode automatically. Is it possible? And is it
>possible to define a key or joystick button to toggle the heroes
>automatically? Again, I don't think so. No big deal anyway. I can add
>an envelope in the first level to explain that.

Well, no. That's not possible exactly. However, this solution might impress you and be exactly what you need: http://www.zomis.net/rnd/info.php?f=94

>Well, I have had a look at your level 14, and I must say that I'm very
>impressed, but I must also confess that I don't understand exactly how it
> works. (I haven't understood the "Page" thing yet.)

Change Pages are to make it possible for a CE to have more than one changes. It's like if and then cases. Page 1 could be "IF touched by player THEN explode", and Page 2 "IF delay 10 frames then change to CE 2" or something like that :) It gets simple when you've worked with it for a while (The first thing I did when I discovered CEs was to just test all things possible! I'm amazed RnD didn't crash at the time... :roll:)


>I have modified your level easily to do a two-ways teleport, and that
>works fine too. Great job!

Nice :)

>BUT I have still a problem with your method. It doesn't work with
> player 2. (...)

Fixed. See level 15 in the updated package. Added an additional 4 CEs.
http://www.zomis.net/rnd/info.php?f=327

>BTW, in your example, tile "4" has a delay of 4 frames. 3 is sufficient.
>But anyway I have modified all delays to add 10 frames, as, with a short
> delay and a two-ways teleport, an odd problem occurs when the player
>activates the teleport from a side and is teleported to the same side of
>the other teleport. Since the user has not enough time to release the
>button, the destination teleport gets activated again, and the player
>jumps to the other teleport, where the problem occurs again until the
>user releases the button (without knowing where he will finally be
>teleported.) With a delay of 10 frames or so, things are OK.

Oops, I accidently set that delay of 4 frames wrong, I meant to set it to 3. I also had a little problem with that, that it went to fast. Didn't bother to fix it though (I had to leave something for you to fix, right?)

Happy playing :)
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Post by r0lZ »

Zomis wrote:There is actually a speed which is faster than "very fast" (1 step per 2 frames), named "even faster" (1 step per 1 frame). But that wouldn't solve it, it would still be possible to move if the distance was long enough.
Yep, I have tried the even faster speed, but as you say, it's not a totally good solution, and things are moving too fast for the player to understand what happens before he dies!
Zomis wrote:There is however another way, using a CE and two change page conditions:
1. (No change) when delay 8 frames, CE Action: Set player speed = Normal
2. Change to CE1 when Move of <Zeppelin>, CE Action: Set player speed = Frozen
Then you can add additional CE change pages, that looks exactly like the second change page but with other CEs (or you could put all the active CEs into a group element and put when move of <Group Element> instead... but maybe you aren't familiar with Group Elements).
See this level: http://www.zomis.net/rnd/info.php?f=692
I have also noticed that possibility, but I thought it was too difficult to control the speed of the player when there are many elements moving at the same time. Also, it might be difficult to control the speed of each player individually, when the game is played by two humans at the same time. Anyway, I will investigate that again. Using Group Elements seems to be THE solution. (And yes, I understand the GEs. You know, I'm programmer, so that doesn't seem too complicated to me!)
Zomis wrote:Well, no. That's not possible exactly. However, this solution might impress you and be exactly what you need: http://www.zomis.net/rnd/info.php?f=94
Thanks. I will have a look.
Zomis wrote:Change Pages are to make it possible for a CE to have more than one changes.
I know that, and I understand and have already created multiple change pages. I haven't been precise enough. What I don't understand is how to use the "Change by page of" argument. In your teleport example, you use that several times in CEs 3, 4 and 5 to reference the previous elements, but I don't understand why you did it that way.
Zomis wrote:>BUT I have still a problem with your method. It doesn't work with
> player 2. (...)

Fixed. See level 15 in the updated package. Added an additional 4 CEs.
http://www.zomis.net/rnd/info.php?f=327
Incredible! I can't wait to try it! Huge thanks!

[EDIT] Oh, yes! Your "2 players" solution is so obvious! I should have thought at that! :oops:
The teleports are now perfect! Thanks again!
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Post by r0lZ »

Zomis wrote:
> ... in XOR, everything is normally static, except when the
>user does something that frees a rock, a zeppelin or a bomb. At this
>point, the user cannot move any more until all moving objects are
> either stopped or exploded. Currently, I can't duplicate that behavior in
> R'n'D. The trick I use is to set the speed of the moving objects to "very
>fast" so that the user has less chances to move, but in some
>circumstances (for example when a bomb has a long way to do before
>exploding and freeing another bomb that falls on the player) that's still
>not sufficient. And due to the fast speed, it is also difficult to see what
>happens exactly in complex situations. I don't think it is possible to
>change that, but as you are a R'n'D guru, you might have an idea.

[...]
There is however another way, using a CE and two change page conditions:
1. (No change) when delay 8 frames, CE Action: Set player speed = Normal
2. Change to CE1 when Move of <Zeppelin>, CE Action: Set player speed = Frozen
Then you can add additional CE change pages, that looks exactly like the second change page but with other CEs (or you could put all the active CEs into a group element and put when move of <Group Element> instead... but maybe you aren't familiar with Group Elements).
See this level: http://www.zomis.net/rnd/info.php?f=692
OK, I have analyzed how it works, and it is true that it's exactly what I need. BUT (again!) that doesn't work well with two players. To check what I mean, just add player 2 to the demo level, plays the level in multiplayer mode, and free the moving object. Player 1 and player 2 are frozen during the move, and when the CE stops, you can control the current player again. That's perfect. But if you toggle the current player, the new player is still frozen, and you cannot use it any more.
Since Player 1 or 2 is never explicitly referenced in the Control CE, I suppose that the speed that is frozen in the CE is global to all players. Therefore, I don't understand why the normal speed is restored only for the current player. Maybe I've found a bug?

Also, I've noticed something strange. In the first change page, the checkbox of the 8 frames delay is ticked, but not the "Element changes to" checkbox. Since that checkbox is the parent of the delay, the delay should be ignored, at least according to the documentation. Is it an error in the documentation?
Zomis wrote:... this solution might impress you and be exactly what you need: http://www.zomis.net/rnd/info.php?f=94
I have also had a quick look at that "Switch Players" level, and it's indeed a good idea and method. But I'm still not sure I will use that method, as the user has to collect the first CE (with the outline of the player) or the method doesn't work. I'm not sure I can easily add it in all XOR levels, at a place where it must (or even can easily) be collected.
Also, with that method, it is impossible to play the game by two human players at the same time.
However, the "frozen" method should work fine with this method (and the teleports are easier to do.) So, maybe I will change my mind.
Anyway, it's a good demo of the power of the game engine!
User avatar
Holger
Site Admin
Posts: 4071
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

> Also, I've noticed something strange. In the first change page, the
> checkbox of the 8 frames delay is ticked, but not the "Element changes to"
> checkbox. Since that checkbox is the parent of the delay, the delay should
> be ignored, at least according to the documentation. Is it an error in the
> documentation?

Well, this is something that is at least a bit strange (I don't know at the moment how it's documented exactly): A change page mainly consists of change conditions and change actions. The classic change action is "element changes to other element", which is that line that you meant by the "parent" of the (delay) condition. Later, this obvious "action" was extended by a whole lot of actions that do not include changing to a different element, but things like "kill player", for example. These actions are connected to the same conditions defined above. Unfortunately, those gadgets may be arranged in a counter-intuitive manner -- the initial intention was to read it like this: "Change element to X when (some conditions) apply; additionally, execute some non-element actions." In cases where there is only a non-element action, but no element change, things look indeed a bit unordered (as the condition gadgets don't look like being hierarchically connected to the additional action as they are to the element change)... :-/

I hope it's a bit clearer now -- maybe it's not the documentation that needs tweaking, but the interface itself. :-o
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Post by r0lZ »

OK, I understand. And I agree. The order of the elements is a bit confusing. Maybe it could be improved by the use of some frames around group of conditions and actions, so that they can be easily arranged in a more comprehensible hierarchy.
But now that I know that, I'm sure the change pages are even more powerful than I thought. Thanks for that precious precision!
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Post by r0lZ »

Hum, seems there are several bugs when using two players. So, I guess I will have to use the "Player switch" method.

BTW, to reproduce the bug I have just discovered, simply load a new level in the editor and add player 2 near player 1. Then, start the game in multiplayer mode, and move player 1 to the left (or the bottom.) When he is near the right (or bottom) edge of the screen, the playfield starts scrolling, and almost immediately player 1 cannot move any more in the same direction. No problem with player 2! And after having used player 2, player 1 can move freely. Strange. I suppose that this problem can be fixed by automatically swapping player 1 and 2 two times at the beginning of the game, but I haven't tried that yet.

I'm also almost sure that the problem with player 2 speed not being restored to normal with the "freeze method" is also due to a bug. And I haven't found a solution yet.

I have also a little problem with the hidden "Speed Control" CE needed to freeze the players when something is moving. In XOR, there are "dolly" elements that are static at the beginning of the game, but can move in a straight line, in any direction, when the player pushes them. It is easy to program that using one static CE that is changed to one of four moving CEs when the user presses it at the corresponding side. But I need to change the moving CE by the static one when it hits something, so that the user can press it again later. Unfortunately, the invisible and walkable "Speed Control" CE is considered as "something", and therefore if the dolly hits it, it is stopped, without apparent reason. I suppose also that I will not be able to replace it during the game by any moving element.
I have envisaged the solution of using an existing element, such as a wall, to store the CE, but unfortunately, in XOR, all elements are destroyable, but I cannot destroy the "Speed Control" CE! Dead end?

Suggestion: IMO, to solve those problems easily, it should be possible to define some "global" actions in a CE that is taken into account even if it is not present in the puzzle itself. It that's already possible, please let me know...
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Goal!

Post by r0lZ »

OK, I have finally merged the three methods and everything works (almost) as expected.

Currently, I've added the "speed control" change pages in the "Friend" player CE (from the SwitchChars method.) Therefore, if the friend is killed by accident, the player can move during the movements of the elements, and that not exactly what I need, as, in XOR, only one player must complete the level, but I suppose that I can replace the dead friend by a CE that contains the Speed Control change pages and is visible, indestructible and cannot move. No big deal. But since the dolly must stops when it hits one player anyway, I have solved the problem reported in my previous post. And since there is only one real player in the playfield, the bugs of the multiplayer game are gone. I'm only a bit disappointed because the game cannot be played by two human players. :(

Thanks for your help and valuable suggestions.

Of course, I will release the game in this forum when it will be finished, but I have still a lot of things to do.

BTW, I have to write a program to convert the original XOR levels in R'n'D format. Is it a documentation on that format somewhere? Seems it's the good old Amiga IFF format that is used. Right?
User avatar
Holger
Site Admin
Posts: 4071
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

> BTW, I have to write a program to convert the original XOR levels in R'n'D
> format. Is it a documentation on that format somewhere? Seems it's the
> good old Amiga IFF format that is used. Right?

Yes, the R'n'D level file format uses Amiga IFF structure (with custom chunk identifiers). To store variable amounts of small-sized data without the overhead of complete IFF chunks, it also uses a flexible "micro chunk" structure inside the normal IFF chunks.

As you are a programmer yourself, you might like to have a look into the C source code file src/files.c, which contains all the level loading and writing stuff. (Look for "LoadLevel()" and "SaveLevel()" there.) It also already contains functions to convert native levels of BD style games to R'n'D level files, like native level files of Emerald Mine, Diamond Caves II and Supaplex -- see how the "convert" command works (on the command line; type "./rocksndiamonds --help" to see how the syntax looks like). That command line "convert" command does what you probably want to do: Read a native level in non-R'n'D format and write it back to disk in R'n'D format. (Usually R'n'D tries to directly guess and read the native level format, but it can also write it back to disk in R'n'D format.)

Sorry, there is no nice documentation of the R'n'D level file format in non-source-code format available for now. :-(

Zomis might help you understanding how that micro-chunk format works, as he has already written code to read and write R'n'D level files!
r0lZ
Posts: 93
Joined: Sat Oct 20, 2007 6:24 pm

Post by r0lZ »

OK. thanks. With your pointers, I should be able to write the converter.

BTW, is it possible to load the levelsketch format (*.lsk files) directly in R'n'D?
Post Reply