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.

Point Allocating System for Attributes (STR, DEX, AGI, INT)

What I want is a way to make it so that when you level up, you get a number of points to allocate into your attributes such as Strength, Dexterity, Agility, and Intelligence.  Any way to make that happen?  I assume that it's similar in scripting to the Skill Point Allocating System.
 
I might have a script that could do that and believe it also provides synergies such as health and magic/mana increase depending on the stat increase.

EDIT: Here it is, there's basic tutorial within the script so you should be able to figure it out. Be sure to give credit to the creator of the script

Code:
#------------------------------------------------------------------------------#
# MMORPG Leveling System V1.1
# Author: Lettuce
# Last update: 23 Dec 2006
# Fixed and Added: 
#       bar used HP information - Fixed
#       [Extra effect] Stats can now effect the HP and SP - Added
#       Help windows shows the extra effect - Added
#        
# Features: Allow your charactor to use points to increase their stats
#           Can add points through events
#           Can be used as a bonus points in addition to the default level system
#           Points are NOT shared between the actors in the party
#           Very customizable
#           (...that's not alot of feature >_>")
# Instructions:
# - You should change the values in the Config section (just below here) to fit
#   your needs
#     FONTFACE and FONTSIZE is pretty obvious
#     STAT_CAP = The maximum value for str,agi,dex and int that your game allows
#     STAT_CAP2 = same as STAT_CAP but this is for pdef, mdef, atk and eva
#     Y_OFFSET and X_OFFSET = change value to change the layout (I would leave
#                             it as it is though)
#     INCREASE_BY = this determines how many points (agi,dex etc) will go up 
#                   for each of the points)
#*** $actors_points = this array is for storing the points for each actor, not
#                      just the ones in your party, but ALL of your actors, so
#                      if you have 5 actors in the game, there should be 5 zero's
# 
# - Press L and R to change between actors
#
#  *******Warning! Once you add the points to a stat, it's PERMANENT!*******
#
#** Add points to actors by using call script and use this:
#    $actors_points[actorID] += AmountOfPoints 
# (replace actorID with the actual ID of the actor,and replace AmountOfPoints
# with a number <3
#
#** If you want to add points when your actor levels, go to Scene_Battle 2 and 
#   find:      if actor.level > last_level
#   and paste this just under it: $actors_points[actorID] += AmountOfPoints * (actor.level - last_level)
#   (don't forget to change the value ^.^)
#
# most of the stuff are pretty obvious of what it does, so if you are not happy
# about the position/colour etc of things, just change the value there <3
#
#Credits: Dubealex - for his pwnage tutorials
#         Leon - I got the layout idea from him <3
#         Samamanjaro - for pointing out a bug
#------------------------------------------------------------------------------#



#----- Config.
FONTFACE = "Tahoma"  #font used in all the windows
FONTSIZE = 22        #font size
STAT_CAP = 9000       #Maximum value for str,agi,dex and int
STAT_CAP2 = 1000     #Maximum value for pdef mdef atk and eva
Y_OFFSET = 10        #incase you want to move some stuff down ^^
X_OFFSET = -80       #incase you want to move stuff across~
INCREASE_BY = 5      #when you spend 1 points, how much do that stat go up

STR_INCREASES = [0.8,0]   #1 point in STR will increase(in %) hp and sp
DEX_INCREASES = [0.8,0.8]   #for example when STR_INCREASES = [10,5]
AGI_INCREASES = [2,2]   #it increases 10% hp and 5% sp for every points you spend in STR
INT_INCREASES = [0,2]   #same goes for the other 3 :D

#--- Don't change this line =[] ---
$actors_points = [0,0,0,0,0,0,0,0,0,0] #this thing here stores the points for actors


