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.

Lufia Styled Battle Report V1.2

Status
Not open for further replies.
I'm having a problem with it I can't figure out...

Okay, so I was playing through my game just to make sure there were no bugs. All the battles before had gone fine, but once one of my characters was paralyzed at the end of a battle, I got the following script error:

Window_BattleResult line 88: NoMethod Error occurred.
undefined method '[]' for nil:NilClass
(the line in the script is: if @level_flags[actor_index][0] == false)

I changed "false" to "true", knowing I could just go back and change it if this screwed it up anymore. Then, I tried my game again and got the following error in the same situation:

Scene_Battle#Edits line 154: TypeError occurred
no implicit conversion from nil to integer
(the line in the script is: last = $data_actors[@actor_id].parameters[stat, last_level])

EDIT: Just to clarify, this error only occurs when a character is paralyzed or dead at the end of the battle.
Also, from an earlier post:
You probably have the font error just add this to the initialize method
self.contents.font.name = "Arial" #whatever font you want
self.contents.font.size = 32
What is the initialize method? Sorry, I'm not a scripter, so I don't know. It's just looking funny to have the font in the battle result script different than the rest of my game, so it would be great to be able to add this.
 
@freakishfae - I don't see why being paralyzed or dead would cause such an error, what other scripts are you using

@Armor_King_108 - I'm pretty sure added an option for that look over the setup section again as I don't have this script on this computer atm
 
I'm using your animated gradient bars script, AMS, and the day and night and light effect scripts by Near Fantasia. Thing is, I removed all other custom scripts and it still had the error. But, when I put them in a new game it worked. The error also takes place with the sleep status. I'm confused. ><
 
I also had the same problem as FreakishFae, that the battle result hung and died when a character was dead at the end of a battle; so I went looking at the script...
Though the script hangs on the Window_Battleresult script; it seems to do so because it cannot find a value for @level_flags
So I went and found where this is defined... Its in the Scene_Battle under the comment #Obtaining EXP
Code:
# Obtaining EXP
    level_flags = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        #EDITS
        if last_level != actor.level
          level_flags[i] = [true, last_level] 
        else
          level_flags[i] = [false]
        end
      end
    end
Yup, this is the criminal. Its all well and good when the actor.cant_get_exp? == false, like it would be under most circumstances. But theres no contingency. What if its true? Then it can't return a value for level_flags, right?

I fixed it with this
Code:
    # Obtaining EXP
    level_flags = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        #EDITS
        if last_level != actor.level
          level_flags[i] = [true, last_level] 
        else
          level_flags[i] = [false]
        end
        #EDITS
        [B]elsif actor.cant_get_exp? == true
        last_level = actor.level
        level_flags[i] = [false][/B]
      end
    end
Now, I'm no coder, so that is probably crap coding; but it works now. I tested it with an item that KO's a character, then finished a battle against a wussy monster, and it now seems OK.

Hope that helps you too.
 
Updated the script Version 1.2

@eharper256 yes it works, but I didn't go in that direction

Also it would have been helpful to tell me the line (whats on the line in the script editor) and the error message since 99% of the time my version is different from yours
 
Someone fixed the audio bug, and now it works with all systems including RTAB, so update the script or add a new section for RTAB. Not sure if it works with all of them, but oh well this might help some for people that use RTAB.

Scene_Battle#Edits RTAB
#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.state('Lufia Style Battle Report') == true
 
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Start Phase 5
  #--------------------------------------------------------------------------
  def start_phase5
    # Shift to phase 5
    @phase = 5
    # Play battle end ME
    $game_system.me_play($game_system.battle_end_me)
    # Return to BGM before battle started
    $game_system.bgm_play($game_temp.map_bgm)
    # Initialize EXP, amount of gold, and treasure
    exp, gold, treasures = 0, 0, []
    # Loop
    $game_troop.enemies.each do |enemy|
      # Skip id enemy is hidden
      next if enemy.hidden
      # Add EXP and amount of gold obtained
      exp += enemy.exp
      gold += enemy.gold
      # Skip if no treasure
      next if rand(100) > enemy.treasure_prob
      # Push Treasures if defined
      treasures << $data_items[enemy.item_id] if enemy.item_id > 0
      treasures << $data_weapons[enemy.weapon_id] if enemy.weapon_id > 0
      treasures << $data_armors[enemy.armor_id] if enemy.armor_id > 0
    end
    # Obtaining EXP
    level_flags = Array.new($game_party.actors.size) {false}
    # Run Through Each Actor With Index
    $game_party.actors.each_with_index do |actor, index|
      # Skip if can't get exp
      next if actor.cant_get_exp?
      # Get Last Level
      last_level = actor.level
      # Add Exp
      actor.exp += exp
      # Skip if no level change
      next if last_level == actor.level
      # Set Level Flags
      level_flags[index] = last_level
    end
    # Obtaining gold
    $game_party.gain_gold(gold)
    # Obtaining treasure
    treasures.each do |item|
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # Make battle result window
    @result_window = Window_BattleResult.new(exp, gold, treasures, level_flags)
    # Set Wait
    @phase5_wait_count = 100
  end
  #--------------------------------------------------------------------------
  # * Update Phase 5
  #--------------------------------------------------------------------------
  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      # Decrease wait count
      @phase5_wait_count -= 1
      # If wait count reaches 0
      if @phase5_wait_count == 0
        # Show result window
        @result_window.visible = true
        # Clear main phase flag
        $game_temp.battle_main_phase = false
        # Refresh status window
        @status_window.refresh
      end
      return
    end
    # If result window
    if not @result_window.disposed?
      # Update Result
      @result_window.update
      # Get final wait count
      @final_wait = LufiaII_Result::Last_Wait
      # Return
      return
    end
    # If Final Wait is greater than 0 and C is not triggered
    if @final_wait > 0 and not Input.trigger?(Input::C)
      # Reduce By 1
      @final_wait -= 1
      # Return
      return
    end
    # Set Result Window to nil
    @result_window = nil
    # Battle End
    Audio.me_stop
    battle_end(0)
  end
end

module RPG
class Class
  #--------------------------------------------------------------------------
  # * Learn Skills
  #--------------------------------------------------------------------------
  def learn_skills(level)
    # Setup Data Array
    data = []
    # Run Through Each Learning Skill
    @learnings.each do |learning|
      # Push if levels are the same
      data << learning.skill_id if learning.level == level
    end
    # Return Data
    return data
  end
end
end

class Game_Actor
  #--------------------------------------------------------------------------
  # * Get the current EXP
  #--------------------------------------------------------------------------
  def now_exp
    return @exp - @exp_list[@level]
  end
  #--------------------------------------------------------------------------
  # * Get the next level's EXP
  #--------------------------------------------------------------------------
  def next_exp
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
  #--------------------------------------------------------------------------
  # * Learn Skills
  #--------------------------------------------------------------------------
  def stat_change(stat, last_level, new_level = nil)
    last = $data_actors[@actor_id].parameters[stat, last_level]
    new_level = self.level if new_level == nil
    now = $data_actors[@actor_id].parameters[stat, new_level]
    return now - last
  end
end
#--------------------------------------------------------------------------
# End SDK Enabled Check
#--------------------------------------------------------------------------
end
 
Status
Not open for further replies.

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