O TEMA DO FÓRUM ESTÁ EM MANUTENÇÃO. FEEDBACKS AQUI: ACESSAR

Registrar Skill e uso da mesma? [Rpg Maker VX Ace]

Iniciado por taisho, 20/11/2016 às 14:47

Estou com essa ABS que fiz seguindo as aulas do Khas, mas tentei de varias formas e não consegui usar skill nessa ABS (Exemplo: Vai no menu aperta o botão S ai aparece que a skill foi registrada depois quando vc apertar o S no mapa sua char vai soltar o skill mesmo que vc tenha que esta do lado do inimigo) se alguem souber de um tuto ou saber como implementar e poder ajudar eu agradeço olha varios script que tem essa função e um que chegou mais perto do que pensei era para o VX e não consegui implementar no VX Ace.

Spoiler
module ABS_Config
  Default_Animation = 1
  Animation_Reduce = 3
  Enable_Weapon_Graphics = true
  Opacity_Burn = 10
  Enemy_Recover = 60
  Attack_Key = :X
  Player_Recover = 40
 
end

class Game_Map
  attr_accessor :enemies 
  attr_accessor :damege_sprites
  alias abs_setup setup
  def setup(map_id)
    @enemies.nil? ? @enemies = [] : @enemies.clear
    abs_setup(map_id)
  end
end

class ABS_Enemy
  include ABS_Config
  attr_accessor :hp
  attr_accessor :attack
  attr_accessor :defense 
  attr_reader :name
  attr_reader :animation
  attr_accessor :exp
  def initialize(id)
    @enemy = Game_Enemy.new(0,id)
    @name =   @enemy.name
    note = @enemy.enemy.note
    if note.include?("Animation=")
      aid = note.sub("Animation=","")
      @animation = aid.to_i
    else
      @animation = Default_Animation
    end
    @hp = @enemy.mhp
    @attack = @enemy.atk
    @defense = @enemy.def
    @exp = @enemy.exp
  end
end

class Game_Event < Game_Character 
  attr_reader :enemy
  alias abs_setup_page_settings setup_page_settings
  alias abs_initialize initialize
  alias abs_update update
  alias abs_start start
  def initialize(map_id, event)
    @enemy = nil
    @recover = 0
    abs_initialize(map_id, event)   
  end
  def setup_page_settings   
    abs_setup_page_settings
    check_enemy
  end
  def check_enemy
    unless @enemy.nil?
      @enemy = nil
      $game_map.enemies.delete(self) if $game_map.enemies.include?(self)
    end
    return if @list.nil?
    for command in @list
      next unless command.code == 108 or command.code == 408
      if command.parameters[0].include?("cmd:enemy=")
        id = command.parameters[0].sub("cmd:enemy=","")
        @enemy = ABS_Enemy.new(id.to_i)
        @trigger = 2
        $game_map.enemies.push(self)
      end
    end
  end
  def damege_enemy(value)
    jump(0,0)
    value -= @enemy.defense
    value = 0 if value < 0
    $game_map.damege_sprites.push(Damege_Sprite.new(self,value))
    @enemy.hp -= value
    if @enemy.hp <= 0
      $game_map.enemies.delete(self)
      RPG::SE.new("Collapse1",80).play
    end
  end
  def update
    if @enemy != nil
      @recover -= 1 if @recover > 0
    update_kill if @enemy.hp <= 0
    end
    abs_update
  end
  def update_kill
    if @opacity > 0
      @opacity -= ABS_Config::Opacity_Burn
    else
      actor = $game_party.members[0]
      actor.change_exp(actor.exp + @enemy.exp,true,)
      actor1 = $game_party.members[1]
      actor1.change_exp(actor1.exp + @enemy.exp,true,)     
      actor2 = $game_party.members[2]
      actor2.change_exp(actor2.exp + @enemy.exp,true,)     
      actor3 = $game_party.members[3]
      actor3.change_exp(actor3.exp + @enemy.exp,true,)     
      @character_name = ""
      @opacity = 255
      @priority_type = 0
      @trigger = 0 
      @enemy = nil
    end
  end
  def start
    @enemy.nil? ? abs_start : attack
  end
  def attack
    return if @enemy.hp <= 0 or @recover > 0
    @recover = ABS_Config::Enemy_Recover
    $game_player.animation_id = @enemy.animation
    $game_player.damege_hero(@enemy.attack)
  end
end

class Game_Player < Game_Character
  attr_reader :animation
  alias abs_initialize initialize
  alias abs_update update
  def initialize   
    @recover = 0
    abs_initialize
    @kill_player = false   
  end
  def update
    @recover -= 1 if @recover > 0
    update_attack if @recover == 0 and Input.trigger?(ABS_Config::Attack_Key) and SceneManager.scene.spriteset.weapon_animation if ABS_Config::Enable_Weapon_Graphics
    update_kill if @kill_player
    abs_update
  end
  def update_attack
    return if @kill_player
    for enemy in $game_map.enemies
      ax = @x - enemy.x
      ay = @y - enemy.y
      case @direction
      when 2 #pra baixo
        attack_enemy(enemy) if ax == 0 and ay == -1     
      when 4 #pra esquerda
        attack_enemy(enemy) if ay == 0 and ax == 1         
      when 6 #pra direita
        attack_enemy(enemy) if ay == 0 and ax == -1   
      when 8 #pra cima
        attack_enemy(enemy) if ax == 0 and ay == 1
      end
    end
  end 
  def attack_enemy(event)
    hero = $game_party.members[0]
    event.damege_enemy(hero.atk)
    event.animation_id = hero.weapons[0].animation_id   
    @recover = ABS_Config::Player_Recover
  end
  def damege_hero(value)
    jump(0,0)
    return if @kill_player
    hero = $game_party.members[0]
    value -= hero.def
    value = 0 if value < 0
    $game_map.damege_sprites.push(Damege_Sprite.new(self,value))
    if value > hero.hp
      hero.hp = 1
      @kill_player = true
      RPG::SE.new("Collapse1",80).play     
    else
      hero.hp -= value     
    end
  end 
  def update_kill
    if @opacity > 0
      @opacity -= ABS_Config::Opacity_Burn
    else
      SceneManager.goto(Scene_Gameover)
    end     
  end
end

class Scene_Map < Scene_Base
  attr_accessor :spriteset
end

class Sprite_Base
  Reduce = 3
  def animation_set_sprites(frame)
    cell_data = frame.cell_data
    @ani_sprites.each_with_index do |sprite, i|
      next unless sprite
      pattern = cell_data[i, 0]
      if !pattern || pattern < 0
        sprite.visible = false
        next
      end
      sprite.bitmap = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2
      sprite.visible = true
      sprite.src_rect.set(pattern % 5 * 192,
        pattern % 100 / 5 * 192, 192, 192)
      if @ani_mirror
        sprite.x = @ani_ox - cell_data[i, 1] / Reduce
        sprite.y = @ani_oy + cell_data[i, 2] / Reduce
        sprite.angle = (360 - cell_data[i, 4])
        sprite.mirror = (cell_data[i, 5] == 0)
      else
        sprite.x = @ani_ox + cell_data[i, 1] / Reduce
        sprite.y = @ani_oy + cell_data[i, 2] / Reduce
        sprite.angle = cell_data[i, 4]
        sprite.mirror = (cell_data[i, 5] == 1)
      end
      sprite.z = self.z + 300 + i
      sprite.ox = 96
      sprite.oy = 96
      sprite.zoom_x = cell_data[i, 3] / (100.0 * Reduce)
      sprite.zoom_y = cell_data[i, 3] / (100.0 * Reduce)
      sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
      sprite.blend_type = cell_data[i, 7]
    end
  end
end

class Spriteset_Map
  alias abs_initialize initialize
  alias abs_update update
  alias abs_dispose dispose   
  def initialize
    $game_map.damege_sprites = []
    abs_initialize
    index = ($game_party.members[0].weapons[0].icon_index rescue nil)
    @weapon_graphic = Sprite.new(@viewport1)
    @weapon_graphic.ox = 22
    @weapon_graphic.oy = 22
    @attacking = false
    @attack_timer = 0
    @angles = {2=>[80,110,140,170],4=>[340,10,40,70],6=>[290,260,230,200],8=>[290,320,350,20]}
    @correction = {2=>[-8,-10],4=>[0,-10],6=>[0,-4],8=>[4,-10]}
    @z_values = {2=>120,4=>50,6=>120,8=>50}
    if index == nil
      @weapon_bitmap = nil
    else
      temp = Cache.system("Iconset")
      @weapon_bitmap = Bitmap.new(24,24)
      @weapon_bitmap.blt(0,0,temp,Rect.new(index%16*24,index/16*24,24,24))
      temp.dispose
      temp = nil
    end   
  end
  def update
    abs_update
    update_weapon_graphic if @attacking
    trash = []
    for sprite in $game_map.damege_sprites
      sprite.update
      trash.push(sprite) if sprite.disposed?
    end
    for item in trash
      $game_map.damege_sprites.delete(item)
    end
    trash.clear
  end
  def dispose
    abs_dispose 
    for sprite in $game_map.damege_sprites
      sprite.bitmap.dispose
      sprite.dispose
    end
    @weapon_graphic.bitmap = nil
    unless @weapon_bitmap.nil?
      @weapon_bitmap.dispose
      @weapon_bitmap = nil
    end   
    @weapon_graphic.dispose
    @weapon_graphic = nil   
    $game_map.damege_sprites.clear
  end
  def update_weapon_graphic
    @weapon_graphic.x = $game_player.screen_x + @correction[$game_player.direction][0]
    @weapon_graphic.y = $game_player.screen_y + @correction[$game_player.direction][1]
    case @attack_timer
    when 12
      @weapon_graphic.angle = @angles[$game_player.direction][0]
      @weapon_graphic.z = @z_values[$game_player.direction]
    when 9
      @weapon_graphic.angle = @angles[$game_player.direction][1]
      @weapon_graphic.z = @z_values[$game_player.direction]
    when 6
      @weapon_graphic.angle = @angles[$game_player.direction][2]
      @weapon_graphic.z = @z_values[$game_player.direction]
    when 3
      @weapon_graphic.angle = @angles[$game_player.direction][3]
      @weapon_graphic.z = @z_values[$game_player.direction]
    when 0
      @attacking = false
      @weapon_graphic.bitmap = nil
    end
    @weapon_graphic.update
    @attack_timer -= 1
  end
  def weapon_animation
    return if @weapon_bitmap.nil?
    @weapon_graphic.bitmap = @weapon_bitmap
    @attacking = true
    @attack_timer = 12
  end 
end

class Damege_Sprite < Sprite
  def initialize (target,value)
    super(nil)
    @target = target
    self.bitmap = Bitmap.new(60,20)
    self.bitmap.draw_text(0,0,60,20,value,1)
    self.ox = 40
    self.x = @target.screen_x
    self.y = @target.screen_y - 60
    self.z = 999
    @timer = 20
  end
  def update
    self.x = @target.screen_x
    self.y = @target.screen_y - 60   
    if @timer > 0
      @timer -= 1
      self.zoom_x += 0.01
      self.zoom_y += 0.01
    else
      self.opacity > 0 ? self.opacity -= 15 : dispose
    end
  end
  def dispose
    self.bitmap.dispose
    super
  end
end
[close]