RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[RMVXA] Event Help: Moving Rock

0 Members and 2 Guests are viewing this topic.

**
Rep: +0/-0Level 38
RMRK Junior
So pushing the rock is normal and all. I set it to move away from player when touched. But when i push it to a wall, it still animates and plays the sound when it's pushed. How do I stop the event from taking place when it is unmovable? More preferably without any switches. Please help!  :ladyj:

Video: https://www.youtube.com/watch?v=pE9ROHXxjJk&feature=youtu.be&noredirect=1

Also please check the script! I know the through ON or OFF options are irrelevant. Ignore  :sdog:  :sdog:

EDIT:
IT WORKS! Thanks @Abigaila!
Also thanks to @Heretic86 for a further fix and an explanation! I am also going to look into your intro to scripting. I need it.

EDIT 2:
http://i1057.photobucket.com/albums/t387/kennysaur/aaaa.jpg
@abi, since the it was set to move away from player, it started moving up when i go to any region behind its row (X marked areas) Im gonna try Heretics for now!
« Last Edit: May 09, 2014, 12:57:23 AM by kennysaur »

***
Rep:
Level 39
N
2014 Zero to Hero
You can do a conditional if to check if the rock's position is at the coordinates against the wall and if it is, you stop execution. If you use this kind of rock in several different places you will have to change the coordinates and use "or" a lot, but this is still the easiest way without scripting as far as I can see.

***
Rep:
Level 70
RMRK Junior
I havent played at all with VXA but in XP, you should be able to play the sound effect from inside the move route, not outside it.

As far as what Abagalia said, there is a little script "trick".  Try figuring out how to use "passable?(new_x, new_y, d)" and put that into a single conditional branch.  Not sure if it can be done in VXA the same way as XP.
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

**
Rep: +0/-0Level 38
RMRK Junior
You can do a conditional if to check if the rock's position is at the coordinates against the wall and if it is, you stop execution. If you use this kind of rock in several different places you will have to change the coordinates and use "or" a lot, but this is still the easiest way without scripting as far as I can see.

Thanks :D I'll try that when i get the chance  :sdog: :sdog:

***
Rep:
Level 39
N
2014 Zero to Hero
So it turns out RPG Maker doesn't allow you to check coordinates in events, so I made you a hybrid solution:

1. Remove through ON and through OFF from the move route, so that only move away from player is left
2. Before you close the move route, uncheck all three checkboxes in the bottom left corner. (Wait for completion, skip, etc.)
3. Insert a Conditional branch after the set move route. Go to tab 4, select "Script" and paste this:

Code: [Select]
$game_map.events[2].y != $game_map.events[2].real_y || $game_map.events[2].x != $game_map.events[2].real_x

4. Move the sound effect to inside the conditional branch
5. Check direction fix in the bottom left

That should work, tell me if it doesn't.

