Cuberite Forum
Player XP - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Player XP (/thread-1265.html)



Player XP - marmot21 - 11-12-2013

Hi, I've been looking at the player XP improvement
(https://github.com/mc-server/MCServer/issues/143)
This is my first thing I've worked on in this project/anything todo with MC Blush - just wondering if there is currently any XP calculation or otherwise how XP should be calculated given different events?

Also, are all clients supposed to begin with zero xp - or what's the intended functionality? i.e. Is the player XP unique to every server instance or can they have an initial XP level

I'll likely have more questions later, but I'll start with storing player XP part firstConfusedhy:

Cheers

--marmot


RE: Player XP - xoft - 11-12-2013

Hello, welcome, and good luck.

The players should start with zero XP. Whatever XP level they get to, it should be stored once they leave the server, so when they come again, their XP is restored - just like regular vanilla server.
In order to test this, you'll probably need some way of setting and getting the player XP to verify, so you'll need to write cPlayer::SetExperience() and cPlayer::GetExperience(); note that vanilla splits the experience into several different variables (XpLevel, XpP, XpTotal), consider duplicating that behavior and having a separate get / set function for each variable, as well as a function to add experience (that will be called later when exp orbs are collected; it will do the calculation of the exp orb value against current level)
http://minecraft.gamepedia.com/Player.dat_format should be helpful with the Xp* variables, http://minecraft.gamepedia.com/XP has the level calculations.

Once you add the Get / Set functions, I can help you make them Lua-exported, and you can write a testing command in the Debuggers plugin, so that you can call those functions in-game, for testing.


RE: Player XP - xoft - 11-13-2013

It would seem that mborland has beaten you to this task; talk to him to see if he intends to finish it entirely, or wants to share the workload.


RE: Player XP - marmot21 - 11-14-2013

(11-13-2013, 08:11 PM)xoft Wrote: It would seem that mborland has beaten you to this task; talk to him to see if he intends to finish it entirely, or wants to share the workload.

Yeah I know haha, I'd just started working on it too after I got your reply before. Dodgy

By the looks of his comments though he just wanted to get started on the Xp orbs thing - though I might see about working with him on that one - sounds like a cool oneBig Grin
You mentioned getting the Get/Set commands lua exported, wouldn't mind some advise on that one Smile

Cheers

--Marmot


RE: Player XP - xoft - 11-14-2013

Usually for the simple getters and setters, if they don't use any special datatype, wrapping them in the // tolua_begin and //tolua_end comments is enough. Either add those to the beginning and end of your added functions, or move the functions down to GetThrowStartPos() et al, those are in an exported API block.
Then, you need to run the tolua processor. On windows, it simply means executing the $/source/AllToLua.cmd script; if it doesn't fail, it's all done for you. Note that the script updates Bindings.cpp and Bindings.h, those need to be committed along with your changes. As for Linux, Bearbin has reported that the tolua processor has some problems, dunno if he managed to get it running or not.