Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Help With VX Ruby?

EDIT: Crap sorry, can this be moved to proper thread please? I apologize.

Basically the problem is this: I have the 2 Player engine and it works great, I found some solutions to some of the problems but with the type of game I got going on I need one simple solution that I just can't figure out. So to all the ruby scripters out there please help.

I've searched up and down the default scripts in RPGVX but can't find anything remotely close to "Get Player 1's X location and Get Player 1's Y location" so I can "Jump Player 2 to Player 1's location" like moveto(x-1,y) or whatever. Because I know that player 2 can't be in the exact same location as player 1, but I need this ONE script/event or whatever so that I may be able to incorporate it into many different functions.

-Player 2 want to join game (jump to player1)
-Player 2 gets lost in previous map that Player 1 goes to somewhere else (Jump to Player1)
-Player 1 goes from town to World Map (why bother setting up different Xs and Ys when you could... Jump to Player1?)

So if anybody could help out with that, I could finally let my mind rest in peace as this is killing me lol. No RPGVX, help file, or anywhere I've searched really covered this exact topic. So if you could please, I would owe ya. (plus I love learning new scripts and how to script. It's fun ^^)
 
You should give a link to the script, it would help a lot.
I guess the second player Object is also a Game_Player (it would be logic) so if you want to get the coords of a player, simply use
Code:
$game_player.x
$game_player.y
$game_player.map_id
Also, Game_Player has a really nice method to transfer the player to a given x/y/map/direction
Code:
$game_player.reserve_transfer(map_id, map_x, map_y, direction)
 
well the 2 player script is:
http://rmxp.org/forums/index.php?topic=43119.0

And it even has a reserve_transfer function within that too. Now how would I incorporate that into actually USING it?

"$game_player2.reserve_transfer($game_player.x - 1, $game_player.y, $game_player.map_id, 8)"

or something like that? Because what I'm also trying to do is allow the Player 2 to jump "next to" Player 1. Afterall they can't go in the same place Player 1 is, heh.  Then there'd be the problem if x - 1 location's in someplace that no player should be (body of water, void, roof, or something) how could they be moved to the next plausible spot.

I know I'm kinda asking a lot, but I feel this script could not only help me, but could be beneficial to the community if we can figure this out.
 
LordValinar":1o5rn4iw said:
well the 2 player script is:
http://rmxp.org/forums/index.php?topic=43119.0

And it even has a reserve_transfer function within that too. Now how would I incorporate that into actually USING it?

"$game_player2.reserve_transfer($game_player.x - 1, $game_player.y, $game_player.map_id, 8)"

or something like that? Because what I'm also trying to do is allow the Player 2 to jump "next to" Player 1. Afterall they can't go in the same place Player 1 is, heh.  Then there'd be the problem if x - 1 location's in someplace that no player should be (body of water, void, roof, or something) how could they be moved to the next plausible spot.

I know I'm kinda asking a lot, but I feel this script could not only help me, but could be beneficial to the community if we can figure this out.

There should be a method called "map_passable?(x, y)" in the Game_Player script. That automatically checks whether the given location is passable, and the player can be transferred there. On the other hand, you've also got to worry about the different levels on the map. For example, player 1 is on one level, but Player 2 gets transferred to a spot at the bottom of a cliff because player one is standing on its edge.
 
For example, player 1 is on one level, but Player 2 gets transferred to a spot at the bottom of a cliff because player one is standing on its edge.

exactly what I'm saying. :)  but also if someone could actually mess with and come up with the actual script, that'd be great too. I mean i'm not saying I'm going to be lazy and just throw this out there, because I wanna learn and know too, hence why I'm asking for help. So I'm going to try to play around with these tips ya'll have given me and see if I can figure it out, but would also appreciate it if we got some scripting geniouses out there to put me in my place, lol.

I'm still learning Ruby. :)

-Thanks so far though!
 
Well I'm still playing around, but the $game_player.x - 1, $game_player.y  works using $game_player2.create($game_player.x - 1, $game_player.y, 17, false)

17 is just the character. But now I need to know how to check for passable area. I have this so far:

Code:
def jumptoplayer1(x, y, id, need_center = false)
  
  if map_passable?(x,y)
    $game_player2.create(x, y, id, need_center)
  else
  x += 1
  y += 1
  refresh
  end
end
 
okay the problem is almost resolved... I'm using the Event Commands for "conditional branch: script"

someone elsewhere suggested using "$game_player.map_passable?(x,y-1)"  then $game_player2.create(x,y-1,17,false)

else
ConditionalBranchScript: $game_player.map_passable?(x,y+1)
then $game_player2.create(x,y+1,17,false)
------------------
now just got to actually test theory and will keep ya posted on whether or not this is resolved but hopefully this will be the last piece of the puzzle :)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top