ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/quest_master.ext
Revision: 1.1
Committed: Thu Apr 24 21:36:21 2008 UTC (16 years, 1 month ago) by elmex
Branch: MAIN
Log Message:
checked in support script for the quest master, for now the quests are listed in the
extension.

File Contents

# Content
1 #! perl
2
3 my @QUESTS = (
4 {
5 name => "Scorn Farmhouse",
6 match => ['marker', 'quest_scorn_farmhouse'],
7 start => "Leave scorn by the eastern gate and look right to the south of the gate, you will find a small farm there. Investigate!",
8 difficulty => 'piece of cake',
9 spoiler_cost => 30000,
10 spoiler => "Ok, get the key on the table in that house, go to the barn, open it with the key, kill all the monsters, especially the troll, take his head (\"Guuh's head\") and walk right in front of the farmer's wife. She will open the door to the storage room. Go in there and take the stuff.",
11 },
12 {
13 name => "Gramp Malone Earhorn",
14 match => ['flag', 'quest_gramp_malones_earhorn'],
15 difficulty => 'be observant',
16 start => 'Go to the hoves in the south west of scorn, go into the south east house from the four houses and ask the woman and/or grandpa malone about his earhorn. H<you will have to find it, maybe it\'s not even on the same map>',
17 spoiler_cost => 50000,
18 spoiler => "You will find his earhorn in the tavern \"The Barking Mule\", he left it in a workbench there.",
19 },
20 {
21 name => "Gramp Malone Walkingstick",
22 match => ['flag', 'quest_gramp_malones_walking_stick'],
23 difficulty => 'be observant',
24 start => 'Go to the hoves in the south west of scorn, go into the south east house from the four houses and ask the woman and/or grandpa malone about his walking stick. H<you will have to find it, maybe it\'s not even on the same map>',
25 spoiler_cost => 50000,
26 spoiler => "The walking stick was lost in the four houses called the \"Riverside Manor\" in the south of Scorn. The House to the very south east has a table, beneath it you will find gramps walking stick."
27 },
28 {
29 name => 'Hero of Scorn',
30 match => ['marker', 'hero_of_scorn'],
31 difficulty => 'easy',
32 start => "Go to the castle of the king of scorn,"
33 ."find the Hall of Quests and finish the first quest.",
34 spoiler_cost => 100000,
35 spoiler => "You have to find the cave where the Goblin Chief hides. You can find that cave by leaving Scorn through the eastern gate, following the road to the east until see a small footpath going to the north. Follow it and you will find a cave. After some levels of fighting you will come to the final level where you will find the Goblin Chief, which usually looks very similar to usual Goblins. Kill him and grab his head, but be careful not to burn it accidentally. Bring that head to the Hall of Quests in the king's castle in scorn, and enter the first teleporter, where you will be awardened with the rank of 'Hero of Scorn'.",
36 },
37 {
38 name => "Mike Miller House",
39 match => ['marker', 'quest_mike_millers_house'],
40 difficulty => 'tricky',
41 start => "In the north west of scorn you will find the 'West Scorn Trademarket', just south from the weapons shop. The first neighbour house to the east of the trademarket, just right next to the street, is Mike Miller's house. Speak to him. H<He wants the angry pixie's head, which you should drop right next to him.>",
42 },
43 );
44
45 sub name2quest {
46 my ($n) = @_;
47 for my $q (@QUESTS) {
48 if ($n =~ /\Q$q->{name}\E/i) {
49 return $q
50 }
51 }
52 return undef;
53 }
54
55 # this is the main command interface for the IPO NPC
56 cf::register_script_function "quest_master::talk" => sub {
57 my ($who, $msg, $npc) = @_;
58 my ($cmd, $arguments) = split /\s+/, $msg, 2;
59 $cmd = lc $cmd;
60
61 if ($cmd eq 'finished'
62 || $cmd eq 'unfinished') {
63 my @finished;
64 my @unfinished;
65
66 for my $q (@QUESTS) {
67 my $ok = 0;
68
69 if ($q->{match}->[0] eq 'marker') {
70 ext::map_lib::rec_inv_by_slaying ($who, $q->{match}->[1], sub { $ok = 1 });
71
72 } elsif ($q->{match}->[0] eq 'flag') {
73 if (exists $who->{dialog_flag}->{$q->{match}->[1]}
74 && $who->{dialog_flag}->{$q->{match}->[1]}) {
75 $ok = 1;
76 }
77 }
78
79 if ($ok) {
80 push @finished, $q;
81 } else {
82 push @unfinished, $q;
83 }
84 }
85
86 if ($cmd eq 'finished') {
87 $who->reply ($npc, "You finished these quests: ");
88 for (@finished) {
89 $who->reply ($npc, "- \"$_->{name}\"");
90 }
91
92 } else {
93 $who->reply ($npc, "You didn't finish these quests yet: ");
94 for (@unfinished) {
95 $who->reply ($npc, "- \"$_->{name}\"");
96 }
97 }
98
99 } elsif ($cmd eq 'start') {
100 if ($arguments eq '') {
101 $who->reply ($npc, "If you want to have a starting pointer for the following quests enter this into the message entry: 'start <name of quest>', for example: 'start hero of scorn'.");
102 $who->reply ($npc, "I know starting points for these quests:");
103 for my $q (@QUESTS) {
104 next unless $q->{start};
105 $who->reply ($npc, "- \"$q->{name}\"");
106 }
107
108 } else {
109 my $q = name2quest ($arguments);
110
111 if ($q) {
112 $who->reply ($npc,
113 "I can give you this starting point for the quest '$q->{name}': $q->{start}"
114 );
115
116 } else {
117 $who->reply ($npc, "I don't know about the quest '$arguments'...");
118 }
119 }
120
121 } elsif ($cmd eq 'spoiler') {
122
123 if ($arguments eq '') {
124 $who->reply ($npc, "If you want to have the spoiler for one the following quests enter this into the message entry: 'spoiler <name of quest>', for example: 'spoiler hero of scorn'.");
125 $who->reply ($npc, "I know spoilers for these quests:");
126 for my $q (@QUESTS) {
127 next unless $q->{spoiler};
128 $who->reply ($npc, "- \"$q->{name}\", cost: "
129 . cf::cost_string_from_value ($q->{spoiler_cost}));
130 }
131
132 } else {
133 my $q = name2quest ($arguments);
134 if ($q) {
135 if ($who->pay_amount ($q->{spoiler_cost})) {
136 $who->reply ($npc,
137 "Ok, I received ".cf::cost_string_from_value ($q->{spoiler_cost})
138 ." from you. This is the spoiler for the quest "
139 ."'$q->{name}': $q->{spoiler}"
140 );
141 } else {
142 $who->reply ($npc,
143 "I'm sorry, but you don't have enough money to pay the spoiler "
144 ."for the quest '$q->{name}', it would cost you "
145 . cf::cost_string_from_value ($q->{spoiler_cost}) . "."
146 );
147 }
148
149 } else {
150 $who->reply ($npc, "I don't know about the quest '$arguments'...");
151 }
152 }
153
154 } elsif ($cmd eq 'erase_quest_from_me') {
155 my $q = name2quest ($arguments);
156
157 if ($q->{match}->[0] eq 'marker') {
158 my $force;
159 ext::map_lib::rec_inv_by_slaying ($who, $q->{match}->[1], sub { $force = $_[0] });
160 if ($force) {
161 $force->remove;
162 $force->destroy (1);
163 $who->reply ($npc, "Successfully erased quest marker '$q->{name}' from you!");
164
165 } else {
166 $who->reply ($npc, "I'm sorry, but you never had a quest marker for the '$q->{name}' quest!");
167 }
168
169 } elsif ($q->{match}->[0] eq 'flag') {
170 delete $who->{dialog_flag}->{$q->{match}->[1]};
171 $who->reply ($npc, "Successfully erased quest flag '$q->{name}' from you!");
172 }
173
174 } else {
175 $who->reply ($npc, <<REPL);
176 Welcome adventurer! What do you want to do?
177 Do you want me to list your finished quests?
178 Or do you want a list of unfinished quests?
179 Or do you want a start point or even a spoiler to a quest?
180 REPL
181 }
182
183 1
184 };
185
186 1;