ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/quest_master.ext
Revision: 1.7
Committed: Thu Nov 27 23:22:14 2008 UTC (15 years, 5 months ago) by elmex
Branch: MAIN
CVS Tags: rel-2_82, rel-2_81, rel-2_80, rel-2_72, rel-2_73, rel-2_76, rel-2_77, rel-2_74, rel-2_75, rel-2_79, rel-2_90, rel-2_92, rel-2_93, rel-2_78
Changes since 1.6: +4 -4 lines
Log Message:
adjusted quest masters hints a bit.

File Contents

# User Rev Content
1 elmex 1.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 elmex 1.7 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 elmex 1.1 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 elmex 1.7 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 elmex 1.1 spoiler_cost => 50000,
26 elmex 1.7 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 elmex 1.1 },
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 elmex 1.2 name => "Wizard Yarid House",
39     match => ['marker', 'quest_wizard_yarid_house'],
40     difficulty => 'tricky',
41 elmex 1.7 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 elmex 1.2 },
43     {
44 elmex 1.1 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 elmex 1.4 {
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 elmex 1.1 );
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 root 1.3 # this is the main command interface for the NPC
68 elmex 1.1 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 root 1.5 . " from you. This is the spoiler for the quest "
151     . "'$q->{name}': $q->{spoiler}"
152 elmex 1.1 );
153     } else {
154     $who->reply ($npc,
155     "I'm sorry, but you don't have enough money to pay the spoiler "
156 root 1.5 . "for the quest '$q->{name}', it would cost you "
157 elmex 1.1 . 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 root 1.6 $force->destroy;
174 elmex 1.1 $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 root 1.5
189 elmex 1.1 Do you want me to list your finished quests?
190     Or do you want a list of unfinished quests?
191 root 1.5 Or maybe you want a starting point, or even a spoiler, for a quest?
192 elmex 1.1 REPL
193     }
194    
195     1
196     };
197    
198     1;