A script to learn: Difficulty System

● ARCHIVED · READ-ONLY
Started by Bloodmorphed 20 posts View original ↗
  1. I do not want too much help on this, if it's done for me I won't learn.

    However, how do I find out how to manipulate enemy stats via scripts (in battle).

    Now I have a system in mind, and I plan on starting to write the script soon, but I need to a few things:

    Script calls on enemy stats, and script calls on having enemy's learn skills based on the system (This will probably be done by note tags).

    Secondly the script call for control variables (I think this is what I'm going for).

    For example here is what the set-up will look like:

    control_variable = 100

    easy = 0

    normal = 1

    hard = 2

    insane = 3

    if easy

    blah blah blah

    etc etc.

    You get the point, I think.

    EDIT: Also this is only a side project as I'm doing something far more important. But I would still like to get a simple one up and going before going too advanced.
  2. Thank you :)
  3. No problem. If you have any other questions feel free to ask :)
    ~ Param mods are my favorite :D
  4. Hmm, I know how to find the variable, but I don't know how to track the number assigned to the variable.

    For example:

    #--------#Script By: Bloodmorphed#Difficulty Script v0.1##--------#-----------------# Which Variable is your difficulty one?#-----------------difficulty_variable = 100#-------------#Difficulty Names#-------------easy = 0normal = 1hard = 2insane = 3#===============================================================================class Game_Enemy#===============================================================================  #-----------------------------------------------------------------------------  # List Of Aliased Methods  #-----------------------------------------------------------------------------  alias :bloody_param :param  #-----------------------------------------------------------------------------  # Method to determine value of actors params  #-----------------------------------------------------------------------------  def param(param_id)    bloody_param (param_id)  end  end
    Doing it this way, I need this

    When Easy is picked, variable 100 is set to 0. I obviously will be doing this from events. But inside the code I need to be able to recognized variable 100 has a number assigned to it.
  5. Well I know that but... I'm confused on how to actually FIND it. Would it be like

    if $game.variables[difficulty_variable] == 0

     Blah Blah

    Would that be how to do it?
  6. yep you are on the right way.

    if $game_variables[difficulty_variable] == 0elsif $game_variables[difficulty_variable] == 1# and so on...Also, by using a lower case letter as what should be a constant, ie,

    #-----------------# Which Variable is your difficulty one?#-----------------difficulty_variable = 100#-------------#Difficulty Names#-------------easy = 0normal = 1hard = 2insane = 3These should not be written like this. IF anything they should at least be Constants, meaning they begin with an upper case letter. As it stands, you are creating local variables with a global range. Thats pointless (sorry).
    Instead, you should do smething like this...

    module Module_Name  Constant_Name = 123end # module endand then to call that , rather than using only the variable name, (ie, 'difficulty_variable') you would do this.

    Module_Name::Constant_NameIt works in a much better way than just leaving things 'lying around in the open' .

    And its a much neater way. :)
  7. So if I did that it would change to:

    if $game_variables[Module_Name::Constant_Name] == 0

    etc etc

    Right?

    The only problem is, I want to you know, have a configuration section where people can easily edit which variable, and the multiplier. 

    Hmm, I'll see what I can do.

    EDIT:

    Okay I have my script:

    #--------#Script By: Bloodmorphed#Difficulty Script v0.1##--------#-----------------# Determines what variable, and which multiplier.#-----------------module Bloody_Difficulty  Difficulty_Variable = 100  Easy = 0.5  Normal = 1  Hard = 2  Insane = 4end #module end#===============================================================================class Game_Enemy#===============================================================================  #-----------------------------------------------------------------------------  # List Of Aliased Methods  #-----------------------------------------------------------------------------  alias :bloody_param :param  #-----------------------------------------------------------------------------  # Method to determine value of actors params  #-----------------------------------------------------------------------------  def param(param_id)    bloody_param (param_id)  end  end## Normal Difficulty#if $game_variables[Bloody_Difficulty::Difficulty_Variable] == 1  def param(param_id)    (bloody_param (param_id) * Bloody_Difficulty::Normal)  end #end def ## Hard Difficulty#elsif $game_variables[Bloody_Difficulty::Difficulty_Variable] == 2  def param(param_id)    (bloody_param (param_id) * Bloody_Difficulty::Hard)  end #end def ## Insane Difficulty#elsif $game_variables[Bloody_Difficulty::Difficulty_Variable] == 3  def param(param_id)    (bloody_param (param_id) * Bloody_Difficulty::Insane)  end #end def ## Easy Difficulty#else  def param(param_id)    (bloody_param (param_id) * Bloody_Difficulty::Easy)  end #end defend #ends if statement
    But :param gives me an error

    o8c91R9.png
  8. That is excessive.
    You would want to be checking the if/else statements inside the method - param.

    like umm...

      def param(param_id)    if $game_variables[Bloody_Difficulty::Difficulty_Variable] == 1      (bloody_param(param_id) * Bloody_Difficulty::Normal).to_i    elsif      #...    end #end else/if  endthe '.to_i' makes sure it reutns an integer value , like 1,2,3,4 rather than a decimal value.

    Also, if you really want to learn to code i would recommend searching for a guide on the basics of ruby coding. It would help alot with the understanding of how things work and the best ways to implement them :)
  9. I understand that, I've read the basics from Code Academy and did their exercises. I just need practice and stuff, but here is the new one

    #--------#Script By: Bloodmorphed#Difficulty Script v0.1##--------#-----------------# Determines what variable, and which multiplier.#-----------------module Bloody_Difficulty  Difficulty_Variable = 100  Easy = 0.5  Normal = 1  Hard = 2  Insane = 4end #module end#===============================================================================class Game_Enemy#===============================================================================  #-----------------------------------------------------------------------------  # List Of Aliased Methods  #-----------------------------------------------------------------------------  alias :bloody_param :param  #-----------------------------------------------------------------------------  # Method to determine value of actors params  #-----------------------------------------------------------------------------  def param(param_id)    bloody_param (param_id)  end  end###def param(param_id)  if $game_variables[Bloody_Difficulty::Difficulty_Variable] == 1    (bloody_param(param_id) * Bloody_Difficulty::Normal).to_i  elsif $game_variables[Bloody_Difficulty::Difficulty_Variable] == 2    (bloody_param(param_id) * Bloody_Difficulty::Hard).to_i  elsif $game_variables[Bloody_Difficulty::Difficulty_Variable] == 3    (bloody_param(param_id) * Bloody_Difficulty::Insane).to_i  else    (bloody_param(param_id) * Bloody_Difficulty::Easy).to_i  end #ends else/ifend #ends def
    But I'm still getting the param error from my above post, from the screen shot.
  10. One problem with that script is that you are ending the definition of Game_Enemy class too early,  delete the first definition of the method 'param' and everything up until the next method starts.

    The method 'param' definitely exists for Game_Enemy. It is inherited from Game_BatterBase via Game_Battler. This can be found at line 267 in the Game_BattlerBase script page within the script editor.

    Also - where exactly are you placing the script within the script editor? ..
  11. Dekita said:
    One problem with that script is that you are ending the definition of Game_Enemy class too early,  delete the first definition of the method 'param' and everything up until the next method starts.
    Huh? 

    And I had it where it didn't need to be, I changed that. I had thought it was under the materials, but it wasn't. I fixed it.

    I'm assuming you wanted me to do this:

    #--------#Script By: Bloodmorphed#Difficulty Script v0.1##--------#-----------------# Determines what variable, and which multiplier.#-----------------module Bloody_Difficulty  Difficulty_Variable = 100  Easy = 0.5  Normal = 1  Hard = 2  Insane = 4end #module end#===============================================================================class Game_Enemy#===============================================================================  #-----------------------------------------------------------------------------  # List Of Aliased Methods  #-----------------------------------------------------------------------------  alias :bloody_param :param  #-----------------------------------------------------------------------------  # Method to determine value of actors params  #----------------------------------------------------------------------------- ###def param(param_id)  bloody_param (param_id)  if $game_variables[Bloody_Difficulty::Difficulty_Variable] == 1    (bloody_param(param_id) * Bloody_Difficulty::Normal).to_i  elsif $game_variables[Bloody_Difficulty::Difficulty_Variable] == 2    (bloody_param(param_id) * Bloody_Difficulty::Hard).to_i  elsif $game_variables[Bloody_Difficulty::Difficulty_Variable] == 3    (bloody_param(param_id) * Bloody_Difficulty::Insane).to_i  else    (bloody_param(param_id) * Bloody_Difficulty::Easy).to_i  end #ends else/ifend #ends defend #ends class
    Either way, it works now.
  12. Yeap, its a little messy and somewhat inefficient. But you are almost there :)

    Here is why.

    #===============================================================================class Game_Enemy#===============================================================================  #-----------------------------------------------------------------------------  # List Of Aliased Methods  #-----------------------------------------------------------------------------  alias :bloody_param :param  #-----------------------------------------------------------------------------  # Method to determine value of actors params  #-----------------------------------------------------------------------------  def param(param_id)#  bloody_param (param_id) # < no need to check this line here.  if $game_variables[Bloody_Difficulty::Difficulty_Variable] == 1    (bloody_param(param_id) * Bloody_Difficulty::Normal).to_i    elsif $game_variables[Bloody_Difficulty::Difficulty_Variable] == 2      (bloody_param(param_id) * Bloody_Difficulty::Hard).to_i    elsif $game_variables[Bloody_Difficulty::Difficulty_Variable] == 3      (bloody_param(param_id) * Bloody_Difficulty::Insane).to_i    else      (bloody_param(param_id) * Bloody_Difficulty::Easy).to_i    end #ends else/if  end #end method end #ends classAlso, you could use a case statement to check the variable faster and nicer..

    like this..

        case $game_variables[Bloody_Difficulty::Difficulty_Variable]    when 1 then (bloody_param(param_id) * Bloody_Difficulty::Normal).to_i    when 2...    end
    I await your new code :D
  13. Okay, so this starting to clean up a bit. Unfortunately, what I want to do next is going to be.. well.. lets say... messy. Lol

    Here it is:

    Code:
    #--------#Script By: Bloodmorphed#Difficulty Script v0.1##--------#-----------------# Determines what variable, and which multiplier.##Feel free to edit these. Make sure you are using the right varibale!#-----------------module Bloody_Difficulty  Difficulty_Variable = 100 # Which variable to use? Default is 100  Easy = 0.5 #Easy difficulty multiplier. Default is 0.5  Normal = 1 #Normal difficulty multiplier. Default is 1  Hard = 2 #Hard difficulty multiplier. Default is 2  Insane = 4 #Insane difficulty multiplier. Default is 4end #module end#===============================================================================class Game_Enemy#===============================================================================  #-----------------------------------------------------------------------------  # List Of Aliased Methods  #-----------------------------------------------------------------------------  alias :bloody_param :param  #-----------------------------------------------------------------------------  # Method to determine value of enemies params based on difficulty.  #----------------------------------------------------------------------------- def param(param_id)  case $game_variables[Bloody_Difficulty::Difficulty_Variable]    when 0 then (bloody_param(param_id) * Bloody_Difficulty::Easy).to_i    when 1 then (bloody_param(param_id) * Bloody_Difficulty::Normal).to_i    when 2 then (bloody_param(param_id) * Bloody_Difficulty::Hard).to_i    when 3 then (bloody_param(param_id) * Bloody_Difficulty::Insane).to_i  end #ends caseend #ends defend #ends class
  14. All thats really wrong with it is the indentation on your method definition imo. and thats not really a requirement, more just a general practice kind of thing.

    So yea, there you have it. You just wrote a script and I could'nt have written it better myself... ;)

    Think this topic can be closed now? :p
  15. Haha, nope it can't because now.... I have to add another feature. There was always two parts I wanted. Parameter manipulation, and actions based on difficulty (using note-tags)

    For example.

    Slime

    Easy Difficulty: Attack

    Normal: Attack

    Hard: Attack, Fireball

    Insane: Attack, Fireball, Heal

    Now the notetages should look something like this:

    <Difficulty:Easy Attack, Always, 5>

    Etc etc

    Basically just a table inside a note-tag.

    Perhaps I should wait on this though.

    Thank you so much for your help though.

    EDIT:

    I know I could do it by events, using triggers, which would be easy I suppose. But I'd rather have it this way. I guess I could just use the event method i can do and just write the note tag stuff later.
  16. Interestingly enough, your script here inspired me to write my own difficulty script. However, instead of modifying params I modified exp gained (less on hard, more on easy). Kept the stats all the same though.

    I'll be interested to see if you can make the script do actions based on difficulty. Though, as someone who has played the old school D and D gold box games, may I suggest making that a separate feature? One thing that always irked me about the older games was a difficulty increase increased both the HP and the actions, but what if I want to deal with only the tougher AI, but not the super HP that comes with it? Just a thought based on reactions I've seen (and had) to older games that did these features, take it for what it is worth.
  17. Yea, I also second making the action difficulty a separate feature for the same reason :)
  18. A separate feature huh? Interesting, but there is no reason writing it as a separate script. The reason being you can just use triggers to turn on.