Advertisement
roninator2

Party Swap for Land Vehicle

Nov 17th, 2024
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.02 KB | None | 0 0
  1. # ╔═══════════════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Party Swap for Vehicle                 ║  Version: 1.00     ║
  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 Script                           ║
  11. # ║                                                                    ║
  12. # ╚════════════════════════════════════════════════════════════════════╝
  13. # ╔════════════════════════════════════════════════════════════════════╗
  14. # ║ Brief Description:                                                 ║
  15. # ║       Switch party for vehicle                                     ║
  16. # ╚════════════════════════════════════════════════════════════════════╝
  17. # ╔════════════════════════════════════════════════════════════════════╗
  18. # ║ Instructions:                                                      ║
  19. # ║   Change the values below for the vehicle actor                    ║
  20. # ║                                                                    ║
  21. # ╚════════════════════════════════════════════════════════════════════╝
  22. # ╔════════════════════════════════════════════════════════════════════╗
  23. # ║ Updates:                                                           ║
  24. # ║ 1.00 - 21 Jul 2023 - 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.   VEHICLE_ACTOR = 11    # Actor that is used as the land vehicle
  49.   LEADER_LEVEL = true   # If true will make the vehicle actor the
  50.                         # same level as the party leader
  51. end
  52. #==============================================================================
  53. # ** End of Editable code
  54. #==============================================================================
  55.  
  56. #==============================================================================
  57. # ** BattleManager
  58. #==============================================================================
  59.  
  60. module BattleManager
  61.   #--------------------------------------------------------------------------
  62.   # * EXP Acquisition and Level Up Display
  63.   #--------------------------------------------------------------------------
  64.   def self.gain_exp
  65.     if $game_player.in_land?
  66.       $game_party.vehicle_party.each do |actor|
  67.         actor.gain_vehicle_exp($game_troop.exp_total)
  68.       end
  69.     else
  70.       $game_party.all_members.each do |actor|
  71.         actor.gain_exp($game_troop.exp_total)
  72.       end
  73.     end
  74.     wait_for_message
  75.   end
  76. end # BattleManager
  77.  
  78. #==============================================================================
  79. # ** Game_Actor
  80. #==============================================================================
  81.  
  82. class Game_Actor < Game_Battler
  83.   #--------------------------------------------------------------------------
  84.   # * Get EXP (Account for Experience Rate)
  85.   #--------------------------------------------------------------------------
  86.   def gain_vehicle_exp(exp)
  87.     change_exp(self.exp + (exp * vehicle_exp_rate).to_i, false)
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # * Calculate Final EXP Rate
  91.   #--------------------------------------------------------------------------
  92.   def vehicle_exp_rate
  93.     exr * (vehicle_battle_member? ? 1 : reserve_members_exp_rate)
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # * Determine Battle Members
  97.   #--------------------------------------------------------------------------
  98.   def vehicle_battle_member?
  99.     $game_party.vehicle_members.include?(self)
  100.   end
  101. end # Game_Actor
  102.  
  103. #==============================================================================
  104. # ** Game_Party
  105. #==============================================================================
  106.  
  107. class Game_Party < Game_Unit
  108.   #--------------------------------------------------------------------------
  109.   # * Public Instance Variables
  110.   #--------------------------------------------------------------------------
  111.   attr_accessor :vehicle_party            # Land Vehicle Party saved
  112.   #--------------------------------------------------------------------------
  113.   # * Get All Members
  114.   #--------------------------------------------------------------------------
  115.   def driving_members
  116.     @vehicle_party.collect {|act| $game_actors[act.id] }
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # * Get Battle Members
  120.   #--------------------------------------------------------------------------
  121.   def vehicle_members
  122.     driving_members[0, max_battle_members].select {|actor| actor.exist? }
  123.   end
  124. end # Game_Party
  125.  
  126. #==============================================================================
  127. # ** Game_Player
  128. #==============================================================================
  129.  
  130. class Game_Player < Game_Character
  131.   #--------------------------------------------------------------------------
  132.   # * Board Vehicle
  133.   #    Assumes that the player is not currently in a vehicle.
  134.   #--------------------------------------------------------------------------
  135.   def get_on_vehicle
  136.     front_x = $game_map.round_x_with_direction(@x, @direction)
  137.     front_y = $game_map.round_y_with_direction(@y, @direction)
  138.     @vehicle_type = :boat    if $game_map.boat.pos?(front_x, front_y)
  139.     @vehicle_type = :ship    if $game_map.ship.pos?(front_x, front_y)
  140.     @vehicle_type = :airship if $game_map.airship.pos?(@x, @y)
  141.     @vehicle_type = :land    if $game_map.land.pos?(@x, @y)
  142.     if vehicle
  143.       @vehicle_getting_on = true
  144.       force_move_forward unless in_airship? or in_land?
  145.       @followers.gather
  146.     end
  147.     if in_land?
  148.       $game_party.vehicle_party = $game_party.members
  149.       $game_party.members.each do |actor|
  150.         $game_party.remove_actor(actor.id)
  151.       end
  152.       $game_party.add_actor(R2_LAND_VEHICLE::VEHICLE_ACTOR)
  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.     @vehicle_getting_on
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # * Get Off Vehicle
  162.   #    Assumes that the player is currently riding in a vehicle.
  163.   #--------------------------------------------------------------------------
  164.   def get_off_vehicle
  165.     if vehicle.land_ok?(@x, @y, @direction)
  166.       set_direction(2) if in_airship?
  167.       @followers.synchronize(@x, @y, @direction)
  168.       if in_land?
  169.         $game_party.remove_actor(R2_LAND_VEHICLE::VEHICLE_ACTOR)
  170.         $game_party.vehicle_party.each do |actor|
  171.           $game_party.add_actor(actor.id)
  172.         end
  173.         $game_party.vehicle_party = nil
  174.       end
  175.       vehicle.get_off
  176.       unless in_airship? || in_land?
  177.         force_move_forward
  178.         @transparent = false
  179.       end
  180.       @vehicle_getting_off = true
  181.       @move_speed = 4
  182.       @through = false
  183.       make_encounter_count
  184.       @followers.gather
  185.     end
  186.     @vehicle_getting_off
  187.   end
  188. end # Game_Player
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement