Advertisement
roninator2

Party Swap for all Vehicles

Nov 18th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.32 KB | None | 0 0
  1. # ╔═══════════════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Party Swap for all Vehicles            ║  Version: 1.01     ║
  3. # ║ Author: Roninator2                            ║                    ║
  4. # ╠═══════════════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                                     ║   Date Created     ║
  6. # ║   Save the party in order to swap             ╠════════════════════╣
  7. # ║   for a vehicle for the party                 ║    22 Jul 2023     ║
  8. # ╚═══════════════════════════════════════════════╩════════════════════╝
  9. # ╔════════════════════════════════════════════════════════════════════╗
  10. # ║ Requires:                                                          ║
  11. # ║   Roninator2 - Land Vehicle                                        ║
  12. # ║                                                                    ║
  13. # ╚════════════════════════════════════════════════════════════════════╝
  14. # ╔════════════════════════════════════════════════════════════════════╗
  15. # ║ Brief Description:                                                 ║
  16. # ║                                                                    ║
  17. # ╚════════════════════════════════════════════════════════════════════╝
  18. # ╔════════════════════════════════════════════════════════════════════╗
  19. # ║ Instructions:                                                      ║
  20. # ║   Change the values below for the vehicle actor                    ║
  21. # ║                                                                    ║
  22. # ╚════════════════════════════════════════════════════════════════════╝
  23. # ╔════════════════════════════════════════════════════════════════════╗
  24. # ║ Updates:                                                           ║
  25. # ║ 1.00 - 22 Jul 2022 - Script finished                               ║
  26. # ║                                                                    ║
  27. # ╚════════════════════════════════════════════════════════════════════╝
  28. # ╔════════════════════════════════════════════════════════════════════╗
  29. # ║ Credits and Thanks:                                                ║
  30. # ║   Roninator2                                                       ║
  31. # ║                                                                    ║
  32. # ╚════════════════════════════════════════════════════════════════════╝
  33. # ╔════════════════════════════════════════════════════════════════════╗
  34. # ║ Terms of use:                                                      ║
  35. # ║  Follow the original Authors terms of use where applicable         ║
  36. # ║    - When not made by me (Roninator2)                              ║
  37. # ║  Free for all uses in RPG Maker except nudity                      ║
  38. # ║  Anyone using this script in their project before these terms      ║
  39. # ║  were changed are allowed to use this script even if it conflicts  ║
  40. # ║  with these new terms. New terms effective 03 Apr 2024             ║
  41. # ║  No part of this code can be used with AI programs or tools        ║
  42. # ║  Credit must be given                                              ║
  43. # ╚════════════════════════════════════════════════════════════════════╝
  44.  
  45. #==============================================================================
  46. # ** Edit Settings
  47. #==============================================================================
  48. module R2_LAND_VEHICLE
  49.   LAND_ACTOR = 11       # Actor that is used as the land vehicle
  50.   BOAT_ACTOR = 11       # Actor that is used as the boat vehicle
  51.   SHIP_ACTOR = 11       # Actor that is used as the ship vehicle
  52.   AIRSHIP_ACTOR = 11    # Actor that is used as the airship vehicle
  53.   LEADER_LEVEL = true   # If true will make the vehicle actor the
  54.                         # same level as the party leader
  55. end
  56. #==============================================================================
  57. # ** End of Editable code
  58. #==============================================================================
  59.  
  60. #==============================================================================
  61. # ** BattleManager
  62. #==============================================================================
  63.  
  64. module BattleManager
  65.   #--------------------------------------------------------------------------
  66.   # * EXP Acquisition and Level Up Display
  67.   #--------------------------------------------------------------------------
  68.   def self.gain_exp
  69.     if $game_player.in_boat? || $game_player.in_ship? || $game_player.in_airship? || $game_player.in_land?
  70.       $game_party.vehicle_party.each do |actor|
  71.         actor.gain_vehicle_exp($game_troop.exp_total)
  72.       end
  73.     else
  74.       $game_party.all_members.each do |actor|
  75.         actor.gain_exp($game_troop.exp_total)
  76.       end
  77.     end
  78.     wait_for_message
  79.   end
  80. end # BattleManager
  81.  
  82. #==============================================================================
  83. # ** Game_Actor
  84. #==============================================================================
  85.  
  86. class Game_Actor < Game_Battler
  87.   #--------------------------------------------------------------------------
  88.   # * Get EXP (Account for Experience Rate)
  89.   #--------------------------------------------------------------------------
  90.   def gain_vehicle_exp(exp)
  91.     change_exp(self.exp + (exp * vehicle_exp_rate).to_i, false)
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Calculate Final EXP Rate
  95.   #--------------------------------------------------------------------------
  96.   def vehicle_exp_rate
  97.     exr * (vehicle_battle_member? ? 1 : reserve_members_exp_rate)
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # * Determine Battle Members
  101.   #--------------------------------------------------------------------------
  102.   def vehicle_battle_member?
  103.     $game_party.vehicle_members.include?(self)
  104.   end
  105. end # Game_Actor
  106.  
  107. #==============================================================================
  108. # ** Game_Party
  109. #==============================================================================
  110.  
  111. class Game_Party < Game_Unit
  112.   #--------------------------------------------------------------------------
  113.   # * Public Instance Variables
  114.   #--------------------------------------------------------------------------
  115.   attr_accessor :vehicle_party            # Land Vehicle Party saved
  116.   #--------------------------------------------------------------------------
  117.   # * Get All Members
  118.   #--------------------------------------------------------------------------
  119.   def driving_members
  120.     @vehicle_party.collect {|act| $game_actors[act.id] }
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # * Get Battle Members
  124.   #--------------------------------------------------------------------------
  125.   def vehicle_members
  126.     driving_members[0, max_battle_members].select {|actor| actor.exist? }
  127.   end
  128. end # Game_Party
  129.  
  130. #==============================================================================
  131. # ** Game_Player
  132. #==============================================================================
  133.  
  134. class Game_Player < Game_Character
  135.   #--------------------------------------------------------------------------
  136.   # * Board Vehicle
  137.   #    Assumes that the player is not currently in a vehicle.
  138.   #--------------------------------------------------------------------------
  139.   def get_on_vehicle
  140.     front_x = $game_map.round_x_with_direction(@x, @direction)
  141.     front_y = $game_map.round_y_with_direction(@y, @direction)
  142.     @vehicle_type = :boat    if $game_map.boat.pos?(front_x, front_y)
  143.     @vehicle_type = :ship    if $game_map.ship.pos?(front_x, front_y)
  144.     @vehicle_type = :airship if $game_map.airship.pos?(@x, @y)
  145.     @vehicle_type = :land    if $game_map.land.pos?(@x, @y)
  146.     if vehicle
  147.       @vehicle_getting_on = true
  148.       force_move_forward unless in_airship? or in_land?
  149.       @followers.gather
  150.     end
  151.     @vehicle_getting_on
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # * Update Boarding onto Vehicle
  155.   #--------------------------------------------------------------------------
  156.   def update_vehicle_get_on
  157.     if !@followers.gathering? && !moving?
  158.       @direction = vehicle.direction
  159.       @move_speed = vehicle.speed
  160.       @vehicle_getting_on = false
  161.       @transparent = true
  162.       @through = true if in_airship?
  163.       vehicle.get_on
  164.       $game_party.vehicle_party = $game_party.members
  165.       $game_party.members.each do |actor|
  166.         $game_party.remove_actor(actor.id)
  167.       end
  168.       case @vehicle_type
  169.       when :land ; $game_party.add_actor(R2_LAND_VEHICLE::LAND_ACTOR)
  170.       when :boat ; $game_party.add_actor(R2_LAND_VEHICLE::BOAT_ACTOR)
  171.       when :ship ; $game_party.add_actor(R2_LAND_VEHICLE::SHIP_ACTOR)
  172.       when :airship ; $game_party.add_actor(R2_LAND_VEHICLE::AIRSHIP_ACTOR)
  173.       end
  174.       if R2_LAND_VEHICLE::LEADER_LEVEL
  175.         lvl = $game_party.vehicle_party[0].level.to_i
  176.         $game_party.members[0].change_level(lvl, false)
  177.       end
  178.     end
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # * Get Off Vehicle
  182.   #    Assumes that the player is currently riding in a vehicle.
  183.   #--------------------------------------------------------------------------
  184.   def get_off_vehicle
  185.     if vehicle.land_ok?(@x, @y, @direction)
  186.       RPG::BGM.stop
  187.       set_direction(2) if in_airship?
  188.       @followers.synchronize(@x, @y, @direction)
  189.       case @vehicle_type
  190.       when :land ; $game_party.remove_actor(R2_LAND_VEHICLE::LAND_ACTOR)
  191.       when :boat ; $game_party.remove_actor(R2_LAND_VEHICLE::BOAT_ACTOR)
  192.       when :ship ; $game_party.remove_actor(R2_LAND_VEHICLE::SHIP_ACTOR)
  193.       when :airship ; $game_party.remove_actor(R2_LAND_VEHICLE::AIRSHIP_ACTOR)
  194.       end
  195.       $game_party.vehicle_party.each do |actor|
  196.         $game_party.add_actor(actor.id)
  197.       end
  198.       $game_party.vehicle_party = nil
  199.       vehicle.get_off
  200.       unless in_airship? || in_land?
  201.         force_move_forward
  202.         @transparent = false
  203.       end
  204.       @vehicle_getting_off = true
  205.       @move_speed = 4
  206.       @through = false
  207.       make_encounter_count
  208.       @followers.gather
  209.     end
  210.     @vehicle_getting_off
  211.   end
  212. end # Game_Player
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement