Chaos Project

RPG Maker => Event Systems => Event System Troubleshooting => Topic started by: Nath on September 04, 2016, 01:07:00 pm

Title: [RESOLVED] [XP] Touch trigger on passable tile in a non-passable direction?
Post by: Nath on September 04, 2016, 01:07:00 pm
This Events Troubleshooting section seems pretty sparse, but... I have a thing. :P

So here's my situation: I have a place on one map that has a ledge, which can be hopped down from, but not back up onto, as pictured below.

Spoiler: ShowHide
(http://i64.tinypic.com/34xjbyr.png)


The events shown are set to trigger on Player Touch, and they check for the direction the player is facing, then hop down from the ledge. The lower ones drop 2 squares down, whereas the ones on the right edge drop down one, and right one.

Spoiler: ShowHide
(http://i63.tinypic.com/2uf7zol.png)


The issue I'm having is that only these circled ones work, because the tile beneath the events are impassable. These ones work perfectly, as intended.

Spoiler: ShowHide
(http://i64.tinypic.com/kbau00.png)


These others do not work, because RMXP expects the player to have to actually walk on top of the tile to trigger it. The player can't actually do that, because the ledge tile doesn't allow walking to and from it's right edge.

Spoiler: ShowHide
(http://i63.tinypic.com/2rfshup.png)


Moving the events to the top of the ledge would cause the player to jump as soon as they stand there, rather than having to actually move toward the edge, which is undesirable. My current (and hopefully temporary) fix is to move the events up to the top and have them trigger on the Action Button instead, but this is... suboptimal...

Is there any solution to this that I'm just not clever enough to figure out?
Title: Re: [XP] Touch trigger on passable tile in a non-passable direction?
Post by: Blizzard on September 04, 2016, 01:23:31 pm
There is a way, but it's a bit of manual work. Once you jump down, turn on the "Through" flag on the 3 events. When you reenter the map depending on where you enter (not the two entrances in the top right), you have to redo that with a parallel process event.

There is also a way to do this more conveniently with a script by using terrain tags.
Title: Re: [XP] Touch trigger on passable tile in a non-passable direction?
Post by: Nath on September 04, 2016, 01:35:54 pm
Well, the issue is that I can't jump down in the first place.

I might have to resort to... scripting   D:

EDIT: In the meantime, I solved the issue by using other events (placed on the ledge) to give the jump events impassable graphics when I'm adjacent to them. It's a very silly and inefficient solution, but I'm not quite skilled enough at scripting to know how to use terrain tags, yet.
Title: Re: [Resolved?] [XP] Touch trigger on passable tile in a non-passable direction?
Post by: KK20 on September 05, 2016, 05:59:17 pm
Can you try using this code and do what you were normally doing with your events? I changed it so that the game triggers the touch if the direction the player is moving in is impassable along with if the event's location cannot pass through the opposite direction (e.g. checks if player cannot move to the right OR if the event cannot move to the left).

class Game_Event
  #--------------------------------------------------------------------------
  # * Determine if Over Trigger
  #    (whether or not same position is starting condition)
  #--------------------------------------------------------------------------
  def over_trigger?(x = @x, y = @y, d = 0)
    # If not through situation with character as graphic
    if @character_name != "" and not @through
      # Starting determinant is face
      return false
    end
    # If this position on the map is impassable
    if !$game_map.passable?(x, y, d) || !$game_map.passable?(@x, @y, 10 - d)
      # Starting determinant is face
      return false
    end
    # Starting determinant is same position
    return true
  end
end

class Game_Player
  #--------------------------------------------------------------------------
  # * Touch Event Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_touch(x, y, d = 0)
    # Direction the character is moving
    d = case [@x - x, @y - y]
        when [-1,0] then 6 # Right
        when [1,0]  then 4 # Left
        when [0,-1] then 2 # Down
        when [0,1]  then 8 # Up
        else 0
        end
    result = false
    # If event is running
    if $game_system.map_interpreter.running?
      return result
    end
    # All event loops
    for event in $game_map.events.values
      # If event coordinates and triggers are consistent
      if event.x == x and event.y == y and [1,2].include?(event.trigger)
        # If starting determinant is front event (other than jumping)
        if not event.jumping? and not event.over_trigger?(@x, @y, d)
          event.start
          result = true
        end
      end
    end
    return result
  end
end
Title: Re: [Resolved?] [XP] Touch trigger on passable tile in a non-passable direction?
Post by: Nath on September 06, 2016, 03:53:23 pm
Woo! It works perfectly!  :D

KK20's Special Touching script does the trick!  :naughty: