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