Jump to content

Photo

Boss Death


  • Please log in to reply
7 replies to this topic

#1 Theryan

Theryan

    Burrito

  • Members

Posted 25 July 2009 - 12:18 AM

I looked around for a bit and couldn't find a script like this this, so here we go:
Basically what I'm looking for is an exploding boss death script, mimicking many of the 2D Zelda games' boss deaths. All I really want is explosions that spawn randomly around the boss while the FFC or enemy graphics flicker away(or simply disappear...).
If its easier, you could just make the boss explode indefinitely, and I could use timed warps to stop the animation.

Thanks to anyone who can help! And if you need anymore clarification, just ask!

#2 Joe123

Joe123

    Retired

  • Members

Posted 25 July 2009 - 07:12 AM

CODE
ffc script BossDeath{
    void run(int wsp,int maxexp)
        int exp[20];
        maxexp = VBound(Floor(maxexp),20,1);
        for(int i=0;i<maxexp;i++) exp[i] = i*Rand(4);
        lweapon l[20];
        while(true){
            for(int i=0;i<maxexp;i++){
                if(exp[i] > -1){
                    exp[i]--;
                    if(exp[i] == 0) SpawnExplosion(wsp,this);
                    continue;
                }
                if(!l[i]->isValid()) SpawnExplosion(wsp,this);
            }
        Waitframe();
        }
    }
    lweapon SpawnExplosion(int wsp,ffc this){
        lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
        l->UseSprite(wsp);
        l->X = this->X+Rand(this->EffectWidth);
        l->Y = this->Y+Rand(this->EffectHeight);
        l->DeadState = l->NumFrames*l->ASpeed;
    return l;
    }
}


Try that.
D0 is the Weapon/Misc. sprite of an explosion animation, and D1 is the max number of explosions at any one point. No more than 20, although I could up that if you want.

Explosions spawn in the area from (ffc->X,ffc->Y) to (ffx->X+EffectHeight,ffc->Y+EffectHeight).

#3 Theryan

Theryan

    Burrito

  • Members

Posted 25 July 2009 - 08:34 PM

Thanks, Joe! I ran into a problem trying to compile it, however.

On pass 3 of the compiler, it says:
"Error S09: variable this is not declared" for these lines
CODE

        l->X = this->X+Rand(this->EffectWidth);
        l->Y = this->Y+Rand(this->EffectHeight);

Try as I might, I cannot seem to remedy this. Any help would be appreciated!

#4 Joe123

Joe123

    Retired

  • Members

Posted 26 July 2009 - 04:26 AM

Oh yeah, I noticed that and fixed it before you posted actually; try copying the script over again and see what happens this time.

#5 Theryan

Theryan

    Burrito

  • Members

Posted 26 July 2009 - 09:26 PM

Thanks! That fixed that problem, but now it says:
Error T21: Could not match type signature SpawnExplosion(Float, FFC)

#6 Joe123

Joe123

    Retired

  • Members

Posted 27 July 2009 - 04:53 AM

Ok, ok, I actually compiled it and tested it this time.
CODE
ffc script BossDeath{
    void run(int wsp,int maxexp,int sfx){
        int exp[20];
        maxexp = VBound(Floor(maxexp),20,1);
        for(int i=0;i<maxexp;i++) exp[i] = i*Rand(3);
        lweapon l[20];
        while(true){
            for(int i=0;i<maxexp;i++){
                if(exp[i] > -1){
                    exp[i]--;
                    if(exp[i] == 0) l[i] = SpawnExplosion(wsp,sfx,this);
                    continue;
                }
                if(!l[i]->isValid()) l[i] = SpawnExplosion(wsp,sfx,this);
            }
        Waitframe();
        }
    }
    lweapon SpawnExplosion(int wsp,int sfx,ffc this){
        lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
        l->UseSprite(wsp);
        l->X = this->X+Rand(this->EffectWidth)-8;
        l->Y = this->Y+Rand(this->EffectHeight)-8;
        l->DeadState = l->NumFrames*l->ASpeed;
        if(sfx > 0) Game->PlaySound(sfx);
    return l;
    }
}


So to use it, first make a new Weapon/Misc. sprite which has an A.Frame and A.Speed value greater than 0.
Then place the ffc where you want the top left corner of the explosion area to appear on the screen, and give it a transparent, non-zero combo as its data.
The size of the explosion area is denoted by the 'ComboWidth' and 'ComboHeight' of the ffc, so if you wanted the explosions to spawn over a 3x2 combo area for example, you'd put in 48 for the ComboWidth and 32 for the ComboHeight.
Give it the script (obviously) then go to the Arguments tab, and for D0 put the ID number of the Weapon/Misc. sprite you just created.
D1 is the max number of explosions that are displayed at a time (up to a max of 20), so that's up to you to decide. 5 worked quite well for me with a 3x2 ffc.
And finally D2 is the SFX you want to play each time an explosion spawns. If you don't want a Sound Effect to play, leave this as 0.

#7 Theryan

Theryan

    Burrito

  • Members

Posted 27 July 2009 - 09:39 PM

Compiles and works perfectly! Thanks a lot, Joe!

#8 Joe123

Joe123

    Retired

  • Members

Posted 28 July 2009 - 04:01 AM

No problem, glad to hear you got it working ok.
Think I might submit it to the database when I have some time.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users