Jump to content

Photo

Gleeok's Script Emporium


  • Please log in to reply
27 replies to this topic

#1 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 March 2008 - 06:17 AM

I realized that some of you purezc people haven't seen these yet, so here you go. There's quite a few of them so feel free to leave a message and Gleeok will get back to you shortly.

..Oh, and I believe that pure's post length limits are fairly short for some reason so i'll have to break some ToS here.


Coming soon: Link FFC weapons, some neat B button magic spells, and more scripted bosses.




Right then well here goes:





Instill energy will turn any ordinary screen enemy into a regenerating killing machine, and rapid fire statue, well, um, it's a statue that fires rapidly...or not, it's up to you.

Uses:

Give the Instill Energy to an otherwise boring enemy, such as the Digdogger, or Aquamentus, maybe the digdogger kids too.

You can use the statue script for, well, a statue...icon_sweat.gif Maybe place it on an unwalkable combo?
Actually, You might want to link it to another ffc for something really sick. Perhaps a few rapid fire scripts linked to an enemy with Instill energy?


CODE

//=============================================================
//         FFC SCRIPT INSTILL ENERGY
// D0 - the first of four ffc's to use as projectiles
// D1 - new enemy HP amount
// D2 - delay between rapid fire attack (in ticks) /default is 300
// D3 - combo to use as projectiles
// D4 - CSet of projectiles
// D5 - speed of projectiles
// D6 - screen enemy number to instill energy to
// D7 - the HP regeneration of the instilled enemy :O
//=============================================================

ffc script Instill_Energy{

    void run(int fireball_number, int enemyHP, int max_delay, int cdata, int cset, int speed, int screen_enemy_number, int regen){

        int fire = fireball_number;
        
        if(max_delay == 0){max_delay = 300;}

        int enemy_number = 0;
        npc enemy;
        ffc shoot;

        int delay = 0;

        Waitframes(4);

        npc fire_master = Screen->LoadNPC(screen_enemy_number);
        npc firestorm;
        fire_master->HP = enemyHP;

        while(true){

            if(fire_master->isValid()){
        
                if(fire >= fireball_number+4){fire = fireball_number;}
    
                this->X = fire_master->X; this->Y = fire_master->Y;
                if(delay > max_delay){
                    delay = 0;
                    fire_master->HP = fire_master->HP + regen;
                }
                if(delay==20||delay==40||delay==60||delay==80){

                    shoot = Screen->LoadFFC(fire);
                    shoot->Data = cdata;
                    shoot->CSet = cset;
                    shoot->X = this->X; shoot->Y = this->Y;                    

                    int dx = Link->X - this->X;
                    int dy = Link->Y - this->Y;
                    float norm = Sqrt(dx*dx+dy*dy);
                    if(norm > 0)
                    {
                        shoot->Vx = dx/norm*speed;
                        shoot->Vy = dy/norm*speed;
                    }
                    fire++;
                }
            delay++;
            }
            else{
                this->X = 0; this->Y = 0; this->Data = 0;
            }
        Waitframe();
        }
    }
}



CODE

//===================================================================================
//            FFC SCRIPT RAPID FIRE STATUE
// D0 - the first ffc to use as projectiles
// D1 - the amount of ffc's to use for fireballs. Ex D0; 2, and D1 5, will use ffc's 2-7.
// D2 - speed of projectile
// D3 - combo of projectile
// D4 - Cset of projectile
// D5 - Max delay in ticks before the firing sequence restarts
// D6 - Delay between shots     *Note* It will fire five shots
// during the max delay sequence. If you want non-stop firing divide max delay by five.
// ex: Delay - 20, max delay 100. -for crazy statues try delay 8, max 50.
// if the combo of the statue changes the shooting will stop.
// D7 - the ffc to link this ffc to.
//====================================================================================


ffc script Rapid_fire_statue{

    void run(int fireball_number, int fireball_amount, int speed, int cdata, int cset, int max_delay, int fireball_delay, int linked_ffc){

        int fire = fireball_number;
        int swap = fireball_amount;
        int armed = fireball_delay;
        ffc shoot;
        int delay = 0;
        int original_combo = this->Data;
        ffc linked = Screen->LoadFFC(linked_ffc);

        if(max_delay == 0){max_delay = 300;}

        while(true){

            if(linked_ffc != 0){ this->X = linked->X; this->Y = linked->Y;}
            if(fire > fireball_number+swap){ fire = fireball_number;}
            if(delay > max_delay){delay = 0;}

            if(this->Data == original_combo){

                if(delay==armed||delay==armed+armed||delay==armed+armed+armed||
                    delay==armed+armed+armed+armed||delay==armed+armed+armed+armed+armed){

                    shoot = Screen->LoadFFC(fire);
                    shoot->Data = cdata;
                    shoot->CSet = cset;
                    shoot->X = this->X; shoot->Y = this->Y;                    

                    int dx = Link->X - this->X;
                    int dy = Link->Y - this->Y;
                    float norm = Sqrt(dx*dx+dy*dy);
                    if(norm > 0)
                    {
                        shoot->Vx = dx/norm*speed;
                        shoot->Vy = dy/norm*speed;
                    }
                    fire++;
                }
            delay++;
            }
        Waitframe();
        }
    }
}




//=======================================================
// ENEMY SPAWNER 3- Will spawn a preset amount of enemies
// from a pool of 3, chosen at random.
// Will place enemies at random locations if walkable.
// D0-D2; Enemies that might spawn,
// D3; Delay in ticks between spawns
// D4; Max number of enemies that will spawn.
// Thanks C-Dawg!
//=======================================================


ffc script enemyspawner3 {
    void run(int e1, int e2, int e3, int delay, int enemy_count ) {
                int RandNum = Rand(3);
                int en_count = enemy_count;
                int counter = delay;

                while(en_count > 0){

            if ( counter == 0 && RandNum == 0){
                    putenemy(e1);
                    counter = delay;
                                        RandNum = Rand(3);
                                        en_count = en_count - 1;
                }if ( counter == 0 && RandNum == 1){
                    putenemy(e2);
                    counter = delay;
                                        RandNum = Rand(3);
                                        en_count = en_count - 1;
                }if ( counter == 0 && RandNum == 2){
                    putenemy(e3);
                    counter = delay;
                                        RandNum = Rand(3);
                                        en_count = en_count - 1;
                }
            counter--;
                        Waitframe();
        } // end of while loop
    }      
    
    void putenemy(int eid){
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}


// =======================================================
// ENEMY SPAWNER 4 - This script is used to spawn enemies.  The FFC running
// the script will continue to spawn particular kinds of enemy at regular intervals
// until there are too many on the screen, or the combo used by the spawner changes.
// This version will always spawn at the location of the FFC running this script and
// will always spawn enemies untill the ghosted enemy at the location of this ffc
// is killed. currently uses enemy z255 as the ghosted enemy. Get used to using
// enemy 255 as a dummy enemy for scripts. Set up this enemy in the enemy editor.
//
// D0 - D2 = enemy_id = The enemy to be spawned.  Check the table in std.zh to get values.
// D3 = delay = The delay, in tics, between enemy spawns.
// D4 = max = The maximum number of enemies that the spawner will put on the screen.
// D5 - the HP of the ghosted enemy at this ffc.
// ======================================================

ffc script enemyspawner4{

    void run(int enemy_id, int enemy_id2, int enemy_id3, int delay, int max, int enemyHP){    
                        

        int original_combo = this->Data;    // Saves the original combo of this FFC.

        int counter = delay;            // Used to count the tics until it is time to spawn.
        int spawnX = this->X;
        int spawnY = this->Y;
        int random = Rand(3);

        Waitframes(4);

        npc enemy_life = Screen->CreateNPC(255);
        enemy_life->HP = enemyHP;

        while(enemy_life->isValid()){

            enemy_life->X = this->X;
            enemy_life->Y = this->Y;

            if ( (this->Data == original_combo) && (Screen->NumNPCs() < max) ){


                if ( counter == 0 && random == 0){

                    npc spawnee = Screen->CreateNPC(enemy_id);
                    spawnee->X = spawnX;
                    spawnee->Y = spawnY;
                    counter = delay;
                    random = Rand(3);
                }
                if ( counter == 0 && random == 1){

                    npc spawnee = Screen->CreateNPC(enemy_id2);
                    spawnee->X = spawnX;
                    spawnee->Y = spawnY;
                    counter = delay;
                    random = Rand(3);
                }
                if ( counter == 0 && random == 2){

                    npc spawnee = Screen->CreateNPC(enemy_id3);
                    spawnee->X = spawnX;
                    spawnee->Y = spawnY;
                    counter = delay;
                    random = Rand(3);                
                }
                else{
                    counter--;
                } // end if
            } // end if

            spawnX = this->X;
            spawnY = this->Y;

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





//====================================================
// FFC SCRIPT ENEMY MAKER
// D0-D6; Enemies that might spawn,
// D7; Number of max enemies you want to spawn.
// <in Addition to boss or any other enemies set to screen enemies>;)
// Thanks to DarkDragon! :=D
//====================================================



ffc script enemymaker {
        void run(int e1, int e2, int e3, int e4, int e5, int e6, int e7, int enemy_max) {
                int RandNum = Rand(7);
                int en_count = enemy_max;
                while(en_count > 0){

                               if (RandNum == 0){
                               putenemy(e1);
                             } if (RandNum == 1){
                               putenemy(e2);
                             } if (RandNum == 2){
                               putenemy(e3);
                             } if (RandNum == 3){
                               putenemy(e4);
                             } if (RandNum == 4){
                               putenemy(e5);
                             } if (RandNum == 5){
                               putenemy(e6);
                             } if (RandNum == 6){
                               putenemy(e7);
                             }
                               en_count = en_count - 1;
                               RandNum = Rand(7);
                            
                   }
          
    }

    void putenemy(int eid)
    {
        //to do this properly we really need priority queues in ZScript;)
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
        //simulate staggered spawning
        Waitframe();
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}





Here's how the en_maker random one works:

It will spawn enemies of your choice,(D0-D7)at RANDOM and spawn them in random locations on the screen if walkable. Just like normal enemies. As for what enemies will spawn, check the enemy data either in std.zh, or in you quest under the enemy editor. Any enemy you have made in the editor is an eligible candidate for this script.


If you use this and still don't know why I call it the veg-o-matic, well, then I know something you don't know. icon_razz.gif

CODE

// FFC SCRIPT VEG-O-MATIC---------------------------------------
//D0- vertical guard set 1
//D1- horizontal guard  set 1 *NOT BOTH!!!*
//D2- set 1 if can fire weapons
//D3- combo of weapon if d2
//D4- speed of weapon projectile if d2
//D5- time in tics between shots
//D6- CSet of weapon projectile
//D7- the starting ffc to use for projectiles
//---------------------------------------------------------

ffc script Veg_O_Matic{

    void run(int vert, int horiz, int armed, int weapon_combo, int speed, int rapid, int cset, int ffc_to_use){

        ffc shoot;
        int ffc_cycle = ffc_to_use;
        int delay = 0;

        while(true){

            delay++;
            if(ffc_cycle >= ffc_to_use+4){ ffc_cycle = ffc_to_use;}

            if(vert == 1){ if(this->Y > Link->Y+2){ this->Y--;} if(this->Y < Link->Y-2){ this->Y++;}}
            if(horiz == 1){ if(this->X > Link->X+2){ this->X--;} if(this->X < Link->X-2){ this->X++;}}

            if(armed == 1){
                if(vert == 1){
                    if(delay == rapid && Link->X > this->X){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y; shoot->X = this->X + 16;
                        shoot->Vx = speed;
                        shoot->CSet = cset;
                        ffc_cycle++;
                        delay = 0;
                    }
                    if(delay == rapid && Link->X < this->X){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y; shoot->X = this->X - 16;
                        shoot->Vx = -speed;
                        shoot->CSet = cset;
                        ffc_cycle++;
                        delay = 0;
                    }
                }
                if(horiz == 1){
                    if(delay == rapid && Link->Y > this->Y){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y + 16; shoot->X = this->X;
                        shoot->Vy = speed;
                        shoot->CSet = cset;
                        ffc_cycle++;
                        delay = 0;
                    }
                    if(delay == rapid && Link->Y < this->Y){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y - 16; shoot->X = this->X;
                        shoot->Vy = -speed;
                        shoot->CSet = cset;
                        ffc_cycle++;
                        delay = 0;
                    }
                }
            }
        Waitframe();
        }
    }
}



Ok, Ok, I know what you're thinking right now: "How can I get 255(or is that 256?) enemies on the screen at once and center them on an enemy and set that enemies HP to any obscene amount I want"? Well alrighty then, ask and ye shall recieve.


Flamethrower script:

CODE

//=======================================
// FFC SCRIPT FLAMETHROWER
//D0- minions to spawn (id number)
//D1- HP of the summoner
//D2- Max enemies on screen at once
//=======================================


ffc script Flamethrower{

    void run(int enemy_id, int enemyHP, int enemy_swarm){

        int enemy_number = 0;
        npc enemy;

        int slow_slowdown=0;
        int death = 0;

        Waitframes(4);

        npc fire_master = Screen->LoadNPC(1);
        npc firestorm;
        fire_master->HP = enemyHP;

        while(true){

            if(fire_master->isValid() || fire_master->HP >0){

                this->X = fire_master->X; this->Y = fire_master->Y;

                if(Screen->NumNPCs() < enemy_swarm){ npc firestorm = Screen->CreateNPC(enemy_id);}
            
                firestorm->X = this->X;
                firestorm->Y = this->Y;
            }
            else{ death = 1;}

            enemy_number = Screen->NumNPCs();

            while(enemy_number > 1){
            
                enemy = Screen->LoadNPC(enemy_number);
                enemy->X = this->X; enemy->Y = this->Y;

                if(death == 1){enemy->HP = 0;Screen->ClearSprites(2);}
                                
                enemy_number--;

                if(enemy_number > 30){
                    if(slow_slowdown == 0){ slow_slowdown = enemy_number; Waitframe();}
                    slow_slowdown--;
                }
            }
        Waitframe();
        }
    }
}


And now to make sure Link walks around in circles while being forced to repeadedly battle these baddies:

Random door generator:


CODE

//------------------------------------------------------
// Creates 1-3 closed shutters in a random direction as
// long as there is a wall.-along with a one-way wherever link enters from.
// Once the enemies have been killed the shutter will open.
// This will not overwrite essential doors added for specific dungeon map layouts :)
// For best results run at *SCREEN INIT*
// Not used yet/ -random locked doors, boss doors, open doors-
//------------------------------------------------------

ffc script random_door_generator{   //ver2.1

      void run(){

        int ddoor = 0;
    int udoor = 0;
    int ldoor = 0;
    int rdoor = 0;
        int RandNum = Rand(4);

        if (Link->Dir == 0 && Screen->Door[DIR_DOWN] == D_WALL){ ddoor = 1;}
                if (Link->Dir == 1 && Screen->Door[DIR_UP] == D_WALL){ udoor = 1;}
                if (Link->Dir == 2 && Screen->Door[DIR_RIGHT] == D_WALL){ rdoor = 1;}
        if (Link->Dir == 3 && Screen->Door[DIR_LEFT] == D_WALL){ ldoor = 1;}
          
                if (RandNum == 0 && Screen->Door[DIR_DOWN] == D_WALL){ Screen->Door[DIR_DOWN] = D_SHUTTER;}
        if (RandNum == 0 && Screen->Door[DIR_UP] == D_WALL){Screen->Door[DIR_UP] = D_SHUTTER;}
        if (RandNum == 1 && Screen->Door[DIR_RIGHT] == D_WALL){Screen->Door[DIR_RIGHT] = D_SHUTTER;}
        if (RandNum == 1 && Screen->Door[DIR_LEFT] == D_WALL){Screen->Door[DIR_LEFT] = D_SHUTTER; }
        if (RandNum == 2 && Screen->Door[DIR_DOWN] == D_WALL){Screen->Door[DIR_DOWN] = D_SHUTTER;}
        if (RandNum == 2 && Screen->Door[DIR_UP] == D_WALL){Screen->Door[DIR_UP] = D_SHUTTER;}
        if (RandNum == 2 && Screen->Door[DIR_RIGHT] == D_WALL){Screen->Door[DIR_RIGHT] = D_SHUTTER;}
        if (RandNum == 3 && Screen->Door[DIR_LEFT] == D_WALL){Screen->Door[DIR_LEFT] = D_SHUTTER;}
        if (RandNum == 3 && Screen->Door[DIR_RIGHT] == D_WALL){Screen->Door[DIR_RIGHT] = D_SHUTTER;}
        if (RandNum == 3 && Screen->Door[DIR_UP] == D_WALL){Screen->Door[DIR_UP] = D_SHUTTER; }

            if (ddoor == 1){Screen->Door[DIR_DOWN] = D_1WAYSHUTTER;}
        if (udoor == 1){Screen->Door[DIR_UP] = D_1WAYSHUTTER;}
        if (rdoor == 1){Screen->Door[DIR_RIGHT] = D_1WAYSHUTTER;}
        if (ldoor == 1){Screen->Door[DIR_LEFT] = D_1WAYSHUTTER; }  
    }
}



2.6 Armos script:

CODE

//======================================
//     -ffc script Armos-
//D0 - id of enemy to create
//D1 - HP of created enemy
//======================================

ffc script Armos{

    void run(int enemy_id, int enemyHP){

        int trigger = 0;
        npc armos;

        while(true){

            if(trigger == 0){
    
                if( Abs(Link->X - this->X) <= 16 && Abs(Link->Y - this->Y) <= 16){
                    npc armos = Screen->CreateNPC(enemy_id);
                    armos->X = this->X; armos->Y = this->Y;
                    armos->HP = enemyHP;
                    this->Data=0;trigger=1;
                }
            }
        Waitframe();
        }
    }
}



New one, Custom Armos. This one will get used...alot. I'm sure of it. icon_wink.gif

I guess it's true with scripts anyway; It's not how big it is, it's how you use it. :laughing:

CODE

//==================================================================================
//                FFC SCRIPT SENTRY
//
// D0 - Direction can shoot / values greater than 3 return up,down,left,right.
// D1 - combo of weapon projectile
// D2 - speed of projectile
// D3 - CSet of projectile
// D4 - First of 3 ffc's to use as projectiles
//==================================================================================

ffc script Sentry{

    void run(int shoot_dir, int weapon_combo, int speed, int cset, int ffc_to_use){

        ffc shoot;
        int ffc_cycle = ffc_to_use;
        int delay = 0;

        while(true){

            if(ffc_cycle >= ffc_to_use+3){ ffc_cycle = ffc_to_use;}
            if(delay > 0){delay--;}
            
        
            if(shoot_dir > 3 && delay == 0){

                if(Abs(Link->X-this->X)<14 && Link->Y < this->Y && canMove(this->X, this->Y-16)) // Up
                {
                    shoot = Screen->LoadFFC(ffc_cycle);
                    shoot->Data = weapon_combo;
                    shoot->Y = this->Y - 16; shoot->X = this->X;
                    shoot->Vy = -speed; shoot->Vx=0;
                    shoot->CSet = cset;
                    ffc_cycle++;
                    delay = 30;
                }
                else if(Abs(Link->X-this->X)<14 && Link->Y > this->Y && canMove(this->X, this->Y+16)) // Down
                {
                    shoot = Screen->LoadFFC(ffc_cycle);
                    shoot->Data = weapon_combo;
                    shoot->Y = this->Y + 16; shoot->X = this->X;
                    shoot->Vy = speed; shoot->Vx=0;
                    shoot->CSet = cset;
                    ffc_cycle++;
                    delay = 30;        
                }
                else if(Abs(Link->Y-this->Y)<14 && Link->X < this->X && canMove(this->X-16, this->Y)) // Left
                {
                    shoot = Screen->LoadFFC(ffc_cycle);
                    shoot->Data = weapon_combo;
                    shoot->Y = this->Y; shoot->X = this->X - 16;
                    shoot->Vx = -speed; shoot->Vy=0;
                    shoot->CSet = cset;
                    ffc_cycle++;
                    delay = 30;            
                }
                else if(Abs(Link->Y-this->Y)<14 && Link->X > this->X && canMove(this->X+16, this->Y)) // Right
                {
                    shoot = Screen->LoadFFC(ffc_cycle);
                    shoot->Data = weapon_combo;
                    shoot->Y = this->Y; shoot->X = this->X + 16;
                    shoot->Vx = speed; shoot->Vy=0;
                    shoot->CSet = cset;
                    ffc_cycle++;
                    delay = 30;
                }
            }
            else{
                if(shoot_dir==0 && delay == 0){
                    if(Abs(Link->X-this->X)<14 && Link->Y < this->Y && canMove(this->X, this->Y-16)){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y - 16; shoot->X = this->X;
                        shoot->Vy = -speed; shoot->Vx=0;
                        shoot->CSet = cset;
                        ffc_cycle++;
                        delay = 30;
                    }
                }
                else if(shoot_dir==1 && delay == 0){
                    if(Abs(Link->X-this->X)<14 && Link->Y > this->Y && canMove(this->X, this->Y+16)){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y + 16; shoot->X = this->X;
                        shoot->Vy = speed; shoot->Vx=0;
                        shoot->CSet = cset;
                        ffc_cycle++;
                       &n

#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 March 2008 - 10:54 AM

CODE
ffc script f_throw_cycle{

    void run(int target_ffc, int offset){

        ffc target = Screen->LoadFFC(target_ffc);
        int og_data = target->Data;
        npc shooter;
        npc remove_shooter;
        int enemy_number;
        int shooter_number = 0;

        while(true){

            if(target->Data == og_data+offset){

                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--;
                }

            }
            else{

                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();
        }
    }
}


Flamethrower mark II;

Will create a fire stream if the ffc's combo has cycled to the appropriate combo. Much faster than mark I, as all the shooters are generated instantaniously.

D0 - target ffc to watch for change.
D1 - offset of combo to trigger th fire stream.



CODE
ffc script string_defeated{

    void run(int m){

        Waitframes(6);
        while(Screen->NumNPCs() > 0) Waitframe();
        Screen->Message(m);
        Waitframe();
        
    }
}


A simple script that will play a message when all the screen enemies are killed.

D0 - string to play.


CODE
//========================================================================
//            FFC SCRIPT AUTO-FORK
//D0 - proximity to Link at which this ffc forks *in pixels*
//D1 - speed of this ffc velocity during pursuit
// leaving these values at 0 will let the script set them automatically!
//========================================================================

ffc script ffc_auto_fork{

    void run(int speed){

        int delay = 30;
        int state = 0;

        if(speed == 0){speed = 2;}

        while(true){


            if(this->Y > 168||this->Y < 0||this->X > 248||this->X < 0){
                this->X = 0; this->Y = 0; this->Vx = 0; this->Vy = 0;
                this->Data = 1; state = 0; delay = 60;
            }
            if(state == 0){

                if(this->Vx > 0 || this->Vy > 0 || this->Vx < 0 || this->Vy < 0){

                    if(delay > 0){ delay--;}

                    if(delay == 0){state = 1;delay = 30;}
                }
            }
            if(state == 1){

                if(delay > 0){
                    delay--;
                    this->Vx = 0;
                    this->Vy = 0;
                }
                if(delay == 0){

                    int dx = Link->X - this->X;
                    int dy = Link->Y - this->Y;
                    float norm = Sqrt(dx*dx+dy*dy);
                    if(norm > 0)
                    {
                        this->Vx = dx/norm*speed;
                        this->Vy = dy/norm*speed;
                    }
                    state = 2;
                }
            }
        Waitframe();
        }
    }
}



Will automaticall re-route the ffc toward Link after 30 ticks if it's velocity is non-zero.

FFC Statue, similar to sentry, exept much more customizable as it links better to other ffc's.


CODE
//==================================================================================
//                FFC SCRIPT STATUE
//
// D0 - Direction can shoot / values greater than 3 return up,down,left,right.
//      Appears to be non-functional untill Link walks in its line-of-sight, oops!
//      link this to other ffc's for custom enemies or bosses.
// D1 - combo of weapon projectile
// D2 - speed of projectile
// D3 - CSet of projectile
// D4 - First ffc of 3 ffc's to use as projectiles
//==================================================================================

ffc script Statue{

    void run(int shoot_dir, int weapon_combo, int speed, int cset, int ffc_to_use){

        ffc shoot;
        int ffc_cycle = ffc_to_use;
        int delay = 0;

        while(true){

            if(ffc_cycle >= ffc_to_use+3){ ffc_cycle = ffc_to_use;}
            if(delay > 0){delay--;}
            
        
            if(shoot_dir > 3 && delay == 0){

                if(Abs(Link->X-this->X)<14 && Link->Y < this->Y) // Up
                {
                    shoot = Screen->LoadFFC(ffc_cycle);
                    shoot->Data = weapon_combo;
                    shoot->Y = this->Y - 16; shoot->X = this->X;
                    shoot->Vy = -speed; shoot->Vx=0;
                    shoot->CSet = cset;
                    ffc_cycle++;
                    delay = 30;
                }
                else if(Abs(Link->X-this->X)<14 && Link->Y > this->Y) // Down
                {
                    shoot = Screen->LoadFFC(ffc_cycle);
                    shoot->Data = weapon_combo;
                    shoot->Y = this->Y + 16; shoot->X = this->X;
                    shoot->Vy = speed; shoot->Vx=0;
                    shoot->CSet = cset;
                    ffc_cycle++;
                    delay = 30;        
                }
                else if(Abs(Link->Y-this->Y)<14 && Link->X < this->X) // Left
                {
                    shoot = Screen->LoadFFC(ffc_cycle);
                    shoot->Data = weapon_combo;
                    shoot->Y = this->Y; shoot->X = this->X - 16;
                    shoot->Vx = -speed; shoot->Vy=0;
                    shoot->CSet = cset;
                    ffc_cycle++;
                    delay = 30;            
                }
                else if(Abs(Link->Y-this->Y)<14 && Link->X > this->X) // Right
                {
                    shoot = Screen->LoadFFC(ffc_cycle);
                    shoot->Data = weapon_combo;
                    shoot->Y = this->Y; shoot->X = this->X + 16;
                    shoot->Vx = speed; shoot->Vy=0;
                    shoot->CSet = cset;
                    ffc_cycle++;
                    delay = 30;
                }
            }
            else{
                if(shoot_dir==0 && delay == 0){
                    if(Abs(Link->X-this->X)<14 && Link->Y < this->Y){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y - 16; shoot->X = this->X;
                        shoot->Vy = -speed; shoot->Vx=0;
                        shoot->CSet = cset;
                        ffc_cycle++;
                        delay = 30;
                    }
                }
                else if(shoot_dir==1 && delay == 0){
                    if(Abs(Link->X-this->X)<14 && Link->Y > this->Y){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y + 16; shoot->X = this->X;
                        shoot->Vy = speed; shoot->Vx=0;
                        shoot->CSet = cset;
                        ffc_cycle++;
                        delay = 30;
                    }        
                }
                else if(shoot_dir==2 && delay == 0){
                    if(Abs(Link->Y-this->Y)<14 && Link->X < this->X){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y; shoot->X = this->X - 16;
                        shoot->Vx = -speed; shoot->Vy=0;
                        shoot->CSet = cset;
                        ffc_cycle++;
                        delay = 30;
                    }
                }
                else if(shoot_dir==3 && delay == 0){
                    if(Abs(Link->Y-this->Y)<14 && Link->X > this->X){
                        shoot = Screen->LoadFFC(ffc_cycle);
                        shoot->Data = weapon_combo;
                        shoot->Y = this->Y; shoot->X = this->X + 16;
                        shoot->Vx = speed; shoot->Vy=0;
                        shoot->CSet = cset;
                        ffc_cycle++;
                        delay = 30;
                    }
                }
            }
        Waitframe();
        }
    }
}


plays a string-
D0 - string number

CODE
ffc script string_enemy{

    void run(int m){

        Waitframes(5);
        Screen->Message(m);
        Waitframe();
    }
}



-also plays a message string, but only if the enemy hasn't been killed yet.
Do-string number

CODE
ffc script string_boss{

    void run(int m){

        Waitframes(6);

        if(Screen->NumNPCs() > 0){

            Screen->Message(m);
            Waitframe();
        }
    }
}


This one's tricky, it does nothing untill it's Vx, or Vy are a non-zero amount.
vars:
D0-X radius
D1-Yradius
D2-speed of rotation
*NOTE* Leave them at 0 and let it work by itself! icon_wink.gif

CODE
ffc script ffc_wobble{

    void run(int radiusX, int radiusY, int speed){

        if(radiusX == 0){radiusX = 16;}
        if(radiusY == 0){radiusY = 16;}

        if(speed == 0){speed = 10;}

        int wobble = 0;
        bool init = false;
        int tx; int ty;
        int tvx; int tvy;

        while(true){


            if(this->Y > 168||this->Y < 0||this->X > 248||this->X < 0){
                this->X = 0; this->Y = 0; this->Vx = 0; this->Vy = 0;
                this->Data = 1; init = false;
            }
            if(this->Vx != 0 || this->Vy != 0){

                if(init == false){
                    tx = this->X; ty = this->Y;
                    tvx = this->Vx; tvy = this->Vy;
                    init = true;
                }
                else{

                    this->X = tx + radiusX*Cos(speed*wobble);
                    this->Y = ty + radiusY*Sin(speed*wobble);

                wobble++; tx += tvx; ty += tvy;
                }
            }
        Waitframe();
        }
    }
}



How cruel of me.icon_sly.gif Mwahahaaha!

CODE
//==========================================================
// FFC SCRIPT *TIMETWISTER*
// This will reset all Link data to zero
//==========================================================
ffc script timetwister{

    void run(){
        int i;
        for (i = 1; i < 255; i ++) {
            if (Link->Item[i] == true){
                Link->Item[i] = false;
            }
        }
    Link->HP = 16;
    Link->MaxHP = 16;
    Link->MP = 0;
    Link->MaxMP = 0;
    Game->Counter[CR_RUPEES] = 0;
    Game->Counter[CR_BOMBS] = 0;
    Game->Counter[CR_SBOMBS] = 0;
    Game->Counter[CR_ARROWS] = 0;
    Game->Counter[CR_KEYS] = 0;
    }
}



For killing those hard to reach places. icon_eyebrow.gif

CODE

//========================================================
// FFC SCRIPT TRIGGER SECRETS (no pun intended) ;)
// D0 - Item neccesary. Check std.zh for values
//========================================================
ffc script trigger_secrets{
    
    void run(int have_item){
        while(true{

            if (Link->Item[have_item] == true && Screen->NumNPCs() >= 1){
                                      npc enemy_trig = Screen->LoadNPC(1);
                enemy_trig->HP = 0;
            }
            Waitframe();
        }
    }
}





And the plant boss...This ones tricky also, because you really need 2 or 3 other scripts attached to this one for it to work right. I'll post those once I finish debugging them.

CODE

// ============================================================================
//                           ***FFC SCRIPT PLANT BOSS***
// give the boss a body by linking ffc's to it
// D0 = the number of this ffc
// D1 = the horizontal speed of this ffc
// D2 = the vertical speed of this ffc
// D3 = the Hit points of the boss
// D4 = the speed at which the projectiles move
// D5 = the combos used as projectiles [number=spread shot, number+1= normal]
// ============================================================================

ffc script plant_boss{

    void run (int this_ffc_number, int horiz_speed, int vert_speed, int plantHP, int sparkspeed, int sparkcom){

        if(this_ffc_number == 0) {this_ffc_number = 1;}
        if(horiz_speed == 0){horiz_speed = 0.5;}
        if(vert_speed == 0){vert_speed = 0.5;}
        if(sparkspeed == 0){ sparkspeed = 0.5;}

        ffc this_ffc = Screen->LoadFFC(this_ffc_number);

        int movement_state = 0;    // 0 = left, 1 = right
        int vertical_state = 0; // 0 = up, 1 = down

        int spark_ffc = 1;
        int delay = 0;
        int critical = 0;

        ffc spark;

        Waitframes(4);
                  
        npc plantlife = Screen->LoadNPC(1);
        plantlife->HP = plantHP;
        
        while(true){

            if(spark_ffc >= 14){ spark_ffc = 1;}

            if(delay == 300){ delay = 0;}

            plantlife->X = this->X; plantlife->Y = this->Y;


        //================================
        //ENEMY MOVEMENT
        //================================    
            
            if(movement_state == 0){

                if(this_ffc->X <= 48){ movement_state = 1;}
                if((this_ffc->X < Link->X)&&(this_ffc->Y >= Link->Y-8)){ this_ffc->Vx = horiz_speed+0.3; movement_state == 1;}
                else{ this_ffc->Vx = -horiz_speed;}

            }
            if(movement_state == 1){

                if(this_ffc->X >= 194){ movement_state = 0;}
                if((this_ffc->X > Link->X)&&(this_ffc->Y >= Link->Y-8)){ this_ffc->Vx = -horiz_speed+0.3; movement_state == 0;}
                else{ this_ffc->Vx = horiz_speed;}

            }
            if(vertical_state == 0){

                if(this_ffc->Y <= 24){ vertical_state = 1;}

                else{ this->Vy = -vert_speed;}

            }
            if(vertical_state == 1){

                if(this_ffc->Y >= 80){ vertical_state = 0;}

                else{ this->Vy = vert_speed;}

            }


        //==================================
        //ENEMY FIRE
        //==================================

            if(plantlife->HP > plantHP*0.4){
            
                if((delay == 55)||(delay == 100)){
                    spark = Screen->LoadFFC(spark_ffc);
                    spark->Data = sparkcom;            
                    spark->X = this->X;
                    spark->Y = this->Y;
                    spark->Vy = -sparkspeed;
                    spark->Vx = -sparkspeed;
                    spark->Ay = sparkspeed*0.1;
                    spark_ffc++;     

                    if(spark_ffc >= 14){ spark_ffc = 1;}

                    spark = Screen->LoadFFC(spark_ffc);
                    spark->Data = sparkcom;            
                    spark->X = this->X;
                    spark->Y = this->Y;
                    spark->Vy = -sparkspeed;
                    spark->Vx = 0;
                    spark->Ay = sparkspeed*0.1;
                    spark_ffc++;     

                    if(spark_ffc >= 14){ spark_ffc = 1;}

                    spark = Screen->LoadFFC(spark_ffc);
                    spark->Data = sparkcom;            
                    spark->X = this->X;
                    spark->Y = this->Y;
                    spark->Vy = -sparkspeed;
                    spark->Vx = sparkspeed;
                    spark->Ay = sparkspeed*0.1;
                    spark_ffc++;
                }    
                if((delay == 5)||(delay == 30)||(delay == 145)||(delay == 170)||(delay == 205)){
                    spark = Screen->LoadFFC(spark_ffc);
                    spark->Data = sparkcom+1;            
                    spark->X = this->X;
                    spark->Y = this->Y;
                    spark->Vy = sparkspeed*0.1;
                    spark->Vx = 0;
                    spark->Ay = sparkspeed*0.02;
                    spark_ffc++; }
                }    


            if(plantlife->HP <= plantHP*0.4){
                
                if(critical == 0){
                    vert_speed = vert_speed+0.3;
                    horiz_speed = horiz_speed+0.4;
                    sparkspeed = sparkspeed+0.5;
                    critical = 1;
                }
                if((delay == 55)||(delay == 100)||(delay == 250)){
                    spark = Screen->LoadFFC(spark_ffc);
                    spark->Data = sparkcom;            
                    spark->X = this->X;
                    spark->Y = this->Y;
                    spark->Vy = -sparkspeed;
                    spark->Vx = -sparkspeed;
                    spark->Ay = sparkspeed*0.1;
                    spark_ffc++;     

                    if(spark_ffc >= 14){ spark_ffc = 1;}

                    spark = Screen->LoadFFC(spark_ffc);
                    spark->Data = sparkcom;            
                    spark->X = this->X;
                    spark->Y = this->Y;
                    spark->Vy = -sparkspeed;
                    spark->Vx = 0;
                    spark->Ay = sparkspeed*0.1;
                    spark_ffc++;     

                    if(spark_ffc >= 14){ spark_ffc = 1;}

                    spark = Screen->LoadFFC(spark_ffc);
                    spark->Data = sparkcom;            
                    spark->X = this->X;
                    spark->Y = this->Y;
                    spark->Vy = -sparkspeed;
                    spark->Vx = sparkspeed;
                    spark->Ay = sparkspeed*0.1;
                    spark_ffc++;
                }    
                if((delay == 5)||(delay == 30)||(delay == 85)||(delay == 140)||(delay == 170)||(delay == 200)){
                    spark = Screen->LoadFFC(spark_ffc);
                    spark->Data = sparkcom+1;            
                    spark->X = this->X;
                    spark->Y = this->Y;
                    spark->Vy = sparkspeed*0.1;
                    spark->Vx = 0;
                    spark->Ay = sparkspeed*0.02;
                    spark_ffc++; }
                }    

        
            delay++;
            Waitframe();
    

        }

    }

}



Edited by Gleeok, 05 March 2008 - 11:02 AM.


#3 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 March 2008 - 11:16 AM

IPB Image


CODE

//===========================================================================
//                   ***FFC SCRIPT CRAB BOSS***
// Link FFC's to this ffc to make it any way you like. :D
// this ffc expects to be in the upper part of the screen. It will move left and right
// and fire projectiles at downward angles.
//D0 the number of this ffc
//D1 enemy HP
//D2 enemy speed
//D3 bubble speed
//D4 the combos to be used as bubble projectiles
//D5 the cset of the bubble projectiles
//D6 0=constant movement, 1=randomly stops for a short time
//===========================================================================

ffc script Crab_boss{

    void run(int this_ffc_number, int enemyHP, int crabspeed, int bubblespeed, int bubble_combo, int cset, int constant){

        ffc this_ffc = Screen->LoadFFC(this_ffc_number);
        if(this_ffc_number == 0){ this_ffc_number = 1; }
        if(enemyHP == 0){ enemyHP = 100; }
        if(bubblespeed == 0){ bubblespeed = 1; }
        int delay = 0;
        int attack_state = 0;    // 0=moving, 1=standing still
        int movement_state = 0;  // 0=right, 1=left
        int switch_state = 0;
        int bubble_ffc = 10;
        int crab_stopped = 0;
        int RandNum;
        int screen_enemy_number = Screen->NumNPCs();

        ffc bubble;
        
        Waitframes(4);

        npc crablife = Screen->LoadNPC(1);
        crablife->HP = enemyHP;
        
        while(true){

            if((delay == 60) && (crablife->HP > enemyHP*0.8)){ delay = 0;}
            if((delay == 150)&&(crablife->HP <= enemyHP*0.8)&&(crablife->HP > enemyHP*0.35)){ delay = 0;}
            if((delay == 200) && (crablife->HP <= enemyHP*0.35)){ delay = 0;}
            delay++;

            if(bubble_ffc >= 23){ bubble_ffc = 10;}

            crablife->X = this->X; crablife->Y = this->Y;
            
            if(this_ffc->X <= 64){ movement_state = 0;}
            if(this_ffc->X >= 180){ movement_state = 1;}


        //===========================
        //ENEMY MOVEMENT
        //===========================

            if(crab_stopped > 0){ crab_stopped--;}
            if(crab_stopped == 0){ attack_state = 0;}

            if(movement_state == 0 && attack_state == 0){this_ffc->Vx = crabspeed;}
            if(movement_state == 1 && attack_state == 0){this_ffc->Vx = -crabspeed;}
            if(movement_state == 0 && attack_state == 1){this_ffc->Vx = 0;}
            if(movement_state == 1 && attack_state == 1){this_ffc->Vx = 0;}

            if((constant == 1)&&(switch_state == 0)){RandNum = Rand(180);switch_state = 1;}
            if((constant == 1)&&(switch_state == 1)){
                RandNum++;
                if(RandNum == 180){
                    attack_state = 1; switch_state = 0; crab_stopped = 30;
                }
            }
            if((this_ffc->X > Link->X)&&(this_ffc->Y >= Link->Y-8)){ this_ffc->Vx = -crabspeed-0.2; crab_stopped = 0; movement_state = 1;}
            if((this_ffc->X < Link->X)&&(this_ffc->Y >= Link->Y-8)){ this_ffc->Vx = crabspeed+0.2; crab_stopped = 0; movement_state = 0;}

                    
        //===========================
        //ENEMY FIRE
        //===========================
            
            if(crablife->HP > enemyHP*0.8){

                if((delay == 15)||(delay == 45)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble_ffc++; }
                if(delay == 30){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = bubblespeed*0.8;
                    bubble_ffc++;}
                if(delay == 60){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = -bubblespeed*0.8;
                    bubble_ffc++;}
                }    
            if((crablife->HP <= enemyHP*0.8)&&(crablife->HP > enemyHP*0.35)){

                if((delay == 10)||(delay == 50 )||(delay == 90)||(delay == 130)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = 0;
                    bubble_ffc++; }
                if((delay == 20)||(delay == 40 )||(delay == 100)||(delay == 120)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = bubblespeed*0.6;
                    bubble_ffc++; }
                if((delay == 30)||(delay == 110 )){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed*0.8;
                    bubble->Vx = bubblespeed;
                    bubble_ffc++; }
                if((delay == 60)||(delay == 80 )||(delay == 140)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = -bubblespeed*0.6;
                    bubble_ffc++; }
                if((delay == 70)||(delay == 150 )){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed*0.8;
                    bubble->Vx = -bubblespeed;
                    bubble_ffc++; }
                }
            if(crablife->HP <= enemyHP*0.35){

                if((delay == 7)||(delay == 49 )||(delay == 91)||(delay == 133)||(delay == 175)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = 0;
                    bubble_ffc++; }

                if((delay == 14)||(delay == 42 )||(delay == 98)||(delay == 126)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = bubblespeed*0.4;
                    bubble_ffc++; }
                if((delay == 21)||(delay == 35 )||(delay == 105)||(delay == 119)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = bubblespeed*0.8;
                    bubble_ffc++; }
                if((delay == 28)||(delay == 112)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed*0.9;
                    bubble->Vx = bubblespeed*1.2;
                    bubble_ffc++; }
                if((delay == 56)||(delay == 84 )||(delay == 140)||(delay == 168)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = -bubblespeed*0.4;
                    bubble_ffc++; }
                if((delay == 63)||(delay == 77 )||(delay == 147)||(delay == 161)){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed;
                    bubble->Vx = -bubblespeed*0.8;
                    bubble_ffc++; }

                if((delay == 70)||(delay == 154 )){
                    bubble = Screen->LoadFFC(bubble_ffc);
                    bubble->Data = bubble_combo;
                    bubble->CSet = cset;            
                    bubble->X = this->X;
                    bubble->Y = this->Y + 8;
                    bubble->Vy = bubblespeed*0.9;
                    bubble->Vx = -bubblespeed*1.2;
                    bubble_ffc++; }
                }

            Waitframe();
        }
    }
}



=================***READ***==================

I do some things a little different than you may be used to. First is this script does not create an enemy. It assumes you have a screen enemy set and enemies->secrets is probably enabled. It then uses this enemy for fuel, increasing it's HP and such. DO NOT USE "ENTER FROM SIDES'.

Next: Do NOT use FFC's 10-23 for anything! don't even set anything on them. The script does all the work and will use these for it's own twisted scheme.


Are you tired of spending too much time playing ZC? Those 20+ hour quests can be very time consuming. Wouldn't you like your own personal apocalypse to tell you when you've had enough, and it's time to go out and get some sunlight?...well here it is.


CODE
int doom = 10800;  // 1 = one second

int sec_combo = 9000;    // combos used for seconds. 9000 + 59, change to any combo you like
int min_combo = 9060;     // combos used for minutes. ditto
int hour_combo = 9120;   //combos used for hours. ditto
int sec_count = 0;
int min_count = 0;
int hour_count = 0;

global script Doomsday{

    void run(){

        ffc hour = Screen->LoadFFC(30);   // loads ffc's 30-32 *DO NOT USE FFC'S 30-32 FOR ANYTHING ELSE!*
        ffc minutes = Screen->LoadFFC(31);
        ffc seconds = Screen->LoadFFC(32);
        

        while(true){

            seconds->Data = sec_combo;
            minutes->Data = min_combo;
            hour->Data = hour_combo;            
            hour->X = 208;
            hour->Y = 0;
            minutes->X = 224;
            minutes->Y = 0;
            seconds->X = 240;
            seconds->Y = 0;
            if (doom >=1){
                Waitframes(60);
                doom--;
                sec_count++;
                sec_combo++;
                if (sec_count == 60){
                    sec_count = 0;
                    sec_combo = 9000;
                    min_combo++;
                    min_count++;
                }
                if (min_count == 60){
                    min_count = 0;
                    min_combo = 9060;
                    hour_count++;
                    hour_combo++;
                }

            } else {
                Link->PitWarp(255,00);  // do as you will with these:
                Game->PlaySound(27); // ..when time is up!
                Waitframes(1800);
                Quit();
            }
        }
    }
}



How it works:

It creates an ffc timer in the upper-right corner of th screen. No, don't worry. No ffc setup is required...in fact, no setup of any kind is needed once you load it into the 2cd global script slot. icon_smile.gif

The "timer" is currently set to use combos 9000 to 9122, and any extra hours you may want to add. For example: Setting combo 9000 to a tile with the graphic "59", and combo 9060 also to "59", and 9120 to "2", will result in the display in the corner of the screen to read: 2:59:59.

Every second of gameplay "int doom" becomes minus one, resulting in(you guessed it) a countdown. 2:59:58.........2:59:57....etc. It is currently set at 10800,(that's 10800 seconds) feel free to change it to whatever you want. -Note that the combos currently use cset 0





OK, here's the ffc version. Use "carry over ffc" with this, and just set the screen flag "No carry-over ffc's" if Link gets there on time.

CODE
//=========================================================
//D0 - amount of time, in seconds, before time expires
//D1 - hours combo
//D2 - minutes combo. (+59 * IT WILL +1 FOR EVERY MINUTE)
//D2 - seconds combos. -again, +59!
//D3 - destination Dmap for warp if time is up!
//=========================================================

ffc script Timebomb{

    void run(int time_clock, int hour_combo, int min_combo, int sec_combo, int dest){

        int doom = time_clock;

        int sec_count = 0;
        int min_count = 0;
        int hour_count = 0;
        ffc hour = Screen->LoadFFC(30);
        ffc minutes = Screen->LoadFFC(31);
        ffc seconds = Screen->LoadFFC(32);

        minutes->Data = min_combo;
        hour->Data = hour_combo;

        while(true){
            if (doom >=1){
                Waitframes(60);
                doom--;
                sec_count++;
                sec_combo++;
                seconds->Data = sec_combo;
                if (sec_count == 60){
                    sec_count = 0;
                    sec_combo = 9000;
                    min_combo++;
                    min_count++;
                    minutes->Data = min_combo;
                }
                if (min_count == 60){
                    min_count = 0;
                    min_combo = 9080;
                    hour_count++;
                    hour_combo++;
                    hour->Data = hour_combo;
                }

            } else {
                Link->Pitwarp(dest,00); // change destination here
                Game->PlaySound(n); // insert sfx here
                Waitframes(600);
                Link->HP = 0;  // kills link :0
                Quit();
            }
        }
    }
}


*IMPORTANT*
There are now variables, meaning you can use this script for different things, and each is unique.

D0 - time in seconds
D1 - combos used for hours
D2 - minutes
D3 - seconds.....

Whatever combos you wish to use be aware that it will use that combo plus 1 for every change in hour, minute, second respectively.

D4 - Dmap to warp to. self explanitory.



more to come..

#4 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 March 2008 - 11:37 AM

More custom enemy and boss scripts:

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
}





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

Edited by Gleeok, 05 March 2008 - 12:50 PM.


#5 LostInHyru1e

LostInHyru1e

    Can you take me as far as PureZC?

  • Members
  • Real Name:Lost
  • Location:Refer to Screename

Posted 05 March 2008 - 11:39 AM

Those are some amazing scripts, dude. icon_drool.gif

EDIT: D'oh! Didn't see the "Hold on to replies, just for a second" edit until just now. Sorry, dude, staff can delete this. ~_~

Edited by LostInHyru1e, 05 March 2008 - 11:40 AM.


#6 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 March 2008 - 12:04 PM

it's cool.



CODE

//D0 Cset of first portal
//D1 Cset of second portal
//D2 speed of portal gun

item script PORTAL_item_ver2{

    void run(int cset, int cset2, int speed){

        ffc portal1 = Screen->LoadFFC(29); //set hard coded ffc data here
        ffc portal2 = Screen->LoadFFC(28);  // and here




            if(!((portal1->Data >= portal_data) && (portal1->Data <= portal_data+7))){  

                Game->PlaySound(11);

                if(Link->Dir == 0) {
                    portal1->X = Link->X;
                    portal1->Y = Link->Y - 16;
                    portal1->Vy = -speed;
                    portal1->Vx = 0;
                    portal1->Data = portal_data;
                    portal1->CSet = cset;
                }
                if(Link->Dir == 1) {
                    portal1->X = Link->X;
                    portal1->Y = Link->Y + 16;
                    portal1->Vy = speed;
                    portal1->Vx = 0;
                    portal1->Data = portal_data+1;
                    portal1->CSet = cset;
                }
                if(Link->Dir == 2) {
                    portal1->X = Link->X - 16;
                    portal1->Y = Link->Y;
                    portal1->Vx = -speed;
                    portal1->Vy = 0;
                    portal1->Data = portal_data+2;
                    portal1->CSet = cset;
                }
                if(Link->Dir == 3) {
                    portal1->X = Link->X + 16;
                    portal1->Y = Link->Y;
                    portal1->Vx = speed;
                    portal1->Vy = 0;
                    portal1->Data = portal_data+3;
                    portal1->CSet = cset;
                }
            }
            else{
                if(!((portal2->Data >= portal_data) && (portal2->Data <= portal_data+7))){

                    Game->PlaySound(11);
            
                    if(Link->Dir == 0) {
                        portal2->X = Link->X;
                        portal2->Y = Link->Y - 16;
                        portal2->Vy = -speed;
                        portal2->Vx = 0;
                        portal2->Data = portal_data;
                        portal2->CSet = cset2;
                    }
                    if(Link->Dir == 1) {
                        portal2->X = Link->X;
                        portal2->Y = Link->Y + 16;
                        portal2->Vy = speed;
                        portal2->Vx = 0;
                        portal2->Data = portal_data+1;
                        portal2->CSet = cset2;
                    }
                    if(Link->Dir == 2) {
                        portal2->X = Link->X - 16;
                        portal2->Y = Link->Y;
                        portal2->Vx = -speed;
                        portal2->Vy = 0;
                        portal2->Data = portal_data+2;
                        portal2->CSet = cset2;
                    }
                    if(Link->Dir == 3) {
                        portal2->X = Link->X + 16;
                        portal2->Y = Link->Y;
                        portal2->Vx = speed;
                        portal2->Vy = 0;
                        portal2->Data = portal_data+3;
                        portal2->CSet = cset2;
                    }
                }
                else{    // if both portals are already set fire portal 1 again

                    if((portal1->Data > portal_data+3) && (portal1->Data <= portal_data+7)&&
                    (portal2->Data > portal_data+3) && (portal2->Data <= portal_data+7)){  

                Game->PlaySound(11);

                if(Link->Dir == 0) {
                    portal1->X = Link->X;
                    portal1->Y = Link->Y - 16;
                    portal1->Vy = -speed;
                    portal1->Vx = 0;
                    portal1->Data = portal_data;
                    portal1->CSet = cset;
                }
                if(Link->Dir == 1) {
                    portal1->X = Link->X;
                    portal1->Y = Link->Y + 16;
                    portal1->Vy = speed;
                    portal1->Vx = 0;
                    portal1->Data = portal_data+1;
                    portal1->CSet = cset;
                }
                if(Link->Dir == 2) {
                    portal1->X = Link->X - 16;
                    portal1->Y = Link->Y;
                    portal1->Vx = -speed;
                    portal1->Vy = 0;
                    portal1->Data = portal_data+2;
                    portal1->CSet = cset;
                }
                if(Link->Dir == 3) {
                    portal1->X = Link->X + 16;
                    portal1->Y = Link->Y;
                    portal1->Vx = speed;
                    portal1->Vy = 0;
                    portal1->Data = portal_data+3;
                    portal1->CSet = cset;
                }
            }
            else{  // if not then fire portal 2 once more

                if((portal2->Data >= portal_data+4) && (portal2->Data <= portal_data+7)){

                    Game->PlaySound(11);
            
                    if(Link->Dir == 0) {
                        portal2->X = Link->X;
                        portal2->Y = Link->Y - 16;
                        portal2->Vy = -speed;
                        portal2->Vx = 0;
                        portal2->Data = portal_data;
                        portal2->CSet = cset2;
                    }
                    if(Link->Dir == 1) {
                        portal2->X = Link->X;
                        portal2->Y = Link->Y + 16;
                        portal2->Vy = speed;
                        portal2->Vx = 0;
                        portal2->Data = portal_data+1;
                        portal2->CSet = cset2;
                    }
                    if(Link->Dir == 2) {
                        portal2->X = Link->X - 16;
                        portal2->Y = Link->Y;
                        portal2->Vx = -speed;
                        portal2->Vy = 0;
                        portal2->Data = portal_data+2;
                        portal2->CSet = cset2;
                    }
                    if(Link->Dir == 3) {
                        portal2->X = Link->X + 16;
                        portal2->Y = Link->Y;
                        portal2->Vx = speed;
                        portal2->Vy = 0;
                        portal2->Data = portal_data+3;
                        portal2->CSet = cset2;
                    }    
                }
            }    
        }} // end of else statements
    }
}

item script PORTAL_item_ver3{

    void run(int cset, int cset2, int speed){

        ffc portal1 = Screen->LoadFFC(29); //set hard coded ffc data here
        ffc portal2 = Screen->LoadFFC(28);  // and here




            if(!((portal1->Data >= portal_data) && (portal1->Data <= portal_data+7))){  

                Game->PlaySound(11);

                if(Link->Dir == 0) {
                    portal1->X = Link->X;
                    portal1->Y = Link->Y - 16;
                    portal1->Vy = -speed;
                    portal1->Vx = 0;
                    portal1->Data = portal_data;
                    portal1->CSet = cset;
                }
                if(Link->Dir == 1) {
                    portal1->X = Link->X;
                    portal1->Y = Link->Y + 16;
                    portal1->Vy = speed;
                    portal1->Vx = 0;
                    portal1->Data = portal_data+1;
                    portal1->CSet = cset;
                }
                if(Link->Dir == 2) {
                    portal1->X = Link->X - 16;
                    portal1->Y = Link->Y;
                    portal1->Vx = -speed;
                    portal1->Vy = 0;
                    portal1->Data = portal_data+2;
                    portal1->CSet = cset;
                }
                if(Link->Dir == 3) {
                    portal1->X = Link->X + 16;
                    portal1->Y = Link->Y;
                    portal1->Vx = speed;
                    portal1->Vy = 0;
                    portal1->Data = portal_data+3;
                    portal1->CSet = cset;
                }
            }
            else{
                if(!((portal2->Data >= portal_data) && (portal2->Data <= portal_data+7))){

                    Game->PlaySound(11);
            
                    if(Link->Dir == 0) {
                        portal2->X = Link->X;
                        portal2->Y = Link->Y - 16;
                        portal2->Vy = -speed;
                        portal2->Vx = 0;
                        portal2->Data = portal_data;
                        portal2->CSet = cset2;
                    }
                    if(Link->Dir == 1) {
                        portal2->X = Link->X;
                        portal2->Y = Link->Y + 16;
                        portal2->Vy = speed;
                        portal2->Vx = 0;
                        portal2->Data = portal_data+1;
                        portal2->CSet = cset2;
                    }
                    if(Link->Dir == 2) {
                        portal2->X = Link->X - 16;
                        portal2->Y = Link->Y;
                        portal2->Vx = -speed;
                        portal2->Vy = 0;
                        portal2->Data = portal_data+2;
                        portal2->CSet = cset2;
                    }
                    if(Link->Dir == 3) {
                        portal2->X = Link->X + 16;
                        portal2->Y = Link->Y;
                        portal2->Vx = speed;
                        portal2->Vy = 0;
                        portal2->Data = portal_data+3;
                        portal2->CSet = cset2;
                    }
                }
                else{
                
                    portal2->Data = 1;
                    portal2->X = 0;
                    portal2->Y = 0;
                    portal1->Data = 1;
                    portal1->X = 0;
                    portal1->Y = 0;
        
            }    
        }
    }
}


//===================GLOBAL VARIABLES=====================
    int portal_warp_delay = 0;
    int enemy_portal_warp_delay = 0;

    int portal_data = 160;    // change this to be the first of 8 block combos for graphics

//make a block of 8 combos, the first 4 being gun projectile up, down, left, right in that order
//then make the next 4 the same used for open portal animation(no combo cycling)
//========================================================

//D0 - this ffc number
//D1 - other ffc number
// Ex: Set ffc 28 D0 to 28 and D1 to 29 then set ffc 29 D0 to 29 and D1 to 28. easy, huh?

ffc script PORTAL_FFC_ver4{ //   BUGFIXED VERSION

    void run(int this_ffc_number, int other_ffc_number){

        ffc this_ffc = Screen->LoadFFC(this_ffc_number);
        ffc other_ffc = Screen->LoadFFC(other_ffc_number);

        int portal_set = 0;

        int portal_position = 0;

        bool portal_open = false;

        int enemy_number = 0;
        npc enemy;

        this_ffc->Data = 1;this->Y = 0; this->X = 0;

        while(true){

            if(this_ffc->X < 14 || this_ffc->X > 226 || this_ffc->Y < 14 || this_ffc->Y > 146 ||
                Link->X < 0 || Link->X > 240 || Link->Y < 0 || Link->Y > 160){
                this_ffc->Data = 1; this->Y = 0; this->X = 0; portal_open = false;}
            if(this_ffc->Data <= portal_data+3){ portal_open = false;}

            if(portal_warp_delay > 0){ portal_warp_delay--;}
            if(enemy_portal_warp_delay > 0){ enemy_portal_warp_delay--;}

            if( (this->Data >= portal_data) && (this->Data <=portal_data+3) ){

                if( (this_ffc->Vx < 0) && (Screen->ComboS[ComboAt(this_ffc->X-1, this_ffc->Y+8)] != 0)
                    && (Screen->ComboT[ComboAt(this_ffc->X-1, this_ffc->Y+8)] != 3)){ portal_open = true;}
                
                if( (this_ffc->Vx > 0) && (Screen->ComboS[ComboAt(this_ffc->X+16, this_ffc->Y+8)] != 0)
                    && (Screen->ComboT[ComboAt(this_ffc->X+16, this_ffc->Y+8)] != 3)){ portal_open = true;}

                if( (this_ffc->Vy < 0) && (Screen->ComboS[ComboAt(this_ffc->X+8, this_ffc->Y-1)] != 0)
                    && (Screen->ComboT[ComboAt(this_ffc->X+8, this_ffc->Y-1)] != 3)){ portal_open = true;}

                if( (this_ffc->Vy > 0) && (Screen->ComboS[ComboAt(this_ffc->X+8, this_ffc->Y+16)] != 0)
                    && (Screen->ComboT[ComboAt(this_ffc->X+8, this_ffc->Y+16)] != 3)){ portal_open = true;}
                
            }
            if(portal_open){
    
                if(Screen->ComboS[ComboAt(this_ffc->X+8, this_ffc->Y+8)] == 15){ portal_open = false;}
                else{ this_ffc->Data = portal_data+4; this_ffc->Vx = 0; this_ffc->Vy = 0;}
            }
            if(portal_set == 0){

                if(other_ffc->Data >= portal_data + 4){

                    if(portal_warp_delay == 0){

                        if ( (Link->X <= this_ffc->X + 8)&&(Link->X >= this_ffc->X -8)&&
                            (Link->Y <= this_ffc->Y + 8)&&(Link->Y >= this_ffc->Y -8) ){

                            portal_warp_delay = 60;
                            Link->X = other_ffc->X;
                            Link->Y = other_ffc->Y;
                            Game->PlaySound(36);
                        }
                    }
                    if(enemy_portal_warp_delay == 0){

                        enemy_number = Screen->NumNPCs();

                        while(enemy_number > 0){
            
                            enemy = Screen->LoadNPC(enemy_number);
                            if ( (this_ffc->X - 10 < enemy->X) && (this_ffc->X + 10 > enemy->X) &&
                                (this_ffc->Y - 10 < enemy->Y) && (this_ffc->Y + 10 > enemy->Y) &&
                                !(enemy->Tile==0) ){
                            
                                enemy->X = other_ffc->X; enemy->Y = other_ffc->Y;
                                Game->PlaySound(35);enemy_portal_warp_delay = 80;
                            }    
                            enemy_number--;
                        }
                    }
                }
            }
        Waitframe();
        }
    }
}

It's currently set up to use ffc's 28 and 29. These are changable only once, before you compile it. Everything else is noted, just read.


Oh, one more thing. This will warp enemies too, as well as being able to cross over water combos. Want to make some nasty puzzles? I suggest using water...alot.icon_wink.gif Any non-walkable combo you don't want to open a portal near in fact.

Also Portals will NOT open on solid objects on layers...use to advantage.




CODE
ffc script leever_spawner{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++)
                    putenemy(26+Rand(2));
                        
                init = true;
            }
            en_count = Screen->NumNPCs();
            while(en_count > 0){
                npc leever = Screen->LoadNPC(en_count);
                if(leever->X > 272 || leever->Y > 192 ||
                    leever->X < -33 || leever->Y < -33){
                        leever->HP=0;
                        npc e = Screen->CreateNPC(26+Rand(2));
                        e->X = Rand(190)+30;
                        e->Y = Rand(100)+30;
                }
                en_count--;
            }
        Waitframe();    
        }        
    }
    void putenemy(int eid)
    {
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
        //simulate staggered spawning
        Waitframe();
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}



CODE
ffc script lanmola_spawner{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++)
                    putenemy(74+Rand(2));
                        
                init = true;
            }
        Waitframe();    
        }        
    }
    void putenemy(int eid)
    {
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
        //simulate staggered spawning
        Waitframe();
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}


CODE

ffc script lynel_spawner{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++)
                    putenemy(30+Rand(2));
                        
                init = true;
            }
        Waitframe();    
        }        
    }
    void putenemy(int eid)
    {
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
        //simulate staggered spawning
        Waitframe();
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}



CODE
ffc script goriya_spawner{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++)
                    putenemy(45+Rand(2));
                        
                init = true;
            }
        Waitframe();    
        }        
    }
    void putenemy(int eid)
    {
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
        //simulate staggered spawning
        Waitframe();
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}



CODE
ffc script darknut_spawner{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++)
                    putenemy(49+Rand(2));
                        
                init = true;
            }
        Waitframe();    
        }        
    }
    void putenemy(int eid)
    {
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
     &nb

#7 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 March 2008 - 12:16 PM

CODE

ffc script E_darknut_spawner{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++)
                    putenemy(49+Rand(2));
                        
                init = true;
            }
        Waitframe();    
        }        
    }
    void putenemy(int eid)
    {
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
        //simulate staggered spawning
        Waitframe();
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}



ffc script E_keese_spawner{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;
        int delay = 300;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++)
                    putenemy(38+Rand(3));
                        
                init = true;
            }
            if(Screen->NumNPCs()==0){

                if(delay > 0)delay--;
                else{
                    npc e = Screen->CreateNPC(38+Rand(3));
                    delay = 200+Rand(200);
                }
            }        
        Waitframe();    
        }        
    }
    void putenemy(int eid)
    {
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
        //simulate staggered spawning
        Waitframe();
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}

ffc script E_octo_spawner_1{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++)
                    putenemy(20+Rand(4));
                        
                init = true;
            }
        Waitframe();    
        }        
    }
    void putenemy(int eid)
    {
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
        //simulate staggered spawning
        Waitframe();
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}


ffc script E_octo_spawner_2{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++)
                    putenemy(138+Rand(4));
                        
                init = true;
            }
        Waitframe();    
        }        
    }
    void putenemy(int eid)
    {
        
        int x = Rand(12)+2;
        int y = Rand(7)+2;
        while(!is_walkable(x,y))
        {
            x = Rand(12)+2;
            y = Rand(7)+2;
        }
        npc en = Screen->CreateNPC(eid);
        if(en->isValid())
        {
            en->X = x*16;
            en->Y = y*16;
        }
        //simulate staggered spawning
        Waitframe();
    }
    bool is_walkable(int x, int y)
    {
        return Screen->ComboS[x+y*16]==0;
    }
}



//=-=-=-=-=-=-=-=-WIZZROBE SPAWNER SCRIPTS-=-=-=-=-=-=-=-=-=
// D0 - amount of wizzrobes to spawn
// other D[] vars: offset(in ticks) and/or enemy HP.
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


const int PHASE_WIZZROBE_2 = 188;
const int PHASE_WIZZROBE_3 = 189;

ffc script E_wizzrobe_spawner_phaser{

        void run(int enemy_max){

        bool init = false;
        int en_count = 0;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++){

                    npc e;
                    if(Rand(3)==0)e = Screen->CreateNPC(56);
                    else if(Rand(3) != 0) e = Screen->CreateNPC(PHASE_WIZZROBE_2);
                    else e = Screen->CreateNPC(PHASE_WIZZROBE_3);
                    int rand = Rand(9)+15;
                    Waitframes(rand);
                }
                init = true;
            }
        Waitframe();    
        }        
    }
}


ffc script E_wiz1_spawner_phaser{

        void run(int enemy_max, int offset){

        bool init = false;
        int en_count = 0;
        if(offset == 0) offset = Rand(9)+15;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++){

                    npc e = Screen->CreateNPC(56);
                    Waitframes(offset);
                }
                init = true;
            }
        Waitframe();    
        }        
    }
}


ffc script E_wiz2_spawner_phaser{

        void run(int enemy_max, int offset){

        bool init = false;
        int en_count = 0;
        if(offset == 0) offset = Rand(9)+15;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++){

                    npc e = Screen->CreateNPC(PHASE_WIZZROBE_2);
                    Waitframes(offset);
                }
                init = true;
            }
        Waitframe();    
        }        
    }
}

ffc script E_wiz3_spawner_phaser{

        void run(int enemy_max, int offset){

        bool init = false;
        int en_count = 0;
        if(offset == 0) offset = Rand(9)+15;

                while(true){

            if(init == false){

                for(int i; i < enemy_max; i++){

                    npc e = Screen->CreateNPC(PHASE_WIZZROBE_3);
                    Waitframes(offset);
                }
                init = true;
            }
        Waitframe();    
        }        
    }
}

ffc script E_aquamentus_spawner{

        void run(){

        npc e;
        Waitframes(5);
              
        e = Screen->CreateNPC(93);e->X=192;e->Y=48;
        Waitframes(5);
        e = Screen->CreateNPC(93);e->X=192;e->Y=80;
        Waitframes(5);
        e = Screen->CreateNPC(93);e->X=192;e->Y=16;
        Waitframes(5);
        e = Screen->CreateNPC(93);e->X=192;e->Y=112;
        Waitframes(5);
        e = Screen->CreateNPC(58);e->X=48;e->Y=48;
        Waitframes(5);
        e = Screen->CreateNPC(58);e->X=48;e->Y=80;
        Waitframes(5);
        e = Screen->CreateNPC(58);e->X=48;e->Y=16;
        Waitframes(5);
        e = Screen->CreateNPC(58);e->X=48;e->Y=112;
        Waitframes(5);
                
    }
}

ffc script splitter_spawner{

        void run(int eid, int e_max, int s1, int s2, int s3, int s4){

        bool init = false;
        npc e;

                while(true){

            if(init == false){

                        e = Screen->CreateNPC(eid);
                init = true;
            }
            else if(!(e->isValid())){

                if(s1>0){
                    for(int i; i < e_max; i++){
                        npc s = Screen->CreateNPC(s1);
                        s->X = this->X;s->Y = this->Y;
                    }
                }
                if(s2>0){
                    for(int i; i < e_max; i++){
                        npc s = Screen->CreateNPC(s2);
                        s->X = this->X;s->Y = this->Y;
                    }
                }
                if(s3>0){
                    for(int i; i < e_max; i++){
                        npc s = Screen->CreateNPC(s3);
                        s->X = this->X;s->Y = this->Y;
                    }
                }
                if(s4>0){
                    for(int i; i < e_max; i++){
                        npc s = Screen->CreateNPC(s4);
                        s->X = this->X;s->Y = this->Y;
                    }
                }
                Waitframe();
                this->Data = 0;
                Quit();
            }
            else{
                this->X = e->X;
                this->Y = e->Y;
            }
        Waitframe();    
        }        
    }
}

Edited by Gleeok, 05 March 2008 - 12:39 PM.


#8 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 March 2008 - 12:50 PM

...


CODE

//========================================================================
//            FFC SCRIPT BOUNCE
//
// this script will activate after it's Data is becomes greater than 6
// this script will "bounce" this ffc off walls...like pong!
//========================================================================


ffc script ffc_bounce{

    void run(){

        while(true){

            if(this->Data > 6){

                if(this->Vx > 0 || this->Vy > 0 || this->Vx < 0 || this->Vy < 0){

                    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;    }
                            }
                        }
                    }
                }
                else{
                    this->Vx = 2/Rand(3);
                    this->Vy = 2/Rand(3);
                }
            if(this->X > 224) { this->Vx = -1; this->X--;}
            if(this->X < 16) { this->Vx = 1; this->X++;}
            if(this->Y > 144) { this->Vy = -1; this->Y--;}
            if(this->Y < 16) { this->Vy = 1; this->Y++;}
            }
        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);
     }// end of canMove
}

ffc script rotater_orb1{

    void run(){

    bool init;
    int cx = 108;
    int cy = 64;
    int speed = 0.5;
    int wobble; int state = 1;
    ffc F = Screen->LoadFFC(7);
    Waitframes(4);

    npc boss = Screen->LoadNPC(1);
    int maxHP = boss->HP;

    npc S = Screen->CreateNPC(83);
    npc T = Screen->CreateNPC(255);
    T->HP = 400;

        while(true){

            Waitframe();
            int tx = this->X; int ty = this->Y;
            int lx = Link->X; int ly = Link->Y;
    
            if(S->isValid()){S->X=tx;S->Y=ty;}
            if(T->isValid()){T->X=tx;T->Y=ty;}
            if(!T->isValid()){S->HP=0;this->Data=0;}
            if(state == 1){
                
                this->X = 120 - (cx * Sin(wobble*speed));
                this->Y = 80  - (cy * Cos(wobble*speed));
                wobble++;
            }
            if(boss->HP<maxHP*0.7 && speed<1)speed += 0.01;
            else if(boss->HP<maxHP*0.5 && speed<1.5)speed += 0.01;
            else if(boss->HP<maxHP*0.25 && speed<2)speed += 0.01;
        }
    }
}

ffc script rotater_orb2{

    void run(){

    bool init;
    int cx = 108;
    int cy = 64;
    int speed = 0.5;
    int wobble; int state = 1;
    ffc F = Screen->LoadFFC(7);
    Waitframes(4);

    npc boss = Screen->LoadNPC(1);
    int maxHP = boss->HP;

    npc S = Screen->CreateNPC(83);
    npc T = Screen->CreateNPC(255);
    T->HP = 400;

        while(true){

            Waitframe();
            int tx = this->X; int ty = this->Y;
            int lx = Link->X; int ly = Link->Y;
    
            if(S->isValid()){S->X=tx;S->Y=ty;}
            if(T->isValid()){T->X=tx;T->Y=ty;}
            if(!T->isValid()){S->HP=0;this->Data=0;}
            if(state == 1){
                
                this->X = 120 + (cx * Sin(wobble*speed));
                this->Y = 80  + (cy * Cos(wobble*speed));
                wobble++;
            }
            if(boss->HP<maxHP*0.7 && speed<1)speed += 0.01;
            else if(boss->HP<maxHP*0.5 && speed<1.5)speed += 0.01;
            else if(boss->HP<maxHP*0.25 && speed<2)speed += 0.01;
        }
    }
}




ffc script poison_gas_room{

    void run(){

        int delay=0;

        while(true){

            Waitframe();delay++;

            if(delay>60){
                delay=0;
                Link->HP -= 4;
            }
        }
    }
}

ffc script heal_full{

    void run(){

        int delay=0;

        while(true){

            Waitframe();

            if(Link->HP < Link->MaxHP){ Link->HP++;Game->PlaySound(23);}
            if(Link->MP < Link->MaxMP){ Link->MP++;Game->PlaySound(23);}            
        }
    }
}



....

#9 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 March 2008 - 01:25 PM

More,more!!!

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();
        }
    }
}



More!!!!!

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();
        }
    }
}

Edited by Gleeok, 05 March 2008 - 01:41 PM.


#10 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 05 March 2008 - 01:50 PM


Mwahahahahahaha!!!!

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();
        }
    }
}




...more later, i'm tired now.

....

....

Edited by Gleeok, 05 March 2008 - 01:42 PM.


#11 jman2050

jman2050

    Illustrious

  • Members

Posted 05 March 2008 - 05:58 PM

My god

Awesome stuff here.

#12 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 06 March 2008 - 12:13 AM

Thanks. You keep on doin what your doin, and I'll help spread the word of the holy scriptures. icon_wink.gif



--------------------------------------------------------------------------------------------------------------------------------
// FFC WEAPON AND MAGICS BELOW. so it is written, so it shall be done.
--------------------------------------------------------------------------------------------------------------------------------


CODE
item script Vaskyre{

    void run(int cset){

        int vaskyre = 52;        

        ffc ray = Screen->LoadFFC(4);

        ffc ray2 = Screen->LoadFFC(5);

        ffc ray3 = Screen->LoadFFC(6);

        if(Link->MP >= 16){

        if(!(ray->Data == vaskyre)){

            Link->MP -= 16;
            Game->PlaySound(37);

            ray->CSet = cset;
            ray->TileWidth = 1;
            ray->TileHeight = 1;

            if(Link->Dir == 0) {
                ray->X = Link->X;
                ray->Y = Link->Y - 16;
                ray->Vy = -2;
                ray->Vx = 0;
                ray->Data = vaskyre;
            }
            if(Link->Dir == 1) {
                ray->X = Link->X;
                ray->Y = Link->Y + 16;
                ray->Vy = 2;
                ray->Vx = 0;
                ray->Data = vaskyre;
            }
            if(Link->Dir == 2) {
                ray->X = Link->X - 16;
                ray->Y = Link->Y;
                ray->Vx = -2;
                ray->Vy = 0;
                ray->Data = vaskyre;
            }
            if(Link->Dir == 3) {
                ray->X = Link->X + 16;
                ray->Y = Link->Y;
                ray->Vx = 2;
                ray->Vy = 0;
                ray->Data = vaskyre;
            }
        }
        else{
            if(ray2->Data != vaskyre){

                Link->MP -= 16;
                Game->PlaySound(37);

                ray2->CSet = cset;
                ray2->TileWidth = 1;
                ray2->TileHeight = 1;

                if(Link->Dir == 0) {
                    ray2->X = Link->X;
                    ray2->Y = Link->Y - 16;
                    ray2->Vy = -2;
                    ray2->Vx = 0;
                    ray2->Data = vaskyre;
                }
                if(Link->Dir == 1) {
                    ray2->X = Link->X;
                    ray2->Y = Link->Y + 16;
                    ray2->Vy = 2;
                    ray2->Vx = 0;
                    ray2->Data = vaskyre;
    
                }
                if(Link->Dir == 2) {
                    ray2->X = Link->X - 16;
                    ray2->Y = Link->Y;
                    ray2->Vx = -2;
                    ray2->Vy = 0;
                    ray2->Data = vaskyre;
                }
                if(Link->Dir == 3) {
                    ray2->X = Link->X + 16;
                    ray2->Y = Link->Y;
                    ray2->Vx = 2;
                    ray2->Vy = 0;
                    ray2->Data = vaskyre;
                }
            }
            else{
                if(ray3->Data != vaskyre){

                    Link->MP -= 16;
                    Game->PlaySound(37);

                    ray3->CSet = cset;
                    ray3->TileWidth = 1;
                    ray3->TileHeight = 1;

                    if(Link->Dir == 0) {
                        ray3->X = Link->X;
                        ray3->Y = Link->Y - 16;
                        ray3->Vy = -2;
                        ray3->Vx = 0;
                        ray3->Data = vaskyre;
                    }
                    if(Link->Dir == 1) {
                        ray3->X = Link->X;
                        ray3->Y = Link->Y + 16;
                        ray3->Vy = 2;
                        ray3->Vx = 0;
                        ray3->Data = vaskyre;
    
                    }
                    if(Link->Dir == 2) {
                        ray3->X = Link->X - 16;
                        ray3->Y = Link->Y;
                        ray3->Vx = -2;
                        ray3->Vy = 0;
                        ray3->Data = vaskyre;
                    }
                    if(Link->Dir == 3) {
                        ray3->X = Link->X + 16;
                        ray3->Y = Link->Y;
                        ray3->Vx = 2;
                        ray3->Vy = 0;
                        ray3->Data = vaskyre;
                    }
                }
            }    
        }}
    }
}

CODE

//==================================
//      ITEM SCRIPT BADI
// translation - Death
//D0 - CSet of the death graphic
//==================================

item script Badi{

    void run(int cset){

        ffc death = Screen->LoadFFC(6);

        int ffc_combo = 40;

        if (Link->MP >=8){

            death->TileWidth = 1;
            death->TileHeight = 1;

            Link->MP -= 8;

            death->Data = ffc_combo;
            death->CSet = cset;
            death->X = Link->X;
            death->Y = Link->Y;
            death->Vx = 0;
            death->Vy = 0;
        }
    }
}

CODE
//==================================
//      ITEM SCRIPT TZALIK
// translation - fist of god
//D0 - CSet of the fist
//==================================

item script Tzalik{

    void run (int cset){

        int fist_data = 125;    
        ffc fist = Screen->LoadFFC(4);    

        if (tzalik_level == 1 && Link->MP >= 16){

            Link->MP -= 16;
            Game->PlaySound(3);
            tzalik_exp++;

            if(Link->Dir == 0) {
                fist->X = Link->X - 8;
                fist->Y = Link->Y - 32;
                fist->Data = fist_data;
                fist->CSet = cset;
                fist->Vx=0;fist->Vy=-0.1;
                fist->TileWidth = 2;
                fist->TileHeight = 2;
            }
            if(Link->Dir == 1) {
                fist->X = Link->X - 8;
                fist->Y = Link->Y + 16;
                fist->Data = fist_data;
                fist->CSet = cset;
                fist->Vx=0;fist->Vy=0.1;
                fist->TileWidth = 2;
                fist->TileHeight = 2;
            }
            if(Link->Dir == 2) {
                fist->X = Link->X - 32;
                fist->Y = Link->Y - 8;
                fist->Data = fist_data;
                fist->CSet = cset;
                fist->Vx=-0.1;fist->Vy=0;
                fist->TileWidth = 2;
                fist->TileHeight = 2;
            }
            if(Link->Dir == 3) {
                fist->X = Link->X + 16;
                fist->Y = Link->Y - 8;
                fist->Data = fist_data;
                fist->CSet = cset;
                fist->Vx=0.1;fist->Vy=0;
                fist->TileWidth = 2;
                fist->TileHeight = 2;
            }
        }
    }
}

CODE

//==================================
//      ITEM SCRIPT LABADI
// translation - life steal
//D0 - CSet of the stealing graphic
//==================================

item script Labadi{

    void run(int cset){

        ffc steal = Screen->LoadFFC(6);

        int ffc_combo = 36;

        if (Link->MP >=8){

            Link->MP -= 8;
            steal->Data = ffc_combo;
            steal->CSet = cset;
            steal->X = Link->X;
            steal->Y = Link->Y;
            steal->Vx = 0;
            steal->Vy = 0;
            steal->TileWidth = 1;
            steal->TileHeight = 1;
        }
    }
}

CODE

//==================================
//      ITEM SCRIPT MANIFO
// translation - Statue
//D0 - the CSet of the projectile
//==================================

item script Manifo{

    void run(int cset){

        ffc beam = Screen->LoadFFC(5);

        int beam_animation = 48;

        if (Link->MP >=8){

            Link->MP -= 8;

            beam->TileWidth = 1;
            beam->TileHeight = 1;

            if(Link->Dir == 0) {
                beam->X = Link->X;
                beam->Y = Link->Y - 16;
                beam->Vy = -4;
                beam->Vx = 0;
                beam->Data = beam_animation;
                beam->CSet = cset;
            }
            if(Link->Dir == 1) {
                beam->X = Link->X;
                beam->Y = Link->Y + 16;
                beam->Vy = 4;
                beam->Vx = 0;
                beam->Data = beam_animation;
                beam->CSet = cset;
            }
            if(Link->Dir == 2) {
                beam->X = Link->X - 16;
                beam->Y = Link->Y;
                beam->Vx = -4;
                beam->Vy = 0;
                beam->Data = beam_animation;
                beam->CSet = cset;
            }
            if(Link->Dir == 3) {
                beam->X = Link->X + 16;
                beam->Y = Link->Y;
                beam->Vx = 4;
                beam->Vy = 0;
                beam->Data = beam_animation;
                beam->CSet = cset;
            }
        }
    }
}

CODE
//==================================
//      ITEM SCRIPT MAMOGREF
// translation - Wall of Force
//D0 - the CSet of the wall of force
//==================================

item script Mamogref{

    void run(int cset){

        int mamogref_animation = 16;

        ffc wall1 = Screen->LoadFFC(1);
        ffc wall2 = Screen->LoadFFC(2);
        ffc wall3 = Screen->LoadFFC(3);


        if(Link->MP >=64 && mamogref_level == 3){

            mamogref_exp++;
            Link->MP -= 64;
            Game->PlaySound(6);
            wall1->Data = mamogref_animation;
            wall1->CSet = cset;
            wall1->X = Link->X; wall1->Y = Link->Y;
            wall2->Data = mamogref_animation+2;
            wall2->CSet = cset;
            wall2->X = Link->X; wall1->Y = Link->Y;
            wall3->Data = mamogref_animation+3;
            wall3->CSet = cset;
            wall3->X = Link->X; wall1->Y = Link->Y;
        }
        else{
            if(Link->MP >=32 && mamogref_level >= 2){

                mamogref_exp++;
                Link->MP -= 32;
                Game->PlaySound(6);
                wall1->Data = mamogref_animation;
                wall1->CSet = cset;
                wall1->X = Link->X; wall1->Y = Link->Y;
                wall2->Data = mamogref_animation+1;
                wall2->CSet = cset;
                wall2->X = Link->X; wall1->Y = Link->Y;
            }
            else{
                if(Link->MP >=16 && mamogref_level >= 1){

                    mamogref_exp++;
                    Link->MP -= 16;
                    Game->PlaySound(6);
                    wall1->Data = mamogref_animation;
                    wall1->CSet = cset;
                    wall1->X = Link->X; wall1->Y = Link->Y;
                }    
            }
        }
    }
}




Edited by Gleeok, 06 March 2008 - 12:31 AM.


#13 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 06 March 2008 - 12:29 AM

CODE

//==================================
//      ITEM SCRIPT HALITO
// translation - Fire
//D0 - the CSet of the flames
//==================================

