CODE
ffc script BallChainKnight {
void run(int ThisFFC, int SynthX, int SynthY) {
ffc Ball;
float X = SynthX; float Y = SynthY;
int LinkX; int LinkY;
int action = 0;
int radius = 24; int ballx = X; int bally = Y; float balldir = 0;
npc BallKnight = Screen->CreateNPC(184);
Ball = Screen->LoadFFC(ThisFFC+1);
npc ChainBall = Screen->CreateNPC(185);
while(BallKnight->isValid()) { // While the Ball Knight is still alive
ballx = X+RadianCos(balldir)*radius;
bally = Y-RadianSin(balldir)*radius;
balldir+=0.15; // this and the 2 lines above do the trig work needed to make this move in a circle. increase this to increase speed.
Ball->X=ballx;
Ball->Y=bally;
ChainBall->X=ballx;
ChainBall->Y=bally;
Ball->Data=895;
this->Data=893;
this->X=X;
this->Y=Y;
//check actions
if (X > Link->X+64 && action==1) {
action=0;
}
if (X < Link->X-64 && action==1) {
action=0;
}
if (Y > Link->Y+64 && action==1) {
action=0;
}
if (Y < Link->Y-64 && action==1) {
action=0;
}
if (X > Link->X+64 && action!=1) {
X-=0.5;
if (X > Link->X+64) {
action = 0;
}
else {
action = 1;
}
}
if (X < Link->X-64 && action!=1) {
X+=0.5;
if (X < Link->X-64) {
action = 0;
}
else {
action = 1;
}
}
if (Y > Link->Y+64 && action!=1) {
Y-=0.5;
if (Y > Link->Y+64) {
action = 0;
}
else {
action = 1;
}
}
if (Y < Link->Y-64 && action!=1) {
X+=0.5;
if (Y < Link->Y-64) {
action = 0;
}
else {
action = 1;
}
}
if (action==1 && radius<=64) {
radius+=1;
}
if (action==0 && radius>=24) {
radius-=1;
}
BallKnight->X=X;
BallKnight->Y=Y;
Waitframe();
}
}
}
I should probably go through and try to comment a bit of it, but I can't be bothered. I'm too busy with other stuff to do that. Those who know how to script should be able to pick this apart though.
http://thunderspeed....nKnightDemo.zip
Edited by ThunderSpeed, 20 February 2008 - 10:04 PM.