Плохо! Плохо!:  0
Страница 2 из 3 ПерваяПервая 123 ПоследняяПоследняя
Показано с 11 по 20 из 30

Тема: Khas Awesome Light Effects

  1. #11
    Хранитель Форума Аватар для Валера
    Информация о пользователе
    Регистрация
    15.04.2008
    Адрес
    Москва
    Сообщений
    14,020
    Записей в дневнике
    3
    Репутация: 164 Добавить или отнять репутацию

    По умолчанию

    Цитата Сообщение от caveman Посмотреть сообщение
    Валера: в первую очередь я хочу новенький каменный топор))
    Последний писк каменной моды:

    Спойлер И как тебе не стыдно-то, а, Валера?:


    Оборона форта: http://rghost.ru/8kLGxFtD2
    Сделать, чтоб все происходило, как я хочу, - вот, собственно, и весь мейкер!
    Адский Рейд: http://rpgmaker.su/downloads/%D0%B7%...-2010raid-full

  2. #12
    Познающий Аватар для Shiva
    Информация о пользователе
    Регистрация
    11.02.2013
    Сообщений
    291
    Репутация: 8 Добавить или отнять репутацию

    По умолчанию

    Цитата Сообщение от HopeBree Посмотреть сообщение
    мне оригинал не нужен
    он у меня есть и уже давно, мне нужна сама реализация параметра R_G или же его можно просто скопировать и вставить?
    Shiva, засунь под теги [CODE] скрипт
    хз как

  3. #13
    Маститый Аватар для HopeBree
    Информация о пользователе
    Регистрация
    28.03.2013
    Сообщений
    1,201
    Записей в дневнике
    6
    Репутация: 38 Добавить или отнять репутацию

    По умолчанию

    fuck yeah.jpg
    посидел, подумал, переделал под АСЕ :3
    Код:
    #-------------------------------------------------------------------------------
    # * [ACE] Khas Awesome Light Effects
    #-------------------------------------------------------------------------------
    # * By Khas Arcthunder - arcthunder.site40.net
    # * Version: 1.0 EN (caveman RGSS edit 1.1 HB RGSS3)
    # * Released on: 17/01/2012
    #
    #-------------------------------------------------------------------------------
    # * Terms of Use
    #-------------------------------------------------------------------------------
    # When using any Khas script, you agree with the following terms:
    # 1. You must give credit to Khas;
    # 2. All Khas scripts are licensed under a Creative Commons license;
    # 3. All Khas scripts are for non-commercial projects. If you need some script 
    #    for your commercial project (I accept requests for this type of project), 
    #    send an email to nilokruch@live.com with your request;
    # 4. All Khas scripts are for personal use, you can use or edit for your own 
    #    project, but you are not allowed to post any modified version;
    # 5. You can’t give credit to yourself for posting any Khas script;
    # 6. If you want to share a Khas script, don’t post the direct download link, 
    #    please redirect the user to arcthunder.site40.net
    #
    #-------------------------------------------------------------------------------
    # * Features
    #-------------------------------------------------------------------------------
    # - Realistic Light
    # - Light does not pass over walls, blocks and roofs
    # - Static Light Sources
    # - Dynamic Light Sources (like a player's lantern)
    # - Multiple effects
    # - Easy to use (comments)
    #
    #-------------------------------------------------------------------------------
    # * WARNING - Performance
    #-------------------------------------------------------------------------------
    # This script may be too heavy to old processors! The Awesome Light Effects was
    # tested on a Core 2 Duo E4500 and on a Core i5, without any lag. However,
    # there's other factors that may influence the script performance:
    #
    # 1. Map size
    # This script searches surfaces on the map, in order to cut the light pictures.
    # In a huge map, the number of surfaces may increase a lot, affecting the
    # DYNAMIC LIGHT SOURCE only. Map size does not influence the static sources.
    #
    # 2. Number of effects
    # This script draws the effects on the screen, but before drawing, it checks 
    # if the effect is out of screen (in this case, the script will skip the 
    # light drawing). Too much effects may cause lag, but this is just a prevision.
    #
    # 3. Effect's picture size
    # The picture size of the DYNAMIC LIGHT SOURCE influences directly on your 
    # game's performace. The bigger is the picture, the slower it will be to
    # draw it dynamically. The recommended maximum size is 200x200 pixels
    # 
    #-------------------------------------------------------------------------------
    # * WARNING - Light pictures
    #-------------------------------------------------------------------------------
    # In order to run this script correctly, the light pictures MUST obey the
    # following conditions:
    # 1. The picture's size MUST be multiple of 2. Example: 150x150
    # 2. The picture's width MUST be equal to it's height. Example: 156x156
    # 3. The picture's colors MUST be inverted! This is necessary because
    #    the script inverts the colors to draw the effect. The black color
    #    will be transparent!
    #
    #-------------------------------------------------------------------------------
    # * Instructions - 1. Setup your effects!
    #-------------------------------------------------------------------------------
    # In order to setup your static effects, go to the setup part and define your
    # effects inside the Effects hash. Do as the following mode:
    #
    # X => [picture,opacity,variation,cut],   <= Remember to put a comma here!
    #
    # Where:
    # picture => Picture's name, inside the Graphics/Lights folder;
    # opacity => Effect's opacity;
    # variation => Effect's opacity variation;
    # cut => Put true to cut the effect or false to don't;
    # X => The effect's ID, it will be used on events. 
    #
    # Check the default effects to understand how they work.
    #
    #-------------------------------------------------------------------------------
    # * Instructions - 2. Use your effects!
    #-------------------------------------------------------------------------------
    # In order to use a effect, put the following comment on a event:
    # 
    # [light x]
    #
    # Where x must be the Effect's ID.
    # 
    #-------------------------------------------------------------------------------
    # * Instructions - 3. Use an awesome lantern!
    #-------------------------------------------------------------------------------
    # The dynamic light source (lantern) is initialized invisible by default. 
    # You may call the following commands:
    # 
    # l = $game_map.lantern
    # Gets the lantern into a variable
    
    # l.set_graphic(i)
    # Sets the lantern's graphic to i, where i must be the picture's file name on 
    # Graphics/Lights folder.
    #
    # l.set_multiple_graphics(h)
    # Sets the lantern's graphics to h, where h must be a hash with the following
    # structure:
    #
    # h = {2=>"ld",4=>"ll",6=>"lr",8=>"lu"}
    # 
    # Where: 
    # "ld" is the name of the picture when the lantern's owner is looking down;
    # "ll" is the name of the picture when the lantern's owner is looking left;
    # "lr" is the name of the picture when the lantern's owner is looking right;
    # "lu" is the name of the picture when the lantern's owner is looking up.
    #
    # l.change_owner(char)
    # Sets the lantern's owner to char. Char must be ONE of the following commands:
    # $game_player           <= The player itself;
    # self_event             <= The event where the command was called;
    # $game_map.events[x]    <= The event ID x.
    #
    # l.set_opacity(o,p)
    # Sets the lantern's opacity, where:
    # o is the opacity itself;
    # p is the opacity variation.
    #
    # l.show
    # After setting the lantern with the commands above, you may set it to visible
    # using this command.
    #
    # l.hide
    # Use this command to set the lantern as invisible.
    #
    #-------------------------------------------------------------------------------
    # * Instructions - 4. Use the effect's surface!
    #-------------------------------------------------------------------------------
    # The Awesome Light Effects draws the effects on a surface. In order to make
    # the effects visible, the effect's surface MUST be visible. The Effect's 
    # Surface is initialized with it's opacity set to zero. You can call the
    # following commands:
    #
    # s = $game_map.effect_surface
    # Gets the Effect's Surface into a variable
    #
    # s.set_color(r,g,b)
    # Changes the Effect's Surface color instantly, where:
    # r => red level;
    # g => green level;
    # b => blue level;
    #
    # s.set_alpha(a)
    # Changes the Effect's Surface opacity instantly to a.
    #
    # s.change_color(time,r,g,b)
    # Changes the Effect's Surface color ONLY in a certain time, where:
    # time => The change's time (frames);
    # r => red level;
    # g => green level;
    # b => blue level;
    #
    # s.change_color(time,r,g,b,a)
    # Changes the Effect's Surface color and it's opacity in a certain time, where:
    # time => The change's time (frames);
    # r => red level;
    # g => green level;
    # b => blue level;
    # a => opacity
    #
    # s.change_alpha(time,a)
    # Changes the Effect's Surface opacity in a certain time, where:
    # time => The change's time (frames);
    # a => opacity
    #
    #-------------------------------------------------------------------------------
    # * Instructions - 5. Use the effect's surface with Tone command!
    #-------------------------------------------------------------------------------
    # You can access the Effect's Surface with the "Screen Tone" command. In order
    # to turn this feature on, set the "Surface_UE" constant to true.
    #
    # If you decided to use this feature, please note some details:
    # 1. The colors values must be between 0 and 255;
    # 2. The time is in frames;
    # 3. The "gray" value will be sent as the opacity value
    #
    #-------------------------------------------------------------------------------
    # * Instructions - 6. Setup your Tileset Tags!
    #-------------------------------------------------------------------------------
    # In order to cut the effect's picture correctly, there's 3 types of behavior
    # for a tile: wall, block and roof. Walls will make shadows as real walls, 
    # blocks as blocks and roofs as roofs. So, the tileset tags MUST be configured.
    # Check the demo to understand how this system works. If the tilesets aren't 
    # configured correctly, the script won't cut the effects correctly.
    # 
    #-------------------------------------------------------------------------------
    # * Setup Part
    #-------------------------------------------------------------------------------
    module Light_Core
      Effects = { #  <= DON'T change this!
    #-------------------------------------------------------------------------------
    # PUT YOUR EFFECTS HERE!
    #-------------------------------------------------------------------------------
      0 => ["light",255,0,true],
      1 => ["torch",200,20,true],
      2 => ["torch_m",180,30,true],
      3 => ["light_s",255,0,true],
      
    #-------------------------------------------------------------------------------
    # End of effecs configuration
    #------------------------------------------------------------------------------- 
      } #  <= DON'T change this!
      
      # Z coordinate of the Effect's Surface
      Surface_Z = 180
      
      # Enable Effect's Surface control by "Screen Tone" command?
      Surface_UE = true
      
      # Roof behavior tag
      Roof_Tag = 5
      # Wall behavior tag
      Wall_Tag = 6
      # Block behavior tag
      Block_Tag = 7
      
      # Don't change this!
      ACC = Math.tan(Math::PI/26)
      
      # Shadow quality (1 - ideal, the more - the worse and faster)
      R_G = 4
    end
    #-------------------------------------------------------------------------------
    # Script
    #-------------------------------------------------------------------------------
    module Cache
      def self.light(filename)
        load_bitmap("Graphics/Lights/", filename)
      end
    end
    module Light_Bitcore
      include Light_Core
      def self.initialize
        @@buffer = {}
        Effects.values.each { |effect| Light_Bitcore.push(effect[0])}
      end
      def self::[](key)
        return @@buffer[key]
      end
      def self.push(key)
        return if @@buffer.keys.include?(key)
        @@buffer[key] = Cache.light(key)
      end
    end
    Light_Bitcore.initialize
    class Light_SSource
      attr_reader :real_x
      attr_reader :real_y
      attr_reader :range
      attr_accessor :bitmap
      attr_reader :w
      attr_reader :h
      attr_reader :hs
      def initialize(char,bitmap,opacity,plus,hs)
        sync(char)
        @key = bitmap
        @bitmap = Light_Bitcore[@key].clone
        @range = @bitmap.width/2
        @w = @bitmap.width
        @h = @bitmap.height
        @mr = @range - 16
        @opacity = opacity
        @plus = plus
        @hs = hs
        render if @hs
      end
      def render
        tx = x
        ty = y
        tsx = x + @range
        tsy = y + @range
        dr = @range*2
        for s in $game_map.surfaces
          next if !s.visible?(tsx,tsy) || !s.within?(tx,tx+dr,ty,ty+dr)
          s.render_shadow(tx,ty,tsx,tsy,@range,@bitmap)
        end
      end
      def restore
        return unless @bitmap.nil?
        @bitmap = Light_Bitcore[@key].clone
        render if @hs
      end
      def opacity
        @plus == 0 ? @opacity : (@opacity + rand(@plus))
      end
      def sx
        return $game_map.adjust_x(@real_x)*32-@mr
      end
      def sy
        return $game_map.adjust_y(@real_y)*32-@mr
      end
      def sync(char)
        @real_x = char.real_x
        @real_y = char.real_y
      end
      def x
        return (@real_x*32 - @mr).to_f
      end
      def y
        return (@real_y*32 - @mr).to_f
      end
      def dispose
        return if @bitmap.nil?
        @bitmap.dispose
        @bitmap = nil
      end
    end
    class Light_DSource < Light_SSource
      attr_reader :bitmap
      attr_reader :visible
      def initialize
        @key = nil
        @bitmap = nil
        @opacity = 255
        @plus = 0
        @char = $game_player
        @visible = false
      end
      def set_opacity(o,p)
        @opacity = o
        @plus = p
      end
      def set_graphic(sb)
        dispose
        @key = {2=>sb,4=>sb,6=>sb,8=>sb}
        Light_Bitcore.push(sb)
        @bitmap = {2=>Light_Bitcore[@key[2]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,8=>Light_Bitcore[@key[8]].clone}
        @range = @bitmap[2].width/2
        @w = @bitmap[2].width
        @h = @bitmap[2].height
        @mr = @range - 16
      end
      def set_multiple_graphics(ba)
        dispose
        @key = ba
        @key.values.each {|key| Light_Bitcore.push(key)}
        @bitmap = {2=>Light_Bitcore[@key[2]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,8=>Light_Bitcore[@key[8]].clone}
        @range = @bitmap[2].width/2
        @w = @bitmap[2].width
        @h = @bitmap[2].height
        @mr = @range - 16
      end
      def get_graphic
        return @bitmap[@char.direction].clone
      end
      def show
        return if @bitmap.nil?
        @visible = true
      end
      def hide
        @visible = false
      end
      def restore
        return if @key.nil?
        @key.values.each {|key| Light_Bitcore.push(key)}
        @bitmap = {2=>Light_Bitcore[@key[2]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,8=>Light_Bitcore[@key[8]].clone}
      end
      def dispose
        return if @bitmap.nil?
        @bitmap.values.each { |b| b.dispose }
        @bitmap = nil
      end
      def change_owner(char)
        @char = char
      end
      def render
      end
      def sx
        return $game_map.adjust_x(@char.real_x)*32-@mr
      end
      def sy
        return $game_map.adjust_y(@char.real_y)*32-@mr
      end
      def x
        return (@char.real_x*32 - @mr).to_f
      end
      def y
        return (@char.real_y*32 - @mr).to_f
      end
    end
    class Light_Surface
      def initialize
        @ta = @a = 0
        @tr = @r = 255
        @tg = @g = 255
        @tb = @b = 255
        @va = @vr = @vg = @vb = 0.0
        @timer = 0
      end
      def refresh
        return if @timer == 0
        @a += @va
        @r += @vr
        @g += @vg
        @b += @vb
        $game_map.light_surface.opacity = @a
        @timer -= 1
      end
      def change_color(time,r,g,b,a=nil)
        r = 0 if r < 0; r = 255 if r > 255
        g = 0 if g < 0; g = 255 if g > 255
        b = 0 if b < 0; b = 255 if b > 255
        unless a.nil?
          a = 0 if a < 0; a = 255 if a > 255
        end
        @timer = time
        @tr = 255-r
        @tg = 255-g
        @tb = 255-b
        @va = (a.nil? ? 0 : (a-@a).to_f/@timer)
        @vr = (@tr - @r).to_f/@timer
        @vg = (@tg - @g).to_f/@timer
        @vb = (@tb - @b).to_f/@timer
      end
      def change_alpha(time,a)
        a = 0 if a < 0; a = 255 if a > 255
        @timer = time
        @ta = a
        @vr = @vg = @vb = 0.0
        @va = (a-@a).to_f/@timer
      end
      def set_color(r,g,b)
        r = 0 if r < 0; r = 255 if r > 255
        g = 0 if g < 0; g = 255 if g > 255
        b = 0 if b < 0; b = 255 if b > 255
        @tr = @r = 255-r
        @tg = @g = 255-g
        @tb = @b = 255-b
        @va = @vr = @vg = @vb = 0.0
        @timer = 0
      end
      def set_alpha(a)
        a = 0 if a < 0; a = 255 if a > 255
        @ta = @a = a
        $game_map.light_surface.opacity = @a
        @va = @vr = @vg = @vb = 0.0
        @timer = 0
      end
      def alpha
        return @a
      end
      def color
        return Color.new(@r,@g,@b)
      end
    end
    class Game_Map
      include Light_Core
      attr_accessor :light_surface
      attr_accessor :light_sources
      attr_accessor :surfaces
      attr_accessor :effect_surface
      attr_accessor :lantern
      alias kbl_setup_events setup_events
      alias kbl_initialize initialize
      alias kbl_update update
      def initialize
        kbl_initialize
        @effect_surface = Light_Surface.new
        @lantern = Light_DSource.new
      end
      def update(arg)
        @effect_surface.refresh if arg
        kbl_update(arg)
      end
      def first_tag(x,y)
        tag = tileset.flags[tile_id(x,y,0)] >> 12
        return tag > 0 ? tag : 0
      end
      def setup_events
        @light_sources.nil? ? @light_sources = [] : @light_sources.clear
        setup_surfaces
        merge_surfaces
        kbl_setup_events
      end
      def setup_surfaces
        @surfaces = []
        for x in 0..(width-1)
          for y in 0..(height-1)
            tag = first_tag(x,y)
            if tag == Wall_Tag
              i = tile_id(x,y,0)
              if i & 0x02 == 0x02
                @surfaces << Block_SD.new(x*32,y*32,x*32+32,y*32)
              end
              if i & 0x04 == 0x04
                @surfaces << Block_WR.new(x*32+31,y*32,x*32+31,y*32+32)
                @surfaces << Block_IL.new(x*32+32,y*32,x*32+32,y*32+32)
              end
              if i & 0x01 == 0x01
                @surfaces << Block_IR.new(x*32-1,y*32,x*32-1,y*32+32)
                @surfaces << Block_WL.new(x*32,y*32,x*32,y*32+32)
              end
            elsif tag == Roof_Tag
              i = tile_id(x,y,0)
              @surfaces << Block_SU.new(x*32,y*32,x*32+32,y*32) if i & 0x02 == 0x02
              @surfaces << Block_SR.new(x*32+31,y*32,x*32+31,y*32+32) if i & 0x04 == 0x04
              @surfaces << Block_SL.new(x*32,y*32,x*32,y*32+32) if i & 0x01 == 0x01
            elsif tag == Block_Tag
              f = tileset.flags[tile_id(x,y,0)]
              @surfaces << Block_SL.new(x*32,y*32,x*32,y*32+32) if f & 0x02 == 0x02
              @surfaces << Block_SR.new(x*32+31,y*32,x*32+31,y*32+32) if f & 0x04 == 0x04
              @surfaces << Block_SU.new(x*32,y*32,x*32+32,y*32) if f & 0x08 == 0x08
            end
          end
        end
      end
      def merge_surfaces
        new_surfaces = []
        hs = []; vs = []
        ws = []; is = []
        for surface in @surfaces
          if surface.type & 0x05 == 0
            hs << surface
          else
            if surface.type & 0x010 == 0
              vs << surface
            else
              if surface.type & 0x08 == 0
                ws << surface
              else
                is << surface
              end
            end
          end
        end
        for surface in hs
          surface.ready ? next : surface.ready = true
          for s in hs
            next if s.ready || s.y1 != surface.y1 || surface.type != s.type
            if s.x2 == surface.x1
              surface.x1 = s.x1
              s.trash = true
              s.ready = true
              surface.ready = false
            elsif s.x1 == surface.x2
              surface.x2 = s.x2
              s.trash = true
              s.ready = true
              surface.ready = false
            end
          end
        end
        hs.each { |s| @surfaces.delete(s) if s.trash}
        for surface in vs
          surface.ready ? next : surface.ready
          for s in vs
            next if s.ready || s.x1 != surface.x1
            if s.y2 == surface.y1
              surface.y1 = s.y1
              s.trash = true
              s.ready = true
              surface.ready = false
            elsif s.y1 == surface.y2
              surface.y2 = s.y2
              s.trash = true
              s.ready = true
              surface.ready = false
            end
          end
        end
        vs.each { |s| @surfaces.delete(s) if s.trash}
        for surface in ws
          surface.ready ? next : surface.ready
          for s in ws
            next if s.ready || s.x1 != surface.x1
            if s.y2 == surface.y1
              surface.y1 = s.y1
              s.trash = true
              s.ready = true
              surface.ready = false
            elsif s.y1 == surface.y2
              surface.y2 = s.y2
              s.trash = true
              s.ready = true
              surface.ready = false
            end
          end
        end
        ws.each { |s| @surfaces.delete(s) if s.trash}
        for surface in is
          surface.ready ? next : surface.ready
          for s in is
            next if s.ready || s.x1 != surface.x1
            if s.y2 == surface.y1
              surface.y1 = s.y1
              s.trash = true
              s.ready = true
              surface.ready = false
            elsif s.y1 == surface.y2
              surface.y2 = s.y2
              s.trash = true
              s.ready = true
              surface.ready = false
            end
          end
        end
        is.each { |s| @surfaces.delete(s) if s.trash}
      end
    end
    class Game_Event < Game_Character
      alias kbl_initialize initialize
      alias kbl_setup_page setup_page
      def initialize(m,e)
        @light = nil
        kbl_initialize(m,e)
      end
      def setup_page(np)
        kbl_setup_page(np)
        setup_light(np.nil?)
      end
      def setup_light(dispose)
        unless @light.nil?
          $game_map.light_sources.delete(self)
          @light.dispose
          @light = nil
        end
        unless dispose && @list.nil?
          for command in @list
            if command.code == 108 && command.parameters[0].include?("[light")
              command.parameters[0].scan(/\[light ([0.0-9.9]+)\]/)
              effect = Light_Core::Effects[$1.to_i]
              @light = Light_SSource.new(self,effect[0],effect[1],effect[2],effect[3])
              $game_map.light_sources << self
              return
            end
          end
        end
      end
      def draw_light
        sx = @light.sx
        sy = @light.sy
        w = @light.w
        h = @light.h
        return if sx > 640 && sy > 416 && sx + w < 0 && sy + h < 0
        $game_map.light_surface.bitmap.blt(sx,sy,@light.bitmap,Rect.new(0,0,w,h),@light.opacity)
      end
      def dispose_light
        @light.dispose
      end
      def restore_light
        @light.restore
      end
    end
    if Light_Core::Surface_UE
      class Game_Interpreter
        def command_223
          $game_map.effect_surface.change_color(@params[1],@params[0].red,@params[0].green,@params[0].blue,@params[0].gray)
          wait(@params[1]) if @params[2]
        end
      end
    end
    class Game_Interpreter
      def self_event
        return $game_map.events[@event_id]
      end
    end
    class Block_Surface
      include Light_Core
      attr_accessor :x1
      attr_accessor :y1
      attr_accessor :x2
      attr_accessor :y2
      attr_accessor :ready
      attr_accessor :trash
      def initialize(x1,y1,x2,y2)
        @x1 = x1
        @y1 = y1
        @x2 = x2
        @y2 = y2
        @ready = false
        @trash = false
      end
      def within?(min_x,max_x,min_y,max_y)
        return @x2 > min_x && @x1 < max_x && @y2 > min_y && @y1 < max_y
      end
    end
    class Block_SL < Block_Surface
      attr_reader :type
      def initialize(x1,y1,x2,y2)
        super(x1,y1,x2,y2)
        @type = 0x01
      end
      def visible?(sx,sy)
        return sx < @x1 
      end
      def render_shadow(phx,phy,sx,sy,range,bitmap)
        @m1 = (@y1-sy)/(@x1-sx)
        @n1 = sy - @m1*sx
        @m2 = (@y2-sy)/(@x2-sx)
        @n2 = sy - @m2*sx
        
        i1 = (sx + range - @x1) / R_G
        for i in 0..i1
          x = R_G*i + @x1
          init = shadow_iy(x)
          bitmap.clear_rect(x-phx, init-phy, R_G, shadow_fy(x)-init+3)
        end
      end
      def shadow_iy(x)
        return @m1*x+@n1
      end
      def shadow_fy(x)
        return @m2*x+@n2
      end
    end
    class Block_SR < Block_Surface
      attr_reader :type
      def initialize(x1,y1,x2,y2)
        super(x1,y1,x2,y2)
        @type = 0x04
      end
      def visible?(sx,sy)
        return sx > @x1 
      end
      def render_shadow(phx,phy,sx,sy,range,bitmap)
        @m1 = (@y1-sy)/(@x1-sx)
        @n1 = sy - @m1*sx
        @m2 = (@y2-sy)/(@x2-sx)
        @n2 = sy - @m2*sx
        
        i1 = ((sx-range).to_i - @x1) / R_G
        for i in i1..0
          x = @x1 + R_G*i
          init = shadow_iy(x)
          bitmap.clear_rect(x-phx, init-phy, R_G, shadow_fy(x)-init+3)
        end
      end
      def shadow_iy(x)
        return @m1*x+@n1
      end
      def shadow_fy(x)
        return @m2*x+@n2
      end
    end
    class Block_IL < Block_Surface
      attr_reader :type
      def initialize(x1,y1,x2,y2)
        super(x1,y1,x2,y2)
        @type = 0x019
      end
      def visible?(sx,sy)
        return sx < @x1 && sy > @y1
      end
      def render_shadow(phx,phy,sx,sy,range,bitmap)
        @m1 = (@y1-sy)/(@x1-sx)
        @n1 = @y1 - @m1*@x1
        @m2 = (@y2-sy)/(@x2-sx)
        @m2 = 0 if @m2 > 0
        @n2 = @y2 - @m2*@x2
        
        i1 = (sx + range - @x1) / R_G    
        for i in 0..i1
          x = R_G*i + @x1
          init = shadow_iy(x).floor
          bitmap.clear_rect(x-phx, init-3-phy, R_G, shadow_fy(x)-init+3)
        end
      end
      def shadow_iy(x)
        return @m1*x+@n1
      end
      def shadow_fy(x)
        return @m2*x+@n2
      end
    end
    class Block_IR < Block_Surface
      attr_reader :type
      def initialize(x1,y1,x2,y2)
        super(x1,y1,x2,y2)
        @type = 0x01c
      end
      def visible?(sx,sy)
        return sx > @x1 && sy > @y1
      end
      def render_shadow(phx,phy,sx,sy,range,bitmap)
        @m1 = (@y1-sy)/(@x1-sx)
        @n1 = @y1 - @m1*@x1
        @m2 = (@y2-sy)/(@x2-sx)
        @m2 = 0 if @m2 < 0
        @n2 = @y2 - @m2*@x2
        
        i1 = ((sx-range).to_i - @x1) / R_G 
        for i in i1..0
          x = @x1 + R_G*i
          init = shadow_iy(x).floor
          bitmap.clear_rect(x-phx,init-3-phy,R_G,shadow_fy(x)-init+3)
        end
      end
      def shadow_iy(x)
        return @m1*x+@n1
      end
      def shadow_fy(x)
        return @m2*x+@n2
      end
    end
    class Block_WL < Block_Surface
      attr_reader :type
      def initialize(x1,y1,x2,y2)
        super(x1,y1,x2,y2)
        @type = 0x011
      end
      def visible?(sx,sy)
        return sx < @x1 && sy < @y2
      end
      def render_shadow(phx,phy,sx,sy,range,bitmap)
        @m1 = (@y1-sy)/(@x1-sx)
        @n1 = sy - @m1*sx
        @m2 = (@y2-sy)/(@x2-sx)
        @n2 = sy - @m2*sx
        
        i1 = (sx + range - @x1) / R_G
        for i in 0..i1
          x = R_G*i + @x1
          init = shadow_iy(x)
          bitmap.clear_rect(x-phx,init-phy,R_G,shadow_fy(x)-init+2)
        end
      end
      def shadow_iy(x)
        return @m1*x+@n1
      end
      def shadow_fy(x)
        return @m2*x+@n2
      end
    end
    class Block_WR < Block_Surface
      attr_reader :type
      def initialize(x1,y1,x2,y2)
        super(x1,y1,x2,y2)
        @type = 0x014
      end
      def visible?(sx,sy)
        return sx > @x1 && sy < @y2
      end
      def render_shadow(phx,phy,sx,sy,range,bitmap)
        @m1 = (@y1-sy)/(@x1-sx)
        @n1 = sy - @m1*sx
        @m2 = (@y2-sy)/(@x2-sx)
        @n2 = sy - @m2*sx
        
        i1 = ((sx-range).to_i - @x1) / R_G    
        for i in i1..0
          x = @x1 + R_G*i
          init = shadow_iy(x)
          bitmap.clear_rect(x-phx,init-phy,R_G,shadow_fy(x)-init+2)
        end
      end
      def shadow_iy(x)
        return @m1*x+@n1
      end
      def shadow_fy(x)
        return @m2*x+@n2
      end
    end
    class Block_SU < Block_Surface
      attr_reader :type
      def initialize(x1,y1,x2,y2)
        super(x1,y1,x2,y2)
        @type = 0x02
      end
      def visible?(sx,sy)
        return sy < @y1
      end
      def render_shadow(phx,phy,sx,sy,range,bitmap)
        if @x1 == sx
          @m1 = nil
        else
          @m1 = (@y1-sy)/(@x1-sx)
          @m1 += ACC if @m1 < -ACC
          @n1 = @y1 - @m1*@x1
        end
        if @x2 == sx
          @m2 = nil
        else
          @m2 = (@y2-sy)/(@x2-sx)
          @n2 = sy - @m2*sx
        end
        
        i1 = (sy + range - @y1) / R_G 
        for i in 0..i1
          y = R_G*i + @y1
          init = shadow_ix(y)
          bitmap.clear_rect(init-phx,y-phy,shadow_fx(y)-init+1,R_G)
        end
      end
      def shadow_ix(y)
        return @m1.nil? ? @x1 : (y-@n1)/@m1
      end
      def shadow_fx(y)
        return @m2.nil? ? @x2 : (y-@n2)/@m2
      end
    end
    class Block_SD < Block_Surface
      attr_reader :type
      def initialize(x1,y1,x2,y2)
        super(x1,y1,x2,y2)
        @type = 0x08
      end
      def visible?(sx,sy)
        return sy > @y1
      end
      def render_shadow(phx,phy,sx,sy,range,bitmap)
        if @x1 == sx
          @m1 = nil
        else
          @m1 = (@y1-sy)/(@x1-sx)
          @m1 -= ACC if @m1 > ACC
          @n1 = sy - @m1*sx
        end
        if x2 == sx
          @m2 = nil
        else
          @m2 = (@y2-sy)/(@x2-sx)
          @n2 = sy - @m2*sx
        end
        
        i1 = ((sy-range).to_i - @y1) / R_G
        for i in i1..0
          y = @y1 + R_G*i
          init = shadow_ix(y)
          bitmap.clear_rect(init-phx,y-phy,shadow_fx(y)-init+1,R_G)
        end
      end
      def shadow_ix(y)
        return @m1.nil? ? @x1 : (y-@n1)/@m1
      end
      def shadow_fx(y)
        return @m2.nil? ? @x2 : (y-@n2)/@m2
      end
    end
    class Spriteset_Map
      include Light_Core
      alias kbl_initialize initialize
      alias kbl_update update
      alias kbl_dispose dispose
      def initialize
        setup_lights
        kbl_initialize
      end
      def update
        kbl_update
        update_lights
      end
      def dispose
        kbl_dispose
        dispose_lights
      end
      def dispose_lights
        $game_map.lantern.dispose
        $game_map.light_sources.each { |source| source.dispose_light }
        $game_map.light_surface.bitmap.dispose
        $game_map.light_surface.dispose
        $game_map.light_surface = nil
      end
      def update_lights
        $game_map.light_surface.bitmap.clear
        $game_map.light_surface.bitmap.fill_rect(0,0,640,416,$game_map.effect_surface.color)
        $game_map.light_sources.each { |source| source.draw_light }
        return unless $game_map.lantern.visible
        @btr = $game_map.lantern.get_graphic
        x = $game_map.lantern.x
        y = $game_map.lantern.y
        r = $game_map.lantern.range
        sx = x + r
        sy = y + r
        dr = r*2
        $game_map.surfaces.each { |s| s.render_shadow(x,y,sx,sy,r,@btr) if s.visible?(sx,sy) && s.within?(x,x+dr,y,y+dr) }
        $game_map.light_surface.bitmap.blt($game_map.lantern.sx,$game_map.lantern.sy,@btr,Rect.new(0,0,dr,dr),$game_map.lantern.opacity)
      end
      def setup_lights
        @btr = nil
        $game_map.lantern.restore
        $game_map.light_sources.each { |source| source.restore_light }
        $game_map.light_surface = Sprite.new
        $game_map.light_surface.bitmap = Bitmap.new(640,416)
        $game_map.light_surface.bitmap.fill_rect(0,0,640,416,$game_map.effect_surface.color)
        $game_map.light_surface.blend_type = 2
        $game_map.light_surface.opacity = $game_map.effect_surface.alpha
        $game_map.light_surface.z = Surface_Z
      end
    end
    Shiva,
    PHP код:
    [CODE]скрипт[/CODE
    Последний раз редактировалось HopeBree; 20.04.2013 в 23:51.

  4. #14
    Бывалый Аватар для caveman
    Информация о пользователе
    Регистрация
    15.02.2013
    Сообщений
    715
    Записей в дневнике
    45
    Репутация: 79 Добавить или отнять репутацию

    По умолчанию

    заодно и под спойлер
    _d3.png

    HopeBree: Хитрый какой - это же писать надо. В общем, копипуешь параметр R_G и заменяешь все методы render_shadow в наследниках Block_Surface на те, что в XP. Так как для XP я буду еще мучать-оптимизировать, то вести параллельно и для VX изменения мне тяжело и лень. Может, под конец, когда закончу с XP - просто залью все изменения и выложу аналог для VX.
    Валера: модная вещь, вот сделаю еще главу от игры - и буду считать, что заслужил
    back to the primitive

    http://cavemangame.blogspot.ru/ - разные идеи и новости
    http://cavescripts.blogspot.ru/ - мои скрипты
    http://cavecrusader.blogspot.ru/ - текущий проект

  5. #15
    Бывалый Аватар для caveman
    Информация о пользователе
    Регистрация
    15.02.2013
    Сообщений
    715
    Записей в дневнике
    45
    Репутация: 79 Добавить или отнять репутацию

    По умолчанию

    ну вот, пока я обедал и писал ответ - ты уже сам все сделал!
    как по скорости стало? в VX просто изначально работает быстрее, чем под XP
    back to the primitive

    http://cavemangame.blogspot.ru/ - разные идеи и новости
    http://cavescripts.blogspot.ru/ - мои скрипты
    http://cavecrusader.blogspot.ru/ - текущий проект

  6. #16
    Маститый Аватар для HopeBree
    Информация о пользователе
    Регистрация
    28.03.2013
    Сообщений
    1,201
    Записей в дневнике
    6
    Репутация: 38 Добавить или отнять репутацию

    По умолчанию

    летает! спасибо за скрипт
    теперь буду тестить значения R_G, может найду оптимальный вариант по скорости и качеству

    UPD: R_G = 4 - летает, качество страдает, R_G = 3 - уже получше, тормозов нет, R_G = 2 - тормоза все же еще есть, но не такие дикие, R_G = 1 - "кризис 3, ты ли это?"

    UPD2: вот еще вопрос, тк в скриптинге я не силен, не подскажешь как можно реализовать фонарь для диагонального движения?
    Diagonal.png
    Последний раз редактировалось HopeBree; 19.04.2013 в 23:18.

  7. #17
    Бывалый Аватар для caveman
    Информация о пользователе
    Регистрация
    15.02.2013
    Сообщений
    715
    Записей в дневнике
    45
    Репутация: 79 Добавить или отнять репутацию

    По умолчанию

    смотря как у тебя движение построено
    если это и есть весь чарсет (перс только вот так двигается) - то все просто, как в примере Khas про фонарь, только картинки фонаря надо повернуть в пейнте или шопе.
    back to the primitive

    http://cavemangame.blogspot.ru/ - разные идеи и новости
    http://cavescripts.blogspot.ru/ - мои скрипты
    http://cavecrusader.blogspot.ru/ - текущий проект

  8. #18
    Маститый Аватар для HopeBree
    Информация о пользователе
    Регистрация
    28.03.2013
    Сообщений
    1,201
    Записей в дневнике
    6
    Репутация: 38 Добавить или отнять репутацию

    По умолчанию

    если было бы все так просто
    !$Alice1.png!$Alice1[diag].png
    вот 2 чарсета из моего проекта
    при движении по вертикали и горизонтали фонарик работает отлично
    при движении по диагонали, фонарик начинает светить как попало

  9. #19
    Бывалый Аватар для caveman
    Информация о пользователе
    Регистрация
    15.02.2013
    Сообщений
    715
    Записей в дневнике
    45
    Репутация: 79 Добавить или отнять репутацию

    По умолчанию

    уууу, тогда все тяжелее. С VX я дело не имел, тем более наверняка это скрипт 8dir. Руками помочь не могу, не до VX и этого мода сейчас, но подскажу.
    В скрипте есть класс

    class Light_DSource < Light_SSource

    в нем метод

    def set_multiple_graphics(ba)
    dispose
    @key = ba
    @key.values.each {|key| Light_Bitcore.push(key)}
    @bitmap = {2=>Light_Bitcore[@key[2]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,8=>Light_Bitcore[@key[8]].clone}


    цифры тут - стандартные положения спрайта (вниз, влево, вправо, вверх) в XP по крайней мере.
    Тебе надо узнать Direction для остальных 4х режимов в твоем моде (или VX, не в курсе) и закинуть еще 4 спрайта в хеш в этом методе. А так же, добавить картинки в вызове этого set_multiple_graphics

    Может где-то еще что-то добавить придется, но, как минимум, это надо

    Ах, да - то же самое в методе def restore
    back to the primitive

    http://cavemangame.blogspot.ru/ - разные идеи и новости
    http://cavescripts.blogspot.ru/ - мои скрипты
    http://cavecrusader.blogspot.ru/ - текущий проект

  10. #20
    Маститый Аватар для HopeBree
    Информация о пользователе
    Регистрация
    28.03.2013
    Сообщений
    1,201
    Записей в дневнике
    6
    Репутация: 38 Добавить или отнять репутацию

    По умолчанию

    так и думал, что где то в тут капать надо, посижу поразмышляю, мб и получится

    upd:
    Спойлер дописал:
    Код:
    def set_graphic(sb)
        dispose
        @key = {1=>sb,2=>sb,3=>sb,4=>sb,6=>sb,7=>sb,8=>sb,9=>sb}
        Light_Bitcore.push(sb)
        @bitmap = {1=>Light_Bitcore[@key[1]].clone,2=>Light_Bitcore[@key[2]].clone,3=>Light_Bitcore[@key[3]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,7=>Light_Bitcore[@key[7]].clone,8=>Light_Bitcore[@key[8]].clone,9=>Light_Bitcore[@key[9]].clone}
        @range = @bitmap[2].width/2
        @w = @bitmap[2].width
        @h = @bitmap[2].height
        @mr = @range - 16
      end
      def set_multiple_graphics(ba)
        dispose
        @key = ba
        @key.values.each {|key| Light_Bitcore.push(key)}
        @bitmap = {1=>Light_Bitcore[@key[1]].clone,2=>Light_Bitcore[@key[2]].clone,3=>Light_Bitcore[@key[3]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,7=>Light_Bitcore[@key[7]].clone,8=>Light_Bitcore[@key[8]].clone,9=>Light_Bitcore[@key[9]].clone}
        @range = @bitmap[2].width/2
        @w = @bitmap[2].width
        @h = @bitmap[2].height
        @mr = @range - 16
      end
      def get_graphic
        return @bitmap[@char.direction].clone
      end
      def show
        return if @bitmap.nil?
        @visible = true
      end
      def hide
        @visible = false
      end
      def restore
        return if @key.nil?
        @key.values.each {|key| Light_Bitcore.push(key)}
        @bitmap = {1=>Light_Bitcore[@key[1]].clone,2=>Light_Bitcore[@key[2]].clone,3=>Light_Bitcore[@key[3]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,7=>Light_Bitcore[@key[7]].clone,8=>Light_Bitcore[@key[8]].clone,9=>Light_Bitcore[@key[9]].clone}
      end

    в ивенте указал
    Код:
    h = 
    {1=>"1",2=>"2",3=>"3",4=>"4",
    6=>"6",7=>"7",8=>"8",9=>"9"}
    но в игре ни чего не изменилось

    и вот еще скрипт, который использовал для диагноального движения
    мб я что-то не то указал
    Спойлер Diagonal Movement:
    Код:
    #==============================================================================
    # ** Victor Engine - Diagonal Movement
    #------------------------------------------------------------------------------
    # Author : Victor Sant
    #
    # Version History:
    #  v 1.00 - 2011.12.23 > First release
    #  v 1.01 - 2011.12.30 > Fixed sync with vehicle
    #  v 1.02 - 2012.01.01 > New comment tags
    #  v 1.03 - 2012.01.04 > Compatibility with Character Control
    #  v 1.04 - 2012.01.04 > Compatibility with Follower Control
    #  v 1.05 - 2012.05.29 > Compatibility with Pixel Movement
    #  v 1.06 - 2012.07.25 > Fixed Compatibility with Visual Equip and
    #                      > Character Control
    #  v 1.07 - 2012.07.30 > Fixed diagonal movement speed
    #  v 1.08 - 2012.08.04 > Added option for fixing blocked movement
    #  v 1.09 - 2013.01.24 > Fixed issue with pixel movement and VE_DIAGONAL_FIX
    #------------------------------------------------------------------------------
    #  This script allows to set diagonal movement for the player and events.
    # This feature is opitional for events. It's possible to have different
    # graphic for the diagonal movement
    #------------------------------------------------------------------------------
    # Compatibility
    #   Requires the script 'Victor Engine - Basic Module' v 1.16 or higher
    #   If used with 'Victor Engine - Multi Frames' place this bellow it.
    #   If used with 'Victor Engine - Pixel Movement' place this bellow it.
    #   If used with 'Victor Engine - Visual Equip' place this bellow it.
    # 
    # * Alias methods (Default)
    #   class Game_CharacterBase
    #     def init_public_members
    #     def move_straight(d, turn_ok = true)
    #     def move_diagonal(horz, vert)
    #
    #   class Game_Character < Game_CharacterBase
    #     def move_random
    #     def move_toward_character(character)
    #     def move_away_from_character(character)
    #     def turn_toward_character(character)
    #     def turn_away_from_character(character)
    #     def move_forward
    #
    #   class Game_Event < Game_Character
    #     def clear_page_settings
    #     def setup_page_settings
    #
    #   class Game_Player < Game_Character
    #     def initialize
    #     def move_by_input
    #
    #   class Game_Vehicle < Game_Character
    #     def sync_with_player
    #
    #   class Sprite_Character < Sprite_Base
    #     def graphic_changed?
    #     def update_src_rect
    #
    # * Alias methods (Basic Module)
    #   class Game_Character < Game_CharacterBase
    #     def move_toward_position(x, y)
    #
    #   class Game_Interpreter
    #     def comment_call
    #
    #------------------------------------------------------------------------------
    # Instructions:
    #  To instal the script, open you script editor and paste this script on
    #  a new section bellow the Materials section. This script must also
    #  be bellow the scripts 'Victor Engine - Basic' and 
    #  'Victor Engine - Multi Frames'.
    #
    #------------------------------------------------------------------------------
    # Comment calls note tags:
    #  Tags to be used in events comment box, works like a script call.
    #
    #  <actor diagonal on> 
    #  <actor diagonal off>
    #   These tags allows to turn the diagonal on or off for the player.
    #
    #  <event i diagonal on> 
    #  <event i diagonal off>
    #   These tags allows to turn the diagonal on or off for events.
    #     i : event ID
    #
    #------------------------------------------------------------------------------
    # Comment boxes note tags:
    #   Tags to be used on events Comment boxes. They're different from the
    #   comment call, they're called always the even refresh.
    #
    #  <diagonal move>
    #    This tag allows the diagonal move for events if VE_DIAGONAL_EVENTS = false
    #    It enables the diagonal move only for the page where the comment
    #    is located
    #
    #  <block diagonal>
    #    This tag disable the diagonal move for events if VE_DIAGONAL_EVENTS = true
    #    It disable the diagonal move only for the page where the comment
    #    is located
    #
    #------------------------------------------------------------------------------
    # Additional instructions:
    #
    #  To add custom graphic for diagonal movement, you must have a graphic
    #  with the sufix set on VE_DIAGONAL_SUFIX added to it's name, by default
    #  this sufix is "[diag]", so you must have a file named "CharName[diag]"
    #  for a chaset named "CharName". If the diagonal file doesn't exist, it 
    #  will use the normal graphic.
    #
    #==============================================================================
    
    #==============================================================================
    # ** Victor Engine
    #------------------------------------------------------------------------------
    #   Setting module for the Victor Engine
    #==============================================================================
    
    module Victor_Engine
      #--------------------------------------------------------------------------
      # * Diagonal graphic sufix
      #    Sufix added to the names of diagonal movement graphics.
      #--------------------------------------------------------------------------
      VE_DIAGONAL_SUFIX = "[diag]"
      #--------------------------------------------------------------------------
      # * Set diagonal movement for events
      #    If true, automatically all events will have diagonal movement
      #    If false, you must add the diagonal movement manually by adding the
      #    comment tag for diagonal move on it.
      #--------------------------------------------------------------------------
      VE_DIAGONAL_EVENTS = true 
      #--------------------------------------------------------------------------
      # * Fix blocked diagonal movement
      #   If true, when the diagonal movement is blocked, then the character
      #   moves straight to the direction not blocked.
      #--------------------------------------------------------------------------
      VE_DIAGONAL_FIX = true
      #--------------------------------------------------------------------------
      # * required
      #   This method checks for the existance of the basic module and other
      #   VE scripts required for this script to work, don't edit this
      #--------------------------------------------------------------------------
      def self.required(name, req, version, type = nil)
        if !$imported[:ve_basic_module]
          msg = "The script '%s' requires the script\n"
          msg += "'VE - Basic Module' v%s or higher above it to work properly\n"
          msg += "Go to http://victorscripts.wordpress.com/ to download this script."
          msgbox(sprintf(msg, self.script_name(name), version))
          exit
        else
          self.required_script(name, req, version, type)
        end
      end
      #--------------------------------------------------------------------------
      # * script_name
      #   Get the script name base on the imported value, don't edit this
      #--------------------------------------------------------------------------
      def self.script_name(name, ext = "VE")
        name = name.to_s.gsub("_", " ").upcase.split
        name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
        name.join(" ")
      end
    end
    
    $imported ||= {}
    $imported[:ve_diagonal_move] = 1.09
    Victor_Engine.required(:ve_diagonal_move, :ve_basic_module, 1.16, :above)
    Victor_Engine.required(:ve_diagonal_move, :ve_character_control, 1.10, :bellow)
    
    #==============================================================================
    # ** Game_CharacterBase
    #------------------------------------------------------------------------------
    #  This class deals with characters. Common to all characters, stores basic
    # data, such as coordinates and graphics. It's used as a superclass of the
    # Game_Character class.
    #==============================================================================
    
    class Game_CharacterBase
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      attr_reader   :diagonal
      #--------------------------------------------------------------------------
      # * Alias method: init_public_members
      #--------------------------------------------------------------------------
      alias :init_public_members_ve_diagonal_move :init_public_members
      def init_public_members
        init_public_members_ve_diagonal_move
        @diagonal = 0
      end
      #--------------------------------------------------------------------------
      # * Alias method: move_straight
      #--------------------------------------------------------------------------
      alias :move_straight_ve_diagonal_move :move_straight
      def move_straight(d, turn_ok = true)
        @diagonal = 0
        move_straight_ve_diagonal_move(d, turn_ok)
      end
      #--------------------------------------------------------------------------
      # * Alias method: move_diagonal
      #--------------------------------------------------------------------------
      alias :move_diagonal_ve_diagonal_move :move_diagonal
      def move_diagonal(horz, vert)
        @diagonal = 1 if diagonal_enabled? && horz == 4 && vert == 2
        @diagonal = 3 if diagonal_enabled? && horz == 6 && vert == 2
        @diagonal = 7 if diagonal_enabled? && horz == 4 && vert == 8
        @diagonal = 9 if diagonal_enabled? && horz == 6 && vert == 8
        move_diagonal_ve_diagonal_move(horz, vert)
        diagonal_direction if diagonal_enabled?
      end
      #--------------------------------------------------------------------------
      # * Alias method: distance_per_frame
      #--------------------------------------------------------------------------
      alias :distance_per_frame_ve_diagonal_move :distance_per_frame
      def distance_per_frame
        distance = distance_per_frame_ve_diagonal_move
        diagonal? ? distance / Math.sqrt(2) : distance
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_enabled?
      #--------------------------------------------------------------------------
      def diagonal_enabled?
        @diagonal_enabled
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal?
      #--------------------------------------------------------------------------
      def diagonal?
        @diagonal && @diagonal != 0 
      end
    end
    
    #==============================================================================
    # ** Game_Character
    #------------------------------------------------------------------------------
    #  This class deals with characters. It's used as a superclass of the
    # Game_Player and Game_Event classes.
    #==============================================================================
    
    class Game_Character < Game_CharacterBase
      #--------------------------------------------------------------------------
      # * Alias method: move_random
      #--------------------------------------------------------------------------
      alias :move_random_ve_diagonal_move :move_random
      def move_random
        if diagonal_enabled? && rand(2) == 0
          horz = [4, 6].random
          vert = [2, 8].random
          move_diagonal(horz, vert)
        else
          move_random_ve_diagonal_move
        end
      end
      #--------------------------------------------------------------------------
      # * Alias method: move_toward_character
      #--------------------------------------------------------------------------
      alias :move_toward_character_ve_diagonal_move :move_toward_character
      def move_toward_character(character)
        sx = distance_x_from(character.x)
        sy = distance_y_from(character.y)
        horz = sx > 0 ? 4 : 6
        vert = sy > 0 ? 8 : 2
        if diagonal_enabled? && sx != 0 && sy != 0 && 
           diagonal_passable?(x, y, horz, vert)
          move_diagonal(horz, vert)
        else
          move_toward_character_ve_diagonal_move(character)
        end
      end
      #--------------------------------------------------------------------------
      # * New method: move_toward_position
      #--------------------------------------------------------------------------
      alias :move_toward_position_ve_diagonal_move :move_toward_position
      def move_toward_position(x, y)
        sx = distance_x_from(x)
        sy = distance_y_from(y)
        horz = sx > 0 ? 4 : 6
        vert = sy > 0 ? 8 : 2
        if diagonal_enabled? && sx != 0 && sy != 0 && 
           diagonal_passable?(x, y, horz, vert)
          move_diagonal(horz, vert)
        else
          move_toward_position_ve_diagonal_move(x, y)
        end
      end
      #--------------------------------------------------------------------------
      # * Alias method: move_away_from_character
      #--------------------------------------------------------------------------
      alias :move_away_from_character_ve_diagonal_move :move_away_from_character
      def move_away_from_character(character)
        sx = distance_x_from(character.x)
        sy = distance_y_from(character.y)
        horz = sx > 0 ? 6 : 4
        vert = sy > 0 ? 2 : 8
        if diagonal_enabled? && sx != 0 && sy != 0 && 
           diagonal_passable?(x, y, horz, vert)
          move_diagonal(horz, vert)
        else
          move_away_from_character_ve_diagonal_move(character)
        end
      end
      #--------------------------------------------------------------------------
      # * Alias method: turn_toward_character
      #--------------------------------------------------------------------------
      alias :turn_toward_character_ve_diagonal_move :turn_toward_character
      def turn_toward_character(character)
        sx = distance_x_from(character.x)
        sy = distance_y_from(character.y)
        if diagonal_enabled? && sx != 0 && sy != 0
          @diagonal = 1 if sx > 0 && sy < 0
          @diagonal = 3 if sx < 0 && sy < 0
          @diagonal = 7 if sx > 0 && sy > 0
          @diagonal = 9 if sx < 0 && sy > 0
          diagonal_direction
        else
          @diagonal = 0
          turn_toward_character_ve_diagonal_move(character)
        end
      end
      #--------------------------------------------------------------------------
      # * Alias method: turn_away_from_character
      #--------------------------------------------------------------------------
      alias :turn_away_from_character_ve_diagonal_move :turn_away_from_character
      def turn_away_from_character(character)
        sx = distance_x_from(character.x)
        sy = distance_y_from(character.y)
        if diagonal_enabled? && sx != 0 && sy != 0
          @diagonal = 1 if sx < 0 && sy > 0
          @diagonal = 3 if sx > 0 && sy > 0
          @diagonal = 7 if sx < 0 && sy < 0
          @diagonal = 9 if sx > 0 && sy < 0
          diagonal_direction
        else
          @diagonal = 0
          turn_away_from_character_ve_diagonal_move(character)
        end
      end
      #--------------------------------------------------------------------------
      # * Alias method: update_move_straight
      #--------------------------------------------------------------------------
      alias :update_move_straight_ve_diagonal_move :update_move_straight if $imported[:ve_pixel_movement]
      def update_move_straight
        update_move_straight_ve_diagonal_move
        diagonal_move_fix_pixel(@move_value[:d].first) if player? && @move_value
      end
      #--------------------------------------------------------------------------
      # * Alias method: update_move_diagonal
      #--------------------------------------------------------------------------
      alias :update_move_diagonal_ve_diagonal_move :update_move_diagonal if $imported[:ve_pixel_movement]
      def update_move_diagonal
        update_move_diagonal_ve_diagonal_move
        if player? && @move_value
          d = 1 if @move_value[:d] == [4, 2]
          d = 3 if @move_value[:d] == [6, 2]
          d = 7 if @move_value[:d] == [4, 8]
          d = 9 if @move_value[:d] == [6, 8]
          diagonal_move_fix_pixel(d)
        end
      end
      #--------------------------------------------------------------------------
      # * Alias method: move_forward
      #--------------------------------------------------------------------------
      alias :move_forward_ve_diagonal_move :move_forward
      def move_forward
        if diagonal?
          diagonal_movement(@diagonal)
          diagonal_move_fix(@diagonal) if need_fix?
        else
          move_forward_ve_diagonal_move
        end
      end
      #--------------------------------------------------------------------------
      # * New method: need_fix?
      #--------------------------------------------------------------------------
      def need_fix?
        (!moving? && !$imported[:ve_pixel_movement]) && VE_DIAGONAL_FIX
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_movement
      #--------------------------------------------------------------------------
      def diagonal_movement(d)
        case d
        when 1 then move_diagonal(4, 2)
        when 3 then move_diagonal(6, 2)
        when 7 then move_diagonal(4, 8)
        when 9 then move_diagonal(6, 8)
        end
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_move_fix
      #--------------------------------------------------------------------------
      def diagonal_move_fix(d)
        @diagonal = nil
        case d
        when 1 then move_straight(4);  move_straight(2) if !moving?
        when 3 then move_straight(6);  move_straight(2) if !moving?
        when 7 then move_straight(4);  move_straight(8) if !moving?
        when 9 then move_straight(6);  move_straight(8) if !moving?
        end
      end
      #--------------------------------------------------------------------------
      # * New method: set_diagonal_direction
      #--------------------------------------------------------------------------
      def diagonal_direction
        set_direction(2) if @diagonal == 1
        set_direction(4) if @diagonal == 7
        set_direction(6) if @diagonal == 3
        set_direction(8) if @diagonal == 9
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_move_fix
      #--------------------------------------------------------------------------
      def diagonal_move_fix_pixel(d)
        case d
        when 1 then perform_move_fix_pixel(4, 2)
        when 3 then perform_move_fix_pixel(6, 2)
        when 7 then perform_move_fix_pixel(4, 8)
        when 9 then perform_move_fix_pixel(6, 8)
        end
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_move_fix
      #--------------------------------------------------------------------------
      def perform_move_fix_pixel(horz, vert)
        return if @moved || moving?
        @move_value = nil
        @diagonal   = nil
        set_direction(horz)       if passable?(@x, @y, horz) && !@moved
        move_straight_pixel(horz) if passable?(@x, @y, horz) && !@moved
        set_direction(vert)       if passable?(@x, @y, vert) && !@moved
        move_straight_pixel(vert) if passable?(@x, @y, vert) && !@moved
      end
    end
    
    #==============================================================================
    # ** Game_Event
    #------------------------------------------------------------------------------
    #  This class deals with events. It handles functions including event page 
    # switching via condition determinants, and running parallel process events.
    # It's used within the Game_Map class.
    #==============================================================================
    
    class Game_Event < Game_Character
      #--------------------------------------------------------------------------
      # * Alias method: clear_page_settings
      #--------------------------------------------------------------------------
      alias :clear_page_settings_ve_diagonal_move :clear_page_settings
      def clear_page_settings
        clear_page_settings_ve_diagonal_move
        @diagonal_enabled = false
      end
      #--------------------------------------------------------------------------
      # * Alias method: setup_page_settings
      #--------------------------------------------------------------------------
      alias :setup_page_settings_ve_diagonal_move :setup_page_settings
      def setup_page_settings
        setup_page_settings_ve_diagonal_move
        @diagonal_enabled =  VE_DIAGONAL_EVENTS || note =~ /<DIAGONAL MOVE>/i
        @diagonal_enabled =  false if note =~ /<BLOCK DIAGONAL>/i
      end
    end
    
    #==============================================================================
    # ** Game_Player
    #------------------------------------------------------------------------------
    #  This class handles maps. It includes event starting determinants and map
    # scrolling functions. The instance of this class is referenced by $game_map.
    #==============================================================================
    
    class Game_Player < Game_Character
      #--------------------------------------------------------------------------
      # * Alias method: initialize
      #--------------------------------------------------------------------------
      alias :initialize_ve_diagonal_move :initialize
      def initialize
        initialize_ve_diagonal_move
        diagonal_on
      end
      #--------------------------------------------------------------------------
      # * Alias method: move_by_input
      #--------------------------------------------------------------------------
      alias :move_by_input_ve_diagonal_move :move_by_input
      def move_by_input
        return if !movable? || $game_map.interpreter.running?
        if diagonal_enabled? && Input.dir8 > 0 && Input.dir8 % 2 != 0
          diagonal_movement(Input.dir8) 
          diagonal_move_fix(Input.dir8) if need_fix?
        else
          move_by_input_ve_diagonal_move
        end
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_on
      #--------------------------------------------------------------------------
      def diagonal_on
        @diagonal_enabled = true
        @followers.diagonal_on
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_off
      #--------------------------------------------------------------------------
      def diagonal_off
        @diagonal_enabled = false
        @followers.diagonal_off
      end
    end
    
    #==============================================================================
    # ** Game_Follower
    #------------------------------------------------------------------------------
    #  This class handles the followers. Followers are the actors of the party
    # that follows the leader in a line. It's used within the Game_Followers class.
    #==============================================================================
    
    class Game_Follower < Game_Character
      #--------------------------------------------------------------------------
      # * Alias method: distance_per_frame
      #--------------------------------------------------------------------------
      alias :distance_per_frame_ve_diagonal_move :distance_per_frame
      def distance_per_frame
        distance = 2 ** real_move_speed / 256.0
        $game_player.diagonal? ? distance / Math.sqrt(2) : distance
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_on
      #--------------------------------------------------------------------------
      def diagonal_on
        @diagonal_enabled = true
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_off
      #--------------------------------------------------------------------------
      def diagonal_off
        @diagonal_enabled = false
      end
    end
    
    #==============================================================================
    # ** Game_Followers
    #------------------------------------------------------------------------------
    #  This class handles the followers. It's a wrapper for the built-in class
    # "Array." It's used within the Game_Player class.
    #==============================================================================
    
    class Game_Followers
      #--------------------------------------------------------------------------
      # * New method: diagonal_on
      #--------------------------------------------------------------------------
      def diagonal_on
        each {|follower| follower.diagonal_on }
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_off
      #--------------------------------------------------------------------------
      def diagonal_off
        each {|follower| follower.diagonal_off }
      end
    end
    
    #==============================================================================
    # ** Game_Vehicle
    #------------------------------------------------------------------------------
    #  Esta classe gerencia veículos. Se não houver veículos no mapa atual, a
    # coordenada é definida como (-1,-1).
    # Esta classe é usada internamente pela classe Game_Map. 
    #==============================================================================
    
    class Game_Vehicle < Game_Character
      #--------------------------------------------------------------------------
      # * Alias method: sync_with_player
      #--------------------------------------------------------------------------
      alias :sync_with_player_ve_diagonal_move :sync_with_player
      def sync_with_player
        sync_with_player_ve_diagonal_move
        @diagonal = $game_player.diagonal
        diagonal_direction
      end
    end
    
    #==============================================================================
    # ** Sprite_Character
    #------------------------------------------------------------------------------
    #  This sprite is used to display characters. It observes a instance of the
    # Game_Character class and automatically changes sprite conditions.
    #==============================================================================
    
    class Sprite_Character < Sprite_Base
      #--------------------------------------------------------------------------
      # * Alias method: graphic_changed?
      #--------------------------------------------------------------------------
      alias :graphic_changed_ve_diagonal_move :graphic_changed?
      def graphic_changed?
        graphic_changed_ve_diagonal_move ||
        @diagonal != @character.diagonal
      end
      #--------------------------------------------------------------------------
      # * New method: update_character_info
      #--------------------------------------------------------------------------
      alias :update_character_info_ve_diagonal_move :update_character_info
      def update_character_info
        update_character_info_ve_diagonal_move
        @diagonal = @character.diagonal
      end
      #--------------------------------------------------------------------------
      # * Alias method: update_src_rect
      #--------------------------------------------------------------------------
      alias :update_src_rect_ve_diagonal_move :update_src_rect
      def update_src_rect
        if @tile_id == 0 && @character.diagonal?
          update_diagonal_src_rect
        else
          update_src_rect_ve_diagonal_move
        end
      end
      #--------------------------------------------------------------------------
      # * Overwrite method: set_character_diagonal_bitmap
      #--------------------------------------------------------------------------
      alias :set_bitmap_name_ve_diagonal_move :set_bitmap_name
      def set_bitmap_name
        name = @character_name + ($imported[:ve_visual_equip] ? "" : diagonal_sufix)
        character_exist?(name) ? name : set_bitmap_name_ve_diagonal_move
      end
      #--------------------------------------------------------------------------
      # * New method: diagonal_sufix
      #--------------------------------------------------------------------------
      def diagonal_sufix
        @character.diagonal? ? VE_DIAGONAL_SUFIX : ""
      end
      #--------------------------------------------------------------------------
      # * New method: update_diagonal_src_rect
      #--------------------------------------------------------------------------
      def update_diagonal_src_rect
        dir = 0 if @diagonal == 1
        dir = 1 if @diagonal == 7
        dir = 2 if @diagonal == 3
        dir = 3 if @diagonal == 9
        index = @character.character_index
        if $imported[:ve_multi_frames] && @character_name[/\[F(\d+)\]/i]
          pattern = @character.pattern
        else
          pattern = @character.pattern < 3 ? @character.pattern : 1
        end
        sx = (index % 4 * @character.frames + pattern) * @cw
        sy = (index / 4 * 4 + dir) * @ch
        self.src_rect.set(sx, sy, @cw, @ch)
      end
    end
    
    #==============================================================================
    # ** Game_Interpreter
    #------------------------------------------------------------------------------
    #  An interpreter for executing event commands. This class is used within the
    # Game_Map, Game_Troop, and Game_Event classes.
    #==============================================================================
    
    class Game_Interpreter
      #--------------------------------------------------------------------------
      # * Alias method: comment_call
      #--------------------------------------------------------------------------
      alias :comment_call_ve_diagonal_move :comment_call
      def comment_call
        call_change_actor_diagonal
        call_change_event_diagonal
        comment_call_ve_diagonal_move
      end  
      #--------------------------------------------------------------------------
      # * New method: call_change_actor_diagonal
      #--------------------------------------------------------------------------
      def call_change_actor_diagonal
        if note =~ /<ACTOR DIAGONAL (ON|OFF)>/i
          $game_player.diagonal_off if $1.upcase == "OFF"
          $game_player.diagonal_on  if $1.upcase == "ON"
        end
      end 
      #--------------------------------------------------------------------------
      # * New method: call_change_event_diagonal
      #--------------------------------------------------------------------------
      def call_change_event_diagonal
        if note =~ /<EVENT (\d+) DIAGONAL (ON|OFF)>/i
          $game_map.events[$1.to_i].diagonal_off if $2.upcase == "OFF"
          $game_map.events[$1.to_i].diagonal_on  if $2.upcase == "ON"
        end
      end
    end
    Последний раз редактировалось HopeBree; 21.04.2013 в 01:50.

Страница 2 из 3 ПерваяПервая 123 ПоследняяПоследняя

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)

Метки этой темы

Социальные закладки

Социальные закладки

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •