Help - Search - Members - Calendar
Full Version: Help With X, Y Positions
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS2
paulojr_mam
I need help to find in this script:
Clicky
CODE
==============================================================================
# MOG VX - Chain System V1.1
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com/
#==============================================================================
# Sistema de chain que permite executar várias ações no mesmo turno.
#==============================================================================
# NOTA
# - Velocidade do medidor aumenta cada vez que você obtém sucesso.
#   Isso serve para o jogador não se acostumar com o timming.
#==============================================================================
# Serão necessários ter os seguintes arquivos.
#
# Chain_Layout.png
# Chain_Meter.png
# Chain_Text.png
#
# Grave-os na pasta GRAPHICS/SYSTEM
#==============================================================================
# Histórico
# 1.1 Remoção do limite de tempo baseado na quantidade de frames da animação.
#==============================================================================
module MOG
  #Definição ID dos personagens que terão o chain de ataque ativado.
  CHAIN_ACTOR_ATTACK = []
  #Definição ID das habilidades que terão o chain ativado.  
  CHAIN_SKILL_ID = [237]
  #Definição ID dos itens que terão o chain ativado.  
  CHAIN_ITEM_ID = []
  #Área de sucesso. Configure-o baseado na imagem do medidor que você criar.
  CHAIN_SUCCESS_RANGE = [42,58]  
  #Velocidade do medidor.
  CHAIN_BASE_SPEED = 23
  #Adição extra na velocidade do medidor cada vez que você tiver sucesso.
  CHAIN_EXTRA_SPEED = 4
  #Velocidade especifica baseado no personagem.  
  CHAIN_ACTOR_SPEED = {2=> 10 }
  #Deixe true caso seu Battle System não mostrar o sprite de seu personagem.
  #Essa opção desativa ações de chain direcionadas no grupo dos heróis,
  #uma vez que a posição do chain é baseado na posição do sprite do alvo.
  CHAIN_NO_ACTOR_SPRITE_BATTLE_SYSTEM = false
  #Posição do Layout.
  CHAIN_LAYOUT_POSITION = [407,102]
  #Posição do medidor.
  CHAIN_METER_POSITION = [415,120]
  #Posição do texto.
  CHAIN_TEXT_POSITION = [387,110]
  #Som ao atingir o sucesso.
  CHAIN_SUCCESS_SE = RPG::SE.new("Chime1", 100, 150)
  #Som caso falhar.
  CHAIN_FAIL_SE = RPG::SE.new("Ice2", 100, 100)
end  
#===============================================================================
# ● Chain_Sprite
#===============================================================================
class Chain_Sprite < Sprite
  attr_accessor :gauge
  attr_accessor :active
  attr_accessor :press_phase
  attr_accessor :fade
  include MOG  
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
  def initialize
     super
     @gauge = 0
     @active = false
     @press_phase = false
     @speed = CHAIN_BASE_SPEED
     @maxgauge = 1000
     @gauge_limit_a = CHAIN_SUCCESS_RANGE[0] * 10
     @gauge_limit_b = CHAIN_SUCCESS_RANGE[1] * 10
     @time_limit = false
     @fade = false
     create_layout
     create_chain_meter
     create_chain_text
  end
#--------------------------------------------------------------------------
# ● Create Layout
#--------------------------------------------------------------------------  
  def create_layout
     @layout = Sprite.new
     @layout.bitmap = Cache.system("Chain_Layout")
     @layout.z = 201
     @layout_width = @layout.bitmap.width
     @layout_width2 = @layout_width / 2
     @layout_height = @layout.bitmap.height / 2
     @layout_pre_x = -@layout_width2 + CHAIN_LAYOUT_POSITION[0]
     @layout_pre_y = -@layout_height + CHAIN_LAYOUT_POSITION[1]
     @layout.x = @layout_pre_x
     @layout.y = @layout_pre_y
  end  
#--------------------------------------------------------------------------
# ● Create Layout
#--------------------------------------------------------------------------  
  def create_chain_text
     @text_time = 0
     @text_image = Cache.system("Chain_Text")
     @text_bitmap = Bitmap.new(@text_image.width,@text_image.height)
     @text_width = @text_image.width
     @text_height = @text_image.height / 3
     @text_src_rect = Rect.new(0, 0, @text_width, @text_height)
     @text_bitmap.blt(0,0, @text_image, @text_src_rect)
     @text_sprite = Sprite.new
     @text_sprite.bitmap = @text_bitmap
     @text_sprite.opacity = 0
     @text_sprite.z = 202
     @text_sprite_pre_x = -@layout_width2 + CHAIN_TEXT_POSITION[0]
     @text_sprite_pre_y = CHAIN_TEXT_POSITION[1]
     @text_sprite.x = @text_sprite_pre_x
     @text_sprite.y = @text_sprite_pre_y
  end        
#--------------------------------------------------------------------------
# ● Create Chain Meter
#--------------------------------------------------------------------------  
  def create_chain_meter
     @chain_flow = 0
     @chain_image = Cache.system("Chain_Meter")
     @chain_bitmap = Bitmap.new(@chain_image.width,@chain_image.height)
     @chain_width = @chain_image.width
     @chain_height = @chain_image.height * @gauge / @maxgauge
     @chain_src_rect = Rect.new(0, @chain_height, @chain_width, @chain_height)
     @chain_bitmap.blt(0,0, @chain_image, @chain_src_rect)
     @chain_sprite = Sprite.new
     @chain_sprite.bitmap = @chain_bitmap
     @chain_sprite_pre_x = -@layout_width2 + CHAIN_METER_POSITION[0]
     @chain_sprite_pre_y = -@layout_height + CHAIN_METER_POSITION[1]
     @chain_sprite.x = @chain_sprite_pre_x
     @chain_sprite.y = @chain_sprite_pre_y
     @chain_sprite.z = 200
     update_flow_chain_meter      
  end    
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------  
   def dispose
      @layout.bitmap.dispose
      @layout.dispose    
      @chain_sprite.bitmap.dispose
      @chain_sprite.dispose
      @chain_bitmap.dispose
      @text_sprite.bitmap.dispose
      @text_sprite.dispose
      @text_bitmap.dispose      
      super
   end  
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------      
  def update
      super
      update_visible
      update_flow_chain_meter
      check_chain_active if @press_phase == true
  end
#--------------------------------------------------------------------------
# ● update_text
#--------------------------------------------------------------------------    
  def refresh_text
     @text_sprite.bitmap.clear
     @text_sprite.opacity = 255    
     if @time_limit == true
        h = @text_height * 2
     elsif @active == true
        h = 0
     else
        h = @text_height
     end  
     @text_src_rect = Rect.new(0, h, @text_width, @text_height)
     @text_bitmap.blt(0,0, @text_image, @text_src_rect)        
  end  
#--------------------------------------------------------------------------
# ● update_visible
#--------------------------------------------------------------------------              
  def update_visible
    if @fade == false
       @text_sprite.x += 1
       @text_sprite.opacity -= 1
        if @press_phase == false
           @chain_sprite.opacity -= 6
           @layout.opacity -= 6
           @text_sprite.opacity -= 6
        end  
     else
        if @layout.opacity > 0    
           @chain_sprite.opacity -= 4
           @text_sprite.opacity -= 4
           @layout.opacity -= 4
           @chain_sprite.x += 1
           @text_sprite.x += 1
           @layout.x += 1
        end  
     end
  end  
#--------------------------------------------------------------------------
# ● reset
#--------------------------------------------------------------------------        
  def reset
      @active = false
      @press_phase = false
      refresh_text
      @speed = CHAIN_BASE_SPEED
      @time_limit = true
      refresh_text
  end  
#--------------------------------------------------------------------------
# ● check_chain_active  
#--------------------------------------------------------------------------          
  def check_chain_active
     @press_phase = false if @gauge >= @maxgauge
     if Input::trigger?(Input::C)
       case @gauge
          when @gauge_limit_a..@gauge_limit_b
            @active = true
            CHAIN_SUCCESS_SE.play
            @speed += CHAIN_EXTRA_SPEED
          else
            @active = false
            CHAIN_FAIL_SE.play
            @speed = CHAIN_BASE_SPEED
        end
       @time_limit = false
       @press_phase = false
       refresh_text
    end
  end      
#--------------------------------------------------------------------------
# ● Update Flow Chain Meter
#--------------------------------------------------------------------------          
  def update_flow_chain_meter    
      return if @press_phase == false
      @gauge += @speed + @e_s if @gauge < @maxgauge
      @gauge = @gauge_limit_b if @gauge > @gauge_limit_b and @active == true  
      reset if @gauge >= @maxgauge
      @chain_sprite.bitmap.clear
      @chain_height = @chain_image.height * @gauge / @maxgauge
      @chain_src_rect = Rect.new(0, 0 ,@chain_width, @chain_height)
      @chain_bitmap.blt(0,0, @chain_image, @chain_src_rect)        
  end  
#--------------------------------------------------------------------------
# ● flow_clear        
#--------------------------------------------------------------------------              
   def flow_clear(a_id)        
       @gauge = 0
       @active = false
       @text_time = 120
       @time_limit = false
       actor = $data_actors[a_id]
       e_speed = CHAIN_ACTOR_SPEED[actor.id]
       @e_s = e_speed
       @e_s = 0 if e_speed == nil
       update_flow_chain_meter  
       @chain_sprite.opacity = 255    
       @layout.opacity = 255
     end    
#--------------------------------------------------------------------------
# ● check_position(sx,sy)      
#--------------------------------------------------------------------------              
  def check_position(sx,sy)  
      nx = [[sx, 0].max,-@layout_width + 544].min
      ny = [[sy, @layout_height].max, 416].min    
      @chain_sprite.x = @chain_sprite_pre_x + nx
      @chain_sprite.y = @chain_sprite_pre_y + ny
      @layout.x = @layout_pre_x + nx
      @layout.y = @layout_pre_y + ny
      @text_sprite.x = @text_sprite_pre_x + nx - 30
      @text_sprite.y = @text_sprite_pre_y + ny      
  end  
end  

#===============================================================================
# Scene_Battle
#===============================================================================
class Scene_Battle < Scene_Base
  include MOG
  #--------------------------------------------------------------------------
  # ● start
  #--------------------------------------------------------------------------
  alias mog_chain_start start
  def start
      create_chain_sprite
      mog_chain_start
  end  
  #--------------------------------------------------------------------------
  # ● create_chain_sprite
  #--------------------------------------------------------------------------
  def create_chain_sprite
      @chain = Chain_Sprite.new
  end
  #--------------------------------------------------------------------------
  # ● dispose_info_viewport
  #--------------------------------------------------------------------------  
  alias mog_chain_dispose_info_viewport dispose_info_viewport  
  def dispose_info_viewport
     mog_chain_dispose_info_viewport
     @chain.dispose
  end    
  #--------------------------------------------------------------------------
  # ● update_basic
  #--------------------------------------------------------------------------
  alias mog_chain_update_basic update_basic
  def update_basic(main = false)
    mog_chain_update_basic(main)
    @chain.update
  end      
  #--------------------------------------------------------------------------
  # ● execute_action_attack
  #--------------------------------------------------------------------------
  alias mog_chain_execute_action_attack execute_action_attack
  def execute_action_attack
      active_chain(0)            
      mog_chain_execute_action_attack
      check_chain(0)
  end
  #--------------------------------------------------------------------------
  # ● execute_action_skill
  #--------------------------------------------------------------------------
  alias mog_chain_execute_action_skill execute_action_skill
  def execute_action_skill
      active_chain(1)
      mog_chain_execute_action_skill
      check_chain(1)
  end
  #--------------------------------------------------------------------------
  # ● execute_action_item
  #--------------------------------------------------------------------------
  alias mog_chain_execute_action_item execute_action_item
  def execute_action_item
      active_chain(2)  
      mog_chain_execute_action_item
      check_chain(2)
  end      
  #--------------------------------------------------------------------------
  # ● clear_chain
  #--------------------------------------------------------------------------
  def active_chain(type)
      return if @active_battler.is_a?(Game_Enemy)
      case type
          when 0
            actor = @active_battler
            enable = CHAIN_ACTOR_ATTACK.include?(actor.id)
          when 1
            skill = @active_battler.action.skill
            enable = CHAIN_SKILL_ID.include?(skill.id)
          when 2
            item = @active_battler.action.item
            enable = CHAIN_SKILL_ID.include?(item.id)
          end
      return if enable == false    
      targets = @active_battler.action.make_targets
      for target in targets    
          return if target.is_a?(Game_Actor) and CHAIN_NO_ACTOR_SPRITE_BATTLE_SYSTEM == true
          sx = target.screen_x
          sy = target.screen_y
          @chain.check_position(sx,sy)  
      end  
      a_id = @active_battler.id
      @chain.press_phase = true
      @chain.flow_clear(a_id)
       for i in 0...180
           break if @chain.active == false
           update_basic    
       end      
  end
  #--------------------------------------------------------------------------
  # ● check_chain
  #--------------------------------------------------------------------------  
  def check_chain(type)
      return if @active_battler.is_a?(Game_Enemy) or @chain.active == false
      targets = @active_battler.action.make_targets
      for target in targets
        if target.hp > 0  
          case type
             when 0
               execute_action_attack
             when 1
               skill_mp = @active_battler.calc_mp_cost(@active_battler.action.skill)
               execute_action_skill unless skill_mp > @active_battler.mp
             when 2
               item = @active_battler.action.item
               execute_action_item unless $game_party.item_number(item) == 0
           end    
         end  
      end
      @chain.press_phase = false  
  end
  #--------------------------------------------------------------------------
  # ● process_victory  
  #--------------------------------------------------------------------------
  alias mog_chain_process_victory   process_victory  
  def process_victory  
      @chain.fade = true
      mog_chain_process_victory      
  end  
end  

$mog_rgssvx_chain_system = true


Where are defined the X,Y coordinates for the CHAIN_SUCCESS_RANGE???
I already have arranged other coordinates, but this, that is extremely important, I can't find where it's set.
Kread-EX
CODE
CHAIN_SUCCESS_RANGE = [42,58]

In the config module.
paulojr_mam
I'm not sure. It seems it is the size of it, not the position. You're sure it is the position?
Kread-EX
The first number is the gauge starting position divided by 10 and the second number the end position divided by 10 too. It's entirely possible that I misunderstood what you want mind you.
paulojr_mam
Fine, I realized it already (others told me). It's automatically made what I want. I think this system just don't works with ATBs.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.