C-Dawg
01-05-2007, 07:33 PM
Oh hay it's another untested, uncompiled script.
// ========================================
// 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
// ========================================
// 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