Log in

View Full Version : Hop Around (movement pattern for boss)



C-Dawg
01-03-2007, 11:48 PM
To follow up the exceeingly simple enemy_ghost idea, I'll be posting enemy movement patterns as I code them. Put these codes on the invisible FFC that your custom boss FFCs are linked to.

This one makes the enemy hop around the room (ala Hardman in MM3).



// ============================================
// hop_around - This script is designed to script a hopping enemy
// in a sideview area. The FFC will target the player's location,
// then hop into the air and fall on that location.
// D0 - The speed at which the enemy moves.
// D1 - The delay before each hop.
// D2 - Drop delay (the time the enemy will take to get to the
// drop location, and wait there. If this value is too small, the
// enemy will drop before getting above the player. If it is too
// large, the enemy will hang in the air before dropping.
// D3 - The height the enemy jumps to before falling.
// D4 - The Y value of the floor of the room
// ===========================================

ffc script hop_around{

void run (int speed, int hop_delay, int drop_delay, int height, int floor_level){

int state = 0; // The state of this hopper
// 0 = resting
// 1 = hopping

int hdelay_counter = hop_delay; // Counters
int ddelay_counter = drop_delay;

int target_x; // Stores the player's x location at the start of a hop
int target_y; // Stores the player's y location at the start of a hop

while(true){

if(state == 0){

if(hdelay_counter <= 0){
state = 1;
hdelay_counter = hop_delay;
ddelay_counter = drop_delay;
target_x = Link->X;
target_y = Link->Y - height;
}
else{
hdelay_counter--;
if(this->Y > floor_level){
this->Vy = 0;
this->Vx = 0;
}
else{
this->Vy = speed;
this->Vx = 0;
}
}
} // end of state 0

if(state == 1){

if(ddelay_counter >= 0){
if(this->X < target_x){ this->Vx = speed; }
if(this->X > target_x){ this->Vx = -speed; }
if(this->Y < target_y){ this->Vy = speed; }
if(this->Y > target_y){ this->Vy = -speed; }
ddelay_counter--;
}
else{
state = 0;
}
} // end of state 1



Waitframe();
} // end of while loop
} // end of void run
} // end of ffc script

CJC
01-07-2007, 07:31 PM
I suppose it's a bit early to be asking this, but would it be possible to set up a script like this so that the enemy_ghost FFC alternates between different movement styles? Possibly some randomly and some based on Link's proximity?



Even if that's outside the realm of possibility, I still find these scripts of yours facinating. I'm going to enjoy exploring this.

C-Dawg
01-07-2007, 07:41 PM
Sure it would be. You'd have to incorporate two movement scripts into the same ffc script, though.

Alternatively, I guess you could have several invisible FFCs performing different movement patterns, and then your boss FFC would change which FFC it was linked too. You'd have to be mindful of getting the FFCs to the same x,y location when it switched between them, though.