Advertisement
Guest User

Game Interpreter

a guest
Mar 3rd, 2012
3,512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 59.13 KB | None | 0 0
  1. #==============================================================================
  2. # ** Game_Interpreter
  3. #------------------------------------------------------------------------------
  4. #  An interpreter for executing event commands. This class is used within the
  5. # Game_Map, Game_Troop, and Game_Event classes.
  6. #==============================================================================
  7.  
  8. class Game_Interpreter
  9.   #--------------------------------------------------------------------------
  10.   # * Object Initialization
  11.   #     depth : nest depth
  12.   #     main  : main flag
  13.   #--------------------------------------------------------------------------
  14.   def initialize(depth = 0, main = false)
  15.     @depth = depth
  16.     @main = main
  17.     if @depth > 100
  18.       print("Common event call has exceeded maximum limit.")
  19.       exit
  20.     end
  21.     clear
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # * Clear
  25.   #--------------------------------------------------------------------------
  26.   def clear
  27.     @map_id = 0                       # Map ID when starting up
  28.     @original_event_id = 0            # Event ID when starting up
  29.     @event_id = 0                     # Event ID
  30.     @list = nil                       # Execution content
  31.     @index = 0                        # Index
  32.     @message_waiting = false          # Waiting for message to end
  33.     @moving_character = nil           # Moving character
  34.     @wait_count = 0                   # Wait count
  35.     @child_interpreter = nil          # Child interpreter
  36.     @branch = {}                      # Branch data
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # * Event Setup
  40.   #     list     : list of event commands
  41.   #     event_id : event ID
  42.   #--------------------------------------------------------------------------
  43.   def setup(list, event_id = 0)
  44.     clear                             # Clear internal interpreter state
  45.     @map_id = $game_map.map_id        # Memorize map ID
  46.     @original_event_id = event_id     # Memorize event ID
  47.     @event_id = event_id              # Memorize event ID
  48.     @list = list                      # Memorize execution contents
  49.     @index = 0                        # Initialize index
  50.     cancel_menu_call                  # Cancel menu call
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Cancel Menu Call
  54.   #    Handles the situation when a player is moving and the cancel button
  55.   #    is pushed,  starting an event in the state where a menu call was
  56.   #    reserved.
  57.   #--------------------------------------------------------------------------
  58.   def cancel_menu_call
  59.     if @main and $game_temp.next_scene == "menu" and $game_temp.menu_beep
  60.       $game_temp.next_scene = nil
  61.       $game_temp.menu_beep = false
  62.     end
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # * Determine if Running
  66.   #--------------------------------------------------------------------------
  67.   def running?
  68.     return @list != nil
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # * Starting Event Setup
  72.   #--------------------------------------------------------------------------
  73.   def setup_starting_event
  74.     if $game_map.need_refresh             # If necessary, refresh the map
  75.       $game_map.refresh
  76.     end
  77.     if $game_temp.common_event_id > 0     # Common event call reserved?
  78.       setup($data_common_events[$game_temp.common_event_id].list)
  79.       $game_temp.common_event_id = 0
  80.       return
  81.     end
  82.     for event in $game_map.events.values  # Map event
  83.       if event.starting                   # If a starting event is found
  84.         event.clear_starting              # Clear starting flag
  85.         setup(event.list, event.id)       # Set up event
  86.         return
  87.       end
  88.     end
  89.     for event in $data_common_events.compact      # Common event
  90.       if event.trigger == 1 and                   # If autorun and
  91.          $game_switches[event.switch_id] == true  # condition switch is ON
  92.         setup(event.list)                         # Set up event
  93.         return
  94.       end
  95.     end
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # * Frame Update
  99.   #--------------------------------------------------------------------------
  100.   def update
  101.     loop do
  102.       if $game_map.map_id != @map_id        # Map is different?
  103.         @event_id = 0                       # Make event ID 0
  104.       end
  105.       if @child_interpreter != nil          # If child interpreter exists
  106.         @child_interpreter.update           # Update child interpreter
  107.         if @child_interpreter.running?      # If running
  108.           return                            # Return
  109.         else                                # After execution has finished
  110.           @child_interpreter = nil          # Erase child interpreter
  111.         end
  112.       end
  113.       if @message_waiting                   # Waiting for message finish
  114.         return
  115.       end
  116.       if @moving_character != nil           # Waiting for move to finish
  117.         if @moving_character.move_route_forcing
  118.           return
  119.         end
  120.         @moving_character = nil
  121.       end
  122.       if @wait_count > 0                    # Waiting
  123.         @wait_count -= 1
  124.         return
  125.       end
  126.       if $game_troop.forcing_battler != nil # Forcing battle action
  127.         return
  128.       end
  129.       if $game_temp.next_scene != nil       # Opening screens
  130.         return
  131.       end
  132.       if @list == nil                       # If content list is empty
  133.         setup_starting_event if @main       # Set up starting event
  134.         return if @list == nil              # Nothing was set up
  135.       end
  136.       return if execute_command == false    # Execute event command
  137.       @index += 1                           # Advance index
  138.     end
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # * Actor iterator (ID)
  142.   #     param : If 1 or more, ID. If 0, all
  143.   #--------------------------------------------------------------------------
  144.   def iterate_actor_id(param)
  145.     if param == 0       # All
  146.       for actor in $game_party.members do yield actor end
  147.     else                # One
  148.       actor = $game_actors[param]
  149.       yield actor unless actor == nil
  150.     end
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # * Actor iterator (index)
  154.   #     param : If 0 or more, index. If -1, all.
  155.   #--------------------------------------------------------------------------
  156.   def iterate_actor_index(param)
  157.     if param == -1      # All
  158.       for actor in $game_party.members do yield actor end
  159.     else                # One
  160.       actor = $game_party.members[param]
  161.       yield actor unless actor == nil
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # * Enemy iterator (index)
  166.   #     param : If 0 or more, index. If -1, all.
  167.   #--------------------------------------------------------------------------
  168.   def iterate_enemy_index(param)
  169.     if param == -1      # All
  170.       for enemy in $game_troop.members do yield enemy end
  171.     else                # One
  172.       enemy = $game_troop.members[param]
  173.       yield enemy unless enemy == nil
  174.     end
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # * Battler iterator (for entire troop, entire party)
  178.   #     param1 : If 0, enemy. If 1, actor.
  179.   #     param : If 0 or more, index. If -1, all.
  180.   #--------------------------------------------------------------------------
  181.   def iterate_battler(param1, param2)
  182.     if $game_temp.in_battle
  183.       if param1 == 0      # Enemy
  184.         iterate_enemy_index(param2) do |enemy| yield enemy end
  185.       else                # Actor
  186.         iterate_actor_index(param2) do |enemy| yield enemy end
  187.       end
  188.     end
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # * Get Screen Command Target
  192.   #--------------------------------------------------------------------------
  193.   def screen
  194.     if $game_temp.in_battle
  195.       return $game_troop.screen
  196.     else
  197.       return $game_map.screen
  198.     end
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # * Event Command Execution
  202.   #--------------------------------------------------------------------------
  203.   def execute_command
  204.     if @index >= @list.size-1
  205.       command_end
  206.       return true
  207.     else
  208.       @params = @list[@index].parameters
  209.       @indent = @list[@index].indent
  210.       case @list[@index].code
  211.       when 101  # Show Text
  212.         return command_101
  213.       when 102  # Show Choices
  214.         return command_102
  215.       when 402  # When [**]
  216.         return command_402
  217.       when 403  # When Cancel
  218.         return command_403
  219.       when 103  # Input Number
  220.         return command_103
  221.       when 111  # Conditional Branch
  222.         return command_111
  223.       when 411  # Else
  224.         return command_411
  225.       when 112  # Loop
  226.         return command_112
  227.       when 413  # Repeat Above
  228.         return command_413
  229.       when 113  # Break Loop
  230.         return command_113
  231.       when 115  # Exit Event Processing
  232.         return command_115
  233.       when 117  # Call Common Event
  234.         return command_117
  235.       when 118  # Label
  236.         return command_118
  237.       when 119  # Jump to Label
  238.         return command_119
  239.       when 121  # Control Switches
  240.         return command_121
  241.       when 122  # Control Variables
  242.         return command_122
  243.       when 123  # Control Self Switch
  244.         return command_123
  245.       when 124  # Control Timer
  246.         return command_124
  247.       when 125  # Change Gold
  248.         return command_125
  249.       when 126  # Change Items
  250.         return command_126
  251.       when 127  # Change Weapons
  252.         return command_127
  253.       when 128  # Change Armor
  254.         return command_128
  255.       when 129  # Change Party Member
  256.         return command_129
  257.       when 132  # Change Battle BGM
  258.         return command_132
  259.       when 133  # Change Battle End ME
  260.         return command_133
  261.       when 134  # Change Save Access
  262.         return command_134
  263.       when 135  # Change Menu Access
  264.         return command_135
  265.       when 136  # Change Encounter
  266.         return command_136
  267.       when 201  # Transfer Player
  268.         return command_201
  269.       when 202  # Set Vehicle Location
  270.         return command_202
  271.       when 203  # Set Event Location
  272.         return command_203
  273.       when 204  # Scroll Map
  274.         return command_204
  275.       when 205  # Set Move Route
  276.         return command_205
  277.       when 206  # Get on/off Vehicle
  278.         return command_206
  279.       when 211  # Change Transparency
  280.         return command_211
  281.       when 212  # Show Animation
  282.         return command_212
  283.       when 213  # Show Balloon Icon
  284.         return command_213
  285.       when 214  # Erase Event
  286.         return command_214
  287.       when 221  # Fadeout Screen
  288.         return command_221
  289.       when 222  # Fadein Screen
  290.         return command_222
  291.       when 223  # Tint Screen
  292.         return command_223
  293.       when 224  # Flash Screen
  294.         return command_224
  295.       when 225  # Shake Screen
  296.         return command_225
  297.       when 230  # Wait
  298.         return command_230
  299.       when 231  # Show Picture
  300.         return command_231
  301.       when 232  # Move Picture
  302.         return command_232
  303.       when 233  # Rotate Picture
  304.         return command_233
  305.       when 234  # Tint Picture
  306.         return command_234
  307.       when 235  # Erase picture
  308.         return command_235
  309.       when 236  # Set Weather Effects
  310.         return command_236
  311.       when 241  # Play BGM
  312.         return command_241
  313.       when 242  # Fadeout BGM
  314.         return command_242
  315.       when 245  # Play BGS
  316.         return command_245
  317.       when 246  # Fadeout BGS
  318.         return command_246
  319.       when 249  # Play ME
  320.         return command_249
  321.       when 250  # Play SE
  322.         return command_250
  323.       when 251  # Stop SE
  324.         return command_251
  325.       when 301  # Battle Processing
  326.         return command_301
  327.       when 601  # If Win
  328.         return command_601
  329.       when 602  # If Escape
  330.         return command_602
  331.       when 603  # If Lose
  332.         return command_603
  333.       when 302  # Shop Processing
  334.         return command_302
  335.       when 303  # Name Input Processing
  336.         return command_303
  337.       when 311  # Change HP
  338.         return command_311
  339.       when 312  # Change MP
  340.         return command_312
  341.       when 313  # Change State
  342.         return command_313
  343.       when 314  # Recover All
  344.         return command_314
  345.       when 315  # Change EXP
  346.         return command_315
  347.       when 316  # Change Level
  348.         return command_316
  349.       when 317  # Change Parameters
  350.         return command_317
  351.       when 318  # Change Skills
  352.         return command_318
  353.       when 319  # Change Equipment
  354.         return command_319
  355.       when 320  # Change Name
  356.         return command_320
  357.       when 321  # Change Class
  358.         return command_321
  359.       when 322  # Change Actor Graphic
  360.         return command_322
  361.       when 323  # Change Vehicle Graphic
  362.         return command_323
  363.       when 331  #  Change Enemy HP
  364.         return command_331
  365.       when 332  #  Change Enemy MP
  366.         return command_332
  367.       when 333  # Change Enemy State
  368.         return command_333
  369.       when 334  # Enemy Recover All
  370.         return command_334
  371.       when 335  # Enemy Appear
  372.         return command_335
  373.       when 336  # Enemy Transform
  374.         return command_336
  375.       when 337  # Show Battle Animation
  376.         return command_337
  377.       when 339  # Force Action
  378.         return command_339
  379.       when 340  # Abort Battle
  380.         return command_340
  381.       when 351  # Open Menu Screen
  382.         return command_351
  383.       when 352  # Open Save Screen
  384.         return command_352
  385.       when 353  # Game Over
  386.         return command_353
  387.       when 354  # Return to Title Screen
  388.         return command_354
  389.       when 355  # Script
  390.         return command_355
  391.       else      # Other
  392.         return true
  393.       end
  394.     end
  395.   end
  396.   #--------------------------------------------------------------------------
  397.   # * End Event
  398.   #--------------------------------------------------------------------------
  399.   def command_end
  400.     @list = nil                             # Clear execution content list
  401.     if @main and @event_id > 0              # If main map event
  402.       $game_map.events[@event_id].unlock    # Clear event lock
  403.     end
  404.   end
  405.   #--------------------------------------------------------------------------
  406.   # * Command Skip
  407.   #--------------------------------------------------------------------------
  408.   def command_skip
  409.     while @list[@index+1].indent > @indent  # Next indent is deeper
  410.       @index += 1                           # Advance index
  411.     end
  412.   end
  413.   #--------------------------------------------------------------------------
  414.   # * Get Character
  415.   #     param : if -1, player. If 0, this event. Otherwise, event ID.
  416.   #--------------------------------------------------------------------------
  417.   def get_character(param)
  418.     case param
  419.     when -1   # Player
  420.       return $game_player
  421.     when 0    # This event
  422.       events = $game_map.events
  423.       return events == nil ? nil : events[@event_id]
  424.     else      # Particular event
  425.       events = $game_map.events
  426.       return events == nil ? nil : events[param]
  427.     end
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # * Calculate Operated Value
  431.   #     operation    : operation (0: increase, 1: decrease)
  432.   #     operand_type : operand type (0: invariable 1: variable)
  433.   #     operand      : operand (number or variable ID)
  434.   #--------------------------------------------------------------------------
  435.   def operate_value(operation, operand_type, operand)
  436.     if operand_type == 0
  437.       value = operand
  438.     else
  439.       value = $game_variables[operand]
  440.     end
  441.     if operation == 1
  442.       value = -value
  443.     end
  444.     return value
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # * Show Text
  448.   #--------------------------------------------------------------------------
  449.   def command_101
  450.     unless $game_message.busy
  451.       $game_message.face_name = @params[0]
  452.       $game_message.face_index = @params[1]
  453.       $game_message.background = @params[2]
  454.       $game_message.position = @params[3]
  455.       @index += 1
  456.       while @list[@index].code == 401       # Text data
  457.         $game_message.texts.push(@list[@index].parameters[0])
  458.         @index += 1
  459.       end
  460.       if @list[@index].code == 102          # Show choices
  461.         setup_choices(@list[@index].parameters)
  462.       elsif @list[@index].code == 103       # Number input processing
  463.         setup_num_input(@list[@index].parameters)
  464.       end
  465.       set_message_waiting                   # Set to message wait state
  466.     end
  467.     return false
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # * Set message wait flag and callback
  471.   #--------------------------------------------------------------------------
  472.   def set_message_waiting
  473.     @message_waiting = true
  474.     $game_message.main_proc = Proc.new { @message_waiting = false }
  475.   end
  476.   #--------------------------------------------------------------------------
  477.   # * Show Choices
  478.   #--------------------------------------------------------------------------
  479.   def command_102
  480.     unless $game_message.busy
  481.       setup_choices(@params)                # Setup
  482.       set_message_waiting                   # Set to message wait state
  483.     end
  484.     return false
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # * Setup Choices
  488.   #--------------------------------------------------------------------------
  489.   def setup_choices(params)
  490.     if $game_message.texts.size <= 4 - params[0].size
  491.       $game_message.choice_start = $game_message.texts.size
  492.       $game_message.choice_max = params[0].size
  493.       for s in params[0]
  494.         $game_message.texts.push(s)
  495.       end
  496.       $game_message.choice_cancel_type = params[1]
  497.       $game_message.choice_proc = Proc.new { |n| @branch[@indent] = n }
  498.       @index += 1
  499.     end
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # * When [**]
  503.   #--------------------------------------------------------------------------
  504.   def command_402
  505.     if @branch[@indent] == @params[0]       # If matching choice
  506.       @branch.delete(@indent)               # Erase branching data
  507.       return true                           # Continue
  508.     else                                    # If doesn't match condition
  509.       return command_skip                   # Command skip
  510.     end
  511.   end
  512.   #--------------------------------------------------------------------------
  513.   # * When Cancel
  514.   #--------------------------------------------------------------------------
  515.   def command_403
  516.     if @branch[@indent] == 4                # If canceling choice
  517.       @branch.delete(@indent)               # Erase branching data
  518.       return true                           # Continue
  519.     else                                    # If doesn't match condition
  520.       return command_skip                   # Command skip
  521.     end
  522.   end
  523.   #--------------------------------------------------------------------------
  524.   # * Input Number
  525.   #--------------------------------------------------------------------------
  526.   def command_103
  527.     unless $game_message.busy
  528.       setup_num_input(@params)              # Setup
  529.       set_message_waiting                   # Set to message wait state
  530.     end
  531.     return false
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # * Number Input Setup
  535.   #--------------------------------------------------------------------------
  536.   def setup_num_input(params)
  537.     if $game_message.texts.size < 4
  538.       $game_message.num_input_variable_id = params[0]
  539.       $game_message.num_input_digits_max = params[1]
  540.       @index += 1
  541.     end
  542.   end
  543.   #--------------------------------------------------------------------------
  544.   # * Conditional Branch
  545.   #--------------------------------------------------------------------------
  546.   def command_111
  547.     result = false
  548.     case @params[0]
  549.     when 0  # Switch
  550.       result = ($game_switches[@params[1]] == (@params[2] == 0))
  551.     when 1  # Variable
  552.       value1 = $game_variables[@params[1]]
  553.       if @params[2] == 0
  554.         value2 = @params[3]
  555.       else
  556.         value2 = $game_variables[@params[3]]
  557.       end
  558.       case @params[4]
  559.       when 0  # value1 is equal to value2
  560.         result = (value1 == value2)
  561.       when 1  # value1 is greater than or equal to value2
  562.         result = (value1 >= value2)
  563.       when 2  # value1 is less than or equal to value2
  564.         result = (value1 <= value2)
  565.       when 3  # value1 is greater than value2
  566.         result = (value1 > value2)
  567.       when 4  # value1 is less than value2
  568.         result = (value1 < value2)
  569.       when 5  # value1 is not equal to value2
  570.         result = (value1 != value2)
  571.       end
  572.     when 2  # Self switch
  573.       if @original_event_id > 0
  574.         key = [@map_id, @original_event_id, @params[1]]
  575.         if @params[2] == 0
  576.           result = ($game_self_switches[key] == true)
  577.         else
  578.           result = ($game_self_switches[key] != true)
  579.         end
  580.       end
  581.     when 3  # Timer
  582.       if $game_system.timer_working
  583.         sec = $game_system.timer / Graphics.frame_rate
  584.         if @params[2] == 0
  585.           result = (sec >= @params[1])
  586.         else
  587.           result = (sec <= @params[1])
  588.         end
  589.       end
  590.     when 4  # Actor
  591.       actor = $game_actors[@params[1]]
  592.       if actor != nil
  593.         case @params[2]
  594.         when 0  # in party
  595.           result = ($game_party.members.include?(actor))
  596.         when 1  # name
  597.           result = (actor.name == @params[3])
  598.         when 2  # skill
  599.           result = (actor.skill_learn?($data_skills[@params[3]]))
  600.         when 3  # weapon
  601.           result = (actor.weapons.include?($data_weapons[@params[3]]))
  602.         when 4  # armor
  603.           result = (actor.armors.include?($data_armors[@params[3]]))
  604.         when 5  # state
  605.           result = (actor.state?(@params[3]))
  606.         end
  607.       end
  608.     when 5  # Enemy
  609.       enemy = $game_troop.members[@params[1]]
  610.       if enemy != nil
  611.         case @params[2]
  612.         when 0  # appear
  613.           result = (enemy.exist?)
  614.         when 1  # state
  615.           result = (enemy.state?(@params[3]))
  616.         end
  617.       end
  618.     when 6  # Character
  619.       character = get_character(@params[1])
  620.       if character != nil
  621.         result = (character.direction == @params[2])
  622.       end
  623.     when 7  # Gold
  624.       if @params[2] == 0
  625.         result = ($game_party.gold >= @params[1])
  626.       else
  627.         result = ($game_party.gold <= @params[1])
  628.       end
  629.     when 8  # Item
  630.       result = $game_party.has_item?($data_items[@params[1]])
  631.     when 9  # Weapon
  632.       result = $game_party.has_item?($data_weapons[@params[1]], @params[2])
  633.     when 10  # Armor
  634.       result = $game_party.has_item?($data_armors[@params[1]], @params[2])
  635.     when 11  # Button
  636.       result = Input.press?(@params[1])
  637.     when 12  # Script
  638.       result = eval(@params[1])
  639.     when 13  # Vehicle
  640.       result = ($game_player.vehicle_type == @params[1])
  641.     end
  642.     @branch[@indent] = result     # Store determination results in hash
  643.     if @branch[@indent] == true
  644.       @branch.delete(@indent)
  645.       return true
  646.     end
  647.     return command_skip
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # * Else
  651.   #--------------------------------------------------------------------------
  652.   def command_411
  653.     if @branch[@indent] == false
  654.       @branch.delete(@indent)
  655.       return true
  656.     end
  657.     return command_skip
  658.   end
  659.   #--------------------------------------------------------------------------
  660.   # * Loop
  661.   #--------------------------------------------------------------------------
  662.   def command_112
  663.     return true
  664.   end
  665.   #--------------------------------------------------------------------------
  666.   # * Repeat Above
  667.   #--------------------------------------------------------------------------
  668.   def command_413
  669.     begin
  670.       @index -= 1
  671.     end until @list[@index].indent == @indent
  672.     return true
  673.   end
  674.   #--------------------------------------------------------------------------
  675.   # * Break Loop
  676.   #--------------------------------------------------------------------------
  677.   def command_113
  678.     loop do
  679.       @index += 1
  680.       if @index >= @list.size-1
  681.         return true
  682.       end
  683.       if @list[@index].code == 413 and    # Command [Repeat Above]
  684.          @list[@index].indent < @indent   # Indent is shallow
  685.         return true
  686.       end
  687.     end
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # * Exit Event Processing
  691.   #--------------------------------------------------------------------------
  692.   def command_115
  693.     command_end
  694.     return true
  695.   end
  696.   #--------------------------------------------------------------------------
  697.   # * Call Common Event
  698.   #--------------------------------------------------------------------------
  699.   def command_117
  700.     common_event = $data_common_events[@params[0]]
  701.     if common_event != nil
  702.       @child_interpreter = Game_Interpreter.new(@depth + 1)
  703.       @child_interpreter.setup(common_event.list, @event_id)
  704.     end
  705.     return true
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # * Label
  709.   #--------------------------------------------------------------------------
  710.   def command_118
  711.     return true
  712.   end
  713.   #--------------------------------------------------------------------------
  714.   # * Jump to Label
  715.   #--------------------------------------------------------------------------
  716.   def command_119
  717.     label_name = @params[0]
  718.     for i in 0...@list.size
  719.       if @list[i].code == 118 and @list[i].parameters[0] == label_name
  720.         @index = i
  721.         return true
  722.       end
  723.     end
  724.     return true
  725.   end
  726.   #--------------------------------------------------------------------------
  727.   # * Control Switches
  728.   #--------------------------------------------------------------------------
  729.   def command_121
  730.     for i in @params[0] .. @params[1]   # Batch control
  731.       $game_switches[i] = (@params[2] == 0)
  732.     end
  733.     $game_map.need_refresh = true
  734.     return true
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # * Control Variables
  738.   #--------------------------------------------------------------------------
  739.   def command_122
  740.     value = 0
  741.     case @params[3]  # Operand
  742.     when 0  # Constant
  743.       value = @params[4]
  744.     when 1  # Variable
  745.       value = $game_variables[@params[4]]
  746.     when 2  # Random
  747.       value = @params[4] + rand(@params[5] - @params[4] + 1)
  748.     when 3  # Item
  749.       value = $game_party.item_number($data_items[@params[4]])
  750.     when 4 # Actor
  751.       actor = $game_actors[@params[4]]
  752.       if actor != nil
  753.         case @params[5]
  754.         when 0  # Level
  755.           value = actor.level
  756.         when 1  # Experience
  757.           value = actor.exp
  758.         when 2  # HP
  759.           value = actor.hp
  760.         when 3  # MP
  761.           value = actor.mp
  762.         when 4  # Maximum HP
  763.           value = actor.maxhp
  764.         when 5  # Maximum MP
  765.           value = actor.maxmp
  766.         when 6  # Attack
  767.           value = actor.atk
  768.         when 7  # Defense
  769.           value = actor.def
  770.         when 8  # Spirit
  771.           value = actor.spi
  772.         when 9  # Agility
  773.           value = actor.agi
  774.         end
  775.       end
  776.     when 5  # Enemy
  777.       enemy = $game_troop.members[@params[4]]
  778.       if enemy != nil
  779.         case @params[5]
  780.         when 0  # HP
  781.           value = enemy.hp
  782.         when 1  # MP
  783.           value = enemy.mp
  784.         when 2  # Maximum HP
  785.           value = enemy.maxhp
  786.         when 3  # Maximum MP
  787.           value = enemy.maxmp
  788.         when 4  # Attack
  789.           value = enemy.atk
  790.         when 5  # Defense
  791.           value = enemy.def
  792.         when 6  # Spirit
  793.           value = enemy.spi
  794.         when 7  # Agility
  795.           value = enemy.agi
  796.         end
  797.       end
  798.     when 6  # Character
  799.       character = get_character(@params[4])
  800.       if character != nil
  801.         case @params[5]
  802.         when 0  # x-coordinate
  803.           value = character.x
  804.         when 1  # y-coordinate
  805.           value = character.y
  806.         when 2  # direction
  807.           value = character.direction
  808.         when 3  # screen x-coordinate
  809.           value = character.screen_x
  810.         when 4  # screen y-coordinate
  811.           value = character.screen_y
  812.         end
  813.       end
  814.     when 7  # Other
  815.       case @params[4]
  816.       when 0  # map ID
  817.         value = $game_map.map_id
  818.       when 1  # number of party members
  819.         value = $game_party.members.size
  820.       when 2  # gold
  821.         value = $game_party.gold
  822.       when 3  # steps
  823.         value = $game_party.steps
  824.       when 4  # play time
  825.         value = Graphics.frame_count / Graphics.frame_rate
  826.       when 5  # timer
  827.         value = $game_system.timer / Graphics.frame_rate
  828.       when 6  # save count
  829.         value = $game_system.save_count
  830.       end
  831.     end
  832.     for i in @params[0] .. @params[1]   # Batch control
  833.       case @params[2]  # Operation
  834.       when 0  # Set
  835.         $game_variables[i] = value
  836.       when 1  # Add
  837.         $game_variables[i] += value
  838.       when 2  # Sub
  839.         $game_variables[i] -= value
  840.       when 3  # Mul
  841.         $game_variables[i] *= value
  842.       when 4  # Div
  843.         $game_variables[i] /= value if value != 0
  844.       when 5  # Mod
  845.         $game_variables[i] %= value if value != 0
  846.       end
  847.       if $game_variables[i] > 99999999    # Maximum limit check
  848.         $game_variables[i] = 99999999
  849.       end
  850.       if $game_variables[i] < -99999999   # Minimum limit check
  851.         $game_variables[i] = -99999999
  852.       end
  853.     end
  854.     $game_map.need_refresh = true
  855.     return true
  856.   end
  857.   #--------------------------------------------------------------------------
  858.   # * Control Self Switch
  859.   #--------------------------------------------------------------------------
  860.   def command_123
  861.     if @original_event_id > 0
  862.       key = [@map_id, @original_event_id, @params[0]]
  863.       $game_self_switches[key] = (@params[1] == 0)
  864.     end
  865.     $game_map.need_refresh = true
  866.     return true
  867.   end
  868.   #--------------------------------------------------------------------------
  869.   # * Control Timer
  870.   #--------------------------------------------------------------------------
  871.   def command_124
  872.     if @params[0] == 0  # Start
  873.       $game_system.timer = @params[1] * Graphics.frame_rate
  874.       $game_system.timer_working = true
  875.     end
  876.     if @params[0] == 1  # Stop
  877.       $game_system.timer_working = false
  878.     end
  879.     return true
  880.   end
  881.   #--------------------------------------------------------------------------
  882.   # * Change Gold
  883.   #--------------------------------------------------------------------------
  884.   def command_125
  885.     value = operate_value(@params[0], @params[1], @params[2])
  886.     $game_party.gain_gold(value)
  887.     return true
  888.   end
  889.   #--------------------------------------------------------------------------
  890.   # * Change Items
  891.   #--------------------------------------------------------------------------
  892.   def command_126
  893.     value = operate_value(@params[1], @params[2], @params[3])
  894.     $game_party.gain_item($data_items[@params[0]], value)
  895.     $game_map.need_refresh = true
  896.     return true
  897.   end
  898.   #--------------------------------------------------------------------------
  899.   # * Change Weapons
  900.   #--------------------------------------------------------------------------
  901.   def command_127
  902.     value = operate_value(@params[1], @params[2], @params[3])
  903.     $game_party.gain_item($data_weapons[@params[0]], value, @params[4])
  904.     return true
  905.   end
  906.   #--------------------------------------------------------------------------
  907.   # * Change Armor
  908.   #--------------------------------------------------------------------------
  909.   def command_128
  910.     value = operate_value(@params[1], @params[2], @params[3])
  911.     $game_party.gain_item($data_armors[@params[0]], value, @params[4])
  912.     return true
  913.   end
  914.   #--------------------------------------------------------------------------
  915.   # * Change Party Member
  916.   #--------------------------------------------------------------------------
  917.   def command_129
  918.     actor = $game_actors[@params[0]]
  919.     if actor != nil
  920.       if @params[1] == 0    # Add
  921.         if @params[2] == 1  # Initialize
  922.           $game_actors[@params[0]].setup(@params[0])
  923.         end
  924.         $game_party.add_actor(@params[0])
  925.       else                  # Remove
  926.         $game_party.remove_actor(@params[0])
  927.       end
  928.       $game_map.need_refresh = true
  929.     end
  930.     return true
  931.   end
  932.   #--------------------------------------------------------------------------
  933.   # * Change Battle BGM
  934.   #--------------------------------------------------------------------------
  935.   def command_132
  936.     $game_system.battle_bgm = @params[0]
  937.     return true
  938.   end
  939.   #--------------------------------------------------------------------------
  940.   # * Change Battle End ME
  941.   #--------------------------------------------------------------------------
  942.   def command_133
  943.     $game_system.battle_end_me = @params[0]
  944.     return true
  945.   end
  946.   #--------------------------------------------------------------------------
  947.   # * Change Save Access
  948.   #--------------------------------------------------------------------------
  949.   def command_134
  950.     $game_system.save_disabled = (@params[0] == 0)
  951.     return true
  952.   end
  953.   #--------------------------------------------------------------------------
  954.   # * Change Menu Access
  955.   #--------------------------------------------------------------------------
  956.   def command_135
  957.     $game_system.menu_disabled = (@params[0] == 0)
  958.     return true
  959.   end
  960.   #--------------------------------------------------------------------------
  961.   # * Change Encounter
  962.   #--------------------------------------------------------------------------
  963.   def command_136
  964.     $game_system.encounter_disabled = (@params[0] == 0)
  965.     $game_player.make_encounter_count
  966.     return true
  967.   end
  968.   #--------------------------------------------------------------------------
  969.   # * Transfer Player
  970.   #--------------------------------------------------------------------------
  971.   def command_201
  972.     return true if $game_temp.in_battle
  973.     if $game_player.transfer? or            # Transferring Player
  974.        $game_message.visible                # Displaying a message
  975.       return false
  976.     end
  977.     if @params[0] == 0                      # Direct designation
  978.       map_id = @params[1]
  979.       x = @params[2]
  980.       y = @params[3]
  981.       direction = @params[4]
  982.     else                                    # Designation with variables
  983.       map_id = $game_variables[@params[1]]
  984.       x = $game_variables[@params[2]]
  985.       y = $game_variables[@params[3]]
  986.       direction = @params[4]
  987.     end
  988.     $game_player.reserve_transfer(map_id, x, y, direction)
  989.     @index += 1
  990.     return false
  991.   end
  992.   #--------------------------------------------------------------------------
  993.   # * Set Vehicle Location
  994.   #--------------------------------------------------------------------------
  995.   def command_202
  996.     if @params[1] == 0                      # Direct designation
  997.       map_id = @params[2]
  998.       x = @params[3]
  999.       y = @params[4]
  1000.     else                                    # Designation with variables
  1001.       map_id = $game_variables[@params[2]]
  1002.       x = $game_variables[@params[3]]
  1003.       y = $game_variables[@params[4]]
  1004.     end
  1005.     if @params[0] == 0                      # Boat
  1006.       $game_map.boat.set_location(map_id, x, y)
  1007.     elsif @params[0] == 1                   # Ship
  1008.       $game_map.ship.set_location(map_id, x, y)
  1009.     else                                    # Airship
  1010.       $game_map.airship.set_location(map_id, x, y)
  1011.     end
  1012.     return true
  1013.   end
  1014.   #--------------------------------------------------------------------------
  1015.   # * Set Event Location
  1016.   #--------------------------------------------------------------------------
  1017.   def command_203
  1018.     character = get_character(@params[0])
  1019.     if character != nil
  1020.       if @params[1] == 0                      # Direct designation
  1021.         character.moveto(@params[2], @params[3])
  1022.       elsif @params[1] == 1                   # Designation with variables
  1023.         new_x = $game_variables[@params[2]]
  1024.         new_y = $game_variables[@params[3]]
  1025.         character.moveto(new_x, new_y)
  1026.       else                                    # Exchange with another event
  1027.         old_x = character.x
  1028.         old_y = character.y
  1029.         character2 = get_character(@params[2])
  1030.         if character2 != nil
  1031.           character.moveto(character2.x, character2.y)
  1032.           character2.moveto(old_x, old_y)
  1033.         end
  1034.       end
  1035.       case @params[4]   # Direction
  1036.       when 8  # Up
  1037.         character.turn_up
  1038.       when 6  # Right
  1039.         character.turn_right
  1040.       when 2  # Down
  1041.         character.turn_down
  1042.       when 4  # Left
  1043.         character.turn_left
  1044.       end
  1045.     end
  1046.     return true
  1047.   end
  1048.   #--------------------------------------------------------------------------
  1049.   # * Scroll Map
  1050.   #--------------------------------------------------------------------------
  1051.   def command_204
  1052.     return true if $game_temp.in_battle
  1053.     return false if $game_map.scrolling?
  1054.     $game_map.start_scroll(@params[0], @params[1], @params[2])
  1055.     return true
  1056.   end
  1057.   #--------------------------------------------------------------------------
  1058.   # * Set Move Route
  1059.   #--------------------------------------------------------------------------
  1060.   def command_205
  1061.     if $game_map.need_refresh
  1062.       $game_map.refresh
  1063.     end
  1064.     character = get_character(@params[0])
  1065.     if character != nil
  1066.       character.force_move_route(@params[1])
  1067.       @moving_character = character if @params[1].wait
  1068.     end
  1069.     return true
  1070.   end
  1071.   #--------------------------------------------------------------------------
  1072.   # * Get on/off Vehicle
  1073.   #--------------------------------------------------------------------------
  1074.   def command_206
  1075.     $game_player.get_on_off_vehicle
  1076.     return true
  1077.   end
  1078.   #--------------------------------------------------------------------------
  1079.   # * Change Transparency
  1080.   #--------------------------------------------------------------------------
  1081.   def command_211
  1082.     $game_player.transparent = (@params[0] == 0)
  1083.     return true
  1084.   end
  1085.   #--------------------------------------------------------------------------
  1086.   # * Show Animation
  1087.   #--------------------------------------------------------------------------
  1088.   def command_212
  1089.     character = get_character(@params[0])
  1090.     if character != nil
  1091.       character.animation_id = @params[1]
  1092.     end
  1093.     return true
  1094.   end
  1095.   #--------------------------------------------------------------------------
  1096.   # * Show Balloon Icon
  1097.   #--------------------------------------------------------------------------
  1098.   def command_213
  1099.     character = get_character(@params[0])
  1100.     if character != nil
  1101.       character.balloon_id = @params[1]
  1102.     end
  1103.     return true
  1104.   end
  1105.   #--------------------------------------------------------------------------
  1106.   # * Erase Event
  1107.   #--------------------------------------------------------------------------
  1108.   def command_214
  1109.     if @event_id > 0
  1110.       $game_map.events[@event_id].erase
  1111.     end
  1112.     @index += 1
  1113.     return false
  1114.   end
  1115.   #--------------------------------------------------------------------------
  1116.   # * Fadeout Screen
  1117.   #--------------------------------------------------------------------------
  1118.   def command_221
  1119.     if $game_message.visible
  1120.       return false
  1121.     else
  1122.       screen.start_fadeout(30)
  1123.       @wait_count = 30
  1124.       return true
  1125.     end
  1126.   end
  1127.   #--------------------------------------------------------------------------
  1128.   # * Fadein Screen
  1129.   #--------------------------------------------------------------------------
  1130.   def command_222
  1131.     if $game_message.visible
  1132.       return false
  1133.     else
  1134.       screen.start_fadein(30)
  1135.       @wait_count = 30
  1136.       return true
  1137.     end
  1138.   end
  1139.   #--------------------------------------------------------------------------
  1140.   # * Tint Screen
  1141.   #--------------------------------------------------------------------------
  1142.   def command_223
  1143.     screen.start_tone_change(@params[0], @params[1])
  1144.     @wait_count = @params[1] if @params[2]
  1145.     return true
  1146.   end
  1147.   #--------------------------------------------------------------------------
  1148.   # * Screen Flash
  1149.   #--------------------------------------------------------------------------
  1150.   def command_224
  1151.     screen.start_flash(@params[0], @params[1])
  1152.     @wait_count = @params[1] if @params[2]
  1153.     return true
  1154.   end
  1155.   #--------------------------------------------------------------------------
  1156.   # * Screen Shake
  1157.   #--------------------------------------------------------------------------
  1158.   def command_225
  1159.     screen.start_shake(@params[0], @params[1], @params[2])
  1160.     @wait_count = @params[2] if @params[3]
  1161.     return true
  1162.   end
  1163.   #--------------------------------------------------------------------------
  1164.   # * Wait
  1165.   #--------------------------------------------------------------------------
  1166.   def command_230
  1167.     @wait_count = @params[0]
  1168.     return true
  1169.   end
  1170.   #--------------------------------------------------------------------------
  1171.   # * Show Picture
  1172.   #--------------------------------------------------------------------------
  1173.   def command_231
  1174.     if @params[3] == 0    # Direct designation
  1175.       x = @params[4]
  1176.       y = @params[5]
  1177.     else                  # Designation with variables
  1178.       x = $game_variables[@params[4]]
  1179.       y = $game_variables[@params[5]]
  1180.     end
  1181.     screen.pictures[@params[0]].show(@params[1], @params[2],
  1182.       x, y, @params[6], @params[7], @params[8], @params[9])
  1183.     return true
  1184.   end
  1185.   #--------------------------------------------------------------------------
  1186.   # * Move Picture
  1187.   #--------------------------------------------------------------------------
  1188.   def command_232
  1189.     if @params[3] == 0    # Direct designation
  1190.       x = @params[4]
  1191.       y = @params[5]
  1192.     else                  # Designation with variables
  1193.       x = $game_variables[@params[4]]
  1194.       y = $game_variables[@params[5]]
  1195.     end
  1196.     screen.pictures[@params[0]].move(@params[2], x, y, @params[6],
  1197.       @params[7], @params[8], @params[9], @params[10])
  1198.     @wait_count = @params[10] if @params[11]
  1199.     return true
  1200.   end
  1201.   #--------------------------------------------------------------------------
  1202.   # * Rotate Picture
  1203.   #--------------------------------------------------------------------------
  1204.   def command_233
  1205.     screen.pictures[@params[0]].rotate(@params[1])
  1206.     return true
  1207.   end
  1208.   #--------------------------------------------------------------------------
  1209.   # * Tint Picture
  1210.   #--------------------------------------------------------------------------
  1211.   def command_234
  1212.     screen.pictures[@params[0]].start_tone_change(@params[1], @params[2])
  1213.     @wait_count = @params[2] if @params[3]
  1214.     return true
  1215.   end
  1216.   #--------------------------------------------------------------------------
  1217.   # * Erase Picture
  1218.   #--------------------------------------------------------------------------
  1219.   def command_235
  1220.     screen.pictures[@params[0]].erase
  1221.     return true
  1222.   end
  1223.   #--------------------------------------------------------------------------
  1224.   # * Set Weather Effects
  1225.   #--------------------------------------------------------------------------
  1226.   def command_236
  1227.     return true if $game_temp.in_battle
  1228.     screen.weather(@params[0], @params[1], @params[2])
  1229.     @wait_count = @params[2] if @params[3]
  1230.     return true
  1231.   end
  1232.   #--------------------------------------------------------------------------
  1233.   # * Play BGM
  1234.   #--------------------------------------------------------------------------
  1235.   def command_241
  1236.     @params[0].play
  1237.     return true
  1238.   end
  1239.   #--------------------------------------------------------------------------
  1240.   # * Fadeout BGM
  1241.   #--------------------------------------------------------------------------
  1242.   def command_242
  1243.     RPG::BGM.fade(@params[0] * 1000)
  1244.     return true
  1245.   end
  1246.   #--------------------------------------------------------------------------
  1247.   # * Play BGS
  1248.   #--------------------------------------------------------------------------
  1249.   def command_245
  1250.     @params[0].play
  1251.     return true
  1252.   end
  1253.   #--------------------------------------------------------------------------
  1254.   # * Fadeout BGS
  1255.   #--------------------------------------------------------------------------
  1256.   def command_246
  1257.     RPG::BGS.fade(@params[0] * 1000)
  1258.     return true
  1259.   end
  1260.   #--------------------------------------------------------------------------
  1261.   # * Play ME
  1262.   #--------------------------------------------------------------------------
  1263.   def command_249
  1264.     @params[0].play
  1265.     return true
  1266.   end
  1267.   #--------------------------------------------------------------------------
  1268.   # * Play SE
  1269.   #--------------------------------------------------------------------------
  1270.   def command_250
  1271.     @params[0].play
  1272.     return true
  1273.   end
  1274.   #--------------------------------------------------------------------------
  1275.   # * Stop SE
  1276.   #--------------------------------------------------------------------------
  1277.   def command_251
  1278.     RPG::SE.stop
  1279.     return true
  1280.   end
  1281.   #--------------------------------------------------------------------------
  1282.   # * Battle Processing
  1283.   #--------------------------------------------------------------------------
  1284.   def command_301
  1285.     return true if $game_temp.in_battle
  1286.     if @params[0] == 0                      # Direct designation
  1287.       troop_id = @params[1]
  1288.     else                                    # Designation with variables
  1289.       troop_id = $game_variables[@params[1]]
  1290.     end
  1291.     if $data_troops[troop_id] != nil
  1292.       $game_troop.setup(troop_id)
  1293.       $game_troop.can_escape = @params[2]
  1294.       $game_troop.can_lose = @params[3]
  1295.       $game_temp.battle_proc = Proc.new { |n| @branch[@indent] = n }
  1296.       $game_temp.next_scene = "battle"
  1297.     end
  1298.     @index += 1
  1299.     return false
  1300.   end
  1301.   #--------------------------------------------------------------------------
  1302.   # * If Win
  1303.   #--------------------------------------------------------------------------
  1304.   def command_601
  1305.     if @branch[@indent] == 0
  1306.       @branch.delete(@indent)
  1307.       return true
  1308.     end
  1309.     return command_skip
  1310.   end
  1311.   #--------------------------------------------------------------------------
  1312.   # * If Escape
  1313.   #--------------------------------------------------------------------------
  1314.   def command_602
  1315.     if @branch[@indent] == 1
  1316.       @branch.delete(@indent)
  1317.       return true
  1318.     end
  1319.     return command_skip
  1320.   end
  1321.   #--------------------------------------------------------------------------
  1322.   # * If Lose
  1323.   #--------------------------------------------------------------------------
  1324.   def command_603
  1325.     if @branch[@indent] == 2
  1326.       @branch.delete(@indent)
  1327.       return true
  1328.     end
  1329.     return command_skip
  1330.   end
  1331.   #--------------------------------------------------------------------------
  1332.   # * Shop Processing
  1333.   #--------------------------------------------------------------------------
  1334.   def command_302
  1335.     $game_temp.next_scene = "shop"
  1336.     $game_temp.shop_goods = [@params]
  1337.     $game_temp.shop_purchase_only = @params[2]
  1338.     loop do
  1339.       @index += 1
  1340.       if @list[@index].code == 605          # Shop second line or after
  1341.         $game_temp.shop_goods.push(@list[@index].parameters)
  1342.       else
  1343.         return false
  1344.       end
  1345.     end
  1346.   end
  1347.   #--------------------------------------------------------------------------
  1348.   # * Name Input Processing
  1349.   #--------------------------------------------------------------------------
  1350.   def command_303
  1351.     if $data_actors[@params[0]] != nil
  1352.       $game_temp.next_scene = "name"
  1353.       $game_temp.name_actor_id = @params[0]
  1354.       $game_temp.name_max_char = @params[1]
  1355.     end
  1356.     @index += 1
  1357.     return false
  1358.   end
  1359.   #--------------------------------------------------------------------------
  1360.   # * Change HP
  1361.   #--------------------------------------------------------------------------
  1362.   def command_311
  1363.     value = operate_value(@params[1], @params[2], @params[3])
  1364.     iterate_actor_id(@params[0]) do |actor|
  1365.       next if actor.dead?
  1366.       if @params[4] == false and actor.hp + value <= 0
  1367.         actor.hp = 1    # If incapacitation is not allowed, make 1
  1368.       else
  1369.         actor.hp += value
  1370.       end
  1371.       actor.perform_collapse
  1372.     end
  1373.     if $game_party.all_dead?
  1374.       $game_temp.next_scene = "gameover"
  1375.     end
  1376.     return true
  1377.   end
  1378.   #--------------------------------------------------------------------------
  1379.   # * Change MP
  1380.   #--------------------------------------------------------------------------
  1381.   def command_312
  1382.     value = operate_value(@params[1], @params[2], @params[3])
  1383.     iterate_actor_id(@params[0]) do |actor|
  1384.       actor.mp += value
  1385.     end
  1386.     return true
  1387.   end
  1388.   #--------------------------------------------------------------------------
  1389.   # * Change State
  1390.   #--------------------------------------------------------------------------
  1391.   def command_313
  1392.     iterate_actor_id(@params[0]) do |actor|
  1393.       if @params[1] == 0
  1394.         actor.add_state(@params[2])
  1395.         actor.perform_collapse
  1396.       else
  1397.         actor.remove_state(@params[2])
  1398.       end
  1399.     end
  1400.     return true
  1401.   end
  1402.   #--------------------------------------------------------------------------
  1403.   # * Recover All
  1404.   #--------------------------------------------------------------------------
  1405.   def command_314
  1406.     iterate_actor_id(@params[0]) do |actor|
  1407.       actor.recover_all
  1408.     end
  1409.     return true
  1410.   end
  1411.   #--------------------------------------------------------------------------
  1412.   # * Change EXP
  1413.   #--------------------------------------------------------------------------
  1414.   def command_315
  1415.     value = operate_value(@params[1], @params[2], @params[3])
  1416.     iterate_actor_id(@params[0]) do |actor|
  1417.       actor.change_exp(actor.exp + value, @params[4])
  1418.     end
  1419.     return true
  1420.   end
  1421.   #--------------------------------------------------------------------------
  1422.   # * Change Level
  1423.   #--------------------------------------------------------------------------
  1424.   def command_316
  1425.     value = operate_value(@params[1], @params[2], @params[3])
  1426.     iterate_actor_id(@params[0]) do |actor|
  1427.       actor.change_level(actor.level + value, @params[4])
  1428.     end
  1429.     return true
  1430.   end
  1431.   #--------------------------------------------------------------------------
  1432.   # * Change Parameters
  1433.   #--------------------------------------------------------------------------
  1434.   def command_317
  1435.     value = operate_value(@params[2], @params[3], @params[4])
  1436.     actor = $game_actors[@params[0]]
  1437.     if actor != nil
  1438.       case @params[1]
  1439.       when 0  # Maximum HP
  1440.         actor.maxhp += value
  1441.       when 1  # Maximum MP
  1442.         actor.maxmp += value
  1443.       when 2  # Attack
  1444.         actor.atk += value
  1445.       when 3  # Defense
  1446.         actor.def += value
  1447.       when 4  # Spirit
  1448.         actor.spi += value
  1449.       when 5  # Agility
  1450.         actor.agi += value
  1451.       end
  1452.     end
  1453.     return true
  1454.   end
  1455.   #--------------------------------------------------------------------------
  1456.   # * Change Skills
  1457.   #--------------------------------------------------------------------------
  1458.   def command_318
  1459.     actor = $game_actors[@params[0]]
  1460.     if actor != nil
  1461.       if @params[1] == 0
  1462.         actor.learn_skill(@params[2])
  1463.       else
  1464.         actor.forget_skill(@params[2])
  1465.       end
  1466.     end
  1467.     return true
  1468.   end
  1469.   #--------------------------------------------------------------------------
  1470.   # * Change Equipment
  1471.   #--------------------------------------------------------------------------
  1472.   def command_319
  1473.     actor = $game_actors[@params[0]]
  1474.     if actor != nil
  1475.       actor.change_equip_by_id(@params[1], @params[2])
  1476.     end
  1477.     return true
  1478.   end
  1479.   #--------------------------------------------------------------------------
  1480.   # * Change Name
  1481.   #--------------------------------------------------------------------------
  1482.   def command_320
  1483.     actor = $game_actors[@params[0]]
  1484.     if actor != nil
  1485.       actor.name = @params[1]
  1486.     end
  1487.     return true
  1488.   end
  1489.   #--------------------------------------------------------------------------
  1490.   # * Change Class
  1491.   #--------------------------------------------------------------------------
  1492.   def command_321
  1493.     actor = $game_actors[@params[0]]
  1494.     if actor != nil and $data_classes[@params[1]] != nil
  1495.       actor.class_id = @params[1]
  1496.     end
  1497.     return true
  1498.   end
  1499.   #--------------------------------------------------------------------------
  1500.   # * Change Actor Graphic
  1501.   #--------------------------------------------------------------------------
  1502.   def command_322
  1503.     actor = $game_actors[@params[0]]
  1504.     if actor != nil
  1505.       actor.set_graphic(@params[1], @params[2], @params[3], @params[4])
  1506.     end
  1507.     $game_player.refresh
  1508.     return true
  1509.   end
  1510.   #--------------------------------------------------------------------------
  1511.   # * Change Vehicle Graphic
  1512.   #--------------------------------------------------------------------------
  1513.   def command_323
  1514.     if @params[0] == 0                      # Boat
  1515.       $game_map.boat.set_graphic(@params[1], @params[2])
  1516.     elsif @params[0] == 1                   # Ship
  1517.       $game_map.ship.set_graphic(@params[1], @params[2])
  1518.     else                                    # Airship
  1519.       $game_map.airship.set_graphic(@params[1], @params[2])
  1520.     end
  1521.     return true
  1522.   end
  1523.   #--------------------------------------------------------------------------
  1524.   # * Change Enemy HP
  1525.   #--------------------------------------------------------------------------
  1526.   def command_331
  1527.     value = operate_value(@params[1], @params[2], @params[3])
  1528.     iterate_enemy_index(@params[0]) do |enemy|
  1529.       if enemy.hp > 0
  1530.         if @params[4] == false and enemy.hp + value <= 0
  1531.           enemy.hp = 1    # If incapacitation is not allowed, make 1
  1532.         else
  1533.           enemy.hp += value
  1534.         end
  1535.         enemy.perform_collapse
  1536.       end
  1537.     end
  1538.     return true
  1539.   end
  1540.   #--------------------------------------------------------------------------
  1541.   # * Change Enemy MP
  1542.   #--------------------------------------------------------------------------
  1543.   def command_332
  1544.     value = operate_value(@params[1], @params[2], @params[3])
  1545.     iterate_enemy_index(@params[0]) do |enemy|
  1546.       enemy.mp += value
  1547.     end
  1548.     return true
  1549.   end
  1550.   #--------------------------------------------------------------------------
  1551.   # * Change Enemy State
  1552.   #--------------------------------------------------------------------------
  1553.   def command_333
  1554.     iterate_enemy_index(@params[0]) do |enemy|
  1555.       if @params[2] == 1                    # If change of incapacitation
  1556.         enemy.immortal = false              # Clear immortal flag
  1557.       end
  1558.       if @params[1] == 0
  1559.         enemy.add_state(@params[2])
  1560.         enemy.perform_collapse
  1561.       else
  1562.         enemy.remove_state(@params[2])
  1563.       end
  1564.     end
  1565.     return true
  1566.   end
  1567.   #--------------------------------------------------------------------------
  1568.   # * Enemy Recover All
  1569.   #--------------------------------------------------------------------------
  1570.   def command_334
  1571.     iterate_enemy_index(@params[0]) do |enemy|
  1572.       enemy.recover_all
  1573.     end
  1574.     return true
  1575.   end
  1576.   #--------------------------------------------------------------------------
  1577.   # * Enemy Appear
  1578.   #--------------------------------------------------------------------------
  1579.   def command_335
  1580.     enemy = $game_troop.members[@params[0]]
  1581.     if enemy != nil and enemy.hidden
  1582.       enemy.hidden = false
  1583.       $game_troop.make_unique_names
  1584.     end
  1585.     return true
  1586.   end
  1587.   #--------------------------------------------------------------------------
  1588.   # * Enemy Transform
  1589.   #--------------------------------------------------------------------------
  1590.   def command_336
  1591.     enemy = $game_troop.members[@params[0]]
  1592.     if enemy != nil
  1593.       enemy.transform(@params[1])
  1594.       $game_troop.make_unique_names
  1595.     end
  1596.     return true
  1597.   end
  1598.   #--------------------------------------------------------------------------
  1599.   # * Show Battle Animation
  1600.   #--------------------------------------------------------------------------
  1601.   def command_337
  1602.     iterate_battler(0, @params[0]) do |battler|
  1603.       next unless battler.exist?
  1604.       battler.animation_id = @params[1]
  1605.     end
  1606.     return true
  1607.   end
  1608.   #--------------------------------------------------------------------------
  1609.   # * Force Action
  1610.   #--------------------------------------------------------------------------
  1611.   def command_339
  1612.     iterate_battler(@params[0], @params[1]) do |battler|
  1613.       next unless battler.exist?
  1614.       battler.action.kind = @params[2]
  1615.       if battler.action.kind == 0
  1616.         battler.action.basic = @params[3]
  1617.       else
  1618.         battler.action.skill_id = @params[3]
  1619.       end
  1620.       if @params[4] == -2                   # Last target
  1621.         battler.action.decide_last_target
  1622.       elsif @params[4] == -1                # Random
  1623.         battler.action.decide_random_target
  1624.       elsif @params[4] >= 0                 # Index designation
  1625.         battler.action.target_index = @params[4]
  1626.       end
  1627.       battler.action.forcing = true
  1628.       $game_troop.forcing_battler = battler
  1629.       @index += 1
  1630.       return false
  1631.     end
  1632.     return true
  1633.   end
  1634.   #--------------------------------------------------------------------------
  1635.   # * Abort Battle
  1636.   #--------------------------------------------------------------------------
  1637.   def command_340
  1638.     $game_temp.next_scene = "map"
  1639.     @index += 1
  1640.     return false
  1641.   end
  1642.   #--------------------------------------------------------------------------
  1643.   # * Open Menu Screen
  1644.   #--------------------------------------------------------------------------
  1645.   def command_351
  1646.     $game_temp.next_scene = "menu"
  1647.     $game_temp.menu_beep = false
  1648.     @index += 1
  1649.     return false
  1650.   end
  1651.   #--------------------------------------------------------------------------
  1652.   # * Open Save Screen
  1653.   #--------------------------------------------------------------------------
  1654.   def command_352
  1655.     $game_temp.next_scene = "save"
  1656.     @index += 1
  1657.     return false
  1658.   end
  1659.   #--------------------------------------------------------------------------
  1660.   # * Game Over
  1661.   #--------------------------------------------------------------------------
  1662.   def command_353
  1663.     $game_temp.next_scene = "gameover"
  1664.     return false
  1665.   end
  1666.   #--------------------------------------------------------------------------
  1667.   # * Return to Title Screen
  1668.   #--------------------------------------------------------------------------
  1669.   def command_354
  1670.     $game_temp.next_scene = "title"
  1671.     return false
  1672.   end
  1673.   #--------------------------------------------------------------------------
  1674.   # * Script
  1675.   #--------------------------------------------------------------------------
  1676.   def command_355
  1677.     script = @list[@index].parameters[0] + "\n"
  1678.     loop do
  1679.       if @list[@index+1].code == 655        # Second line of script and after
  1680.         script += @list[@index+1].parameters[0] + "\n"
  1681.       else
  1682.         break
  1683.       end
  1684.       @index += 1
  1685.     end
  1686.     eval(script)
  1687.     return true
  1688.   end
  1689. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement