RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Quick Question

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 82
I am using a vehicle system and I'm in need of a manipulation in the script. It calls for the actor's graphic to be saved and restored when the vehicle is exited. I wanted a way to change it so that it will save the actor who is in the first party slott as opposed to a single specific actor. Here is the script:
Code: [Select]
class Game_Character
  def passable?(x, y, d)
   
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
   
    # If coordinates are outside of map
    unless $game_map.valid?(new_x, new_y)
      return false
    end
   
    # If through is ON
    if @through
      return true
    end
       
    # If unable to leave first move tile in designated direction
    unless $game_map.passable?(x, y, d, self)
      return false
    end
   
    # If unable to enter move tile in designated direction
    unless $game_map.passable?(new_x, new_y, 10 - d)
      return false
    end
       
    #check terrain for vehicle
    check_terrain(new_x, new_y)   
     
    # Loop all events
    for event in $game_map.events.values
      # If event coordinates are consistent with move destination
      if event.x == new_x and event.y == new_y
        @state = true
        # If through is OFF
        unless event.through
          # If self is event
          if self != $game_player
            return false
          end
          # With self as the player and partner graphic as character
          if event.character_name != ""
            return false
          end
        end
      end
    end
   
    if @state == false
      return false
    end     
   
    # If player coordinates are consistent with move destination
    if $game_player.x == new_x and $game_player.y == new_y
      # If through is OFF
      unless $game_player.through
        # If your own graphic is the character
        if @character_name != ""
          return false
        end
      end
    end
     
   
    return true
   
  end
 
  #--------------------------------------------------------------------------
  # * Check the terrain for the vehicle
  #   @terrain (0=none, 1=river, 2=ocean, 3=air, 4=ground)
  #   @vehicle (0=foot, 1=canoe, 2=boat, 3=dragon)
  #   @state (true=passable tile, false=unpassable tile)
  #--------------------------------------------------------------------------
  def check_terrain(new_x, new_y) 
    @state = false
    @terrain = $game_map.terrain_tag(new_x, new_y)
    @vehicle = $game_variables[1]
   
    @state = true if @vehicle == 0 && @terrain == 4 #foot & ground
    @state = true if @vehicle == 0 && @terrain == 5
    @state = true if @vehicle == 0 && @terrain == 6
    @state = true if @vehicle == 1 && @terrain == 4  #canoe & river
    @state = true if @vehicle == 2 && @terrain == 2  #boat & ocean
    @state = true if @vehicle == 3                   #dragon
    @state = true if @terrain == 0
  end

end

class Game_Player < Game_Character
 
  alias in_vehicle_alias update
  #--------------------------------------------------------------------------
  # * Memorize actor graphic
  #--------------------------------------------------------------------------     
  def actor_memorize
    @actor_name = $game_actors[1].character_name
    @actor_hue = $game_actors[1].character_hue
    @battler_name = $game_actors[1].battler_name
    @battler_hue = $game_actors[1].battler_hue
    return true
  end

  #--------------------------------------------------------------------------
  # * Restore actor graphic
  #--------------------------------------------------------------------------     
  def actor_restore
    actor = $game_actors[1]
    actor.set_graphic(@actor_name.to_s, @actor_hue, @battler_name.to_s, @battler_hue)
    $game_player.refresh
    return true
  end   
 
  #--------------------------------------------------------------------------
  # * Enter a vehicle
  #--------------------------------------------------------------------------       
  def enter_vehicle(type)
   
    $game_system.menu_disabled = true
    $game_system.save_disabled = true   
   
    if type != "dragon"
      @through = true
      move_forward
      @through = false   
    end
   
    actor_memorize
    actor = $game_actors[1]   
    actor.set_graphic(type, @actor_hue, @battler_name.to_s, @battler_hue)
   
    $game_switches[1] = false    #Canoe Off     
    $game_switches[2] = false    #Boat Off     
    $game_switches[3] = false    #Dragon Off         
   
    if type == "Caravan"
      $game_variables[1] = 1       #set terrian
      $game_switches[1] = true    #Canoe On
      Audio.bgm_play("Audio/BGM/047-Positive05", 100, 100) #play canoe music
 
    elsif type == "boat"
      $game_variables[1] = 2       #set terrian
      $game_switches[2] = true    #Boat On     
      Audio.bgm_play("Audio/BGM/Crvantes", 100, 100) #play ship music
     
    elsif type == "dragon"
      $game_variables[1] = 3       #set terrian
      $game_switches[3] = true    #Dragon On 
      Audio.bgm_play("Audio/BGM/045-Positive03", 100, 100) #play dragon music
     
    end
   
    $game_player.refresh
    $game_map.refresh
   
    return true
  end

  #--------------------------------------------------------------------------
  # * Enter a vehicle
  #--------------------------------------------------------------------------       
  def exit_vehicle

    $game_system.menu_disabled = true   
    $game_system.save_disabled = true
   
    if @terrain == 4
           
      if $game_switches[1] == true      #getting off canoe
        canoe = $game_map.events[2]     #get canoe event
        canoe.moveto(x, y)              #move to player's x, y coords
        $game_switches[1] = false       #Canoe Off   
        $game_variables[4] = x          #set canoe x coord
        $game_variables[5] = y          #set canoe y coord
        @through = true
        move_forward
        @through = false         
       
      elsif $game_switches[2] == true   #getting off boat
        boat = $game_map.events[8]      #get boat event
        boat.moveto(x, y)               #move to player's x, y coords       
        $game_switches[2] = false       #Boat Off   
        $game_variables[2] = x          #set boat x coord
        $game_variables[3] = y          #set boate y coord 
        @through = true
        move_forward
        @through = false                 
       
      elsif $game_switches[3] == true   #getting off dragon
        dragon = $game_map.events[2]    #get dragon event
        dragon.moveto(x, y)             #move to player's x, y coords       
        $game_switches[3] = false       #Dragon Off   
        $game_variables[6] = x          #set dragon x coord
        $game_variables[7] = y          #set dragon y coord
      end
     
      # get off vehicle
      actor_restore
   
      # reset terrain
      $game_variables[1] = 0           
   
      # play walking music
      Audio.bgm_play("Audio/BGM/044-Positive02", 100, 100) #play music
     
      $game_player.refresh 
      $game_map.refresh   
   
    end
 
  end
 
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    in_vehicle_alias
    # if not on ground terrain, check for boat exit
    if $game_variables[1] != 0
      if Input.trigger?(Input::C)
        exit_vehicle
      end   
    end
  end
 
end

The issue lies in lines 95 - 114:
Code: [Select]
#--------------------------------------------------------------------------
  # * Memorize actor graphic
  #--------------------------------------------------------------------------     
  def actor_memorize
    @actor_name = $game_actors[1].character_name
    @actor_hue = $game_actors[1].character_hue
    @battler_name = $game_actors[1].battler_name
    @battler_hue = $game_actors[1].battler_hue
    return true
  end

  #--------------------------------------------------------------------------
  # * Restore actor graphic
  #--------------------------------------------------------------------------     
  def actor_restore
    actor = $game_actors[1]
    actor.set_graphic(@actor_name.to_s, @actor_hue, @battler_name.to_s, @battler_hue)
    $game_player.refresh
    return true
  end   

**
Rep:
Level 82
Bump. Help please.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
It's been a very long time since I looked at XP, but all I think you would need to do is change every reference to $game_actors[1] to $game_party.actors[0] and perform a check to make sure the party is not empty.

On looking through the script though, the author seems to have made some pretty bizarre design choices there - it doesn't make any sense to change the actual actor's graphics as he or she does - he or she should have only changed the refresh method of Game_Player. Does that script even work to change the graphic to the vehicle at all if Actor 1 is not the lead actor? Also, it reserves and changes in-game variables without even giving the user a chance to specify which ones.

If I were you, I would perhaps invest some time in finding a different vehicle system.

**
Rep:
Level 82
When the primary actor is someone other than number 1, the graphic does not change. As for other vehicle systems, this one is the simplest to use that I have found, and it doesn't require me making copy maps for vehicles. Would it be possible to perhaps revamp this script?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, I don't have time to totally rewrite the script, but I will make the modifications necessary so that it works when Actor 1 is not the lead actor.

I'll get back to you shortly.

**
Rep:
Level 82
Much appreciated.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Alright, I did not test this at all, so you might want to try it out in a new project first, but try this:

Code: [Select]
class Game_Character
  def passable?(x, y, d)
   
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
   
    # If coordinates are outside of map
    unless $game_map.valid?(new_x, new_y)
      return false
    end
   
    # If through is ON
    if @through
      return true
    end
       
    # If unable to leave first move tile in designated direction
    unless $game_map.passable?(x, y, d, self)
      return false
    end
   
    # If unable to enter move tile in designated direction
    unless $game_map.passable?(new_x, new_y, 10 - d)
      return false
    end
       
    #check terrain for vehicle
    check_terrain(new_x, new_y)   
     
    # Loop all events
    for event in $game_map.events.values
      # If event coordinates are consistent with move destination
      if event.x == new_x and event.y == new_y
        @state = true
        # If through is OFF
        unless event.through
          # If self is event
          if self != $game_player
            return false
          end
          # With self as the player and partner graphic as character
          if event.character_name != ""
            return false
          end
        end
      end
    end
   
    if @state == false
      return false
    end     
   
    # If player coordinates are consistent with move destination
    if $game_player.x == new_x and $game_player.y == new_y
      # If through is OFF
      unless $game_player.through
        # If your own graphic is the character
        if @character_name != ""
          return false
        end
      end
    end
     
   
    return true
   
  end
 
  #--------------------------------------------------------------------------
  # * Check the terrain for the vehicle
  #   @terrain (0=none, 1=river, 2=ocean, 3=air, 4=ground)
  #   @vehicle (0=foot, 1=canoe, 2=boat, 3=dragon)
  #   @state (true=passable tile, false=unpassable tile)
  #--------------------------------------------------------------------------
  def check_terrain(new_x, new_y) 
    @state = false
    @terrain = $game_map.terrain_tag(new_x, new_y)
    @vehicle = $game_variables[1]
   
    @state = true if @vehicle == 0 && @terrain == 4 #foot & ground
    @state = true if @vehicle == 0 && @terrain == 5
    @state = true if @vehicle == 0 && @terrain == 6
    @state = true if @vehicle == 1 && @terrain == 4  #canoe & river
    @state = true if @vehicle == 2 && @terrain == 2  #boat & ocean
    @state = true if @vehicle == 3                   #dragon
    @state = true if @terrain == 0
  end

