Help - Search - Members - Calendar
Full Version: How to say 'if this doesn't work, try this' in Common Event
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
OniLink99999
Hey guys,

I've been working on a common event utilising the RPG Maker jump function. It works alright, but there's just one thing I have a problem with - if there's something in the way of the jump trajectory, even if it's 3 tiles away, the player won't jump. So what I'm trying to do is tell RPG Maker that 'if you can't jump this distance, try jumping this distance' and so on to cover all the tile distances.

Now, I was thinking I could do this with conditional branching and the 'Else' category, but unfortunately that doesn't seem to work (as my conditional branch is a button, and that button is the same for all the different degrees of jumping, it just references the first branch regardless of any problems...). I'm sorry if this doesn't make a huge amount of sense - I'm not great at explaining this sort of thing, haha.

But basically, what I want to know is - is there a way to say to RPG Maker 'hey, if you aren't going to let the player jump with that move event, try this move event instead'? Again, I'm doing this in events, so no scripting, etc.

Thanks very much in advance happy.gif
Jens of Zanicuud
I think there's a way to do this...
In conditional branches, you can check a script to be true or false, in the fourth page, if I remember correctly.
Let me explain this with an example:

Your char has to do: >Jump (+x0,+y0)

If you put a Conditional Branch with the following script in the fourth page:

CODE
$game_map.passable?($game_player.x+x0,$game_player.y+y0)


where x0 and y0 are the jump coordinates (you have to switch them with the number you need...), the engine will check if the destination square is actually passable...

Try and let me know if it works...

Hope this can help.

Jens

EDIT: (maybe this is what you were looking for...)

I had another idea, but it's rather complicated...
First, before the jumpe event, set two variables [OLD_PLAYER_X] equal to Player X tile and [OLD_PLAYER_Y] equal to Player Y tile.

Then, call the jump event, with the Ignore Impossible Moves box checked.

