Adding xp to a skill.


Questions, Explanations, Howtos

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Friday, 9th August 2013, 12:27

Adding xp to a skill.

I've been trying to figure out how to add xp to a randomly chosen skill for a while.
Currently I've got the randomly chosen skill bit down, but I'm still not sure how to add xp.
I tried to figure it out via the code for pot of experience, but that seems to be spread out through three different files and I can't figure out how it works.
Is there some kind of function to call? Any help would be greatly appreciated.

Ziggurat Zagger

Posts: 3163

Joined: Friday, 6th January 2012, 18:45

Post Friday, 9th August 2013, 16:39

Re: Adding xp to a skill.

The potion seems to set you.exp_available to a value, then after determining which skills are enabled it calls train_skills().

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Friday, 9th August 2013, 17:48

Re: Adding xp to a skill.

Huh. Thanks! I've never been good with things in three or more files.
User avatar

Dungeon Master

Posts: 502

Joined: Wednesday, 7th March 2012, 13:25

Location: Lexington, KY, US

Post Saturday, 10th August 2013, 16:03

Re: Adding xp to a skill.

You might also look into how sage works, which is fairly similar. See the "if (!you.sage_skills.empty())" block in player.cc:gain_exp(). It saves the existing exp pool (you.exp_available), sets the pool to the amount of XP it wants to give, calls train_skill(), then restores the old value of the pool.

For this message the author neil has received thanks:
BlackSheep

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Monday, 12th August 2013, 07:23

Re: Adding xp to a skill.

I'll try that too.
I allready got the code for randomly choosing a skill from there, might as well go all out.

Return to Coding

Who is online

Users browsing this forum: No registered users and 18 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.