Jump to content
UncannyBoots

Vehicle that can pass through certain impassible tiles

Recommended Posts

Are there any scripts or ways in general to make a custom vehicle -- think a car or a motorbike -- that can drive over certain impassible tiles (like rough potholes and ditches that the player normally cannot walk over)?

I don't know how to write a script from scratch but I have an idea of how it would be done. When player has $game_switches[x] on, tiles covered with a specific region ID will be passable. Something like that should work in theory, I think...

Share this post


Link to post
Share on other sites

I have no script, but I can share some eventing knowledge.

 

Put an event over the tile. In the screenshot below, it shows what the tile should look like. You can probably leave the graphic blank but remember to make priority "Same as Characters" because when you make it blank, the program automatically changes it to "Below Characters" Through On will overwrite the tiles it is on. Now, I don't know how your maps are made but you will need to eventually turn Through OFF if the player is not going through that tile again. Where you do that is entirely based on how you implement the mechanic and where you're implementing it. If you are making custom vehicles, you'll need to make a switch when the player is using those vehicles. If you want to know how to create vehicles, I can show that as well.

 

unknown.png

Share this post


Link to post
Share on other sites

Well, making a whole new kind of vehicle might take a little bit of work just because of how the default scripts used fixed indexes for everything, but if you wanted to turn the boat into a car/buggy (the ship is basically like a better boat anyway) all you have to do is change the 'map_passable?' method for the Game_Player class.

 

Try this, it makes the boat go over anything you can already walk on and any tile with a terrain tag of 1!

 

class Game_Player < Game_Character

  alias_method :map_passable_buggy_base, :map_passable
  def map_passable?(x, y, d)
    case @vehicle_type
    when :boat
      $game_map.passable?(x, y, d) || $game_map.terrain_tag(x, y) == 1
    else
      map_passable_buggy_base(x, y, d)
    end
  end
                                  
end

Of course you can also check region_id if you want instead of terrain_tag, no switches needed! I just think terrain tags are more useful for this type of thing.

 

Edit: Also:

 

17 minutes ago, Lord Vectra said:

I have no script, but I can share some eventing knowledge.

 

Put an event over the tile. In the screenshot below, it shows what the tile should look like. You can probably leave the graphic blank but remember to make priority "Same as Characters" because when you make it blank, the program automatically changes it to "Below Characters" Through On will overwrite the tiles it is on. Now, I don't know how your maps are made but you will need to eventually turn Through OFF if the player is not going through that tile again. Where you do that is entirely based on how you implement the mechanic and where you're implementing it. If you are making custom vehicles, you'll need to make a switch when the player is using those vehicles. If you want to know how to create vehicles, I can show that as well.

 

 

Eh?!?! I can't see the image, but... that sounds like the most cumbersome way to do that possible! And how are you planning on making a vehicle using events? By turning off followers and changing the lead actor's graphic? I can already think of so so many ways that can bug out. Otherwise I really have no idea how you would do it. Maybe... Manually create a  vehicle object with a script call of some kind? Would that work? Like I said, the default scripts kinda expect just the three.

 

Edited by Kayzee

Share this post


Link to post
Share on other sites
11 minutes ago, Kayzee said:

Eh?!?! I can't see the image, but... that sounds like the most cumbersome way to do that possible! And how are you planning on making a vehicle using events? By turning off followers and changing the lead actor's graphic? I can see so so many ways that can bug out.

 

Image works perfectly for me.

 

Additionally, I've done this and it doesn't bug out at all, so I'm going to need examples on when it would bug out. And it may sound like the most cumbersome way, but it's really easy to set up. On paper, it seems like a lot of steps, but if you, instead, show him how to script it and how to do each command via scripting, the steps are about as equal, if not, more because you have syntax that comes into play and then you have to get around some of the hard-coded mechanics.You showed him how to do it via existing vehicles but he wants custom vehicles which is where my part comes in.

 

10 hours ago, UncannyBoots said:

When player has $game_switches[x] on, tiles covered with a specific region ID will be passable. Something like that should work in theory, I think...

Pretty close, actually. There are numerous ways you can do it via eventing. Fastest way is parallel process common event that checks for Y coord, X coord, and Region ID of the player and then say if region ID == X and if switch Y = ON, then set move route: player Though ON. However, doing this means you need to increase your expected region ID size. If the player cant pass a 4 x 4 block, you'll need to make it 5x5. So you make a 4x4 impassible block on the map then you fill it with region ID tag and then you create an outline of that same tag because if not, the player can't get into the 4x4 block to get the region ID.

