Advertisement
roninator2

Kid Friendly Basic Quest - Enemy Remaining on Map

Dec 14th, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.84 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: KFBQ Enemy remaining on Map  ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║   FFMQ Style Battle Count           ║    14 Mar 2023     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Instructions:                                            ║
  11. # ║                                                          ║
  12. # ║  Configure hash with data for battle on the map.         ║
  13. # ║  Battle_Data = { :1 => [ [4,6],[8,12]  ],                ║
  14. # ║                  :2 => [ [17,5],32,8] ], }               ║
  15. # ║                                                          ║
  16. # ║  Works like this -> :1 = map id                          ║
  17. # ║                     [4,6] = [event id, battles]          ║
  18. # ║                                                          ║
  19. # ║  Data is copied to the Current_Data variable specified   ║
  20. # ║  The variable data is modified not the module data       ║
  21. # ║                                                          ║
  22. # ║  This is because module data does not change.            ║
  23. # ║                                                          ║
  24. # ║  Second variable is used to pass current data to the     ║
  25. # ║  battle in progress.                                     ║
  26. # ╚══════════════════════════════════════════════════════════╝
  27. # ╔══════════════════════════════════════════════════════════╗
  28. # ║ Terms of use:                                            ║
  29. # ║ Free for all uses in RPG Maker - Except nudity           ║
  30. # ╚══════════════════════════════════════════════════════════╝
  31.  
  32. #==============================================================================
  33. # * Module R2 Enemy Count Data
  34. #==============================================================================
  35. module R2_Enemy_Count_Data
  36. # { Map id => [ [event_id, number], [event_id, number] ], <- don't forget comma
  37.   Battle_Data = { 1 => [ [10,5], [9, 1] ],
  38.                   2 => [ [3,1] ],
  39.                 }
  40.         # {} = curly bracket.  [] = square bracket
  41.   # entire data for the map is in one array. i.e. [ ]
  42.   # secondary [ ] is the event data
  43.   Current_Data = 20 # variable that copies the Battle Data and is
  44.                     # changed curing game play.
  45.   Remaining = 21    # variable that holds the current event enemy count remaining
  46.   Data_Transfer = 22 # variable used to set current values to battle system
  47. end
  48.  
  49. #==============================================================================
  50. # ** Scene Map
  51. #==============================================================================
  52. class Scene_Map < Scene_Base
  53.   #--------------------------------------------------------------------------
  54.   # * Start
  55.   #--------------------------------------------------------------------------
  56.   alias r2_battle_data_hud_start  start
  57.   def start
  58.     r2_battle_data_hud_start
  59.     $game_variables[R2_Enemy_Count_Data::Current_Data] =
  60.     R2_Enemy_Count_Data::Battle_Data if $game_variables[R2_Enemy_Count_Data::Current_Data] == 0
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # * Update Scene Transition
  64.   #--------------------------------------------------------------------------
  65.   def update_scene
  66.     check_gameover
  67.     update_transfer_player unless scene_changing?
  68.     update_encounter unless scene_changing?
  69.     update_call_menu unless scene_changing?
  70.     update_call_debug unless scene_changing?
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # * Update Encounter
  74.   #--------------------------------------------------------------------------
  75.   def update_encounter
  76.     SceneManager.call(Scene_Battle) if $game_player.encounter
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # * Preprocessing for Battle Screen Transition
  80.   #--------------------------------------------------------------------------
  81.   def pre_battle_scene
  82.     map = $game_map.map_id
  83.     event = $game_map.event_id_xy($game_player.x, $game_player.y)
  84.     id = -1
  85.     if !R2_Enemy_Count_Data::Battle_Data[map].nil?
  86.       R2_Enemy_Count_Data::Battle_Data[map].each_with_index do |chk, ind|
  87.         id = ind if chk[0] == event
  88.       end
  89.       if id != -1
  90.         $game_variables[R2_Enemy_Count_Data::Remaining] =
  91.         $game_variables[R2_Enemy_Count_Data::Current_Data][map][id][1]
  92.         $game_variables[R2_Enemy_Count_Data::Data_Transfer] = [map, id]
  93.       end
  94.     end
  95.     # test
  96.     Graphics.update
  97.     Graphics.freeze
  98.     BattleManager.save_bgm_and_bgs
  99.     BattleManager.play_battle_bgm
  100.     Sound.play_battle_start
  101.   end
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement