Advertiser Content

fauno

Non-binary
Brazil
Seen 1 Hour Ago
Posted 1 Week Ago
31 posts
2.1 Years
Well, I'm trying to create a variable that memorizes the Dynamax level of a Pokémon. But I don't quite understand how values are stored between these attributes.
I tried to add some conditions in PokeBattle_Pokemon, but it didn't work. Could someone help or explain how I can create this? It may be similar to Level, but must be set by an individual variable to Pokémon.
Hera an example:

Sir_Tman

Overworked game Dev

Non-binary
Australia
Seen 3 Days Ago
Posted 4 Days Ago
201 posts
4.4 Years
In PokeBattle_Pokemon you need to add a variable in the PokeBattle_Pokemon class at the very top. In this case you need to make a new attr_accessor, which would be attr_accessor(:dynamax). This can be added somewhere around line 4-53 if you so choose in PokeBattle_Pokemon. ((You don't have to call it just dynamax you could call it dynamaxlv for readability))

If you're really stuck:
Spoiler:

class PokeBattle_Pokemon
  attr_reader(:totalhp)       # Current Total HP
  attr_reader(:attack)        # Current Attack stat
  attr_reader(:defense)       # Current Defense stat
  attr_reader(:speed)         # Current Speed stat
  attr_reader(:spatk)         # Current Special Attack stat
  attr_reader(:spdef)         # Current Special Defense stat
  attr_accessor(:iv)          # Array of 6 Individual Values for HP, Atk, Def,
  attr_accessor(:dynamax)     # Current Dynamax Level (0-10)


Then you will need to make a method to be able to access that attribute which would be.

  def dynamax_level #You can rename this line to whatever you like I just called it this for readability
    @dynamax=0 if !@dynamax
    @dynamax=10 if @dynamax < 10
    return @dynamax
  end
Basically what this does is initializes the dynamax variable as zero when the game generates a new pokemon, and lets you call the dynamax level which can be changed. With something like @dynamax=7 assuming you'll use Dynamax Candies, it would be a simple line of @dynamax+=1

The line @dynamax=10 if @dynamax < 10 makes it so you can't make the level go past 10 which you can change as you see fit.
Add this method before def baseStats.

Then in def initialize(species,level,player=nil,withMoves=true) add @dynamax=0 after @iv[5]=rand(32)

fauno

Non-binary
Brazil
Seen 1 Hour Ago
Posted 1 Week Ago
31 posts
2.1 Years
In PokeBattle_Pokemon you need to add a variable in the PokeBattle_Pokemon class at the very top. In this case you need to make a new attr_accessor, which would be attr_accessor(:dynamax). This can be added somewhere around line 4-53 if you so choose in PokeBattle_Pokemon. ((You don't have to call it just dynamax you could call it dynamaxlv for readability))

If you're really stuck:
Spoiler:

class PokeBattle_Pokemon
  attr_reader(:totalhp)       # Current Total HP
  attr_reader(:attack)        # Current Attack stat
  attr_reader(:defense)       # Current Defense stat
  attr_reader(:speed)         # Current Speed stat
  attr_reader(:spatk)         # Current Special Attack stat
  attr_reader(:spdef)         # Current Special Defense stat
  attr_accessor(:iv)          # Array of 6 Individual Values for HP, Atk, Def,
  attr_accessor(:dynamax)     # Current Dynamax Level (0-10)


Then you will need to make a method to be able to access that attribute which would be.

  def dynamax_level #You can rename this line to whatever you like I just called it this for readability
    @dynamax=0 if !@dynamax
    @dynamax=10 if @dynamax < 10
    return @dynamax
  end
Basically what this does is initializes the dynamax variable as zero when the game generates a new pokemon, and lets you call the dynamax level which can be changed. With something like @dynamax=7 assuming you'll use Dynamax Candies, it would be a simple line of @dynamax+=1

The line @dynamax=10 if @dynamax < 10 makes it so you can't make the level go past 10 which you can change as you see fit.
Add this method before def baseStats.

Then in def initialize(species,level,player=nil,withMoves=true) add @dynamax=0 after @iv[5]=rand(32)
Well, sure your help made me see much more clearly, I also got help from other people in Discord and I was able to create this variable using methods similar to what you described, in any case thank you very much for helping.
Advertiser Content