Feature [TFS 1.3] Adding New Skills

Ramirow

Excellent OT User
Joined
Aug 22, 2009
Messages
495
Best answers
13
Reaction score
200
Location
Argentina
First of all, I make this thread because I was struggling to add a new skill that I could show using bars on the skill section of the client.
I know this pieces of code are not something really complex and I only post it in case someone is struggling like I did with this issue, will also create a thread on how to display it on OtClient. (Show additional skills on client (https://otland.net/threads/show-additional-skills-on-client.265785/))

rune1.pngrune2.png

This will create a skill that has all working functions for it (addSkillTries, getSkillLevel and so on) BUT you need to code, be it in Lua or in C++, how the player is supposed to advance or gain experience in the skill itself.
I will use "Runecraft" as an example skill. With that said, let's start.

tools.cpp
Search for this line:
Code:
case SKILL_FISHING:
            return "fishing";
And under it paste:
Code:
case SKILL_RUNECRAFT:
            return "runecraft";

luascript.cpp
Search for this line: registerEnum(CONDITION_PARAM_SKILL_FISHING)
And under it paste:
Code:
registerEnum(CONDITION_PARAM_SKILL_RUNECRAFT)
registerEnum(CONDITION_PARAM_SKILL_RUNECRAFTPERCENT)

Now search for registerEnum(SKILL_FISHING)
And paste this under that line: registerEnum(SKILL_RUNECRAFT)

Items.cpp
Search for this line: {"skillfish", ITEM_PARSE_SKILLFISH},
Right under it paste: {"skillrunecraft", ITEM_PARSE_SKILLRUNECRAFT},

Now look for:
Code:
case ITEM_PARSE_SKILLFISH: {
                    abilities.skills[SKILL_FISHING] = pugi::cast<int32_t>(valueAttribute.value());
                    break;
                }
And under it paste:
Code:
case ITEM_PARSE_SKILLRUNECRAFT: {
                    abilities.skills[SKILL_RUNECRAFT] = pugi::cast<int32_t>(valueAttribute.value());
                    break;
                }

iologindata.cpp
Search for: bool IOLoginData::loadPlayerById(Player* player, uint32_t id)

Pay attention to the query some lines below. Replace 'skill_fishing', 'skill_fishing_tries',

For: 'skill_fishing', 'skill_fishing_tries', 'skill_runecraft', 'skill_runecraft_tries',

NOTE: I can't seem to use the symbol it should contain, just don't use this ' and use the ones you see in the query.

Search for: bool IOLoginData::loadPlayerByName(Player* player, const std::string& name) and repeat the same as before (Replace the query lines)

Now look for: static const std::string skillNames[]
And replace the entire line with static const std::string skillNames[] = {"skill_fist", "skill_club", "skill_sword", "skill_axe", "skill_dist", "skill_shielding", "skill_fishing", "skill_runecraft"};

Just under it you will find this line: static const std::string skillNameTries[]
Replace the entire line with: static const std::string skillNameTries[] = {"skill_fist_tries", "skill_club_tries", "skill_sword_tries", "skill_axe_tries", "skill_dist_tries", "skill_shielding_tries", "skill_fishing_tries", "skill_runecraft_tries"};

Now look for: player->skills[SKILL_FISHING].tries
And under that line paste:
Code:
query << "'skill_runecraft' = " << player->skills[SKILL_RUNECRAFT].level << ',';
    query << "'skill_runecraft_tries' = " << player->skills[SKILL_RUNECRAFT].tries << ',';
NOTE: Same as before, had to use ' instead of the actual symbol, please remember to use the correct one.

condition.cpp
Search for:
Code:
case CONDITION_PARAM_SKILL_FISHINGPERCENT: {
            skillsPercent[SKILL_FISHING] = value;
            return true;
        }
And under it paste:
Code:
case CONDITION_PARAM_SKILL_RUNECRAFT: {
            skills[SKILL_RUNECRAFT] = value;
            return true;
        }

        case CONDITION_PARAM_SKILL_RUNECRAFTPERCENT: {
            skillsPercent[SKILL_RUNECRAFT] = value;
            return true;
        }

items.h
Search for: ITEM_PARSE_SKILLFISH,
And under it paste: ITEM_PARSE_SKILLRUNECRAFT,

enums.h
Search for: CONDITION_PARAM_DISABLE_DEFENSE = 47,
And under it paste:
Code:
CONDITION_PARAM_SKILL_RUNECRAFT = 48,
CONDITION_PARAM_SKILL_RUNECRAFTPERCENT = 49,
After that search for: SKILL_FISHING = 6,
And under it paste: SKILL_RUNECRAFT = 7,
NOTE: You will have to set SKILL_MAGLEVEL and SKILL_LEVEL from 7-8 to 8-9 in their values (So id 7 is free for our new skill)

Finally, where it says SKILL_LAST = SKILL_FISHING change it to SKILL_LAST = SKILL_RUNECRAFT

vocation.h
Find float skillMultipliers[SKILL_LAST + 1] = {1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 1.5f, 1.1f}; and replace it with float skillMultipliers[SKILL_LAST + 1] = {1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 1.5f, 1.1f};

vocation.cpp
Search for uint32_t Vocation::skillBase[SKILL_LAST + 1] = {50, 50, 50, 50, 30, 100, 20};
Change it to uint32_t Vocation::skillBase[SKILL_LAST + 1] = {50, 50, 50, 50, 30, 100, 20, 20};

Well, that should be about it, hope it's useful to someone. If you need any help I would answer to the best of my knowledge.

If you need to create a new database you can add this to your schema.sql:
Code:
'skill_runecraft' int(10) unsigned NOT NULL DEFAULT 10,
'skill_runecraft_tries' bigint(20) unsigned NOT NULL DEFAULT 0,
Again, can't use the correct symbol, please careful about that.

Or you can run this sql query on an existing database:
Code:
ALTER TABLE players
ADD COLUMN skill_runecraft int(10) unsigned NOT NULL DEFAULT 10,
ADD COLUMN skill_runecraft_tries bigint(20) unsigned NOT NULL DEFAULT 0;
 
Last edited:

Creater

From 0 to Hero :>
Premium User
Joined
Oct 15, 2018
Messages
71
Best answers
0
Reaction score
4
Location
Poland
That's same when I'll want change one of skills? Means just only change everything on mine?
 
OP
Ramirow

Ramirow

Excellent OT User
Joined
Aug 22, 2009
Messages
495
Best answers
13
Reaction score
200
Location
Argentina
That's same when I'll want change one of skills? Means just only change everything on mine?
I don't really understand your question, I'll try to guess what you meant, you can use this code and change the name of the skill to whatever you want, or add multiple of them.
 

Creater

From 0 to Hero :>
Premium User
Joined
Oct 15, 2018
Messages
71
Best answers
0
Reaction score
4
Location
Poland
I don't really understand your question, I'll try to guess what you meant, you can use this code and change the name of the skill to whatever you want, or add multiple of them.
For example I will be want change fishing for runecraft, I need just only switch all of name in files what you wrote?

@edit

Sorry mistake, I understood right know, this is that what I want. But how can I set how skill this?
 
Last edited:
OP
Ramirow

Ramirow

Excellent OT User
Joined
Aug 22, 2009
Messages
495
Best answers
13
Reaction score
200
Location
Argentina
For example I will be want change fishing for runecraft, I need just only switch all of name in files what you wrote?

@edit

Sorry mistake, I understood right know, this is that what I want. But how can I set how skill this?
You can modify the lines that contain the Fishing skill only yes, that way you will replace Fishing for Runecraft.

Rami back with another great release, you are a beast dude!
It's not much really, I couldn't find how to do it so it was trial and error, surely there are things I maybe overlooked. Managed to get it working, altough i'm running a downgraded TFS 1.3...I have my doubts about the manaleech, critical hit chance, etc displaying properly in newer versions. Will have to see if someone with those versions happens to test this.

@Creater how skill this? If you mean how to level up the skill you can use player:addSkillTry(SKILL_RUNECRAFT, 1) if you pretend to code the skill on Lua.
That's just for one try (It works like a hit with a club, axe, etc)
 
Last edited:

Creater

From 0 to Hero :>
Premium User
Joined
Oct 15, 2018
Messages
71
Best answers
0
Reaction score
4
Location
Poland
That really I mean for example making a floor what getting this skill so propably I'll be must set it in server option. But I'll try find :)
 

MikeOT

Active Member
Joined
Jan 22, 2017
Messages
195
Best answers
2
Reaction score
53
I have a question (that may be dumb, and I'm probably overlooking it).

I have an entire crafting system written in LUA with just about every OSRS style skill working 100%.

I've tried to get opcodes to work to display on the client to no avail, and I'd rather have it working through the sources anyway.

My question is this:

How many skill tries = level?

In my lua scripts, I have set up a central exp table for my crafting skills that they use. (So if you cut a tree you get +20exp, if you cut a maple you get +40exp, etc), and you advance level that way.

How do i figure how many skill tries = a level up for each level?
 
OP
Ramirow

Ramirow

Excellent OT User
Joined
Aug 22, 2009
Messages
495
Best answers
13
Reaction score
200
Location
Argentina
I have a question (that may be dumb, and I'm probably overlooking it).

I have an entire crafting system written in LUA with just about every OSRS style skill working 100%.

I've tried to get opcodes to work to display on the client to no avail, and I'd rather have it working through the sources anyway.

My question is this:

How many skill tries = level?

In my lua scripts, I have set up a central exp table for my crafting skills that they use. (So if you cut a tree you get +20exp, if you cut a maple you get +40exp, etc), and you advance level that way.

How do i figure how many skill tries = a level up for each level?
In my case, if you look at vocation.h and vocation.cpp you see the multipliers for every skill, in the case of the example I gave, the advance rate is the same as fishing. I don't really know how to determine the exact number of tries tho, forgot to mention you can also add multipliers to vocations.xml for different vocations. So, a druid could be more profficient at making runes and advances faster (not really faster, they just need less tries to advance)
 

MikeOT

Active Member
Joined
Jan 22, 2017
Messages
195
Best answers
2
Reaction score
53
Ahhh.

Does anyone know how to figure how many skill tries it takes for each level?
 

amoxicilina

Well-Known Member
Joined
Jun 25, 2010
Messages
25
Best answers
0
Reaction score
1
I would like to know how to increase the maximum skill of my server from 201 to 350, please help me.
 

Creater

From 0 to Hero :>
Premium User
Joined
Oct 15, 2018
Messages
71
Best answers
0
Reaction score
4
Location
Poland
How that's looking with for example in items.otb when I change example sword skill? I must everysingle line with sword change on another think?
 

MikeOT

Active Member
Joined
Jan 22, 2017
Messages
195
Best answers
2
Reaction score
53
How that's looking with for example in items.otb when I change example sword skill? I must everysingle line with sword change on another think?
If you are renaming "sword" in sources to something else, then yes, you'll need to change the item references also
 

Awesomedudei

Revolutionot.com
Joined
Jan 20, 2010
Messages
281
Best answers
0
Reaction score
42
Location
Sweden
In Enums.h

Can i add more like

SKILL_RUNECRAFT = 9,

with numbers like 11, 12 etc?
Or am i limited to only using 0-9
 
Top