• 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.
  • There is an important update regarding account security and 2FA. Please click here for more information.
  • 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.
  • Imgur has blocked certain regions from viewing any images uploaded to their site. If you use Imgur, please consider replacing any image links/embeds you may have on PokéCommunity so everyone can see your images. Click here to learn more.

[Scripting Question] Question about tweaking "def passable?".

Telemetius

Tele*
  • 267
    Posts
    11
    Years
    Hello forum, it's been a while since i posted something here.

    I've been trying to tweak the method that checks if the player or the events can walk somewhere. It's called "def passable?" and it's located in the "Game_map" class.
    What I'm trying to do is to force a certain event to never leave a specific terrain tag area if it's name is "Incontro".
    Here's what I did so far:

    This is the original method with what I added:

    Spoiler:

    It works well until the event tries to exit his area, then I receive the error:

    [PokeCommunity.com] Question about tweaking "def passable?".


    I suppose that self_event doesn't like names.
    Is there anything else I can do at this point?

    Thank you for your help.
     
    Hey there,

    I think the problem is with the "if self_event.name=="Incontro"" part. According to the error message the "self_event" is nil, as to say empty and therefore it can't use the .name on it. Maybe you should find a different way to address the event. Maybe it could work if you use "event.name" instead.
     
    Update

    Turns out that implementing a new "onStepTakenFieldMovement" was better. It's a roundabout method to keep the npc in the area but it works.

    Of course if anyone has a better solution I'm open to suggestions.

    For those interested paste this in PFieldField into the Field movement section:

    Code:
    Events.onStepTakenFieldMovement+=proc{|sender,e|
      event=e[0]
      spriteset=e[0]
      map=spriteset.map
      if $scene.is_a?(Scene_Map)
        currentTag=pbGetTerrainTag(event)
        for i in map.events.keys
        if map.events[i].name=="Incontro"  && !PBTerrain.isGrass?(pbGetTerrainTag(map.events[i],true))
            map.events[i].move_backward
        end
        end
      end
    }
     
    The thing to consider here, for you original problem, is that self_event has the possibility to be null, so you'd just have to do validation first.

    Code:
    if !self_event.nil? && self_event.name=="Incontro" && !PBTerrain.isGrass?($game_map.terrain_tag(newx,newy))
        return 
    end
     
    The thing to consider here, for you original problem, is that self_event has the possibility to be null, so you'd just have to do validation first.

    Code:
    if !self_event.nil? && self_event.name=="Incontro" && !PBTerrain.isGrass?($game_map.terrain_tag(newx,newy))
        return 
    end

    Oh so that was the problem, alright thanks a lot!
     
    Back
    Top