PROGRAM vegetaII;
GLOBAL
 energyx[1];
 gstep;
 super;
 level;cy;
 fight[8];
 vfile[3];
 sfx[5];
 vegeta[4];
 exit_game;
 vegetatype;
 vegetagame;
 fpower;
 vx;vy;
 firex;firey;
 monstermax;
 monsterout;
 total;
 power;
 music;
 maxpower;
 targetpower;
 savdat[2];
LOCAL
 pfile, var1;var2;var3;
 aggr;subm;kiatt;energy;
 mhp;matk;mfreq;mspeed;mx;
BEGIN
vfile[0]=load_fpg("intro.fpg");
vfile[1]=load_fpg("enemy.fpg");
vfile[2]=load_fpg("enemy2.fpg");
vfile[3]=load_fpg("saga.fpg");
fight[0]=load_fpg("fight01.fpg");
fight[1]=load_fpg("fight02.fpg");
fight[2]=load_fpg("fight03.fpg");
fight[3]=load_fpg("fight04.fpg");
fight[4]=load_fpg("fight05.fpg");
fight[5]=load_fpg("fight06.fpg");
fight[6]=load_fpg("fight07.fpg");
fight[7]=load_fpg("fight08.fpg");
vegeta[0]=load_fpg("vegeta1.fpg");
vegeta[1]=load_fpg("vegeta2.fpg");
vegeta[2]=load_fpg("vegeta3.fpg");
vegeta[3]=load_fpg("vegeta4.fpg");
vegeta[4]=load_fpg("vegeta5.fpg");
pfile=fopen("vegsav.dat",O_READ);
fread(pfile,savdat);
fclose(pfile);
load_fnt("vegeta1.fnt");
load_fnt("numbers.fnt");
music=load_song("music.mod");
sfx[0]=load_wav("vegeta.wav");
sfx[1]=load_wav("boom.wav");
sfx[2]=load_wav("laser.wav");
sfx[3]=load_wav("hit1.wav");
sfx[4]=load_wav("power.wav");
play_wav(sfx[0],0);
FRAME; //(3000);
REPEAT
 pfile=fopen("vegsav.dat",O_WRITE);
 fwrite(pfile,savdat);
 fclose(pfile);
 clear_screen();exit_game=0;
 stop_scroll(0);targetpower=0;power=0;maxpower=0;
 x=180;y=100;size=200;graph=0;
 REPEAT
  graph++;
  FRAME(1000);
  FRAME;
 UNTIL(graph>=5);
 write(1,0,20,3,"VEGETAS WRATH  II");
 frame(500);
 picture(50,150,0);
 picture(150,60,1);
 picture(150,100,2);
 picture(150,140,4);
 picture(150,180,3);
 cursor(150,100);
 FRAME(3000);
play_song(music,-1);
 REPEAT
   FRAME;
 UNTIL(key(_enter));
 let_me_alone();
 clear_screen();size=0;
 delete_text(all_text);
 exit_game=0;
 if(cy==180)exit_game=1;end
 if(cy==60)cy=100;end
 if(cy==100 and vegetagame==0)vegwrath(100,200);end
 if(cy==100 and vegetagame==1)beatemup1();end
 if(cy==100 and vegetagame==2)vegnight(100,200);end
 if(cy==100 and vegetagame==3)gokusfight();end
 if(cy==140)start_scroll(0,vfile[0],21,0,0,15);end
 REPEAT
  if(cy==140)
    if(key(_left))scroll.x0-=5;end
    if(key(_right))scroll.x0+=5;end
    if(key(_space))exit_game=1;end
  end
  if(cy==100 and vegetagame==1)
    if(exit_game==3)exit_game=1;end
    if(exit_game==2)let_me_alone();delete_text(all_text);exit_game=1;end
  end
  if(cy==100 and vegetagame==0)
   if(power>targetpower)
    super=0;
    targetpower=(level+1)*100+power;
    let_me_alone();
    delete_text(all_text);
    if(vegetatype==0)fighter1(0,(level*20)+100);end
    if(vegetatype==1)fighter1(3,(level*20)+100);end
    if(vegetatype==2)fighter1(6,(level*20)+100);end
    if(vegetatype==3)fighter1(7,(level*20)+100);end
    var1=level;
    if(level>5)var1=rand(0,5);end
    fighter2(var1+1,(level*20)+150);
    REPEAT
     FRAME;
    UNTIL(exit_game>0);
    if(exit_game==2)level++;end
    fpower=0;monsterout=0;firex=350;
    if(exit_game==3)exit_game=1;end
    if(exit_game==2)let_me_alone();delete_text(all_text);vegwrath(power,targetpower);end
   end
  end
  if(cy==100 and vegetagame==2)
   if(power>targetpower)
    level++;super=0;
    targetpower=level*200+power;
    let_me_alone();
    delete_text(all_text);
    if(vegetatype==0)fighter1(0,(level*20)+200);end
    if(vegetatype==1)fighter1(3,(level*20)+200);end
    if(vegetatype==2)fighter1(6,(level*20)+200);end
    if(vegetatype==3)fighter1(7,(level*20)+200);end
    fighter2(1,(level*20)+250);
    REPEAT
     FRAME;
    UNTIL(exit_game>0);
    fpower=0;monsterout=0;firex=350;
    if(exit_game==3)exit_game=1;end
    if(exit_game==2)let_me_alone();delete_text(all_text);vegnight(power,targetpower);end
   end
  end
  FRAME;
 UNTIL(exit_game==1);
 FRAME(500);
 let_me_alone();
 if(level>savdat[1] and vegetagame==0)savdat[1]=level;end
 level=0;power=0;targetpower=0;firex=500;
 delete_text(all_text);
UNTIL(cy==180);
exit("thank you for playing",0);
END
PROCESS cursor(x,y)
BEGIN
file=vfile[0];graph=19;
LOOP
 if(key(_up)and y>80)y-=40;end
 if(key(_down)and y<180)y+=40;end
 if(key(_right) and cy==100)vegetagame++;end
 if(key(_left) and cy==100)vegetagame++;end
 if(key(_right) and cy==60)vegetatype++;end
 if(key(_left) and cy==60)vegetatype++;end
 if(vegetagame>=1 and savdat[1]==0)vegetagame=0;end
 if(vegetagame>=2 and savdat[1]<=2)vegetagame=0;end
 if(vegetagame>=3 and savdat[1]<=4)vegetagame=0;end
 if(vegetagame>=4)vegetagame=0;end
 if(vegetatype>0 and savdat[1]<2)vegetatype=0;end
 if(vegetatype>1 and savdat[1]<4)vegetatype=0;end
 if(vegetatype>2 and savdat[1]<5)vegetatype=0;end
 if(vegetatype>3)vegetatype=0;end
 cy=y;
 FRAME;
END
END
PROCESS picture(x,y,var1);
BEGIN
 LOOP
  if(var1==0)graph=10+vegetatype;file=vfile[0];end
  if(var1==1)size=75;graph=14+vegetatype;file=vfile[0];end
  if(var1==2)size=75;graph=6+vegetagame;file=vfile[0];end
  if(var1==3)size=75;graph=18;end
  if(var1==4)size=75;graph=20;end
  FRAME;
 END
END
// BEGIN BOSS FIGHT/ BEAT EM UP SECTION
PROCESS beatpic(file,graph,x);
BEGIN
file=fight[file];
y=100;
put_screen(vfile[0],102);
LOOP
 FRAME;
END
END
PROCESS beatemup1();
PRIVATE
 id2;
BEGIN
FROM file = 7 TO 0 STEP -1;
 beatpic(file, 12, 20+(file*40));
END
write(0,150,20,4,"Choose your character");
file=vfile[0];graph=22;
var1=0;
REPEAT
 x=mouse.x;y=mouse.y;
 id2=collision(TYPE beatpic);
 if(id2!=0 and mouse.left)var1=1;var2=id2.file;end
 FRAME;
UNTIL(var1<>0);
FRAME(1000);
write(0,150,30,4,"Now choose your opponent");
var1=0;
REPEAT
 x=mouse.x;y=mouse.y;
 id2=collision(TYPE beatpic);
 if(id2!=0 and mouse.left)var1=1;var3=id2.file;end
 FRAME;
UNTIL(var1<>0);
delete_text(all_text);
fighter1(var2-4,200);
fighter2(var3-4,200);
signal(TYPE beatpic, s_kill);
size=0;
LOOP
 FRAME;
END
END
PROCESS beatemup();
BEGIN
put_screen(0,100);
REPEAT
 if(key(_esc))exit_game=1;end
 FRAME;
UNTIL(exit_game<>0);
FRAME(500);
if(exit_game==3);exit_game=1;end
END
PROCESS fighter1(var1,energy);
PRIVATE
 id2;
BEGIN
beatemup();
FRAME(100);
file=fight[var1];
if(var1==0)aggr=30;subm=05;kiatt=12;end
if(var1==1)aggr=20;subm=10;kiatt=10;end
if(var1==2)aggr=25;subm=08;kiatt=06;end
if(var1==3)aggr=35;subm=05;kiatt=10;end
if(var1==4)aggr=25;subm=18;kiatt=06;end
if(var1==5)aggr=35;subm=02;kiatt=16;end
if(var1==6)aggr=30;subm=02;kiatt=08;end
if(var1==7)aggr=25;subm=04;kiatt=13;end
var1=0;
graph=12;
x=50;y=150;
write_int(2,0,10,3,&energy);
LOOP
 id2=get_id(TYPE fighter2);
  if(rand(0,100)<75 and mouse.left and mouse.right)energy+=5;end
  if(var1==0 and var3==0)graph=12;end
  if(var1>=1 and var1<=12)y-=10;end
  if(var1>=13 and var1<=23)y+=10;end
  if(var1>=24 and var3==0)var1=0;graph=12;end
  if(var3<30 and key(_left))x-=5;end
  if(var3<30 and flags==1 and key(_right))graph=6;end
  if(var3<30 and flags==0 and key(_left))graph=6;end
  if(var3<30 and key(_right))x+=5;end
  if(var3<30 and var1==0 and key(_up))var1=1;graph=1;end
  if(var1>=1 and var1<=26)var1++;end
  if(var3<30 and var3==0 and key(_space))var3=1;end
  if(var3>=1 and var3<5)
   if(var3==1 and var1==0)graph=4;end
   if(var3==1 and var1>=1)graph=2;end
   var3++;
  end
  if(var3>4 and var3<12)
   if(var3==5 and var1==0)graph=5;end
   if(var3==5 and var1>=1)graph=3;end
   var3++;
  end
  if(var3==12)var3=0;graph=12;end
  if(var1==0 and var3==0 and key(_enter))var3=30;graph=9;end
  if(var3>=30)
   var3++;
   if(var3>40)graph=10;end
   if(var3>50)graph=11;end
   if(var3==50)kiball(x,y,flags,file);end
   if(var3>55)graph=12;var3=0;end
  end
 if(id2.x>x)flags=0;end
 if(id2.x<x)flags=1;end
 if(x<10)x=10;end
 if(x>300)x=300;end
 if(energy<1)var3=50;graph=8;exit_game=3;end
 FRAME;
 id2=collision(TYPE fighter2);
 if(id2!=0)
  if(graph==3 or graph==5)
   if(id2.graph<>6)id2.energy-=aggr/10;id2.graph=7;play_wav(sfx[3],0);end
  end
  if(flags==0)x-=5;end
  if(flags==1)x+=5;end
 end
END
END
PROCESS fighter2(var1,energy);
PRIVATE
 id2;
BEGIN
file=fight[var1];
graph=12;flags=1;
x=250;y=150;
if(var1==0)aggr=30;subm=05;kiatt=12;end
if(var1==1)aggr=20;subm=10;kiatt=10;end
if(var1==2)aggr=25;subm=08;kiatt=06;end
if(var1==3)aggr=35;subm=05;kiatt=10;end
if(var1==4)aggr=25;subm=18;kiatt=06;end
if(var1==5)aggr=35;subm=02;kiatt=16;end
if(var1==6)aggr=30;subm=02;kiatt=08;end
if(var1==7)aggr=25;subm=04;kiatt=13;end
var1=0;
write_int(2,270,10,3,&energy);
 LOOP
 id2=get_id(TYPE fighter1);
  if(var1==0 and var3==0)graph=12;end
  if(var1>=1 and var1<=10)y-=10;end
  if(var1>=11 and var1<=19)y+=10;end
  if(var1>=20 and var3==0)var1=0;graph=12;end
  if(flags==1)
   if(var3<30 and id2.x<x and rand(0,100)<90)x-=5;end
   if(id2.x>x-30 and rand(0,100)<subm)graph=6;end
  end
  if(flags==0)
   if(var3<30 and id2.x>x and rand(0,100)<90)x+=5;end
   if(id2.x>x+30 and rand(0,100)<subm)graph=6;end
  end
  if(var3<30 and var1==0 and rand(0,100)<((aggr+subm)/5))var1=1;graph=1;end
  if(var1>=1 and var1<=21)var1++;end
  if(var3<30 and var3==0 and rand(0,100)<aggr and id2.x>x-30 and id2.x<x+30)var3=1;end
  if(var3>=1 and var3<5)
   if(var3==1 and var1==0)graph=4;end
   if(var3==1 and var1>=1)graph=2;end
   var3++;
  end
  if(var3>4 and var3<12)
   if(var3==5 and var1==0)graph=5;end
   if(var3==5 and var1>=1)graph=3;end
   var3++;
  end
  if(var3==12)var3=0;graph=12;end
  if(var1==0 and var3==0 and rand(0,100)<kiatt)var3=30;graph=9;end
  if(var3>=30)
   var3++;
   if(var3>40)graph=10;end
   if(var3>50)graph=11;end
   if(var3==50)kiball(x,y,flags,file);end
   if(var3>55)graph=12;var3=0;end
  end
 if(id2.x>x)flags=0;end
 if(id2.x<x)flags=1;end
 if(x<10)x=10;end
 if(x>300)x=300;end
 if(energy<1)var3=50;graph=8;exit_game=2;end
 FRAME;
 id2=collision(TYPE fighter1);
 if(id2!=0)
  if(graph==3 or graph==5)
   if(id2.graph<>6)id2.energy-=aggr/10;id2.graph=7;play_wav(sfx[3],0);end
  end
  if(flags==0)x-=5;end
  if(flags==1)x+=5;end
 end
 END
END
PROCESS kiball(x,y,flags,file)
PRIVATE
 id2;
BEGIN
graph=13;
play_wav(sfx[2],0);
REPEAT
 if(flags==0)x+=10;end
 if(flags==1)x-=10;end
 id2=collision(TYPE fighter1);
 if(id2!=0)
  if(id2.flags<>flags and id2.graph<>6)id2.energy-=20;id2.graph=7;x=400;play_wav(sfx[3],0);end
 end
 id2=collision(TYPE fighter2);
 if(id2!=0)
  if(id2.flags<>flags and id2.graph<>6)id2.energy-=20;id2.graph=7;x=400;play_wav(sfx[3],0);end
 end
 FRAME;
UNTIL(x<0 OR x>320);
END
PROCESS vegwrath(power,targetpower);
BEGIN
vegetacontrol();
start_scroll(0,vfile[0],101,100,0,15);
monsterout=0;monstermax=3;
delete_text(all_text);
write(2,0,10,3,"POWER LEVEL:");
write_int(2,250,10,5,&power);
write(2,250,10,3,"000");
write(2,0,180,3,"TARGET LEVEL:");
write_int(2,250,180,5,&targetpower);
write(2,250,180,3,"000");
write(2,0,190,3,"HIGHEST POWER:");
write_int(2,250,190,5,&savdat[0]);
write(2,250,190,3,"000");
LOOP
 scroll.x0+=20;
 if(monsterout<monstermax)
  if(rand(0,100)<30)monster(rand(1,8));monsterout++;end
 end
 if(power<(maxpower-50))exit_game=1;end
 if(key(_esc))exit_game=1;end
 FRAME;
END
END
PROCESS vegnight(power,targetpower);
BEGIN
vegetacontrol();
start_scroll(0,vfile[0],101,100,0,15);
monsterout=0;monstermax=4;
delete_text(all_text);
write(2,0,10,3,"POWER LEVEL:");
write_int(2,250,10,5,&power);
write(2,250,10,3,"000");
write(2,0,180,3,"TARGET LEVEL:");
write_int(2,250,180,5,&targetpower);
write(2,250,180,3,"000");
write(2,0,190,3,"HIGHEST POWER:");
write_int(2,250,190,5,&savdat[2]);
write(2,250,190,3,"000");
LOOP
 scroll.x0+=20;
 if(monsterout<monstermax)
  if(rand(0,100)<30)monsternight(rand(1,8));monsterout++;end
 end
 if(power<(maxpower-50))exit_game=1;end
 if(key(_esc))exit_game=1;end
 FRAME;
END
END
PROCESS vegetacontrol();
BEGIN
file=vegeta[vegetatype];
graph=1;x=50;y=100;
LOOP
 if(exit_game>1)exit_game=0;end
 if(power>maxpower)maxpower=power;end
 if(vegetagame==0 and power>savdat[0])savdat[0]=power;end
 if(vegetagame==2 and power>savdat[2])savdat[2]=power;end
 vx=x;vy=y;
 gstep++;
 if(mouse.left and key(_v))super=1;end
 if(super>7)super++;end
 if(super==100)super=0;file=vegeta[vegetatype];end
 if(super==0 or super>=6)
  if(vegetatype==3 and super>=6)
   size=400;y=100;
   if(gstep>1)gstep=0;end
   if(firex>320)graph=1;fpower=0;firex=-50;end
   if(key(_space))
    fpower++;
    if(super>6)fpower++;end
   end
   if(fpower==0)graph=1;end
   if(key(_space)==0 and fpower>0 and graph<>4)fireball(x,y,fpower);end
   if(fpower>0 and fpower<41)graph=2+gstep;end
   if(fpower>=40)fpower=40;graph=2+gstep;end
   if(firex<320 and firex>0)graph=4;total=0;end
  end
  if(vegetatype<>3 or super<6)
   size=100;
   if(gstep>1)gstep=0;end
   if(firex>320)graph=1;fpower=0;firex=-50;end
   if(key(_up) and y>20)y-=5;end
   if(key(_down) and y<180)y+=5;end
   if(key(_space))
    fpower++;
    if(super>6)fpower++;end
   end
   if(fpower==0)graph=1;end
   if(key(_space)==0 and fpower>0 and graph<>10)fireball(x,y,fpower);end
   if(fpower>0 and fpower<10)graph=2+gstep;end
   if(fpower>10 and fpower<20)graph=4+gstep;end
   if(fpower>20 and fpower<30)graph=6+gstep;end
   if(fpower>30 and fpower<41)graph=8+gstep;end
   if(fpower>=40)fpower=40;graph=8+gstep;end
   if(firex<320 and firex>0)graph=10;total=0;end
  end
 end
 if(super>0 and super<8)
  graph=11+super;
  FRAME(300);
  if(super==1)play_wav(sfx[4],0);end
  if(super==2)play_wav(sfx[4],0);end
  super++;
  if(graph==17)graph=1;var3=0;var1=0;var2=0;super=8;file=vegeta[vegetatype+1];end
 end
 FRAME;
