User Tag List

Results 1 to 4 of 4

Thread: Diving Orbit Custom Boss Movement Pattern

  1. #1
    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%

    Diving Orbit Custom Boss Movement Pattern

    Oh hay it's another untested, uncompiled script.

    Code:
    // ========================================
    // orbit_diver - This FFC script makes the FFC behave as an
    // orbit diver.  At rest, the FFC will orbit the player at a certain
    // distance.  If the player attacks, the FFC distance of the
    // orbit will double for a short period of time, then it will 
    // immediately counterattck.  At regular
    // intervals, the FFC will dive towards the player and then return
    // to it's circular path.
    //
    // D0 - Speed of the orbit diver's normal behavior.  Must be
    // between 0 and about 6.28 for proper behavior.
    // D1 - Speed of the orbit diver's attack
    // D2 - Radius of the orbit diver's normal behavior
    // D3 - Delay between orbit diver's diving attack.  Make it longer
    // than 30, because that's how long the attack will last.
    // D4 - The time the orbit diver spends in a larger orbit after an attack
    // =======================================
    
    ffc script orbit_diver{
    
    	void run(int orbit_speed, int diving_speed, int radius, int delay, int dodge_time){
    
    		int state = 0;	// 0 = At rest, not dodging
    				// 1 = Dodging away from player attack
    				// 2 = Diving towards player
    
    		int i = 0;	// Used to keep track of the
    		int orbit_x;	// orbit of the ffc.
    		int orbit_y;	
    
    		int delay_counter = delay;		// Countdown to attack
    
    		int dodge_counter = dodge_time;		// Countdown to dodging
    
    		int dive_counter = 30;			// Duration of attack
    
    		// We need to scale 
    
    		while(true){
    
    			// First, calculate the idea orbit of this ffc and put it into orbit_x, orbit_y
    
    			orbit_x = Sin(i) + Link->X;
    			orbit_y = Cos(i) + Link->Y;
    			
    			// Next, increase the value of i for the next loop.
    
    			i  = i + orbit_speed;
    
    			// ============= State 0 Behavior ==============
    
    			if (state == 0){
    
    				// The FFC should get close to the ideal orbit (kept track of
    				// by orbit_x, orbit_y) if it is not already.
    		
    				if (  ((this->X - orbit_x) > 8) || ((this->X - orbit_x) < -8) ||
    				((this->Y - orbit_y) > 8) || ((this->Y - orbit_y) < -8)  ){
    
    					if (this->X >= orbit_x) { this->Vx = orbit_speed; }
    					else { this->Vx = -orbit_speed; }
    	
    					if (this->Y >= orbit_y) { this->Vy = orbit_speed; }
    					else { this->Vy = -orbit_speed; }
    				} 
    
    				// If the FFC is already close to the ideal orbit, just follow it around.
    	
    				else{
    
    					this->X = orbit_x;
    					this->Y = orbit_y;
    				}
    
    				// Countdown to diving attack
    
    				if (delay_counter <= 0){
    
    					state = 2;
    					dive_counter = 30;
    					delay_counter = delay;
    				}
    				else{
    					delay_counter--;
    				}
    
    				// Detect whether the player is attacking or using an item
    				if ( (Link->InputB) || (Link->InputA)){
    			
    					state = 1;	
    				}
    
    			} // end of state 0
    
    			// ============= State 1 Behavior ==============
    			if ( state == 1 ){
    
    				// Shift the ideal orbit to farther away from player
    				orbit_x = orbit_x * 2;
    				orbit_y = orbit_y * 2;
    
    				// The FFC should get close to the ideal orbit (kept track of
    				// by orbit_x, orbit_y) if it is not already.
    		
    				if (  ((this->X - orbit_x) > 8) || ((this->X - orbit_x) < -8) ||
    				((this->Y - orbit_y) > 8) || ((this->Y - orbit_y) < -8)  ){
    
    					if (this->X >= orbit_x) { this->Vx = orbit_speed; }
    					else { this->Vx = -orbit_speed; }
    	
    					if (this->Y >= orbit_y) { this->Vy = orbit_speed; }
    					else { this->Vy = -orbit_speed; }
    				} 
    
    				// If the FFC is already close to the ideal orbit, just follow it around.
    				else{
    
    					this->X = orbit_x;
    					this->Y = orbit_y;
    				}
    
    				// Countdown to diving attack
    				if (delay_counter <= 0){
    
    					state = 2;
    					dive_counter = 30;
    					delay_counter = delay;
    				}
    				else{
    					delay_counter--;
    				}
    
    				// Countdown to counterattack
    				if (dodge_counter <= 0){
    					state = 2;
    					dive_counter = 30;
    					dodge_counter = dodge_time;
    				}
    				else{
    					dodge_counter--;
    				}
    			} // end of state 1
    
    			// ============= State 2 Behavior ==============
    			if (state == 2){
    
    				if (this->X <= Link->X){
    					this->Vx = this->Vx + (diving_speed/10);
    					if ( this->Vx > diving_speed ) { this->Vx = diving_speed; }
    				else{
    					this->Vx = this->Vx - (diving_speed/10);
    					if ( this->Vx < -diving_speed ) { this->Vx = -diving_speed; }
    				}
    
    				if (this->Y <= Link->Y){
    					this->Vy = this->Vy + (diving_speed/10);
    					if ( this->Vy > diving_speed ) { this->Vy = diving_speed; }
    				else{
    					this->Vy = this->Vy - (diving_speed/10);
    					if ( this->Vy < -diving_speed ) { this->Vy = -diving_speed; }
    				}
    
    				// Duration of attack
    				if (dive_counter <= 0){
    					state = 0;
    				}
    				else{
    					dive_counter--;
    				}
    
    			} end of state 2 
    
    			Waitframe();
    		} // end of while loop
    	} // end of void run
    }// end of ffc script

  2. #2
    Developer
    ZC Developer
    jman2050's Avatar
    Join Date
    Jun 2001
    Location
    Do you really need to know
    Age
    37
    Posts
    3,883
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    5,709
    Level
    23
    vBActivity - Bars
    Lv. Percent
    46.23%

    Re: Diving Orbit Custom Boss Movement Pattern

    I'm getting a P00 error. After I put the comments on line 171 to get rid of that error, it gives me an unexpected $end, on token error at the very last line in the file :/
    AGN's Resident Zelda Classic Developer and Sonic the Hedgehog Fanboy

  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: Diving Orbit Custom Boss Movement Pattern

    Yea, raw code'll do that. I post here to let people borrow from what I'm working on, and serve as a little online saved version of what I'm doing. When it comes to scripting, my philosophy is to script in the open. It's the only way other people are going to learn.

  4. #4
    Developer
    ZC Developer
    jman2050's Avatar
    Join Date
    Jun 2001
    Location
    Do you really need to know
    Age
    37
    Posts
    3,883
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    5,709
    Level
    23
    vBActivity - Bars
    Lv. Percent
    46.23%

    Re: Diving Orbit Custom Boss Movement Pattern

    Just because I felt like it, here's my version, based off this raw code

    Code:
    // ========================================
    // orbit_diver - This FFC script makes the FFC behave as an
    // orbit diver.  At rest, the FFC will orbit the player at a certain
    // distance.  If the player attacks, the FFC distance of the
    // orbit will double for a short period of time, then it will 
    // immediately counterattck.  At regular
    // intervals, the FFC will dive towards the player and then return
    // to it's circular path.
    //
    // D0 - Speed of the orbit diver's normal behavior.  Must be
    // between 0 and about 6.28 for proper behavior.
    // D1 - Speed of the orbit diver's attack
    // D2 - Radius of the orbit diver's normal behavior
    // D3 - Delay between orbit diver's diving attack.  Make it longer
    // than 30, because that's how long the attack will last.
    // D4 - The time the orbit diver spends in a larger orbit after an attack
    // =======================================
    
    ffc script orbit_diver{
    
    	void run(int orbit_speed, int diving_speed, int radius, int delay, int dodge_time) {
    
    		int state = 0;	// 0 = At rest, not dodging
    				// 1 = Dodging away from player attack
    				// 2 = Diving towards player
    
    		int i = 0;	// Used to keep track of the
    		int orbit_x;	// orbit of the ffc.
    		int orbit_y;
    		int orig_radius = radius;
    
    		int delay_counter = delay;		// Countdown to attack
    
    		int dodge_counter = dodge_time;		// Countdown to dodging
    
    		int dive_counter = 30;			// Duration of attack
    		
    		bool ontrack = true;
    
    		// We need to scale 
    
    		while(true) {
    
    			// First, calculate the idea orbit of this ffc and put it into orbit_x, orbit_y
    
    			orbit_x = ((Sin(i)*radius) + Link->X+8)-(this->EffectWidth/2);
    			orbit_y = ((Cos(i)*radius) + Link->Y+8)-(this->EffectWidth/2);
    			
    			// Next, increase the value of i for the next loop.
    
    			i  = i + orbit_speed;
    
    			// ============= State 0 Behavior ==============
    
    			if (state == 0) {
    			
    				// The FFC should get close to the ideal orbit (kept track of
    				// by orbit_x, orbit_y) if it is not already.
    		
    				if(!ontrack)
    				{
    				 	if (  ((this->X - orbit_x) > diving_speed) || ((this->X - orbit_x) < -diving_speed) ||
    					((this->Y - orbit_y) > diving_speed) || ((this->Y - orbit_y) < -diving_speed)  )
    					{
    
    						if (this->X >= orbit_x) 
    						{ 
    							this->X -= diving_speed; 
    						}
    						else 
    						{ 
    							this->X += diving_speed; 
    						}
    	
    						if (this->Y >= orbit_y) 
    						{ 
    							this->Y -= diving_speed; 
    						}
    						else 
    						{ 
    							this->Y += diving_speed; 
    						}
    					}
    					else
    					{
    						ontrack=true;
    					}
    				}
    
    				// If the FFC is already close to the ideal orbit, just follow it around.
    	
    				else{
    
    					this->X = orbit_x;
    					this->Y = orbit_y;
    				}
    
    				// Countdown to diving attack
    
    				if (delay_counter <= 0){
    
    					state = 2;
    					dive_counter = 30;
    					delay_counter = delay;
    				}
    				else{
    					delay_counter--;
    				}
    
    				// Detect whether the player is attacking or using an item
    				if ( (Link->InputB) || (Link->InputA)){
    			
    					state = 1;	
    				}
    
    			} // end of state 0
    
    			// ============= State 1 Behavior ==============
    			if ( state == 1 ) {
    
    				// Increase the radius incrementally until it reaches double the radius;
    				if(radius >= orig_radius*2) { radius = orig_radius*2; }
    				else { radius += 1; }
    
    				// The FFC should get close to the ideal orbit (kept track of
    				// by orbit_x2, orbit_y2) if it is not already.
    				
    				if(!ontrack)
    				{
    					if (  ((this->X - orbit_x) > orbit_speed) || ((this->X - orbit_x) < -orbit_speed) ||
    					((this->Y - orbit_y) > orbit_speed) || ((this->Y - orbit_y) < -orbit_speed)  ){
    
    						if (this->X >= orbit_x) { this->X -= diving_speed; }
    						else { this->X += diving_speed; }
    	
    						if (this->Y >= orbit_y) { this->Y -= diving_speed; }
    						else { this->Y += diving_speed; }
    					} 
    					else
    					{
    						ontrack=true;
    					}
    				}
    
    				// If the FFC is already close to the ideal orbit, just follow it around.
    				else{
    
    					this->X = orbit_x;
    					this->Y = orbit_y;
    				}
    
    				// Countdown to diving attack
    				if (delay_counter <= 0){
    
    					state = 2;
    					dive_counter = 30;
    					delay_counter = delay;
    				}
    				else{
    					delay_counter--;
    				}
    
    				// Countdown to counterattack
    				if (dodge_counter <= 0){
    					state = 2;
    					dive_counter = 30;
    					dodge_counter = dodge_time;
    				}
    				else{
    					dodge_counter--;
    				}
    			} // end of state 1
    
    			// ============= State 2 Behavior ==============
    			if (state == 2) {
    
    				if (this->X <= Link->X){
    					this->Vx = this->Vx + (diving_speed/10);
    					if ( this->Vx > diving_speed ) { this->Vx = diving_speed; }
    				}
    				else{
    					this->Vx = this->Vx - (diving_speed/10);
    					if ( this->Vx < -diving_speed ) { this->Vx = -diving_speed; }
    				}
    
    				if (this->Y <= Link->Y){
    					this->Vy = this->Vy + (diving_speed/10);
    					if ( this->Vy > diving_speed ) { this->Vy = diving_speed; }
    				}
    				else{
    					this->Vy = this->Vy - (diving_speed/10);
    					if ( this->Vy < -diving_speed ) { this->Vy = -diving_speed; }
    				}
    
    				// Duration of attack
    				if (dive_counter <= 0){
    					state = 0;
    					this->Vx = 0;
    					this->Vy = 0;
    					ontrack = false;
    					delay_counter = delay;
    					dodge_counter = dodge_time;
    					radius = orig_radius;
    				}
    				else{
    					dive_counter--;
    				}
    
    			} //end of state 2 
    
    			Waitframe();
    		} // end of while loop
    	} // end of void run
    } // end of ffc script
    AGN's Resident Zelda Classic Developer and Sonic the Hedgehog Fanboy

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