Back to index

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