PDA

View Full Version : Mace Enemy



Joe123
11-16-2008, 03:04 PM
const int T_CHAIN = 196; //Mace Chain
const int T_HEAD = 197; //Mace Head
//Gives an enemy a mace to swing at Link
ffc script MaceEnemy{
void run(int num, int maxradius, int damage){
int counter = Rand(360);
int spintimer;
int radius = maxradius;
int x; int y;
int ret;
Waitframes(4);
npc e = Screen->LoadNPC(num);
while(e->isValid()){
spintimer = 0;
//spin the ball
while(spintimer < 240+Rand(120) && e->isValid()){
SpinBall(radius,counter,num,damage,false);
spintimer++;
counter = (counter+3)%360;
Waitframe();
}
//pull the ball in
while(radius > 20 && e->isValid()){
SpinBall(radius,counter,num,damage,false);
radius -= 2;
counter = (counter+3)%360;
Waitframe();
}
spintimer = 0;
//spin very fast with small radius
while(spintimer < 120 && e->isValid()){
SpinBall(radius,counter,num,damage,false);
spintimer++;
counter = (counter+10)%360;
Waitframe();
}
//throw at Link
x = Link->X;
y = Link->Y;
counter = 4;
ret = 1;
while(e->isValid() && counter > 0){
SpinBall(counter,ArcTan((x-e->X),(y-e->Y)),num,damage,true);
if(Abs(x-(e->X + RadianCos(ArcTan((x-e->X),(y-e->Y)))*counter)) < 4
&& Abs(y-(e->Y + RadianSin(ArcTan((x-e->X),(y-e->Y)))*counter)) < 4){
if(ret == 1) Pause(counter,ArcTan((x-e->X),(y-e->Y)),num,damage);
//return
ret = -1;
}
counter += 4*ret;
Waitframe();
}
Pause(0,0,num,damage);
//bring back to main spin position
counter = Floor(ArcTan((x-e->X),(y-e->Y))*180/PI);
radius = 0;
while(radius < maxradius && e->isValid()){
SpinBall(radius,counter,num,damage,false);
radius += 2;
counter = (counter+3)%360;
Waitframe();
}
}
Screen->ClearSprites(SL_EWPNS);
}
void Pause(int r, int c, int n, int d){
for(int i=0;i<10;i++){
SpinBall(r,c,n,d,true);
Waitframe();
}
}
void SpinBall(int radius, int counter, int num, int damage, bool radians){
npc e = Screen->LoadNPC(num);
Screen->ClearSprites(SL_EWPNS);
for(int i=0;i<5;i++){
eweapon ball = Screen->CreateEWeapon(EW_SCRIPT1);
if(i<4) ball->Tile = T_CHAIN;
else ball->Tile = T_HEAD;
ball->Damage = damage;
if(radians){
ball->X = e->X + RadianCos(counter)*(radius*(i+1)/5);
ball->Y = e->Y + RadianSin(counter)*(radius*(i+1)/5);
}else{
ball->X = e->X + Cos(counter)*(radius*(i+1)/5);
ball->Y = e->Y + Sin(counter)*(radius*(i+1)/5);
}
}
}
}
Well, I wrote this earlier and I thought I'd share cause it's quite easy to use, and it makes for quite nice mini-bosses, or even just an addition to normal enemies.

D0: Number of enemy on the list to give the mace to
D1: Max radius of the mace. Set to a value greater than 20, otherwise hell may ensue.
D2: Damage for mace to deal

Set the two constants at the top to be what you want the chain and the mace head to be.
The chain is just made up of little circles, so it's a bit like the LA one.

You can only have one mace enemy on a screen, and it shouldn't really be paired with enemies that shoot fireballs or anything (cause they won't work).
It can be attached to any enemy, so if you really like, you can give it to at tektite.
I tried it earlier.
It's less fun than you might think really.
Maybe a mace-carrying gel is what some of you were looking for though?
I don't know.

I prefer it on a Darknut.

What it does is:
Spin round 2 or 3 times at D1 radius, then move in to a radius of 20, spin really quickly a couple of times, then launch off at Link, then start over.

Shazza Dani
01-18-2009, 01:34 AM
Would you be able to make the weapon center around the top-left corner of the enemy sprite?

example:
http://i8.photobucket.com/albums/a40/tdrisko/yush.gif

Joe123
01-18-2009, 06:40 AM
Oh yeah sure, I think the version I'm using actually does that. It's a bit stripped down, but more like the GB enemy, d‘yuwant that version?

Shazza Dani
01-18-2009, 06:44 AM
Yessir plz! O;

Joe123
01-18-2009, 09:37 AM
const int T_CHAIN = 3277;
const int T_HEAD = 3276;
//Give an enemy a mace to swing at Link
ffc script E_Mace{
void run(int num, int maxradius, int damage){
int counter = Rand(360);
int spintimer;
int radius = maxradius;
int x; int y;
int ret;
Waitframes(4);
npc e = Screen->LoadNPC(num);
while(e->isValid()){
spintimer = 0;
//spin
while(spintimer < 120 && e->isValid()){
SpinBall(radius,counter,num,damage,false);
if(spintimer%30 == 0) Game->PlaySound(SFX_BRANG);
spintimer++;
counter = (counter+10)%360;
Waitframe();
}
//throw at Link
x = Link->X;
y = Link->Y;
counter = 4;
ret = 1;
while(e->isValid() && counter > 0){
SpinBall(counter,ArcTan((x-e->X),(y-e->Y)),num,damage,true);
if(Abs(x-(e->X + RadianCos(ArcTan((x-e->X),(y-e->Y)))*counter)) < 4
&& Abs(y-(e->Y + RadianSin(ArcTan((x-e->X),(y-e->Y)))*counter)) < 4){
if(ret == 1){
Game->PlaySound(SFX_HAMMER);
Pause(counter,ArcTan((x-e->X),(y-e->Y)),num,damage);
}
//return
ret = -1;
}
counter += 4*ret;
Waitframe();
}
Pause(0,0,num,damage);
//bring back to main spin position
counter = Floor(ArcTan((x-e->X),(y-e->Y))*180/PI);
radius = 0;
while(radius < maxradius && e->isValid()){
SpinBall(radius,counter,num,damage,false);
radius += 2;
counter = (counter+3)%360;
Waitframe();
}
}
Screen->ClearSprites(SL_EWPNS);
}
void Pause(int r, int c, int n, int d){
for(int i=0;i<10;i++){
SpinBall(r,c,n,d,true);
Waitframe();
}
}
void SpinBall(int radius, int counter, int num, int damage, bool radians){
npc e = Screen->LoadNPC(num);
Screen->ClearSprites(SL_EWPNS);
for(int i=0;i<5;i++){
eweapon ball = Screen->CreateEWeapon(EW_SCRIPT1);
if(i<4) ball->Tile = T_CHAIN;
else ball->Tile = T_HEAD;
ball->Damage = damage;
ball->CSet = 8;
if(radians){
ball->X = e->X-8 + RadianCos(counter)*(radius*(i+1)/5);
ball->Y = e->Y-8 + RadianSin(counter)*(radius*(i+1)/5);
}else{
ball->X = e->X-8 + Cos(counter)*(radius*(i+1)/5);
ball->Y = e->Y-8 + Sin(counter)*(radius*(i+1)/5);
}
}
}
}

That should be the right one.

Beta Link
01-27-2009, 08:14 PM
Dude... This is just what I need for an enemy in Kanalet Castle in IoD...

*yoinks* :D