PDA

View Full Version : Big Death Poofs



raiu
06-10-2010, 02:21 PM
Lucky you! you get two scripts today!!

This first one is designed for big bosses and such:

void DeathAni(int cx, int cy, int size, int spri, int circ, int radius, int bigSpri, int spriSize, int delay){
lweapon me;
int x[17]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int y[17]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
if(size==3){
x[0]=cx-24;x[1]=cx+24;x[2]=cx-8;x[3]=cx-19;x[4]=cx+8;x[5]=cx-36;x[6]=cx+3;x[7]=cx+4;x[8]=cx-36;x[9]=cx+4;x[10]=cx-19;x[11]=cx-20;x[12]=cx+24;x[13]=cx-20;x[14]=cx-8;x[15]=cx+3;x[16]=cx-1;
y[0]=cy-8;y[1]=cy-19;y[2]=cy+8;y[3]=cy-36;y[4]=cy-8;y[5]=cy+3;y[6]=cy-36;y[7]=cy+4;y[8]=cy-19;y[9]=cy-20;y[10]=cy+24;y[11]=cy-20;y[12]=cy+3;y[13]=cy+4;y[14]=cy-24;y[15]=cy+24;y[16]=cy-1;
}
else if(size==2){
x[0]=cx-20;x[1]=cx+8;x[2]=cx-20;x[3]=cx-8;x[4]=cx+4;x[5]=cx-24;x[6]=cx+4;x[7]=cx-8;x[8]=cx-1;
y[0]=cy-20;y[1]=cy-8;y[2]=cy+4;y[3]=cy-24;y[4]=cy+4;y[5]=cy-8;y[6]=cy-20;y[7]=cy+8;y[8]=cy-1;
}
else if(size==1){
x[0]=cx-8;x[1]=cx-8;x[2]=cx;x[3]=cx-16;x[4]=cx-1;
y[0]=cy-16;y[1]=cy;y[2]=cy-8;y[3]=cy-8;y[4]=cy-1;
} else { x[0]=cx; y[0]=cy; }
for(int i=0; x[i]!=cx-1; i++){
me = Screen->CreateLWeapon(LW_SPARKLE);
me->X = x[i]; me->Y = y[i];
me->UseSprite(spri);
me->Behind=false;
Waitframes(delay);
}
for(int angle=Rand(360); circ>0; circ--){
angle += Rand2(90,270); if(angle>360)angle-=360;
for(int i=16; i>=0; i--){
me = Screen->CreateLWeapon(LW_SPARKLE);
me->X = Cos(angle)*i*radius+cx-8; me->Y = Sin(angle)*i*radius+cy-8;
me->UseSprite(spri);
me->Behind=false;
angle+=20;
Waitframe();
}
Waitframes(delay-1);
}
if(bigSpri>0){
me = Screen->CreateLWeapon(LW_SPARKLE);
me->Extend = 4;
me->TileWidth = spriSize; me->TileHeight = spriSize;
me->Behind=false;
me->X = cx- spriSize*8; me->Y = cy- spriSize*8;
me->UseSprite(bigSpri);
}
}

put this outside of your other script files, and then you can have a ffc that checks to see when an enemy is dead, and then call this script. arguments:
cx=center x (usually you'd want the x value of the enemy +8(or +16 for bosses))
cy=center y, same as above, but with y
size= [1|2|3] largeness of explosion thingy
spri=spite to use for poofs
circ=number of circles (can be 0)
radius=radius of the circles (i would suggest small numbers)
bigSpri=sprite to use for extended size explotion (tiles should be layed out XXX with each X representing a block of tiles, sprite should select the top left)
spriSize=size of the big sprite (i havent tested with over 2)
delay = number of frames between each poof.

-----------

second script is for standard everyday enemies:

import "std.zh"


const int dp_size=2;//tile width/height
const int dp_sprite=57;//sprite number


global script slot2{
void run(){


int curScreen=0;
int curDmap=0;
int dPoofX[10]={0,0,0,0,0,0,0,0,0,0};
int dPoofY[10]={0,0,0,0,0,0,0,0,0,0};
int dp_cx=777;//777 indicates no value
int dp_cy=0;
int dp_numEs=0;
npc dpTest;
lweapon dPoof;
int dpTD=0;//bianary array to do
int dpNTD=111111111111111b;//bianary array not to do

while(true){

if(ScreenFlag(SF_MISC, 2)==0){
dpTD=0;
if(Game->GetCurDMapScreen()!=curScreen||Game->GetCurDMap()!=curDmap){
curScreen=Game->GetCurDMapScreen();
curDmap=Game->GetCurDMap();
dp_numEs=0;
dpNTD=111111111111111b;
}
if(Screen->NumNPCs()>dp_numEs){
dpNTD=111111111111111b;
for(int i=0;i<15;i++){
dpTest=Screen->LoadNPC(i+1);
if(dpTest->isValid()&&dpTest->ID>10&&dpTest->Type!=NPCT_FAIRY&&dpTest->Type!=NPCT_ROCK){
dPoofX[i]=dpTest->X;
dPoofY[i]=dpTest->Y;
dpTest->Misc[15]=i+1;
dpNTD&=~Pow(2,i);
}
}
}
dp_cx=777;
for(int i=0;i<15;i++){
int n=-1;
dpTest=Screen->LoadNPC(i+1);
if(dpTest->isValid()){
n=dpTest->Misc[15]-1;
}
if(n>=0&&(dpNTD&Pow(2,n))==0){
dPoofX[n]=dpTest->X;
dPoofY[n]=dpTest->Y;
dpTD|=Pow(2,n);
}
}if((dpTD|dpNTD)!=111111111111111b){
int n=-1;
for(int i=0;n==-1;i++){
if(((dpTD|dpNTD)&Pow(2,i))==0){
n=i;
dpNTD|=Pow(2,n);
dp_cx=dPoofX[n]+(dp_size-1)*8;
dp_cy=dPoofY[n]+(dp_size-1)*8;
}
}
}
if(dp_cx!=777){
dPoof = Screen->CreateLWeapon(LW_SPARKLE);
dPoof->Extend = 4;
dPoof->TileWidth = dp_size;
dPoof->TileHeight = dp_size;
dPoof->Behind=false;
dPoof->X = dp_cx- dp_size*8;
dPoof->Y = dp_cy- dp_size*8;
dPoof->UseSprite(dp_sprite);
}
dp_numEs=Screen->NumNPCs();
}





Waitframe();
}
}
}
Script i mad for a request here (http://www.purezc.com/forums/index.php?showtopic=45785&pid=648982&st=15&#entry648982). Its a modified version of my other script.
Combine it with other global scripts and now in any screen that general use 1 (scripts) flag is un-checked, enemies have a large poof when dying.
sample quest: PoofTest (http://www.mediafire.com/file/nannnwkhhhj/poofTest2.qst)
for the poof, the animation tiles should be layed out as followed, with the sprite chosen by the constant (which to can change to any sprite you want) pointing to the top left tile:
1 1 2 2 3 3
1 1 2 2 3 3
set the sprites animation and speed and such in the zquest editor, then the extend function within the script will enlargen it.