Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
TriangleGM

Simple "Learned Skill" window, scripting trouble

Question

I'm trying to create a window that will simply display

"CHARACTER learned SKILL"

as needed when characters gain levels in battle.

 

EDIT: Okay, I figured out why nothing was happening. I left out the "window.visible" line. D'oh.

However, my new problem is, the window never goes away. So how do I make this window disappear after it shows up?

 

 

(Oringinal post text)

At this point, everything runs smoothly, but nothing happens.

There's no error, but there's no New Skill window displayed either.

I like learning about the scripting side of things, but I always seem to get to this same problem.

I did successfully create an element type for bard weapons that causes them to attack all enemies at once.

So, I have done SOME of this stuff before, but I am NOT fluent in RMXP's scripting.

Any suggestions at all would be much appreciated.

 

This is my new window class (placed before main):

 

 

#==============================================================================
# ** Window_LearnSkill
#------------------------------------------------------------------------------
#  This window displays new skills learned at the end of a battle.
#==============================================================================

class Window_LearnSkill < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     name      : actor name
  #     dskill    : new skill name
  #--------------------------------------------------------------------------
  def initialize(name, newskill)
    @name = name
    @dskill = $data_skills[newskill]
    super(160, 0, 320, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.y = 160 - height / 2
    self.back_opacity = 160
    self.visible = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    x = 4
    self.contents.font.color = normal_color
    cx = contents.text_size(@name).width
    self.contents.draw_text(x, 0, cx, 32, @name)
    x += cx + 4
    self.contents.font.color = normal_color
    cx = contents.text_size("learned").width
    self.contents.draw_text(x, 0, 64, 32, "learned")
    x += cx + 16
    self.contents.font.color = normal_color
    cx = contents.text_size(@dskill.name).width
    self.contents.draw_text(x, 0, cx, 32, @dskill.name)
    y = 32
  end
end

 

 

 

I have then placed a line to call the window directly into the Game_Actor class at line 468, during the # Learn Skill loop, as shown here.

 

 

#--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
          @newskill_window = Window_LearnSkill.new(@name, j.skill_id)
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end

 

 

To clarify, I JUST want an awareness of skills learned, nothing else. I've seen a few examples of custom battle result windows here and there on "the googles," but they're all WAY more involved than what I want. Everyone wants to display a full list of character attribute changes with each level-up. I just want there to be SOME way of the player knowing they have a new skill, because sometimes it's important to the game's puzzle mechanics (i.e. use "Feat Of Strength" skill to roll boulder on map).

 

P.S.: By the way, I used to hang around on the RPG Revolution forums a couple years back.

Edited by TriangleGM

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I'm just strolling on RPG Revolution. You wouldn't know me :p

However, I'm still sad when the site died. Seriously, no announcement or whatsoever :annoyed:

 

Anyway, for your problem, have you tried "@newskill_window.dispose"?

 

Place it on the correct place and your script is done. :shifty:

Share this post


Link to post
Share on other sites
  • 0

Woohoo! Thanks! That led me on the right path to finding out more about windows, as well. I did a lot of research yesterday in the RMXP help files, other tutorials online, etc, but some basic functions of the RGSS still seem elusive. I also found that using the event script command is an easy way to test my understanding of things without having to mess-up the actual game scripts. That helped.

 

I'm still having a little trouble controlling the display of windows in conjunction with program control, but I think I have most of the other scripting figured out. I did realize that I was going to need a slightly more complex plan, but the windows themselves still seem to be the hard part. My plan for now is to use an until Input.trigger?(Input::C) to loop refreshing each window one at a time. Outside of Event based messages, I couldn't find a standered term for making the game wait for a keypress between windows, so I'm hoping this will work. Right now all my plans are written in text files that I'll have to transfer this evening. If there's a better/more typical way to control progressing through multiple windows one at a time, that would be good to know. Otherwise, I THINK I've got it figured out, and I'll post up my final scripts if/when I get it working.

Thanks for the help!

Share this post


Link to post
Share on other sites
  • 0

Well, the code is a lot "messier" than I'd like, but it's done and it works! Each party member is handled one at a time with their own unique window. I had hoped to make it a BIT more professional looking via arrays and loops, but hey, I'm not a professional.

There are a few lines that needed to be inserted into Game_Actor and Battle_Scene, but most of it is off in its own script like it should be.

[spoiler=New Window Code]

#==============================================================================
# ** Window_LearnSkill
#------------------------------------------------------------------------------
#  This window displays new skills learned at the end of a battle.
#==============================================================================

class Window_NewSkill < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor, lessons)
    @student = actor
    @lessons = lessons
    super(160, 0, 320, @lessons.size * 32 + 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.y = 160 - height / 2
    self.back_opacity = 160
    self.visible = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    x = 4
    self.contents.font.color = system_color
    cx = contents.text_size(@student.name).width
    self.contents.draw_text(x, 0, cx, 32, @student.name)
    x += cx + 4
    self.contents.font.color = system_color
    cx = contents.text_size("learned").width
    self.contents.draw_text(x, 0, cx, 32, "learned")
    x = 8
    y = 32
    for l in @lessons
      self.contents.font.color = normal_color
      cx = contents.text_size(l).width
      self.contents.draw_text(x, y, cx, 32, l)
      y += 32
    end
  end
end

 

 

[spoiler=New Battle Scene Methods]

class Scene_Battle
  def roll_call
    # Clear current New Skill window
    if $game_party.actors[0] != nil
      if @leswin0.visible == true
      $game_party.actors[0].new_lessons = false
      $game_party.actors[0].lessons.clear
      @leswin0.visible = false
      end
    end
    if $game_party.actors[1] != nil
      if @leswin1.visible == true
      @leswin1.visible = false
      $game_party.actors[1].lessons.clear
      $game_party.actors[1].new_lessons = false
      end
    end
    if $game_party.actors[2] != nil
      if @leswin2.visible == true
      @leswin2.visible = false
      $game_party.actors[2].lessons.clear
      $game_party.actors[2].new_lessons = false
      end
    end
    if $game_party.actors[3] != nil
      if @leswin3.visible == true
      @leswin3.visible = false
      $game_party.actors[3].lessons.clear
      $game_party.actors[3].new_lessons = false
      end
    end
    # Display next New Skill window
    if $game_party.actors[0] != nil
      if $game_party.actors[0].new_lessons == true
      @leswin0.visible = true
      $game_system.se_play($data_system.decision_se)
      return
      end
    end
    if $game_party.actors[1] != nil
      if $game_party.actors[1].new_lessons == true
      @leswin1.visible = true
      $game_system.se_play($data_system.decision_se)
      return
      end
    end
    if $game_party.actors[2] != nil
      if $game_party.actors[2].new_lessons == true
      @leswin2.visible = true
      $game_system.se_play($data_system.decision_se)
      return
      end
    end
    if $game_party.actors[3] != nil
      if $game_party.actors[3].new_lessons == true
      @leswin3.visible = true
      $game_system.se_play($data_system.decision_se)
      return
      end
    end
    # End battle reached when no windows need to be displayed
      battle_end(0)
  end

  def update_phase6
    if Input.trigger?(Input::C)
      roll_call
      return
    end
  end
end

 

 

Game_Actor has two new public access variables:

lessons[] (array for names of skills to put in windows)

new_lessons = boolean

Both are used in the Game_Actor class when skills are learned. As each skill is learned, the lessons[] gets pushed the names of the skills, and then new_lessons is set to true.

 

Battle_Scene actually creates the windows themselves at the end of phase5 before moving to the new phase6, which is in the new separate script.

 

Thanks for the help, it really got me looking at the right things. Also, I checked out some of your stuff. You draw better than I do! :)

 

P.S.: In the end I had to settle for using window.visible = false to get rid of the windows. I don't know why, but once I got everything set up it started giving me an error when I tried to use window.dispose. It popped up with "ERRER! window disposed!" I was like, "yeah, I know! What's your point?!"

Edited by TriangleGM

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...