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.

draw_actor_parameter in battle

Hi, I've got trouble with my battle system.

In scene_battle 1, a window is called:

@actor_comwin = Window_NumberCommand.new(@actor)


This window should display the actors stats during the input command phase.
Now the problem is that I get an error, if I try to do that. The code for the window is the following:

class Window_NumberCommand < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(80, 100, 480, 300)
    self.contents = Bitmap.new(width - 32, height - 32)

    @actor = actor
   
   
    refresh
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    super
  end

  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear

   
   
    draw_actor_parameter(@actor, 10,32, 7)
   
   
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # Slightly lower opacity level during main phase
    if $game_temp.battle_main_phase
      self.contents_opacity -= 4 if self.contents_opacity > 191
    else
      self.contents_opacity += 4 if self.contents_opacity < 255
    end
  end
end


The Error I get:
http://img529.imageshack.us/img529/4456/errorom7.jpg[/img]

Hope someone can help...


oh, and a_1 ist parameter 7. That is not the problem, because the same happens whith all the other parameters such as str, dex and so on.
 
Here's what I think the problem is...

@actor is supposed to be which actor is in the input battle commands phase, correct?

So in your initialize method, change this...

Code:
@actor = actor

to this...

Code:
@actor = actor_index

Setting it to 'actor' isn't going to tell you which actor is in command phase, so you have to set it to actor_index.

Reference to Scene_Battle, start_phase2 and you'll see where the actor_index comes from.
 

khmp

Sponsor

No Mr. Kain Nobel it should be the actual actor and not his index. If you look at draw_actor_parameter and look at the very first case you will actor.atk. You can't use that method unless the object is in fact a Game_Battler. We would have used actor_index only if in the draw_parameter method they had a line like this:
Code:
actor = $game_party.actors[actor] 
#or
actor = $game_actors[actor]
Stuck in before the case statement.

So anyway Mr. lucien. There is a problem in that in XP Window_Base isn't even 330 lines long. So when you get the error at that line I have to assume you have made edits to the class. We would actually need to see the edits because they are what seem to be causing the error. The window that you made looks correct.
 
Thanks, but this gives also an error. I did not change anything relevant for this problem in window_base. just some def actor graphic 2 to display faces in the menu.

The Error shows on the line actor = $game_party.actors[actor] , I added it as you said before the cases in window_base.

it seems at it does not get the actors number from the scene battle, because if I replace the actor = $game_party.actors[actor]  with actor = $game_party.actors[0] the whole code works for the first party member. so the error must be there.
 

khmp

Sponsor

lucien":3mvvu0pt said:
Thanks, but this gives also an error. I did not change anything relevant for this problem in window_base. just some def actor graphic 2 to display faces in the menu.

The Error shows on the line actor = $game_party.actors[actor] , I added it as you said before the cases in window_base.

it seems at it does not get the actors number from the scene battle, because if I replace the actor = $game_party.actors[actor]  with actor = $game_party.actors[0] the whole code works for the first party member. so the error must be there.

Then the problem lies in how you are creating your window. How exactly are you instantiating Window_NumberCommand?
 
@actor_comwin = Window_NumberCommand.new(@actor)
@actor_comwin.visible = false

this is how it is called in scene_battle 1. and @actor_comwin.visible = true makes it visable when the commands are being put in.
 

khmp

Sponsor

Where are you getting "@actor" from in Scene_Battle? There's an "@active_battler" instance variable inside Scene_Battle but no instance variable called "@actor". And I don't think it is always be something that's valid. I think you should revamp the approach you are using to present whatever parameter is number 7. Allow the actor inside the Window_NumberCommand to be set some where other than its initialize. If you put it in the initialize there's the problem where @active_battler changes and also that at window creation the actor being passed in may be nil. Perhaps make a method that when the actor is changed, redraw/refresh the window.

Code:
class Window_NumberCommand < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(80, 100, 480, 300)
    self.contents = Bitmap.new(width - 32, height - 32)
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    super
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_parameter(@actor, 10, 32, 7)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super

    # Slightly lower opacity level during main phase
    if $game_temp.battle_main_phase
      self.contents_opacity -= 4 if self.contents_opacity > 191
    else
      self.contents_opacity += 4 if self.contents_opacity < 255
    end
  end
  #--------------------------------------------------------------------------
  # * Actor = 
  #     actor : the actor whose information we want to draw.
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if actor.nil? || @actor == actor
    @actor = actor
    refresh
  end
end

Code:
# Then use a line like this after the active battler has changed.
@actor_comwin.actor = @active_battler

Good luck with it lucien! :thumb:
 

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