END
END
PROCESS fireball(x,y,var1)
BEGIN
play_wav(sfx[2],0);
file=vegeta[vegetatype];graph=11;
if(var1>0 and var1<10)var2=2;size=100;end
if(var1>10 and var1<20)var2=4;size=125;end
if(var1>20 and var1<30)var2=6;size=150;end
if(var1>30 and var1<45)var2=8;size=200;end
if(vegetatype==3 and super>1)size=1000;var2=10;end
REPEAT
 x+=20-(var2);
 firex=x;firey=y;
 angle+=100000;
 FRAME;
UNTIL(x>330)
if(total>15 and super<1)bonus(x,y);end
total=0;
END
PROCESS monster(var1)
PRIVATE
 id2;
BEGIN
 file=vfile[1];graph=var1;
 x=350;y=rand(0,200);
 mx=rand(200,290);
 if(var1==1)mhp=rand(2,6);matk=rand(2,10);mfreq=rand(2,10);end
 if(var1==2)mhp=rand(3,9);matk=rand(4,14);mfreq=rand(5,15);end
 if(var1==3)mhp=rand(6,13);matk=rand(5,10);mfreq=rand(2,10);end
 if(var1==4)mhp=rand(8,15);matk=rand(4,10);mfreq=rand(2,10);end
 if(var1==5)mhp=rand(5,10);matk=rand(2,8);mfreq=rand(2,10);end
 if(var1==6)mhp=rand(15,20);matk=rand(5,13);mfreq=rand(2,10);end
 if(var1==7)mhp=rand(20,30);matk=rand(5,15);mfreq=rand(2,10);end
 if(var1==8)mhp=rand(5,12);matk=rand(1,4);mspeed=rand(2,8);mx=63;end
 size=80;
REPEAT
 if(x>mx)x-=5;end
 if(var1==1)// attack = up and down shooting   purple fishdude
  if(y<20)var2=1;end
  if(y>180)var2=0;end
  if(var2==1)y+=5;end
  if(var2==0)y-=5;end
 end
 if(var1==2)// attack = up and down following you, shooting   green fishdude
  if(vy>y)y+=3;end
  if(vy<y)y-=3;end
 end
 if(var1==3)// attack = teleporter                         blanka guy
  if(rand(0,100)<70) y=vy;end
 end
 if(var1==4)// attack = up and down following you, shooting   jeice race
  if(vy>y)y+=5;end
  if(vy<y)y-=5;end
 end
 if(var1==5)// attack = up and down shooting   human
  if(y<20)var2=1;end
  if(y>180)var2=0;end
  if(var2==1)y+=8;end
  if(var2==0)y-=8;end
 end
 if(var1==6)// attack = teleporst randomly    robot guy
  if(rand(0,100)<20)y=rand(10,190);end
 end
 if(var1==7)// attack = teleports when you fire             freeza
  if(vy>y)y+=5;end
  if(vy<y)y-=5;end
  if(fpower>0 and key(_space)==0 and y>vy-20 and y<vy+20)y=rand(0,200);end
 end
 if(var1==8)// attack = move towards and kick              red kanek
  if(x<=70 and y>vy-20 and y<vy+20)
   graph=9;
   if(super==0)power-=matk;end
  end
  if(y<vy-20 or y>vy+20 or x>70)graph=8;end
  if(vy>y)y+=5;end
  if(vy<y)y-=5;end
 end
 if(var1<>8)
  if(rand(0,250)<mfreq)eshot(x,y,matk);end
 end
 id2=collision(TYPE fireball);
 if(id2!=0)mhp=mhp-=id2.var2;total+=id2.var2;end
 FRAME;