Put a Wait 1 Frame command below the move event, then set two new variables [NEW_PLAYER_X] equal to Player X tile and [NEW_PLAYER_Y] equal to Player Y tile. If jump was succesful, the two new variables would be different from the older ones. If the player remains still (i.e. didn't jump), then the actual difference will be 0...

Now, just put a conditional branch on those varaibles and... les jeux sont fait.

Tell me if it works.... maybe the Wait command is unnecessary...

Jens
OniLink99999
First off, let me just say - brilliant idea Jens! Thanks a lot for your input. The latter solution is exactly what I'm trying to do. Unfortunately it didn't work - exactly why, I'm not 100% sure. So basically what I've got is this in the Common Event:

Conditional Branch - The 'A' Button is Pressed
Control Variables: OLD Player X = Player's Map X

Control Variables: OLD Player Y = Player's Map Y

Conditional Branch - The 'Up' Button is Pressed

Set Move Route: Player (Ignore if Can't Move)
Jump +0, -3

Wait 1 Frame

Control Variables: NEW Player X = Player's Map X

Control Variables: NEW Player Y = Player's Map Y

Conditional Branch - Variable NEW Player X == OLD Player X

Conditional Branch - Variable NEW Player Y == OLD Player Y

Set Move Route: Player (Ignore if Can't Move)
Jump +0, -2

Wait 1 Frame

Control Variables: NEW Player X = Player's Map X

Control Variables: NEW Player Y = Player's Map Y

Conditional Branch - Variable NEW Player X == OLD Player X

Conditional Branch - Variable NEW Player Y == OLD Player Y

Etc. I then continue onto the other buttons, so:

Else: Conditional Branch - The 'Right' Button is Pressed

Set Move Route: Player (Ignore if Can't Move)
Jump +4, -2

Control Variables: NEW Player X = Player's Map X

Control Variables: NEW Player Y = Player's Map Y

Conditional Branch - Variable NEW Player X == OLD Player X

Conditional Branch - Variable NEW Player Y == OLD Player Y

And so on, so on until I cover all of the potential degrees that the player can jump. I've also tried seperating each of the 'Conditional Branch - Variable NEW Player X == OLD Player X' sections under 'Else' tags, but that didn't work.

Basically, I can still jump to the same standard degree that I could before. Every now and again the player character will do what I want and actually jump less than normal, but it seems almost randomised. Additionally, standard jumps seem to be all over the place - sometimes the character does a double-jump, other times they turn to face the background in mid-air. It's rather odd (and I can't find any discrepancies that would allow it to happen in the event code).

The biggest problem seems to be jumping left and right (ironically the most important directions) - potentially because there are 8 degrees of jumping I've included in the code for these side-ways jumps, as opposed to only three degrees of jumping I included for up and down.

If anyone can follow that, any ideas? happy.gif
Jens of Zanicuud
Well, actually double jump is due to the fact that there's not Wait below the succesful jump. So, anytime you press the A button, RPG Maker registers the Input twice and your player will randomly jump like a drunk rabbit.

Maybe a common event is not the best way to resolve that problem...
Too many free variables... and too many branches. I need to know what exactly is your jump-needed-event, with exact ciphers and numbers, i.e. something like this:

"My player has to jump:
Up : 0,-3
Down: 0,3
Right: 3,0
Left: -3,0

I have to press button A and then direction..."

A full description could be useful, but let me say that an event-based jump could be a complete suicide...

If you post that additional info, maybe someone willl be able to solve the problem.

Jens
OniLink99999
Actually, I just forgot to write it, haha. There is a 1 frame Wait beneath every move event, and at the end of each full directional key branch (up, down, left, right) there's a 10 frame Wait. Naturally, if I put a 10 frame wait beneath each event, it'll take ages before it figures out what it's supposed to do. As an attempt to fix it, I also tried adding a 10 frame Wait to the end of every branch that I made. This simply resulted in a kind of creepy glitch, however, where my character would jump, turn around, and then stare at me for the next 80 frames.

Okay then, no problem. So, I have 3 different degrees of jumping for the Up and Down keys. For Up, the numbers are (+0, -3), (+0, -2), (+0, -1). For Down, the numbers are (+0, +3), (+0, +2), (+0, +1).

Now, I have 8 different degrees of jumping for the Left and Right keys. For Right, the numbers are (+4, -2), (+3, -2), (+2, -2), (+1, -2), (+4, -1), (+3, -1), (+2, -1), (+1, -1). For Left, the numbers are (-4, -2), (-3, -2), (-2, -2), (-1, -2), (-4, -1), (-3, -1), (-2, -1), (-1, -1).

When the player presses the A button and a directional key together, their character jumps in whatever direction they press. That's simple enough. However, there is a problem with the standard form of jumping. If you try to make a jump, but something is in the way of your trajectory - say, three tiles away - the player will not jump. I am trying to make it so that if the player cannot jump, say (+4, -2) but can jump (+3, -2) without issue, the game will figure it out and let them do that.

Haha, thanks for the warning, but events are generally where I am most comfortable and can do the most with. And I don't need the player amazing jumping abilities or anything. Just thought a system like this would improve the feel of the control and make jumps easier for the player.

Thanks again for your help Jens happy.gif
Jens of Zanicuud
For Up and Down it shouldn't be such painful...

Something like this, where [Cx] indicates the conditional branch number x...

I tried writing UP condition

>Conditional Branch: A is pressed? [C1]
>Conditional Branch: Up is pressed?
[C2]

>Game_Variables[1] = Player Y
>Move Event: Player
>Jump(-3,0)
>Ignore Impossible Moves

>Wait 1 frame
>Game_Variables[2] = Player Y
>Conditional Branch: Game_Variables[2] == Game_Variables[1]? [C3]
>Game_Variables[1] = Player Y
>Move Event: Player
>Jump(-2,0)
>Ignore Impossible Moves

>Wait 1 frame
= Player Y
>Conditional Branch: Game_Variables[2] == Game_Variables[1]? [C4]
>Game_Variables[1] = Player Y
>Move Event: Player
>Jump(-1,0)
>Ignore Impossible Moves

>Wait 1 frame
= Player Y
>else [C4]
>Wait 10 frames
>end [C4]
>else [C3]
>Wait 10 frames
>end [C3]

>else [C2]
....

Unfortunately, Right and Left seem very painful to handle with.
You'll need at least eight conditional branches incapsulated in strange ways (but I bet they could be two times that number, since different branches can lead to the same jump event).
Try and let me know!

I apologise if you just tryed this and didn't work...
Hope this can be more useful than my description.

Good luck for your project happy.gif

Jens

EDIT:
Are you working on a platform or stuff like this?
Some time ago, I built a script/common_event based Metroid for RMXP (it's still a Demo, but I think was decent... 2D platform, if you don't know...), but I haven't used the standard Jump... Actually, I preferred set different move events plus a gravity common event... It seems strange, I know, but it worked...
"Void" tiles, through which player could fall had terrain 0, while "Solid" tiles had terrain >= 1
The flow was something like this:

<JUMP> [PARALLEL]

Key A pressed:

Switch[JUMP] = on

Move_Event::Player
>Move_Up
>Move_Up
>Move_Up
>Move_Up
(Ignore Impossible Moves)

Wait 5 frames

Switch[JUMP] = off

<Gravity> [PARALLEL]

If Switch[JUMP] == off
if Player Terrain == 0

Move_Event::Player
>Move_Down
(Ignore Impossible Moves)

Wait 2 frames

end
end

Well, actually it was far more complicated, but I hope this could be explainatory...

Jens
OniLink99999
Haha, seems that great minds think alike! I also used a Terrain Tag-based Gravity system - although mine's the opposite (0 is walkable, and 1 pushes the player down to the ground). And yes, the project is partly Metroid-inspired. Not really a platformer by any stretch of the imagination, but it does take and use elements from the Metroidvania genre, and does also switch perspective between top-down and side-scrolling.

I never really thought of simple 'Move Up' events as working for a jump system, but after seeing that it worked for you, I gave it a go. It took a little bit of tinkering, but it's already working much better than when I was using the jump function! Thanks a lot Jens - I really appreciate you spending all this time helping me out biggrin.gif
Jens of Zanicuud
QUOTE (OniLink99999 @ Dec 12 2011, 02:10 AM) *
Haha, seems that great minds think alike! I also used a Terrain Tag-based Gravity system - although mine's the opposite (0 is walkable, and 1 pushes the player down to the ground). And yes, the project is partly Metroid-inspired. Not really a platformer by any stretch of the imagination, but it does take and use elements from the Metroidvania genre, and does also switch perspective between top-down and side-scrolling.

I never really thought of simple 'Move Up' events as working for a jump system, but after seeing that it worked for you, I gave it a go. It took a little bit of tinkering, but it's already working much better than when I was using the jump function! Thanks a lot Jens - I really appreciate you spending all this time helping me out biggrin.gif


Ok, let me know if it works:)
I really loved Metroid and this was the best way I thougth to replicate that jumping system without using scripts.
The firt version was horrible, but now seems to work rather well...
Good luck for you project, if you need some more help, just post:)

Jens
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.