• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Resource icon

Resource Mega MewThree's Achievement System for v21.1 v1.1

hostman

Trainer
Member
Joined
Aug 24, 2023
Posts
70
nice, do you know how it could be done with persistent switches?
 

Gardenette

Cooltrainer
Member
Joined
May 30, 2022
Posts
156
nice, do you know how it could be done with persistent switches?
Well for it to work with that script, you would need to keep the save files that have the achievements completed.
If you start over with no save files at all, it wouldn't work since the plugin searches other save files.

If you mean like from a coding perspective how would it look, I don't remember the syntax off the top of my head.
 

Gardenette

Cooltrainer
Member
Joined
May 30, 2022
Posts
156
@Frooziemon per your question in the the reviews -
"If you put this script above the v20.1 Essentials Hotfixes, or if you have the hotfixes as a plugin, this will overwrite the method for selling items, and selling items will not be counted towards achievements. I just copied the code from the hotfix and modified it to add to the achievement count. The def pbSellScreen in the Misc Bug Fixes script for hotfix 1.0.7 can be removed."

I know you wanted an explanation, but it might be easier if you state whether you're having issues with it and then me trying to explain if I need to.
When you sell things at the mart, does it progress your achievement for selling items?
 

mindbender12

Novice
Member
Joined
Jan 15, 2022
Posts
45
It doesn't disrupt the gameplay, but the background doesn't appear, making the design look a bit ugly. I don't understand programming much, but I've tried various possible modifications that don't change the result, and it works fine in v20, so it must be something that changed in v21. I'm investigating what it could be, but, as I mentioned, I'm not very skilled at this

View attachment 22077
How did you set it up to have a achievement based on a switch?
 

rafahbit

Trainer
Member
Joined
Oct 21, 2020
Posts
53
How did you set it up to have a achievement based on a switch?

I will give an example of my project. I added the achievements "charms progress", where there are goals to achieve, being [5,10,15,20,25,30, and every time I added a charm, I called the script: Achievements.incrementProgress("CHARMS_PROGRESS", 1) , where I said which achievement it was supposed to increase and its value to be added.

to add the achievement, under the nuzlock achievement in Achievement_Module, I did:

"CHARMS_PROGRESS"=>{
"id"=>15,
"name"=>"Enchanted Amulets",
"description"=>"Every charm Unveiled",
"goals"=>[5,10,15,20,25,30]
}

So, if you want the player to gain an achievement when they activate a switch, in fact just put :Achievements.incrementProgress("achievement here", 1) where you want, without needing to spend a switch for it, it can be in a conditional branch for example.

You can customize your achievements within the game, for example the mega evolution, I'm working on the script to add a count for every time you use dynamax, gigantamax, z move and terastalization, but I didn't have much time to do this.
 

rafahbit

Trainer
Member
Joined
Oct 21, 2020
Posts
53
I modified Achievement_Triggers a little so that I could identify the use of: Dynamax, gigantamax, terastal and z-moves from the Deluxe battle kit plugins
but it is necessary to add the respective achievements to be updated by the modifications in the Achievement_Module, they are:

Don't forget to put the order corresponding to your script, the description and goals are just examples, do as you wish.

Ruby:
Expand Collapse Copy
"DYNAMAXING"=>{
    "id"=>16,
    "name"=>"Dynamax Expert",
    "description"=>"Dynamaxing Pokémon",
    "goals"=>[1,10,50,100,300]
    },
  "GIGANTAMAXING"=>{
    "id"=>17,
    "name"=>"Gigantamax Expert",
    "description"=>"Gigantamaxing Pokémon",
    "goals"=>[1,10,50,100,300]
    },
 "ZMOVE"=>{
    "id"=>18,
    "name"=>"Z-move Expert",
    "description"=>"zmove",
    "goals"=>[1,10,25,50,100,200]
    },
"ULTRA"=>{
    "id"=>19,
    "name"=>"Ultra Expert",
    "description"=>"Ultra",
    "goals"=>[1,10,25,50,100,200]
    },
 "TERASTAL"=>{
    "id"=>20,
    "name"=>"Terastal Expert",
    "description"=>"terastal",
    "goals"=>[1,10,25,50,100,200]
    }
  }

Z-MOVE:
in Achievement Triggers, in the class Battle::Battler, where it says " alias achieve_pbUseMove pbUseMove" replace with:
Ruby:
Expand Collapse Copy
alias achieve_pbUseMove pbUseMove
  def pbUseMove(*args)
    achieve_pbUseMove(*args)
    if @lastMoveUsedIsZMove && @battle.pbOwnedByPlayer?(self.index)
      Achievements.incrementProgress("ZMOVE", 1)
  else
      Achievements.incrementProgress("MOVES_USED", 1)

    end
  end
end

This will make the system recognize the use of Z-move or not.

for Dynamax, Gigantamax and Terastal, in class Battle, place:
Ruby:
Expand Collapse Copy
alias tera_pbTerastallize pbTerastallize
  def pbTerastallize(idxBattler)
    tera_pbTerastallize(idxBattler)
    battler = @battlers[idxBattler]
    if battler.pbOwnedByPlayer?
      Achievements.incrementProgress("TERASTAL", 1)
    end
  end


  alias achieve_pbDynamax pbDynamax

  def pbDynamax(index, *args)
    achieve_pbDynamax(index, *args)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].gmax?
      Achievements.incrementProgress("GIGANTAMAXING", 1)
    else
      Achievements.incrementProgress("DYNAMAXING", 1)
    end
  end
alias achieve_pbUltraBurst pbUltraBurst
  def pbUltraBurst(index)
    achieve_pbUltraBurst(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].ultra?
      Achievements.incrementProgress("ULTRA", 1)
    end
  end
 
Last edited:

Jukes

Cooltrainer
Member
Joined
Jul 15, 2023
Posts
102
I'm looking to make achievements for a few things if someone can help me

Looking to implement the following:

Lifetime money earned.
Lifetime Coins earned.
$game_variables[94] reaching a certain number
the sum of a bunch of variables being a certain number.
 

Thomwell

Trainer
Member
Joined
Mar 8, 2024
Posts
63
Wow, your plugin is really amazing. It has brought me a lot of fun in game creation. May I ask the author, is there a reward mechanism for this achievement system? Will players be rewarded if they complete their achievements? For example, money, props, Pok é mon, and so on. I think doing so will attract players more to complete this gameplay operation.
 

Thomwell

Trainer
Member
Joined
Mar 8, 2024
Posts
63
I modified Achievement_Triggers a little so that it could identify the use of: Dynamax, gigantamax, terastal and z-moves.
but it is necessary to add the respective achievements to be updated by the modifications in the Achievement_Module, they are:

Don't forget to put the order corresponding to your script, the description and goals are just examples, do as you wish.

Ruby:
Expand Collapse Copy
"DYNAMAXING"=>{
    "id"=>16,
    "name"=>"Dynamax Expert",
    "description"=>"Dynamaxing Pokémon",
    "goals"=>[1,10,50,100,300]
    },
  "GIGANTAMAXING"=>{
    "id"=>17,
    "name"=>"Gigantamax Expert",
    "description"=>"Gigantamaxing Pokémon",
    "goals"=>[1,10,50,100,300]
    },
 "ZMOVE"=>{
    "id"=>18,
    "name"=>"Z-move Expert",
    "description"=>"zmove",
    "goals"=>[1,10,25,50,100,200]
    },
"ULTRA"=>{
    "id"=>19,
    "name"=>"Ultra Expert",
    "description"=>"Ultra",
    "goals"=>[1,10,25,50,100,200]
    },
 "TERASTAL"=>{
    "id"=>20,
    "name"=>"Terastal Expert",
    "description"=>"terastal",
    "goals"=>[1,10,25,50,100,200]
    }
  }

Z-MOVE:
in Achievement Triggers, in the class Battle::Battler, where it says " alias achieve_pbUseMove pbUseMove" replace with:
Ruby:
Expand Collapse Copy
alias achieve_pbUseMove pbUseMove
  def pbUseMove(*args)
    achieve_pbUseMove(*args)
    if @lastMoveUsedIsZMove && @battle.pbOwnedByPlayer?(self.index)
      Achievements.incrementProgress("ZMOVE", 1)
  else
      Achievements.incrementProgress("MOVES_USED", 1)

    end
  end
