View Single Post
  #1  
Old 12-29-2008, 12:14 PM
djeryv
Hill Giant
 
Join Date: Apr 2008
Posts: 234
Default NPC Skill Trainer

I have been having problems with skills going past 21 (specifically, skills like Blacksmithing, Tailoring...crafting skills basically). Even with the server rules set for Skills:MaxTrainTradeskills set to 250, these skills were not going past 21. Some say that it is a client issue...so...here is what I did to fix this...

I made this perl script (my first quest type script)...

Code:
###################################
#Zone: All (Global)               #
#Short Name:                      #
#Zone ID: 55                      #
###################################
#NPC Name: Teacher_of_Norrath     #
#NPC ID: All                      #
#Quest Status: Complete           #
###################################
sub EVENT_SAY {

$myskills = $client->GetSkillPoints()-1;

if($text=~/hail/i){
quest::say("Greetings, $name. Have you come to me for my [teachings]? I can only teach you more of what you started learning from your Guildmaster and only if it does not exceed your level. Make sure to [zone] after I am done teaching you.");
}

if($text=~/zone/i){
quest::say("Yes, you must leave this zone after learning from me so you will see the results of your lessons. Even your Guildmaster will not recognize your achievements if you do not zone first.");
}

if($text=~/teachings/i){
$pcskills = $client->GetSkillPoints();
quest::say("I can teach you many things with your $pcskills skill points. I can teach you more about [alchemy], [baking], black[smithing], [brewing], [fletching], [jewelry] making, [poison] making, [pottery], [research], [tailoring] and [tinkering].");
}

if($text=~/alchemy/i){
  if ($client->GetRawSkill(59)<$client->MaxSkill(59) && $client->GetSkillPoints()>0 && $client->GetRawSkill(59)>0){
    $skill_from = $client->GetRawSkill(59);
    $client->IncreaseSkill(59);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(59);
    quest::say("I have taught you a little more about alchemy from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about alchemy.");
  }
}

if($text=~/smithing/i){
  if ($client->GetRawSkill(63)<$client->MaxSkill(63) && $client->GetSkillPoints()>0 && $client->GetRawSkill(63)>0){
    $skill_from = $client->GetRawSkill(63);
    $client->IncreaseSkill(63);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(63);
    quest::say("I have taught you a little more about blacksmithing from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about blacksmithing.");
  }
}

if($text=~/poison/i){
  if ($client->GetRawSkill(56)<$client->MaxSkill(56) && $client->GetSkillPoints()>0 && $client->GetRawSkill(56)>0){
    $skill_from = $client->GetRawSkill(56);
    $client->IncreaseSkill(56);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(56);
    quest::say("I have taught you a little more about making poisons from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about making poisons.");
  }
}

if($text=~/tinkering/i){
  if ($client->GetRawSkill(57)<$client->MaxSkill(57) && $client->GetSkillPoints()>0 && $client->GetRawSkill(57)>0){
    $skill_from = $client->GetRawSkill(57);
    $client->IncreaseSkill(57);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(57);
    quest::say("I have taught you a little more about tinkering from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about tinkering.");
  }
}

if($text=~/research/i){
  if ($client->GetRawSkill(58)<$client->MaxSkill(58) && $client->GetSkillPoints()>0 && $client->GetRawSkill(58)>0){
    $skill_from = $client->GetRawSkill(58);
    $client->IncreaseSkill(58);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(58);
    quest::say("I have taught you a little more about research from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about research.");
  }
}

if($text=~/baking/i){
  if ($client->GetRawSkill(60)<$client->MaxSkill(60) && $client->GetSkillPoints()>0 && $client->GetRawSkill(60)>0){
    $skill_from = $client->GetRawSkill(60);
    $client->IncreaseSkill(60);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(60);
    quest::say("I have taught you a little more about baking from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about baking.");
  }
}

if($text=~/tailoring/i){
  if ($client->GetRawSkill(61)<$client->MaxSkill(61) && $client->GetSkillPoints()>0 && $client->GetRawSkill(61)>0){
    $skill_from = $client->GetRawSkill(61);
    $client->IncreaseSkill(61);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(61);
    quest::say("I have taught you a little more about tailoring from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about tailoring.");
  }
}

if($text=~/fletching/i){
  if ($client->GetRawSkill(64)<$client->MaxSkill(64) && $client->GetSkillPoints()>0 && $client->GetRawSkill(64)>0){
    $skill_from = $client->GetRawSkill(64);
    $client->IncreaseSkill(64);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(64);
    quest::say("I have taught you a little more about fletching from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about fletching.");
  }
}

if($text=~/brewing/i){
  if ($client->GetRawSkill(65)<$client->MaxSkill(65) && $client->GetSkillPoints()>0 && $client->GetRawSkill(65)>0){
    $skill_from = $client->GetRawSkill(65);
    $client->IncreaseSkill(65);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(65);
    quest::say("I have taught you a little more about brewing from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about brewing.");
  }
}

if($text=~/jewelry/i){
  if ($client->GetRawSkill(68)<$client->MaxSkill(68) && $client->GetSkillPoints()>0 && $client->GetRawSkill(68)>0){
    $skill_from = $client->GetRawSkill(68);
    $client->IncreaseSkill(68);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(68);
    quest::say("I have taught you a little more about jewelry making from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about jewelry making .");
  }
}

if($text=~/pottery/i){
  if ($client->GetRawSkill(69)<$client->MaxSkill(69) && $client->GetSkillPoints()>0 && $client->GetRawSkill(69)>0){
    $skill_from = $client->GetRawSkill(69);
    $client->IncreaseSkill(69);
    $client->SetSkillPoints($myskills);
    $skill_this = $client->GetRawSkill(69);
    quest::say("I have taught you a little more about pottery from $skill_from to $skill_this.");
  }
  else {
    quest::say("You are not ready to learn more about pottery.");
  }
}

}
...and named it Teacher_of_Norrath.pl. Then i put it in the templates folder. Now...you can make a brand new NPC for this script but I decided to use something useless on my server...the Priest of Discord. I have a small MiniLogin server with a handful of players and no one does PVP, so by using the Priest of Discord I can take care of this teacher in a more simple way as the Priests are already spawning next to towns. So i ran this query in MySQL...

Code:
UPDATE npc_types SET name='Teacher_of_Norrath' WHERE name='Priest_of_Discord';
...now when I boot up my server...the Priests are now Teachers and they will train your characters past 21 in some select skills. So, whenever I update my PEQ, I simply put my perl script back in the templates folder and rerun the MySQL query above.

Now...he his training is for free but he will keep an eye on your available skill points and will not let you spend more than you have. I hope this is helpful to some.

- Djeryv
Reply With Quote