PDA

View Full Version : Changing the FFC's Combo in a Script



C-Dawg
10-19-2006, 10:03 PM
How is this accomplished? I've tried loading values into this->Data, such as:

this->Data = this->Data + 1;

And it compiles, but has no effect on changing the combo associated with the FFC.

Saffith
10-19-2006, 10:41 PM
It doesn't? It should. You're doing it right. Are you sure the statement's being executed?

C-Dawg
10-19-2006, 11:48 PM
Well, here's the script:

// ================================================== ====================
// Charging_Bull: The FFC will move horizontally back and forth until it is lined up with Link.
// Once it's lined up, it will charge towards Link until it hits a solid combo. It will then
// be stunned and pause for a moment before reviving and resuming the same movement.
// ================================================== ====================

ffc script charging_bull {

void run() {

// CONSTANTS (use to change FFC behavior without modifying code)
int charge_sound = 13; // The sound played when the FFC charges
int slam_sound = 13; // The sound played when the FFC hits a solid combo
int stun_tics = 60; // The number of tics for which the FFC will be stunned.
int patrol_speed = 1; // The speed at which the FFC moves horizontally back and forth.

// VARIABLES (used by the code; do not change)
int stun_counter = 0; // The countdown to when the FFC will move again.
int accel = 0; // The FFC's current accelleration
int state = 0; // Determines the state of the FFC.
// 0 = Moving horizontally to the right
// 1 = Moving horizontally to the left
// 2 = Charging north
// 3 = Charging south
// 4 = Stunned

int combo = this->Data; // combo used by the charging_bull

while (true){

// Moving horizontally to the right.

if (state == 0) {

if (Link->Y > this->Y){
this->Data = combo;
}
else{
this->Data = combo + 3;
}

// Check to see if FFC is lined up with Link. If so,
// switch behavior to charge in the appropriate direction.

if (Abs(Link->X - this->X)<16){

Game->PlaySound(charge_sound);
if (Link->Y < this->Y) { this->Vx = 0; state = 2; }
else {this->Vx = 0; state = 3;}

}

// If not lined up with Link, move right.

else{this->Vx = patrol_speed;}

// If the FFC can't move to the right anymore, switch state
// and move to the left.

if (!canMove(this->X + 16, this->Y)){state = 1;}
}

if (state == 1) {


if (Link->Y > this->Y){
this->Data = combo;
}
else{
this->Data = combo + 3;
}

// Check to see if FFC is lined up with Link. If so,
// switch behavior to charge in the appropriate direction.

if (Abs(Link->X - this->X)<16){

Game->PlaySound(charge_sound);
if (Link->Y < this->Y) { this->Vx = 0; state = 2; }
else {this->Vx = 0; state = 3;}
}

// If not lined up with Link, move left.

else{this->Vx = -patrol_speed;}

// If the FFC can't move to the right anymore, switch state
// and move to the left.

if (!canMove(this->X - 16, this->Y)){state = 0;}

}

if (state == 2) {

// Charging NORTH

this->Data = combo + 4;

// Accelerate up to 1.5px/sec, then jump to 2px/sec.
// Easy way to keep the trap centered on tiles.

if(accel<1.5){

accel=accel+0.1;
this->Y=this->Y-accel;
}
else {accel=2;}

// Once at maximum speed, every time the trap's
// centered on a tile, check whether it can
// continue moving. If not, then stop.

if(this->Y%16==0){

if(!canMove(this->X, this->Y-16)){

Game->PlaySound(slam_sound);
this->Data = combo + 8;
state = 4;
accel = 0;
stun_counter = stun_tics;

}
else{
this->Y=this->Y-accel;
}
}
else{
this->Y=this->Y-accel;
}
}

if (state == 3) {

// Charging SOUTH

this->Data = combo + 2;

// Accelerate up to 1.5px/sec, then jump to 2px/sec.
// Easy way to keep the trap centered on tiles.

if(accel<1.5){

accel=accel+0.1;
this->Y=this->Y+accel;
}
else {accel=2;}

// Once at maximum speed, every time the trap's
// centered on a tile, check whether it can
// continue moving. If not, then stop.

if(this->Y%16==0){

if(!canMove(this->X, this->Y+16)){

Game->PlaySound(slam_sound);
this->Data = combo +5;
state = 4;
stun_counter = stun_tics;
accel = 0;
}

else{
this->Y=this->Y+accel;
}
}
else{
this->Y=this->Y+accel;
}
}

if (state == 4) {

// Waiting while stunned
if (stun_counter == 0){ state = 0; }
else {stun_counter = stun_counter - 1;}
}

Waitframe();

} // End of While loop

} // End of void run()

// Collision detection function
bool canMove(int x, int y){

if(x<0 || x>240 || y<0 || y>160)

return false;

return Screen->ComboS[y+(x>>4)]==0;
}

} // End of FFC Script

As you can see, it's supposed to switch combos when it's charging and based on it's position relative to Link. It's a miniboss, and the damage counter is taken care of by screen flags. So all this needs to do is switch between combos appropriately.

Saffith
10-20-2006, 12:10 AM
I don't know. It seems to be working just fine for me.
Is there anything else you can think of that could possibly be interfering?

C-Dawg
10-20-2006, 12:18 AM
Not that I can see. There are no other combos on the screen. The damn combo just won't change. Hmm...

EDIT - Okay, now, without changing anything, it works... sorta. The way I have it set up, when the FFC is stunned, it is a combo with a STRIKE flag attached. When you hit him at the right time, you score a hit and the secrets trigger once, reducing his health. In game, when I successfully strike the FFC at the right time, the game just freezes up. Midi continues playing, but the game crashes.