end

This will make the system recognize the use of Z-move or not.

for Dynamax, Gigantamax and Terastal, in class Battle, place:
Ruby:
Expand Collapse Copy
alias tera_pbTerastallize pbTerastallize
  def pbTerastallize(idxBattler)
    tera_pbTerastallize(idxBattler)
    battler = @battlers[idxBattler]
    if battler.pbOwnedByPlayer?
      Achievements.incrementProgress("TERASTAL", 1)
    end
  end


  alias achieve_pbDynamax pbDynamax

  def pbDynamax(index, *args)
    achieve_pbDynamax(index, *args)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].gmax?
      Achievements.incrementProgress("GIGANTAMAXING", 1)
    else
      Achievements.incrementProgress("DYNAMAXING", 1)
    end
  end
alias achieve_pbUltraBurst pbUltraBurst
  def pbUltraBurst(index)
    achieve_pbUltraBurst(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].ultra?
      Achievements.incrementProgress("ULTRA", 1)
    end
  end
Hello, I followed your instructions, but there was a problem. I don't understand Ruby very well, and I don't know where I went wrong. Thank you for your guidance.
 

Attachments

  • 001.png
    001.png
    17.9 KB · Views: 11

rafahbit

Trainer
Member
Joined
Oct 21, 2020
Posts
53
Hello, I followed your instructions, but there was a problem. I don't understand Ruby very well, and I don't know where I went wrong. Thank you for your guidance.
Are you using the Deluxe battle kit plugins?
because the error says that it did not find "terastallize" in the existing scripts, you need to have the dbk terastal plugin for this, the same for dynamax and zmove, I think I didn't include this information when I posted XD
 

Thomwell

Trainer
Member
Joined
Mar 8, 2024
Posts
63
Are you using the Deluxe battle kit plugins?
because the error says that it did not find "terastallize" in the existing scripts, you need to have the dbk terastal plugin for this, the same for dynamax and zmove, I think I didn't include this information when I posted XD
Deluxe Battle Kit ?Yes, I am using it.
 

rafahbit

Trainer
Member
Joined
Oct 21, 2020
Posts
53
Deluxe Battle Kit ?Yes, I am using it.
Can you send me your entire Achievement_Triggers file so I can take a look? I'm half blind and just looking at the photo of the error I can't see almost anything hahahahah

Or, just copy this section here again and put it in Achievement_Triggers

Ruby:
Expand Collapse Copy
class Battle

  alias achieve_pbMegaEvolve pbMegaEvolve

  def pbMegaEvolve(index)
    achieve_pbMegaEvolve(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].mega?
      Achievements.incrementProgress("MEGA_EVOLUTIONS", 1)
    end
  end

alias tera_pbTerastallize pbTerastallize
  def pbTerastallize(idxBattler)
    tera_pbTerastallize(idxBattler)
    battler = @battlers[idxBattler]
    if battler.pbOwnedByPlayer?
      Achievements.incrementProgress("TERASTAL", 1)
    end
  end


  alias achieve_pbDynamax pbDynamax

  def pbDynamax(index, *args)
    achieve_pbDynamax(index, *args)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].gmax?
      Achievements.incrementProgress("GIGANTAMAXING", 1)
    else
      Achievements.incrementProgress("DYNAMAXING", 1)
    end
  end


  alias achieve_pbPrimalReversion pbPrimalReversion

  def pbPrimalReversion(index)
    achieve_pbPrimalReversion(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].primal?
      Achievements.incrementProgress("PRIMAL_REVERSIONS", 1)
    end
  end

alias achieve_pbUltraBurst pbUltraBurst
  def pbUltraBurst(index)
    achieve_pbUltraBurst(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].ultra?
      Achievements.incrementProgress("ULTRA", 1)
    end
  end

  #use item on pokemon in battle
 

Thomwell

Trainer
Member
Joined
Mar 8, 2024
Posts
63
Can you send me your entire Achievement_Triggers file so I can take a look? I'm half blind and just looking at the photo of the error I can't see almost anything hahahahah

Or, just copy this section here again and put it in Achievement_Triggers

Ruby:
Expand Collapse Copy
class Battle

  alias achieve_pbMegaEvolve pbMegaEvolve

  def pbMegaEvolve(index)
    achieve_pbMegaEvolve(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].mega?
      Achievements.incrementProgress("MEGA_EVOLUTIONS", 1)
    end
  end

alias tera_pbTerastallize pbTerastallize
  def pbTerastallize(idxBattler)
    tera_pbTerastallize(idxBattler)
    battler = @battlers[idxBattler]
    if battler.pbOwnedByPlayer?
      Achievements.incrementProgress("TERASTAL", 1)
    end
  end


  alias achieve_pbDynamax pbDynamax

  def pbDynamax(index, *args)
    achieve_pbDynamax(index, *args)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].gmax?
      Achievements.incrementProgress("GIGANTAMAXING", 1)
    else
      Achievements.incrementProgress("DYNAMAXING", 1)
    end
  end


  alias achieve_pbPrimalReversion pbPrimalReversion

  def pbPrimalReversion(index)
    achieve_pbPrimalReversion(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].primal?
      Achievements.incrementProgress("PRIMAL_REVERSIONS", 1)
    end
  end

alias achieve_pbUltraBurst pbUltraBurst
  def pbUltraBurst(index)
    achieve_pbUltraBurst(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].ultra?
      Achievements.incrementProgress("ULTRA", 1)
    end
  end

  #use item on pokemon in battle
Wow, that's really great. After you made these modifications, it can now be used normally. It's really amazing. Thank you very much for your guidance.
 

komeiji514

Elite Trainer
Member
Joined
Oct 28, 2023
Posts
267
How to set events that check whether player has reached a certain level of an achievement and give rewards?
 

komeiji514

Elite Trainer
Member
Joined
Oct 28, 2023
Posts
267
Can you send me your entire Achievement_Triggers file so I can take a look? I'm half blind and just looking at the photo of the error I can't see almost anything hahahahah

Or, just copy this section here again and put it in Achievement_Triggers

Ruby:
Expand Collapse Copy
class Battle

  alias achieve_pbMegaEvolve pbMegaEvolve

  def pbMegaEvolve(index)
    achieve_pbMegaEvolve(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].mega?
      Achievements.incrementProgress("MEGA_EVOLUTIONS", 1)
    end
  end

alias tera_pbTerastallize pbTerastallize
  def pbTerastallize(idxBattler)
    tera_pbTerastallize(idxBattler)
    battler = @battlers[idxBattler]
    if battler.pbOwnedByPlayer?
      Achievements.incrementProgress("TERASTAL", 1)
    end
  end


  alias achieve_pbDynamax pbDynamax

  def pbDynamax(index, *args)
    achieve_pbDynamax(index, *args)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].gmax?
      Achievements.incrementProgress("GIGANTAMAXING", 1)
    else
      Achievements.incrementProgress("DYNAMAXING", 1)
    end
  end


  alias achieve_pbPrimalReversion pbPrimalReversion

  def pbPrimalReversion(index)
    achieve_pbPrimalReversion(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].primal?
      Achievements.incrementProgress("PRIMAL_REVERSIONS", 1)
    end
  end

alias achieve_pbUltraBurst pbUltraBurst
  def pbUltraBurst(index)
    achieve_pbUltraBurst(index)
    return if !pbOwnedByPlayer?(index)
    if @battlers[index].ultra?
      Achievements.incrementProgress("ULTRA", 1)
    end
  end

  #use item on pokemon in battle
