linktree Atrinik.org - Multiplayer Online Role Playing Game  >  Development  >  Tutorials
linktree Topic: Ghost102's "way" of making a kill item quest
Pages: [1]   Go Down
  Print  
Author Topic: Ghost102's "way" of making a kill item quest  (Read 3235 times)
0 Members and 1 Guest are viewing this topic. Bookmarked by 0 members.
Offline Ghost

Do not read this or you will go bli
Posts: 162
Gender: Male
« on: August 26, 2010, 03:21:14 am »

I simply use the testmaps, I just paste it into a new script.. edit in what I want.
But lets make a quest for Clearhaven Graveyard. (Ghost's style)(great feedback or editing by a developer is greatly appreciated)

Okay we have just the Dev Testmaps Script: quest_item_kill
Code: [Select]
## @file
## Example quest that requires the player to kill X monsters.

from Atrinik import *
from QuestManager import QuestManager

activator = WhoIsActivator()
me = WhoAmI()
msg = WhatIsMessage().strip().lower()

## The quest.
quest = {
# Name of this quest.
"quest_name": "Dev Testmaps Quest 5",
# Type of this quest.
"type": QUEST_TYPE_KILL,
# How many quest monsters to kill.
"kills": 5,
# Message that will appear in the player's quest list about this quest.
"message": "Kill 5 demiliches.",
                # Whether to keep the quest item.
"quest_item_keep": 1,
# Message that will appear in the player's quest list about this quest.
"message": "Find pile of graveyard dirt from the red ant.",
}

qm = QuestManager(activator, quest)

def main():
if msg == "hello" or msg == "hi" or msg == "hey":
if not qm.started():
me.SayTo(activator, "\nHello {0}. I can demonstrate how 'kill' quest works.\nDo you ^accept^ this quest?".format(activator.name))
elif qm.completed():
me.SayTo(activator, "\nThank you for helping me out.")
elif qm.finished():
me.SayTo(activator, "\nYou have done an excellent job! As this is just an example quest, there is no reward.")
qm.complete()
else:
to_kill = qm.num_to_kill()
me.SayTo(activator, "\nYou still need to kill {0} demilich{1}.".format(to_kill, to_kill > 1 and "es" or ""))

# Accept the quest.
elif msg == "accept":
if not qm.started():
me.SayTo(activator, "\nKill 10 demiliches on this map.")
qm.start()

main()


Okay lets do this bit by bit.. so here's the top-most part.. the name of the quest and it's contents.
Code: [Select]
]## @file
## Example quest that requires the player to kill X monsters.

from Atrinik import *
from QuestManager import QuestManager

activator = WhoIsActivator()
me = WhoAmI()
msg = WhatIsMessage().strip().lower()

## The quest.
quest = {
# Name of this quest.
"quest_name": "Dev Testmaps Quest 5",
# Type of this quest.
"type": QUEST_TYPE_KILL,
# How many quest monsters to kill.
"kills": 5,
# Message that will appear in the player's quest list about this quest.
"message": "Kill 5 demiliches.",
}

Now let's change the 'quest_name' to: Haunting Continues to it would be like this
Code: [Select]
# Name of the quest.
"quest_name": "Haunting Continues",

Now, for the number of kill's a player must have to complete the quest.
Code: [Select]
# How many quest monsters to kill.
"kills": 15,

So, we want it to where a player has to kill 15 skeletons.
Mk, moving on.. so the text that will appear in the Quest List.
Code: [Select]
# Message that will appear in the player's quest list about this quest.
"message": "Kill 15 skeletons in the Clearhaven Graveyard.",
}

Now, for to keep the item and what item you get!
Code: [Select]
# Whether to keep the quest item.
"quest_item_keep": 1,
# Message that will appear in the player's quest list about this quest.
"message": "If you find a key, come and speak to me.",


So, we wanted it to say that we need a player to kill 15 skeletons. So there it is.

Now for the next part... Now for the text while talking to the one who gives the quest.

Code: [Select]
qm = QuestManager(activator, quest)

