Skip to content

Instantly share code, notes, and snippets.

@pydsigner
Last active April 28, 2016 03:33
Show Gist options
  • Save pydsigner/71c2c393e368a1114bf3 to your computer and use it in GitHub Desktop.
Save pydsigner/71c2c393e368a1114bf3 to your computer and use it in GitHub Desktop.
Aphor — NPC Demo
; Requires a comparison expression→comparison function post-processor
npcs.script("The Doctor", 184, "009-2", 110, 44) {
func(`main) {
if(player.level < 25) {
npc.message("Hmm, it's very interesting, very ... (mumbling).")
}
elif(player.qvars.episode = nil) {
introduction()
}
elif(player.qvars.episode = 2, player.level ≥ 40) {
discuss_miler()
}
else() {
if(player.qvars.episode = 1) {
first_check()
}
else() {
normal_prompt()
}
}
close()
}
func(`introduction) {
npc.message("Quite interesting, quite interesting indeed.")
player.prompt("Um, might I ask, what is so interesting?")
npc.message("Well, you are. You're quite interesting. I've been watching you for some time now, as you've been helping so many people: you're quite a master at what you do, you know.")
player.prompt("Well, thanks.")
npc.message("I don't suppose you have some herbs and a few bottles of water with you, do you?")
player.prompt("'Some herbs and water'? Could you be more specific?")
npc.message("Ah, sorry, of course. I need 50 mauve herbs, 50 cobalt herbs, 50 gamboge herbs, 50 alizarin herbs and 10 bottles of water as well.")
player.prompt("That shouldn't been too hard, but do I get something in return?")
npc.message("I suppose, what would you like?",
"Er, nevermind, I've thought of something to give you. You can go off now and get what I need.")
player.qvars.episode :: 1
}
func(`first_check) {
if(check_tea_items()) {
npc.message("Mmm, it's been so long since I have had herbal tea. You have my gratitude.")
player.prompt("Seriously? What sort of reward is that?")
npc.message(""Well, I suppose you can have what's left of my tea.")
player.getitem("DarkConcentrationPotion", 5)
player.prompt("Oh, thank you!")
player.qvars.episode :: 2
}
}
func(`normal_prompt) {
npc.message("If you want, you can bring me some more of those herbs and water.")
player.menu(["Alright, I have them here!", normal_check],
["Can you remind me what I need to get again?", item_reminder],
["No thanks, see ya!"])
}
func(`normal_check) {
if(check_tea_items()) {
player.getitem("DarkConcentrationPotion", 5)
npc.message("Thanks, enjoy!")
}
}
func(`discuss_miler) {
npc.message("Thank you for helping me make my tea. I hope the potions have been helpful...",
"That reminds me. I have a friend in Nivalis named Miler who gave me some hints on the recipe. Would you take him a sample of what I gave you?",
"If you've used all the ones I've given you, just remember that you can always bring me more ingredients...")
player.menu(["I'll go right away],
["Ah, I used them all... I suppose I need to gather more ingredients first..."],
["Oh, I have all the ingredients right here!", miler_check])
player.qvars.episode :: 3
}
func(`miler_check) {
if(check_tea_items()) {
npc.message("Remember to save one for Miler!")
player.getitem("DarkConcentrationPotion", 5)
}
}
func(`check_tea_items) {
if(player.hasitem("GambogeHerb", 50), player.hasitem("CobaltHerb", 50),
player.hasitem("MauveHerb", 50), player.hasitem("AlizarinHerb", 50),
player.hasitem("BottleOfWater", 50)) {
player.delitem("MauveHerb", 50)
player.delitem("CobaltHerb", 50)
player.delitem("GambogeHerb", 50)
player.delitem("AlizarinHerb", 50)
player.delitem("BottleOfWater", 10)
true
}
else() {
missing_items()
false
}
}
func(`missing_items) {
npc.message("Sorry, you do not have enough ingredients. You'd better search thoroughly.")
player.menu(["Can you remind me what I need to get?", item_reminder],
["Ok, I'll go find what you need."])
}
func(`item_reminder) {
npc.message("Ah, sorry, of course. I need 50 mauve herbs, 50 cobalt herbs, 50 gamboge herbs, 50 alizarin herbs and 10 bottles of water.")
}
main()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment