ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/quest_master.ext
Revision: 1.9
Committed: Sun Jan 29 02:47:04 2017 UTC (7 years, 3 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +2 -2 lines
Log Message:
remove eol whitespace

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 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 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 east 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 => "Wizard Yarid House",
39 match => ['marker', 'quest_wizard_yarid_house'],
40 difficulty => 'tricky',
41 start => "Near the mad mages tower, in the western part of Scorn you will find a house with a red roof. It's wizard Yarid's house, he died while experimenting in his basement. Ask his house keeper for more information and explore the dungeon.",
42 },
43 {
44 name => "Mike Miller House",
45 match => ['marker', 'quest_mike_millers_house'],
46 difficulty => 'tricky',
47 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.>",
48 },
49 {
50 name => "Jeweler Quest",
51 match => ['flag', 'jeweler_quest_1'],
52 difficulty => 'tough fighting',
53 start => "You have to travel to Valleynoy. You find a ship to Valleynoy in Navar. Take it and search the valley of the jeweler town. Go to the welcome house and speak to the old man there."
54 }
55 );
56
57 sub name2quest {
58 my ($n) = @_;
59 for my $q (@QUESTS) {
60 if ($n =~ /\Q$q->{name}\E/i) {
61 return $q
62 }
63 }
64 return undef;
65 }
66
67 # this is the main command interface for the NPC
68 cf::register_script_function "quest_master::talk" => sub {
69 my ($who, $msg, $npc) = @_;
70 my ($cmd, $arguments) = split /\s+/, $msg, 2;
71 $cmd = lc $cmd;
72
73 if ($cmd eq 'finished'
74 || $cmd eq 'unfinished') {
75 my @finished;
76 my @unfinished;
77
78 for my $q (@QUESTS) {
79 my $ok = 0;
80
81 if ($q->{match}->[0] eq 'marker') {
82 ext::map_lib::rec_inv_by_slaying ($who, $q->{match}->[1], sub { $ok = 1 });
83
84 } elsif ($q->{match}->[0] eq 'flag') {
85 if (exists $who->{dialog_flag}->{$q->{match}->[1]}
86 && $who->{dialog_flag}->{$q->{match}->[1]}) {
87 $ok = 1;
88 }
89 }
90
91 if ($ok) {
92 push @finished, $q;
93 } else {
94 push @unfinished, $q;
95 }
96 }
97
98 if ($cmd eq 'finished') {
99 $who->reply ($npc, "You finished these quests: ");
100 for (@finished) {
101 $who->reply ($npc, "- \"$_->{name}\"");
102 }
103
104 } else {
105 $who->reply ($npc, "You didn't finish these quests yet: ");
106 for (@unfinished) {
107 $who->reply ($npc, "- \"$_->{name}\"");
108 }
109 }
110
111 } elsif ($cmd eq 'start') {
112 if ($arguments eq '') {
113 $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'.");
114 $who->reply ($npc, "I know starting points for these quests:");
115 for my $q (@QUESTS) {
116 next unless $q->{start};
117 $who->reply ($npc, "- \"$q->{name}\"");
118 }
119
120 } else {
121 my $q = name2quest ($arguments);
122
123 if ($q) {
124 $who->reply ($npc,
125 "I can give you this starting point for the quest '$q->{name}': $q->{start}"
126 );
127
128 } else {
129 $who->reply ($npc, "I don't know about the quest '$arguments'...");
130 }
131 }
132
133 } elsif ($cmd eq 'spoiler') {
134
135 if ($arguments eq '') {
136 $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'.");
137 $who->reply ($npc, "I know spoilers for these quests:");
138 for my $q (@QUESTS) {
139 next unless $q->{spoiler};
140 $who->reply ($npc, "- \"$q->{name}\", cost: "
141 . cf::cost_string_from_value ($q->{spoiler_cost}));
142 }
143
144 } else {
145 my $q = name2quest ($arguments);
146 if ($q) {
147 if ($who->pay_amount ($q->{spoiler_cost})) {
148 $who->reply ($npc,
149 "Ok, I received ".cf::cost_string_from_value ($q->{spoiler_cost})
150 . " from you. This is the spoiler for the quest "
151 . "'$q->{name}': $q->{spoiler}"
152 );
153 } else {
154 $who->reply ($npc,
155 "I'm sorry, but you don't have enough money to pay the spoiler "
156 . "for the quest '$q->{name}', it would cost you "
157 . cf::cost_string_from_value ($q->{spoiler_cost}) . "."
158 );
159 }
160
161 } else {
162 $who->reply ($npc, "I don't know about the quest '$arguments'...");
163 }
164 }
165
166 } elsif ($cmd eq 'erase_quest_from_me') {
167 my $q = name2quest ($arguments);
168
169 if ($q->{match}->[0] eq 'marker') {
170 my $force;
171 ext::map_lib::rec_inv_by_slaying ($who, $q->{match}->[1], sub { $force = $_[0] });
172 if ($force) {
173 $force->destroy;
174 $who->reply ($npc, "Successfully erased quest marker '$q->{name}' from you!");
175
176 } else {
177 $who->reply ($npc, "I'm sorry, but you never had a quest marker for the '$q->{name}' quest!");
178 }
179
180 } elsif ($q->{match}->[0] eq 'flag') {
181 delete $who->{dialog_flag}->{$q->{match}->[1]};
182 $who->reply ($npc, "Successfully erased quest flag '$q->{name}' from you!");
183 }
184
185 } else {
186 $who->reply ($npc, <<REPL);
187 Welcome adventurer! What do you want to do?
188
189 Do you want me to list your finished quests?
190 Or do you want a list of unfinished quests?
191 Or maybe you want a starting point, or even a spoiler, for a quest?
192 REPL
193 }
194
195 1
196 };
197