Advertisement
diamondandplatinum3

Metronome Skill in Battle ~ RGSS3

Jan 18th, 2013
1,011
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.63 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Metronome Skill in Battle
  3. #             Author: DiamondandPlatinum3
  4. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. #  Description:
  6. #
  7. #    This script puts in a skill similar to pokemon's metronome, in the sense
  8. #    that skills will be chosen at random to be used if this skill is used.
  9. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10. #------------------------------------------------------------------------------
  11. #  Instructions:
  12. #  
  13. #     Simply create a new skill in the database and call it whatever you want,
  14. #     set the scope to random enemies (so you don't actually have to choose an
  15. #     enemy in battle when trying to use this skill) then set the skill ID below.
  16. #
  17. #
  18. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. module DiamondandPlatinum3
  20.   module MetronomeSkill
  21.    
  22.     # Skill ID for Metronome
  23.     METRONOME_SKILL_ID = 127
  24.    
  25.     # Skill IDs that you do not wish to be selected with Metronome.
  26.     # If you want all skills to be available, simply make the below empty
  27.     # Skills 1-7 are already accounted for, so you do not need to insert them.
  28.     NON_USABLE_SKILLS = [ 25, 75, 79, ]
  29.    
  30.   end
  31. end
  32.  
  33.  
  34.  
  35.  
  36.  
  37. #==============================================================================
  38. # ** Scene_Battle
  39. #------------------------------------------------------------------------------
  40. #  This class performs battle screen processing.
  41. #==============================================================================
  42. class Scene_Battle  
  43.   #--------------------------------------------------------------------------
  44.   # * Aliased Method: Use Skill/Item
  45.   #--------------------------------------------------------------------------
  46.   alias dp3_scn_battle_useitem_18j      use_item
  47.   #--------------------------------------------------------------------------
  48.   def use_item
  49.     if @subject.current_action.item.is_a?(RPG::Skill) && @subject.current_action.item.id == DiamondandPlatinum3::MetronomeSkill::METRONOME_SKILL_ID
  50.       @subject.dp3_set_metronome_skill_used(true)
  51.       @subject.dp3_metronome_set_current_action(rand($data_skills.size - 1) + 1) while( !dp3_metronome_can_use_skill?() )
  52.       @log_window.display_use_item(@subject, $data_skills[DiamondandPlatinum3::MetronomeSkill::METRONOME_SKILL_ID])
  53.     end
  54.     dp3_scn_battle_useitem_18j() # Call Original Method
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # * Can Use Skill?
  58.   #--------------------------------------------------------------------------
  59.   def dp3_metronome_can_use_skill?()
  60.     return false if @subject.current_action.item.id < 8
  61.     return false if @subject.current_action.item.id == DiamondandPlatinum3::MetronomeSkill::METRONOME_SKILL_ID
  62.     for id in DiamondandPlatinum3::MetronomeSkill::NON_USABLE_SKILLS
  63.       return false if @subject.current_action.item.id == id
  64.     end
  65.     return true
  66.   end
  67. end
  68.  
  69.  
  70. #==============================================================================
  71. # ** Game_Battler
  72. #------------------------------------------------------------------------------
  73. #  A battler class with methods for sprites and actions added. This class
  74. # is used as a super class of the Game_Actor class and Game_Enemy class.
  75. #==============================================================================
  76.  
  77. class Game_Battler < Game_BattlerBase
  78.   #--------------------------------------------------------------------------
  79.   # * Aliased Method: Pay Cost of Using Skill
  80.   #--------------------------------------------------------------------------
  81.   alias dp3_metronome_gamebattler_payskillcost    pay_skill_cost
  82.   #--------------------------------------------------------------------------
  83.   def pay_skill_cost(skill)
  84.     skill = $data_skills[DiamondandPlatinum3::MetronomeSkill::METRONOME_SKILL_ID] if @dp3_metronome_skill_used
  85.     dp3_set_metronome_skill_used(false)
  86.     dp3_metronome_gamebattler_payskillcost(skill) # Call Original Method
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # * Get Current Action
  90.   #--------------------------------------------------------------------------
  91.   def dp3_metronome_set_current_action( skill_id )
  92.     @actions[0].set_skill(skill_id)
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # * Set Metronome Used? Instance Variable
  96.   #--------------------------------------------------------------------------
  97.   def dp3_set_metronome_skill_used( set )
  98.     @dp3_metronome_skill_used = set
  99.   end
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement