• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Event with tileset image that consider terrain tag

  • 44
    Posts
    7
    Years
    Hello everyone!
    This topic is not easy to explain but I will try my best. When you build up an event,it is possible to assign to the event an image from the tileset currently in use on the map. When you do, the event will have the same passability and the same priority of the tile used.
    Here comes the question: Is it possible without too many codes to have the event with also the same Terrain Tag of the choosen tile?
    For example: an event with a ledge as image; at the moment the event does not have the properties of a ledge.
    The same can be said for bridges, water,etc..

    But I think that just the possibility to make that work for ledges and bridges would be very useful.
    Thanks in advance for whoever read the post :)
     
    This seems pretty interesting!

    From what I can tell, this seems to work:

    In the Game_Map script, find def deepBush?(x,y), def bush?(x,y), and def terrain_tag(x,y,countBridge=false). Each of these methods has these two lines:

    Code:
    for i in [2, 1, 0]
      tile_id = data[x, y, i]
      ...

    In the three methods I mentioned above, replace these two lines with this:
    Code:
    for i in [events.values.find { |e| e.x == x && e.y == y }, 2, 1, 0]
      next if i.nil?
      if i.is_a?(Numeric)
        tile_id = data[x, y, i]
      else
        tile_id = pbGetActiveEventPage(i).graphic.tile_id
        next if tile_id == 0
      end
      ...
    (leave out the dots obviously; that's the rest of the code)


    Then, UNLESS you have my Overworld Shadows resource, you should add this in a new script section above Main:
    Code:
    unless defined?(pbGetActiveEventPage)
      def pbGetActiveEventPage(event, mapid = nil)
        mapid ||= event.map.map_id if event.respond_to?(:map)
        pages = (event.is_a?(RPG::Event) ? event.pages : event.instance_eval { @event.pages })
        for i in 0...pages.size
          c = pages[pages.size - 1 - i].condition
          ss = !(c.self_switch_valid && !$game_self_switches[[mapid,
              event.id,c.self_switch_ch]])
          sw1 = !(c.switch1_valid && !$game_switches[c.switch1_id])
          sw2 = !(c.switch2_valid && !$game_switches[c.switch2_id])
          var = true
          if c.variable_valid
            if !c.variable_value || !$game_variables[c.variable_id].is_a?(Numeric) ||
               $game_variables[c.variable_id] < c.variable_value
              var = false
            end
          end
          if ss && sw1 && sw2 && var # All conditions are met
            return pages[pages.size - 1 - i]
          end
        end
        return nil
      end
    end


    I gotta say though: this will most likely increase lag on maps with a lot of events. For some reason, these methods are called EVERY frame (even when standing still for some reason?), and it determines the position of every event and the active event page if it finds on you're currently standing on. So that's a lot of processing to do every frame. If you don't want the bush or deep bush effects on the events, I suggest leaving those out. They'd only increase lag and if you're never gonna use them, there's no reason to have them.
     
    Last edited:
    Thank you so much Marin! As soon as possible I will implement it and see if it adds significant lag.

    I must admit that one of my main purposes is to reduce the lag where possible, and if this script will be in contrast with this principle, I will be forced to give up, even if that would decrease in a large way the possibility to make particular puzzles into the game. I hope for the best :) Thank you again!
     
    I'm gonna look into why those methods are being called every frame (because that's just a waste of processing power - if that could be reduced, the FPS issue would also be resolved).
     
    The script works perfectly! :) I noticed just a bit of lag, but I will see better the situation with my other pc (that is faster and more fluid). I avoided the bush part because it is not in my interest and for lag reasons. I think that changing these methods, in order to not call them every frame, would be a great addition. Maybe someday I will post a small guide on the usefulness of these methods you wrote :) They open a new field for map making.
    Thanks again Marin! If you will ever get new results I will be happy to test them out :)
     
    Back
    Top