#----- Status block 1, displays actors info
class Status_Window_1 < Window_Base
  def initialize
    super(0,0,400,480)
    self.contents = Bitmap.new(width-32,height-32)
    self.contents.font.name = FONTFACE
    self.contents.font.size = FONTSIZE
    update(0)
  end
  
  
  def update(actor_index)    
    self.contents.clear
    
    if actor_index == nil
      actor_index = 0
    end
    
    actor = $game_party.actors[actor_index]
    self.contents.draw_text(0,0,200,32,"Name: " + actor.name.to_s)
    self.contents.draw_text(0,32,100,32,"Level: " + actor.level.to_s)
    self.contents.draw_text(200,32,200,32,"Class: " + actor.class_name.to_s)
    draw_actor_graphic(actor,32,128)
    
    self.contents.draw_text(96, 64, 200, 32, "HP: " + actor.hp.to_s + "/" + actor.maxhp.to_s)
    draw_bar(96,88,200,5,actor.hp,actor.maxhp,14,99)
    
    self.contents.draw_text(96, 96, 200, 32, "SP: " + actor.sp.to_s + "/" + actor.maxsp.to_s)
    draw_bar(96,120,200,5,actor.sp,actor.maxsp,19,99)
    
    self.contents.draw_text(96, 128, 200, 32, "EXP: " + actor.exp_gained.to_s + "/" + actor.exp_needed.to_s)
    draw_bar(96,152,200,5,actor.exp_gained,actor.exp_needed,16,99)
    
    self.contents.draw_text(96 + X_OFFSET, 160 + Y_OFFSET, 200, 32, "STR: " + actor.str.to_s + "/" + STAT_CAP.to_s)
    draw_bar(96 + X_OFFSET,184 + Y_OFFSET,200,5,actor.str,STAT_CAP,21,99)
    
    self.contents.draw_text(96 + X_OFFSET, 192 + Y_OFFSET, 200, 32, "DEX: " + actor.dex.to_s + "/" + STAT_CAP.to_s)
    draw_bar(96 + X_OFFSET,216 + Y_OFFSET,200,5,actor.dex,STAT_CAP,18,99)
    
    self.contents.draw_text(96 + X_OFFSET, 224 + Y_OFFSET, 200, 32, "CON: " + actor.agi.to_s + "/" + STAT_CAP.to_s)
    draw_bar(96 + X_OFFSET,248 + Y_OFFSET,200,5,actor.agi,STAT_CAP,15,99)
    
    self.contents.draw_text(96 + X_OFFSET, 256 + Y_OFFSET, 200, 32, "INT: " + actor.int.to_s + "/" + STAT_CAP.to_s)
    draw_bar(96 + X_OFFSET,280 + Y_OFFSET,200,5,actor.int,STAT_CAP,10,99)
    
    
    
    
    self.contents.draw_text(96 + X_OFFSET, 300 + Y_OFFSET, 200, 32, "ATK: " + actor.atk.to_s + "/" + STAT_CAP2.to_s)
    draw_bar(96 + X_OFFSET,324 + Y_OFFSET,200,5,actor.atk,STAT_CAP2,21,99)
    
    #self.contents.draw_text(96 + X_OFFSET, 332 + Y_OFFSET, 200, 32, "EVA: " + actor.eva.to_s + "/" + STAT_CAP2.to_s)
    #draw_bar(96 + X_OFFSET,356 + Y_OFFSET,200,5,actor.eva,STAT_CAP2,18,99)
    
    self.contents.draw_text(96 + X_OFFSET, 332 + Y_OFFSET, 200, 32, "PDEF: " + actor.pdef.to_s + "/" + STAT_CAP2.to_s)
    draw_bar(96 + X_OFFSET,356 + Y_OFFSET,200,5,actor.mdef,STAT_CAP2,15,99)
    
    self.contents.draw_text(96 + X_OFFSET, 364 + Y_OFFSET, 200, 32, "MDEF: " + actor.mdef.to_s + "/" + STAT_CAP2.to_s)
    draw_bar(96 + X_OFFSET,388 + Y_OFFSET,200,5,actor.pdef,STAT_CAP2,10,99)
    
    self.contents.font.color = cc(1)
    self.contents.draw_text(45 , 396 + Y_OFFSET, 400, 32, "**Stats changes are permanent**")
    self.contents.font.color = cc(99)
    
  end
  
end    

#------ Status block 2 , displays points

class Status_Window_2 < Window_Base
  
  def initialize
    super(0,0,240,75)
    self.contents = Bitmap.new(width-32,height-32)
    self.contents.font.name = FONTFACE
    self.contents.font.size = FONTSIZE - 4
  end
  
  def update(actor_id)
    actor = $game_party.actors[actor_id].id - 1
    if actor_id == nil
      actor = 0
    end
    self.contents.clear
    self.contents.draw_text(0,0,100,32, "Points left: " + $actors_points[actor].to_s)
  end
  
end


#------ Status block 3, help box =D

