Advertisement
roninator2

Party Swap for default Vehicles

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