PDA

View Full Version : Extra Enemy Attacks



Joe123
05-12-2008, 05:42 AM
Had enough of the old 'rock and sword' projectiles?

Wellll....


Now we have homing laser and flamethrower =D
I've tried to make them as fool-proof as possible, so basically all you have to do is stick them into a script file with std.zh in it, then put them on a screen with an enemy on.
And set the graphics for the fireball in the flamethrower.


So:
Enemy Flamethrower

ffc script flamethrower{
void run(int t,int c,int d,int n,int f,int a){
if(a==0) a=1;
if(d==0) d=4;
Waitframes(4);
npc e = Screen->LoadNPC(a);
while(e->isValid()){
homingprojectile(e->X,e->Y,t,c,d,2,n,f);
Waitframe();
}
}
void homingprojectile(int x, int y, int tile, int cset, int dmg, int spd, int num, int fspd){
eweapon w = Screen->CreateEWeapon(31);
w->Tile = tile; w->OriginalTile = tile;
w->CSet = cset;
w->NumFrames = num; w->ASpeed = fspd;
w->X = x; w->Y = y;
w->Step = spd;
w->Damage = dmg;
w->Angular = true;
int angle = ArcTan((Link->X-x),(Link->Y-y));
w->Angle = angle;
if(angle==-PI || angle==PI) w->Dir=2;
else if(angle==-PI/2) w->Dir=0;
else if(angle==PI/2) w->Dir=1;
else if(angle==0) w->Dir=3;
else if(angle<-PI/2) w->Dir=4;
else if(angle<0) w->Dir=5;
else if(angle>(PI/2)) w->Dir=6;
else w->Dir=7;
}
}
D0: Tile for projectile to use
D1: CSet
D2: Damage (default 1 heart)
D3: Number of frames of animation of projectile
D4: Speed of animation
D5: Number of enemy on screen to put flamethrower attack onto (default 1)


Enemy Laser

ffc script laser{
void run(int d,int w,int a){
int dx; int dy;
int m; int c;
int i; int j;
if(a==0) a=1;
if(d==0) d=4;
if(w==0) w = 4;

//this is the number of frames behind Link the laser is. Because we don't have variable arrays, if you want
//to change it, you have to change all 3 numbers here. Make them the same. Please.
int fb = 20;
int x[20]; int y[20];

x[0] = Link->X+8;
x[0] = Link->Y+8;
for(j=0;j<fb-1;j++){
for(i=fb-1;i>0;i--){
x[i] = x[i-1];
y[i] = y[i-1];
}
Waitframe();
}

npc e = Screen->LoadNPC(a);
j = 0;
while(e->isValid()){
if(j>0) j--;
x[0] = Link->X+8;
y[0] = Link->Y+8;
for(i=fb-1;i>0;i--){
x[i] = x[i-1];
y[i] = y[i-1];
}

dx = (e->X+8)-x[fb-1];
dy = (e->Y+8)-y[fb-1];
if(dx != 0){
m = dy/dx;
c = y[fb-1] - m*x[fb-1];
if(dy==0){
y[fb] = y[fb-1];
if(dx>0) x[fb] = 0;
else x[fb] = 256;
}else if(dy>0){
y[fb] = 0;
x[fb] = (y[fb]-c)/m;
}else{
y[fb] = 256;
x[fb] = (y[fb]-c)/m;
}
}else{
x[fb] = x[fb-1];
if(dy>0) y[fb] = 0;
else y[fb] = 168;
}

Screen->Line(2,e->X+8,e->Y+8,x[fb],y[fb],Rand(120)+1,1,0,0,0,128);
if(j==0){
if(DistancePointToLine(e->X+8,e->Y+8,x[fb],y[fb],Link->X+8,Link->Y+8) < 2 && Link->Z == 0){
Game->PlaySound(36);
Game->PlaySound(19);
Link->HP -= d;
}
j = w;
}
Waitframe();
}
}
int DistancePointToLine(int x1,int y1,int x2,int y2,int distx,int disty){
int dx = x2-x1;
if(dx != 0){
int m = (y2-y1)/dx;
int c = y1 - m*x1;
return (Abs(-m*distx + disty - c))/Sqrt(m*m + 1);
}
else return Abs(distx-x1);
}
}
D0: Damage of laser (default quarter heart)
D1: Number of frames to wait between taking damage from laser (default 4)
D2: Number of enemy on screen to give laser attack to (default 1)

If you want to edit how many 'frames ago' it attacks, then I've noted up the places you have to change in the script.

Master Maniac
05-18-2008, 11:01 PM
joe, this is perfect for scripting beamos statues! awesome =) you are truly a scrpting genious.

Russ
05-18-2008, 11:22 PM
I will definitely use these for Beamoses! Thank's Joe!

Joe123
05-19-2008, 07:15 AM
Hrm.

It's a bit powerful to be a Beamos really.
I might make a Beamos though, that rotates and only shoots if Link is near that direction or something.
I'll see.

Russ
05-19-2008, 10:55 AM
You might? Awesome! Although to be honest, I'd rather see you try to finish the DoFR Scent tree that make a beamos script. :)

Joe123
05-19-2008, 05:48 PM
Woahhh, that was ages ago, I competely forgot about that =P

I might go back to it sometime, but I really wasn't finding it too easy at all.