def main():
if msg == "hello" or msg == "hi" or msg == "hey":
if not qm.started():
me.SayTo(activator, "\nHello {0}. what's that? How do I know your name? Well, I know everyone's name! Lately I've been getting haunted by some spirits.\nI think they need to be put to ^sleep^.. for good.".format(activator.name))
elif qm.completed():
me.SayTo(activator, "\nThank you for helping me out.elif qm.finished():
me.SayTo(activator, "\nYou have done an excellent job! Hm, a key? Well, that's the Catacombs Key. You can keep it. I don't even know where the Catacombs are so, I hope you find it.")
qm.complete()
else:
to_kill = qm.num_to_kill()
me.SayTo(activator, "\nYou still need to kill {0} skeletons{1}.".format(to_kill, to_kill > 1 and "es" or ""))


As you can see.. I've changed what need's to be put in for the style of quest you want.

Now, for the last part! I will change some thing's so pay attention!
Code: [Select]
# Accept the quest.
elif msg == "sleep":
if not qm.started():
me.SayTo(activator, "\nYes, I mean kill them, I can't kill a living soul so I'm hoping you can.")
qm.start()

Now the end of Ghost102's Kill Item Quest!





« Last Edit: May 09, 2011, 09:05:13 am by Kiana »  Logged

Collector of Chilis and Gems/Pearls/Nuggets of all size and type
Offline Mamoru
Developer
Edwin Miltenburg

Posts: 625
Gender: Male
« Reply #1 on: May 16, 2011, 11:50:34 am »

I've tried your "way" by copy&pasting from the tutorial.
Here are the problems the server found just by running the script:


In your second codebox there's ]## @file on top:
Code: (server output) [Select]
[Chat]   Say: Kiana: hi
[Debug]  Python: triggerEvent(): eventcode 6
[Debug]  Python: Start script file >Ghost102Script.py<, activator:
Kiana, who: Ghost102, other: >NULL<, text: hi, parms: 0, 0, 0, 2
  File "../../test/maps/Ghost102Script.py", line 1
    ]## @file
    ^
SyntaxError: invalid syntax

Should leave the ] out.


You do not use indentation in your script, at least not in your code boxes above:
Code: (server output) [Select]
[Chat]   Say: Kiana: hi
[Debug]  Python: triggerEvent(): eventcode 6
[Debug]  Python: Start script file >Ghost102Script.py<, activator:
Kiana, who: Ghost102, other: >NULL<, text: hi, parms: 0, 0, 0, 2
  File "../../test/maps/Ghost102Script.py", line 27
    if msg == "hello" or msg == "hi" or msg == "hey":
     ^
IndentationError: expected an indented block

Use the Tab key to properly indent the if, else, etc. like in quest_item_kill.


In your text for talking to the NPC some characters are missing:
Code: (server output) [Select]
[Chat]   Say: Kiana: hi
[Debug]  Python: triggerEvent(): eventcode 6
[Debug]  Python: Start script file >Ghost102Script.py<, activator:
Kiana, who: Ghost102, other: >NULL<, text: hi, parms: 0, 0, 0, 2
  File "../../test/maps/Ghost102Script.py", line 31
    me.SayTo(activator, "\nThank you for helping me out.elif qm.finished():
                                                                          ^
SyntaxError: EOL while scanning string literal

me.SayTo(activator, "\nThank you for helping me out.elif qm.finished():
should be:
         me.SayTo(activator, "\nThank you for helping me out.")
      elif qm.finished():



There's something missing at the end of your last codebox:
Code: (server output) [Select]
[Chat]   Say: Kiana: hi
[Debug]  Python: triggerEvent(): eventcode 6
[Debug]  Python: Start script file >Ghost102Script.py<, activator:
Kiana, who: Ghost102, other: >NULL<, text: hi, parms: 0, 0, 0, 2
[Debug]  Python: done (returned: 0).

Add main() on a new line after qm.start() (without indentation).


These were all syntax errors. With just the script the quest can't be done though, yet. What is the next step to take to make a "kill item quest" according to your way? I hope you'd still like to continue on this tutorial. I'm looking forward to it :)
~Kiana~

N.b. I've attached the script with the python syntax errors mentioned above fixed.

* Ghost102Script.py (1.55 KB - downloaded 188 times.)

* haunting1.png (67.56 KB, 413x190 - viewed 344 times.)

* haunting2.png (1.58 KB, 225x37 - viewed 348 times.)
« Last Edit: May 16, 2011, 12:36:12 pm by Kiana »  Logged
Pages: [1]   Go Up
  Print  
 
Jump to: