[MOD] SQL to set specific skill with robust checks

Place for sharing your game modifications for Life is Feudal: Your Own

Allquixotic
 
Posts: 13
Joined: 14 Jan 2015, 22:22

[MOD] SQL to set specific skill with robust checks

Post by Allquixotic » 21 Feb 2015, 23:51

CLICK HERE to view the SQL code. If you have trouble copying and pasting it from there, CLICK HERE to view it in raw form.

This SQL procedure is intended to set a specific skill for someone while performing robust checks to make sure it is legal.

Features:
  • Lets you know if you typed something wrong, like an invalid skill name or invalid character name.
  • Checks to make sure that setting the skill to the requested value will not exceed the user's skill cap (factoring in intelligence and the current value of the skill if they are already trained in it).
  • Checks to make sure that the prerequisites are met; specifically, that the parent skill is 30 or higher if the requested skill amount is less than 30, and the parent skill is 60 or higher if the requested amount is 60 or higher.
  • Automatically unlocks the next skill in the tree if applicable, and sets it to 0. If the next skill in the tree was locked but non-zero, preserves the value that was set but unlocks it.
  • Works equivalently for locking skills and takes care of locking any skill that depends on it (but does NOT recursively keep checking all the skills down the tree; this is a known limitation right now.)
  • You can specify the skill amount in whole numbers rather than the large numbers used by the raw data.

Setup

The SQL code for the procedure needs to be submitted to your MySQL or MariaDB server (I will refer to this generically as "your SQL server" from here on out, but I am NOT referring to the product Microsoft SQL Server, since that isn't supported by LiF:YO). The in-game console does not accept SQL, so you must execute it on your SQL server.

How you do that will depend on how your server is set up. If you have never connected to your SQL server directly before, you must learn how to do that on your own. I can't tell you how to connect to your SQL server, because it depends on how you installed it, what platform you installed it on, whether it's MySQL or MariaDB, whether you're hosted or running a dedicated server, etc. If you don't know how to do this, consider that a project for you to complete as a pre-requisite before you are able to use this mod.

Once you have access to your SQL server, simply submit the contents of the mod (linked to at the start of the post) to your SQL server as a query. There are literally hundreds of different ways to do this, that range from web interfaces, desktop apps like HeidiSQL, or console commands like mysql. Again, learn how to use your SQL server before trying to use this mod.

Example usage

Assuming you have the mod installed, you can change someone's skill by running a query like this in your SQL server:

CALL p_setSkill('Coorbin', 'Mining', 60, 1);

The above sets the Mining skill to 60 for the character whose first name is Coorbin, then unlocks both Mining and Smelting, but will fail if the user's Prospecting is not at least 60 or if they have exceeded their skill cap.
Last edited by Allquixotic on 22 Feb 2015, 18:06, edited 2 times in total.


Revv
 
Posts: 76
Joined: 22 Sep 2014, 12:53

Re: [MOD] SQL to set specific skill with robust checks

Post by Revv » 22 Feb 2015, 04:23

Is this executed in the query tab of say HeidiSQl (or whatever sql viewer)?
Or is it executed in game?
When providing code it would be great if people could specify where to put it for those of us who don't know.


Allquixotic
 
Posts: 13
Joined: 14 Jan 2015, 22:22

Re: [MOD] SQL to set specific skill with robust checks

Post by Allquixotic » 22 Feb 2015, 16:31

Revv wrote:Is this executed in the query tab of say HeidiSQl (or whatever sql viewer)?
Or is it executed in game?
When providing code it would be great if people could specify where to put it for those of us who don't know.


Edited OP accordingly

Return to Game mods