Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Problem with Final fantasy XII's battlesystem script...

Hey there guys, I hope this is the correct section to post this, a long long time ago I downloaded a final fantasy XII style battlesystem.
and everything is perfect with one single problem...
sometimes when I defeat an enemy (most of the time a boss) the game crashes and gives me this error message:

I haven't been able to see what's causing the error, and it seems the script was dumped, so I can't really get a fixed version, here's the line that gives the error ni the script:
t.battler.skill_effect(self.battler, skill)
I'm at a loss here because I know some scripting but CBS still go way over my head :(
here's the complete script that gives the error message:
Code:
#===============================================================================

# FFXII - Game_Character - Attack

#-------------------------------------------------------------------------------

# Criador: RTH

#===============================================================================

 

class Game_Character

      

  #-----------------------------------------------------------------------------

  # Attaca o alvo

  #-----------------------------------------------------------------------------

    

  def attack(target)

    return false unless FFXII.valid_attack?(self, target)

    @animation_type = 0

    target.battler.attack_effect(self.battler)

    if target.enemy?

      target.agressivity = 1

    end

    target.setup_damage

    target.animation_id = @battler.animation2_id

    return true

  end

                

  #-----------------------------------------------------------------------------

  # Attaca o alvo

  #-----------------------------------------------------------------------------

    

  def skill(skill, target)

    return false unless FFXII.valid_attack?(self, target)

    return false if skill.nil?

    return false if @battler.sp < skill.sp_cost

    if skill.allsp?

      @battler.sp = @battler.sp - @battler.maxsp

    else

      @battler.sp = @battler.sp - skill.sp_cost

    end

    if skill.quickening?

      quickening(skill, target)

      return

    end

    @animation_id = skill.animation1_id

    animation = $data_animations[@animation_id]

    counter_max = 1

    if animation != nil

      counter_max = (Graphics.frame_rate * animation.frame_max / 20.0).to_i

    end

    @animation_type = 1

    @skill_id = skill.id

    @last_skill_id = skill.id

    @last_skill_target = target

    @last_skill_damage_count = counter_max

    if @last_skill_damage_count <= 0

      skill_damage(skill, target)

    end

  end

  

  def skill_damage(skill, target)

    @last_skill_id = 0

    @last_skill_target = nil

    @last_skill_damage_count = 0

    targets = [target]

    if skill.raio > 0

      if self.enemy?

        for i in 0...FFXII::MAX_ACTORS

          next if $game_party.actors[i].nil? or $game_party.actors[i].dead?

          if i == $game_player.main_actor

            actor = $game_player

          else

            actor = $game_train_actors[$game_party.actors[i].id]

          end

          next if actor == target

          if target.inside_real_raio?(actor, skill.raio)

            targets.push(actor)

          end

        end

      else

        case skill.scope

        when 1..2

          for event in $game_map.screen_events.values

            next if event.nil? or event.battler.nil? or event.battler.dead?

            next if event == target

            if skill.scope == 2

              targets.push(event)

              next

            end

            if target.inside_real_raio?(event, skill.raio)

              targets.push(event)

            end

          end

        when 3..6

          for i in 0...$game_pacty.actors.size

            next if $game_pacty.actors[i].nil?

            next unless $game_pacty.actors[i].active

            next if (skill.scope <= 4 ? $game_pacty.actors[i].dead? : (!$game_pacty.actors[i].dead?))

            actor = (i == $game_player.main_actor ? $game_player : $game_train_actors[$game_pacty.actors[i].id])

            if [4, 6].include?(skill.scope)

              targets.push($actor) unless targets.include?(actor)

              next

            end

            if target.inside_real_raio?(actor, skill.raio)

              targets.push($actor) unless targets.include?(actor)

            end

          end

        end

      end

    end

    $game_temp.in_battle = true

    animation_2 = $data_animations[skill.animation2_id]

    if animation_2.nil?

      all_animation = true

    elsif animation_2.position == 3

      all_animation = false

    else

      all_animation = true

    end

    if all_animation == false

      target.animation_id = skill.animation2_id

    end

    for t in targets

      next if t.nil?

      t.battler.skill_effect(self.battler, skill)

      if t.enemy?

        t.agressivity = 1

      end

      t.setup_damage

      t.animation_id = skill.animation2_id if all_animation

    end

    $game_temp.in_battle = false

    return true

  end

 

  #-----------------------------------------------------------------------------

  # Quickening Alguem

  #-----------------------------------------------------------------------------

    

  def quickening(skill, target)

    targets = [target]

    if skill.raio > 0

      if self.enemy?

        for i in 0...FFXII::MAX_ACTORS

          next if $game_party.actors[i].nil? or $game_party.actors[i].dead?

          if i == $game_player.main_actor

            actor = $game_player

          else

            actor = $game_train_actors[$game_party.actors[i].id]

          end

          next if actor == target

          if target.inside_real_raio?(actor, skill.raio)

            targets.push(actor)

          end

        end

      else

        for event in $game_map.screen_events.values

          next if event.nil? or event.battler.nil? or event.battler.dead?

          next if event == target

          if target.inside_real_raio?(event, skill.raio)

            targets.push(event)

          end

        end

      end

    end

    $game_temp.quickening_player = self

    $game_temp.quickening_targets = targets

    $game_temp.quickening_skill_id = skill.id

  end

                

  #-----------------------------------------------------------------------------

  # Usa o item no alvo

  #-----------------------------------------------------------------------------

    

  def item(item, target)

    return false unless FFXII.valid_attack?(self, target)

    return false if item.nil?

    return false if $game_party.item_number(item.id) <= 0

    $game_party.lose_item(item.id, 1)

    @animation_id = item.animation1_id

    animation = $data_animations[@animation_id]

    if animation != nil and $scene.instance_of?(Scene_Map)

      counter_max = (Graphics.frame_rate * animation.frame_max / 20.0).to_i

      for i in 0...counter_max 

        Graphics.update

        Input.update

        $scene.action_update

      end

    end

    targets = [target]

    $game_temp.in_battle = true

    for t in targets

      next if t.nil?

      t.battler.item_effect(item)

      t.setup_damage

      if t.enemy?

        t.agressivity = 1

      end

      t.animation_id = item.animation2_id

    end

    $game_temp.in_battle = false

    return true

  end

                

  #-----------------------------------------------------------------------------

  # Atualiza o dano

  #-----------------------------------------------------------------------------

 

  def setup_damage

    @damage = @battler.damage

    @critical = @battler.critical

  end

                

  #-----------------------------------------------------------------------------

  # Faz a ação

  #-----------------------------------------------------------------------------

 

  def make_action

    if @target.is_a?(Game_Train_Actor)

      unless $game_party.actors[$game_player.main_actor].nil?

        if @target.id == $game_party.actors[$game_player.main_actor].id

          self.target = $game_player

        end

      end

    end

    if @battler.attacking?

      attack(@target)

      self.target = nil

    elsif @battler.skilling?

      skill($data_skills[@battler.current_action.skill_id], @target)

      self.target = nil

    elsif @battler.iteming?

      item($data_items[@battler.current_action.item_id], @target)

      self.target = nil

    end

    @battler.current_action.clear

  end

                

  #-----------------------------------------------------------------------------

  # Inicia o ataque

  #-----------------------------------------------------------------------------

 

  def start_attack(target)

    return if @battler.nil? or target.nil? or target.battler.nil?

    @battler.current_action.kind = 0

    @battler.current_action.basic = 0

    @battler.current_action.setup_action_speed

    self.target = target

  end

  

  #-----------------------------------------------------------------------------

  # Inicia a habilidade

  #-----------------------------------------------------------------------------

 

  def start_skill(skill_id, target)

    return if @battler.nil? or target.nil? or target.battler.nil?

    $game_temp.in_battle = true

    unless @battler.skill_can_use?(skill_id)

      $game_temp.in_battle = false

      return 

    end

    $game_temp.in_battle = false

    @battler.current_action.kind = 1

    @battler.current_action.skill_id = skill_id

    @battler.current_action.basic = 0

    @battler.current_action.setup_action_speed

    self.target = target

  end

                

  #-----------------------------------------------------------------------------

  # Inicia o Item

  #-----------------------------------------------------------------------------

 

  def start_item(item_id, target)

    return if @battler.nil? or target.nil? or target.battler.nil?

    @battler.current_action.kind = 2

    @battler.current_action.item_id = item_id

    @battler.current_action.basic = 0

    @battler.current_action.setup_action_speed

    self.target = target

  end

                

  #-----------------------------------------------------------------------------

  # Limpa a ação

  #-----------------------------------------------------------------------------

 

  def clear_action

    self.target = nil

    return if @battler.nil?

    @battler.current_action.clear

  end

  

