User Tag List

Results 1 to 4 of 4

Thread: Some Custom Enemy and Boss Scripts.

  1. #1
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,826
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,959
    Level
    33
    vBActivity - Bars
    Lv. Percent
    26.24%

    Some Custom Enemy and Boss Scripts.

    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!

    Code:
    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
    }


    Code:
    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);
    	 }
    }

    Code:
    //=======================================================
    //		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();
    		}
    	}
    }
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  2. #2
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,826
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,959
    Level
    33
    vBActivity - Bars
    Lv. Percent
    26.24%

    Re: Some Custom Enemy and Boss Scripts.

    Code:
    ffc script npc_shadow{
    
    	void run(int this_ffc_number, int enemyHP){
    
    		ffc this_ffc = Screen->LoadFFC(this_ffc_number);
    		ffc flame1 = Screen->LoadFFC(this_ffc_number+1);
    		ffc flame2 = Screen->LoadFFC(this_ffc_number+2);
    		ffc flame3 = Screen->LoadFFC(this_ffc_number+3);
    
    		int vert;int horiz;
    		int lurk = this->Data;
    		int rise = this->Data+1;
    		int attack = this->Data+2;
    		int f1 = this->Data+4;
    		int f2 = this->Data+5;
    		int f3 = this->Data+6;
    
    		int state = 0;
    		int delay = 0;
    		int xs; int ys;
    
    		int s = 9; //sfx
    		int rand = Rand(220);
    		int teleportX;
    		int teleportY;
    
    		npc shadow = Screen->CreateNPC(255);
    		shadow->HP =  enemyHP;
    	
    		while(true){
    
    			if(Link->Y < this->Y){vert = 0;}
    			else{vert = 1;}
    			if(Link->X < this->X){horiz = 0;}
    			else{horiz = 1;}
    
    			if(state == 0){
    		
    				this->Data = lurk;
    				shadow->X = -16;shadow->Y = -16;
    
    				for(int n=0; n<20; n++){
    
    					if(vert == 0){this_ffc->Y-=0.2;}
    					if(vert == 1){this_ffc->Y+=0.2;}
    					if(horiz == 0){this_ffc->X-=0.2;}
    					if(horiz == 1){this_ffc->X+=0.2;}
    
    					Waitframe();delay++;
    				}
    				if(delay > 120+rand){state = 1;delay = 0;}
    			}
    			else{
    			if(state == 1){
    
    				this->Data = rise;
    				shadow->X = this->X;shadow->Y = this->Y;
    
    				for(int n=0; n<20; n++){
    
    					if(vert == 0){this_ffc->Y-=0.3;}
    					if(vert == 1){this_ffc->Y+=0.3;}
    					if(horiz == 0){this_ffc->X-=0.3;}
    					if(horiz == 1){this_ffc->X+=0.3;}
    					shadow->X = this->X;shadow->Y = this->Y;
    					Waitframe();delay++;
    				}
    				if(delay > 120){state = 2;delay = 0;}
    			}
    			else{
    			if(state == 2){
    
    				this->Data = attack;
    				shadow->X = this->X;shadow->Y = this->Y;
    
    				for(int n=0; n<10; n++){
    
    					if(vert == 0){this_ffc->Y-=0.5;}
    					if(vert == 1){this_ffc->Y+=0.5;}
    					if(horiz == 0){this_ffc->X-=0.5;}
    					if(horiz == 1){this_ffc->X+=0.5;}
    					shadow->X = this->X;shadow->Y = this->Y;
    					Waitframe();delay++;
    				}
    				if(delay > 60){state = 3;delay = 0;}
    			}
    			else{
    			if(state == 3){ //find firing direction
    
    				if(vert == 0){ //up
    					if(Abs(this->X-Link->X)<16){ys = -1;xs = 0;}
    					else{
    						if(horiz == 0){ys = 0;xs = -1;}
    						else{ys = 0;xs = 1;}
    					}
    				}
    				else if(vert == 1){ //down
    					if(Abs(this->X-Link->X)<16){ys = 1;xs = 0;}
    					else{
    						if(horiz == 0){ys = 0;xs = -1;}
    						else{ys = 0;xs = 1;}
    					}
    				}
    				state = 4;
    			}
    			else{
    			if(state == 4){ // desroy!
    
    				flame1->Data = f1; flame1->X = this->X;flame1->Y = this->Y;
    				flame1->Vx = xs; flame1->Vy = ys;
    				shadow->X = this->X;shadow->Y = this->Y;
    				Waitframes(16);Game->PlaySound(s);
    				flame2->Data = f2; flame2->X = this->X;flame2->Y = this->Y;
    				flame2->Vx = xs; flame2->Vy = ys;
    				shadow->X = this->X;shadow->Y = this->Y;
    				Waitframes(16);Game->PlaySound(s);
    				flame3->Data = f3; flame3->X = this->X;flame3->Y = this->Y;
    				flame3->Vx = xs; flame3->Vy = ys;
    				shadow->X = this->X;shadow->Y = this->Y;
    				Waitframes(16);Game->PlaySound(s);
    				rand = Rand(120);
    				shadow->X = this->X;shadow->Y = this->Y;
    				Waitframes(rand);
    				shadow->X = this->X;shadow->Y = this->Y;
    				state = 0;delay = 0;
    				Waitframes(10);
    				teleportX = Rand(200)+20;
    				teleportY = Rand(120)+20;
    				Waitframe();
    				this->X = teleportX;
    				this->Y = teleportY;
    			}
    			}}}} //end of else statements
    		Waitframe();
    		}
    	}
    }

    Code:
    ffc script boss_phantoon{
    
    	void run(int this_ffc_number, int enemyHP, int vert_speed, int horiz_speed){
    
    		ffc this_ffc = Screen->LoadFFC(this_ffc_number);
    		ffc top = Screen->LoadFFC(this_ffc_number+1);
    		ffc bottom = Screen->LoadFFC(this_ffc_number+2);
    
    		ffc fire;
    		ffc current_ffc;
    
    		int state = 0;
    		int movement_state = 0;
    		int attack_state = 0;
    
    		int foo = this_ffc_number-1;
    		int bar = this_ffc_number-1;
    		int rand = Rand(300);
    		int delay = rand + 600;
    		int spit = 0;
    		int wobble = 0;
    
    		int data = 44; // combo number
    		int cset = 9;  // combo cset
    		int og_top = top->Data;
    		int og_bottom = bottom->Data;
    
    		int shooter_number = 0;
    		int enemy_number = 0;
    		npc shooter;
    		npc remove_shooter;
    
    		Waitframes(4);
    
    		npc boss = Screen->LoadNPC(1);
    		boss->HP = enemyHP;
    		boss->X=-16;boss->Y=-16;
    
    		top->Flags[1] = true;
    		bottom->Flags[1] = true;
    
    		Waitframes(120); // dramatic pause, play midi, etc.
    
    		while(true){
    
    			if(state == 0){ // transparent and invulnerable
    				top->Flags[1] = true;
    				bottom->Flags[1] = true;
    				top->Flags[9] = true;
    				bottom->Flags[9] = true;
    				top->Data = og_top; bottom->Data = og_bottom;
    				boss->X=-16;boss->Y=-16;
    			}
    			if(state == 1){
    				top->Flags[1] = false;
    				bottom->Flags[1] = false;
    				top->Flags[9] = false;
    				bottom->Flags[9] = false;
    				boss->X=this->X;boss->Y=this->Y;
    			}
    			if(state == 2){ // transparent 
    				top->Flags[1] = true;
    				bottom->Flags[1] = true;
    				top->Flags[9] = true;
    				bottom->Flags[9] = true;
    				boss->X=-16;boss->Y=-16;
    			}
    			if(state == 3){ // invisible!
    				top->Data = 1;
    				bottom->Data = 1;
    				boss->X=-16;boss->Y=-16;
    			}
    
    			if(delay > 0) delay--;
    			if(delay == 0){
    				if(state == 0) state = 1;
    				else if(state == 1) state = 2;
    				else if(state == 2) state = 3;
    				else if(state == 3) state = 0;
    
    				if(state == 1) delay = Rand(300)+600;
    				else delay = Rand(300)+200;
    				attack_state = Rand(3);
    			}
    
    			wobble++;
    
    			if(movement_state == 0){
    
    				if(this_ffc->X <= 32){ movement_state = 1;}
    				else{
    					this_ffc->Vx = -horiz_speed;
    					this_ffc->Vy = vert_speed * Sin(wobble);
    				}
    			}
    			if(movement_state == 1){
    				if(this_ffc->X >= 208){ movement_state = 0;}
    				else{
    					this_ffc->Vx = horiz_speed;
    					this_ffc->Vy = vert_speed * Sin(wobble);
    				}
    			}
    			if(attack_state == 0){ // tactical fire
    				
    				if(spit == 0){
    
    					if(foo < this_ffc_number-10) {foo = this_ffc_number-1;}
    
    					ffc fire = Screen->LoadFFC(foo);
    					fire->X = this->X;
    					fire->Y = this->Y + 16;
    					fire->Vy = 1;
    					if(Rand(2) == 0) fire->Vx= Rand(7)/9;
    					else fire->Vx= -Rand(7)/9;
    					fire->Data = data;fire->CSet = cset;
    					foo--; spit = 45;
    				}
    				else spit--;
    
    				bar = this_ffc_number-1;
    				
    				while(bar >= this_ffc_number-10){
    	
    					ffc current_ffc = Screen->LoadFFC(bar);
    
    					if(current_ffc->Y >= 140) current_ffc->Vy = -1;
    					else if(current_ffc->Y <= 20) current_ffc->Vy = 1;
    					else if(current_ffc->X >= 220) current_ffc->Vx = -1;
    					else if(current_ffc->X <= 20) current_ffc->Vx = 1;
    
    					bar--;
    				}
    			}
    			if(attack_state == 1){ // rapid fire!
    				
    				if(spit == 0){
    
    					if(foo < this_ffc_number-10) foo = this_ffc_number-1;
    
    					ffc fire = Screen->LoadFFC(foo);
    					if(Rand(2) == 0) fire->X = this->X+Rand(16);
    					else fire->X = this->X-Rand(16);
    					fire->Y = this->Y + Rand(17);
    					if(Rand(2) == 0) fire->Vx= Rand(10)/9;
    					else fire->Vx= -Rand(10)/9;
    					fire->Vy = 1;
    					fire->Data = data;fire->CSet = cset;
    					foo--; spit = 8;
    				}
    				else spit--;
    			}
    			if(attack_state == 2){ // direct fire stream!
    
    				while(shooter_number < 25){
    
    					npc shooter = Screen->CreateNPC(83);
    					shooter->X=this->X;shooter->Y=this->Y;
    					shooter_number++;					
    				}
    				enemy_number = Screen->NumNPCs();
    
    				while(enemy_number > 1){
    
    					npc remove_shooter = Screen->LoadNPC(enemy_number);
    
    					if(remove_shooter->Tile==0){
    						remove_shooter->X=this->X;
    						remove_shooter->Y=this->Y;
    					}
    					enemy_number--;
    				}
    
    			}
    			if(attack_state != 2){
    
    				enemy_number = Screen->NumNPCs();
    
    				while(enemy_number > 1){
    
    					npc remove_shooter = Screen->LoadNPC(enemy_number);
    
    					if(remove_shooter->Tile==0) remove_shooter->HP = 0;
    					enemy_number--;
    				}
    				shooter_number = 0;
    			}			
    			Waitframe();
    		}
    	}
    }

    OK, so here's the deal. I no longer have the quest file that these went to (Hard drive crash) so if nobody else uses them then no-one will.

    Basically each one is set up to be a boss (exept the fuzzballs...you can have 32 of those on one screen!) meaning you should use the enemies->Secret for that room.

    However I will be happy to change any of them for how you would like to use it. Just request what you need and I'll alter it for you.


    I'll add in a better explanation later...I realized I might still have an old copy of this quest somewhere online...So I'm off to look for it. *crosses fingers*
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  3. #3
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,612
    Level
    24
    vBActivity - Bars
    Lv. Percent
    99.95%

    Re: Some Custom Enemy and Boss Scripts.

    Cool. Wait, your drive died? No uploaded backups? Bummer.

  4. #4
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,826
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,959
    Level
    33
    vBActivity - Bars
    Lv. Percent
    26.24%

    Re: Some Custom Enemy and Boss Scripts.

    Yeah, I'm screwed.

    I know there is a copy of the quest somewhere though, I just have to find it. I mean I uploaded it at least on three occasions...somewhere..Also I keep backups on cds', but that is another story with a shitty ending also, no need to go into that. The crazy thing though is that if I hadn't uploaded a copy of my shmup quest one day earlier, I wouldn't even have it anymore..fuck.

    What I'm going to do is just unpassword it and let people look through it, Which is easier for me since I don't have to explain alot of it in detail. Plus they can just rip the scripts/tiles straight out of there if they wanted too. Sorry but this also puts another sizable delay on those backgrounds... Should pick up steam pretty fast again once I reinstall xp though.
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social