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.

Character Advancement - Script Rewrite

Status
Not open for further replies.
Hi, I've been working on a script called Character Advancement, for my online game.

Basically, it is like an EXP shop, where you buy new skills for your player through the script.

Each "class" is a group of nine skills, and to buy a skill you must own the one before it, and pay exp to buy it, which is taken off your character.

You can switch classes in the script - basically, for all scripting purposes, each class is just a new shop. But, each class must be unlocked.

There is this for the skills:

Code:
def set_skills
    case @classes_viewing
    when 1
      $skills = [1, 2, 3, 4, 5, 6, 7, 8, 9] # This is probably wrong
      alias $level $level1 # I know for sure this is wrong
    when 2
      $skills = [3, 7, 2, 4, 6, 1, 5, 9, 8] # As above
      alias $level $level2 # As above
    end
  end

The skills are skills from the database. So, if we look at the above, the third number along in class 1 is skill number 3, unlocked at level 3 of that skill.

EXP for each skill is also defined in the script:

Code:
  def set_exp
    case @classes_viewing
    when 1
      @exp = [50, 60, 70, 80, 90, 100, 110, 120, 130]
    when 2
      @exp = [50, 60, 70, 80, 90, 100, 110, 120, 130]
    end
  end

So to unlock skill 3 in class 1, you need 70 exp, etc.

There are two windows. One shows the skills for that class, and one is a selectable window. The selectable window has three options:
- Purchase the upgrade (gives you the skill and takes away from your exp)
- Next class (simply adds 1 to @class_viewing)
- Cancel ($scene = Scene_Menu.new)





Probably everything in this script is wrong. That is why I am requesting a rewrite... I have the basics in there, even if they are scripted wrong.

Here is teh script:

Code:
class Scene_Advancement < Scene_Base
  # For use in nx:media games only
  # Dan Badger
  
  # Raise Max HP
  def raise_hp(amount)
    hp_maxmin = 99 - amount
    unless $game_actors[0].maxhp > hp_maxmin
      $game_actors[0].maxhp += amount
    end
  end
  
  # Raise Max SP
  def raise_sp(amount)
    sp_maxmin = 99 - amount
    unless $game_actors[0].maxsp > sp_maxmin
      $game_actors[0].maxsp += amount
    end
  end
  
  # Learn Skill
  def give_skill(skill)
    $game_actors[0].learn_skill(skill)
  end
  
  def main
    set_skills
    set_exp
    @classes = [0,]
    @classes.push[1] if $class1 == true
    @classes.push[2] if $class2 == true
    @class_viewing = @classes[0]
    #@window = Window_Advancement.new
    @hud = Window_HUD.new
    @spriteset = Spriteset_Map.new
    @image = Sprite.new
    @image.bitmap = RPG::Cache.picture('menu_1')
        exp_to_next = @exp[$level.to_i + 1]
      s1 = "Raise by 1 (#{exp_to_next})"
      s2 = "Next Class"
      s3 = "Cancel"
    @command = Window_Command.new(123, [s1, s2, s3, s4, s5, s6])
    @command.z = 9999
    @command.y = 145 - 16
    @command_window.x = 167 - 16
    @command_window.index = 0
    
    Graphics.transition
    
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    
    #@window.dispose
    @hud.dispose
    @spriteset.dispose
    @image.dispose
  end
  
  def update
    set_skills
    set_exp
    #@window.update
    @hud.update
    update_command
  end
  
  def set_skills
    case @classes_viewing
    when 1
      $skills = [1, 2, 3, 4, 5, 6, 7, 8, 9]
      alias $level $level1
    when 2
      $skills = [3, 7, 2, 4, 6, 1, 5, 9, 8]
      alias $level $level2
    end
  end
  
  def set_exp
    case @classes_viewing
    when 1
      @exp = [50, 60, 70, 80, 90, 100, 110, 120, 130]
    when 2
      @exp = [50, 60, 70, 80, 90, 100, 110, 120, 130]
    end
  end
  
  def charge_exp
    charge = @exp_costs[$level]
    min = 0 + charge
    $game_actors[0].now_exp -= charge unless $game_actors[0].now_exp < min
    skill_give = $skills[$level]
    give_skill(skill_give)
    $level += 1
  end
  
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new
      return
    end
    if Input.trigger?(Input::C)
      exp_got = $game_actors[0].now_exp
      if $game_party.actors.size == 0 and @exp[$level + 1] >= exp_got
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        charge_exp
        $level += 1
      when 1
        $game_system.se_play($data_system.decision_se)
        @classes_viewing += 1
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Menu.new
      end
      return
    end
  end

end

class Window_Advancement < Window_Base
  def initialize
    super(20-16, 19-16, 300, 300)
    self.contents = Bitmap.new(width-32, height-32)
    self.z = 9999
    refresh
  end
  def refresh
    for i in 0..$skills
      text = $skills[i].to_s
      self.contents.draw_text(0, i * 16, 0, 200, 16, "#{text}")
    end
  end
end



Thanks very much if you can do this. I will add you in the credits as a scripter/programmer. Please note that the game is commercial.
 
There are many errors in your script, but I think I'll leave them since you want a rewrite and to leave this thread stick into requesting, not into RGSS support :)

Your system is interesting, but I still don't get it. How do I unlock a new class? Via the same script or you already handle it? And I still don't understand about unlocking new skills. Can I unlock skill #9 if I haven't unlocked skill # 8?

So, if we look at the above, the third number along in class 1 is skill number 3, unlocked at level 3 of that skill.
Which skill did you refer to?
 
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