I'm trying to make HP increase with an xstat.

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
When using N.A.S.T.Y. Extra Stats https://forums.rpgmakerweb.com/index.php?threads/n-a-s-t-y-extra-stats.998/ and Theo Custom Parameter Formula https://www.rpgmakercentral.com/topic/20334-theo-custom-parameter-formula/, I am trying to create a custom parameter that determines how much HP is gained by an actor's Constitution xstat. I'll preclude this by saying that I have little to no understanding of how ruby scripting works, and I am struggling through the dark to try and get this to work. Forgive me for my lack of understanding if I make simple scripting errors.

I'll give a run down of what is supposed to happen: Let's say a character starts with 20 HP at level 1, and starts with 10 CON. Any amount of CON above 10 increases Max HP by 8, per point in CON. That's governed by this formula: 20 + (8 * (CON - 10)) For instance, if a character has 12 CON, he has 20 + (8 * (12-10)). This becomes 20 + 16 = 36.

The formula I made in the Theo Custom Parameter script looks like this (the relevant part between "def" and the second "end"):

Code:
  def custom_mhp(ori_param)
    if $game_actors[actor.id].xstat.con > 10
      20 + (8 * ($game_actor[actor.id].xstat.con - 10))
    else
      20
    end
  end
With this, I get an "Stack Level Too Deep" error. I have tried other variations like:

Code:
  def custom_mhp(ori_param)
    if $game_actors.xstat.con > 10
      20 + (8 * ($game_actors.xstat.con - 10))
    else
      20
    end
  end
This don't work either. I feel like the only way to move forward is blocked because I lack the knowledge to understand how this works.
 
Last edited:

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
682
Reaction score
446
First Language
English
Primarily Uses
RMVXA
I haven't tested anything, but does it work if you do something like:
Code:
def custom_mhp(ori_param)
   ori_param = @xstat.con > 10 ? 20 + (8 * (@xstat.con - 10)) : 20
 end
Since the method is in the Game_Actor class, you don't need to use $game_actors or anything like that.
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
I haven't tested anything, but does it work if you do something like:
Code:
def custom_mhp(ori_param)
   ori_param = @xstat.con > 10 ? 20 + (8 * (@xstat.con - 10)) : 20
 end
Since the method is in the Game_Actor class, you don't need to use $game_actors or anything like that.
I just tried it and I got an error that says "undefined method 'con' for nil:NilClass.

The reason I used $game_actors is because this is what it said for the extra stats script:

Code:
# *For Scripters
#
# -If you want to access the stats, just use:
# actor.xstat.STAT - Where STAT is the name of the new stat
#
# Ex. $game_actors[1].xstat.str , will return actor 1's str
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
682
Reaction score
446
First Language
English
Primarily Uses
RMVXA
I'd try changing the order of the scripts. You could also try:
Code:
def custom_mhp(ori_param)
   return ori_param = 20 unless @xstat.con
   ori_param = @xstat.con > 10 ? 20 + (8 * (@xstat.con - 10)) : 20
 end
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
I'd try changing the order of the scripts. You could also try:
Code:
def custom_mhp(ori_param)
   return ori_param = 20 unless @xstat.con
   ori_param = @xstat.con > 10 ? 20 + (8 * (@xstat.con - 10)) : 20
 end
I got the same error. I changed the order of the two scripts, and that didn't change the outcome.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,674
Reaction score
566
First Language
English
Primarily Uses
RMVXA

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
Could you not combine these to give...
Code:
def custom_mhp(ori_param)
  ori_param = $game_actors[actor.id].xstat.con > 10 ? 20 + (8 * (@xstat.con - 10)) : 20
end
I plugged it in, but I got the error "stack level too deep". Also, I get these errors when I start a new game. By the way, what does the "actor.id" part do in the brackets?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,674
Reaction score
566
First Language
English
Primarily Uses
RMVXA
Where are you putting this?
I plugged it in, but I got the error "stack level too deep"
This code should go right in the script.
Code:
  # --------------------------------------------------------------------------
  # * ) Defense Point
  # --------------------------------------------------------------------------
  def custom_def(ori_param)
    ori_param   # <-- Define it here
  end
  # --------------------------------------------------------------------------
  # * ) Magic Attack
  # --------------------------------------------------------------------------
  def custom_mat(ori_param)
    ori_param   # <-- Define it here
  end
  # --------------------------------------------------------------------------
  # * ) Magic Defense
  # --------------------------------------------------------------------------
  def custom_mdf(ori_param)
    ori_param   # <-- Define it here
  end
  # --------------------------------------------------------------------------
  # * ) Agility Point
  # --------------------------------------------------------------------------
  def custom_agi(ori_param)
    ori_param   # <-- Define it here
  end
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
682
Reaction score
446
First Language
English
Primarily Uses
RMVXA
The issue is because of where things are being run. Theo's script is trying to pull parameters that don't exist yet. You could try two things:

Option 1:
Code:
  alias z26_s setup unless $@
  def setup(actor_id)
    @xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))
    z26_s(actor_id)
    for item in equips.compact
      z26variate_equip(item)
    end
    for stat in Z26::STATS
      z26variate_stats(stat, @level)
    end
  end
Replace the aliased setup method in Game_Actor with this in NASTY's script.

Option 2:
Code:
  def custom_mhp(ori_param)
    return ori_param = 20 unless @xstat && @xstat.con
    ori_param = @xstat.con > 10 ? 20 + (8 * (@xstat.con - 10)) : 20
  end
Use that as your code in Theo's script.
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
The issue is because of where things are being run. Theo's script is trying to pull parameters that don't exist yet. You could try two things:

Option 1:
Code:
  alias z26_s setup unless $@
  def setup(actor_id)
    @xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))
    z26_s(actor_id)
    for item in equips.compact
      z26variate_equip(item)
    end
    for stat in Z26::STATS
      z26variate_stats(stat, @level)
    end
  end
Replace the aliased setup method in Game_Actor with this in NASTY's script.

Option 2:
Code:
  def custom_mhp(ori_param)
    return ori_param = 20 unless @xstat && @xstat.con
    ori_param = @xstat.con > 10 ? 20 + (8 * (@xstat.con - 10)) : 20
  end
Use that as your code in Theo's script.
I tried option 2 first, and it works great! Can you explain how it's different?

Also, thank you so much!
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
Where are you putting this?

This code should go right in the script.
Code:
  # --------------------------------------------------------------------------
  # * ) Defense Point
  # --------------------------------------------------------------------------
  def custom_def(ori_param)
    ori_param   # <-- Define it here
  end
  # --------------------------------------------------------------------------
  # * ) Magic Attack
  # --------------------------------------------------------------------------
  def custom_mat(ori_param)
    ori_param   # <-- Define it here
  end
  # --------------------------------------------------------------------------
  # * ) Magic Defense
  # --------------------------------------------------------------------------
  def custom_mdf(ori_param)
    ori_param   # <-- Define it here
  end
  # --------------------------------------------------------------------------
  # * ) Agility Point
  # --------------------------------------------------------------------------
  def custom_agi(ori_param)
    ori_param   # <-- Define it here
  end
I was putting them where they were supposed to go in the script.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
682
Reaction score
446
First Language
English
Primarily Uses
RMVXA
The reason is because the parameters are set up before the xstats, so it was throwing an error (because you're referring to something that doesn't exist yet). With the first option, I was basically moving the xstats (albeit blank ones) to be set up first. The second option basically says 'if the xstats aren't set up yet, don't continue with the rest of the code and set ori_param to 20'.

Hope that makes sense.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,467
Members
137,821
Latest member
Capterson
Top