end

  

  

 
BTW the whole battlesystem uses many scripts more than just that one, but I don't know if I should post them ALL in here...
I hope someone can help me with this, I just want the script to stop crashing the game, that's all =P
 
Didn't really work... where should put it? I tried in several places and didn't work. :(
this is the whole section of the code, maybe you'll understand better than me...
Code:
#-----------------------------------------------------------------------------

  # Attaca o alvo

  #-----------------------------------------------------------------------------

    

  def skill(skill, target)

    return false unless FFXII.valid_attack?(self, target)

    return false if skill.nil?

    return false if @battler.sp < skill.sp_cost

    if skill.allsp?

      @battler.sp = @battler.sp - @battler.maxsp

    else

      @battler.sp = @battler.sp - skill.sp_cost

    end

    if skill.quickening?

      quickening(skill, target)

      return

    end

    @animation_id = skill.animation1_id

    animation = $data_animations[@animation_id]

    counter_max = 1

    if animation != nil

      counter_max = (Graphics.frame_rate * animation.frame_max / 20.0).to_i

    end

    @animation_type = 1

    @skill_id = skill.id

    @last_skill_id = skill.id

    @last_skill_target = target

    @last_skill_damage_count = counter_max

    if @last_skill_damage_count <= 0

      skill_damage(skill, target)

    end

  end

  

  def skill_damage(skill, target)

    @last_skill_id = 0

    @last_skill_target = nil

    @last_skill_damage_count = 0

    targets = [target]

    if skill.raio > 0

      if self.enemy?

        for i in 0...FFXII::MAX_ACTORS

          next if $game_party.actors[i].nil? or $game_party.actors[i].dead?

          if i == $game_player.main_actor

            actor = $game_player

          else

            actor = $game_train_actors[$game_party.actors[i].id]

          end

          next if actor == target

          if target.inside_real_raio?(actor, skill.raio)

            targets.push(actor)

          end

        end

      else

        case skill.scope

        when 1..2

          for event in $game_map.screen_events.values

            next if event.nil? or event.battler.nil? or event.battler.dead?

            next if event == target

            if skill.scope == 2

              targets.push(event)

              next

            end

            if target.inside_real_raio?(event, skill.raio)

              targets.push(event)

            end

          end

        when 3..6

          for i in 0...$game_pacty.actors.size

            next if $game_pacty.actors[i].nil?

            next unless $game_pacty.actors[i].active

            next if (skill.scope <= 4 ? $game_pacty.actors[i].dead? : (!$game_pacty.actors[i].dead?))

            actor = (i == $game_player.main_actor ? $game_player : $game_train_actors[$game_pacty.actors[i].id])

            if [4, 6].include?(skill.scope)

              targets.push($actor) unless targets.include?(actor)

              next

            end

            if target.inside_real_raio?(actor, skill.raio)

              targets.push($actor) unless targets.include?(actor)

            end

          end

        end

      end

    end

    $game_temp.in_battle = true

    animation_2 = $data_animations[skill.animation2_id]

    if animation_2.nil?

      all_animation = true

    elsif animation_2.position == 3

      all_animation = false

    else

      all_animation = true

    end

    if all_animation == false

      target.animation_id = skill.animation2_id

    end

    for t in targets

      next if t.nil?

      t.battler.skill_effect(self.battler, skill)             #this is the line that gives error

      if t.enemy?

        t.agressivity = 1

     end

      t.setup_damage

      t.animation_id = skill.animation2_id if all_animation

    end

    $game_temp.in_battle = false

    return true

  end

 
 

opaj

Member

What an odd thing to occur.

Try adding the following line directly before the line that's giving you the error:

Code:
next if t.battler.nil?

It's a bit of a brute-force solution, since I don't know what the game is doing just before the error occurs. Hopefully this fixes the problem, though.
 
thanks, but that line is already just before the line that gives me the error :S
I don't want to keep giving trouble but maybe it would be easier if I post the whole demo? I'm not sure what would be best...
 

opaj

Member

Please, take another look. A very similar line is there, but it is not the same line, unless you've added it since you first posted the script. Though I admit, I'm still a relative Ruby newbie, so it may not be the thing that fixes this (I've mostly gotten by through trial and error and experience with other languages).

The line that's currently there checks to make sure t exists. The line I added then checks to make sure that t.battler exists. According to the error you're getting, the game is trying to access t.battler when it doesn't exist, so I'm thinking the line I gave you should fix that.
 

Atoa

Member

Probably your version is outdated, even the most updated version of this script relased only on portuguese is inconplet.

So i don't suggest using it unless you want to face bugs on your game.
 

opaj

Member

Glad to have helped! To be honest, I wasn't 100% sure it would work. Finally picked up a book on Ruby, so hopefully my future fixes will be more reliable. :wink:

Now I'm tempted to get my hands on this battle system just to figure out what caused this to happen in the first place. Probably won't, but it's tempting.
 
yeah Thanks a lot man :)
I'm running into another (smaller) problem with the system...
for some reason, when I kill an enemy using a skill instead of a regular attack or an item, it doesn't give my any experience or items, I've looked all around for what might be causing the problem, but haven't been able to figure it out, I *think* I know which scripts handles that info, but I'm not sure...
I'll post the 2 scripts I think may be the ones causing it, and I hope someone can see why it's not working, but if you can't then I can post the whole demo, maybe that would work too...
Code:
#===============================================================================

# FFXII - Game_Character - Attack

#-------------------------------------------------------------------------------

# Criador: RTH

#===============================================================================

 

class Game_Character

      

  #-----------------------------------------------------------------------------

  # Attaca o alvo

  #-----------------------------------------------------------------------------

    

  def attack(target)

    return false unless FFXII.valid_attack?(self, target)

    @animation_type = 0

    target.battler.attack_effect(self.battler)

    if target.enemy?

      target.agressivity = 1

    end

    target.setup_damage

    target.animation_id = @battler.animation2_id

    return true

  end

                

  #-----------------------------------------------------------------------------

  # Attaca o alvo

  #-----------------------------------------------------------------------------

    

  def skill(skill, target)

    return false unless FFXII.valid_attack?(self, target)

    return false if skill.nil?

    return false if @battler.sp < skill.sp_cost

    if skill.allsp?

      @battler.sp = @battler.sp - @battler.maxsp

    else

      @battler.sp = @battler.sp - skill.sp_cost

    end

    if skill.quickening?

      quickening(skill, target)

      return

    end

    @animation_id = skill.animation1_id

    animation = $data_animations[@animation_id]

    counter_max = 1

    if animation != nil

      counter_max = (Graphics.frame_rate * animation.frame_max / 20.0).to_i

    end

    @animation_type = 1

    @skill_id = skill.id

    @last_skill_id = skill.id

    @last_skill_target = target

    @last_skill_damage_count = counter_max

    if @last_skill_damage_count <= 0

      skill_damage(skill, target)

    end

  end

  

  def skill_damage(skill, target)

    @last_skill_id = 0

    @last_skill_target = nil

    @last_skill_damage_count = 0

    targets = [target]

    if skill.raio > 0

      if self.enemy?

        for i in 0...FFXII::MAX_ACTORS

          next if $game_party.actors[i].nil? or $game_party.actors[i].dead?

          if i == $game_player.main_actor

            actor = $game_player

          else

            actor = $game_train_actors[$game_party.actors[i].id]

          end

          next if actor == target

          if target.inside_real_raio?(actor, skill.raio)

            targets.push(actor)

          end

        end

      else

        case skill.scope

        when 1..2

          for event in $game_map.screen_events.values

            next if event.nil? or event.battler.nil? or event.battler.dead?

            next if event == target

            if skill.scope == 2

              targets.push(event)

              next

            end

            if target.inside_real_raio?(event, skill.raio)

              targets.push(event)

            end

          end

        when 3..6

          for i in 0...$game_pacty.actors.size

            next if $game_pacty.actors[i].nil?

            next unless $game_pacty.actors[i].active

            next if (skill.scope <= 4 ? $game_pacty.actors[i].dead? : (!$game_pacty.actors[i].dead?))

            actor = (i == $game_player.main_actor ? $game_player : $game_train_actors[$game_pacty.actors[i].id])

            if [4, 6].include?(skill.scope)

              targets.push($actor) unless targets.include?(actor)

              next

            end

            if target.inside_real_raio?(actor, skill.raio)

              targets.push($actor) unless targets.include?(actor)

            end

          end

        end

      end

    end

    $game_temp.in_battle = true

    animation_2 = $data_animations[skill.animation2_id]

    if animation_2.nil?

      all_animation = true

    elsif animation_2.position == 3

      all_animation = false

    else

      all_animation = true

    end

    if all_animation == false

      target.animation_id = skill.animation2_id

    end

    for t in targets

      next if t.nil?

      next if t.battler.nil?

      t.battler.skill_effect(self.battler, skill)

      if t.enemy?

        t.agressivity = 1

     end

      t.setup_damage

      t.animation_id = skill.animation2_id if all_animation

    end

    $game_temp.in_battle = false

    return true

  end

 

  #-----------------------------------------------------------------------------

  # Quickening Alguem

  #-----------------------------------------------------------------------------

    

  def quickening(skill, target)

    targets = [target]

    if skill.raio > 0

      if self.enemy?

        for i in 0...FFXII::MAX_ACTORS

          next if $game_party.actors[i].nil? or $game_party.actors[i].dead?

          if i == $game_player.main_actor

            actor = $game_player

          else

            actor = $game_train_actors[$game_party.actors[i].id]

          end

          next if actor == target

          if target.inside_real_raio?(actor, skill.raio)

            targets.push(actor)

          end

        end

      else

        for event in $game_map.screen_events.values

          next if event.nil? or event.battler.nil? or event.battler.dead?

          next if event == target

          if target.inside_real_raio?(event, skill.raio)

            targets.push(event)

          end

        end

      end

    end

    $game_temp.quickening_player = self

    $game_temp.quickening_targets = targets

    $game_temp.quickening_skill_id = skill.id

  end

                

  #-----------------------------------------------------------------------------

  # Usa o item no alvo

  #-----------------------------------------------------------------------------

    

  def item(item, target)

    return false unless FFXII.valid_attack?(self, target)

    return false if item.nil?

    return false if $game_party.item_number(item.id) <= 0

    $game_party.lose_item(item.id, 1)

    @animation_id = item.animation1_id

    animation = $data_animations[@animation_id]

    if animation != nil and $scene.instance_of?(Scene_Map)

      counter_max = (Graphics.frame_rate * animation.frame_max / 20.0).to_i

      for i in 0...counter_max 

        Graphics.update

        Input.update

        $scene.action_update

      end

    end

    targets = [target]

    $game_temp.in_battle = true

    for t in targets

      next if t.nil?

      t.battler.item_effect(item)

      t.setup_damage

      if t.enemy?

        t.agressivity = 1

      end

      t.animation_id = item.animation2_id

    end

    $game_temp.in_battle = false

    return true

  end

                

  #-----------------------------------------------------------------------------

  # Atualiza o dano

  #-----------------------------------------------------------------------------

 

  def setup_damage

    @damage = @battler.damage

    @critical = @battler.critical

  end

                

  #-----------------------------------------------------------------------------

  # Faz a ação

  #-----------------------------------------------------------------------------

 

  def make_action

    if @target.is_a?(Game_Train_Actor)

      unless $game_party.actors[$game_player.main_actor].nil?

        if @target.id == $game_party.actors[$game_player.main_actor].id

          self.target = $game_player

        end

      end

    end

    if @battler.attacking?

      attack(@target)

      self.target = nil

    elsif @battler.skilling?

      skill($data_skills[@battler.current_action.skill_id], @target)

      self.target = nil

    elsif @battler.iteming?

      item($data_items[@battler.current_action.item_id], @target)

      self.target = nil

    end

    @battler.current_action.clear

  end

                

  #-----------------------------------------------------------------------------

  # Inicia o ataque

  #-----------------------------------------------------------------------------

 

  def start_attack(target)

    return if @battler.nil? or target.nil? or target.battler.nil?

    @battler.current_action.kind = 0

    @battler.current_action.basic = 0

    @battler.current_action.setup_action_speed

    self.target = target

  end

  

  #-----------------------------------------------------------------------------

  # Inicia a habilidade

  #-----------------------------------------------------------------------------

 

  def start_skill(skill_id, target)

    return if @battler.nil? or target.nil? or target.battler.nil?

    $game_temp.in_battle = true

    unless @battler.skill_can_use?(skill_id)

      $game_temp.in_battle = false

      return 

    end

    $game_temp.in_battle = false

    @battler.current_action.kind = 1

    @battler.current_action.skill_id = skill_id

    @battler.current_action.basic = 0

    @battler.current_action.setup_action_speed

    self.target = target

  end

                

  #-----------------------------------------------------------------------------

  # Inicia o Item

  #-----------------------------------------------------------------------------

 

  def start_item(item_id, target)

    return if @battler.nil? or target.nil? or target.battler.nil?

    @battler.current_action.kind = 2

    @battler.current_action.item_id = item_id

    @battler.current_action.basic = 0

    @battler.current_action.setup_action_speed

    self.target = target

  end

                

  #-----------------------------------------------------------------------------

  # Limpa a ação

  #-----------------------------------------------------------------------------

 

  def clear_action

    self.target = nil

    return if @battler.nil?

    @battler.current_action.clear

  end

  

end

  

  

 
Code:
#===============================================================================

# FFXII - Game_Player

#-------------------------------------------------------------------------------

# Criador: RTH

#===============================================================================

 

class Game_Player < Game_Character

      

  #-----------------------------------------------------------------------------

  # Váriaveis Globais

  #-----------------------------------------------------------------------------

    

  attr_reader   :main_actor

  attr_accessor :gambit_on

  #-----------------------------------------------------------------------------

  # Alias

  #-----------------------------------------------------------------------------

    

  unless method_defined?("ffxii_abs_gplayer_initialize")

    alias ffxii_abs_gplayer_initialize initialize

    alias ffxii_abs_gplayer_moveto moveto

  end

  

  @@initialize_method = (method_defined?("initialize"))

  

  #-----------------------------------------------------------------------------

  # Inicialização

  #-----------------------------------------------------------------------------

    

  def initialize

    (@@initialize_method ? ffxii_abs_gplayer_initialize : super())

    @main_actor = 0

    @stoped_time = 0

    @gambit_on = false

  end

  

  #-----------------------------------------------------------------------------

  # Atualização

  #-----------------------------------------------------------------------------

    

  def refresh

    # Selecionar o Herói líder

    actor = $game_party.actors[@main_actor]

    # Se o número de membros no Grupo de Heróis for 0

    if actor.nil?

      # Limpar o nome do arquivo e a tonalidade do Herói

      @character_name = ""

      @character_hue = 0

      @battler = nil

      # Fim do método

      return

    end

    # Selecionar o nome do arquivo e a tonalidade do Herói

    @character_name = actor.character_name

    @character_hue = actor.character_hue

    # Inicializar a opacidade e a sinteticidade

    @opacity = 255

    @blend_type = 0

    @battler = actor

  end

  

  #-----------------------------------------------------------------------------

  # main_actor=

  #-----------------------------------------------------------------------------

    

  def main_actor=(valor)

    return if @main_actor == valor

    return if $game_party.actors[valor].nil?

    pre_actor = $game_train_actors[$game_party.actors[@main_actor].id]

    pre_actor.target = @target

    @main_actor = valor

    $game_temp.hud_need_clear = true

    actor = $game_train_actors[$game_party.actors[@main_actor].id]

    self.target = actor.target

    self.moveto(actor.x, actor.y, false)

    @real_x = actor.real_x

    @real_y = actor.real_y

    @animation_id = actor.animation_id

    @hp_bar_refresh = true

    actor.refresh

    refresh

  end

    

  #-----------------------------------------------------------------------------

  # action_near_enough?

  #-----------------------------------------------------------------------------

 

  def set_dead

    $game_train_actors[$game_party.actors[@main_actor].id].set_dead

    if $game_party.all_dead?

      $scene = Scene_Gameover.new

      return

    end

    if $game_system.summoning

      $game_temp.need_call_unsummon = true

    end

    $game_temp.need_call_actor_select_menu = true

  end

  

  #-----------------------------------------------------------------------------

  # moveto

  #-----------------------------------------------------------------------------

    

  def moveto(x, y, move_players=true)

    ffxii_abs_gplayer_moveto(x, y)

    if move_players

      for i in 0...FFXII::MAX_ACTORS

        next if $game_party.actors[i].nil?

        $game_train_actors[$game_party.actors[i].id].moveto($game_player.x, $game_player.y)

      end

      if $game_system.summoning

        $game_train_actors[$game_system.summon_actor_id].moveto($game_player.x, $game_player.y)

      end

    end

  end

    

  #-----------------------------------------------------------------------------

  # Attack

  #-----------------------------------------------------------------------------

    

  def attack(target)

    valor = super(target)

    check_exp_gain(target)

    return valor

  end

    

  #-----------------------------------------------------------------------------

  # Skill

  #-----------------------------------------------------------------------------

    

  def skill(skill, target)

    valor = super(skill, target)

    check_exp_gain(target)

    return valor

  end

    

  #-----------------------------------------------------------------------------

  # Item

  #-----------------------------------------------------------------------------

    

  def item(item, target)

    valor = super(item, target)

    check_exp_gain(target)

    return valor

  end

    

  #-----------------------------------------------------------------------------

  # check_exp_gain(target)

  #-----------------------------------------------------------------------------

    

  def check_exp_gain(target)

    return if target.nil?

    return if target.checked_exp_gain

    if target.battler.dead?

      target.checked_exp_gain = true

      if target.enemy?

        if $game_temp.chain_enemy_id == target.battler.id

          $game_temp.chain_counter += 1

          gdata = FFXII::CHAIN::ITEMS[target.battler.id]

          unless gdata.nil?

            level = 0

            for k, v in gdata

              if $game_temp.chain_counter >= k

                level += 1

              end

            end

            if $game_temp.chain_level != level

              $game_temp.chain_level_up = true

            end

            $game_temp.chain_level = level

          end

          $game_temp.need_chain = true

        else

          $game_temp.chain_level = 0

          $game_temp.chain_enemy_id = target.battler.id

          $game_temp.chain_counter = 1

          $game_temp.need_chain = false

        end

        treasure = nil

        if FFXII::CHAIN::ITEMS[target.battler.id].nil?

          treasure = [get_treasure(target)]

        else

          treasure = FFXII::CHAIN.get_treasure(target.battler.id, $game_temp.chain_counter)

        end

        if treasure != nil

          $game_map.add_items(treasure, target.x, target.y, $game_temp.chain_counter, target.battler.id)

        end

        $game_party.gain_gold(target.battler.gold)

        win_lp = FFXII::LICENCES::ENEMIES_LP_DEFAULT

        if FFXII::LICENCES::ENEMIES_LP[target.battler.id] != nil

          win_lp = FFXII::LICENCES::ENEMIES_LP[target.battler.id]

        end

        case win_lp

        when Range

          win_lp = rand(win_lp.last - win_lp.first) + win_lp.first

        when Array

          win_lp = win_lp[rand(win_lp.size)]

        end

        target.lp_damage = (win_lp <= 0 ? nil : "#{FFXII::LICENCES::LICENCE_POINTS_S} #{win_lp}")

        target.exp_damage = (target.battler.exp <= 0 ? nil : "EXP #{target.battler.exp}")

        target.gold_damage = (target.battler.gold <= 0 ? nil : "#{target.battler.gold} #{$data_system.words.gold}")

        for i in 0...FFXII::MAX_ACTORS

          actor = $game_party.actors[i]

          next if actor.nil?

          actor.lp += win_lp

          pre_level = actor.level

          actor.exp += target.battler.exp

          pactor = (i == $game_player.main_actor ? $game_player : $game_train_actors[actor.id])

          if pre_level < actor.level

            if i == $game_player.main_actor

              pactor.level_up_message = true

            else

              pactor.level_up_message = true

            end

          end

        end

      end

    end

  end

                

  #-----------------------------------------------------------------------------

  # Pega o item ao matar

  #-----------------------------------------------------------------------------

 

  def get_treasure(target)

    treasure = nil

    if rand(100) < target.battler.treasure_prob

      if target.battler.weapon_id > 0

        treasure = $data_weapons[target.battler.weapon_id]

      elsif target.battler.armor_id > 0

        treasure = $data_armors[target.battler.armor_id]

      elsif target.battler.item_id > 0

        treasure = $data_items[target.battler.item_id]

      end

    end

    return treasure

  end

                

  #-----------------------------------------------------------------------------

  # Inicia o ataque

  #-----------------------------------------------------------------------------

 

  def start_attack(target)

    super(target)

    @stoped_time = 0

  end

  

  #-----------------------------------------------------------------------------

  # Inicia a habilidade

  #-----------------------------------------------------------------------------

  

  def start_skill(skill_id, target)

    super(skill_id, target)

    @stoped_time = 0

  end

 

  #-----------------------------------------------------------------------------

  # Inicia o Item

  #-----------------------------------------------------------------------------

 

  def start_item(item_id, target)

    super(item_id, target)

    @stoped_time = 0

  end

  

  #-----------------------------------------------------------------------------

  # Vista da Arma

  #-----------------------------------------------------------------------------

    

  def weapon_vista

    return [($data_weapons[@battler.weapon_id].nil? ? 1.2 : $data_weapons[@battler.weapon_id].vista), 1.2].max

  end

          

end

  

  

 
I hope you guys can help me... :/
EDIT: I've been messing around with the script to see where the error can be, and the problem seems to be that whenever you use a skill on an enemy, it doesn't actually decrease its hp,(even though the HP bar shows that it clearly does) so when you kill it, even though it turned its "dead" selfswitch on, it's not really dead, because it's hp is still at full...
maybe if I could check if the event's selfswitch "dead" is on instead of checking if the event's state is "dead" then it might work...
is there a command to check an event's selfswitch?
 
Ugh, after a whole day checking different things, I finally solved it, it was just a 1 symbol error that made the whole script mess up :S
in line 53 it had:
if @last_skill_damage_count <= 0
and it should be:
if @last_skill_damage_count >= 0
I fixed it and now it works, :D!!!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top