UNTIL(mhp<0);
power+=matk;
monsterout--;
var1=rand(1,2);
play_wav(sfx[1],0);
if(var1==1)
FROM graph = 10 TO 15;
 FRAME;
END
end
if(var1==2)
FROM graph = 16 TO 22;
 FRAME;
END
end
END
PROCESS monsternight(var1)
PRIVATE
 id2;
BEGIN
 file=vfile[2];graph=var1;
 x=350;y=rand(0,200);
 mx=rand(200,290);
 if(var1==1)mhp=rand(2,6);matk=rand(2,10);mfreq=rand(2,10);end
 if(var1==2)mhp=rand(3,9);matk=rand(4,14);mfreq=rand(5,15);end
 if(var1==3)mhp=rand(6,13);matk=rand(5,10);mfreq=rand(2,10);end
 if(var1==4)mhp=rand(8,15);matk=rand(4,10);mfreq=rand(2,10);end
 if(var1==5)mhp=rand(5,10);matk=rand(2,8);mfreq=rand(2,10);end
 if(var1==6)mhp=rand(15,20);matk=rand(5,13);mfreq=rand(2,10);end
 if(var1==7)mhp=rand(20,30);matk=rand(5,15);mfreq=rand(2,10);end
 if(var1==8)mhp=rand(5,12);matk=rand(1,4);mspeed=rand(2,8);mx=63;end
 size=80;
REPEAT
 if(x>mx)x-=5;end
 if(var1==1)// attack = up and down shooting   purple fishdude
  if(y<20)var2=1;end
  if(y>180)var2=0;end
  if(var2==1)y+=5;end
  if(var2==0)y-=5;end
 end
 if(var1==2)// attack = up and down following you, shooting   green fishdude
  if(vy>y)y+=3;end
  if(vy<y)y-=3;end
 end
 if(var1==3)// attack = teleporter                         blanka guy
  if(rand(0,100)<70) y=vy;end
 end
 if(var1==4)// attack = up and down following you, shooting   jeice race
  if(vy>y)y+=5;end
  if(vy<y)y-=5;end
 end
 if(var1==5)// attack = up and down shooting   human
  if(y<20)var2=1;end
  if(y>180)var2=0;end
  if(var2==1)y+=8;end
  if(var2==0)y-=8;end
 end
 if(var1==6)// attack = teleporst randomly    robot guy
  if(rand(0,100)<20)y=rand(10,190);end
 end
 if(var1==7)// attack = teleports when you fire             freeza
  if(vy>y)y+=5;end
  if(vy<y)y-=5;end
  if(fpower>0 and key(_space)==0 and y>vy-20 and y<vy+20)y=rand(0,200);end
 end
 if(var1==8)// attack = move towards and kick              red kanek
  if(x<=70 and y>vy-20 and y<vy+20)
   graph=9;
   if(super==0)power-=matk;end
  end
  if(y<vy-20 or y>vy+20 or x>70)graph=8;end
  if(vy>y)y+=5;end
  if(vy<y)y-=5;end
 end
 if(var1<>8)
  if(rand(0,250)<mfreq)eshot(x,y,matk);end
 end
 id2=collision(TYPE fireball);
 if(id2!=0)mhp=mhp-=id2.var2;total+=id2.var2;end
 FRAME;
UNTIL(mhp<0);
power+=matk;
monsterout--;
var1=rand(1,2);
play_wav(sfx[1],0);
if(var1==1)
FROM graph = 10 TO 15;
 FRAME;
END
end
if(var1==2)
FROM graph = 16 TO 22;
 FRAME;
END
end
END
PROCESS bonus(x,y)
PRIVATE
id2;
BEGIN
file=vfile[1];
graph=rand(25,26);
REPEAT
 x-=10;
 id2=collision(TYPE vegetacontrol);
 IF(id2!=0)
  x=-10;
  if(graph==25)power=maxpower+10;end
  if(graph==26)super=1;end
 END
 FRAME;
UNTIL(x<0)
END
PROCESS eshot(x,y,matk)
PRIVATE
id2;
BEGIN
graph=rand(23,24);
file=vfile[1];
REPEAT
 x-=10;
 angle+=100000;
 if(x<-20)var1=1;end
 id2=collision(TYPE vegetacontrol);
 if(id2!=0)
  var1=1;
  if(super==0)power-=matk;end
 end
 FRAME;
UNTIL(var1==1);
size=25;
FROM graph = 10 TO 15;
 FRAME;
END
END
PROCESS gokusfight()
BEGIN
freeza();
file=vfile[3];x=50;y=130;flags=0;graph=1;
put_screen(vfile[0],102);
FROM graph=1 TO 11;
 FRAME(900);
END
write(0,150,190,4,"Use space to volley the ki ball");
write(1,150,50,4,"GET READY");
FRAME(1000);
delete_text(all_text);
write(0,150,190,4,"Use space to volley the ki ball");
write(1,150,50,4,"SET");
FRAME(1000);
delete_text(all_text);
write(0,150,190,4,"Use space to volley the ki ball");
write(1,150,50,4,"FIGHT NOW!!");
FRAME(2000);
delete_text(all_text);
energyx[0]=100;energyx[1]=100;
write_int(0,50,15,5,&energyx[0]);
write_int(0,250,15,5,&energyx[1]);
write(0,50,15,3,"0000");
write(0,250,15,3,"0000");
FRAME(1000);
exit_game=2;
LOOP
 if(var3==0)graph=13;end
 if(key(_space))var3=1;end
 if(var3>=1)
   var3++;
   if(var3>0 and var3<8)graph=14;end
   if(var3>7 and var3<15)graph=15;end
   if(var3>14 and var3<25)graph=16;end
   if(var3>24)var3=0;end
 end
 if(key(_up) and var3==0 and y>40)y-=5;end
 if(key(_down) and var3==0  and y<170)y+=5;end
 vy=y;
 FRAME;
 if(energyx[0]<=0 or energyx[1]<=0)exit_game=1;end
END
END
PROCESS freeza()
BEGIN
file=vfile[3];x=250;y=130;flags=1;graph=21;
FROM graph=21 TO 31;
 FRAME(900);
END
REPEAT
 FRAME;
UNTIL(exit_game==2);
graph=33;
LOOP
 if(var3==0 and rand(0,100)<20)var3=1;power=0;end
 if(var3>0)
  var3++;
  if(var3>0 and var3<8)graph=33;end
  if(var3>7 and var3<15)graph=34;end
  if(var3>14 and var3<25)graph=35;end
  if(var3==24)fball(x,y);end
  if(var3>24)graph=35;end
  if(power==1)var3=0;graph=32;end
 end
 if(vy<y and var3==0)y-=5;end
 if(vy>y and var3==0)y+=5;end
 FRAME;
END
END
PROCESS fball(x,y)
PRIVATE
id2;
BEGIN
var3=rand(5,25);
flags=1;file=vfile[3];graph=37;
play_wav(sfx[2],0);
REPEAT
 if(flags==1)x-=var3;id2=collision(TYPE gokusfight);end
 if(flags==0)x+=var3;id2=collision(TYPE freeza);end
 if(flags==0 and id2!=0)
  energyx[1]-=20;id2.graph=36;var1=1;
 end
 if(flags==1 and id2!=0)
  if(id2.graph==15)flags=0;end
  if(id2.graph<>15)var1=1;energyx[0]-=20;id2.graph=17;end
 end
 if(x<0 or x>320)var1=1;end
 FRAME;
UNTIL(var1==1);
power=1;
END

