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.

[VX] need flying script

I have a small problem; I'm making a game and I want that at somepoint the player will be able to fly for a small distance so they can reach certain areas. but I'm not really good at scripting (I think it would work better with a script).

I need this script to have the following things in it:
- when a button is being pressed the player starts flying, but when the button is being released the player
   stops flying.
- the player can only fly for a certain amouth of tiles, which should be controlled with a variable (so the
   player can learn to fly further).
- If the player reached the maximum distance he can fly then he will fall on the ground.
- if the player stops flying on a unpasseble tile, he should be transported back to the point where he started
   flying and lose a certain amouth of HP (for example 10%).
- it should be posseble to activate the script with a switch.

could anyone help me out here! (I hope it's not to hard to do this)
I need the script for rpg maker VX
 
If you want, you can try this event system.

It's actually pretty easy and useful. I can show you a method to change it so the player can only fly for a certain number of tiles, and how to make the player teleport back to their starting position if they land on an impassable tile.

Of course, you can always wait for a scripter to help you make it too, if it's too much of a bother.
 
thanx, but I also need that there's a 'flying button', and you start flying when you start pressing the button, and stop flying when you release the button (stop pressing it).
but thanx anyway
 
and guesse what, another bump!


if anyone´s trying this or thinks it´s imposseble to do please say something. Right now my project got to a dead end I need this to get further with it.
 

Akin

Member

It's not impossible its just tricky has a doubled edge to it.

Most of this can be done solely with events. Just make a parrell process common event that detects key input. Then when keyinput is detected activate "trough" on the player movement to make them pass through all impassible terrain. When the key stops being help remove "through." To detect max movement just setup another variable and whenever they take a set subtract 1 from it. If it reaches 0 force them to land.

The only tricky part is when they land. Detecting if the tile they landed on is impassible or not. I'm not really sure how to handle that. You could I guess use an anti-lag script and setup an event on every impassible tile with "player touch" as the activation. That seems inefficient though.

In the end I don't really think this needs to be done with scripting. Except for maybe one part that I myself am not sure how to do it. Hope that helps and good luck.
 
What Samot said would work perfectly with just events. With scripts, if you examine Game_Character(or the VX equivalents at least), Scene_Map, etc. it should give you an idea about passabilities.
 

Haki

Member

You can do it with common events in Rpg Maker XP. I don't know about VX 'cause I don't have it.
Create a skill named "Fly" and two common events named "Fly1" and "Fly2".
Name one switch "Flying". You will need 9 variables. Name them: "MAP ID", "MaxDistance", "Distance", "Start X", "Start Y", "Prev X", "Prev Y", "Next X", "Next Y".
The skill should be using common event "Fly1"
This common event should look something like this (I'll write it short):

Code:
Through = On
Variable "Distance" = Variable "MaxDistance"
Variable "MAP ID" = Map ID 
Variable "Start X" = Player X
Variable "Start Y" = Player Y
Variable "Prev X" = Player X
Variable "Prev Y" = Player Y
Variable "Next X" = Player X
Variable "Next Y" = Player Y
Remove skill "Fly"
Switch "Flying = On

The second common event should be a parallel process acivated by switch "Flying".
Code:
Variable "Next X" = Player X
Variable "Next Y" = Player Y
Conditional Branch "Next X" != "Prev X"
    Variable "Distance" -= 1
    Variable "Prev X" = Player X
    Variable "Prev Y" = Player Y
    Conditional Branch "Distance" == 0
        Conditional Branch Script $game_map.passable?($game_player.x,$game_player.y,0)
        Switch "Flying" = Off
        Through = Off
        Add skill "Fly"
        Else
        Teleport by Variables "Start X", "Start Y", "MAP ID"
        Switch "Flying" = Off
        Through = Off
        Add skill "Fly"
        End
    End
End
Conditional Branch "Next Y" != "Prev Y"
    Variable "Distance" -= 1
    Variable "Prev X" = Player X
    Variable "Prev Y" = Player Y
    Conditional Branch "Distance" == 0
        Conditional Branch Script $game_map.passable?($game_player.x,$game_player.y,0)
        Switch "Flying" = Off
        Through = Off
        Add skill "Fly"
        Else
        Teleport by Variables "Start X", "Start Y", "MAP ID"
        Switch "Flying" = Off
        Through = Off
        Add skill "Fly"
        End
    End
End
 

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