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.

Play SE every 20 seconds.

Hello,

I need an script for an event or whatever for a frog who plays every 20 seconds the SE 'Small 03'. But you can only hear it when your near him by 5 places (feet, or whatever it is).

I'd like to have some help ;)

Edit: In RPG Maker XP ofcourse.
 
All right, you can do it with eventing alone, but it'll be just tiny bit complicated.

While you're on the map, you'll need a parallel event that continuously sets two different variables: one to the players Map X and the other to the player's Map Y. (It's under characters in the variable control options)

Next, if your frog is sitting on one place, just set 2 variables one time to its Map X and Y. If it moves, do it in the same parallel event as before.

Now, in that parallel event, you need a conditional branch that uses a script as a condition. Here's what you enter, replacing my variables ids (the numbers in []) with the variables you're using:

Code:
 

@>Conditional Branch: Script [b]$game_variables[playerx] - $game_variables[frogx] <= 5 && $game_variables[playerx] >= -5[/b]

   @>Conditional Branch: Script [b]$game_variables  [playery] <= 5 && $game_variables[frogy] >= -5[/b]

   @>Play SE "Small 03"

 

So, put that code in conditional branches, the second one INSIDE the first, because they both have to be true. Then, within the second branch, play the sound, and then do this:

Code:
 

@> Loop

   @>Wait: 35 frames

   @>Control Variable [005] += 1 (add one)

   @> Conditional Branch: Varible [005] == 20

      @> Break loop

   :Branch End

:Repeat Above

 

That SHOULD work. If you have any questions or problems, let me know.

EDIT: Oh! And make sure you set your counter variable (the one you're adding to in your loop) back to zero before you start the loop or your frog will keep going off every second. LOL
 
I think I did something wrong, because I get this message while testplaying:

14twjer.png


What did I wrong:
nn9rf9.png

20sdf14.png
 
In place of the [playerx] or [frogy] and the other two, you need to put in the variables ID of the variable you're using for that coordinate.

For example, if you've set variables 001 to the Player's Map X, you'll put: $game_variables[1]. (You don't need the leading zeros).
 

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