Gleeok
05-06-2008, 04:31 AM
I posted these a while back at pure but then totally forgot to post them here too...sorry. Anyway, here's about five boss/miniboss scripts. You can use/alter/add-to them as you see fit. They work great (last used in b758) and should have no remaining bugs in them. Credit for some of the code fragments or idea's goes to Saffith and C-Dawg, and I can't remember...but I think I got a few lines from ShadowMancer (wherever you are) , so credit given.
These scripts are actually quite old, but a mix between zc bugs and script bugs postponed their release..yeah, that's it..otherwise It might seem I've been lazy or something. :p
Anyway; Enjoy!
const int FUZZBALL_CALL_HELP = 52;
ffc script npc_fuzzball{
void run(int enemyHP, int call_help){
if(enemyHP == 0){ enemyHP = 30;}
int counter = 240;
int delay = 0;
int wobble = 0;
int state = 0;
bool has_called = false;
bool init = false;
npc fuzzy;
while(true){
Waitframe();
int tx = this->X; int ty = this->Y;
int lx = Link->X; int ly = Link->Y;
if(this->Data > 6){
if(init == false){
init = true;
counter = 300 + Rand(200);
fuzzy = Screen->CreateNPC(255);
fuzzy->HP = enemyHP;
}
fuzzy->X = tx;
fuzzy->Y = ty;
if(!(fuzzy->isValid())){this->Data=0;this->X=0;this->Y=0;this->Vx=0;this->Vy=0;}
if(state == 0){ // random bouncing
if(this->Vx == 0){ this->Vx = 1.5/Rand(3);}
if(this->Vy == 0){ this->Vy = 1.5/Rand(3);}
if ( (this->Vx > 0) && (!canMove(this->X+17,this->Y))){
this->Vx = -this->Vx; }
else{
if ( (this->Vx < 0) && (!canMove(this->X-1,this->Y))){
this->Vx = -this->Vx; }
else{
if ( (this->Vy > 0) && (!canMove(this->X,this->Y+17))){
this->Vy = -this->Vy; }
else{
if ( (this->Vy < 0) && (!canMove(this->X,this->Y-1))){
this->Vy = -this->Vy; }
}
}
}
counter--;
if(counter <= 0){ state = 1;counter = 60;}
}
if(state == 1){ // attacking
if(lx > tx){this->X++;} if(lx < tx){this->X --;}
if(ly > ty){this->Y++;} if(ly < ty){this->Y --;}
if(Abs(tx-lx)<=14 && ly > ty){this->Vy += 0.1;}
if(Abs(tx-lx)<=14 && ly < ty){this->Vy -= 0.1;}
if(Abs(ty-ly)<=14 && lx > tx){this->Vx += 0.1;}
if(Abs(ty-ly)<=14 && lx < tx){this->Vx -= 0.1;}
if(Abs(ty-ly)<=24 && Abs(tx-ly)<=24){state = 2; counter = 23;}
}
else{
if(state == 2){ // moving back
if(counter > 0){
if(lx > tx){this->X --;} else{ this->X ++;}
if(ly > ty){this->Y --;} else{ this->Y ++;}
counter--;
}
else{ state = 3;counter = 350+Rand(350);}
}
else{
if(state == 3){ // seeking
if(counter > 0){
if(tx<lx){this->Vx=this->Vx+0.05;}else{this->Vx=this->Vx-0.05;}
if(ty<ly){this->Vy=this->Vy+0.05;}else{this->Vy=this->Vy-0.05;}
if(this->Vx>2){this->Vx=2;}if(this->Vx<-2){this->Vx=-2;}
if(this->Vy>2){this->Vy=2;}if(this->Vy<-2){this->Vy=-2;}
counter--;
}
else{ state = 4; counter = 120;}
}
else{
if(state == 4){ // calling for help
if(!has_called){
if(call_help > 0){
ffc help = Screen->LoadFFC(call_help);
help->Data = this->Data;
help->X = this->X;
Screen->Message(FUZZBALL_CALL_HELP);
}
has_called = true;
}
else{state = 5;}
}
else{
if(state == 5){ // resting
if(counter > 0){
this->Vx = 0; this->Vy = 0;counter--;
}
else{ state = 0; counter = 300 + Rand(300);}
}
}
}
}
}
}
if(this->X > 232) { this->Vx = -1; this->X--;}
if(this->X < 8) { this->Vx = 1; this->X++;}
if(this->Y > 152) { this->Vy = -1; this->Y--;}
if(this->Y < 8) { this->Vy = 1; this->Y++;}
}
}
bool canMove(int x, int y){
// x=23, y=130
// Obviously in range...
if(x<0 || x>255 || y<0 || y>175)
return false;
int mask=1111b;
// x % 16 = 7, so
// mask = 1111 & 0011 = 0011
if(x%16<8)
mask&=0011b;
else
mask&=1100b;
// y % 16 = 2, so
// mask = 0011 & 0101 = 0001
if(y%16<8)
mask&=0101b;
else
mask&=1010b;
// All but the top-right quarter of the combo is solid, so ComboS = 1011
// mask & ComboS = 0001 & 1011 = 0001
// The result wasn't 0, so return false
return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);
}// end of canMove
}
ffc script npc_ninja{
void run(int this_ffc_number, int enemyHP, int boss){
ffc this_ffc = Screen->LoadFFC(this_ffc_number);
int dir = 0;
int directX;
int directY;
int throw = 0;
int slash_delay = 0;
int state = 0;
int up = this->Data;
int down = this->Data+1;
int left = this->Data+2;
int right = this->Data+3;
ffc shuriken1 = Screen->LoadFFC(this_ffc_number+1);
ffc shuriken2 = Screen->LoadFFC(this_ffc_number+2);
ffc shuriken3 = Screen->LoadFFC(this_ffc_number+3);
int shuriken_data = 8;
ffc slash = Screen->LoadFFC(this_ffc_number+4);
int sword_up = slash->Data;
int sword_down = slash->Data+1;
int sword_left = slash->Data+2;
int sword_right = slash->Data+3;
npc ninja;
if(boss == 0){
ninja = Screen->CreateNPC(255);
ninja->HP = enemyHP;
}
if(boss != 0){
Waitframes(4);
ninja = Screen->LoadNPC(boss);
ninja->HP = enemyHP;
}
while(true){
ninja->X = this->X;
ninja->Y = this->Y;
int tx = this->X; int ty = this->Y;
int lx = Link->X; int ly = Link->Y;
if(throw > 0){throw--;}
if(slash_delay > 0){slash_delay--;}
if(state == 0){ //deciding
int rand = Rand(20);
if(Abs(tx - lx)<18 && Abs(ty - ly)<18){ // link is close, attack!
if(ty > ly && Abs(tx - lx)<14){state = 4; dir = 0;} //up
if(ty < ly && Abs(tx - lx)<14){state = 4; dir = 1;} //down
if(tx > lx && Abs(ty - ly)<14){state = 4; dir = 2;} //left
if(tx < lx && Abs(ty - ly)<14){state = 4; dir = 3;} //right
else{state = 5;directX = lx; directY = ly;} // direct attack!!!
}
else{
if(Abs(tx - lx)<9 && ty > ly && canMove(tx, ty-1)){state = 3; dir = 0;} //up
if(Abs(tx - lx)<9 && ty < ly && canMove(tx, ty+16)){state = 3; dir = 1;} //down
if(Abs(ty - ly)<9 && tx > lx && canMove(tx-1, ty)){state = 3; dir = 2;} //left
if(Abs(ty - ly)<9 && tx < lx && canMove(tx+16, ty)){state = 3; dir = 3;} //right
else{
if(rand == 0){ state = 2;}
else{state = 1;}
}
}
}
if(state == 1){ //moving toward Link
if(ty > ly && Abs(tx - lx)<= 48 && canMove(tx, ty-1)){ //up
this->Data = up;
for(int n=0; n<16; n++){
this_ffc->Y--;
Waitframe();
ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
if(Link->Y > this->Y){
if(Link->X > this->X){state = 3; dir = 3;}
if(Link->X < this->X){state = 3; dir = 2;}
}
}
else{
if(ty < ly && Abs(tx - lx)<= 48 && canMove(tx, ty+16)){ //down
this->Data = down;
for(int n=0; n<16; n++){
this_ffc->Y++;
Waitframe();
ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
if(Link->Y < this->Y){
if(Link->X > this->X){state = 3; dir = 3;}
if(Link->X < this->X){state = 3; dir = 2;}
}
}
else{
if(tx > lx && Abs(ty - ly)<= 48 && canMove(tx-1, ty)){ //left
this->Data = left;
for(int n=0; n<16; n++){
this_ffc->X--;
Waitframe();
ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
if(tx < lx && Abs(ty - ly)<= 48 && canMove(tx+16, ty)){ //right
this->Data = right;
for(int n=0; n<16; n++){
this_ffc->X++;
Waitframe();
ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
state = 2; // cannot move, so attack!
}
}
}
}
}
if(state == 2 && throw == 0){ //throw shurikens
int speed = (Rand(4)+3)/2;
shuriken1 = Screen->LoadFFC(this_ffc_number+1);
shuriken1->X = this->X; shuriken1->Y = this->Y;
shuriken1->Data = shuriken_data;
int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
shuriken1->Vx = dx/norm*speed;
shuriken1->Vy = dy/norm*speed;
}
Waitframes(20);
ninja->X = this->X;
ninja->Y = this->Y;
speed = (Rand(4)+3)/2;
shuriken2 = Screen->LoadFFC(this_ffc_number+2);
shuriken2->X = this->X; shuriken2->Y = this->Y;
shuriken2->Data = shuriken_data;
int px = Link->X - this->X;
int py = Link->Y - this->Y;
float normy = Sqrt(px*px+py*py);
if(normy > 0)
{
shuriken2->Vx = px/normy*speed;
shuriken2->Vy = py/normy*speed;
}
Waitframes(20);
ninja->X = this->X;
ninja->Y = this->Y;
speed = (Rand(4)+3)/2;
shuriken3 = Screen->LoadFFC(this_ffc_number+3);
shuriken3->X = this->X; shuriken3->Y = this->Y;
shuriken3->Data = shuriken_data;
int rx = Link->X - this->X;
int ry = Link->Y - this->Y;
float normf = Sqrt(rx*rx+ry*ry);
if(norm > 0)
{
shuriken3->Vx = dx/normf*speed;
shuriken3->Vy = dy/normf*speed;
}
state = 0;throw = 100;
}
if(state == 2 && throw > 0){ state = 0;}
if(state == 3){ //running toward Link
if(dir ==0){
this->Data = up;
for(int n=0; n<8; n++){
this_ffc->Y-=2;
Waitframe();ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
if(dir ==1){
this->Data = down;
for(int n=0; n<8; n++){
this_ffc->Y+=2;
Waitframe();ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
if(dir ==2){
this->Data = left;
for(int n=0; n<8; n++){
this_ffc->X-=2;
Waitframe();ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
if(dir ==3){
this->Data = right;
for(int n=0; n<8; n++){
this_ffc->X+=2;
Waitframe();ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
state = 2;
}
}
}
}
}
if(state == 4){ // slashing link
if(slash_delay == 0){
slash = Screen->LoadFFC(this_ffc_number+4);
if(dir == 0){ slash->Data = sword_up; slash->X = tx; slash->Y = ty-18;}
if(dir == 1){ slash->Data = sword_down;slash->X = tx; slash->Y = ty+18;}
if(dir == 2){ slash->Data = sword_left;slash->X = tx-18; slash->Y = ty;}
if(dir == 3){ slash->Data = sword_right;slash->X = tx+18; slash->Y = ty;}
slash_delay = 16;state = 0;
}
else{state = 1;}
}
if(state == 5){ // direct assault!
if(directX > tx){this->X++;}
if(directX < tx){this->X--;}
if(directY > ty){this->Y++;}
if(directY < ty){this->Y--;}
if(tx == directX && ty == directY){ state = 0;}
}
Waitframe();
}
}
bool canMove(int x, int y){
// x=23, y=130
// Obviously in range...
if(x<0 || x>255 || y<0 || y>175)
return false;
int mask=1111b;
// x % 16 = 7, so
// mask = 1111 & 0011 = 0011
if(x%16<8)
mask&=0011b;
else
mask&=1100b;
// y % 16 = 2, so
// mask = 0011 & 0101 = 0001
if(y%16<8)
mask&=0101b;
else
mask&=1010b;
// All but the top-right quarter of the combo is solid, so ComboS = 1011
// mask & ComboS = 0001 & 1011 = 0001
// The result wasn't 0, so return false
return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);
}
}
//================================================== =====
// FFC BOSS SENTINAL
// this ffc expects to be 2x2 and will use 9
// ffc's for attacks. previous 5-lasers, next 2- bombs, last 2 extra attacks.
// will move horizontally firing downward.
// you should also set the "draw over" flag for lasers.
// use with utility ffc scripts for maximum results!
//D0 - this ffc number
//D1 - boss HP
//================================================== =====
ffc script boss_Sentinal{
void run(int this_ffc_number, int enemyHP){
ffc this_ffc = Screen->LoadFFC(this_ffc_number);
ffc laser1 = Screen->LoadFFC(this_ffc_number-1);
ffc laser2 = Screen->LoadFFC(this_ffc_number-2);
ffc laser3 = Screen->LoadFFC(this_ffc_number-3);
ffc laser4 = Screen->LoadFFC(this_ffc_number-4);
ffc laser5 = Screen->LoadFFC(this_ffc_number-5);
ffc bomb1 = Screen->LoadFFC(this_ffc_number+1);
ffc bomb2 = Screen->LoadFFC(this_ffc_number+2);
ffc spark1 = Screen->LoadFFC(this_ffc_number+3);
ffc spark2 = Screen->LoadFFC(this_ffc_number+4);
int laser_data = this->Data+4;
int bomb_data = this->Data+6;
int beam_data = this->Data+10;
int spark_data = this->Data+11;
int delay = 0;
int state = 0;
bool t1 = false;
bool t2 = false;
int s = 19; // sfx
int moving = this->Data;
int firing = this->Data+1;
int throw_left = this->Data+2;
int throw_right = this->Data+3;
Waitframes(4);
npc boss = Screen->LoadNPC(1);
boss->HP = enemyHP;
while(true){
boss->X = this->X+8;boss->Y = this->Y+8;
int tx = this->X; int ty = this->Y;
int lx = Link->X; int ly = Link->Y;
if(state == 0){ //preparing to attack
this->Data = moving;
if(lx > tx+8){
this->X++;
Waitframe();
}
else{
if(lx < tx+8){
this->X--;
Waitframe();
}
}
delay++;
if(delay > 120){
if(t1 == false){state = 1;delay = 0;}
else{
if(t2 == false){state = 2;delay = 0;}
else{
state = 3;
}
}
}
}
if(state == 1 || state == 2){ //throwing energy bomb#1 or #2
int speed = 2;
int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(state == 1){
bomb1->X = this->X+8;bomb1->Y = this->Y+8;
//bomb1->TileWidth = 2;bomb1->TileHeight = 2;
//bomb1->EffectWidth = 32;bomb1->EffectHeight = 32;
bomb1->Data = bomb_data;
bomb1->Vx = 1.2;
bomb1->Vy = 1.3;
state = 0;this->Data = throw_left;t1 = true;
Waitframes(30);
}
if(state == 2){
bomb2->X = this->X+8;bomb2->Y = this->Y+8;
//bomb2->TileWidth = 2;bomb2->TileHeight = 2;
//bomb2->EffectWidth = 32;bomb2->EffectHeight = 32;
bomb2->Data = bomb_data;
bomb2->Vx = -1.3;
bomb2->Vy = -1.2;
state = 3;this->Data = throw_right;t2 = true;
Waitframes(30);
}
}
if(state == 3){ //main attack and movement
delay++;
if(lx > tx+8){
this->X++;this->Data = moving;
Waitframe();delay++;
}
else{
if(lx < tx+8){
this->X--;this->Data = moving;
Waitframe();delay++;
}
}
if(delay > 60 && delay < 880){
if(delay > 450 && delay < 502){
int speed = 0.3;this->Data = throw_left;spark1->Data = spark_data;spark1->X=this->X+8;spark1->Y=this->Y+8;
int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
spark1->Vx = dx/norm*speed;
spark1->Vy = dy/norm*speed;
}
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
this->Data = throw_right;spark2->Data = spark_data;spark2->X=this->X+8;spark2->Y=this->Y+8;
dx = Link->X - this->X;
dy = Link->Y - this->Y;
norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
spark2->Vx = dx/norm*speed;
spark2->Vy = dy/norm*speed;
}
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
delay += 50;
}
if(Abs(tx+8 - lx)<14 && ly > ty){ //fire lasers!
this->Data = firing;
laser1->Data = laser_data;
laser1->X = this->X+8;laser1->Y = this->Y+8;
laser1->Vx = 0; laser1->Vy = 3;
for(int n=0; n<16; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
laser2->Data = laser_data;
laser2->X = this->X+8;laser2->Y = this->Y+8;
laser2->Vx = 0; laser2->Vy = 3;
for(int n=0; n<16; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
laser3->Data = laser_data;
laser3->X = this->X+8;laser3->Y = this->Y+8;
laser3->Vx = 0; laser3->Vy = 3;
for(int n=0; n<16; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
laser4->Data = laser_data;
laser4->X = this->X+8;laser4->Y = this->Y+8;
laser4->Vx = 0; laser4->Vy = 3;
for(int n=0; n<16; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
laser5->Data = laser_data;
laser5->X = this->X+8;laser5->Y = this->Y+8;
laser5->Vx = 0; laser5->Vy = 3;
delay += 50;
for(int n=0; n<20; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
}
else{
if(Link->X > tx+8){this->X++;}
if(Link->X < tx+8){this->X--;}
}
}
if(delay >= 840){ // fire beam cannon!!!
this->Data = firing;delay += 200;
for(int n=0; n<20; n++){
int tx = this->X; int ty = this->Y;
int lx = Link->X; int ly = Link->Y;
laser1->Data = beam_data;
laser1->X = this->X+8;laser1->Y = this->Y+8;
laser1->Vx = 0; laser1->Vy = 0;
Screen->Rectangle(3,this->X+8,this->Y+16,this->X+24,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+8,this->Y+16,this->X+24,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+8,this->Y+16,this->X+24,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+8,this->Y+16,this->X+24,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+9,this->Y+16,this->X+23,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+9,this->Y+16,this->X+23,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+9,this->Y+16,this->X+23,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+9,this->Y+16,this->X+23,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
}
laser1->Data=1;
}
if(delay > 999){
int speed = 0.3;this->Data = throw_left;spark1->Data = spark_data;spark1->X=this->X+8;spark1->Y=this->Y+8;
int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
spark1->Vx = dx/norm*speed;
spark1->Vy = dy/norm*speed;
}
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
this->Data = throw_right;spark2->Data = spark_data;spark2->X=this->X+8;spark2->Y=this->Y+8;
dx = Link->X - this->X;
dy = Link->Y - this->Y;
norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
spark2->Vx = dx/norm*speed;
spark2->Vy = dy/norm*speed;
}
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
delay = 0;
}
}
Waitframe();
}
}
}
These scripts are actually quite old, but a mix between zc bugs and script bugs postponed their release..yeah, that's it..otherwise It might seem I've been lazy or something. :p
Anyway; Enjoy!
const int FUZZBALL_CALL_HELP = 52;
ffc script npc_fuzzball{
void run(int enemyHP, int call_help){
if(enemyHP == 0){ enemyHP = 30;}
int counter = 240;
int delay = 0;
int wobble = 0;
int state = 0;
bool has_called = false;
bool init = false;
npc fuzzy;
while(true){
Waitframe();
int tx = this->X; int ty = this->Y;
int lx = Link->X; int ly = Link->Y;
if(this->Data > 6){
if(init == false){
init = true;
counter = 300 + Rand(200);
fuzzy = Screen->CreateNPC(255);
fuzzy->HP = enemyHP;
}
fuzzy->X = tx;
fuzzy->Y = ty;
if(!(fuzzy->isValid())){this->Data=0;this->X=0;this->Y=0;this->Vx=0;this->Vy=0;}
if(state == 0){ // random bouncing
if(this->Vx == 0){ this->Vx = 1.5/Rand(3);}
if(this->Vy == 0){ this->Vy = 1.5/Rand(3);}
if ( (this->Vx > 0) && (!canMove(this->X+17,this->Y))){
this->Vx = -this->Vx; }
else{
if ( (this->Vx < 0) && (!canMove(this->X-1,this->Y))){
this->Vx = -this->Vx; }
else{
if ( (this->Vy > 0) && (!canMove(this->X,this->Y+17))){
this->Vy = -this->Vy; }
else{
if ( (this->Vy < 0) && (!canMove(this->X,this->Y-1))){
this->Vy = -this->Vy; }
}
}
}
counter--;
if(counter <= 0){ state = 1;counter = 60;}
}
if(state == 1){ // attacking
if(lx > tx){this->X++;} if(lx < tx){this->X --;}
if(ly > ty){this->Y++;} if(ly < ty){this->Y --;}
if(Abs(tx-lx)<=14 && ly > ty){this->Vy += 0.1;}
if(Abs(tx-lx)<=14 && ly < ty){this->Vy -= 0.1;}
if(Abs(ty-ly)<=14 && lx > tx){this->Vx += 0.1;}
if(Abs(ty-ly)<=14 && lx < tx){this->Vx -= 0.1;}
if(Abs(ty-ly)<=24 && Abs(tx-ly)<=24){state = 2; counter = 23;}
}
else{
if(state == 2){ // moving back
if(counter > 0){
if(lx > tx){this->X --;} else{ this->X ++;}
if(ly > ty){this->Y --;} else{ this->Y ++;}
counter--;
}
else{ state = 3;counter = 350+Rand(350);}
}
else{
if(state == 3){ // seeking
if(counter > 0){
if(tx<lx){this->Vx=this->Vx+0.05;}else{this->Vx=this->Vx-0.05;}
if(ty<ly){this->Vy=this->Vy+0.05;}else{this->Vy=this->Vy-0.05;}
if(this->Vx>2){this->Vx=2;}if(this->Vx<-2){this->Vx=-2;}
if(this->Vy>2){this->Vy=2;}if(this->Vy<-2){this->Vy=-2;}
counter--;
}
else{ state = 4; counter = 120;}
}
else{
if(state == 4){ // calling for help
if(!has_called){
if(call_help > 0){
ffc help = Screen->LoadFFC(call_help);
help->Data = this->Data;
help->X = this->X;
Screen->Message(FUZZBALL_CALL_HELP);
}
has_called = true;
}
else{state = 5;}
}
else{
if(state == 5){ // resting
if(counter > 0){
this->Vx = 0; this->Vy = 0;counter--;
}
else{ state = 0; counter = 300 + Rand(300);}
}
}
}
}
}
}
if(this->X > 232) { this->Vx = -1; this->X--;}
if(this->X < 8) { this->Vx = 1; this->X++;}
if(this->Y > 152) { this->Vy = -1; this->Y--;}
if(this->Y < 8) { this->Vy = 1; this->Y++;}
}
}
bool canMove(int x, int y){
// x=23, y=130
// Obviously in range...
if(x<0 || x>255 || y<0 || y>175)
return false;
int mask=1111b;
// x % 16 = 7, so
// mask = 1111 & 0011 = 0011
if(x%16<8)
mask&=0011b;
else
mask&=1100b;
// y % 16 = 2, so
// mask = 0011 & 0101 = 0001
if(y%16<8)
mask&=0101b;
else
mask&=1010b;
// All but the top-right quarter of the combo is solid, so ComboS = 1011
// mask & ComboS = 0001 & 1011 = 0001
// The result wasn't 0, so return false
return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);
}// end of canMove
}
ffc script npc_ninja{
void run(int this_ffc_number, int enemyHP, int boss){
ffc this_ffc = Screen->LoadFFC(this_ffc_number);
int dir = 0;
int directX;
int directY;
int throw = 0;
int slash_delay = 0;
int state = 0;
int up = this->Data;
int down = this->Data+1;
int left = this->Data+2;
int right = this->Data+3;
ffc shuriken1 = Screen->LoadFFC(this_ffc_number+1);
ffc shuriken2 = Screen->LoadFFC(this_ffc_number+2);
ffc shuriken3 = Screen->LoadFFC(this_ffc_number+3);
int shuriken_data = 8;
ffc slash = Screen->LoadFFC(this_ffc_number+4);
int sword_up = slash->Data;
int sword_down = slash->Data+1;
int sword_left = slash->Data+2;
int sword_right = slash->Data+3;
npc ninja;
if(boss == 0){
ninja = Screen->CreateNPC(255);
ninja->HP = enemyHP;
}
if(boss != 0){
Waitframes(4);
ninja = Screen->LoadNPC(boss);
ninja->HP = enemyHP;
}
while(true){
ninja->X = this->X;
ninja->Y = this->Y;
int tx = this->X; int ty = this->Y;
int lx = Link->X; int ly = Link->Y;
if(throw > 0){throw--;}
if(slash_delay > 0){slash_delay--;}
if(state == 0){ //deciding
int rand = Rand(20);
if(Abs(tx - lx)<18 && Abs(ty - ly)<18){ // link is close, attack!
if(ty > ly && Abs(tx - lx)<14){state = 4; dir = 0;} //up
if(ty < ly && Abs(tx - lx)<14){state = 4; dir = 1;} //down
if(tx > lx && Abs(ty - ly)<14){state = 4; dir = 2;} //left
if(tx < lx && Abs(ty - ly)<14){state = 4; dir = 3;} //right
else{state = 5;directX = lx; directY = ly;} // direct attack!!!
}
else{
if(Abs(tx - lx)<9 && ty > ly && canMove(tx, ty-1)){state = 3; dir = 0;} //up
if(Abs(tx - lx)<9 && ty < ly && canMove(tx, ty+16)){state = 3; dir = 1;} //down
if(Abs(ty - ly)<9 && tx > lx && canMove(tx-1, ty)){state = 3; dir = 2;} //left
if(Abs(ty - ly)<9 && tx < lx && canMove(tx+16, ty)){state = 3; dir = 3;} //right
else{
if(rand == 0){ state = 2;}
else{state = 1;}
}
}
}
if(state == 1){ //moving toward Link
if(ty > ly && Abs(tx - lx)<= 48 && canMove(tx, ty-1)){ //up
this->Data = up;
for(int n=0; n<16; n++){
this_ffc->Y--;
Waitframe();
ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
if(Link->Y > this->Y){
if(Link->X > this->X){state = 3; dir = 3;}
if(Link->X < this->X){state = 3; dir = 2;}
}
}
else{
if(ty < ly && Abs(tx - lx)<= 48 && canMove(tx, ty+16)){ //down
this->Data = down;
for(int n=0; n<16; n++){
this_ffc->Y++;
Waitframe();
ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
if(Link->Y < this->Y){
if(Link->X > this->X){state = 3; dir = 3;}
if(Link->X < this->X){state = 3; dir = 2;}
}
}
else{
if(tx > lx && Abs(ty - ly)<= 48 && canMove(tx-1, ty)){ //left
this->Data = left;
for(int n=0; n<16; n++){
this_ffc->X--;
Waitframe();
ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
if(tx < lx && Abs(ty - ly)<= 48 && canMove(tx+16, ty)){ //right
this->Data = right;
for(int n=0; n<16; n++){
this_ffc->X++;
Waitframe();
ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
state = 2; // cannot move, so attack!
}
}
}
}
}
if(state == 2 && throw == 0){ //throw shurikens
int speed = (Rand(4)+3)/2;
shuriken1 = Screen->LoadFFC(this_ffc_number+1);
shuriken1->X = this->X; shuriken1->Y = this->Y;
shuriken1->Data = shuriken_data;
int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
shuriken1->Vx = dx/norm*speed;
shuriken1->Vy = dy/norm*speed;
}
Waitframes(20);
ninja->X = this->X;
ninja->Y = this->Y;
speed = (Rand(4)+3)/2;
shuriken2 = Screen->LoadFFC(this_ffc_number+2);
shuriken2->X = this->X; shuriken2->Y = this->Y;
shuriken2->Data = shuriken_data;
int px = Link->X - this->X;
int py = Link->Y - this->Y;
float normy = Sqrt(px*px+py*py);
if(normy > 0)
{
shuriken2->Vx = px/normy*speed;
shuriken2->Vy = py/normy*speed;
}
Waitframes(20);
ninja->X = this->X;
ninja->Y = this->Y;
speed = (Rand(4)+3)/2;
shuriken3 = Screen->LoadFFC(this_ffc_number+3);
shuriken3->X = this->X; shuriken3->Y = this->Y;
shuriken3->Data = shuriken_data;
int rx = Link->X - this->X;
int ry = Link->Y - this->Y;
float normf = Sqrt(rx*rx+ry*ry);
if(norm > 0)
{
shuriken3->Vx = dx/normf*speed;
shuriken3->Vy = dy/normf*speed;
}
state = 0;throw = 100;
}
if(state == 2 && throw > 0){ state = 0;}
if(state == 3){ //running toward Link
if(dir ==0){
this->Data = up;
for(int n=0; n<8; n++){
this_ffc->Y-=2;
Waitframe();ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
if(dir ==1){
this->Data = down;
for(int n=0; n<8; n++){
this_ffc->Y+=2;
Waitframe();ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
if(dir ==2){
this->Data = left;
for(int n=0; n<8; n++){
this_ffc->X-=2;
Waitframe();ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
if(dir ==3){
this->Data = right;
for(int n=0; n<8; n++){
this_ffc->X+=2;
Waitframe();ninja->X = this->X;ninja->Y = this->Y;
}
state = 0;
}
else{
state = 2;
}
}
}
}
}
if(state == 4){ // slashing link
if(slash_delay == 0){
slash = Screen->LoadFFC(this_ffc_number+4);
if(dir == 0){ slash->Data = sword_up; slash->X = tx; slash->Y = ty-18;}
if(dir == 1){ slash->Data = sword_down;slash->X = tx; slash->Y = ty+18;}
if(dir == 2){ slash->Data = sword_left;slash->X = tx-18; slash->Y = ty;}
if(dir == 3){ slash->Data = sword_right;slash->X = tx+18; slash->Y = ty;}
slash_delay = 16;state = 0;
}
else{state = 1;}
}
if(state == 5){ // direct assault!
if(directX > tx){this->X++;}
if(directX < tx){this->X--;}
if(directY > ty){this->Y++;}
if(directY < ty){this->Y--;}
if(tx == directX && ty == directY){ state = 0;}
}
Waitframe();
}
}
bool canMove(int x, int y){
// x=23, y=130
// Obviously in range...
if(x<0 || x>255 || y<0 || y>175)
return false;
int mask=1111b;
// x % 16 = 7, so
// mask = 1111 & 0011 = 0011
if(x%16<8)
mask&=0011b;
else
mask&=1100b;
// y % 16 = 2, so
// mask = 0011 & 0101 = 0001
if(y%16<8)
mask&=0101b;
else
mask&=1010b;
// All but the top-right quarter of the combo is solid, so ComboS = 1011
// mask & ComboS = 0001 & 1011 = 0001
// The result wasn't 0, so return false
return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);
}
}
//================================================== =====
// FFC BOSS SENTINAL
// this ffc expects to be 2x2 and will use 9
// ffc's for attacks. previous 5-lasers, next 2- bombs, last 2 extra attacks.
// will move horizontally firing downward.
// you should also set the "draw over" flag for lasers.
// use with utility ffc scripts for maximum results!
//D0 - this ffc number
//D1 - boss HP
//================================================== =====
ffc script boss_Sentinal{
void run(int this_ffc_number, int enemyHP){
ffc this_ffc = Screen->LoadFFC(this_ffc_number);
ffc laser1 = Screen->LoadFFC(this_ffc_number-1);
ffc laser2 = Screen->LoadFFC(this_ffc_number-2);
ffc laser3 = Screen->LoadFFC(this_ffc_number-3);
ffc laser4 = Screen->LoadFFC(this_ffc_number-4);
ffc laser5 = Screen->LoadFFC(this_ffc_number-5);
ffc bomb1 = Screen->LoadFFC(this_ffc_number+1);
ffc bomb2 = Screen->LoadFFC(this_ffc_number+2);
ffc spark1 = Screen->LoadFFC(this_ffc_number+3);
ffc spark2 = Screen->LoadFFC(this_ffc_number+4);
int laser_data = this->Data+4;
int bomb_data = this->Data+6;
int beam_data = this->Data+10;
int spark_data = this->Data+11;
int delay = 0;
int state = 0;
bool t1 = false;
bool t2 = false;
int s = 19; // sfx
int moving = this->Data;
int firing = this->Data+1;
int throw_left = this->Data+2;
int throw_right = this->Data+3;
Waitframes(4);
npc boss = Screen->LoadNPC(1);
boss->HP = enemyHP;
while(true){
boss->X = this->X+8;boss->Y = this->Y+8;
int tx = this->X; int ty = this->Y;
int lx = Link->X; int ly = Link->Y;
if(state == 0){ //preparing to attack
this->Data = moving;
if(lx > tx+8){
this->X++;
Waitframe();
}
else{
if(lx < tx+8){
this->X--;
Waitframe();
}
}
delay++;
if(delay > 120){
if(t1 == false){state = 1;delay = 0;}
else{
if(t2 == false){state = 2;delay = 0;}
else{
state = 3;
}
}
}
}
if(state == 1 || state == 2){ //throwing energy bomb#1 or #2
int speed = 2;
int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(state == 1){
bomb1->X = this->X+8;bomb1->Y = this->Y+8;
//bomb1->TileWidth = 2;bomb1->TileHeight = 2;
//bomb1->EffectWidth = 32;bomb1->EffectHeight = 32;
bomb1->Data = bomb_data;
bomb1->Vx = 1.2;
bomb1->Vy = 1.3;
state = 0;this->Data = throw_left;t1 = true;
Waitframes(30);
}
if(state == 2){
bomb2->X = this->X+8;bomb2->Y = this->Y+8;
//bomb2->TileWidth = 2;bomb2->TileHeight = 2;
//bomb2->EffectWidth = 32;bomb2->EffectHeight = 32;
bomb2->Data = bomb_data;
bomb2->Vx = -1.3;
bomb2->Vy = -1.2;
state = 3;this->Data = throw_right;t2 = true;
Waitframes(30);
}
}
if(state == 3){ //main attack and movement
delay++;
if(lx > tx+8){
this->X++;this->Data = moving;
Waitframe();delay++;
}
else{
if(lx < tx+8){
this->X--;this->Data = moving;
Waitframe();delay++;
}
}
if(delay > 60 && delay < 880){
if(delay > 450 && delay < 502){
int speed = 0.3;this->Data = throw_left;spark1->Data = spark_data;spark1->X=this->X+8;spark1->Y=this->Y+8;
int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
spark1->Vx = dx/norm*speed;
spark1->Vy = dy/norm*speed;
}
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
this->Data = throw_right;spark2->Data = spark_data;spark2->X=this->X+8;spark2->Y=this->Y+8;
dx = Link->X - this->X;
dy = Link->Y - this->Y;
norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
spark2->Vx = dx/norm*speed;
spark2->Vy = dy/norm*speed;
}
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
delay += 50;
}
if(Abs(tx+8 - lx)<14 && ly > ty){ //fire lasers!
this->Data = firing;
laser1->Data = laser_data;
laser1->X = this->X+8;laser1->Y = this->Y+8;
laser1->Vx = 0; laser1->Vy = 3;
for(int n=0; n<16; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
laser2->Data = laser_data;
laser2->X = this->X+8;laser2->Y = this->Y+8;
laser2->Vx = 0; laser2->Vy = 3;
for(int n=0; n<16; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
laser3->Data = laser_data;
laser3->X = this->X+8;laser3->Y = this->Y+8;
laser3->Vx = 0; laser3->Vy = 3;
for(int n=0; n<16; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
laser4->Data = laser_data;
laser4->X = this->X+8;laser4->Y = this->Y+8;
laser4->Vx = 0; laser4->Vy = 3;
for(int n=0; n<16; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
laser5->Data = laser_data;
laser5->X = this->X+8;laser5->Y = this->Y+8;
laser5->Vx = 0; laser5->Vy = 3;
delay += 50;
for(int n=0; n<20; n++){
boss->X = this->X+8;boss->Y = this->Y+8;
if(Link->X > this->X+8){this->X+=0.5;}
if(Link->X < this->X+8){this->X-=0.5;}
Waitframe();
}
}
else{
if(Link->X > tx+8){this->X++;}
if(Link->X < tx+8){this->X--;}
}
}
if(delay >= 840){ // fire beam cannon!!!
this->Data = firing;delay += 200;
for(int n=0; n<20; n++){
int tx = this->X; int ty = this->Y;
int lx = Link->X; int ly = Link->Y;
laser1->Data = beam_data;
laser1->X = this->X+8;laser1->Y = this->Y+8;
laser1->Vx = 0; laser1->Vy = 0;
Screen->Rectangle(3,this->X+8,this->Y+16,this->X+24,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+8,this->Y+16,this->X+24,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+8,this->Y+16,this->X+24,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+8,this->Y+16,this->X+24,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+9,this->Y+16,this->X+23,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+9,this->Y+16,this->X+23,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+9,this->Y+16,this->X+23,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
Screen->Rectangle(3,this->X+9,this->Y+16,this->X+23,180,17,1,0,0,0,true,128);
Waitframe();boss->X = this->X+8;boss->Y = this->Y+8;
if(lx > tx+8){this->X+=0.5;}
if(lx < tx+8){this->X-=0.5;}laser1->X = this->X+8;laser1->Y = this->Y+8;
if(Abs(this->X+8 - Link->X)<16 && Link->Y > this->Y){Link->HP--;Game->PlaySound(s);}
}
laser1->Data=1;
}
if(delay > 999){
int speed = 0.3;this->Data = throw_left;spark1->Data = spark_data;spark1->X=this->X+8;spark1->Y=this->Y+8;
int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
spark1->Vx = dx/norm*speed;
spark1->Vy = dy/norm*speed;
}
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
this->Data = throw_right;spark2->Data = spark_data;spark2->X=this->X+8;spark2->Y=this->Y+8;
dx = Link->X - this->X;
dy = Link->Y - this->Y;
norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
spark2->Vx = dx/norm*speed;
spark2->Vy = dy/norm*speed;
}
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
Waitframes(10);boss->X = this->X+8;boss->Y = this->Y+8;
delay = 0;
}
}
Waitframe();
}
}
}