Advertisement
Zetu

Executable Actions Extension

Jun 6th, 2011
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.92 KB | None | 0 0
  1.                             #======================#
  2.                             #  Z-Systems by: Zetu  #
  3. #===========================#======================#===========================#
  4. #             *  *  *  Executable Actions Extension v1.04  *  *  *             #
  5. #=#==========================================================================#=#
  6.   #                       - - - Version  History - - -                       #
  7.   # Version History                                                          #
  8.   #  1.01 ALPHA                                                              #
  9.   #  1.02                                                                    #
  10.   #    • Added Further Customization (Vocab for defaults and Advanced        #
  11.   #        Conditions for further support of other scripts.)                 #
  12.   #  1.03                                                                    #
  13.   #    • Corrected Capatability issues.                                      #
  14.   #  1.04                                                                    #
  15.   #    • Complete Overhaul                                                   #
  16.   #--------------------------------------------------------------------------#
  17.   #  WARNING: Use of this program may require some scripting knowledge.  If  #
  18.   #  you do not know what your doing, please ask on a forum.                 #
  19.   #--------------------------------------------------------------------------#
  20.   #  How to configure.                                                       #
  21.   #    • First, all commands must be added to the COMMANDS array.  In this   #
  22.   #    array, you have [Symbol, Label, and Code].                            #
  23.   #      - Symbol    => Any representation of the command.  This will not    #
  24.   #      appear within the game, only for representation within the code.    #
  25.   #      - Label     => What you wish for the action to be labeled as.       #
  26.   #      - Code      => Code that is run at the time of selecting a command. #
  27.   #      More than one line can be done without "\n" by placing each line    #
  28.   #      in a separate element within the array.                             #
  29.   #    • After that, if there is an alternate term for your action, place    #
  30.   #    it within the REPLACE hash.  It is symbol => [To, If]                 #
  31.   #      - Symbol    => Must be the same one defined in COMMANDS.            #
  32.   #      - To        => The new term, if applicable.                         #
  33.   #      - If        => The condition to use the new term.                   #
  34.   #    • Then, for CONDITIONS, only place a new line if it will not always   #
  35.   #    appear as a command.  Symbol => Condition.                            #
  36.   #      - Symbol    => Must be the same one defined in COMMANDS (again).    #
  37.   #      - Condition => Condition for appearing in commands.                 #
  38.   #==========================================================================#
  39. module Z_Systems
  40.   module ExComEx
  41.     #FOR ALL LITERAL STRINGS, USE ('""')
  42.     COMMANDS = [#In the order to appear in command window.
  43.     #[Symbol, Label, Code(new element per line)]
  44.     [:event,  '"Event"',         'force_skill(96)'],
  45.     [:dual,   '"Double Attack"', 'force_skill(1)'],
  46.     [:tri,    '"Triple Attack"', 'force_skill(3)'],
  47.     [:attack, 'Vocab::attack',   '@active_battler.action.set_attack', 'start_target_enemy_selection'],
  48.     [:skill,  'Vocab::skill',    'start_skill_selection'],
  49.     [:scan,   '"Scan"',          'force_skill(97)'],
  50.     [:guard,  'Vocab::guard',    '@active_battler.action.set_guard', 'next_actor'],
  51.     [:item,   'Vocab::item',     'start_item_selection']
  52.     ] #DO NOT REMOVE
  53.    
  54.     REPLACE = { #[To What?, if What?]
  55.     :skill    => ['actor.class.skill_name', 'actor.class.skill_name_valid'],
  56.     :event    => ['"This Event"',           'true']
  57.     } #DO NOT REMOVE
  58.    
  59.     CONDITIONS = {#If condition is false, it will not show up.
  60.        #if you cannot use Dual or Triple Attacks
  61.     :attack   => 'not cond(:dual) and not cond(:tri)',
  62.        #if $event is set to true and actor id is 1.
  63.     :event    => '$event == true and actor.id == 1',
  64.        #if actor id is 1, 3, or 7 and does not use Triple Attack
  65.     :dual     => '[1,3,7].include?(actor.id) and not cond(:tri)',
  66.        #if actor id is 3 and at least level 34
  67.     :tri      => 'actor.id == 3 and actor.level >= 34'
  68.     } #DO NOT REMOVE
  69.   end
  70. end
  71.  
  72. #========#======================#====#================================#========#
  73. #--------#                      #----# DO NOT EDIT PAST THIS POINT!!! #--------#
  74. #--------# End of Customization #----# Editing will cause death by    #--------#
  75. #--------#                      #----# brain asplosions.              #--------#
  76. #========#======================#====#================================#========#
  77.  
  78. class Window_ActorCommand < Window_Command
  79.   include Z_Systems::ExComEx
  80.  
  81.   def initialize
  82.     super(128, [], 1, 4)
  83.     self.active = false
  84.   end
  85.  
  86.   def setup(actor)
  87.     @command_sym = []
  88.     @commands = []
  89.     for array in COMMANDS
  90.       bool = CONDITIONS[array[0]].nil? ? true : eval(CONDITIONS[array[0]])
  91.       if bool
  92.         @command_sym.push(array[0])
  93.         if REPLACE[array[0]].nil?
  94.           push_csym(array[1])
  95.         else
  96.           if eval(REPLACE[array[0]][1])
  97.             push_replaced_csym(array[0])
  98.           else
  99.             push_csym(array[1])
  100.           end
  101.         end
  102.       end
  103.     end
  104.     @item_max = @commands.size
  105.     create_contents
  106.     refresh
  107.     self.index = 0
  108.   end
  109.  
  110.   def cond(symbol)
  111.     actor = $scene.a_battler
  112.     return eval(CONDITIONS[symbol])
  113.   end
  114.  
  115.   def wcom
  116.     return @command_sym
  117.   end
  118.  
  119.   def push_csym(string)
  120.     string = eval(string)
  121.     @commands.push(string)
  122.   end
  123.  
  124.   def push_replaced_cym(symbol)
  125.     push_csym(REPLACE[symbol][1])
  126.   end
  127.  
  128. end
  129.  
  130. class Scene_Battle < Scene_Base
  131.   include Z_Systems::ExComEx
  132.  
  133.   def update_actor_command_selection
  134.     if Input.trigger?(Input::B)
  135.       Sound.play_cancel
  136.       prior_actor
  137.     elsif Input.trigger?(Input::C)
  138.       Sound.play_decision
  139.       for array in COMMANDS
  140.         if array[0] == @actor_command_window.wcom[@actor_command_window.index]
  141.           index = 2
  142.           while !array[index].nil?
  143.             eval(array[index])
  144.             index += 1
  145.           end
  146.           break
  147.         end
  148.       end
  149.     end
  150.   end
  151.  
  152.   def a_battler
  153.     return @active_battler
  154.   end
  155.  
  156.   def force_skill(skill_id)
  157.     @skill = $data_skills[skill_id]
  158.     @active_battler.action.set_skill(@skill.id)
  159.     @active_battler.action.forcing = true
  160.     if @skill.need_selection?
  161.       if @skill.for_opponent?
  162.         start_target_enemy_selection
  163.       else
  164.         start_target_actor_selection
  165.       end
  166.     else
  167.       end_skill_selection
  168.       next_actor
  169.     end
  170.   end
  171.  
  172. end
  173.  
  174. class Game_Actor < Game_Battler
  175.  
  176.   def skills_include?(skill_id)
  177.     return @skills.include?(skill_id)
  178.   end
  179.  
  180. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement