Save-Point
VPassengersLimit XP - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: VPassengersLimit XP (/thread-8340.html)



VPassengersLimit XP - kyonides - 08-18-2021

VPassengersLimit XP
The Unofficial Super Simple Vehicle System Add On

by Kyonides Arkanthes

Introduction

Thinking Did you ever want to limit a furry werewolf's script called Super Simple Vehicle System in a curious way?

Shocked Now you can with this add for it lets you set the maximum passengers capacity of any vehicle.

The Scriptlet

Code:
# * VPassengersLimit XP
#   Unofficial Super Simple Vehicle System Add On
#   Scripter : Kyonides Arkanthes
#   2021-08-17

# This scriptlet adds a passengers limit to the vehicle system.
# It also displays an in game warning if the party tries to embark on a journey.

# * Overwritten Method * #
# Game_Player#update_vehicle_detect_boarding?

# * Aliased Method * #
# Game_Player#update
# Window_Message#update

module Vehicles
# Indexes 5 - Speed, 6 - Step Animation, 7 - Maximum No. of Actors on board
  VEHICLE['Canoe'][5..7] = [false, 0, 2]
  VEHICLE['Boat'][5..7] = [false, 0, 3]
  PARTY_SIZE_ERROR = "The %s is not large enough for all heroes\n" +
   "to embark.\nVehicle's maximum capacity: %s"
end

class Game_Temp
  attr_accessor :embark_failed
end

class Game_Party
  def size() @actors.size end
end

class Game_Player
  alias :kyon_vpasslim_gm_player_up :update
  def update
    return true if $game_temp.embark_failed
    kyon_vpasslim_gm_player_up
  end

  def check_char_event_dir(event_x, event_y)
    case @direction
    when 1 ; return true if event_x == @x-1 and event_y == @y+1
    when 2 ; return true if event_x == @x+0 and event_y == @y+1
    when 3 ; return true if event_x == @x+1 and event_y == @y+1
    when 4 ; return true if event_x == @x-1 and event_y == @y+0
    when 6 ; return true if event_x == @x+1 and event_y == @y+0
    when 7 ; return true if event_x == @x-1 and event_y == @y-1
    when 8 ; return true if event_x == @x+0 and event_y == @y-1
    when 9 ; return true if event_x == @x+1 and event_y == @y-1
    end
    return false
  end

  def stop_embark(name, limit)
    $game_system.se_play($data_system.buzzer_se)
    $game_temp.message_text = sprintf(Vehicles::PARTY_SIZE_ERROR, name, limit)
    $game_temp.embark_failed = true
  end

  def update_vehicle_detect_boarding?
    return true if $game_temp.embark_failed
    return false unless $game_system.vehicle_current.nil?
    return false unless Input.trigger?(Vehicles::BOARD_INPUT)
    veh_key = nil
    veh_id  = 0
    for event in $game_map.events.values
      next if event.nil? or event.erased
      next unless event.name =~ Vehicles::VEHICLE_FORMULA
      check_type = false
      if event.through
        check_type = (event.x == @x and event.y == @y)
      else
        check_type = check_char_event_dir(event.x, event.y)
      end
      next unless check_type
      veh_key = $1
      veh_id  = event.id
      break
    end
    if veh_id != 0
      if (v = Vehicles::VEHICLE[veh_key])
        max = v[7]
        return stop_embark(veh_key, max) if max and $game_party.size > max
        update_vehicle_board_peform(veh_key, veh_id)
      end
    end
    return true
  end
end

class Window_Message
  alias :kyon_vpasslim_win_mess_up :update
  def update
    if @contents_showing and $game_temp.embark_failed
      if Input.trigger?(Input::B) or Input.trigger?(Input::C) or
         Input.trigger?(Vehicles::BOARD_INPUT)
        $game_system.se_play($data_system.cancel_se)
        $game_temp.embark_failed = nil
        terminate_message
        return
      end
    end
    kyon_vpasslim_win_mess_up
  end
end


Terms & Conditions

Happy with a sweat You know, it is the usual inclusion in your game credits. You can use it free of charge.
Yet, I could charge you Cash for it if that is what you wish. Laughing