Adding a skill trainer is a fairly straight forward process. In order to start this make sure you have your Healing Hands skill done and added to the game along with Andarry or another peaceful mob youc an use to assign a dialog to. We are going to make modifications to this skill and add a trainer dialog to Andarry
Healing Hands Change
You will need to make a simple change to the skill
skill.trained = True
This will make the skill trainable instead of automatic. This will require a trainer be used to learn the skill.
Adding the Trainer code
Open up the following file
test.game\genesis\dialog\skilltrainers.py
You will need to add the following bit of code into it at the end of the file. There should be only 4 lines of code in this file
def CreateSkillTrainer(dialogName, skillName,cost):
tin = long(cost[0])
tin += cost[1] * 100L
tin += cost[2] * 10000L
tin += cost[3] * 1000000L
tin += cost[4] * 100000000L
money = GenMoneyText(tin)
greeting = DBDialogLine(text = "Hello, would you like to learn the skills I have to offer?\\n")
choice = DBDialogChoice(text=r'Learn %s for %s.'%(skillName,money))
choice.failLine = DBDialogLine(text="\\nI cannot teach you the %s skill at this time.\\n"%skillName)
choice.successLine = DBDialogLine(text="\\nAlright, here's what you need to know!\\n")
action = DBDialogAction()
action.takeTin = tin
action.trainSkill(skillName)
req = DBDialogRequirement()
req.addSkillRequirement(False,skillName)
choice.successLine.addAction(action)
choice.addRequirement(req)
greeting.addChoice(choice)
dialog = DBDialog(name=dialogName,greeting = greeting)
return greeting
def AddSkill(greeting, skillName,cost):
tin = long(cost[0])
tin += cost[1] * 100L
tin += cost[2] * 10000L
tin += cost[3] * 1000000L
tin += cost[4] * 100000000L
money = GenMoneyText(tin)
choice = DBDialogChoice(text=r'Learn %s for %s.'%(skillName,money))
choice.failLine = DBDialogLine(text="\\nI cannot teach you the %s skill at this time.\\n"%skillName)
choice.successLine = DBDialogLine(text="\\nAlright, here's what you need to know!\\n")
action = DBDialogAction()
action.takeTin = tin
action.trainSkill(skillName)
req = DBDialogRequirement()
req.addSkillRequirement(False,skillName)
choice.successLine.addAction(action)
choice.addRequirement(req)
greeting.addChoice(choice)
greeting = CreateSkillTrainer("Andarry Trainer", "Healing Hands",(15,2,2,0,0))
This performs 3 functions. The first one to create a skill trainer and assign the initial skill. The 2nd one to create add an additional skill to that trainer. The final one is to set the cost (tin is the first number).
Adding the trainer function to a mob
Open up the spawns.py file at
test.game\genesis\zone\zoneone\spawns.py
Change the location or mob to whatever you want and add the following dialog line (with the case of Andarry remove his old one)
spawn.dialog = "Andarry Trainer"
Compile and startup the game. When you click on Andarry he should have a skill you can train.
Adding additional skills to a single trainer
The process is very simple. First create a new skill and set it up to be trainable. Second open back up the skilltrainers.py file and add this right after the first skill.
AddSkill(greeting, "My Skill Name",(15,2,2,0,0))
This will use the greeting value passed after the initial creation of the dialog and then add a new dialog options. Change "My Skill Name" to the appropriate name. Once this is done compile and enter the game and you should see 2 selections.
Additional Trainers
This is simple, simply add this after everything you have done so far
greeting = CreateSkillTrainer("New Trainer", "My New Skill 2",(15,2,2,0,0))
This will create a dialog called "New Trainer". Assign it to a different mob and you are set to go.

