Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Bits and pieces

Bit operators and their use in modding

Experience

  • 2013-08-07 18:52:00
    So how do I remove some experience from the player, I've already tried copying the addExperience method from the player class and alter it to remove xp but that just didn't work. Is there an easy method of doing this?
  • 2013-08-07 21:35:00
    I think I actually solved it :D
  • 2013-08-07 22:03:32
    Nice. Please post the solution for others to see :)
  • 2013-08-07 22:06:51
    Sure:
    player.experience -= 50F / (float) player.xpBarCap();
                        player.experienceTotal -= 50;

    while (player.experience < 0) {
    float experience = player.experience * (float)player.xpBarCap();
                    player.addExperienceLevel(-1);
                            player.experience = 1 + experience / (float) player.xpBarCap();

                        }

    Where 50 ofcourse is the xp I take from the player
  • 2013-08-08 09:36:52
    or you could just do this :D

    int tempXp = player.experienceTotal;
    player.experience = 0;
    player.experienceLevel = 0;
    player.experienceTotal = 0;

    player.addExperience(tempXp - 50);
  • 2013-08-08 11:01:40
    That version would also work. However, it would play you a lot of sounds for leveling up.
  • Log in or sign up to reply to this thread