1 //script for store manager, actually attached to the bench
2 
main(void)3 void main( void )
4 {
5 int &bsword;
6 int &bnut
7 
8 
9  int &crap = create_sprite(180,260, 0, 0, 0);
10  &temphold = &crap;
11 
12 
13 preload_seq(389);
14 preload_seq(383);
15 int &myrand;
16 sp_brain(&temphold, 0);
17 sp_base_walk(&temphold, 380);
18 sp_speed(&temphold, 0);
19 
20 //set starting pic
21 
22 sp_pseq(&temphold, 383);
23 sp_pframe(&temphold, 1);
24 
25 mainloop:
26 wait(500);
27 &myrand = random(8, 1);
28 
29   if (&myrand == 1)
30   {
31   sp_pseq(&temphold, 383);
32   }
33 
34   if (&myrand == 2)
35   {
36   sp_pseq(&temphold, 389);
37   }
38 
39 &myrand = random(20, 1);
40 
41   if (&myrand == 1)
42   {
43   say_stop_npc("`6Let me know if I can help you find something.", &temphold);
44   }
45 
46 
47 goto mainloop;
48 }
49 
50 
hit(void)51 void hit( void )
52 {
53 sp_speed(&current_sprite, 0);
54 wait(400);
55 say_stop_npc("`6Please don't wreck the place, thanks.", &temphold);
56 wait(800);
57 goto mainloop;
58 }
59 
60 
buys1(void)61 void buys1( void)
62 {
63 int &junk = free_items();
64 
65 
66 if (&junk < 1)
67  {
68          choice_start()
69         set_y 240
70         title_start();
71 You are carrying too much.
72         title_end();
73          "Ok"
74          choice_end()
75  return;
76  }
77 
78 
79 if (&gold < 400)
80  {
81          choice_start()
82         set_y 240
83         title_start();
84 You don't have enough gold to buy this sword.  Awk!
85         title_end();
86          "Ok"
87          choice_end()
88  return;
89  }
90 
91 &gold -= 400;
92 add_item("item-sw1",438, 7);
93 
94 }
95 
96 void buyb1( void)
97 {
98 int &junk = free_items();
99 
100 
101 if (&junk < 1)
102  {
103          choice_start()
104         set_y 240
105         title_start();
106 You are carrying too much.
107         title_end();
108          "Ok"
109          choice_end()
110  return;
111  }
112 
113 
114 if (&gold < 400)
115  {
116          choice_start()
117         set_y 240
118         title_start();
119 You don't have enough gold to buy this bow.  Awk!
120         title_end();
121          "Ok"
122          choice_end()
123  return;
124  }
125 
126 &gold -= 400;
127 add_item("item-b1",438, 8);
128 
129 }
130 
buybomb(void)131 void buybomb( void)
132 {
133 int &junk = free_items();
134 
135 
136 if (&junk < 1)
137  {
138          choice_start()
139         set_y 240
140         title_start();
141 You are carrying too much.
142         title_end();
143          "Ok"
144          choice_end()
145  return;
146  }
147 
148 
149 if (&gold < 20)
150  {
151          choice_start()
152         set_y 240
153         title_start();
154 You don't have enough gold to buy this bomb.  Awk!
155         title_end();
156          "Ok"
157          choice_end()
158  return;
159  }
160 
161 &gold -= 20;
162 add_item("item-bom",438, 3);
163 
164 }
165 
166 void sell(void )
167 {
168 //let's sell some stuff back
169 
170 sell:
171 
172 //how many items do they have?
173 
174 &bsword = count_item("item-sw1");
175 &bnut = count_item("item-nut");
176 
177          choice_start()
178         set_y 240
179         set_title_color 6
180         title_start();
181 "We'll buy a few things.  What have you got?"
182         title_end();
183        (&bsword > 0)  "Sell a Longsword - $200"
184        (&bnut > 0)  "Sell a nut - $2"
185         "Sell nothing"
186         choice_end()
187 
188 if (&result == 1)
189     {
190      kill_this_item("item-sw1");
191      &gold += 200;
192     goto sell;
193     }
194 
195 if (&result == 2)
196     {
197      kill_this_item("item-nut");
198      &gold += 2;
199     goto sell;
200     }
201    unfreeze(1);
202    goto mainloop;
203    return;
204 
205 
206 }
207 
208 
209 void buy( void )
210 {
211 buy:
212          choice_start()
213         set_y 240
214         set_title_color 6
215         title_start();
216 "Our wares are the finest quality around.  We'll beat any price!"
217         title_end();
218          "Longsword - $400"
219          "Bomb - $20"
220          "Leave"
221          choice_end()
222 
223           if (&result == 1)
224           {
225            buys1();
226            unfreeze(1);
227            goto mainloop;
228            return;
229 
230           }
231           if (&result == 2)
232           {
233            buybomb();
234            unfreeze(1);
235            goto mainloop;
236            return;
237 
238           }
239 
240 
241    unfreeze(1);
242    goto mainloop;
243    return;
244 
245 }
246 
247 
248 void talk( void )
249 {
250 
251  freeze(1);
252          choice_start()
253         set_y 240
254         set_title_color 6
255         title_start();
256 "What can I do for you today, sir?"
257         title_end();
258          "Buy"
259          "Sell"
260          "Leave"
261          choice_end()
262 
263    if (&result == 1)
264            {
265             goto buy;
266            }
267 
268    if (&result == 2)
269            {
270             goto sell;
271            }
272 
273 
274    unfreeze(1);
275    goto mainloop;
276    return;
277 
278 }
279 
280