molegato

Basimple BS v3

Apr 14th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 38.84 KB | None | 0 0
  1. #==============================================================================
  2. # BASIMPLE BATTLE SYSTEM
  3. # Author Molegato
  4. # Version 3
  5. #------------------------------------------------------------------------------
  6. # The formerly least customizable battle system on the universe, now it's
  7. # HUGELY customizable! HUGE hooray!
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported['Molegato-Basimple Battle System'] = true
  12.  
  13. #==============================================================================
  14. # CONFIGURATION, YOU CAN TOUCH THIS
  15. #==============================================================================
  16. module MOLEGATO_BASIMPLE_BS
  17.   # Default number of frames for the poses
  18.   FRAME_NUMBER = 4
  19.  
  20.   # Animation Speed
  21.   FRAME_SPEED = 0.1
  22.  
  23.   # movement ratio. The bigger, the slower the movement
  24.   MOVEMENT_RATIO = 10
  25.  
  26.   # 0 -> default
  27.   # 1 -> no effect
  28.   # 2 -> all blink
  29.   DAMAGE_EFFECT = 1
  30.  
  31.   #troops with @ in their name will never auto-arrange
  32.   ARRANGE_ENEMIES = true
  33.  
  34.   #Number of frames for each normal pose
  35.   #Only applies if INDIVIDUAL_FN is set true
  36.   INDIVIDUAL_FN = false
  37.   PF_STAND = 4
  38.   PF_MOVE = 4
  39.   PF_MOVE_BACK = 4
  40.   PF_HURT = 4
  41.   PF_ATTACK = 4
  42.   PF_ITEM = 4
  43.   PF_PHYSICAL = 4
  44.   PF_MAGICAL = 4
  45.  
  46.   #----------------------------------------------------------------------------
  47.   # All the options below this line can be changed in mid-game
  48.   #----------------------------------------------------------------------------  
  49.  
  50.   #0= heroes at left, 1= heroes at right
  51.   SIDE = 0
  52.   #distance to the border of the screen (horizontally)
  53.   MARGIN = 75
  54.   #distance to the top of the lowest member of the party
  55.   VERTICAL_PARTY_POS = 325
  56.   #vertical separation between members of the party
  57.   VERTICAL_SEP = 25
  58.   #for a diagonal-ish effect, horizontal separation between members of party
  59.   DIAGONAL_POS = 30
  60.   #Distance the battler will be away of its target while meleeing
  61.   MELEE_DISTANCE = 25
  62.   #Distance the battler will move forward while casting magic
  63.   STEP_DISTANCE = 100
  64.   # screen y for battlers that are attacking everyone
  65.   CENTER_DOWN = 250
  66.   #to mirror every battler. Useful if all your battlers are facing the left and you dont want to flip'em all
  67.   GLOBAL_MIRROR = false
  68.  
  69.   #background panning, enable by setting true
  70.   #if activated, background 2 will move more than background 1
  71.   #You can set the multipliers for backgroun2 panning any ammount. 1 means normal movement
  72.   BACK_PANNING = false
  73.   BACKPANNING_X = 2
  74.   BACKPANNING_Y = 1
  75.   #z value for battleback 2. Default is 1. Set it to a value greater than
  76.   # 500 for it to ve OVER the battlers. Useful for clouds/fog/etc
  77.   BACK2_Z = 1
  78.   #autoscrolls
  79.   BACK1_SCROLL_X=0
  80.   BACK1_SCROLL_Y=0
  81.   BACK2_SCROLL_X=0
  82.   BACK2_SCROLL_Y=0
  83.  
  84. end
  85.  
  86. #==============================================================================
  87. # TAG INSTRUCTIONS
  88. #------------------------------------------------------------------------------
  89. #--- For Actors/enemies:
  90.  
  91. # <guard_anim: id>
  92. #Sets an animation for guarding
  93.  
  94. # <enemy_size: size>
  95. # <actor_size: size>
  96. #Both control the size of the battler. 1 means normal.
  97.  
  98. # <enem_attack_animation: id>
  99. #Sets the attack animation for an ENEMY.
  100.  
  101. #--- For Skills/items:
  102.  
  103. # <melee>
  104. #The battler gets near the target while performing action
  105.  
  106. # <cast_anim: id>
  107. #Shows an animation on battler before moving
  108.  
  109. # <melee_anim: id>
  110. #Shows an animation on battler after moving.
  111.  
  112. # <custom_pose: name>
  113. #Uses a custom pose animation, rather than the default
  114. # <custom_pose: name, frame_max>
  115. # <custom_pose: name, frame_max, loop>
  116. #These two variations include the maximum frame number
  117. #and if the animation should loop or not. (1 for loop)
  118.  
  119. # <camera: x,y,zoom,rate_move,rate_zoom>
  120. # <cast_zoom_on_user: zoom,rate>
  121. # <hit_zoom_on_user: zoom,rate>
  122. # <cast_zoom_on_target: zoom,rate>
  123. # <hit_zoom_on_target: zoom,rate>
  124. # <cast_zoom_center: zoom,rate>
  125. # <hit_zoom_center: zoom,rate>
  126.  
  127. #--- CUSTOM CHAIN ACTIONS
  128. # You can use custom actions by adding those commands on a skill/item notes
  129. # <c_chain: wait,frames>
  130. # <c_chain: pose,name>
  131. # <c_chain: pose,name,frames,loop>
  132. # <c_chain: move,self/center/target,+x,+y,ratio>
  133. # <c_chain: animation,self/target,id>
  134. # <c_chain: autoanimation,self/target>
  135. # <c_chain: camera,self/center/target,+x,+y,zoom,ratio>
  136. # <c_chain: camera_normal,rate>
  137. # <c_chain: use_action>
  138. # <c_chain: end>
  139.  
  140. # It follows this nomenclature:
  141. # <c_chain>
  142. # <c_chain: wait,frames>;
  143. # <c_chain: pose,name>;
  144. # <c_chain: end>;
  145. # </c_chain>
  146.  
  147. #--- TIPS, TRICKS & WARNINGS
  148.  
  149. # In the tags with parameters, parameters are separated only by ','
  150. # That means, <tag: this,this,this> is correct, and
  151. # <tag: this, this, this> is wrong
  152.  
  153. # With custom chain actions, allways remember to call the
  154. # 'use_action' tag at least once, or the skill won't have effect.
  155.  
  156. # Also remember to end every custom chain action with the 'end' tag.
  157.  
  158. #==============================================================================
  159.  
  160. #==============================================================================
  161. # MID GAME OPTION CHANGE VIA SCRIPT CALL INSTRUCTIONS
  162. #------------------------------------------------------------------------------
  163. # You can change any configuration in midgame via script call.
  164. # This can be useful for example, if you want a certain battle to have
  165. # a custom battler layout, or a certain map to have a dynamic battleback.
  166. #
  167. # To do so, use this code:
  168. #     $game_system.basimple_options.YOUROPTION=NEW_VALUE
  169. # The only difference between the names of the options in this module and
  170. # in the script call is that the option names are all lowercase.
  171. # So for example, if you want to enable battleback panning, use this:
  172. #     $game_system.basimple_options.back_panning=true
  173. #==============================================================================
  174.  
  175.  
  176. #==============================================================================
  177. # END OF CONFIGURATION. EVERYTHING UNDER HERE IS A HELLISH MESS OF DEFICIENT
  178. # AMATEUR SCRIPTING. BE AWARE THAT MESSING WITH IT CAN RESULT IN DISASTER
  179. #==============================================================================
  180.  
  181.  
  182.  
  183.  
  184.  
  185. #===============================================================================
  186. # BASIMPLE_OPTIONS OBJECT
  187. #   To be able to change the options in mid-game
  188. #===============================================================================
  189. class Basimple_options
  190.   attr_accessor :side
  191.   attr_accessor :margin
  192.   attr_accessor :vertical_party_pos
  193.   attr_accessor :vertical_sep
  194.   attr_accessor :diagonal_pos
  195.   attr_accessor :melee_distance
  196.   attr_accessor :step_distance
  197.   attr_accessor :center_down
  198.   attr_accessor :global_mirror
  199.   attr_accessor :back_panning
  200.   attr_accessor :backpanning_x
  201.   attr_accessor :backpanning_y
  202.   attr_accessor :back2_z
  203.   attr_accessor :back1_scroll_x
  204.   attr_accessor :back1_scroll_y
  205.   attr_accessor :back2_scroll_x
  206.   attr_accessor :back2_scroll_y
  207.  
  208.   def initialize
  209.     @side=MOLEGATO_BASIMPLE_BS::SIDE
  210.     @margin=MOLEGATO_BASIMPLE_BS::MARGIN
  211.     @vertical_party_pos=MOLEGATO_BASIMPLE_BS::VERTICAL_PARTY_POS
  212.     @vertical_sep=MOLEGATO_BASIMPLE_BS::VERTICAL_SEP
  213.     @diagonal_pos=MOLEGATO_BASIMPLE_BS::DIAGONAL_POS
  214.     @melee_distance=MOLEGATO_BASIMPLE_BS::MELEE_DISTANCE
  215.     @step_distance=MOLEGATO_BASIMPLE_BS::STEP_DISTANCE
  216.     @center_down=MOLEGATO_BASIMPLE_BS::CENTER_DOWN
  217.     @global_mirror=MOLEGATO_BASIMPLE_BS::GLOBAL_MIRROR
  218.    
  219.     @back_panning=MOLEGATO_BASIMPLE_BS::BACK_PANNING
  220.     @backpanning_x=MOLEGATO_BASIMPLE_BS::BACKPANNING_X
  221.     @backpanning_y=MOLEGATO_BASIMPLE_BS::BACKPANNING_Y
  222.     @back2_z=MOLEGATO_BASIMPLE_BS::BACK2_Z
  223.    
  224.     @back1_scroll_x=MOLEGATO_BASIMPLE_BS::BACK1_SCROLL_X
  225.     @back1_scroll_y=MOLEGATO_BASIMPLE_BS::BACK1_SCROLL_Y
  226.     @back2_scroll_x=MOLEGATO_BASIMPLE_BS::BACK2_SCROLL_X
  227.     @back2_scroll_y=MOLEGATO_BASIMPLE_BS::BACK2_SCROLL_Y
  228.   end
  229. end
  230.  
  231.  
  232. #==============================================================================
  233. # ■ Game_System
  234. #==============================================================================
  235. class Game_System
  236.   attr_accessor :basimple_options
  237.   alias basimple_initialize initialize
  238.   def initialize
  239.     basimple_initialize
  240.     @basimple_options=Basimple_options.new
  241.   end
  242. end
  243.  
  244. #==============================================================================
  245. # ■ BattleManager
  246. #==============================================================================
  247.  
  248. module BattleManager
  249.  
  250.   def self.update_pos
  251.     action_battlers = []
  252.     action_battlers += $game_party.members unless @surprise
  253.     action_battlers += $game_troop.members unless @preemptive
  254.     action_battlers.each {|battler|
  255.     battler.update_pos
  256.     battler.frame+=MOLEGATO_BASIMPLE_BS::FRAME_SPEED
  257.     if frame_string=battler.frame.round()>battler.max_frame_number-1
  258.       if battler.action=='' or battler.action=='move' or battler.action=='move_back' and battler.custom==false
  259.         battler.frame=0
  260.       else
  261.         if battler.action=='attack' or battler.action=='hurt' or battler.action=='item' or battler.action=='magical' or battler.action=='physical' and battler.custom==false
  262.           battler.frame=battler.max_frame_number-1
  263.         else
  264.           if battler.custom_loop==true
  265.             battler.frame=0
  266.           else
  267.             battler.frame=battler.max_frame_number-1
  268.           end
  269.         end
  270.       end
  271.     end
  272.     }
  273.   end
  274.  
  275.   def self.init_pos
  276.     @action_battlers = []
  277.     @action_battlers += $game_party.members unless @surprise
  278.     @action_battlers += $game_troop.members unless @preemptive
  279.     @action_battlers.each {|battler|
  280.     battler.set_x=battler.screen_x
  281.     battler.set_y=battler.screen_y
  282.     battler.current_x=battler.screen_x
  283.     battler.current_y=battler.screen_y
  284.     }
  285.   end
  286.  
  287.   #--------------------------------------------------------------------------
  288.   # ● battle_start
  289.   #--------------------------------------------------------------------------
  290.   # overwritten for fun!!
  291.   #--------------------------------------------------------------------------
  292.   def self.battle_start    
  293.     $game_system.battle_count += 1
  294.     $game_party.on_battle_start
  295.     $game_troop.on_battle_start
  296.     $game_troop.enemy_names.each do |name|
  297.       $game_message.add(sprintf(Vocab::Emerge, name))
  298.     end
  299.     if @preemptive
  300.       $game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
  301.     elsif @surprise
  302.       $game_message.add(sprintf(Vocab::Surprise, $game_party.name))
  303.     end
  304.     init_pos
  305.     wait_for_message
  306.   end
  307.  
  308.  
  309. end
  310.  
  311.  
  312. #==============================================================================
  313. # ■ Scene_Battle
  314. #==============================================================================
  315.  
  316. class Scene_Battle < Scene_Base
  317.   #--------------------------------------------------------------------------
  318.   # ● start
  319.   #--------------------------------------------------------------------------
  320.   alias basimple_start start
  321.   def start
  322.     $cam_x=Graphics.width/2
  323.     $cam_y=Graphics.height/2
  324.     $cam_zoom=1.0
  325.     @cam_goal_x=$cam_x
  326.     @cam_goal_y=$cam_y
  327.     @cam_goal_zoom=$cam_zoom
  328.     @cam_move_rate=10
  329.     @cam_zoom_rate=10
  330.     basimple_start
  331.   end
  332.  
  333.   #--------------------------------------------------------------------------
  334.   # ● update_basic
  335.   #--------------------------------------------------------------------------
  336.   # there used to be an infinite loop here. Its gone now.
  337.   #--------------------------------------------------------------------------
  338.   alias basimple_update_basic update_basic
  339.   def update_basic
  340.     basimple_update_basic
  341.     BattleManager.update_pos
  342.     if @cam_goal_x!=$cam_x or @cam_goal_y!=$cam_y or @cam_goal_zoom!=$cam_zoom
  343.       $cam_x=($cam_x*(@cam_move_rate-1)+@cam_goal_x)/@cam_move_rate
  344.       $cam_y=($cam_y*(@cam_move_rate-1)+@cam_goal_y)/@cam_move_rate
  345.       $cam_zoom=($cam_zoom*(@cam_zoom_rate-1)+@cam_goal_zoom)/@cam_zoom_rate
  346.      
  347.       $cam_x=@cam_goal_x if ($cam_x-@cam_goal_x).abs<0.01 or !$cam_x
  348.       $cam_y=@cam_goal_y if ($cam_y-@cam_goal_y).abs<0.01 or !$cam_y
  349.       $cam_zoom=@cam_goal_zoom if ($cam_zoom-@cam_goal_zoom).abs<0.01 or !$cam_zoom
  350.     end
  351.   end
  352.  
  353.  
  354.   def camera_move(rate,x,y,zoom)
  355.     @cam_move_rate=rate
  356.     @cam_zoom_rate=rate
  357.     @cam_goal_x=x
  358.     @cam_goal_y=y
  359.     @cam_goal_zoom=zoom
  360.   end
  361.  
  362.   def camera_move_default(rate)
  363.     @cam_goal_x=Graphics.width/2
  364.     @cam_goal_y=Graphics.height/2
  365.     @cam_goal_zoom=1.0
  366.     @cam_move_rate=rate
  367.     @cam_zoom_rate=rate
  368.   end
  369.  
  370.   #--------------------------------------------------------------------------
  371.   # ● use_item
  372.   #--------------------------------------------------------------------------
  373.   # i spent a big time here
  374.   #--------------------------------------------------------------------------
  375.  
  376.   def use_item
  377.     use_item_interpreted
  378.     @subject.action=""
  379.     @subject.frame=0
  380.   end
  381.  
  382.   #USE ITEM INTERPRETED
  383.   def use_item_interpreted
  384.     item = @subject.current_action.item
  385.    
  386.     if not item.has_tag?("c_chain") or item.has_tag?("c_chain")==false
  387.       use_item_normal
  388.       return
  389.     end
  390.     #CORE
  391.     @chain=item.tag_check_multiple_multivalues("c_chain")
  392.     @chain.each do |action|
  393.       #wait
  394.       if action[0]=="wait"
  395.         abs_wait(action[1].to_i())
  396.       end
  397.       #pose
  398.       if action[0]=="pose"
  399.         if action.size==2
  400.           @subject.action=action[1]
  401.           @subject.frame=0
  402.           @subject.custom=false
  403.         else
  404.           @subject.action=action[1]
  405.           @subject.custom_frame=action[2].to_i()
  406.           @subject.custom_loop=false
  407.           @subject.custom_loop=true if action[3].to_i()==1
  408.           @subject.frame=0
  409.           @subject.custom=true
  410.         end
  411.       end
  412.       #move
  413.       if action[0]=="move"
  414.         if action[1]=="self"
  415.           in_x=@subject.screen_x
  416.           in_y=@subject.screen_y
  417.         end
  418.         if action[1]=="center"
  419.           in_x=Graphics.width/2
  420.           in_y=Graphics.height/2
  421.         end
  422.         if action[1]=="target"
  423.           if item.for_all?
  424.             in_x=Graphics.width/2
  425.             in_x=$game_system.basimple_options.center_down
  426.           else
  427.             in_x=@subject.current_action.make_targets.compact[0].screen_x
  428.             in_x=@subject.current_action.make_targets.compact[0].screen_y
  429.           end
  430.         end
  431.         @subject.set_x=in_x+action[2].to_i()
  432.         @subject.set_y=in_y+action[3].to_i()
  433.         @subject.ratio=action[4].to_i()
  434.       end
  435.       #show animation
  436.       if action[0]=="animation"
  437.         if action[1]=="self"
  438.           show_animation([@subject], action[2].to_i())
  439.         end
  440.         if action[1]=="target"
  441.           show_animation(@subject.current_action.make_targets.compact, action[2].to_i())
  442.         end
  443.       end
  444.       #show auto animation
  445.       if action[0]=="autoanimation"
  446.         if action[1]=="self"
  447.           show_animation([@subject], item.animation_id)
  448.         end
  449.         if action[1]=="target"
  450.           show_animation(@subject.current_action.make_targets.compact, item.animation_id)
  451.         end
  452.       end
  453.  
  454.       #camera
  455.       if action[0]=="camera"
  456.         if action[1]=="self"
  457.           in_x=@subject.set_x
  458.           in_y=@subject.set_y
  459.         end
  460.         if action[1]=="center"
  461.           in_x=Graphics.width/2
  462.           in_y=Graphics.height/2
  463.         end
  464.         if action[1]=="target"
  465.           if item.for_all?
  466.             in_x=Graphics.width/2
  467.             in_x=$game_system.basimple_options.center_down
  468.           else
  469.             in_x=@subject.current_action.make_targets.compact[0].screen_x
  470.             in_x=@subject.current_action.make_targets.compact[0].screen_y
  471.           end
  472.         end
  473.         @cam_goal_x=in_x+action[2].to_i()
  474.         @cam_goal_y=in_y+action[3].to_i()
  475.         @cam_goal_zoom=action[4].to_f()
  476.         @cam_move_rate=action[5].to_f()
  477.         @cam_zoom_rate=action[5].to_f()
  478.       end
  479.       #camera_normal
  480.       if action[0]=="camera_normal"
  481.         camera_move_default(action[1].to_i())
  482.       end
  483.       #use_action
  484.       if action[0]=="use_action"
  485.         targets = @subject.current_action.make_targets.compact
  486.         targets.each {|target| item.repeats.times {
  487.           invoke_item(target, item)
  488.           target.action=""
  489.         } }
  490.       end
  491.       #set back to normal
  492.       if action[0]=="end"
  493.         @subject.custom=false
  494.         @subject.ratio=MOLEGATO_BASIMPLE_BS::MOVEMENT_RATIO
  495.       end
  496.     end
  497.    
  498.   end
  499.   # USE ITEM NORMAL
  500.   def use_item_normal
  501.     item = @subject.current_action.item
  502.    
  503.     #show cast anim
  504.     if item.tag_check_multivalues(item.note,"cast_anim")
  505.       show_animation([@subject], item.tag_check_multivalues(item.note,"cast_anim")[0].to_i())
  506.     end
  507.     @subject.action="move"
  508.     @subject.frame=0
  509.     @subject.ratio=MOLEGATO_BASIMPLE_BS::MOVEMENT_RATIO
  510.     #change pos
  511.     if item.has_tag?("melee")
  512.       if item.for_all?
  513.         @subject.set_x=Graphics.width/2
  514.         @subject.set_y=$game_system.basimple_options.center_down
  515.       else
  516.         @subject.set_x=@subject.current_action.make_targets.compact[0].screen_x-$game_system.basimple_options.melee_distance*@subject.face_direction
  517.         @subject.set_y=@subject.current_action.make_targets.compact[0].screen_y
  518.       end
  519.     end
  520.    
  521.     if not item.has_tag?("melee")
  522.       if item.for_all?
  523.         @subject.set_x=@subject.screen_x+$game_system.basimple_options.step_distance*@subject.face_direction
  524.         @subject.set_y=$game_system.basimple_options.center_down
  525.       else
  526.         @subject.set_x=@subject.screen_x+$game_system.basimple_options.step_distance*@subject.face_direction
  527.         @subject.set_y=@subject.current_action.make_targets.compact[0].screen_y        
  528.       end
  529.     end
  530.        
  531.     #change zoom and camera
  532.     if item.tag_check_multivalues(item.note,"camera")
  533.       @cam_goal_x=item.tag_check_multivalues(item.note,"camera")[0].to_i()
  534.       @cam_goal_y=item.tag_check_multivalues(item.note,"camera")[1].to_i()
  535.       @cam_goal_zoom=item.tag_check_multivalues(item.note,"camera")[2].to_f()
  536.       @cam_move_rate=item.tag_check_multivalues(item.note,"camera")[3].to_i()
  537.       @cam_zoom_rate=item.tag_check_multivalues(item.note,"camera")[4].to_i()
  538.     end
  539.     if item.tag_check_multivalues(item.note,"cast_zoom_on_user")
  540.       @cam_goal_x=@subject.set_x
  541.       @cam_goal_y=@subject.set_y
  542.       @cam_goal_zoom=item.tag_check_multivalues(item.note,"cast_zoom_on_user")[0].to_f()
  543.       @cam_move_rate=item.tag_check_multivalues(item.note,"cast_zoom_on_user")[1].to_i()
  544.       @cam_zoom_rate=item.tag_check_multivalues(item.note,"cast_zoom_on_user")[1].to_i()
  545.     end
  546.     if item.tag_check_multivalues(item.note,"cast_zoom_on_target")
  547.       if item.for_all?
  548.         @cam_goal_x=Graphics.width/2
  549.         @cam_goal_y=$game_system.basimple_options.center_down
  550.       else
  551.         @cam_goal_x=@subject.current_action.make_targets.compact[0].screen_x
  552.         @cam_goal_y=@subject.current_action.make_targets.compact[0].screen_y
  553.       end
  554.       @cam_goal_zoom=item.tag_check_multivalues(item.note,"cast_zoom_on_target")[0].to_f()
  555.       @cam_move_rate=item.tag_check_multivalues(item.note,"cast_zoom_on_target")[1].to_i()
  556.       @cam_zoom_rate=item.tag_check_multivalues(item.note,"cast_zoom_on_target")[1].to_i()
  557.     end
  558.     if item.tag_check_multivalues(item.note,"cast_zoom_center")
  559.       @cam_goal_x=Graphics.width/2
  560.       @cam_goal_y=Graphics.height/2
  561.       @cam_goal_zoom=item.tag_check_multivalues(item.note,"cast_zoom_center")[0].to_f()
  562.       @cam_move_rate=item.tag_check_multivalues(item.note,"cast_zoom_center")[1].to_i()
  563.       @cam_zoom_rate=item.tag_check_multivalues(item.note,"cast_zoom_center")[1].to_i()
  564.     end
  565.     #wait for the movement
  566.     abs_wait(30)
  567.  
  568.     #change graphic
  569.     @subject.custom=false
  570.     if item.tag_check_multivalues(item.note,"custom_pose")
  571.       if item.tag_check_multivalues(item.note,"custom_pose").size>1
  572.         @subject.custom_frame=item.tag_check_multivalues(item.note,"custom_pose")[1].to_i()
  573.       else
  574.         @subject.custom_frame=MOLEGATO_BASIMPLE_BS::FRAME_NUMBER
  575.       end
  576.       if item.tag_check_multivalues(item.note,"custom_pose").size>2
  577.         @subject.custom_loop=(item.tag_check_multivalues(item.note,"custom_pose")[2].to_i()==1)
  578.       else
  579.         @subject.custom_loop=false
  580.       end
  581.       @subject.action=item.tag_check_multivalues(item.note,"custom_pose")[0]
  582.       @subject.custom=true
  583.     end
  584.     custom=@subject.custom
  585.    
  586.     if item.is_a?(RPG:: Skill) && item.id == @subject.attack_skill_id
  587.       if custom==false
  588.         @subject.action="attack"
  589.       end
  590.     else
  591.       if item.is_a?(RPG:: Skill) && item.id == @subject.guard_skill_id
  592.         @subject.action="stand"
  593.         #show guard anim
  594.         if @subject.actor?
  595.           if item.tag_check_multivalues(@subject.actor.note,"guard_anim")
  596.             show_animation([@subject], item.tag_check_multivalues(@subject.actor.note,"guard_anim")[0].to_i())
  597.           end
  598.         else
  599.           if item.tag_check_multivalues(@subject.enemy.note,"guard_anim")
  600.             show_animation([@subject], item.tag_check_multivalues(@subject.enemy.note,"guard_anim")[0].to_i())
  601.           end
  602.         end
  603.       else
  604.         if item.is_a?(RPG:: Skill) && item.physical?
  605.           if custom==false
  606.             @subject.action="physical"
  607.           end
  608.         end
  609.         if item.is_a?(RPG:: Skill) && item.magical?
  610.           if custom==false
  611.             @subject.action="magical"
  612.           end
  613.         end
  614.         if item.is_a?(RPG:: Item)
  615.           if custom==false
  616.             @subject.action="item"
  617.           end
  618.         end
  619.       end
  620.     end
  621.     @subject.frame=0
  622.    
  623.     #show melee anim
  624.     if item.tag_check_multivalues(item.note,"melee_anim")
  625.       show_animation([@subject], item.tag_check_multivalues(item.note,"melee_anim")[0].to_i())
  626.     else
  627.       #wait some more
  628.       abs_wait(15)
  629.     end
  630.    
  631.    
  632.     #hit camera
  633.     if !item.tag_check_multivalues(item.note,"hit_zoom_on_user")
  634.       camera_move_default(10)
  635.       abs_wait(30)
  636.     end
  637.  
  638.     if item.tag_check_multivalues(item.note,"hit_zoom_on_user")
  639.       @cam_goal_x=@subject.set_x
  640.       @cam_goal_y=@subject.set_y
  641.       @cam_goal_zoom=item.tag_check_multivalues(item.note,"hit_zoom_on_user")[0].to_f()
  642.       @cam_move_rate=item.tag_check_multivalues(item.note,"hit_zoom_on_user")[1].to_i()
  643.       @cam_zoom_rate=item.tag_check_multivalues(item.note,"hit_zoom_on_user")[1].to_i()
  644.       abs_wait(30)
  645.     end    
  646.     if item.tag_check_multivalues(item.note,"hit_zoom_on_target")
  647.       if item.for_all?
  648.         @cam_goal_x=Graphics.width/2
  649.         @cam_goal_y=$game_system.basimple_options.center_down
  650.       else
  651.         @cam_goal_x=@subject.current_action.make_targets.compact[0].screen_x
  652.         @cam_goal_y=@subject.current_action.make_targets.compact[0].screen_y
  653.       end
  654.       @cam_goal_zoom=item.tag_check_multivalues(item.note,"hit_zoom_on_target")[0].to_f()
  655.       @cam_move_rate=item.tag_check_multivalues(item.note,"hit_zoom_on_target")[1].to_i()
  656.       @cam_zoom_rate=item.tag_check_multivalues(item.note,"hit_zoom_on_target")[1].to_i()
  657.       abs_wait(30)
  658.     end
  659.     if item.tag_check_multivalues(item.note,"hit_zoom_center")
  660.       @cam_goal_x=Graphics.width/2
  661.       @cam_goal_y=Graphics.height/2
  662.       @cam_goal_zoom=item.tag_check_multivalues(item.note,"hit_zoom_center")[0].to_f()
  663.       @cam_move_rate=item.tag_check_multivalues(item.note,"hit_zoom_center")[1].to_i()
  664.       @cam_zoom_rate=item.tag_check_multivalues(item.note,"hit_zoom_center")[1].to_i()
  665.       abs_wait(30)
  666.     end
  667.  
  668.    
  669.     #normal stuff
  670.     @log_window.display_use_item(@subject, item)
  671.     @subject.use_item(item)
  672.     refresh_status
  673.     targets = @subject.current_action.make_targets.compact
  674.     targets.each {|target| item.repeats.times {
  675.       if item.damage.to_hp? and not item.damage.recover?
  676.         target.action="hurt"
  677.         target.frame=0
  678.       end} }
  679.     if not $imported["YEA-BattleEngine"]
  680.       if targets.size==1
  681.         show_animation(targets, item.animation_id,targets[0].animation_mirror)
  682.       else
  683.         show_animation(targets, item.animation_id)
  684.       end
  685.     end
  686.     targets.each {|target| item.repeats.times {
  687.     invoke_item(target, item)
  688.     target.action=""
  689.     } }
  690.    
  691.     #restart graphic and pos
  692.     @subject.action="move_back"
  693.     @subject.frame=0
  694.     @subject.set_x=@subject.screen_x
  695.     @subject.set_y=@subject.screen_y
  696.     camera_move_default(10)
  697.     abs_wait(30)
  698.   end
  699.   #--------------------------------------------------------------------------
  700.   # show animation
  701.   #--------------------------------------------------------------------------
  702.   # because of the mirror
  703.   #--------------------------------------------------------------------------
  704.   def show_animation(targets, animation_id, mirror = false)
  705.     if animation_id < 0
  706.       show_attack_animation(targets)
  707.     else
  708.       show_normal_animation(targets, animation_id, mirror)
  709.     end
  710.     @log_window.wait
  711.     wait_for_animation
  712.   end
  713.  
  714.   def show_attack_animation(targets)
  715.     if @subject.actor?
  716.       show_normal_animation(targets, @subject.atk_animation_id1, false)
  717.       show_normal_animation(targets, @subject.atk_animation_id2, true)
  718.     else
  719.       if @subject.enemy
  720.         if @subject.enemy.tag_check_multivalues(@subject.enemy.note,"enem_attack_animation")
  721.           show_normal_animation(targets, @subject.enemy.tag_check_multivalues(@subject.enemy.note,"enem_attack_animation")[0].to_i(),false)
  722.         else
  723.           Sound.play_enemy_attack
  724.           abs_wait_short
  725.         end
  726.       end
  727.     end
  728.   end
  729.  
  730. end
  731.  
  732.  
  733. #==============================================================================
  734. # ■ Game_Enemy
  735. #==============================================================================
  736.  
  737. class Game_Enemy < Game_Battler
  738.   attr_accessor :current_x
  739.   attr_accessor :current_y
  740.   attr_accessor :set_x
  741.   attr_accessor :set_y
  742.   attr_accessor :action
  743.   attr_accessor :frame
  744.   attr_accessor :size
  745.   attr_accessor :custom_frame
  746.   attr_accessor :custom_loop
  747.   attr_accessor :custom_anim_speed
  748.   attr_accessor :custom
  749.   attr_accessor :ratio
  750.  
  751.   #--------------------------------------------------------------------------
  752.   # ● initialize
  753.   #--------------------------------------------------------------------------
  754.   def initialize(index, enemy_id)
  755.     super()
  756.     @index = index
  757.     @enemy_id = enemy_id
  758.     enemy = $data_enemies[@enemy_id]
  759.     @original_name = enemy.name
  760.     @letter = ""
  761.     @plural = false
  762.     @screen_x = 0
  763.     @screen_y = 0
  764.     @battler_hue = enemy.battler_hue
  765.     @hp = mhp
  766.     @mp = mmp
  767.     @current_x=0
  768.     @current_y=0
  769.     @set_x=0
  770.     @set_y=0
  771.     @action = ''
  772.     @frame=0.0
  773.     @custom=false
  774.     @ratio=10
  775.     if enemy.tag_check_multivalues(enemy.note,"enemy_size")
  776.       @size=enemy.tag_check_multivalues(enemy.note,"enemy_size")[0].to_f
  777.     else
  778.       @size=1
  779.     end
  780.     @custom_frame=MOLEGATO_BASIMPLE_BS::FRAME_NUMBER
  781.     @custom_loop=false
  782.     @custom_anim_speed=MOLEGATO_BASIMPLE_BS::FRAME_SPEED
  783.   end
  784.  
  785.   def max_frame_number
  786.     if MOLEGATO_BASIMPLE_BS::INDIVIDUAL_FN==false
  787.       return MOLEGATO_BASIMPLE_BS::FRAME_NUMBER
  788.     else
  789.       return @custom_frame if @custom==true
  790.       return MOLEGATO_BASIMPLE_BS::PF_STAND if action=='stand' or action==''
  791.       return MOLEGATO_BASIMPLE_BS::PF_MOVE if action=='move'
  792.       return MOLEGATO_BASIMPLE_BS::PF_MOVE_BACK if action=='move_back'
  793.       return MOLEGATO_BASIMPLE_BS::PF_HURT if action=='hurt'
  794.       return MOLEGATO_BASIMPLE_BS::PF_ATTACK if action=='attack'
  795.       return MOLEGATO_BASIMPLE_BS::PF_ITEM if action=='item'
  796.       return MOLEGATO_BASIMPLE_BS::PF_MAGICAL if action=='magical'
  797.       return MOLEGATO_BASIMPLE_BS::PF_PHYSICAL if action=='physical'
  798.       return @custom_frame
  799.     end
  800.   end
  801.  
  802.   def battler_name
  803.     if MOLEGATO_BASIMPLE_BS::FRAME_NUMBER==1
  804.       frame_string=''
  805.     else
  806.       frame_string=@frame.round().to_s()
  807.     end
  808.    
  809.     if action==''
  810.       return enemy.battler_name+'/'+'stand'+frame_string
  811.     else
  812.       return enemy.battler_name+'/'+action+frame_string
  813.     end
  814.   end
  815.  
  816.   def update_pos
  817.     @current_x=(@current_x*(@ratio-1)+@set_x)/@ratio
  818.     @current_y=(@current_y*9+@set_y)/10
  819.   end
  820.  
  821.   def screen_x
  822.     if MOLEGATO_BASIMPLE_BS::ARRANGE_ENEMIES==false or $game_troop.troop.name[/@/mi]=="@"
  823.       return @screen_x
  824.     else
  825.       if $game_system.basimple_options.side==0
  826.         return Graphics.width-$game_system.basimple_options.margin - $game_system.basimple_options.diagonal_pos*self.index
  827.       else
  828.         return $game_system.basimple_options.margin + $game_system.basimple_options.diagonal_pos*self.index
  829.       end
  830.     end
  831.   end
  832.  
  833.   def screen_y
  834.     if MOLEGATO_BASIMPLE_BS::ARRANGE_ENEMIES==false or $game_troop.troop.name[/@/mi]=="@"
  835.       return @screen_y
  836.     else
  837.       return $game_system.basimple_options.vertical_party_pos-self.index*$game_system.basimple_options.vertical_sep
  838.     end
  839.   end
  840.  
  841.   def animation_mirror
  842.     if $game_system.basimple_options.global_mirror==false
  843.       if $game_system.basimple_options.side==0
  844.         return false
  845.       else
  846.         return true
  847.       end
  848.     else
  849.       if $game_system.basimple_options.side==0
  850.         return true
  851.       else
  852.         return false
  853.       end
  854.     end
  855.   end
  856.   #--------------------------------------------------------------------------
  857.   # ● perform damage_effect
  858.   #--------------------------------------------------------------------------
  859.   # cause it was annoying.
  860.   #--------------------------------------------------------------------------
  861.   def perform_damage_effect
  862.     if MOLEGATO_BASIMPLE_BS::DAMAGE_EFFECT==0 or MOLEGATO_BASIMPLE_BS::DAMAGE_EFFECT==2
  863.       @sprite_effect_type = :blink
  864.       Sound.play_enemy_damage      
  865.     end
  866.   end
  867.  
  868.   def face_direction
  869.     if $game_system.basimple_options.side==0
  870.       if actor?
  871.         return 1
  872.       else
  873.         return -1
  874.       end
  875.     else
  876.       if actor?
  877.         return -1
  878.       else
  879.         return 1
  880.       end        
  881.     end
  882.   end
  883.  
  884. end
  885.  
  886.  
  887. #==============================================================================
  888. # ■ Game_Actor
  889. #==============================================================================
  890.  
  891. class Game_Actor < Game_Battler
  892.   attr_accessor :current_x
  893.   attr_accessor :current_y
  894.   attr_accessor :set_x
  895.   attr_accessor :set_y
  896.   attr_accessor :action
  897.   attr_accessor :frame
  898.   attr_accessor :size
  899.   attr_accessor :custom_frame
  900.   attr_accessor :custom_loop
  901.   attr_accessor :custom_anim_speed
  902.   attr_accessor :custom
  903.   attr_accessor :ratio
  904.  
  905.   #--------------------------------------------------------------------------
  906.   # ● setup
  907.   #--------------------------------------------------------------------------
  908.   def setup(actor_id)
  909.     @actor_id = actor_id
  910.     @name = actor.name
  911.     @nickname = actor.nickname
  912.     init_graphics
  913.     @class_id = actor.class_id
  914.     @level = actor.initial_level
  915.     @exp = {}
  916.     @equips = []
  917.     @battler_hue = 0
  918.     init_exp
  919.     init_skills
  920.     init_equips(actor.equips)
  921.     clear_param_plus
  922.     recover_all
  923.     @current_x=0
  924.     @current_y=0
  925.     @set_x=0
  926.     @set_y=0
  927.     @action = ''
  928.     @frame=0.0
  929.     @custom=false
  930.     @ratio=10
  931.     if actor.tag_check_multivalues(actor.note,"actor_size")
  932.       @size=actor.tag_check_multivalues(actor.note,"actor_size")[0].to_f
  933.     else
  934.       @size=1
  935.     end
  936.     @custom_frame=MOLEGATO_BASIMPLE_BS::FRAME_NUMBER
  937.     @custom_loop=false
  938.     @custom_anim_speed=MOLEGATO_BASIMPLE_BS::FRAME_SPEED
  939.   end
  940.  
  941.   def max_frame_number
  942.     if MOLEGATO_BASIMPLE_BS::INDIVIDUAL_FN==false
  943.       return MOLEGATO_BASIMPLE_BS::FRAME_NUMBER
  944.     else
  945.       return @custom_frame if @custom==true
  946.       return MOLEGATO_BASIMPLE_BS::PF_STAND if action=='stand' or action==''
  947.       return MOLEGATO_BASIMPLE_BS::PF_MOVE if action=='move'
  948.       return MOLEGATO_BASIMPLE_BS::PF_MOVE_BACK if action=='move_back'
  949.       return MOLEGATO_BASIMPLE_BS::PF_HURT if action=='hurt'
  950.       return MOLEGATO_BASIMPLE_BS::PF_ATTACK if action=='attack'
  951.       return MOLEGATO_BASIMPLE_BS::PF_ITEM if action=='item'
  952.       return MOLEGATO_BASIMPLE_BS::PF_MAGICAL if action=='magical'
  953.       return MOLEGATO_BASIMPLE_BS::PF_PHYSICAL if action=='physical'
  954.       return @custom_frame
  955.     end
  956.   end
  957.  
  958.   #--------------------------------------------------------------------------
  959.   # ● screen_whatever
  960.   #--------------------------------------------------------------------------
  961.   def screen_z
  962.     return 100
  963.   end
  964.  
  965.   def screen_x
  966.     if $game_system.basimple_options.side==0
  967.       return $game_system.basimple_options.margin + $game_system.basimple_options.diagonal_pos*self.index
  968.     else
  969.       return Graphics.width-$game_system.basimple_options.margin - $game_system.basimple_options.diagonal_pos*self.index
  970.     end
  971.   end
  972.  
  973.   def screen_y
  974.     return $game_system.basimple_options.vertical_party_pos-self.index*$game_system.basimple_options.vertical_sep
  975.   end
  976.    
  977.   def battler_name
  978.     if MOLEGATO_BASIMPLE_BS::FRAME_NUMBER==1
  979.       frame_string=''
  980.     else
  981.       frame_string=@frame.round().to_s()
  982.     end
  983.    
  984.     if action==''
  985.       return face_name+"/"+'stand'+frame_string
  986.     else
  987.       return face_name+"/"+action+frame_string
  988.     end
  989.   end
  990.  
  991.   def update_pos
  992.     @current_x=(@current_x*(@ratio-1)+@set_x)/@ratio
  993.     @current_y=(@current_y*9+@set_y)/10
  994.   end
  995.  
  996.   #--------------------------------------------------------------------------
  997.   # ● use sprite
  998.   #--------------------------------------------------------------------------
  999.   def use_sprite?
  1000.     return true
  1001.   end
  1002.  
  1003.   def animation_mirror
  1004.     if $game_system.basimple_options.global_mirror==false
  1005.       if $game_system.basimple_options.side==0
  1006.         return true
  1007.       else
  1008.         return false
  1009.       end
  1010.     else
  1011.       if $game_system.basimple_options.side==0
  1012.         return false
  1013.       else
  1014.         return true
  1015.       end
  1016.     end
  1017.   end
  1018.   #--------------------------------------------------------------------------
  1019.   # ● perform damage effect
  1020.   #--------------------------------------------------------------------------
  1021.   # edited cause it annoyed me
  1022.   #--------------------------------------------------------------------------
  1023.   def perform_damage_effect
  1024.     if MOLEGATO_BASIMPLE_BS::DAMAGE_EFFECT==0
  1025.       $game_troop.screen.start_shake(5, 5, 10)
  1026.       @sprite_effect_type = :blink
  1027.       Sound.play_actor_damage
  1028.     end
  1029.     if MOLEGATO_BASIMPLE_BS::DAMAGE_EFFECT==2
  1030.       @sprite_effect_type = :blink
  1031.       Sound.play_actor_damage      
  1032.     end
  1033.   end
  1034.  
  1035.   def face_direction
  1036.     if $game_system.basimple_options.side==0
  1037.       if actor?
  1038.         return 1
  1039.       else
  1040.         return -1
  1041.       end
  1042.     else
  1043.       if actor?
  1044.         return -1
  1045.       else
  1046.         return 1
  1047.       end        
  1048.     end
  1049.   end
  1050.  
  1051. end
  1052.  
  1053.  
  1054. #==============================================================================
  1055. # ■ Sprite_Battler
  1056. #==============================================================================
  1057.  
  1058. class Sprite_Battler < Sprite_Base
  1059.    
  1060.   alias basimple_update update
  1061.   def update
  1062.     basimple_update
  1063.     update_size
  1064.     if $game_system.basimple_options.global_mirror==false
  1065.       if $game_system.basimple_options.side==0
  1066.         self.mirror=@battler.enemy?
  1067.       else
  1068.         self.mirror=@battler.actor?
  1069.       end
  1070.     else
  1071.       if $game_system.basimple_options.side==0
  1072.         self.mirror=@battler.actor?
  1073.       else
  1074.         self.mirror=@battler.enemy?
  1075.       end
  1076.     end
  1077.   end
  1078.  
  1079.   def update_size
  1080.     if @battler and @battler.size!=get_size
  1081.       @size=@battler.size
  1082.     end
  1083.     if @size!=1 or $cam_zoom!=1
  1084.       self.zoom_x=get_size
  1085.       self.zoom_y=get_size
  1086.     end
  1087.   end
  1088.  
  1089.   def update_position
  1090.     self.x = ((@battler.current_x-$cam_x)*$cam_zoom+Graphics.width/2).to_i()
  1091.     self.y = ((@battler.current_y-$cam_y)*$cam_zoom+Graphics.height/2).to_i()
  1092.     self.z = self.y*2
  1093.   end
  1094.  
  1095.   def set_size(new_size)
  1096.     @size=new_size
  1097.   end
  1098.  
  1099.   def get_size
  1100.     if !@size
  1101.       @size=1
  1102.     end
  1103.     return @size*$cam_zoom
  1104.   end
  1105. end
  1106.  
  1107. class Game_Battler < Game_BattlerBase
  1108.   def face_direction
  1109.     if $game_system.basimple_options.side==0
  1110.       if actor?
  1111.         return 1
  1112.       else
  1113.         return -1
  1114.       end
  1115.     else
  1116.       if actor?
  1117.         return -1
  1118.       else
  1119.         return 1
  1120.       end        
  1121.     end
  1122.   end
  1123. end
  1124. #==============================================================================
  1125. # ■ Spriteset_Battle
  1126. #==============================================================================
  1127.  
  1128. class Spriteset_Battle
  1129.   #--------------------------------------------------------------------------
  1130.   # battleback blues
  1131.   #--------------------------------------------------------------------------
  1132.   def create_battleback1
  1133.     @back1_sprite = Plane.new(@viewport1)
  1134.     @back1_sprite.bitmap = battleback1_bitmap
  1135.     @back1_sprite.z = 0
  1136.     @scroll1_x=0
  1137.     @scroll1_y=0
  1138.   end
  1139.  
  1140.   def create_battleback2
  1141.     @back2_sprite = Plane.new(@viewport1)
  1142.     @back2_sprite.bitmap = battleback2_bitmap
  1143.     @back2_sprite.z = 1
  1144.     if $game_system.basimple_options.back_panning
  1145.       @back2_sprite.z = $game_system.basimple_options.back2_z
  1146.     end
  1147.     @scroll2_x=0
  1148.     @scroll2_y=0
  1149.   end
  1150.  
  1151.   def update_battleback1
  1152.     return if not battleback1_name
  1153.     @back1_sprite.zoom_x=$cam_zoom
  1154.     @back1_sprite.zoom_y=$cam_zoom
  1155.     @scroll1_x+=$game_system.basimple_options.back1_scroll_x
  1156.     @scroll1_y+=$game_system.basimple_options.back1_scroll_y
  1157.     @back1_sprite.ox=(($cam_x)*$cam_zoom)-Graphics.width/2 +@scroll1_x
  1158.     @back1_sprite.oy=(($cam_y)*$cam_zoom)-Graphics.height/2 +@scroll1_y
  1159.   end
  1160.  
  1161.   def update_battleback2
  1162.     return if not battleback2_name
  1163.     @back2_sprite.zoom_x=$cam_zoom
  1164.     @back2_sprite.zoom_y=$cam_zoom
  1165.     @scroll2_x+=$game_system.basimple_options.back2_scroll_x
  1166.     @scroll2_y+=$game_system.basimple_options.back2_scroll_y
  1167.  
  1168.     if $game_system.basimple_options.back_panning
  1169.       @back2_sprite.ox=(($cam_x*$game_system.basimple_options.backpanning_x)*$cam_zoom)-Graphics.width/2 +@scroll2_x
  1170.       @back2_sprite.oy=(($cam_y*$game_system.basimple_options.backpanning_y)*$cam_zoom)-Graphics.height/2 +@scroll2_y
  1171.     else
  1172.       @back2_sprite.ox=(($cam_x)*$cam_zoom)-Graphics.width/2 +@scroll2_x
  1173.       @back2_sprite.oy=(($cam_y)*$cam_zoom)-Graphics.height/2 +@scroll2_y
  1174.     end
  1175.   end
  1176.  
  1177.   #--------------------------------------------------------------------------
  1178.   # create_actors
  1179.   #--------------------------------------------------------------------------
  1180.   # cause they needed to be visible
  1181.   #--------------------------------------------------------------------------
  1182.   def create_actors
  1183.     @actor_sprites = $game_party.members.reverse.collect do |actor|
  1184.       Sprite_Battler.new(@viewport1, actor)
  1185.     end
  1186.   end
  1187.  
  1188.   #--------------------------------------------------------------------------
  1189.   # update_actors
  1190.   #--------------------------------------------------------------------------
  1191.   def update_actors
  1192.       @actor_sprites.each {|sprite| sprite.update }
  1193.   end
  1194.    
  1195. end
Advertisement
Add Comment
Please, Sign In to add comment