[ACE] Event pass through another event

Hello, i'm doing an enhanced version of CSCA Dungeon Tools (here), but i'm having some problems with event passing through another events.

In that script you have to setup your map regions where you want your tool to travel (unpassable tiles), Exemple: A pit with a switch that you have to shoot an arrow to activate. The pit will have the regions configured so your arrow can fly through it.

But there's one problem, let's say i'll make birds that fly around that pit so you have to time your shot to hit the swith. Those events will be flying over the region configured, and then the arrow will pass through then instead of colliding. I need help to fix that since i don't see where i can change that. The only method he made for checking passability is that:



Code:
def csca_check_through
    csca_get_event
    d = @csca_event.direction
    if (region_id(@csca_event.x, @csca_event.y) == REGION_ID1) ||
    (d == 2 && region_id(@csca_event.x, @csca_event.y) == REGION_ID2) ||
    (d == 4 && region_id(@csca_event.x, @csca_event.y) == REGION_ID3) ||
    (d == 6 && region_id(@csca_event.x, @csca_event.y) == REGION_ID4) ||
    (d == 8 && region_id(@csca_event.x, @csca_event.y) == REGION_ID5) ||
    ((d == 8 || d == 4) && region_id(@csca_event.x, @csca_event.y) == REGION_ID6) ||
    ((d == 8 || d == 6) && region_id(@csca_event.x, @csca_event.y) == REGION_ID7) ||
    ((d == 2 || d == 4) && region_id(@csca_event.x, @csca_event.y) == REGION_ID8) ||
    ((d == 2 || d == 6) && region_id(@csca_event.x, @csca_event.y) == REGION_ID9) ||
    ((d == 2 || d == 8) && region_id(@csca_event.x, @csca_event.y) == REGION_ID10) ||
    ((d == 4 || d == 6) && region_id(@csca_event.x, @csca_event.y) == REGION_ID11) ||
    ((d == 4 || d == 6 || d == 8) && region_id(@csca_event.x, @csca_event.y) == REGION_ID12) ||
    ((d == 4 || d == 6 || d == 2) && region_id(@csca_event.x, @csca_event.y) == REGION_ID13) ||
    ((d == 2 || d == 8 || d == 4) && region_id(@csca_event.x, @csca_event.y) == REGION_ID14) ||
    ((d == 2 || d == 8 || d == 6) && region_id(@csca_event.x, @csca_event.y) == REGION_ID15) ||
    @hookshot_reverse_dir == true
	  @csca_event.csca_change_through(true)
    else
	  @csca_event.csca_change_through(false)
    end
  end
I don't think there is a problem within that code but i do think i'll need to write another method to cover events prioritys within that region_ids, so any leads to how i must do that or there's already a way?

Thanks in advice.
Tick the 'passage' box in the event setup screen which is in the 'options' box under the graphic it uses. This will make the tool pass through it.
Tick the 'passage' box in the event setup screen which is in the 'options' box under the graphic it uses. This will make the tool pass through it.
I think you didn't understood, i want to prevent the event passing through another event. As it is, the tool will pass through another event.
Ooooh, now I see.

How 'bout this:

Use an invisible tile on tab B-E of the tileset which you set as passable in the database instead of the regions you put down, but make sure the player can't pass the pit by having at least one 'line of pit' without this passable tile, and make sure the birds don't fly over this line. You do have to put down region tiles on this line, of course.

Now make sure the birds have the priority 'same as player' and watch how your arrow will only fly over if it doesn't hit a bird.

I hope you understand what I typed out.... Tell me if you don't and I'll screenshot some stuff.
Your sugestion is good but its just a workaround and while it fixes the problem exemplified there might appear another cases wheres this solution won't work (my enhanced version will let you create your own tools and specify how they work). I'm asking for logic leads or places i could see and edit to make this work without specifics procedures like this.

But thanks, i'll see if i can make something with tiles passability instead of region_id.
Wahhhhhh ok, so this took some time... BUT, I think I may have found the solution!



Code:
  def csca_check_through
    if check_passable_event == false
	  @csca_event.csca_change_through(false)
    else
    csca_get_event
    d = @csca_event.direction
    if (region_id(@csca_event.x, @csca_event.y) == REGION_ID1) ||
    (d == 2 && region_id(@csca_event.x, @csca_event.y) == REGION_ID2) ||
    (d == 4 && region_id(@csca_event.x, @csca_event.y) == REGION_ID3) ||
    (d == 6 && region_id(@csca_event.x, @csca_event.y) == REGION_ID4) ||
    (d == 8 && region_id(@csca_event.x, @csca_event.y) == REGION_ID5) ||
    ((d == 8 || d == 4) && region_id(@csca_event.x, @csca_event.y) == REGION_ID6) ||
    ((d == 8 || d == 6) && region_id(@csca_event.x, @csca_event.y) == REGION_ID7) ||
    ((d == 2 || d == 4) && region_id(@csca_event.x, @csca_event.y) == REGION_ID8) ||
    ((d == 2 || d == 6) && region_id(@csca_event.x, @csca_event.y) == REGION_ID9) ||
    ((d == 2 || d == 8) && region_id(@csca_event.x, @csca_event.y) == REGION_ID10) ||
    ((d == 4 || d == 6) && region_id(@csca_event.x, @csca_event.y) == REGION_ID11) ||
    ((d == 4 || d == 6 || d == 8) && region_id(@csca_event.x, @csca_event.y) == REGION_ID12) ||
    ((d == 4 || d == 6 || d == 2) && region_id(@csca_event.x, @csca_event.y) == REGION_ID13) ||
    ((d == 2 || d == 8 || d == 4) && region_id(@csca_event.x, @csca_event.y) == REGION_ID14) ||
    ((d == 2 || d == 8 || d == 6) && region_id(@csca_event.x, @csca_event.y) == REGION_ID15) ||
    @hookshot_reverse_dir == true
	  @csca_event.csca_change_through(true)
    else
	  @csca_event.csca_change_through(false)
    end
    end
  end

  def check_passable_event(e=@csca_event)
    arr = letsdothis(ahead(@csca_event,1,@csca_event.direction))
    if arr != nil && $game_map.events[arr].priority_type ==1 &&
	    $game_map.events[arr].through == false
	    return false
    else
	    return true
    end
  end

  def ahead(e,r,d)
    ev = @csca_event
    v = [ev.x,ev.y]
    case d
	  when 2;  v[1] += r
	  when 4;  v[0] -= r
	  when 6;  v[0] += r
	  when 8;  v[1] -= r
	  when 3;  v[1] += r; v[0] -= r
	  when 7;  v[1] -= r; v[0] -= r
	  when 5;  v[1] -= r; v[0] += r
	  when 1;  v[1] += r; v[0] += r
    end
    return v
  end

  def letsdothis(w)
    evs = $game_map.events_xy(w[0],w[1])
    return nil if evs.empty?
    evs.each{ |e|
	  return e.id if e.priority_type > 0
    }
    return evs[0].id
  end
Change that old check thingy into this one and you'll be all set, methinks.

Now I'd like some cookies and/or credit since this kept me from working on eventing tetris in Ace >=o
Thanks! Your code worked just fine, now i can continue with my enhanced version. Credits will be provided 🙂

Original thread: https://forums.rpgmakerweb.com/threads/ace-event-pass-through-another-event.2845/