ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/quest_master.ext
Revision: 1.3
Committed: Thu May 1 06:47:03 2008 UTC (16 years ago) by root
Branch: MAIN
CVS Tags: rel-2_54, rel-2_55, rel-2_56, rel-2_53
Changes since 1.2: +1 -1 lines
Log Message:
add statistician

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