#--------------------------------# # Dramatic Lightning Co Presents: # Face Time #--------------------------------# # Your Battlers will have a random face in battle! # This is a complicated script, so first, you need # a "face" folder in your Battlers folder and a few "face#" pictures in there. #--------------------------------# # You place any of these notetags on the enemy: # - Choose the default face or else your enemy has a blank face. # - Change the face category and the chance of getting a default face. #Example: if Enemy A has "face", Enemy B uses "teddy" faces. # - Adjust the position of the faces. Faces start at the middle of the baller. # - Adjusts zoom on a 100 scales and the tilt of the face. #Half slices up the face, 1/2 top/bottom, 3/4 left/right, and 5/6 eyes only. #--------------------------------# module DL module FACE DEFAULT_FOLD = "face" # The name of the folder. Use nil or "" to get faces from Battlers DEFAULT_FACE = "face" # The name of the face file. When using more than one, label them face0, face1, face2... DEFAULT_NUM = 10 # The probability of getting a face. If this number is higher than the number of faces you have, you may get a blank face or default face. end end class RPG::BaseItem def facebase return @facebase end def facebase_change regex = //i res = self.note.match(regex) if res @facebase = res[1].to_s if DL::FACE::DEFAULT_FOLD != nil and DL::FACE::DEFAULT_FOLD != "" @facebase = DL::FACE::DEFAULT_FOLD + "/" + @facebase end else @facebase = nil end end def facemore @facemore = "" if @facemore == nil return @facemore end def facecount @facecount = 0 if @facecount == nil return @facecount end def facemore_change regex = //i res = self.note.match(regex) if res @facemore = res[1].to_s @facecount = res[2].to_i @facemore = DL::FACE::DEFAULT_FOLD + "/" + @facemore if DL::FACE::DEFAULT_FOLD != nil else if DL::FACE::DEFAULT_FOLD == nil @facemore = DL::FACE::DEFAULT_FACE else @facemore = DL::FACE::DEFAULT_FOLD + "/" + DL::FACE::DEFAULT_FACE end @facecount = DL::FACE::DEFAULT_NUM end end def facex @facex = 0 if @facex == nil return @facex end def facey @facey = 0 if @facey == nil return @facey end def faceposition_change regex = //i res = self.note.match(regex) if res @facex = res[1].to_i @facey = res[2].to_i else @facex = 0 @facey = 0 end end def facezoom_x @facezoom_x = 1.0 if @facezoom_x == nil return @facezoom_x end def facezoom_y @facezoom_y = 1.0 if @facezoom_y == nil return @facezoom_y end def faceangle @faceangle = 0 if @faceangle == nil return @faceangle end def facehalf @facehalf = 0 if @facehalf == nil return @facehalf end def faceextra_change regex = //i res = self.note.match(regex) if res @facezoom_x = res[1].to_f / 100 @facezoom_y = res[2].to_f / 100 @faceangle = res[3].to_i @facehalf = res[4].to_i else @facezoom_x = 1.0 @facezoom_y = 1.0 @faceangle = 0 @facehalf = 0 end end end ########################################################################### class Game_Enemy < Game_Battler alias :dl_initialize :initialize def initialize(index, enemy_id) dl_initialize(index, enemy_id) more_setup(enemy_id) mega_more_setup end def more_setup(enemy_id) da = $data_enemies[enemy_id] da.facemore_change da.facebase_change da.faceposition_change da.faceextra_change @facemore = da.facemore @facecount = da.facecount @facebase = da.facebase @facex = da.facex @facey = da.facey @facezoom_x = da.facezoom_x @facezoom_y = da.facezoom_y @faceangle = da.faceangle @facehalf = da.facehalf end def facebase return @facebase end def facemore @facemore = "" if @facemore == nil return @facemore end def facemore @facecount = 0 if @facecount == nil return @facecount end def facex @facex = 0 if @facex == nil return @facex end def facey @facey = 0 if @facey == nil return @facey end def facezoom_x @facezoom_x = 1.0 if @facezoom_x == nil return @facezoom_x end def facezoom_y @facezoom_y = 1.0 if @facezoom_y == nil return @facezoom_y end def faceangle @faceangle = 0 if @faceangle == nil return @faceangle end def facehalf @facehalf = 0 if @facehalf == nil return @facehalf end def mega_more_setup bob = nil begin if @facecount > 1 bob = @facemore + (rand(@facecount)).to_s else bob = @facemore end bobby = Cache.battler(bob, 0) rescue bob = @facebase end bob = nil if @facemore.include? "noface" or (@facebase != nil and @facebase.include? "noface") @facebase = bob end end #============================================================================== # ** Sprite_Battler #------------------------------------------------------------------------------ # This sprite is used to display battlers. It observes an instance of the # Game_Battler class and automatically changes sprite states. #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :battler #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias :dl_initialize :initialize def initialize(viewport, battler = nil) dl_initialize(viewport, battler) @facemap = Sprite.new(viewport) #@facemap.bitmap = Cache.battler("face/" + "face", 0) end #-------------------------------------------------------------------------- # * Free #-------------------------------------------------------------------------- alias :dl_dispose :dispose def dispose @facemap.dispose if @facemap dl_dispose end #-------------------------------------------------------------------------- # * Update Transfer Origin Bitmap #-------------------------------------------------------------------------- alias :dl_update_bitmap :update_bitmap def update_bitmap dl_update_bitmap if @battler.facebase != nil new_facemap = Cache.battler(@battler.facebase, @battler.battler_hue) if @facemap.bitmap != new_facemap @facemap.bitmap = new_facemap @battler_visible = @battler.alive? @facemap.opacity = 0 unless @battler_visible end end end #-------------------------------------------------------------------------- # * Update Origin #-------------------------------------------------------------------------- alias :dl_update_origin :update_origin def update_origin dl_update_origin @facemap.ox = @facemap.width / 2 @facemap.oy = @facemap.height / 2 end #-------------------------------------------------------------------------- # * Update Position #-------------------------------------------------------------------------- alias :dl_update_position :update_position def update_position dl_update_position @facemap.x = self.x + @battler.facex @facemap.y = self.y - (self.oy / 2) + @battler.facey @facemap.z = self.z + 1 case @battler.facehalf when 1 # top @facemap.src_rect.height = @facemap.bitmap.height * (2.0/3.0) if @facemap.bitmap @facemap.y -= @facemap.height * (2.0/3.0) when 2 # bottom @facemap.src_rect.y = @facemap.bitmap.height * (1.0/3.0) if @facemap.bitmap @facemap.y += @facemap.height * (2.0/3.0) when 3 # left @facemap.src_rect.width = @facemap.bitmap.width / 2 if @facemap.bitmap when 4 # right @facemap.src_rect.x = @facemap.bitmap.width / 2 if @facemap.bitmap @facemap.x += @facemap.width / 2 when 5 #left eye @facemap.src_rect.height = @facemap.bitmap.height * (2.0/3.0) if @facemap.bitmap @facemap.y -= @facemap.height * (2.0/3.0) @facemap.src_rect.width = @facemap.bitmap.width / 2 if @facemap.bitmap when 6 #right eye @facemap.src_rect.height = @facemap.bitmap.height * (2.0/3.0) if @facemap.bitmap @facemap.y -= @facemap.height * (2.0/3.0) @facemap.src_rect.x = @facemap.bitmap.width / 2 if @facemap.bitmap @facemap.x += @facemap.width / 2 end @facemap.zoom_x = @battler.facezoom_x @facemap.zoom_y = @battler.facezoom_y @facemap.angle = @battler.faceangle end #-------------------------------------------------------------------------- # * Revert to Normal Settings #-------------------------------------------------------------------------- alias :dl_revert_to_normal :revert_to_normal def revert_to_normal dl_revert_to_normal @facemap.blend_type = self.blend_type @facemap.color = self.color @facemap.opacity = self.opacity @facemap.ox = @facemap.width / 2 if @battler.enemy? and @battler.facehalf == 2 @facemap.src_rect.y = @facemap.bitmap.height * (2.0/3.0) if @facemap.bitmap else @facemap.src_rect.y = 0 end end alias :dl_update_effect :update_effect def update_effect dl_update_effect @facemap.color = self.color @facemap.color.alpha= self.color.alpha @facemap.opacity = self.opacity @facemap.blend_type = self.blend_type @facemap.ox = @facemap.width / 2 if @battler.enemy? and @battler.facehalf == 2 @facemap.src_rect.y = (@facemap.bitmap.height * (2.0/3.0)) + self.src_rect.y if @facemap.bitmap else @facemap.src_rect.y = self.src_rect.y end @facemap.update end def animation_process_timing(timing) timing.se.play unless @ani_duplicated case timing.flash_scope when 1 self.flash(timing.flash_color, timing.flash_duration * @ani_rate) @facemap.flash(timing.flash_color, timing.flash_duration * @ani_rate) when 2 if viewport && !@ani_duplicated viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate) end when 3 self.flash(nil, timing.flash_duration * @ani_rate) @facemap.flash(nil, timing.flash_duration * @ani_rate) end end end