Well for it to work with that script, you would need to keep the save files that have the achievements completed.nice, do you know how it could be done with persistent switches?
How did you set it up to have a achievement based on a switch?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?
"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]
}
}
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
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.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:"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: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: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
Are you using the Deluxe battle kit plugins?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.
Deluxe Battle Kit ?Yes, I am using it.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
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 hahahahahDeluxe Battle Kit ?Yes, I am using it.
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.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: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.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: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
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 lateAfter 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?
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
After some checks, you can find some solutions to check if the achievement is complete:How to set events that check whether player has reached a certain level of an achievement and give rewards?
$PokemonGlobal.achievements.dig("CHARMS", "level") == 6
$PokemonGlobal.achievements.dig("CHARMS", "level") >= 4
Good! I will try.After some checks, you can find some solutions to check if the achievement is complete:
you can use it in a conditional branch:
Ruby:$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.