class Status_Window_3 < Window_Base
  
  def initialize
    super(0,0,240,180)
    self.contents = Bitmap.new(width-32,height-32)
    self.contents.font.name = FONTFACE
    self.contents.font.size = FONTSIZE - 4
  end
  
  def update(text_set)
    self.contents.clear
    case text_set
    when 0
      self.contents.draw_text(0,0,210,32,"Increase STR by " + INCREASE_BY.to_s + " point(s)")
      self.contents.draw_text(0,22,210,32,"Increase HP by " + STR_INCREASES[0].to_s + " %")
      self.contents.draw_text(0,44,210,32,"Increase SP by " + STR_INCREASES[1].to_s + " %")
      self.contents.draw_text(0,76,210,32,"     Description:")
      self.contents.draw_text(0,98,210,32,"Boosts Physical Damage")
    when 1
      self.contents.draw_text(0,0,210,32,"Increase DEX by " + INCREASE_BY.to_s + " point(s)")
      self.contents.draw_text(0,22,210,32,"Increase HP by " + DEX_INCREASES[0].to_s + " %")
      self.contents.draw_text(0,44,210,32,"Increase SP by " + DEX_INCREASES[1].to_s + " %")
      self.contents.draw_text(0,76,210,32,"     Description:")
      self.contents.draw_text(0,98,210,32,"Increases luck, and range skills")
    when 2
      self.contents.draw_text(0,0,210,32,"Increase CON by " + INCREASE_BY.to_s + " point(s)")
      self.contents.draw_text(0,22,210,32,"Increase HP by " + AGI_INCREASES[0].to_s + " %")
      self.contents.draw_text(0,44,210,32,"Increase SP by " + AGI_INCREASES[1].to_s + " %")
      self.contents.draw_text(0,76,210,32,"     Description:")
      self.contents.draw_text(0,98,210,32,"Boosts Health")
    when 3
      self.contents.draw_text(0,0,210,32,"Increase INT by " + INCREASE_BY.to_s + " point(s)")
      self.contents.draw_text(0,22,210,32,"Increase HP by " + INT_INCREASES[0].to_s + " %")
      self.contents.draw_text(0,44,210,32,"Increase SP by " + INT_INCREASES[1].to_s + " %")
      self.contents.draw_text(0,76,210,32,"     Description:")
      self.contents.draw_text(0,98,210,32,"Increases Magic Performance")
    end
  end
  
end



#------ Stats Upgrading SCENE ------
#...Here comes the complicated bit!!!

class Scene_Stats_Upgrade
  @@actor = 0
  
  def initialize(menu_index = 0)
    @menu_index = menu_index      
  end
  
  
  def main
    
    @window_1 = Status_Window_1.new
    @window_1.update(@@actor) #Begins with actor 1
    
    @window_2 = Status_Window_2.new
    @window_2.x = 400
    @window_2.y = 225
    @window_2.update(@@actor)
    
    @window_3 = Status_Window_3.new
    @window_3.x = 400
    @window_3.y = 300
    
    
    s1 = "Add " + INCREASE_BY.to_s + " point(s) to STR"
    s2 = "Add " + INCREASE_BY.to_s + " point(s) to DEX"
    s3 = "Add " + INCREASE_BY.to_s + " point(s) to CON"
    s4 = "Add " + INCREASE_BY.to_s + " point(s) to INT"
    
    @window_4 = Window_Command.new(240, [s1,s2,s3,s4]) #Remember, 200 is the Width
    @window_4.y = 0 #Set a position for the menu other than 0:0
    @window_4.x = 400
    @window_4.height=225 #Force a new height for the menu window
    @window_4.index = @menu_index
    
    
    #update yerself bish!
    Graphics.transition
    loop do
       Graphics.update
       Input.update
       update #update yerself bish!
       if $scene != self
          break
       end
    end


    Graphics.freeze
    @window_1.dispose
    @window_2.dispose
    @window_3.dispose
    @window_4.dispose
    
  end
    
  def update
  
   @window_4.update 
   
   case @window_4.index 
   when 0 
    @window_3.update(0) 
   when 1
    @window_3.update(1) 
   when 2
    @window_3.update(2) 
   when 3
    @window_3.update(3) 
  end  
  
