Back to index

freedink-data  1.08.20080920
S2-OUT.c
Go to the documentation of this file.
00001 //script for store manager, actually attached to the bench
00002 
00003 void main( void )
00004 {
00005 int &bsword;
00006 int &bnut
00007 
00008 
00009  int &crap = create_sprite(180,260, 0, 0, 0);
00010  &temphold = &crap;
00011 
00012 
00013 preload_seq(389);
00014 preload_seq(383);
00015 int &myrand;
00016 sp_brain(&temphold, 0);
00017 sp_base_walk(&temphold, 380);
00018 sp_speed(&temphold, 0);
00019 
00020 //set starting pic
00021 
00022 sp_pseq(&temphold, 383);
00023 sp_pframe(&temphold, 1);
00024 
00025 mainloop:
00026 wait(500);
00027 &myrand = random(8, 1);
00028 
00029   if (&myrand == 1)
00030   {
00031   sp_pseq(&temphold, 383);
00032   }
00033 
00034   if (&myrand == 2)
00035   {
00036   sp_pseq(&temphold, 389);
00037   }
00038 
00039 &myrand = random(20, 1);
00040 
00041   if (&myrand == 1)
00042   {
00043   say_stop_npc("`6Let me know if I can help you find something.", &temphold);
00044   }
00045 
00046 
00047 goto mainloop;
00048 }
00049 
00050 
00051 void hit( void )
00052 {
00053 sp_speed(&current_sprite, 0);
00054 wait(400);
00055 say_stop_npc("`6Please don't wreck the place, thanks.", &temphold);
00056 wait(800);  
00057 goto mainloop;
00058 }
00059 
00060 
00061 void buys1( void)
00062 {
00063 int &junk = free_items();
00064 
00065 
00066 if (&junk < 1)
00067  {
00068          choice_start()
00069         set_y 240
00070         title_start();
00071 You are carrying too much.
00072         title_end();
00073          "Ok"
00074          choice_end()
00075  return;
00076  }
00077 
00078 
00079 if (&gold < 400)
00080  {
00081          choice_start()
00082         set_y 240
00083         title_start();
00084 You don't have enough gold to buy this sword.  Awk!
00085         title_end();
00086          "Ok"
00087          choice_end()
00088  return;
00089  }
00090 
00091 &gold -= 400;
00092 add_item("item-sw1",438, 7);
00093 
00094 }
00095 
00096 void buyb1( void)
00097 {
00098 int &junk = free_items();
00099 
00100 
00101 if (&junk < 1)
00102  {
00103          choice_start()
00104         set_y 240
00105         title_start();
00106 You are carrying too much.
00107         title_end();
00108          "Ok"
00109          choice_end()
00110  return;
00111  }
00112 
00113 
00114 if (&gold < 400)
00115  {
00116          choice_start()
00117         set_y 240
00118         title_start();
00119 You don't have enough gold to buy this bow.  Awk!
00120         title_end();
00121          "Ok"
00122          choice_end()
00123  return;
00124  }
00125 
00126 &gold -= 400;
00127 add_item("item-b1",438, 8);
00128 
00129 }
00130 
00131 void buybomb( void)
00132 {
00133 int &junk = free_items();
00134 
00135 
00136 if (&junk < 1)
00137  {
00138          choice_start()
00139         set_y 240
00140         title_start();
00141 You are carrying too much.
00142         title_end();
00143          "Ok"
00144          choice_end()
00145  return;
00146  }
00147 
00148 
00149 if (&gold < 20)
00150  {
00151          choice_start()
00152         set_y 240
00153         title_start();
00154 You don't have enough gold to buy this bomb.  Awk!
00155         title_end();
00156          "Ok"
00157          choice_end()
00158  return;
00159  }
00160 
00161 &gold -= 20;
00162 add_item("item-bom",438, 3);
00163 
00164 }
00165 
00166 void sell(void )
00167 {
00168 //let's sell some stuff back
00169 
00170 sell:
00171 
00172 //how many items do they have?
00173 
00174 &bsword = count_item("item-sw1");
00175 &bnut = count_item("item-nut");
00176 
00177          choice_start()
00178         set_y 240
00179         set_title_color 6
00180         title_start();
00181 "We'll buy a few things.  What have you got?"
00182         title_end();
00183        (&bsword > 0)  "Sell a Longsword - $200"
00184        (&bnut > 0)  "Sell a nut - $2"
00185         "Sell nothing"
00186         choice_end()
00187 
00188 if (&result == 1)
00189     {
00190      kill_this_item("item-sw1");
00191      &gold += 200;
00192     goto sell;
00193     }
00194 
00195 if (&result == 2)
00196     {
00197      kill_this_item("item-nut");
00198      &gold += 2;
00199     goto sell;
00200     }
00201    unfreeze(1);
00202    goto mainloop;
00203    return;
00204 
00205 
00206 }
00207 
00208 
00209 void buy( void )
00210 {
00211 buy:
00212          choice_start()
00213         set_y 240
00214         set_title_color 6
00215         title_start();
00216 "Our wares are the finest quality around.  We'll beat any price!"
00217         title_end();
00218          "Longsword - $400"
00219          "Bomb - $20"
00220          "Leave"
00221          choice_end()
00222 
00223           if (&result == 1)
00224           {
00225            buys1();
00226            unfreeze(1);
00227            goto mainloop;
00228            return;
00229 
00230           }
00231           if (&result == 2)
00232           {
00233            buybomb();
00234            unfreeze(1);
00235            goto mainloop;
00236            return;
00237 
00238           }
00239 
00240 
00241    unfreeze(1);
00242    goto mainloop;
00243    return;
00244 
00245 }
00246 
00247 
00248 void talk( void )
00249 {
00250 
00251  freeze(1);
00252          choice_start()
00253         set_y 240
00254         set_title_color 6
00255         title_start();
00256 "What can I do for you today, sir?"
00257         title_end();
00258          "Buy"
00259          "Sell"
00260          "Leave"
00261          choice_end()
00262 
00263    if (&result == 1)
00264            {
00265             goto buy;
00266            }
00267 
00268    if (&result == 2)
00269            {
00270             goto sell;
00271            }
00272 
00273 
00274    unfreeze(1);
00275    goto mainloop;
00276    return;
00277 
00278 }
00279