Advertisement
Fomar0153

Fomar0153 - AP System I

Jan 10th, 2012
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.44 KB | None | 0 0
  1. =begin
  2. AP System Script
  3. by Fomar0153
  4. Version 1.0
  5. ----------------------
  6. Notes
  7. ----------------------
  8. No requirements
  9. Implements an ap system for you to use when creating skill
  10. ystems that utilise AP.
  11. ----------------------
  12. Instructions
  13. ----------------------
  14. You will need to create an attribute to use for AP.
  15. Then set is as a trait, although it says % just put
  16. the number you want the enemy to give as AP.
  17. ----------------------
  18. Known bugs
  19. ----------------------
  20. None
  21. =end
  22. module Vocab
  23.   ObtainAp         = "%s AP was obtained!"
  24. end
  25.  
  26. class Game_Actor < Game_Battler
  27.   #--------------------------------------------------------------------------
  28.   # ● New Method gain_ap
  29.   #--------------------------------------------------------------------------
  30.   def gain_ap(ap)
  31.     # your code goes here
  32.   end
  33. end
  34.  
  35. module BattleManager
  36.  
  37.   # Set you AP Element
  38.   AP_Element = 11
  39.  
  40.   #--------------------------------------------------------------------------
  41.   # ● Rewrote self.display_exp
  42.   #--------------------------------------------------------------------------
  43.   def self.display_exp
  44.     if $game_troop.exp_total > 0
  45.       text = sprintf(Vocab::ObtainExp, $game_troop.exp_total)
  46.       $game_message.add('\.' + text)
  47.     end
  48.     if $game_troop.ap_total > 0
  49.       text = sprintf(Vocab::ObtainAp, $game_troop.ap_total)
  50.       $game_message.add('\.' + text)
  51.     end
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● Rewrote self.gain_exp
  55.   #--------------------------------------------------------------------------
  56.   def self.gain_exp
  57.     $game_party.all_members.each do |actor|
  58.         actor.gain_exp($game_troop.exp_total)
  59.     end
  60.     wait_for_message
  61.     $game_party.all_members.each do |actor|
  62.     actor.gain_ap($game_troop.ap_total)
  63.     end
  64.     wait_for_message
  65.   end
  66. end
  67.  
  68. class Game_Troop < Game_Unit
  69.   #--------------------------------------------------------------------------
  70.   # ● New Method ap_total
  71.   #--------------------------------------------------------------------------
  72.   def ap_total
  73.     dead_members.inject(0) {|r, enemy| r += enemy.ap }
  74.   end
  75. end
  76.  
  77. class Game_Enemy < Game_Battler
  78.   #--------------------------------------------------------------------------
  79.   # ● New Method ap_total
  80.   #--------------------------------------------------------------------------
  81.   def ap
  82.     return (self.element_rate(BattleManager::AP_Element) * 100).to_i
  83.   end
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement