Back to index

freedink-data  1.08.20080920
EN-DRAG.c
Go to the documentation of this file.
00001 //pillbug brain
00002 
00003 void main( void )
00004 {
00005 int &fsave_x;
00006 int &kcrap;
00007 int &fsave_y;
00008 int &resist;
00009 int &mcounter;
00010 int &mtarget;
00011 screenlock(1);
00012 sp_brain(&current_sprite, 10);
00013 sp_timing(&current_sprite, 66);
00014 sp_speed(&current_sprite, 1);
00015 sp_nohit(&current_sprite, 0);
00016 sp_exp(&current_sprite, 400);
00017 sp_base_walk(&current_sprite, 200);
00018 sp_base_death(&current_sprite, 210);
00019 sp_touch_damage(&current_sprite, 10);
00020 sp_hitpoints(&current_sprite, 80);
00021 sp_defense(&current_sprite, 8);
00022 preload_seq(202);
00023 preload_seq(204);
00024 preload_seq(206);
00025 preload_seq(208);
00026 preload_Seq(70);
00027 preload_Seq(166);
00028 
00029 set_callback_random("target",500,2000);
00030 
00031 }
00032 
00033 void target( void )
00034 {
00035     //get new target
00036 &kcrap = random(9, 1);
00037 if (&life < 1)
00038   &kcrap = 2;
00039 
00040 if (&kcrap == 1)
00041  {
00042  sp_target(&current_sprite, 1);
00043  return;
00044  }
00045 
00046         &mtarget = get_sprite_with_this_brain(16, &current_sprite);
00047         if (&mtarget > 0)
00048           {
00049 
00050            &mtarget = get_rand_sprite_with_this_brain(16, &current_sprite);
00051            sp_target(&current_sprite, &mtarget);
00052           }
00053 
00054 }
00055 
00056 
00057 
00058 
00059 void attack( void )
00060 {
00061 
00062   playsound(47, 22050,0,0,0);
00063 
00064         &kcrap = sp_target(&current_sprite, -1);
00065 &fsave_x = sp_x(&kcrap, -1);
00066 &fsave_y = sp_y(&kcrap, -1);
00067         &mcounter = random(5000,3000);
00068         sp_attack_wait(&current_sprite, &mcounter);
00069 
00070 &resist = random(40, 1);
00071 
00072 //if NPC, turn off resist option
00073 if (&kcrap != 1)
00074 &resist = 100000;
00075 
00076 if (&resist > &magic)
00077         {
00078         say("`4<Casts harm>", &current_sprite);
00079 
00080         playsound(31, 12050,0,0, 0);
00081         hurt(&kcrap, 20);
00082 
00083         &fsave_y -= 29;
00084         int &spark = create_sprite(&fsave_x, &fsave_y, 7, 70, 1);
00085         sp_seq(&spark, 70);
00086         sp_que(&spark, -70);
00087         sp_speed(&spark, 5);
00088         return;
00089         }
00090 
00091         playsound(31, 44050,0,0, 0);
00092         &fsave_y -= 29;
00093         int &spark = create_sprite(&fsave_x, &fsave_y, 7, 166, 1);
00094         sp_seq(&spark, 166);
00095         sp_que(&spark, -70);
00096         say("Magic resisted.", &kcrap);
00097 }
00098 
00099 void hit( void )
00100 {
00101 sp_target(&current_sprite, &enemy_sprite);
00102 playsound(46, 17050, 4000, &current_sprite, 0);
00103 //lock on to the guy who just hit us
00104 //playsound
00105 }
00106 
00107 void die( void )
00108 {
00109 
00110 if (get_sprite_with_this_brain(10, &current_sprite) == 0)
00111  {
00112   //no more brain 10 monsters here, lets unlock the screen
00113   if (&life > 0)
00114   {
00115    spawn("s5-end");
00116   }
00117  }
00118 
00119   int &hold = sp_editor_num(&current_sprite);
00120   if (&hold != 0)
00121   editor_type(&hold, 6); 
00122 
00123 &save_x = sp_x(&current_sprite, -1);
00124 &save_y = sp_y(&current_sprite, -1);
00125 
00126  external("emake","xlarge");
00127 
00128 }