#============================================================================== # BASIMPLE BATTLE SYSTEM # Author Molegato # Version 2.1 #------------------------------------------------------------------------------ # The formerly least customizable battle system on the universe, now it's # customizable! hooray! #============================================================================== $imported = {} if $imported.nil? $imported['Molegato-Basimple Battle System'] = true #============================================================================== # CONFIGURATION, YOU CAN TOUCH THIS #============================================================================== module MOLEGATO_BASIMPLE_BS # Number of frames for the poses FRAME_NUMBER = 4 # Animation Speed FRAME_SPEED = 0.1 # 0 -> default # 1 -> no effect # 2 -> all blink DAMAGE_EFFECT = 1 #troops with @ in their name will never auto-arrange ARRANGE_ENEMIES = true #0= heroes at left, 1= heroes at right SIDE = 0 #distance to the border of the screen (horizontally) MARGIN = 75 #distance to the top of the lowest member of the party VERTICAL_PARTY_POS = 325 #vertical separation between members of the party VERTICAL_SEP = 25 #for a diagonal-ish effect, horizontal separation between members of party DIAGONAL_POS = 30 #Distance the battler will be away of its target while meleeing MELEE_DISTANCE = 25 #Distance the battler will move forward while casting magic STEP_DISTANCE = 100 # screen y for battlers that are attacking everyone CENTER_DOWN = 250 #to mirror every battler. Useful if all your battlers are facing the left and you dont want to flip'em all GLOBAL_MIRROR = false end #============================================================================== # TAG INSTRUCTIONS #------------------------------------------------------------------------------ # For Actors/enemies: # Sets an animation for guarding # # Both control the size of the battler. 1 means normal. # # For Skills/items: # The battler gets near the target while performing action # Shows an animation on battler before moving # Shows an animation on battler after moving. # Uses a custom pose animation, rather than the default # magical/physical/item one. # #============================================================================== #============================================================================== # END OF CONFIGURATION. EVERYTHING UNDER HERE IS A HELLISH MESS OF DEFICIENT # AMATEUR SCRIPTING. BE AWARE THAT MESSING WITH IT CAN RESULT IN DISASTER #============================================================================== #============================================================================== # ■ BattleManager #============================================================================== module BattleManager def self.update_pos action_battlers = [] action_battlers += $game_party.members unless @surprise action_battlers += $game_troop.members unless @preemptive action_battlers.each {|battler| battler.update_pos battler.frame+=MOLEGATO_BASIMPLE_BS::FRAME_SPEED if frame_string=battler.frame.round()>MOLEGATO_BASIMPLE_BS::FRAME_NUMBER-1 if battler.action=='' or battler.action=='move' or battler.action=='move_back' battler.frame=0 else battler.frame=MOLEGATO_BASIMPLE_BS::FRAME_NUMBER-1 end end } end def self.init_pos @action_battlers = [] @action_battlers += $game_party.members unless @surprise @action_battlers += $game_troop.members unless @preemptive @action_battlers.each {|battler| battler.set_x=battler.screen_x battler.set_y=battler.screen_y battler.current_x=battler.screen_x battler.current_y=battler.screen_y } end #-------------------------------------------------------------------------- # ● battle_start #-------------------------------------------------------------------------- # overwritten for fun!! #-------------------------------------------------------------------------- def self.battle_start $game_system.battle_count += 1 $game_party.on_battle_start $game_troop.on_battle_start $game_troop.enemy_names.each do |name| $game_message.add(sprintf(Vocab::Emerge, name)) end if @preemptive $game_message.add(sprintf(Vocab::Preemptive, $game_party.name)) elsif @surprise $game_message.add(sprintf(Vocab::Surprise, $game_party.name)) end init_pos wait_for_message end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● update_basic #-------------------------------------------------------------------------- # there used to be an infinite loop here. Its gone now. #-------------------------------------------------------------------------- alias basimple_update_basic update_basic def update_basic basimple_update_basic BattleManager.update_pos end #-------------------------------------------------------------------------- # ● use_item #-------------------------------------------------------------------------- # i spent a big time here #-------------------------------------------------------------------------- def use_item item = @subject.current_action.item #show cast anim if item.tag_check_multivalues(item.note,"cast_anim") show_animation([@subject], item.tag_check_multivalues(item.note,"cast_anim")[0].to_i()) end @subject.action="move" @subject.frame=0 #change pos if item.has_tag?("melee") if item.for_all? @subject.set_x=Graphics.width/2 @subject.set_y=MOLEGATO_BASIMPLE_BS::CENTER_DOWN else @subject.set_x=@subject.current_action.make_targets.compact[0].screen_x-MOLEGATO_BASIMPLE_BS::MELEE_DISTANCE*@subject.face_direction @subject.set_y=@subject.current_action.make_targets.compact[0].screen_y end end if not item.has_tag?("melee") if item.for_all? @subject.set_x=@subject.screen_x+MOLEGATO_BASIMPLE_BS::STEP_DISTANCE*@subject.face_direction @subject.set_y=MOLEGATO_BASIMPLE_BS::CENTER_DOWN else @subject.set_x=@subject.screen_x+MOLEGATO_BASIMPLE_BS::STEP_DISTANCE*@subject.face_direction @subject.set_y=@subject.current_action.make_targets.compact[0].screen_y end end #wait for the movement abs_wait(30) #change graphic custom=false if item.tag_check_multivalues(item.note,"custom_pose") @subject.action=item.tag_check_multivalues(item.note,"custom_pose")[0] custom=true end if item.is_a?(RPG:: Skill) && item.id == @subject.attack_skill_id if custom==false @subject.action="attack" end else if item.is_a?(RPG:: Skill) && item.id == @subject.guard_skill_id @subject.action="stand" #show guard anim if @subject.actor? if item.tag_check_multivalues(@subject.actor.note,"guard_anim") show_animation([@subject], item.tag_check_multivalues(@subject.actor.note,"guard_anim")[0].to_i()) end else if item.tag_check_multivalues(@subject.enemy.note,"guard_anim") show_animation([@subject], item.tag_check_multivalues(@subject.enemy.note,"guard_anim")[0].to_i()) end end else if item.is_a?(RPG:: Skill) && item.physical? if custom==false @subject.action="physical" end end if item.is_a?(RPG:: Skill) && item.magical? if custom==false @subject.action="magical" end end if item.is_a?(RPG:: Item) if custom==false @subject.action="item" end end end end @subject.frame=0 #show melee anim if item.tag_check_multivalues(item.note,"melee_anim") show_animation([@subject], item.tag_check_multivalues(item.note,"melee_anim")[0].to_i()) else #wait some more abs_wait(15) end @log_window.display_use_item(@subject, item) @subject.use_item(item) refresh_status targets = @subject.current_action.make_targets.compact targets.each {|target| item.repeats.times { if item.damage.to_hp? and not item.damage.recover? target.action="hurt" target.frame=0 end} } if not $imported["YEA-BattleEngine"] if targets.size==1 show_animation(targets, item.animation_id,targets[0].animation_mirror) else show_animation(targets, item.animation_id) end end targets.each {|target| item.repeats.times { invoke_item(target, item) target.action="" } } #restart graphic and pos @subject.action="move_back" @subject.frame=0 @subject.set_x=@subject.screen_x @subject.set_y=@subject.screen_y abs_wait(30) @subject.action="" @subject.frame=0 end #-------------------------------------------------------------------------- # show animation #-------------------------------------------------------------------------- # because of the mirror #-------------------------------------------------------------------------- def show_animation(targets, animation_id, mirror = false) if animation_id < 0 show_attack_animation(targets) else show_normal_animation(targets, animation_id, mirror) end @log_window.wait wait_for_animation end end #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler attr_accessor :current_x attr_accessor :current_y attr_accessor :set_x attr_accessor :set_y attr_accessor :action attr_accessor :frame attr_accessor :size #-------------------------------------------------------------------------- # ● initialize #-------------------------------------------------------------------------- def initialize(index, enemy_id) super() @index = index @enemy_id = enemy_id enemy = $data_enemies[@enemy_id] @original_name = enemy.name @letter = "" @plural = false @screen_x = 0 @screen_y = 0 @battler_hue = enemy.battler_hue @hp = mhp @mp = mmp @current_x=0 @current_y=0 @set_x=0 @set_y=0 @action = '' @frame=0.0 if enemy.tag_check_multivalues(enemy.note,"enemy_size") @size=enemy.tag_check_multivalues(enemy.note,"enemy_size")[0].to_f else @size=1 end end def battler_name if MOLEGATO_BASIMPLE_BS::FRAME_NUMBER==1 frame_string='' else frame_string=@frame.round().to_s() end if action=='' return enemy.battler_name+'/'+'stand'+frame_string else return enemy.battler_name+'/'+action+frame_string end end def update_pos @current_x=(@current_x*9+@set_x)/10 @current_y=(@current_y*9+@set_y)/10 end def screen_x if MOLEGATO_BASIMPLE_BS::ARRANGE_ENEMIES==false or $game_troop.troop.name[/@/mi]=="@" return @screen_x else if MOLEGATO_BASIMPLE_BS::SIDE==0 return Graphics.width-MOLEGATO_BASIMPLE_BS::MARGIN - MOLEGATO_BASIMPLE_BS::DIAGONAL_POS*self.index else return MOLEGATO_BASIMPLE_BS::MARGIN + MOLEGATO_BASIMPLE_BS::DIAGONAL_POS*self.index end end end def screen_y if MOLEGATO_BASIMPLE_BS::ARRANGE_ENEMIES==false or $game_troop.troop.name[/@/mi]=="@" return @screen_y else return MOLEGATO_BASIMPLE_BS::VERTICAL_PARTY_POS-self.index*MOLEGATO_BASIMPLE_BS::VERTICAL_SEP end end def animation_mirror if MOLEGATO_BASIMPLE_BS::GLOBAL_MIRROR==false if MOLEGATO_BASIMPLE_BS::SIDE==0 return false else return true end else if MOLEGATO_BASIMPLE_BS::SIDE==0 return true else return false end end end #-------------------------------------------------------------------------- # ● perform damage_effect #-------------------------------------------------------------------------- # cause it was annoying. #-------------------------------------------------------------------------- def perform_damage_effect if MOLEGATO_BASIMPLE_BS::DAMAGE_EFFECT==0 or MOLEGATO_BASIMPLE_BS::DAMAGE_EFFECT==2 @sprite_effect_type = :blink Sound.play_enemy_damage end end def face_direction if MOLEGATO_BASIMPLE_BS::SIDE==0 if actor? return 1 else return -1 end else if actor? return -1 else return 1 end end end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler attr_accessor :current_x attr_accessor :current_y attr_accessor :set_x attr_accessor :set_y attr_accessor :action attr_accessor :frame attr_accessor :size #-------------------------------------------------------------------------- # ● setup #-------------------------------------------------------------------------- def setup(actor_id) @actor_id = actor_id @name = actor.name @nickname = actor.nickname init_graphics @class_id = actor.class_id @level = actor.initial_level @exp = {} @equips = [] @battler_hue = 0 init_exp init_skills init_equips(actor.equips) clear_param_plus recover_all @current_x=0 @current_y=0 @set_x=0 @set_y=0 @action = '' @frame=0.0 if actor.tag_check_multivalues(actor.note,"actor_size") @size=actor.tag_check_multivalues(actor.note,"actor_size")[0].to_f else @size=1 end end #-------------------------------------------------------------------------- # ● screen_whatever #-------------------------------------------------------------------------- def screen_z return 100 end def screen_x if MOLEGATO_BASIMPLE_BS::SIDE==0 return MOLEGATO_BASIMPLE_BS::MARGIN + MOLEGATO_BASIMPLE_BS::DIAGONAL_POS*self.index else return Graphics.width-MOLEGATO_BASIMPLE_BS::MARGIN - MOLEGATO_BASIMPLE_BS::DIAGONAL_POS*self.index end end def screen_y return MOLEGATO_BASIMPLE_BS::VERTICAL_PARTY_POS-self.index*MOLEGATO_BASIMPLE_BS::VERTICAL_SEP end def battler_name if MOLEGATO_BASIMPLE_BS::FRAME_NUMBER==1 frame_string='' else frame_string=@frame.round().to_s() end if action=='' return face_name+"/"+'stand'+frame_string else return face_name+"/"+action+frame_string end end def update_pos @current_x=(@current_x*9+@set_x)/10 @current_y=(@current_y*9+@set_y)/10 end #-------------------------------------------------------------------------- # ● use sprite #-------------------------------------------------------------------------- def use_sprite? return true end def animation_mirror if MOLEGATO_BASIMPLE_BS::GLOBAL_MIRROR==false if MOLEGATO_BASIMPLE_BS::SIDE==0 return true else return false end else if MOLEGATO_BASIMPLE_BS::SIDE==0 return false else return true end end end #-------------------------------------------------------------------------- # ● perform damage effect #-------------------------------------------------------------------------- # edited cause it annoyed me #-------------------------------------------------------------------------- def perform_damage_effect if MOLEGATO_BASIMPLE_BS::DAMAGE_EFFECT==0 $game_troop.screen.start_shake(5, 5, 10) @sprite_effect_type = :blink Sound.play_actor_damage end if MOLEGATO_BASIMPLE_BS::DAMAGE_EFFECT==2 @sprite_effect_type = :blink Sound.play_actor_damage end end def face_direction if MOLEGATO_BASIMPLE_BS::SIDE==0 if actor? return 1 else return -1 end else if actor? return -1 else return 1 end end end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base alias basimple_update update def update basimple_update update_size if MOLEGATO_BASIMPLE_BS::GLOBAL_MIRROR==false if MOLEGATO_BASIMPLE_BS::SIDE==0 self.mirror=@battler.enemy? else self.mirror=@battler.actor? end else if MOLEGATO_BASIMPLE_BS::SIDE==0 self.mirror=@battler.actor? else self.mirror=@battler.enemy? end end end def update_size if @battler and @battler.size!=get_size @size=@battler.size end if get_size!=1 source = self.bitmap self.bitmap = Bitmap.new(source.width*@size, source.height*@size) self.bitmap.stretch_blt(self.bitmap.rect, source, source.rect) self.ox*=get_size self.oy*=get_size end end #-------------------------------------------------------------------------- # ● 位置の更新 #-------------------------------------------------------------------------- def update_position self.x = @battler.current_x self.y = @battler.current_y self.z = self.y*2 end def set_size(new_size) @size=new_size end def get_size if !@size @size=1 end return @size end end class Game_Battler < Game_BattlerBase def face_direction if MOLEGATO_BASIMPLE_BS::SIDE==0 if actor? return 1 else return -1 end else if actor? return -1 else return 1 end end end end #============================================================================== # ■ Spriteset_Battle #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # create_actors #-------------------------------------------------------------------------- # cause they needed to be visible #-------------------------------------------------------------------------- def create_actors @actor_sprites = $game_party.members.reverse.collect do |actor| Sprite_Battler.new(@viewport1, actor) end end #-------------------------------------------------------------------------- # update_actors #-------------------------------------------------------------------------- def update_actors @actor_sprites.each {|sprite| sprite.update } end end