After the round using Dynamax in a battle this happens.But the game didn't crash and the opposing pokemon did nothing.
[2024-07-06 15:27:37 +0800]
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `[]' for nil:NilClass

Backtrace:
[Mega MewThree's Achievement System] Achievement_Module.rb:215:in `checkIfLevelUp'
[Mega MewThree's Achievement System] Achievement_Module.rb:158:in `incrementProgress'
[Mega MewThree's Achievement System] Achievement_Triggers.rb:121:in `pbDynamax'
[[DBK] Dynamax] [007] Dynamax Mechanics.rb:254:in `block in pbAttackPhaseSpecialActions3'
[[DBK] Dynamax] [007] Dynamax Mechanics.rb:250:in `each'
[[DBK] Dynamax] [007] Dynamax Mechanics.rb:250:in `pbAttackPhaseSpecialActions3'
[[DBK] Z-Power] [007] Z-Move Mechanics.rb:244:in `pbAttackPhaseSpecialActions3'
[[DBK] Z-Power] [009] Ultra Burst Mechanics.rb:223:in `pbAttackPhaseSpecialActions3'
[Deluxe Battle Kit] [003] Command Menu Refactor.rb:408:in `pbAttackPhase'
148:Battle_StartAndEnd:339:in `block (2 levels) in pbBattleLoop'
Edit: I referred to https://eeveeexpo.com/threads/592/ to try to add rewards. After removing the codes it's ok.
But how can I add rewards to make it run correctly?
 
Last edited:

rafahbit

Trainer
Member
Joined
Oct 21, 2020
Posts
53
After the round using Dynamax in a battle this happens.But the game didn't crash and the opposing pokemon did nothing.
[2024-07-06 15:27:37 +0800]
[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.9]

Exception: NoMethodError
Message: undefined method `[]' for nil:NilClass

Backtrace:
[Mega MewThree's Achievement System] Achievement_Module.rb:215:in `checkIfLevelUp'
[Mega MewThree's Achievement System] Achievement_Module.rb:158:in `incrementProgress'
[Mega MewThree's Achievement System] Achievement_Triggers.rb:121:in `pbDynamax'
[[DBK] Dynamax] [007] Dynamax Mechanics.rb:254:in `block in pbAttackPhaseSpecialActions3'
[[DBK] Dynamax] [007] Dynamax Mechanics.rb:250:in `each'
[[DBK] Dynamax] [007] Dynamax Mechanics.rb:250:in `pbAttackPhaseSpecialActions3'
[[DBK] Z-Power] [007] Z-Move Mechanics.rb:244:in `pbAttackPhaseSpecialActions3'
[[DBK] Z-Power] [009] Ultra Burst Mechanics.rb:223:in `pbAttackPhaseSpecialActions3'
[Deluxe Battle Kit] [003] Command Menu Refactor.rb:408:in `pbAttackPhase'
148:Battle_StartAndEnd:339:in `block (2 levels) in pbBattleLoop'
Edit: I referred to https://eeveeexpo.com/threads/592/ to try to add rewards. After removing the codes it's ok.
But how can I add rewards to make it run correctly?
sorry, I wasn't active a few months ago for health reasons, but here's what you asked for, I hope it's not too late




Achievement_Triggers:
Expand Collapse Copy
class AchievementButton < Sprite
  attr_reader :name
  attr_accessor :selected

  def initialize(x,y,name="",level="",internal="",viewport=nil)
    super(viewport)
    @name=name
    @level=level
    @selected=false
    currgoal=Achievements.getCurrentGoal(internal)
    if currgoal
      @button=AnimatedBitmap.new("Graphics/Pictures/Achievements/achievementsButton")
    else
      @button=AnimatedBitmap.new("Graphics/Pictures/Achievements/completedButton")
    end
    @contents=BitmapWrapper.new(@button.width,@button.height)
    self.bitmap=@contents
    self.x=x
    self.y=y
    refresh
    update
  end

  def dispose
    @button.dispose
    @contents.dispose
    super
  end

  def refresh
    self.bitmap.clear
    self.bitmap.blt(0,0,@button.bitmap,Rect.new(0,0,@button.width,@button.height))
    pbSetSystemFont(self.bitmap)
    textpos=[          # Name is written on both unselected and selected buttons
       [@name,14,10,0,Color.new(248,248,248),Color.new(40,40,40)],
       [@name,14,62,0,Color.new(248,248,248),Color.new(40,40,40)],
       [@level,482,10,1,Color.new(248,248,248),Color.new(40,40,40)],
       [@level,482,62,1,Color.new(248,248,248),Color.new(40,40,40)]
    ]
    pbDrawTextPositions(self.bitmap,textpos)
  end

  def update
    if self.selected
      self.src_rect.set(0,self.bitmap.height/2,self.bitmap.width,self.bitmap.height/2)
    else
      self.src_rect.set(0,0,self.bitmap.width,self.bitmap.height/2)
    end
    super
  end
end

class AchievementText < Sprite
  attr_reader :index
  attr_reader :name

  def initialize(x,y,description="",progress="",viewport=nil)
    super(viewport)
    @description=description
    @progress=progress
    @button=AnimatedBitmap.new("Graphics/Pictures/Achievements/achievementsText")
    @window=Window_AdvancedTextPokemon.newWithSize("",16,Graphics.height-96,Graphics.width-32,96,viewport)
    @window.letterbyletter=false
    @window.windowskin=nil
    #@window.baseColor=MessageConfig::LIGHTTEXTBASE
    @window.baseColor=MessageConfig::LIGHT_TEXT_MAIN_COLOR
    #@window.shadowColor=MessageConfig::LIGHTTEXTSHADOW
    @window.shadowColor=MessageConfig::LIGHT_TEXT_SHADOW_COLOR
    self.bitmap=@button.bitmap
    self.x=x
    self.y=y
    refresh
    update
  end

  def color=(val)
    @window.color=val
    super
  end
 
  def dispose
    @button.dispose
    @window.dispose
    super
  end

  def refresh
    @window.setText(@description+"\n"+"<ac>"+@progress+"</ac>")
  end

  def change(description,progress)
    @description=description.to_s
    @progress=progress.to_s
    refresh
  end
 
  def update
    @window.update
    super
  end
end

class PokemonAchievements_Scene
  def initialize(menu_index = 0)
    @menu_index = menu_index
    @buttons=[]
    @_buttons=[]
    @achievements=[]
    @achievementInternalNames=[]
  end
  #-----------------------------------------------------------------------------
  # start the scene
  #-----------------------------------------------------------------------------
  def pbStartScene
  buttonList = {}
  al = Achievements.list.keys.sort_by { |k| Achievements.list[k]["id"] }
  al.each do |k|
    @buttons.push(_INTL(Achievements.list[k]["name"]))
    @_buttons.push([k, (Achievements.list[k]["goals"])])
    @achievements.push(Achievements.list[k])
    @achievementInternalNames.push(k)
    buttonList[k.to_s] = -1
  end
 
  # Viewport setup
  @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  @viewport.z = 99999
  @buttonport = Viewport.new(0, 46, Graphics.width, 250)
  @buttonport.z = 99999
 
  # Background and other visual elements setup
  @sprites = {}
  self.addBackgroundPlaneMod(@sprites, "background", "Achievements/achievementsbg", @viewport)
  @sprites["command_window"] = Window_CommandPokemon.new(@buttons, 160)
  @sprites["command_window"].visible = false
  @sprites["command_window"].index = @menu_index
  @sprites["achievementText"] = AchievementText.new(8, 296, "Error.", _INTL("{1}/{2}", "-1", "-1"), @viewport)
  currgoal = Achievements.getCurrentGoal(@achievementInternalNames[0])
  progress = currgoal ? _INTL("{1}/{2}", $PokemonGlobal.achievements[@_buttons[0][0]]["progress"], currgoal) : _INTL("{1}", $PokemonGlobal.achievements[@_buttons[0][0]]["progress"])
  @sprites["achievementText"].change(_INTL(@achievements[0]["description"]), progress)
  @sprites["achievementText"].visible = true
 
  # Create AchievementButton sprites
  for i in 0...@buttons.length
    x = 8
    y = i * 50
    @sprites["button#{i}"] = AchievementButton.new(x, y, @buttons[i], _INTL("{1}/{2}", $PokemonGlobal.achievements[@_buttons[i][0]]["level"], @_buttons[i][1].length), @_buttons[i][0], @buttonport)
    @sprites["button#{i}"].selected = (i == @sprites["command_window"].index)
  end
 
  # Fade-in animation
  pbFadeInAndShow(@sprites) { update }
end

  #-----------------------------------------------------------------------------
  # play the scene
  #-----------------------------------------------------------------------------
  def pbAchievements
    loop do
      Graphics.update
      Input.update
      update
      if Input.trigger?(Input::B)
        break
      end
    end
  end
  #-----------------------------------------------------------------------------
  # end the scene
  #-----------------------------------------------------------------------------
  def pbEndScene
    pbFadeOutAndHide(@sprites) { update }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end
  #-----------------------------------------------------------------------------
  # update the scene
  #-----------------------------------------------------------------------------
  def update
    if @sprites["command_window"].nil?
      pbUpdateSpriteHash(@sprites)
      return true
    end
    oldi = @sprites["command_window"].index rescue 0
    pbUpdateSpriteHash(@sprites)
    newi = @sprites["command_window"].index rescue 0
    if oldi!=newi
      @sprites["button#{oldi}"].selected=false
      @sprites["button#{oldi}"].update
      @sprites["button#{newi}"].selected=true
      @sprites["button#{newi}"].update
      currgoal=Achievements.getCurrentGoal(@achievementInternalNames[newi])
      if currgoal
        progress=_INTL("{1}/{2}",$PokemonGlobal.achievements[@_buttons[newi][0]]["progress"],currgoal)
      else
        progress=_INTL("{1}",$PokemonGlobal.achievements[@_buttons[newi][0]]["progress"])
      end
      @sprites["achievementText"].change(_INTL(@achievements[newi]["description"]),progress)
      while @sprites["button#{newi}"].y>200
        for i in 0...@buttons.length
          @sprites["button#{i}"].y-=50
        end
      end
      while @sprites["button#{newi}"].y<0
        for i in 0...@buttons.length
          @sprites["button#{i}"].y+=50
        end
      end
    end
  end
 
  #added by Gardenette to work in v21.1
  def addBackgroundPlaneMod(sprites, planename, background, viewport = nil)
    sprites[planename] = AnimatedPlane.new(viewport)
    bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}")
    if bitmapName.nil?
        # Plane should exist in any case
        sprites[planename].bitmap = nil
        sprites[planename].visible = false
    else
        sprites[planename].setBitmap(bitmapName)
        sprites.each_value do |spr|
        spr.windowskin = nil if spr.is_a?(Window)
        end
    end
  end #def self.addBackgroundPlaneMod
 
end

class PokemonAchievements
  def initialize(scene)
    @scene=scene
  end

  def pbStartScreen
    @scene.pbStartScene
    @scene.pbAchievements
    @scene.pbEndScene
  end
end
 

rafahbit

Trainer
Member
Joined
Oct 21, 2020
Posts
53
How to set events that check whether player has reached a certain level of an achievement and give rewards?
After some checks, you can find some solutions to check if the achievement is complete:

you can use it in a conditional branch:

Ruby:
Expand Collapse Copy
$PokemonGlobal.achievements.dig("CHARMS", "level") == 6

to use, you create an npc that checks whether the achievement is complete or not, in this case, I used the charms achievement which has 6 goals, so the npc would check whether the achievement is at level 6, that is, complete.


If you want to check if this level is 1, 2, 3, 4, 5... before this obligation, you can use the same code, however, it will only inform the coding of the current progress of the guess, so that it checks if this level 4 and that you have already gone through 3 2 and 1, I am using the following command:

Ruby:
Expand Collapse Copy
$PokemonGlobal.achievements.dig("CHARMS", "level") >= 4

This way, it checks that levels 1,2,3 and 4 are complete, and can give different rewards for each level.
 

komeiji514

Elite Trainer
Member
Joined
Oct 28, 2023
Posts
267
After some checks, you can find some solutions to check if the achievement is complete:

you can use it in a conditional branch:

Ruby:
Expand Collapse Copy
$PokemonGlobal.achievements.dig("CHARMS", "level") == 6

to use, you create an npc that checks whether the achievement is complete or not, in this case, I used the charms achievement which has 6 goals, so the npc would check whether the achievement is at level 6, that is, complete.
Good! I will try.
 
Back
Top