If you set the player to have Through ON, they will walk pass anything even if it's impassible. The rest is pretty much what Kayzee said. You turn off followers, change leader's graphics, turn a switch on and if the common event is already running, its already gonna have the region ID. When you change the "vehicles" graphic from a graphic to none, you need to turn on self switch A (make a 2nd event page and make sure graphic is none). Self switch A will check if the switch is on (parallel process). When it is OFF, turn player Through OFF, use "Set Event Location" command and use the X and Y coord of the player and turn self-switch off immediately afterwards.

X coord and Y coord of the player can go into variables so I can show that. Region ID is in the "Get Location" command. Besides vehicles, getting that info from the player is HIGHLY beneficial for a lot of mechanics out there bc u can check the player's location at anytime for any puzzles, quests, and region ID is extremely useful for random encounters so it's not like you're doing this ONLY for these vehicles. If you don't know how to look for the location of the player, it's control variables => game data => character => player = > X coord and then you do the exact same for Y coord and it's set up.

Share this post


Link to post
Share on other sites
3 hours ago, Lord Vectra said:

Image works perfectly for me.

 

Additionally, I've done this and it doesn't bug out at all, so I'm going to need examples on when it would bug out. And it may sound like the most cumbersome way, but it's really easy to set up. On paper, it seems like a lot of steps, but if you, instead, show him how to script it and how to do each command via scripting, the steps are about as equal, if not, more because you have syntax that comes into play and then you have to get around some of the hard-coded mechanics.You showed him how to do it via existing vehicles but he wants custom vehicles which is where my part comes in.

 

It just says 'unknown.png' to me and displays nothing. Are you sure the image can be publicly accessed? It looks like it's a discord attachment. Maybe it dosn't show up right if you arn't logged in?

 

I think I misunderstood what you were trying to do actually. I thought basically you were saying to make an event for each tile on the map  or something, but rereading I think it seems more likely you were using one event to change the player's through flag on or off, which is a LOT more reasonable. By cumbersome I meant I thought it would take a lot of set up for every map you wanted the new vehicles in (though thinking about it more, maybe that's a moot point if they are only used in one overworld map). Still will a bit it sounds like, but no where near what I originally thought. I was trying to go for a thing where you basically just needed to tag the tileset and basically nothing else.

 

As for examples of how the changing the actor graphic might bug out (if that is what you are doing): What happens when you reorder the party and/or change the leader? What happens when you go into an area that transfers you to another map? What happens if you do a cutscene thing on the overworld? What if you draw the character sprites in the menu? Also there is checks in place for vehicles during interactions. Am I missing something or thinking about it all wrong? Can you change the player character's appearance without changing the leading actor's apprentice? I thing you could use move route commands, but I think it would just refresh back to what it was 'supposed to be'.

 

Seriously I really want to know how you plan on doing it, because it seems like a million things could go funny if you try and do some kind of fake vehicles via events. I'm sure it could be done, it just seems like a pain to iron all the kinks out of.

Share this post


Link to post
Share on other sites
5 hours ago, Lord Vectra said:

I have no script, but I can share some eventing knowledge.

 

Put an event over the tile. In the screenshot below, it shows what the tile should look like. You can probably leave the graphic blank but remember to make priority "Same as Characters" because when you make it blank, the program automatically changes it to "Below Characters" Through On will overwrite the tiles it is on. Now, I don't know how your maps are made but you will need to eventually turn Through OFF if the player is not going through that tile again. Where you do that is entirely based on how you implement the mechanic and where you're implementing it. If you are making custom vehicles, you'll need to make a switch when the player is using those vehicles. If you want to know how to create vehicles, I can show that as well.

 

unknown.png

 

That would make the player be able to pass over every tile. I don't want that, I want the vehicle to only pass over certain specified tiles, not over walls and things like that. Still, thank you for your help!

EDIT: I misread it, that actually would work in theory (I think) but it would take a lot more work. Regardless, thanks for taking the time to help me :)

 

4 hours ago, Kayzee said:

Well, making a whole new kind of vehicle might take a little bit of work just because of how the default scripts used fixed indexes for everything, but if you wanted to turn the boat into a car/buggy (the ship is basically like a better boat anyway) all you have to do is change the 'map_passable?' method for the Game_Player class.

 

Try this, it makes the boat go over anything you can already walk on and any tile with a terrain tag of 1!

 


class Game_Player < Game_Character

  alias_method :map_passable_buggy_base, :map_passable
  def map_passable?(x, y, d)
    case @vehicle_type
    when :boat
      $game_map.passable?(x, y, d) || $game_map.terrain_tag(x, y) == 1
    else
      map_passable_buggy_base(x, y, d)
    end
  end
                                  
end

Of course you can also check region_id if you want instead of terrain_tag, no switches needed! I just think terrain tags are more useful for this type of thing.

 