item script Halito{

    void run(int cset){

        int fire_animation = 8;

        ffc fire1 = Screen->LoadFFC(4);
        ffc fire2 = Screen->LoadFFC(5);
        ffc fire3 = Screen->LoadFFC(6);

        if(Link->MP >= 1 && halito_level == 1){
            

            if(!(fire1->Data >= fire_animation) && (fire1->Data <= fire_animation+7)){

                Game->PlaySound(13);
                Link->MP -= 1;
                halito_exp++;

                fire1->TileWidth = 1;
                fire1->TileHeight = 1;

                if((Link->InputLeft) && (Link->InputUp)) {
                    fire1->X = Link->X - 16;
                    fire1->Y = Link->Y - 16;
                    fire1->Vy = -2;
                    fire1->Vx = -2;
                    fire1->Data = fire_animation+4;
                    fire1->CSet = cset;
                }
                else if((Link->InputRight) && (Link->InputUp)) {
                    fire1->X = Link->X + 16;
                    fire1->Y = Link->Y - 16;
                    fire1->Vy = -2;
                    fire1->Vx = 2;
                    fire1->Data = fire_animation+5;
                    fire1->CSet = cset;
                }
                else if((Link->InputLeft) && (Link->InputDown)) {
                    fire1->X = Link->X - 16;
                    fire1->Y = Link->Y + 16;
                    fire1->Vx = -2;
                    fire1->Vy = 2;
                    fire1->Data = fire_animation+6;
                    fire1->CSet = cset;
                }
                else if((Link->InputRight) && (Link->InputDown)) {
                    fire1->X = Link->X + 16;
                    fire1->Y = Link->Y + 16;
                    fire1->Vx = 2;
                    fire1->Vy = 2;
                    fire1->Data = fire_animation+7;
                    fire1->CSet = cset;
                }
                else{

                    if(Link->Dir == 0) {
                        fire1->X = Link->X;
                        fire1->Y = Link->Y - 16;
                        fire1->Vy = -2;
                        fire1->Vx = 0;
                        fire1->Data = fire_animation;
                        fire1->CSet = cset;
                    }
                    if(Link->Dir == 1) {
                        fire1->X = Link->X;
                        fire1->Y = Link->Y + 16;
                        fire1->Vy = 2;
                        fire1->Vx = 0;
                        fire1->Data = fire_animation+1;
                        fire1->CSet = cset;
                    }
                    if(Link->Dir == 2) {
                        fire1->X = Link->X - 16;
                        fire1->Y = Link->Y;
                        fire1->Vx = -2;
                        fire1->Vy = 0;
                        fire1->Data = fire_animation+2;
                        fire1->CSet = cset;
                    }
                    if(Link->Dir == 3) {
                        fire1->X = Link->X + 16;
                        fire1->Y = Link->Y;
                        fire1->Vx = 2;
                        fire1->Vy = 0;
                        fire1->Data = fire_animation+3;
                        fire1->CSet = cset;
                    }
                }
            }
            else{
                if(!(fire2->Data == fire_animation) && (fire2->Data <= fire_animation+7)){

                    Game->PlaySound(13);
                    Link->MP -= 1;

                    fire2->TileWidth = 1;
                    fire2->TileHeight = 1;

                    if(Link->InputLeft && Link->InputUp) {
                        fire2->X = Link->X - 16;
                        fire2->Y = Link->Y - 16;
                        fire2->Vy = -2;
                        fire2->Vx = -2;
                        fire2->Data = fire_animation+4;
                        fire2->CSet = cset;
                    }
                    else if(Link->InputRight && Link->InputUp) {
                        fire2->X = Link->X + 16;
                        fire2->Y = Link->Y - 16;
                        fire2->Vy = -2;
                        fire2->Vx = 2;
                        fire2->Data = fire_animation+5;
                        fire2->CSet = cset;
                    }
                    else if(Link->InputLeft && Link->InputDown) {
                        fire2->X = Link->X - 16;
                        fire2->Y = Link->Y + 16;
                        fire2->Vx = -2;
                        fire2->Vy = 2;
                        fire2->Data = fire_animation+6;
                        fire2->CSet = cset;
                    }
                    else if(Link->InputRight && Link->InputDown) {
                        fire2->X = Link->X + 16;
                        fire2->Y = Link->Y + 16;
                        fire2->Vx = 2;
                        fire2->Vy = 2;
                        fire2->Data = fire_animation+7;
                        fire2->CSet = cset;
                    }
                    else{
            
                        if(Link->Dir == 0) {
                            fire2->X = Link->X;
                            fire2->Y = Link->Y - 16;
                            fire2->Vy = -2;
                            fire2->Vx = 0;
                            fire2->Data = fire_animation;
                            fire2->CSet = cset;
                        }
                        if(Link->Dir == 1) {
                            fire2->X = Link->X;
                            fire2->Y = Link->Y + 16;
                            fire2->Vy = 2;
                            fire2->Vx = 0;
                            fire2->Data = fire_animation+1;
                            fire2->CSet = cset;
                        }
                        if(Link->Dir == 2) {
                            fire2->X = Link->X - 16;
                            fire2->Y = Link->Y;
                            fire2->Vx = -2;
                            fire2->Vy = 0;
                            fire2->Data = fire_animation+2;
                            fire2->CSet = cset;
                        }
                        if(Link->Dir == 3) {
                            fire2->X = Link->X + 16;
                            fire2->Y = Link->Y;
                            fire2->Vx = 2;
                            fire2->Vy = 0;
                            fire2->Data = fire_animation+3;
                            fire2->CSet = cset;
                        }
                    }
                }
                else{
                if(!(fire3->Data == fire_animation) && (fire3->Data <= fire_animation+7)){

                    Game->PlaySound(13);
                    Link->MP -= 1;

                    fire3->TileWidth = 1;
                    fire3->TileHeight = 1;

                    if(Link->InputLeft && Link->InputUp) {
                        fire3->X = Link->X - 16;
                        fire3->Y = Link->Y - 16;
                        fire3->Vy = -2;
                        fire3->Vx = -2;
                        fire3->Data = fire_animation+4;
                        fire3->CSet = cset;
                    }
                    else if(Link->InputRight && Link->InputUp) {
                        fire3->X = Link->X + 16;
                        fire3->Y = Link->Y - 16;
                        fire3->Vy = -2;
                        fire3->Vx = 2;
                        fire3->Data = fire_animation+5;
                        fire3->CSet = cset;
                    }
                    else if(Link->InputLeft && Link->InputDown) {
                        fire3->X = Link->X - 16;
                        fire3->Y = Link->Y + 16;
                        fire3->Vx = -2;
                        fire3->Vy = 2;
                        fire3->Data = fire_animation+6;
                        fire3->CSet = cset;
                    }
                    else if(Link->InputRight && Link->InputDown) {
                        fire3->X = Link->X + 16;
                        fire3->Y = Link->Y + 16;
                        fire3->Vx = 2;
                        fire3->Vy = 2;
                        fire3->Data = fire_animation+7;
                        fire3->CSet = cset;
                    }
                    else{
            
                        if(Link->Dir == 0) {
                            fire3->X = Link->X;
                            fire3->Y = Link->Y - 16;
                            fire3->Vy = -2;
                            fire3->Vx = 0;
                            fire3->Data = fire_animation;
                            fire3->CSet = cset;
                        }
                        if(Link->Dir == 1) {
                            fire3->X = Link->X;
                            fire3->Y = Link->Y + 16;
                            fire3->Vy = 2;
                            fire3->Vx = 0;
                            fire3->Data = fire_animation+1;
                            fire3->CSet = cset;
                        }
                        if(Link->Dir == 2) {
                            fire3->X = Link->X - 16;
                            fire3->Y = Link->Y;
                            fire3->Vx = -2;
                            fire3->Vy = 0;
                            fire3->Data = fire_animation+2;
                            fire3->CSet = cset;
                        }
                        if(Link->Dir == 3) {
                            fire3->X = Link->X + 16;
                            fire3->Y = Link->Y;
                            fire3->Vx = 2;
                            fire3->Vy = 0;
                            fire3->Data = fire_animation+3;
                            fire3->CSet = cset;
                        }
                    }
                }
            }} //nested else statements
        }
    }
}

CODE
//==================================
//      ITEM SCRIPT MAHALITO
// translation - Big Fire
//D0 - the CSet of the flames
//==================================

//Copy/Paste the Halito script here then change this part:

//ffc script Halito{

//to this: ffc script Mahalito{

...or whatever you want.



OK, now these won't work without an ffc script. What I will do is split that into *THREE SECTIONS*

Section 1: Beginning and end of script. Used by all.
Section 2: General effects of each weapon. You can copy/paste as many as you want here.
Section 3: Additional effects of some weopons. Not all have this part. You may not need this at all.

Edited by Gleeok, 06 March 2008 - 12:56 AM.


#14 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 06 March 2008 - 12:52 AM

SECTION 1
CODE

//GLOBAL VARIABLES
    int halito_level = 1;        // fire
    int halito_exp = 0;

    int mahalito_level = 1;        // big fire
    int mahalito_exp = 0;

    int lahalito_level = 1;        // torch
    int lahalito_exp = 0;

    int dilto_level = 1;        // darkness
    int dilto_exp = 0;

    int dalto_level = 1;        // ice
    int dalto_exp = 0;

    int labadi_level = 1;        // life steal
    int labadi_exp = 0;

    int manifo_level = 1;        // statue
    int manifo_exp = 0;

    int makanito_level = 1;        // deadly air
    int makanito_exp = 0;    

    int mamogref_level = 1;        // wall of force
    int mamogref_exp = 0;    

    int malor_level = 1;        // teleport
    int malor_exp = 0;

    int tzalik_level = 1;        // fist of god
    int tzalik_exp = 0;

    int badi_level = 1;        // death
    int badi_exp = 0;

    int porfic_level = 1;        // shield
    int porfic_exp = 0;
    int porfic_shield = 0;
    int porfic_timer = 0;

    int elemental_sword_level = 1;    // elemental sword
    int elemental_sword_exp = 0;
    int enchant_sword = 0;
    int elemental_sword_timer = 0;

CODE

// ============================================================================================================
//                     ~FFC SCRIPT LINK WEAPONS~
//
//             -This version was based on General Weapon script by C-Dawg-
//
// "This script will use FFCs 1,2,3,4,5,6 to simulate weapons.depending. You can change these from the item scripts however
//  
// ~Variables~
//
// D0 = This ffc number.
// =============================================================================================================

ffc script Weapon{

    void run(int this_ffc_number){
        
        ffc this_ffc = Screen->LoadFFC(this_ffc_number);    int damage;

        this->Data=1; // for optional "script restarts on carry over" if you like you can delete this line;

    //--------------------------------------
    //         -Labadi-

        int labadi = 36;        // life steal

        bool life_steal = false;
        npc drained;

    //--------------------------------------
    //          -Badi-

        int badi = 40;            // death

        bool death = false;
        npc damned;
    //--------------------------------------
    //        -Mamogref-

        int mamogref = 16;        // wall of force
        int mamogref_timer = 0;
        int wobble_shield = 0;
        int wobble_shield2 = 180;
        int wobble_shield3 = 120;
        int wobble_shield4 = 240;
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //        -Halito-
        int halito = 8;            // fire spells

        int mahalito = 525;

        int lahalito = 56;

        int charge1 = 60;
        int charge2 = 60;

        int makanito = 116;        // deadly air

        int tzalik = 125;        // fist of god

        int vaskyre = 52;        // rainbow rays

    //--------------------------------------
    //        -Manifo-

        int manifo = 48;        // statue

        bool cast_manifo = false;
        npc statue1;
        npc statue2;
        npc statue3;
        npc statue4;
        float is_held1 = 0;
        float is_held2 = 0;
        float is_held3 = 0;
        float is_held4 = 0;
        int held1_x; int held1_y;
        int held2_x; int held2_y;
        int held3_x; int held3_y;
        int held4_x; int held4_y;

            //----------------------------------------------------------------
            //ANY NEW WEAPONS AND YOU HAVE TO ADD THE VARIABLES HERE YOURSELF






            //----------------------------------------------------------------

        // Variables to determine whether enemy is impacted

        int enemy_number = 0;
        npc enemy;

        // Variables to record which enemy is damaged

        npc enemy_1_damaged;                
        int enemy_1_cset = 0;            
        int enemy_1_damaged_counter = 0;    

        npc enemy_2_damaged;            
        int enemy_2_cset = 0;            
        int enemy_2_damaged_counter = 0;

        npc enemy_3_damaged;
        int enemy_3_cset = 0;
        int enemy_3_damaged_counter = 0;

        npc enemy_4_damaged;
        int enemy_4_cset = 0;
        int enemy_4_damaged_counter = 0;

    //======================================
    // Secondary Damage Simulation Routine   ..in progress/ not currently finished
    //======================================

        npc e1_damaged;            
        int e1_cset = 0;            
        int e1_damaged_counter = 0;    

        npc e2_damaged;            
        int e2_cset = 0;            
        int e2_damaged_counter = 0;    

        npc e3_damaged;            
        int e3_cset = 0;            
        int e3_damaged_counter = 0;    

        npc e4_damaged;            
        int e4_cset = 0;            
        int e4_damaged_counter = 0;    


    // ==============================
    //   End of declared variables
    // ==============================



        while (true){

            if(this_ffc->Data == 11908){Link->HP++;} // dummy if, don't delete it though if you don't know much about scripting.

        // =================================
        //               WEAPON SCRIPTS GO BELOW HERE
        // =================================






        // =================================
        //               WEAPON SCRIPTS GO ABOVE HERE
        // =================================



            // =================================
            //           Else Reset Data
            // =================================

            else{

                    this_ffc->Data = 1;
                    this_ffc->X = 16;
                    this_ffc->Y = 16;
            }

        // =================================
        //               ADDED EFFECTS GO HERE




        // =================================



        //==================================
        //    DAMAGE SIMULATION ENGINE 1
        //==================================

            // This part: Directly taken from Zodiac, the side quest by C-Dawg. For more by C-Dawg check the scripting forum at www.armageddongames.net

            // Damage simulation for enemy 1

            int lx = Link->X;
            int ly = Link->Y;
            
            if(enemy_1_damaged_counter > 0 && enemy_1_damaged->isValid()){

                int en1x = enemy_1_damaged->X;
                int en1y = enemy_1_damaged->Y;

                // enemy always moves away from the player while damaged

                if((en1x > lx) && (canMove(en1x + 24, en1y)) &&
                (canMove(en1x + 24, en1y + 8)) && (canMove(en1x + 24, en1y + 15))
                ){
                     enemy_1_damaged->X++;
                }

                if((en1x < lx) && (canMove(en1x - 1, en1y)) &&
                (canMove(en1x - 1, en1y + 8)) && (canMove(en1x - 1, en1y + 15))
                ){
                     enemy_1_damaged->X--;
                }

                if((en1y > ly) && (canMove(en1x, en1y + 24)) &&
                (canMove(en1x + 8, en1y + 24)) && (canMove(en1x + 15, en1y + 24))
                ){
                     enemy_1_damaged->Y++;
                }

                if((en1y < ly) && (canMove(en1x, en1y - 1)) &&
                (canMove(en1x + 8, en1y - 1)) && (canMove(en1x + 15, en1y - 1))
                ){
                     enemy_1_damaged->Y--;
                }
                
                enemy_1_damaged->CSet++;
        
                if (enemy_1_damaged_counter == 30) {enemy_1_damaged->HP = enemy_1_damaged->HP - damage;}

                enemy_1_damaged_counter--;    

                if(enemy_1_damaged_counter == 0){
                    enemy_1_damaged->CSet = enemy_1_cset;
                }

            }
            else enemy_1_damaged_counter=0;

            // Damage simulation for enemy 2
            
            if(enemy_2_damaged_counter > 0 && enemy_2_damaged->isValid()){

                int en2x = enemy_2_damaged->X;
                int en2y = enemy_2_damaged->Y;

                // enemy always moves away from the player while damaged

                if((en2x > lx) && (canMove(en2x + 24, en2y)) &&
                (canMove(en2x + 24, en2y + 8)) && (canMove(en2x + 24, en2y + 15))
                ){
                     enemy_2_damaged->X++;
                }

                if((en2x < lx) && (canMove(en2x - 1, en2y)) &&
                (canMove(en2x - 1, en2y + 8)) && (canMove(en2x - 1, en2y + 15))
                ){
                     enemy_2_damaged->X--;
                }

                if((en2y > ly) && (canMove(en2x, en2y + 24)) &&
                (canMove(en2x + 8, en2y + 24)) && (canMove(en2x + 15, en2y + 24))
                ){
                     enemy_2_damaged->Y++;
                }

                if((en2y < ly) && (canMove(en2x, en2y - 1)) &&
                (canMove(en2x + 8, en2y - 1)) && (canMove(en2x + 15, en2y - 1))
                ){
                     enemy_2_damaged->Y--;
                }
                
                enemy_2_damaged->CSet++;
        
                if (enemy_2_damaged_counter == 30) {enemy_2_damaged->HP = enemy_2_damaged->HP - damage;}

                enemy_2_damaged_counter--;    

                if(enemy_2_damaged_counter == 0){
                    enemy_2_damaged->CSet = enemy_2_cset;
                }

            }
            else enemy_2_damaged_counter=0;

            // Damage simulation for enemy 3
            
            if(enemy_3_damaged_counter > 0 && enemy_3_damaged->isValid()){

                int en3x = enemy_3_damaged->X;
                int en3y = enemy_3_damaged->Y;

                // enemy always moves away from the player while damaged

                if((en3x > lx) && (canMove(en3x + 24, en3y)) &&
                (canMove(en3x + 24, en3y + 8)) && (canMove(en3x + 24, en3y + 15))
                ){
                     enemy_3_damaged->X++;
                }

                if((en3x < lx) && (canMove(en3x - 1, en3y)) &&
                (canMove(en3x - 1, en3y + 8)) && (canMove(en3x - 1, en3y + 15))
                ){
                     enemy_3_damaged->X--;
                }

                if((en3y > ly) && (canMove(en3x, en3y + 24)) &&
                (canMove(en3x + 8, en3y + 24)) && (canMove(en3x + 15, en3y + 24))
                ){
                     enemy_3_damaged->Y++;
                }

                if((en3y < ly) && (canMove(en3x, en3y - 1)) &&
                (canMove(en3x + 8, en3y - 1)) && (canMove(en3x + 15, en3y - 1))
                ){
                     enemy_3_damaged->Y--;
                }
                
                enemy_3_damaged->CSet++;
        
                if (enemy_3_damaged_counter == 30) {enemy_3_damaged->HP = enemy_3_damaged->HP - damage;}

                enemy_3_damaged_counter--;    

                if(enemy_3_damaged_counter == 0){
                    enemy_3_damaged->CSet = enemy_3_cset;
                }
            }
            else enemy_3_damaged_counter=0;

            // Damage simulation for enemy 4
            
            if(enemy_4_damaged_counter > 0 && enemy_4_damaged->isValid()){

                int en4x = enemy_4_damaged->X;
                int en4y = enemy_4_damaged->Y;

                // enemy always moves away from the player while damaged

                if((en4x > lx) && (canMove(en4x + 24, en4y)) &&
                (canMove(en4x + 24, en4y + 8)) && (canMove(en4x + 24, en4y + 15))
                ){
                     enemy_4_damaged->X++;
                }

                if((en4x < lx) && (canMove(en4x - 1, en4y)) &&
                (canMove(en4x - 1, en4y + 8)) && (canMove(en4x - 1, en4y + 15))
                ){
                     enemy_4_damaged->X--;
                }

                if((en4y > ly) && (canMove(en4x, en4y + 24)) &&
                (canMove(en4x + 8, en4y + 24)) && (canMove(en4x + 15, en4y + 24))
                ){
                     enemy_4_damaged->Y++;
                }

                if((en4y < ly) && (canMove(en4x, en4y - 1)) &&
                (canMove(en4x + 8, en4y - 1)) && (canMove(en4x + 15, en4y - 1))
                ){
                     enemy_4_damaged->Y--;
                }
                
                enemy_4_damaged->CSet++;
        
                if (enemy_4_damaged_counter == 30) {enemy_4_damaged->HP = enemy_4_damaged->HP - damage;}

                enemy_4_damaged_counter--;    

                if(enemy_4_damaged_counter == 0){
                    enemy_4_damaged->CSet = enemy_4_cset;
                }
            }
            else enemy_4_damaged_counter=0;

            Waitframe();

        } // end of while loop
    } // end of void run

    // ===================================
    // Collision detection function
    // ===================================
    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


} // end of ffc script...Finally!

