• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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.

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

Telemetius

Tele*
267
Posts
9
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:

    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.
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • 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.
     

    Telemetius

    Tele*
    267
    Posts
    9
    Years
  • 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
    }
     
    1,224
    Posts
    10
    Years
  • 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
     

    Telemetius

    Tele*
    267
    Posts
    9
    Years
  • 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