Skip to content

Instantly share code, notes, and snippets.

@baughj
Created August 12, 2014 00:47
Show Gist options
  • Save baughj/b9d6eb2a974acb17207c to your computer and use it in GitHub Desktop.
Save baughj/b9d6eb2a974acb17207c to your computer and use it in GitHub Desktop.
Example of scripting in Hybrasyl
"""Information about the script goes here"""
name = "Riona"
description = "Riona in Mileth Inn"
author = "Justin Baugh <[email protected]>"
class Scriptable(object):
def __init__(self):
# Set up stuff here
tq = world.NewDialogSequence("Training Quest",
world.NewDialog("A new Aisling like you should go train with Vorlof. To get to Vorlof, walk out of this Inn and follow the path behind the statue."),
world.NewDialog("""((To find out where you can begin quests, click on your character. Then click the 'Event' tab on the right.))"""))
npc.AddPursuit(tq)
wth = world.NewDialogSequence("Welcome to Hybrasyl!",
world.NewDialog("""Welcome to Hybrasyl, Aisling! This is an out of character explanation as to what the heck it is, and where you are."""),
world.NewDialog("""Hybrasyl was a project started by a number of old Dark Ages players to essentially emulate the old Dark Ages, allowing it to live on in a new form."""),
world.NewDialog("""Although it shares much in common with Dark Ages, there are quite a few differences in how various in-game features are implemented. For more information, please visit our website: http://www.hybrasyl.com ."""),
world.NewDialog("""We truly hope you enjoy your time in New Temuair, and if you don't, you'll let us know what we can do to make it better. If you encounter a bug, please report it by going to our website! We will try to fix it as soon as we can."""))
npc.AddPursuit(wth)
optionTest = world.NewDialogSequence("Dialog & Scripting Test",
world.NewDialog("""Welcome to the test of the dialog system, Aisling. I'm Riona, and I'll be your host. Hit next to display an options dialog."""),
world.NewOptionsDialog("""This is an options dialog. Please select an option.""", ['I like this one.', 'Actually, this one is better.'], lambda x: npc.Say('You picked something! Wonderful.') ),
world.NewDialog("""Thanks for picking an option, Aisling. It means a lot to me. Now, let's try something else. """),
world.NewOptionsDialog("""This is a different type of options dialog. Even though I'm just a mundane, I can dazzle you with spell effects. Pick anything you like!""", {'Awesome Teleport Effect' : lambda x: invoker.DisplayEffect(306), 'A Less Impressive Effect' : lambda x: invoker.DisplayEffect(312)}),
world.NewDialog("""There, wasn't that fun? Now, let's try something else."""),
world.NewTextDialog("Display text", "Tell me your name, Aisling.", "I'll write it down in my inn's register.", 30, lambda x: npc.Say("Thanks, %s! Welcome to my humble inn." % x) ),
world.NewDialog("""This concludes the dialog and scripting test. Thank you for your time, Aisling."""))
npc.AddPursuit(optionTest)
scriptingTest = world.NewDialogSequence("API Functionality Test")
scriptingTest.AddDialog(world.NewOptionsDialog("""Select an API function to test.""",
{'GiveExperience: 100k': lambda x: self.GiveXP(),
'GiveItem: cherries': lambda x: self.GiveCherries(),
'TakeItem: cherries': lambda x: self.TakeCherries(),
'TakeExperience: 100k': lambda x: self.TakeXP()}))
npc.AddPursuit(scriptingTest)
branchTest = world.NewDialogSequence("Riona's Hair")
branchTest.AddCheck(lambda: self.hairCheck())
branchTest.AddDialog(world.NewDialog("""((This is a simple quest implemented to test branching dialogs and the usage of player flags. It is intended to utilize - and demonstrate - much of Hybrasyl's new scripting functionality.))"""))
branchTest.AddDialog(world.NewOptionsDialog("""Oh, Aisling! Nice to see you again. Pray tell, which hair color do you think suits me best...? Be honest, Aisling!""",
{'I really do like red, actually': lambda x: invoker.StartSequence('riona-redhair-start'),
'Brown, I think.': lambda x: invoker.StartSequence('riona-brownhair-start'),
'Blonde, maybe?': lambda x: invoker.StartSequence('riona-blonde-start') }))
npc.AddPursuit(branchTest)
rionared = world.NewDialogSequence('riona-redhair-start',
world.NewDialog("Oh, I don't know. I've always wondered what I'd look like as a brunette...then maybe Vorlof would take note of me."),
world.NewDialog("Aisling, won't you do me a favor, and give this note to him? I'd do it myself but I'm just so busy!", lambda: self.VorlofLetter()))
npc.RegisterSequence(rionared);
rionabrown = world.NewDialogSequence('riona-brownhair-start',
world.NewDialog("Brown! Lovely. Such a smart Aisling! Now if I could only buy some dye...but I hear the King is hoarding it."),
world.NewDialog("Perhaps you can plead with him on my behalf? Certainly he'll listen to an Aisling!", lambda: invoker.SetFlag('riona-hair', 'bruce') ))
npc.RegisterSequence(rionabrown);
rionablonde = world.NewDialogSequence('riona-blonde-start',
world.NewDialog("Blonde, really? You've no sense of style, Aisling! Hmmph!", lambda: invoker.SystemMessage('Riona scoffs and returns to her tasks.') ))
npc.RegisterSequence(rionablonde);
rionavorlof = world.NewDialogSequence('riona-vorlof-inprogress',
world.NewDialog("...Have you given my letter to Vorlof yet? O, please, Aisling, won't you deliver it?"))
npc.RegisterSequence(rionavorlof);
rionabruce = world.NewDialogSequence('riona-bruce-inprogress',
world.NewDialog("Have you convinced the King to part with some of his dye? I'm sure if you tell him a story about your exploits..."))
npc.RegisterSequence(rionabruce);
def TakeCherries(self):
invoker.SystemMessage('Riona takes your cherries.');
invoker.TakeItem('Cherries');
def GiveCherries(self):
invoker.SystemMessage('Cherries are good for you.');
invoker.GiveItem('Cherries');
def GiveXP(self):
invoker.GiveExperience(100000);
def TakeXP(self):
invoker.TakeExperience(100000);
def hairCheck(self):
if invoker.GetFlag('riona-hair') == 'vorlof':
invoker.StartSequence('riona-vorlof-inprogress', npc)
elif invoker.GetFlag('riona-hair') == 'bruce':
invoker.StartSequence('riona-bruce-inprogress', npc)
else:
return True
return False
def VorlofLetter(self):
invoker.SetFlag('riona-hair', 'vorlof');
invoker.SystemMessage('Riona gently hands you a letter with a wax seal.')
invoker.GiveItem("Riona's Letter")
def onClick(self, invoker):
npc.DisplayPursuits(invoker)
npc.Say("Hello there %s" % invoker.Name);
def onLoad(self):
npc.Say("Hmm...that's odd. I don't remember what I was just doing...")
def onDeath(self):
npc.Shout("O, help! Help me! I'm dying!")
def onSpawn(self):
print "Yo: Riona is loaded"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment