I
IncuTyph
Guest
Hi, I'm fairly new to GML. I've been slowly working on my first game, and so far things have been pretty good. I came across an issue that is probably super simple to fix, but I'm not entirely sure what is wrong with what I have.
So, I'm trying to implement an XP system. When a monster is killed, its base xp (bxp) value (the amount of xp scales with monster level; think Pokemon) is supposed to be added to the player's (or other party members' once I actually add them) xp totals. This part seems to work, as the debug message I put in the monster's code shows when it's killed. However, what doesn't work is when the xp the player gets doesn't advance them to the next level.
This is the monster's code. Currently just touching the monster inflicts damage on it. This is in the monster's collision event with the player object:
As I said, this displays the debug message, so I'm assuming it works. This is my player's code though (Create event):
In the monster's code, I did try using self.xp and obj_player.xp but it doesn't seem to work either. I'm just not sure what's wrong with what I have. Also, I do have the monster set to give 10,000 xp, so surely I meet the requirements to level up a few times with that. Any help would be appreciated though.
So, I'm trying to implement an XP system. When a monster is killed, its base xp (bxp) value (the amount of xp scales with monster level; think Pokemon) is supposed to be added to the player's (or other party members' once I actually add them) xp totals. This part seems to work, as the debug message I put in the monster's code shows when it's killed. However, what doesn't work is when the xp the player gets doesn't advance them to the next level.
This is the monster's code. Currently just touching the monster inflicts damage on it. This is in the monster's collision event with the player object:
Code:
if hp <= 0
{
with(obj_player)
{
xp += obj_goobey_grey_ow.bxp; //(player?)xp += monster's bxp
show_debug_message("xp gained");
}
instance_destroy();
}
Code:
lvl = 1;
xp = 0;
nlvl = lvl*10; //nlvl stands for next level
if xp >= nlvl
{
lvl += 1;
show_debug_message("Leveled up!")
}