[MOD] Set character skills after creation.

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

RudgerWolvram
 
Posts: 37
Joined: 01 Jan 2015, 22:27

[MOD] Set character skills after creation.

Post by RudgerWolvram » 02 Jan 2015, 22:51

Changing the post to pertinent information.

This mod will set any new characters skill to the determined amount in each IF statement. The idea here is for skills that are not "gainable" or should be set higher because of the early alpha nature of the game.

Since this uses a trigger BEFORE INSERT on the skills table, any additional skill changes BEFORE INSERT at character creation should be put in this trigger and not a separate one as SQL will not allow it.
Code: Select all
delimiter $$
CREATE TRIGGER `t_set_new_skills`
BEFORE INSERT ON `skills`
FOR EACH ROW BEGIN
  /* Set Piety to 30 so character can pray without needing to pray for homecoming several times */
   IF (New.SkillTypeID = 54 and New.SkillAmount < 300000000) then
      set New.SkillAmount = 300000000;
   end if;

/* Set Warhorse handling to 60 since it is not implemented yet  */
   IF (New.SkillTypeID = 26 and New.SkillAmount < 600000000) then
      set New.SkillAmount = 600000000;
   end if;

END;
$$


Pretty straight forward. And if anyone complains that they need the skill points spent in these, they have the option to remove the skill via the down arrow on their sheet.
Last edited by RudgerWolvram on 09 Jan 2015, 02:31, edited 1 time in total.


Tolarn
 
Posts: 2
Joined: 10 Jan 2015, 03:35

Re: [MOD] Set character skills after creation.

Post by Tolarn » 23 Jan 2015, 12:41

Tried this on our server because we disallowed mining and tunneling. So we've been adding skills manually but it would be really nice to just have it automatic.


Code: Select all
delimiter $$
CREATE TRIGGER `t_set_new_skills`
BEFORE INSERT ON `skills`
FOR EACH ROW BEGIN
  /* Set Prospecting to 60 */
   IF (New.SkillTypeID = 1 and New.SkillAmount < 600000000) then
      set New.SkillAmount = 600000000;
   end if;

/* Set Mining to 60  */
   IF (New.SkillTypeID = 2 and New.SkillAmount < 600000000) then
      set New.SkillAmount = 600000000;
   end if;

/* Set Smelting to 1  */
   IF (New.SkillTypeID = 3 and New.SkillAmount < 600000000) then
      set New.SkillAmount = 10000000;
   end if;
END;
$$


Lumberjack
True Believer
 
Posts: 26
Joined: 13 Dec 2014, 03:16

Re: [MOD] Set character skills after creation.

Post by Lumberjack » 31 Jan 2015, 02:55

I have a problem with those scripts - as of now they only work for the skills that are not part of a skill tree.

It looks like the problem is, the necessary skill value doesn't exist yet in the database. I tried inserting it like that:
Code: Select all
INSERT INTO skills(`CharacterID`, `SkillTypeID`, `SkillAmount`, `LockStatus`) VALUES(New.CharacterID,2,990000000,1);


But it doesn't work ;(.


Any help would be appreciated ;-).


RudgerWolvram
 
Posts: 37
Joined: 01 Jan 2015, 22:27

Re: [MOD] Set character skills after creation.

Post by RudgerWolvram » 05 Feb 2015, 05:57

I ran into that problem and fixed it with the following. Since warhorse can be set to 60, in order to get the chainarmor skill you have to do a BEFORE UPDATE on the skills table.
The catch is, this trigger fires every time someone gets a skill increase, so it is very slightly performance impacting to the database engine.

Code: Select all
CREATE DEFINER=`root`@`localhost` TRIGGER `t_skills_before_update` BEFORE UPDATE ON `skills` FOR EACH ROW BEGIN
 IF (New.SkillTypeID = 26 and New.SkillAmount < 600000000) then
      set New.SkillAmount = 600000000;
   end if;
END


Then i set up a temporary stored proc to run when needed on those that needed chain armor skill

Code: Select all
BEGIN
DECLARE done BOOLEAN DEFAULT FALSE;
DECLARE _CharID INT UNSIGNED;
DECLARE cur CURSOR FOR SELECT ID FROM `character`;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done := TRUE;




OPEN cur;

 ChainArmorLoop:LOOP
 FETCH cur INTO _CharID;
 IF done THEN
    LEAVE ChainArmorLoop;
 END IF;
   IF ((SELECT SkillAmount from skills where CharacterID = _CharID and SkillTypeID = 26) >= 600000000)THEN
      if((Select SkillAmount from Skills where CharacterID = _CharID and skilltypeID = 27) >= 0) Then
         BEGIN
         END;
      else
         INSERT IGNORE INTO skills(`CharacterID`, `SkillTypeID`, `SkillAmount`, `LockStatus`)
         VALUES(_CharID, 27, 0, 1);
      end if;
      
      
   END IF;


END
LOOP ChainArmorLoop;
CLOSE cur;
END


You could add the insert skill portion to the update trigger when the skill in warhorse hits above 30 or 60.

Return to Game mods