1 inherit "room/room";
2
3 object harry;
4 int count;
5 string * chat_str; /* This variable is only initialized once. */
6 string * a_chat_str;
7 string * action, * type, * match;
8
9 void start_harry();
10
reset(int arg)11 void reset(int arg) {
12 dest_dir = ({ "room/vill_road1","west",
13 "room/vill_shore","east",
14 "room/adv_guild","south",
15 "room/station", "down",
16 "room/shop","north" });
17 start_harry(); /* Requires dest_dir set */
18 if (arg)
19 return;
20 short_desc = "Village road";
21 no_castle_flag = 1;
22 long_desc = "A long road going through the village. There are stairs going down.\n" +
23 "The road continues to the west. To the north is the shop, and to the\n" +
24 "south is the adventurers guild. The road runs towards the shore to\n"+
25 "the east.\n";
26 set_light(1);
27 }
28
start_harry()29 void start_harry() {
30 if(!harry) {
31 if (!chat_str) {
32 chat_str = allocate(10);
33 a_chat_str = allocate(8);
34 chat_str[0] = "Harry says: What are you waiting for?\n";
35 chat_str[1] = "Harry says: Hello there!\n";
36 chat_str[2] = "Harry says: I don't like winter.\n";
37 chat_str[3] = "Harry says: I don't like snow.\n";
38 chat_str[4] = "Harry says: I don't like rain.\n";
39 chat_str[5] = "Harry says: Who are you?\n";
40 chat_str[6] = "Harry says: Why do you look like that?\n";
41 chat_str[7] = "Harry says: What are you doing here?\n";
42 chat_str[8] = "Harry says: Nice weather, isn't it?\n";
43 chat_str[9] = "Harry smiles.\n";
44 a_chat_str[0] = "Harry says: Don't hit me!\n";
45 a_chat_str[1] = "Harry says: That hurt!\n";
46 a_chat_str[2] = "Harry says: Help, someone!\n";
47 a_chat_str[3] = "Harry says: Why can't you go bullying elsewhere?\n";
48 a_chat_str[4] = "Harry says: Aooooo\n";
49 a_chat_str[5] = "Harry says: I hate bashers!\n";
50 a_chat_str[6] = "Harry says: Bastard\n";
51 a_chat_str[7] = "Harry says: You big brute!\n";
52
53 action = allocate(12);
54 type = allocate(12);
55 match = allocate(12);
56
57 action[0] = "why_did";
58 type[0] = "sells";
59 type[1] = "attack";
60 type[2] = "left";
61 match[2] = "the game";
62 type[3] = "takes";
63 type[4] = "drops";
64 action[5] = "how_does_it_feel";
65 type[5] = "is now level";
66 action[6] = "smiles";
67 type[6] = "smiles";
68 match[6] = " happily.";
69 action[7] = "say_hello";
70 type[7] = "arrives";
71 action[8] = "test_say";
72 type[8] = "says:";
73 type[9] = "tells you:";
74 action[10] = "follow";
75 type[10] = "leaves";
76 action[11] = "gives";
77 type[11] = "gives";
78 }
79 harry = clone_object("obj/monster");
80 /* Reuse the same arrays. */
81 harry->load_chat(2, chat_str);
82 harry->load_a_chat(20, a_chat_str);
83 harry->set_match(this_object(), action, type, match);
84 harry->set_name("harry");
85 harry->set_alias("fjant");
86 harry->set_short("Harry the affectionate");
87 harry->set_long("Harry has an agreeable look.\n");
88 harry->set_ac(0);
89 harry->set_level(3);
90 harry->set_al(50);
91 harry->set_ep(2283);
92 harry->set_wc(5);
93 harry->set_aggressive(0);
94 move_object(harry, this_object());
95
96 harry->set_random_pick(20);
97 harry->set_move_at_reset(0);
98 }
99 }
100
notify(string str)101 void notify(string str) {
102 say(str);
103 write(str);
104 }
105
why_did(string str)106 void why_did(string str) {
107 string who, what;
108 sscanf(str, "%s %s", who, what);
109 if(who == "harry" || who == "Harry")
110 return;
111 if (sscanf(str, "%s sells %s.", who, what) == 2) {
112 notify("Harry says: Why did you sell " + what + "\n");
113 }
114 if (sscanf(str, "%s attacks %s.", who, what) == 2) {
115 notify("Harry says: Why is " + who + " attacking " + what + "?\n");
116 }
117 if (sscanf(str, "%s left the game.", who) == 1) {
118 notify("Harry says: Why did " + who + " quit the game ?\n");
119 }
120 if (sscanf(str, "%s takes %s.\n", who, what) == 2) {
121 notify("Harry says: Why did " + who + " take " + what + " ?\n");
122 }
123 if (sscanf(str, "%s drops %s.\n", who, what) == 2) {
124 notify("Harry says: Why did " + who + " drop " + what + " ?\n");
125 }
126 }
127
how_does_it_feel(string str)128 void how_does_it_feel(string str) {
129 string who, what;
130 sscanf(str, "%s %s", who, what);
131 if(who == "harry" || who == "Harry")
132 return;
133 if (sscanf(str, "%s is now level %s.\n", who, what) == 2) {
134 notify("Harry says: How does it feel, being of level " + what +
135 " ?\n");
136 }
137 }
138
smiles(string str)139 void smiles(string str) {
140 string who, what;
141 sscanf(str, "%s %s", who, what);
142 if(who == "harry" || who == "Harry")
143 return;
144 if (sscanf(str, "%s smiles happily", who) == 1 &&
145 who != "Harry") {
146 notify("Harry smiles happily.\n");
147 }
148 }
149
say_hello(string str)150 void say_hello(string str) {
151 string who;
152 if (sscanf(str, "%s arrives.", who) == 1) {
153 notify( "Harry says: Hi " + who + ", nice to see you !\n");
154 }
155 }
156
test_say(string str)157 void test_say(string str) {
158 string a, b, message;
159
160 sscanf(str, "%s %s", a, b);
161 if(a == "harry" || a == "Harry")
162 return;
163 if (!sscanf(str, "%s says: %s\n", a, b) == 2) {
164 return;
165 }
166 str = b;
167
168 if (str == "hello" || str == "hi" || str == "hello everybody") {
169 message = "Harry says: Pleased to meet you!\n";
170 }
171 if (str == "shut up") {
172 message = "Harry says: Why do you want me to shut up ?\n";
173 }
174 if (sscanf(str, "%sstay here%s", a, b) == 2 ||
175 sscanf(str, "%snot follow%s", a, b) == 2 ||
176 sscanf(str, "%sget lost%s", a, b) == 2) {
177 message = "Harry says: Ok then.\n";
178 }
179 if(!message)
180 message = "Harry says: Why do you say '" + str + "'???\n";
181 notify(message);
182 }
183
follow(string str)184 void follow(string str) {
185 string who, where;
186 if(sscanf(str, "%s leaves %s.\n", who, where) == 2)
187 harry->init_command(where);
188 }
189
gives(string str)190 void gives(string str) {
191 string who, what, whom;
192 int rand;
193 object obj, next_obj;
194 if(sscanf(str, "%s gives %s to %s.\n", who, what, whom) != 3)
195 return;
196 if(whom != "Harry")
197 return;
198 if(what == "firebreather" || what == "special" ||
199 what == "beer" || what == "bottle") {
200 rand = random(4);
201 if(rand == 0) {
202 if(random(10) > 6) {
203 notify("Harry sighs and says: I guess you're gonna kill me now.\n");
204 obj = first_inventory(harry);
205 while(obj) {
206 next_obj = next_inventory(harry);
207 transfer(obj, environment(harry));
208 notify("Harry drops " + obj->short() + ".\n");
209 obj = next_obj;
210 }
211 harry->init_command("west");
212 }
213 }
214 if(rand == 1) {
215 harry->init_command("drink " + what);
216 }
217 if(rand == 2) {
218 obj = first_inventory(harry);
219 while(!obj->id(what))
220 obj = next_inventory(obj);
221 transfer(obj, environment(harry));
222 notify("Harry drops the " + what + ".\n");
223 }
224 if(rand == 3) {
225 obj = first_inventory(harry);
226 while(!obj->id(what))
227 obj = next_inventory(obj);
228 transfer(obj, find_living(lower_case(who)));
229 notify("Harry returned the " + what + " to " + who + ".\n");
230 }
231 } else if(what == "corpse") {
232 notify("Harry says: HEY, bury your corpses yourself, asshole.\n");
233 obj = first_inventory(harry);
234 while(!obj->id(what))
235 obj = next_inventory(obj);
236 transfer(obj, find_living(lower_case(who)));
237 notify("Harry returned the " + what + " to " + who + ".\n");
238 } else {
239 notify("Harry says: Thank you very much, sir.\n");
240 }
241 }
242
monster_died()243 void monster_died() {
244 object obj, b;
245 int num;
246 obj = first_inventory(harry);
247 while(obj) {
248 b = next_inventory(harry);
249 if(obj->id("bottle")) {
250 destruct(obj);
251 num = 1;
252 }
253 obj = b;
254 }
255 if(num)
256 notify("There is a crushing sound of bottles breaking, as the body falls.\n");
257 }
258
down()259 int down() {
260 this_player()->move_player("down#room/station");
261 return 1;
262
263 }
264