Lua script - give special amount EXP at start of a level?

Added by LL-Aga over 2 years ago

Hi,

I am not looking for a XPsave possibility - that is existing.

We are a group of 6 player, which have different skills - one is really good, other are ok, 2 are real newbies.
I thought, if it would be possible to give each player a special amount of XP when a level starts - e.g. the best guy 0 XP and the "worst" one 400 or what else - as the worst gamer have then some better knowhow and and

Today our best gamer will reach around 800 XP and the "worst" maybe 200 - and if it would be possible to start with a defined level it will be as we are on the same "level"

Maybe it is possible or someone know, if such LUA script is existing?

LL-Aga

BTW: we are looking for German speaking gamer - we are a group of silverhair people and like to play 2 times per week regularly. Have a look to our "Silvergamer" homepage (German required ) http://silver-gamer.jimdo.com/


Replies (11)

RE: Lua script - give special amount EXP at start of a level? - Added by Spyhawk over 2 years ago

This is an interesting question. XP could be initially awarded with a simple Lua script if the game knows the skill level of each players before each map. However, XP are a very bad metric to evaluate skill (f.e. the defending team always earns more XP)

Incidentally, in 2.75, we’ve implemented a skill rating system (see #403, and this wiki page) that works in conjunction with a Lua script (still wip, but I’ll fix the remaining issues in the following days, and then enable it on our test server).

In a nutshell, the rating system gives each player a score between 0 and 50, in the same manner that Elo gives chess players a score that can rank them.
The caveat is that, to work correctly, that system needs players playing against each over time other so there are winners and losers. If you all play in the same team (like yesterday evening ), that system will be unable to give an accurate score relative to each other.

But this is definitely something to explore. I might very well write such a script that uses the rating information in the near future!

RE: Lua script - give special amount EXP at start of a level? - Added by LL-Aga over 2 years ago

Yes - that are really interesting informations - and glad to read this with the skill rating system.

My point of interest was, that we are in the moment a closed user group (6 player - everyone have gray hair and is near the retirement - therefore we are somehow a overall "old" group )

Based on this we know each other and know the skill. Based on XP the "quality" of weapons, health, ... is increasing - therefore I thought to give our "noobs" some more EXP points at the start of any match we do in our closed Serverarea (yes PW needed our provider wanted this for our wish).

Well - we have always the same nick and based on this I thought to set the EXP to a value each time the match starts for our own "internal" rating and want to see, if it will be better for the overall gameplay as a "mixture" of "poor" guys together against other "good" player is not very usefull

But that was a question and I see, that it seems in work (maybe a number from 1 to 10 may be given to each player in future which will evaluated afterwards to have this skill done "automatically" at the start of a game. But for sure such "KI" is not really easy to create.

Thanks in advance and nice development - we are gaming ET not for 10 years and ET-L since it was released and we heard about it.

LL-Aga (LL : LevelLords - in before as Descent2/3 Gamertimes)

RE: Lua script - give special amount EXP at start of a level? - Added by Spyhawk over 2 years ago

You should be able to do that by using the et.G_XP_Set() function, and hardcoding the GUID of each player.

Quick and dirty example:

-- called when game initializes
function et_InitGame(levelTime, randomSeed, restart)
    -- register name of this module
    et.RegisterModname("StartXP")
end

-- called for every ClientBegin
function et_ClientBegin(clientNum)
    local guid = et.Info_ValueForKey(et.trap_GetUserinfo(clientNum), "cl_guid")

    -- skills are 0 to 6
    -- levels 0 to 4 are "0 20 50 90 140" 

    -- player 1
    if guid == "0123456789ABCDEF0123456789ABCDEF" then
        -- et.G_XP_Set(clientNum, xp, skill, add)
        et.G_XP_Set(clientNum, 140, 0, 0) -- Battle Sense, lvl 4
        et.G_XP_Set(clientNum, 90, 1, 0)  -- Engineering, lvl 3
        et.G_XP_Set(clientNum, 50, 2, 0)  -- First Aid, lvl 2
        et.G_XP_Set(clientNum, 140, 3, 0) -- Signals, lvl 1
        et.G_XP_Set(clientNum, 90, 4, 0)  -- Light Weapons, lvl 3
        et.G_XP_Set(clientNum, 0, 5, 0)   -- Heavy Weapons, lvl 0
        et.G_XP_Set(clientNum, 0, 6, 0)   -- Covert Ops, lvl 0
    -- -- player 2
    elseif guid == "0123456789ABCDEF0123456789ABCDEF" then
        et.G_XP_Set(clientNum, 140, 4, 0) -- Light Weapons, lvl 5
    -- player 3
    elseif guid == "0123456789ABCDEF0123456789ABCDEF" then
        for i = 0, 6 do
            et.G_XP_Set(clientNum, 50, i, 0) -- all skills at lvl 2
        end
    end
end

The GUID of player can be found by typing "cl_guid" in console. You can use "comdump test.txt" to dump the content of console in a test.txt file, where the guid can be easily retrieved.
Lua reference can be found here.

RE: Lua script - give special amount EXP at start of a level? - Added by LL-Aga over 2 years ago

Wow - that is great and it seems to be possible to create such a script.
I just started to check the ladm.lua and saw, it will be possible.
With this example we will start to check for such lua script for our 6 people.

Thanks a lot and great help

Greetings LL-Aga nr Berlin

RE: Lua script - give special amount EXP at start of a level? - Added by LL-Atan over 2 years ago

Hi, this is new stuff for me and I’m not sure if I understand things correctly so please let me ask:

You wrote: – (function is) called when game initializes
Where exactly the script should go in so it will start with the game then?

You wrote:
– and hardcoding the GUID of each player.
– The GUID of player can be found by...

Is this gui static and every game the same for each single player all the time?

Sorry for asking, but as said, new stuff for me.

cheers LL-Atan

RE: Lua script - give special amount EXP at start of a level? - Added by RaFaL over 2 years ago

LL-Atan wrote:

Hi, this is new stuff for me and I’m not sure if I understand things correctly so please let me ask:

You wrote: – (function is) called when game initializes
Where exactly the script should go in so it will start with the game then?

You wrote:
– and hardcoding the GUID of each player.
– The GUID of player can be found by...

Is this gui static and every game the same for each single player all the time?

Sorry for asking, but as said, new stuff for me.

cheers LL-Atan

Hi LL-Atan this scripts is getting cl_guid from players and compares them, if specified is found then grants lvls for all skills for a player with this guid
Simple as it is.

RE: Lua script - give special amount EXP at start of a level? - Added by Spyhawk over 2 years ago

The GUID is a unique string. Each player has one, and it stays the same over maps. It is stored in the etkey file of each player (but it can’t be read from that file directly as it is encrypted).
Each player will have to send his GUID to you.

As with all Lua scripts, your script will need to be put in the /legacy directory on your server and added to the lua_modules cvar in the legacy.cfg file (ie, set lua_modules "test.lua")

RE: Lua script - give special amount EXP at start of a level? - Added by LL-Atan over 2 years ago

Thank you for these informations. They are very helpful for me.
I’ll give it a try asap.

RE: Lua script - give special amount EXP at start of a level? - Added by LL-Atan over 2 years ago

Ok, I found the time to give it a first try now.

I used for a test inside the script this line here:
....
for i = 0, 6 do
et.G_XP_Set(clientNum, 1, i, 0)
....

I thought it will give me one XP due map start then.
But the result was 7 XP.

A second test with (clientNum, 5, i, 0) results in 35 XP

So just for my info now, is it right, that I will own 5XP for each single point using inside that funktion?
Or is that possible a fault?

RE: Lua script - give special amount EXP at start of a level? - Added by Spyhawk over 2 years ago

This is correct. If you don’t know what a for loop is, you probably want to learn a bit more about general programming first.

Again, the Legacy mod API doc is available here, and you’ll find the general Lua manual linked there too.

RE: Lua script - give special amount EXP at start of a level? - Added by LL-Atan over 2 years ago

LOL, yes, too bad. I see my fault now.
Thanks for your advice.

(1-11/11)