#------ This bit is for navigation~
  
  if Input.trigger?(Input::C) 
    r_actor = $game_party.actors[@@actor].id - 1
   case @window_4.index 
   when 0 
    if $actors_points[r_actor] <= 0 || $game_party.actors[@@actor].str == STAT_CAP
      $game_system.se_play($data_system.cancel_se)
      else
    $game_party.actors[@@actor].str += INCREASE_BY
    @m_hp = $game_party.actors[@@actor].maxhp * (STR_INCREASES[0]/100.to_f)
    @m_sp = $game_party.actors[@@actor].maxsp * (STR_INCREASES[1]/100.to_f)
    $game_party.actors[@@actor].maxhp += @m_hp
    $game_party.actors[@@actor].maxsp += @m_sp
    $actors_points[r_actor] -= 1
    @window_1.update(@@actor)
    @window_2.update(@@actor)
    end
    
   when 1
    if $actors_points[r_actor] <= 0 || $game_party.actors[@@actor].dex == STAT_CAP
      $game_system.se_play($data_system.cancel_se)
      else
    $game_party.actors[@@actor].dex += INCREASE_BY
    @m_hp = $game_party.actors[@@actor].maxhp * (DEX_INCREASES[0]/100.to_f)
    @m_sp = $game_party.actors[@@actor].maxsp * (DEX_INCREASES[1]/100.to_f)
    $game_party.actors[@@actor].maxhp += @m_hp
    $game_party.actors[@@actor].maxsp += @m_sp
    $actors_points[r_actor] -= 1
    @window_1.update(@@actor)
    @window_2.update(@@actor)
    end 
   when 2
    if $actors_points[r_actor] <= 0 || $game_party.actors[@@actor].agi == STAT_CAP      
      $game_system.se_play($data_system.cancel_se)
      else
    $game_party.actors[@@actor].agi += INCREASE_BY
    @m_hp = $game_party.actors[@@actor].maxhp * (AGI_INCREASES[0]/100.to_f)
    @m_sp = $game_party.actors[@@actor].maxsp * (AGI_INCREASES[1]/100.to_f)
    $game_party.actors[@@actor].maxhp += @m_hp
    $game_party.actors[@@actor].maxsp += @m_sp
    $actors_points[r_actor] -= 1
    @window_1.update(@@actor)
    @window_2.update(@@actor)
    end 
   when 3
    if $actors_points[r_actor] <= 0 || $game_party.actors[@@actor].int == STAT_CAP
      $game_system.se_play($data_system.cancel_se)
      else
    $game_party.actors[@@actor].int += INCREASE_BY
    @m_hp = $game_party.actors[@@actor].maxhp * (INT_INCREASES[0]/100.to_f)
    @m_sp = $game_party.actors[@@actor].maxsp * (INT_INCREASES[1]/100.to_f)
    $game_party.actors[@@actor].maxhp += @m_hp
    $game_party.actors[@@actor].maxsp += @m_sp
    $actors_points[r_actor] -= 1
    @window_1.update(@@actor)
    @window_2.update(@@actor)
    end 
  end  
end
  
   if Input.trigger?(Input::B) 
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Map.new
     $game_map.autoplay 
   end
   
   if Input.trigger?(Input::R)
     if @@actor == 3
       @@actor = 0
     else
       @@actor += 1
     end
          
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Stats_Upgrade.new
   end

   if Input.trigger?(Input::L)
     if @@actor == 0
       @@actor = 3
     else
       @@actor -= 1
     end
          
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Stats_Upgrade.new
   end
 end
end

    
    
#------ Goodness me, that bit is over :D!
    

#------ This is for drawing bars
class Window_Base < Window
  
  def draw_bar(x,y,width,height,min_value,max_value,color,back_color)
    rect = Rect.new(x,y,width,height)
    self.contents.fill_rect(rect,cc(back_color.to_f))
        
    rect = Rect.new(x + 1, y + 1, (width - 2) * (min_value / max_value.to_f), height-2)
    self.contents.fill_rect(rect,cc(color.to_f))
  end
  
end

#------ For calculating exp
class Game_Actor < Game_Battler
     def exp_gained
          return @exp - @exp_list[@level]
     end
        
     def exp_needed
          return @exp_list[@level + 1] - @exp_list[@level]
     end
      
end
    

#------ This bit deals with saving and loading   
class Scene_Save
  
  alias lolipop write_save_data
  
  def write_data(file)
    lolipop(file)
    Marshal.dump($actors_points, file)
  end
end


class Scene_Load
  
  alias candycane read_save_data
  
  def load_data(file)
    candycane(file)
    $actors_points = Marshal.load(file)
  end
  
end
 
Is it okay if you can modify it slightly to make it so that the HP/MP boost is based on that pre-determined by the curve created for each character in the Actor database?  That thing isn't necessary for my game, no thank you.
 

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