Smart learning of new skills

Example of learning new skills (including learn from NPC)

In one of the updates to the bot lists of available for learning skills were added: LearnList (if you can learn skills everywhere) и LearnList2 (if you can learn skills from NPC)
The elements of these lists are objects of the TLearnItem class.

In this regard, all the bikes and crutches, written earlier for the study of skills can now be transformed around the following procedure:

procedure LearnSkills();
var i: integer;
begin
  for i:= 0 to LearnList.Count-1 do begin                    // running through the list of available skills
    if (User.Level >= LearnList(i).NeedLevel)                // if our level is suitable
    and (User.SP >= LearnList(i).SpCost) then begin          // and we have enough SP (+ other conditions can be checked)
      if Engine.LearnSkill(LearnList(i).ID) then             // learn skill
        Print('Learned: ' + LearnList(i).Name)
      else 
        Print('Could not learn: ' + LearnList(i).Name);
    end;  
  end;
end;

If we do not need to run up to the NPC, then such a function can be run for example in the stream, adding an infinite loop to it:

procedure LearnSkillsThread();
var i: integer;
begin
  while delay(999) do begin
    for i:= 0 to LearnList.Count-1 do begin                  // running through the list of available skills
      if (User.Level >= LearnList(i).NeedLevel)              // if our level is suitable
      and (User.SP >= LearnList(i).SpCost) then begin        // and we have enough SP (+ other conditions can be checked)
        if Engine.LearnSkill(LearnList(i).ID) then           // learn skill
          Print('Learned: ' + LearnList(i).Name)
        else 
          Print('Could not learn: ' + LearnList(i).Name);
      end;
    end;
  end;  
end;

begin
  Script.NewThread(@LearnSkillsThread);
  // code
end.

If you need to approach the NPC to learn skills, then add a runner to the mentor in the script, open a dialogue with it and run the same function, replacing LearnList everywhere with LearnList2.