end

class Game_Player < Game_Character
 
  alias in_vehicle_alias update
  alias ma_vehicle_refrsh_5fg1 refresh
  #--------------------------------------------------------------------------
  # * Enter a vehicle
  #--------------------------------------------------------------------------       
  def enter_vehicle(type)
   
    $game_system.menu_disabled = true
    $game_system.save_disabled = true   
   
    if type != "dragon"
      @through = true
      move_forward
      @through = false   
    end
   
    $game_switches[1] = false    #Canoe Off   
    $game_switches[2] = false    #Boat Off   
    $game_switches[3] = false    #Dragon Off       
   
    if type == "Caravan"
      $game_variables[1] = 1       #set terrian
      $game_switches[1] = true    #Canoe On
      Audio.bgm_play("Audio/BGM/047-Positive05", 100, 100) #play canoe music
 
    elsif type == "boat"
      $game_variables[1] = 2       #set terrian
      $game_switches[2] = true    #Boat On     
      Audio.bgm_play("Audio/BGM/Crvantes", 100, 100) #play ship music
     
    elsif type == "dragon"
      $game_variables[1] = 3       #set terrian
      $game_switches[3] = true    #Dragon On 
      Audio.bgm_play("Audio/BGM/045-Positive03", 100, 100) #play dragon music
     
    end
   
    refresh
    $game_map.refresh
   
    return true
  end

  #--------------------------------------------------------------------------
  # * Enter a vehicle
  #--------------------------------------------------------------------------       
  def exit_vehicle

    $game_system.menu_disabled = true   
    $game_system.save_disabled = true
   
    if @terrain == 4
           
      if $game_switches[1] == true      #getting off canoe
        canoe = $game_map.events[2]     #get canoe event
        canoe.moveto(x, y)              #move to player's x, y coords
        $game_switches[1] = false       #Canoe Off 
        $game_variables[4] = x          #set canoe x coord
        $game_variables[5] = y          #set canoe y coord
        @through = true
        move_forward
        @through = false         
       
      elsif $game_switches[2] == true   #getting off boat
        boat = $game_map.events[8]      #get boat event
        boat.moveto(x, y)               #move to player's x, y coords       
        $game_switches[2] = false       #Boat Off   
        $game_variables[2] = x          #set boat x coord
        $game_variables[3] = y          #set boate y coord 
        @through = true
        move_forward
        @through = false                 
       
      elsif $game_switches[3] == true   #getting off dragon
        dragon = $game_map.events[2]    #get dragon event
        dragon.moveto(x, y)             #move to player's x, y coords       
        $game_switches[3] = false       #Dragon Off   
        $game_variables[6] = x          #set dragon x coord
        $game_variables[7] = y          #set dragon y coord
      end
      # reset terrain
      $game_variables[1] = 0         
   
      # play walking music
      Audio.bgm_play("Audio/BGM/044-Positive02", 100, 100) #play music
     
      refresh 
      $game_map.refresh   
   
    end
 
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(*args, &block)
    if $game_switches[1] || $game_switches[2] || $game_switches[3]
      # Set character file name and hue
      @character_name = $game_switches[1] ? "Caravan" : $game_switches[2] ? "boat" : "dragon"
      @character_hue = 0
      # Initialize opacity level and blending method
      @opacity = 255
      @blend_type = 0
  else
      ma_vehicle_refrsh_5fg1(*args, &block)
  end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    in_vehicle_alias
    # if not on ground terrain, check for boat exit
    if $game_variables[1] != 0
      if Input.trigger?(Input::C)
        exit_vehicle
      end 
    end
  end
 
end

Please don't give any credit to me; only credit the original author.

**
Rep:
Level 82
Yep, all is well. Thanks modern. Might you be able to help with one more problem involving this script?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
What is it?

**
Rep:
Level 82
Well, it seems that this script is causing some strange effects when put together with IAMFORTE's CMS. (My copy is attached below)

Apparently, when the map is brought up on a map that uses the vehicle script, when the map is exited the player is unable to move. However, when a vehicle is entered when this happens, not only can the player move, but when the vehicle is exited, the problem is gone.