Note that the script refers explicitly to this event (by it's id, 2) so if you want to create new events like this you will have to replace the number 2 with the new event ID.
« Last Edit: May 08, 2014, 10:11:50 PM by Abigaila »

***
Rep:
Level 70
RMRK Junior
Got it.

In your Conditional Branch, put this under Scripts exactly as it is:

Code: [Select]
e = $game_map.events[@event_id]; e.passable?(e.x, e.y, $game_player.direction)

The other thing that needs to be done is to move Play SE to inside your Set Move Route which should be inside your Conditional Branch.  Play SE can be called either from the List of Event Commands or from a Move Route.  Then your Sound Effect will not play if the event can not move.

I used Player Direction to skip other processing because when the Player presses up on a "movable object" like a Rock or a Box, the Player will expect the movable object moves in the direction that they press.  They push up, rock should move up.  If the player pushed up, and the rock moved left or right, that would just seem weird.

This also allows other events to get in the way.  Like another NPC standing behind the rock will prevent the rock from moving.  But if its a bird flying overhead, or a butterfly, any events with Through checked will not interfere with movement of the rock.  Thats already built in to the functionality of "passable?".

---

Intro To Scripting / Overkill Answer

There is another way to do this, and its an easy way to get used to using scripts, even if you dont quite understand them yet.  In your Script Editor window that shows all the scripts for the whole game (hit the F11 key), on the left side, there is a bunch of Scripts listed there.  Go to the very bottom of the list and click on Main.  Then hit the Insert Key on your Keyboard a couple times.  Some new Scripts with no names will be inserted.  Select one of the Blank Names.  Just below the list, click on "Name", and put in a name for this script.  Just so you know its not empty.  Call it something like "move away?".  Then on the Right Side, copy and paste in this code:

Spoiler for:
Code: [Select]
# Most useful if used in a Conditional Branch for an Event.
# XP - Name the class Interpreter
# VX / Ace - Name the class Game_Interpreter

class Interpreter
  #--------------------------------------------------------------------------
  # * Can Move Away From Player
  #
  #   - Returns True if an Event can move away from the Player.
  #   
  #   **Note: Only works on Self Events.  So cant use to call
  #           checks for other events accurately.
  #--------------------------------------------------------------------------
  def can_move_away_from_player?
    # Get the Event (takes less typing)
    e = $game_map.events[@event_id]
    # Direction Always Same as Players
    # This says "yes, event can move away from Player" without actually
    # moving the event.  True is returned which allows Conditional Branches
    # to validate as "conditions met"
    return true if e.passable?(e.x, e.y, $game_player.direction)
  end
end

Note: To use with XP, class MUST be Interpreter.  For either VX or VX Ace, the class MUST be named Game_Interpreter.  I could have set this up to check automatically, but youre not ready for that yet.

The use of this code is exactly the same as the code snippet above.  In your Conditional Branch -> Script, put in "can_move_away_from_player?".  Dont include the quotes, dont put in any text that says the word IF, and DO include the Question Mark.

I think everyone has run into this small snafu before.  Just like in XP that they did fix in Ace, there was no ability to Turn Toward Event, not just the Player.  An option to check if an Event can move away from Player should have been one of those other Conditional Branch Options.  However, with the ability to put in our own scripts, it matters little, but it is more effort and requires more understanding. 

Since so many people have run into this, I took extra time to completely solve this issue.

---

@abi

Code is close, but does the same thing as "passable".  Theory is perfectly sound tho.  One small thing that was missed is that x and y vs real_x and real_y is what theyre used for.  real_x / y determine exact coordinates for pixel perfect rendering.  X/Y just follows the grid of the map.  Translating X into Real X just requires multiplying X by 128.  real_x = x * 128 is used to check if a character is "moving?".
« Last Edit: May 09, 2014, 12:15:50 AM by Heretic86 »
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

**
Rep: +0/-0Level 38
RMRK Junior
So it turns out RPG Maker doesn't allow you to check coordinates in events, so I made you a hybrid solution:

1. Remove through ON and through OFF from the move route, so that only move away from player is left
2. Before you close the move route, uncheck all three checkboxes in the bottom left corner. (Wait for completion, skip, etc.)
3. Insert a Conditional branch after the set move route. Go to tab 4, select "Script" and paste this:

Code: [Select]
$game_map.events[2].y != $game_map.events[2].real_y || $game_map.events[2].x != $game_map.events[2].real_x

4. Move the sound effect to inside the conditional branch
5. Check direction fix in the bottom left

That should work, tell me if it doesn't.

Note that the script refers explicitly to this event (by it's id, 2) so if you want to create new events like this you will have to replace the number 2 with the new event ID.
Got it.

In your Conditional Branch, put this under Scripts exactly as it is:

Code: [Select]
e = $game_map.events[@event_id]; e.passable?(e.x, e.y, $game_player.direction)

The other thing that needs to be done is to move Play SE to inside your Set Move Route which should be inside your Conditional Branch.  Play SE can be called either from the List of Event Commands or from a Move Route.  Then your Sound Effect will not play if the event can not move.

I used Player Direction to skip other processing because when the Player presses up on a "movable object" like a Rock or a Box, the Player will expect the movable object moves in the direction that they press.  They push up, rock should move up.  If the player pushed up, and the rock moved left or right, that would just seem weird.

This also allows other events to get in the way.  Like another NPC standing behind the rock will prevent the rock from moving.  But if its a bird flying overhead, or a butterfly, any events with Through checked will not interfere with movement of the rock.  Thats already built in to the functionality of "passable?".

---

Intro To Scripting / Overkill Answer

There is another way to do this, and its an easy way to get used to using scripts, even if you dont quite understand them yet.  In your Script Editor window that shows all the scripts for the whole game (hit the F11 key), on the left side, there is a bunch of Scripts listed there.  Go to the very bottom of the list and click on Main.  Then hit the Insert Key on your Keyboard a couple times.  Some new Scripts with no names will be inserted.  Select one of the Blank Names.  Just below the list, click on "Name", and put in a name for this script.  Just so you know its not empty.  Call it something like "move away?".  Then on the Right Side, copy and paste in this code:

Spoiler for:
Code: [Select]
# Most useful if used in a Conditional Branch for an Event.
# XP - Name the class Interpreter
# VX / Ace - Name the class Game_Interpreter

class Interpreter
  #--------------------------------------------------------------------------
  # * Can Move Away From Player
  #
  #   - Returns True if an Event can move away from the Player.
  #   
  #   **Note: Only works on Self Events.  So cant use to call
  #           checks for other events accurately.
  #--------------------------------------------------------------------------
  def can_move_away_from_player?
    # Get the Event (takes less typing)
    e = $game_map.events[@event_id]
    # Direction Always Same as Players
    # This says "yes, event can move away from Player" without actually
    # moving the event.  True is returned which allows Conditional Branches
    # to validate as "conditions met"
    return true if e.passable?(e.x, e.y, $game_player.direction)
  end
end

Note: To use with XP, class MUST be Interpreter.  For either VX or VX Ace, the class MUST be named Game_Interpreter.  I could have set this up to check automatically, but youre not ready for that yet.

The use of this code is exactly the same as the code snippet above.  In your Conditional Branch -> Script, put in "can_move_away_from_player?".  Dont include the quotes, dont put in any text that says the word IF, and DO include the Question Mark.

I think everyone has run into this small snafu before.  Just like in XP that they did fix in Ace, there was no ability to Turn Toward Event, not just the Player.  An option to check if an Event can move away from Player should have been one of those other Conditional Branch Options.  However, with the ability to put in our own scripts, it matters little, but it is more effort and requires more understanding. 

Since so many people have run into this, I took extra time to completely solve this issue.

---

@abi

Code is close, but does the same thing as "passable".  Theory is perfectly sound tho.  One small thing that was missed is that x and y vs real_x and real_y is what theyre used for.  real_x / y determine exact coordinates for pixel perfect rendering.  X/Y just follows the grid of the map.  Translating X into Real X just requires multiplying X by 128.  real_x = x * 128 is used to check if a character is "moving?".

Thanks! Im gonna try all of what you guys said  ;D Amazing answers <3

EDIT:
IT WORKS! Thanks @Abigaila!
Also thanks to @Heretic86 for a further fix and an explanation! I am also going to look into your intro to scripting. I need it.

EDIT 2:
http://i1057.photobucket.com/albums/t387/kennysaur/aaaa.jpg
@abi, since the it was set to move away from player, it started moving up when i go to any region behind its row (X marked areas) Im gonna try Heretics for now!

EDIT 3:
@Heretic86 Your script still has that same movement as the picture i posted a link of. For the time being, i'll set it to move down only until i figure out or if anyone can help me fix this too! :D
« Last Edit: May 09, 2014, 01:23:09 AM by kennysaur »

***
Rep:
Level 70
RMRK Junior
Img doesnt come up for me for some reason.  I didnt have any troubles, other than thinking that maybe the script should also return if "e.moving?", but should work fine in theory.  Does the player have Direction Fix turned on?  Not the event, the Player...

Edit: Any other scripts installed?
« Last Edit: May 10, 2014, 01:34:43 AM by Heretic86 »
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

**
Rep: +0/-0Level 38
RMRK Junior
Img doesnt come up for me for some reason.  I didnt have any troubles, other than thinking that maybe the script should also return if "e.moving?", but should work fine in theory.  Does the player have Direction Fix turned on?  Not the event, the Player...

Edit: Any other scripts installed?

How do you turn on Direction Fix for the player?
And i have a ton of scripts installed.

***
Rep:
Level 70
RMRK Junior
Direction fix for player can be turned on and off in a Move Route.  That image came up fine for me.  Can you put the other image I couldnt see up  on the same host?

It shouldnt make a difference where the small script I wrote is installed cuz it just adds a new definition, but just out of curiousity, where is it installed?
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

**
Rep: +0/-0Level 38
RMRK Junior
Direction fix for player can be turned on and off in a Move Route.  That image came up fine for me.  Can you put the other image I couldnt see up  on the same host?

It shouldnt make a difference where the small script I wrote is installed cuz it just adds a new definition, but just out of curiousity, where is it installed?

It is installed right in the middle of the pic in the <<Forum Help Stuff>> section, also below the <<Hime Works>> section.  ^-^

***
Rep:
Level 70
RMRK Junior
Does the trick work in other projects with no other scripts installed?
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!