Goomba Killing Achievement (SOLVED!)
Posted: Wed Feb 22, 2023 7:07 pm
How can I make an achievement that activates when I've killed a grand total of 100 Goombas?
Forums for SMBX
https://www.smbxgame.com/forums/
Tell me how you did it in excruciating detail
Code: Select all
name = "Goomba Destroyer"
desc = "Destroy 100 Goombas!"
condition-1 = 100
condition-1-desc = "Goombas Defeated:"
Code: Select all
local ach1 = Achievements(1)
function onNPCKill(eventObj, killedNPC, killReason)
if killedNPC.id == 1 then
if killReason ~= HARM_TYPE_OFFSCREEN then
ach1:progressCondition(1)
end
end
end
OMG thx so much for the info!KurttheKing wrote: ↑Fri Feb 24, 2023 4:18 pm
With pleasure! First, write the Achievement's info in ach-1.ini, located in the achievements file of your episode:and then go to the Global Lunalua File and write the following:Code: Select all
name = "Goomba Destroyer" desc = "Destroy 100 Goombas!" condition-1 = 100 condition-1-desc = "Goombas Defeated:"
If I understand correctly, the way it all works is like this. First, we create a Variable to take the place of Achievement 1 (ach1), then we make an onNPCKill Function to check when a Goomba is killed using the code, "if killedNPC.id == 1 then" Afterwards, we check if the Goomba didn't die to Harm Type Off-Screen. This is so that the Goomba isn't considered to be dead when he falls down a hole or walks off-screen and despawns. Then we just need to advance the Achievement. To do this, we write ach1:progressCondition(1). What this does is first checks for what Achievement we are referring to (in this case Achievement 1 because ach1 takes it's place) and then progresses the condition in parentheses (1), which adds 1 to the amount of Goombas you killed. So everytime a Goomba is killed it adds on 1 until you kill 100 Goombas and will be given the Achievement.Code: Select all
local ach1 = Achievements(1) function onNPCKill(eventObj, killedNPC, killReason) if killedNPC.id == 1 then if killReason ~= HARM_TYPE_OFFSCREEN then ach1:progressCondition(1) end end end
I hope this helped and was filled with enough excruciating detail!![]()