Setting up a unique vehicle/spell

Hello everyone, to start I'm going to say what I'm planning on doing in my game. There is going to be a vampire that bites you and you start to get vampiric powers. One of these powers is having the ability to turn into a bat. To start, the bat will only be able to fly over water and certain tiles. Eventually you will be able to become a bat indefinitely. The first stage of the bat will last for 15 seconds and if time runs out, you would normally get stuck but I want it to force you to fly back to the last regularly passable tile that you were on. This tile could be a passable tile that you flew over while you were a bat (this is to make sure that you arent forced to fly like 30 tiles backwards if the timer happens to end while you are over a tree). I don't have the slightest clue how to do this so if somebody could tell me how that would be awesome.


I also need to know how to make certain tiles (as well as events because I have events for enemies instead of random encounters) unpassable even though through is turned on when you are a bat. This is so that you won't be able to get over areas you aren't supposed to go in and more importantly so that events activated with event touch will still activate.


Here is my common event (it is activated by pressing b. i'm using the button common events plugin from yanfly) Everything works just fine but I don't want the player to go back to normal when you enter a new area. I know it can be done by just making an event that checks if the bat variable is turned on but that would mean I have to have this check in an autorun event in every single area and I would rather do it in a common event. Here is my common event:


Untitled.png


Finally how do I disable dashing while you are in bat form?


Thank you guys so much!
http://mvplugins.tordamian.com/plugins/manage-dashing/ 


Here is your dashing control, this should give you all the functionality you need for that part. 


$gameMap.isPassable($gamePlayer.x, $gamePlayer.y, direction)   This isn't something I've tested, but I got the base of it from the MV script call page 


Here is the page if you haven't seen it. 


But that script call should return true if the tile is passable. That means you can have a conditional branch that says


if *script call from above*


[no code required]


else 


[control variables ID = $gamePlayer.x        here you would want to grab the player x because this means it's the last x location before you went to unpassable terrain


control variables ID = $gamePlayer.y]        and here you would grab the y


Then you'd want to kill this process, because otherwise it would keep updating those variables instead of saving just that last x and y.


You could set a timer for it by creating a separate common event, set to parallel process and bound to a switch. When the bat mode is activated, that switch is turned on. The event code will read:


Wait 60 frames


Control Variable "Seconds" or whatever     + 1


Conditional Branch: If Seconds >= 15 


turn off switch, turn player back to normal, reenable dashing


Also you could call the Map Passable bit from above again to check if you're on passable ground. If not (else) you could use this HIME script  to move your player toward the x and y that you stored before. Here's how you do that:


Set an invisible event with Through on somewhere out of the way. Call it 'return box' or whatever you want.


At this point in the event, if you need the player to 'return' to the last passable area, you can use the event command 'Set Event Location' to the x and y you stored, and the use 'Set Movement Route', followed by the commands provided in the HIME script to move your player to that location. This is possible because of the invisible 'return box' that you created, the player is truly moving toward that. Unfortunately I don't know how to move the player toward an x and y, but this is how you can accomplish it anyway. 


Now as far as disabling movement on certain tiles, I believe you could accomplish that with terrain tags, although I've rarely messed with them and have little experience with them. 


You could set events on those tiles that are activated by player touch or event touch (one might trigger quicker than the other, you'd have to test it)that either turn you away or do something to prevent you from moving.


If it's entire areas, you could use conditional branches to say if $gamePlayer.x is >  and <     as well as $gamePlayer.y in the same fashion. 


I'd need to know a bit more to be more specific.


Finally, I believe if you use the Change Actor Images on the third page of the event calls to change your graphic it should stay that way between maps. 


I'm sure I haven't answered everything, but you know the drill lol
@standardplayerThis is extremely helpful! Thank you so much! The only thing you missed (I think) is how to make your character be able to collide with "on event touch" events. I use these events for enemies rather than random encountes. Could I accomplish this by making the blue tiles in the screenshot say if Bat Collision (switch) is on: turn collision off else turn collision on. And then for the red tiles just have turn collision off? Sorry I don't have much time to test this and if it doesn't work it's better to respond now rather than later.
The way you mentioned above sounds like it would work, although the fact that Through would be on your player makes me think only tinkering with the blue tiles will be necessary. 


Since all of the blue tiles are on the same y coordinate, though, you could just set a condition that activates if $gamePlayer.y == the y of the blue tile -1, since you'd want to stop the player one tile above the blue tiles. 


So the condition could be


if $gamePlayer.y == y of the blue tiles + 1     and 


if Input.isPressed('down')     Stop Player movement, turn player, whatever you want to do. Yanfly has a great script for Disable Map Movement, which also comes with commands to Disable Player movement, then Allow Player Movement. You could use those to stop player movement if they try to move onto that tile. 


I LOVE that little script, it's one of my new must haves 
You could try this plugin as well http://forums.rpgmakerweb.com/index.php?/topic/46972-orange-region-collisions/#comment-470054
Hello @standardplayer. Sorry I have been pretty busy until now. I have tried a few things and am confused about some others.


For the dashing plugin, I don't know if you are able to turn it on and off in the game. It seems like you can only completely disable it or have it always be on.


For returning to your last passable tile. I have changed what I want to happen just a little. Instead of being forced to fly back to the last passable tile, I would rather have this happen: if your character is 5 tiles or closer from a passable tile, you will automatically fly there and if not, you will fall down and die. I don't want this to be a game over death but instead the screen goes black for a few seconds and your character is placed back on the last passable tile he was on. How would I set this up? What exactly would my common event look like?



Last question is how would I make a if statement that checks for your tileset? I decided to make a copy of each tileset and make certain tiles passable instead of turning on through while using the bat.


Thanks!
Hey Zomina, 


                    sorry I just saw your message about 20 mins ago and I'm heading to bed, the but I will have this done hopefully by tomorrow. It's gonna be a bit tricky but I've done a few tests in the last 20 mins and I'm sure I can make everything work. As for the Dashing Plugin, I just suggested to you one I'd found a while back, it wasn't a first choice or anything and I hadn't tested it. I haven't tested this either, but HIME's page says it has the commands you'll need 


http://himeworks.com/2016/01/disable-dashing/


As for the Map Passable bit, I'll get that figured out and explain a bit about loops via events and via script call when I show you a solution. Again, hopefully by tomorrow
Okay, so here's what I've got happening right now.


I don't know how to check for tilesets, I'm sure it can be done but I HIGHLY recommend not using that method, turning through on and off will work absolutely fine, I've got it working myself. It's not perfect because it's not in your project yet, it's in test form, but I've tested it a good bit and it does seem to work. We'll tweak it to fit the way you've envisioned it. 


So,


I've done this using a script I recommend to everyone as a plugin for any project, HIME's Movement Route Commands. This allows you to move the Player toward an event, which is infinitely useful in eventing. This plugin is what's being used to move your character to the last movable spot. Transferring a player to an x and y stored in a variable is no problem, but moving a player toward one can be a pain. This makes it a snap. To make this work, you'll need an event box with no graphic on the maps where you can transform. 


Here's what the event looks like (This is all in one event, with two pages)zomina1.png


Here is the second Page, with parallel triggering and Self Switch A as a condition


Page2  1.pngPage2  2.pngPage2  3.png


So what winds up happening is the moment you leave passable tiles, it stores your location in a variable and then stops the process (so that it doesn't keep updating your location while you're not on passable tiles). If you hit passable tiles again while you're still in the bat mode, it will restart the process. It also tracks which direction you're moving in when you hit unpassable terrain so that it can adjust the x and y accordingly(without this, you'd wind up on the first unpassable tile you hit, not the one before it)


Either way, when the Timer reaches 0, if you are greater than 5 tiles, it will transfer the player to the last passable location. If you are less than 5 tiles away, it will move the invisible event box (I called it 'flybox') to your last passable location so that your player knows where to move, then I use the HIME plugin script call to move the player toward the event. 


Also, you'll need to change certain things like the Timer, fitting it to the time you want or using a condition other than a timer if you'd like. And I have it set up so that you automatically turn into the bat in my test, obviously in your game there would be something causing this to happen. So that stuff will have to be adjusted to fit your environment.


Finally, if there is some penalty for 'dying' while flying (if you are more than 5 tiles away from passable terrain) you'll need to add that in, too.


I'm POSITIVE that this will have bugs when plugged into your maps, because I had no way to test it within your environment. So I'm anticipating further adjustments. But it worked wonderfully in testing, so I'm hoping it won't need too much tinkering. Hit me back with any problems or questions your run into.


**Update** I've found a bug that occurs when you don't actually leave passable tiles during the transformation. Working on it now, sorry ^^


**Update** I've fixed the bugs, everything works right as far as I can tell.
@standardplayer Hey, I have a couple questions? Are the screenshots in order and is all of the event covered in the screen shot (it looks like the top part is missing). Also what is the full script? All I can see is $gameMap.isPassable($gamePlayer.x -5, $gamePlayer.y) || $gameMap.isPassable
$gameMap.isPassable($gamePlayer.x -5, $gamePlayer.y) || $gameMap.isPassable($gamePlayer.x + 5, $gamePlayer.y) || $gameMap.isPassable($gamePlayer.x, $gamePlayer.y + 5) || $gameMap.isPassable($gamePlayer.x, $gamePlayer.y - 5)


Sorry. Above is the long line of conditions that got cutoff in the example. Also ive recut the second page of the event and posted those pictures in a much easier to read layout. Sorry, I messed up on the first post and must have saved over a picture by mistake before posting them. Anyway, plug all that in and let me know if there's any problems
@standardplayer I really appreciate the help but I think I'm just gonna make bat mode unlimited. It will save a lot of time so I can do other things.
No problem, I actually learned plenty by trying to help you with this one ^^ Never actually had the chance to use Map.isPassable, it was fun 

Original thread: https://forums.rpgmakerweb.com/threads/setting-up-a-unique-vehicle-spell.60332/