Edited by Gleeok, 06 March 2008 - 01:54 AM.


#15 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 06 March 2008 - 01:36 AM

SECTION 2 and/or 3:

CODE
        // =================================
        //               VASKYRE
        // =================================

            else if(this_ffc->Data == vaskyre){

                damage = Rand(2);

                if ((this_ffc->X < 2) || (this_ffc->X > 240) || (this_ffc->Y > 160) || (this_ffc->Y < 2)){
                    this_ffc->Data = 1;
                    this_ffc->CSet = 0;
                    this_ffc->X = 16;
                    this_ffc->Y = 16;
                }

                int tx = this_ffc->X;
                int ty = this_ffc->Y;

                enemy_number = Screen->NumNPCs();
                while(enemy_number > 0){
            
                    enemy = Screen->LoadNPC(enemy_number);

                    int en_x = enemy->X;
                    int en_y = enemy->Y;

                    if(Abs( (tx+8)-en_x)<=8 && Abs( (ty+8)-en_y)<=8 && !(enemy->Tile==0)){
    
                        enemy->HP-=Rand(2);
                        Game->PlaySound(11);
                    }
                    else if(Abs( (tx+8)-en_x)<=40 && Abs( (ty+8)-en_y)<=40 && !(enemy->Tile==0)){

                        Screen->Line(2,tx+8,ty+8,en_x+8,en_y+8,Rand(15)+1,1,0,0,0,128);
                        enemy->HP-=Rand(3)-1;
                        Game->PlaySound(3);

                    }
                enemy_number--;
                }
            }

CODE
        // =================================
        //               TZALIK
        // =================================

            else if(this_ffc->Data == tzalik || this_ffc->Data == tzalik+1){

                damage = Rand(5)+4;

                this_ffc->Vx = 0;
                this_ffc->Vy = 0;

                int tx = this_ffc->X;
                int ty = this_ffc->Y;

                enemy_number = Screen->NumNPCs();
                while(enemy_number > 0){
            
                    enemy = Screen->LoadNPC(enemy_number);

                    int en_x = enemy->X;
                    int en_y = enemy->Y;

                    if(Abs( (tx+8)-en_x)<=16 && Abs( (ty+8)-en_y)<=16 && !(enemy->Tile==0)){

                        if(enemy_1_damaged_counter == 0){
                            enemy_1_damaged = enemy;  enemy_1_damaged_counter = 30; enemy_1_cset = enemy->CSet;Game->PlaySound(11);
                        }
                        else{
                            if(enemy_2_damaged_counter == 0){
                                if(enemy != enemy_1_damaged){
                                    enemy_2_damaged = enemy;  enemy_2_damaged_counter = 30; enemy_2_cset = enemy->CSet;Game->PlaySound(11);
                                }
                            }
                            else{
                                if(enemy_3_damaged_counter == 0){
                                    if(enemy != enemy_1_damaged && enemy != enemy_2_damaged){
                                        enemy_3_damaged = enemy;  enemy_3_damaged_counter = 30; enemy_3_cset = enemy->CSet;Game->PlaySound(11);
                                    }
                                }
                                else{
                                    if(enemy_4_damaged_counter == 0){
                                        if(enemy != enemy_1_damaged && enemy != enemy_2_damaged && enemy != enemy_3_damaged){
                                            enemy_4_damaged = enemy;  enemy_4_damaged_counter = 30; enemy_4_cset = enemy->CSet;Game->PlaySound(11);
                                        }
                                    }
                                    else{
                                        enemy_number = 1;    
                                    }
                                }
                            }
                        }

                    }    
                    enemy_number--;
                }
            }
        

CODE
        // =================================
        //                HALITO
        // =================================

            else if(this_ffc->Data >= halito && this_ffc->Data <= halito+7){

                this_ffc->TileWidth = 1;
                this_ffc->TileHeight = 1;

                damage = Rand(2)+1;    

                if( (this_ffc->X < 8) || (this_ffc->X > 240) || (this_ffc->Y > 160) || (this_ffc->Y < 8)
                    || (Abs(this_ffc->X - Link->X)>64) || (Abs(this_ffc->Y - Link->Y)>64) ){

                    this_ffc->Data = 1;
                    this_ffc->X = 16;
                    this_ffc->Y = 16;
                }

                int tx = this_ffc->X;
                int ty = this_ffc->Y;

                enemy_number = Screen->NumNPCs();
                while(enemy_number > 0){
            
                    npc enemy = Screen->LoadNPC(enemy_number);

                    int en_x = enemy->X;
                    int en_y = enemy->Y;


                    if (    (tx - 12 < en_x) &&
                        (tx + 12 > en_x) &&
                        (ty - 12 < en_y) &&
                        (ty + 12 > en_y) &&
                        (!(enemy->Tile==0) )    
                        ){

                        Game->PlaySound(11);
                        this_ffc->Data = 1;
                        enemy->HP -= damage;
                        enemy_number = 1;
                    }    
                    enemy_number--;
                }    
            }
    

CODE
        // =================================
        //                MAHALITO
        // =================================

            else if(this_ffc->Data >= mahalito && this_ffc->Data <= mahalito+7){

                this_ffc->TileWidth = 1;
                this_ffc->TileHeight = 1;

                damage = Rand(3)+2;    

                if( (this_ffc->X < 8) || (this_ffc->X > 240) || (this_ffc->Y > 160) || (this_ffc->Y < 8)){

                    this_ffc->Data = 1;
                    this_ffc->X = 16;
                    this_ffc->Y = 16;
                }

                int tx = this_ffc->X;
                int ty = this_ffc->Y;

                enemy_number = Screen->NumNPCs();
                while(enemy_number > 0){
            
                    enemy = Screen->LoadNPC(enemy_number);

                    int en_x = enemy->X;
                    int en_y = enemy->Y;


                    if (    (tx - 12 < en_x) &&
                        (tx + 12 > en_x) &&
                        (ty - 12 < en_y) &&
                        (ty + 12 > en_y) &&
                        (!(enemy->Tile==0) )    
                        ){

                        Game->PlaySound(11);
                        this_ffc->Data = 1;
                        enemy->HP -= damage;
                        enemy_number = 1;
                    }    
                    enemy_number--;
                }    
            }


CODE
        // ================================
        //          MAMOGREF SHIELD
        // ================================

            else if(this_ffc->Data >= mamogref && this_ffc->Data <= mamogref + 3){

                this_ffc->TileWidth = 1;
                this_ffc->TileHeight = 1;

                if(mamogref_level == 1){damage = 2;}
                if(mamogref_level == 2){damage = 4;}
                if(mamogref_level == 3){damage = 6;}

                if(this_ffc->Data == mamogref){

                    this_ffc->X = Link->X + (16 * Sin(wobble_shield*12));
                    this_ffc->Y = Link->Y + (16 * Cos(wobble_shield*12));

                    wobble_shield++;wobble_shield2++;wobble_shield3++;wobble_shield4++;
                    mamogref_timer++;
                }
                if(this_ffc->Data == mamogref+1){

                    this_ffc->X = Link->X - (16 * Sin(wobble_shield2*12));
                    this_ffc->Y = Link->Y - (16 * Cos(wobble_shield2*12));

                    wobble_shield++;wobble_shield2++;wobble_shield3++;wobble_shield4++;
                    mamogref_timer++;
                }
                if(this_ffc->Data == mamogref+2){

                    this_ffc->X = Link->X + (18 * Sin(wobble_shield3*14));
                    this_ffc->Y = Link->Y + (18 * Cos(wobble_shield3*14));

                    wobble_shield++;wobble_shield2++;wobble_shield3++;wobble_shield4++;
                    mamogref_timer++;
                }
                if(this_ffc->Data == mamogref+3){

                    this_ffc->X = Link->X + (20 * Sin(wobble_shield4*16));
                    this_ffc->Y = Link->Y + (20 * Cos(wobble_shield4*16));

                    wobble_shield++;wobble_shield2++;wobble_shield3++;wobble_shield4++;
                    mamogref_timer++;
                }

    
                if (mamogref_timer >= 1200) {

                    this_ffc->Data = 1;
                    wobble = 0;wobble_shield=0;wobble_shield2=180;wobble_shield3=120;wobble_shield4=240;
                    initialize = 0;
                    this_ffc->X = 16;
                    this_ffc->Y = 16;
                    mamogref_timer = 0;
                }

                int tx = this_ffc->X;
                int ty = this_ffc->Y;

                enemy_number = Screen->NumNPCs();
                while(enemy_number > 0){
            
                    enemy = Screen->LoadNPC(enemy_number);

                    int en_x = enemy->X;
                    int en_y = enemy->Y;


                    if (    (tx - 12 < en_x) &&
                        (tx + 12 > en_x) &&
                        (ty - 12 < en_y) &&
                        (ty + 12 > en_y) &&
                        (!(enemy->Tile==0) )    
                        ){


                        if(enemy_1_damaged_counter == 0){
                            enemy_1_damaged = enemy;  enemy_1_damaged_counter = 30; enemy_1_cset = enemy->CSet;Game->PlaySound(11);
                        }
                        else{
                            if(enemy_2_damaged_counter == 0){
                                if(enemy != enemy_1_damaged){
                                    enemy_2_damaged = enemy;  enemy_2_damaged_counter = 30; enemy_2_cset = enemy->CSet;Game->PlaySound(11);
                                }
                            }
                            else{
                                if(enemy_3_damaged_counter == 0){
                                    if(enemy != enemy_1_damaged && enemy != enemy_2_damaged){
                                        enemy_3_damaged = enemy;  enemy_3_damaged_counter = 30; enemy_3_cset = enemy->CSet;Game->PlaySound(11);
                                    }
                                }
                                else{
                                    if(enemy_4_damaged_counter == 0){
                                        if(enemy != enemy_1_damaged && enemy != enemy_2_damaged && enemy != enemy_3_damaged){
                                            enemy_4_damaged = enemy;  enemy_4_damaged_counter = 30; enemy_4_cset = enemy->CSet;Game->PlaySound(11);
                                        }    
                                    }
                                    else{
                                        enemy_number = 1;    
                                    }
                                }
                            }
                        }
                    }    
                    enemy_number--;
                }    
            }
            

Edited by Gleeok, 06 March 2008 - 01:35 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users