Hey, it works. Thank you!

I got a few error messages at first but I was able to fix them. The alias was just a bit messed up. Here's the fix:

class Game_Player < Game_Character

  alias :map_passable_buggy_base map_passable?
  def map_passable?(x, y, d)
    case @vehicle_type
    when :boat
      $game_map.passable?(x, y, d) || $game_map.terrain_tag(x, y) == 1
    else
      map_passable_buggy_base(x, y, d)
    end
  end
                                  
end

Hmm, actually wouldn't the alias also not even be called there? Iirc, you have to then call the alias under the def, right? So like this:

alias :map_passable_buggy_base map_passable?

def map_passable?(x, y,d)

:map_passable_buggy_base

 

Well either way, the script works but yeah

Edited by UncannyBoots

Share this post


Link to post
Share on other sites

Wait... I am sure I tested it and fixed that already... Did I forget to paste it back in the post? Oh well. As long as it works!

 

Also: I got into the habit of using alias_method rather then alias which is ever so slightly different. That's why I have a : before the names and a comma, they are required for alias_method but with just alias you can skip them. But if you are confused, the ':' is not part of the method name, it marks the name as a 'Symbol', which is kinda like a special identifier thing you can pass around as data. It's kind of confusing I know, but there are some benefits to using alias_method Not sure how much of a difference it makes but my corrected version was this I think:

class Game_Player < Game_Character

  alias_method :map_passable_buggy_base?, :map_passable?
  def map_passable?(x, y, d)
    case @vehicle_type
    when :boat
      $game_map.passable?(x, y, d) || $game_map.terrain_tag(x, y) == 1
    else
      map_passable_buggy_base?(x, y, d)
    end
  end
                                  
end

Sometimes I forget question marks are actually part of the names. You might notice I also put one at the end of map_passable_buggy_base. Really all it really is for is just as a friendly way to let people know that the method is basically meant to be answering a true or false question.

Edited by Kayzee

Share this post


Link to post
Share on other sites

I don't mean to be much of a bother but I just realized that now the vehicle can go into water, which I do not want. The water is marked with a region id, making it so that the player can swim in it. How would I make it so that when riding the vehicle, the player cannot pass over a specific region ID?

Share this post


Link to post
Share on other sites
3 hours ago, UncannyBoots said:

I don't mean to be much of a bother but I just realized that now the vehicle can go into water, which I do not want. The water is marked with a region id, making it so that the player can swim in it. How would I make it so that when riding the vehicle, the player cannot pass over a specific region ID?

 

Well, this is one way of doing it... Not sure what region id you were using, so I used 1 here.

class Game_Player < Game_Character

  alias_method :map_passable_buggy_base?, :map_passable?
  def map_passable?(x, y, d)
    case @vehicle_type
    when :boat
      ($game_map.passable?(x, y, d) || $game_map.terrain_tag(x, y) == 1) && $game_map.region_id(x, y) != 1
    else
      map_passable_buggy_base?(x, y, d)
    end
  end
                                  
end

Also:

 

2 hours ago, roninator2 said:

 

That's more designed for use with the through flag right?

 

Share this post


Link to post
Share on other sites
3 hours ago, roninator2 said:

 

I use that already but it doesn't restrict vehicles only. Thanks though!

 

@Kayzee, it works perfectly. I actually edited the script almost exactly like that but it didn't work and I had no idea why. Turns out the parenthesis were what I was missing, and I never would have figured that out lol. Also I used || instead of && so I dunno which of those differences is what made it not work. But it works now, so yeah thanks a ton!

Edited by UncannyBoots

Share this post


Link to post
Share on other sites
10 hours ago, UncannyBoots said:

@Kayzee, it works perfectly. I actually edited the script almost exactly like that but it didn't work and I had no idea why. Turns out the parenthesis were what I was missing, and I never would have figured that out lol. Also I used || instead of && so I dunno which of those differences is what made it not work. But it works now, so yeah thanks a ton!

 

Well '||' means 'or' and checks if any of the things are true, but '&&' means 'and' and checks if all the things are true. In this case we want to do something like "if this or that and not the other thing". I am not sure if the parenthesis are really needed to be honest, I put them in just in case because I am never quite sure about order of operations. I mean when I said "if this or that and not the other thing" I meant to imply "if (this or that) and not the other thing" but it's possible to read it as "if this or (that and not the other thing)" which is actually a big difference. Oh the woes of interfix notation...

 

Edit: Ha! I looked it up and '&&' does take priority over '||', so yeah the parenthesis were needed. Though I could have written it in a 'otherthing && this || that' kinda way instead.

Edited by Kayzee

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×