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.

A Little help with writing my first script

this the first time I actually dived deep into the scripting scene so bare with me.
I am making a character customization script to replace level ups and need to know exactly how I would go about this

Here is the Script
Code:
#==========================================================
# Character Customization
# Version 0.01
# By Michael aka Twilight
#------------------------------------------------------------------------------
# Use experience points to customize your character
#==========================================================
#
# - In Game Directions -
#
# Press left to decrease or right to increase the stat, Press Up or Down to change what stat you are 
# upgrading. Press the C key to finalize all changes, press B to leave without saving.
#
#--------------------------------------------------------------------------------------------------------------------
#
# - Script Customization Directions -
# 
# - Parameter Increase -
#
# Direct Increase Per Level 
# Note: This is how much the parameter increases with every level. Increases by a set amount
# Actor ID { stat => direct increase,... }
#
# Percent Increase Per Level
# Note: This increase a stat for every level by a percent
# Actor ID { stat => percent increase,... }
#
#--------------------------------------------------------------------------------------------------------------------
#
# Cost Per Level
# Note: This affects how much extra experience is needed for the next level of the skill
#
# Direct Increase
# Actor ID { Stat => Cost Increase,... }
# Skill ID
# Percent Increase
# Actor ID { Stat => Cost Increase,... }
#
#--------------------------------------------------------------------------------------------------------------------
#
# Level Max
# Set the maximum level for a stat
# Actor ID { Stat => Max }
#
#--------------------------------------------------------------------------------------------------------------------
#
# Free Customization 
# Enables or Disables the ability to regain stat points after they have already been set
# This basically allows you to lower a stat and get the experience for that stat back
# Free_Customization = false
#
#==========================================================

  module Character_Customization
    Character_Customization:HP_Direct
    Character_Customization:HP_Percent
    Character_Customization:SP_Direct
    Character_Customization:SP_Percent
    Character_Customization:Str_Direct
    Character_Customization:Str_Percent
    Character_Customization:Dex_Direct
    Character_Customization:Dex_Percent
    Character_Customization:Agi_Direct
    Character_Customization:Agi_Percent
    Character_Customization:Int_Direct
    Character_Customization:Int_Percent
    Character_Customization:Atk_Direct
    Character_Customization:Atk_Percent
    Character_Customization:Def_Direct
    Character_Customization:Def_Percent
    Character_Customization:Mdf_Direct
    Character_Customization:Mdf_Percent
    Character_Customization:Eva_Direct
    Character_Customization:Eva_Percent
    Character_Customization:Cost_Direct
    Character_Customization:Cost_Percent
 
I see that you are going with the module with constants setup, good.

Let me make some things clear, since I am a bit confused.

1) This script is for stat levels, you use exp to increase them and when they go up a level it will increase by the value Direct Increase Per Level and the percentage will go up by Percent Increase Per Level.

2) The exp required to level up a stat is defined in the Cost per Level constants.

3) The Stat Levels also have a maximum level defined in the constant Level Max.
[/FONT]
 
Oooh, no, no, no. Haven't you seen how its done :P since you are already in the module you can drop off the (module_name):: (also its two colons)

Code:
module Character_Customization
  HP_Direct
  HP_Percent
  SP_Direct
  SP_Percent
  Str_Direct
  Str_Percent
  Dex_Direct
  Dex_Percent
  Agi_Direct
  Agi_Percent
  Int_Direct
  Int_Percent
  Atk_Direct
  Atk_Percent
  Def_Direct
  Def_Percent
  Mdf_Direct
  Mdf_Percent
  Eva_Direct
  Eva_Percent
  Cost_Direct
  Cost_Percent
end

Ok, now by the way you have it setup it would be best to use a hash with the actor_id as a key and the value as the value.
 
Thanks Trickster, this is what I have so far, now all I need to do is code the bulk of the code :-/

Code:
#==========================================================
# Character Customization
# Version 0.01
# By Michael aka Twilight
#---------------------------------------------------------------------------
# Use experience points to customize your character
#==========================================================
#
# - In Game Directions -
#
# Press left to decrease or right to increase the stat, Press Up or Down to change what stat you are 
# upgrading. Press the C key to finalize all changes, press B to leave without saving.
#
#--------------------------------------------------------------------------------------------------------------------
#
# - Script Customization Directions -
# 
# - Parameter Increase -
#
# Direct Increase Per Level 
# Note: This is how much the parameter increases with every level. Increases by a set amount
# Actor ID { stat => direct increase}
#
# Percent Increase Per Level
# Note: This increase a stat for every level by a percent
# Actor ID { stat => percent increase}
#
#--------------------------------------------------------------------------------------------------------------------
#
# Cost Per Level
# Note: This affects how much extra experience is needed for the next level of the skill
#
# Direct Increase
# Actor ID { Stat => Cost Increase,... }
# 
# Percent Increase
# Actor ID { Stat => Cost Increase,... }
#
#--------------------------------------------------------------------------------------------------------------------
#
# Level Max
# Set the maximum level for a stat
# Actor ID { Stat => Max,... }
#
#--------------------------------------------------------------------------------------------------------------------
#
# Free Customization 
# Enables or Disables the ability to regain stat points after they have already been set
# This basically allows you to lower a stat and get the experience for that stat back
# Free_Customization = false
# Note - For Version 2.0
#==========================================================

  module Character_Customization
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    HP_Direct = {
    1 => 100,
    2 => 85
    }
    HP_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    SP_Direct = {
    }
    SP_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Str_Direct = {
    }
    Str_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Dex_Direct = {
    }
    Dex_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Agi_Direct = {
    }
    Agi_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Int_Direct = {
    }
    Int_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Atk_Direct = {
    }
    Atk_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Def_Direct = {
    }
    Def_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Mdf_Direct = {
    }
    Mdf_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Eva_Direct = {
    }
    Eva_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Cost_Direct = {
    1 => { 'maxhp' => 100}
    }
    Cost_Percent = {
    }
    #-----------------------------------------------------------------------------------------------------------------
    #
    #-----------------------------------------------------------------------------------------------------------------
    Level_Max = {
    1 => { 'maxhp' => 100, 'mdf' => 99}
    }
  end

Basically I want the script to Raise or Lower the characters stats if they have enough exp to do so. Also, with every stat level, the experience cost would increase by a amount that can be setup in the script. The Max Levels would set a maximum stat level so that characters wont have things like HP Lvl 3421
I would also like to input the option to enable or disable the ability to Lower the stats as well as disable the level up system altogether

The Way the script works is this
The character enters the menu. They would press up or down in order to select the parameter. after highlighting the stat they want to edit they would press the C button that allows them to raise or lower the stat by pressing right or left respectively. Pressing B would cancel out the menu and Pressing C would finalize the options made by the player.

Here is a Mock Up of the Menu
http://i52.photobucket.com/albums/g13/Mega_Man_Trigger/untitled-1.png[/IMG]
 
As I said, all of this will be done in a new Scene, all you have to do is create the windows you have in your mockup. Now Use of the the default Scenes as your base and start butchering and hacking it until you get it to work the way you like.

As for your (Stat)_(Direct|Percentage) Constants it may be easier to use my Curve Generator since you have the format level => value

Well you will have to create more constants for the description of each parameter, since I see that you want to display that information.

Add variables in Game_Actor for the exp for each parameter and the next level for each stat.

Also note that Window 4 should be a Command Window

now to reference the constants in the module you created do
Character_Customization::(Constant) although I would shorten the length of the module name for neatness.

Now don't disappoint me :thumb: any other questions just reply
 

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