CODE
//Notes for non-coders:
//suck_dist is the distance in pixels the vacuum will suck the enemy closer to Link
//dist_from_link is the range in pixels the enemy will have to be from Link for the vacuum to start sucking
item script Enemy_Vacuum
{
int suck_dist = 6;
int dist_from_link = 33;
void run()
{
npc current_enemy;
int i;
if ( Screen->NumNPCs() == 0) {
Quit();
}
for (i = 0; i < Screen->NumNPCs(); i++)
{
current_enemy = Screen->LoadNPC(i);
if ( dist(Link->X, Link->Y, current_enemy->X, current_enemy->Y) < dist_from_link )
{
if (Link->X > current_enemy->X) {
current_enemy->X -= suck_dist;
}
else if (Link->X < current_enemy->X) {
current_enemy->X += suck_dist;
}
else if (Link->X == current_enemy->X) {
Quit();
if (Link->Y > current_enemy->Y) {
current_enemy->Y -= suck_dist;
}
else if (Link->Y < current_enemy->Y) {
current_enemy->X += suck_dist;
}
else if (Link->Y == current_enemy->Y) {
Quit();
}
}
}
}
}
float dist(float x1, float y1, float x2, float y2) {
return Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
}
//suck_dist is the distance in pixels the vacuum will suck the enemy closer to Link
//dist_from_link is the range in pixels the enemy will have to be from Link for the vacuum to start sucking
item script Enemy_Vacuum
{
int suck_dist = 6;
int dist_from_link = 33;
void run()
{
npc current_enemy;
int i;
if ( Screen->NumNPCs() == 0) {
Quit();
}
for (i = 0; i < Screen->NumNPCs(); i++)
{
current_enemy = Screen->LoadNPC(i);
if ( dist(Link->X, Link->Y, current_enemy->X, current_enemy->Y) < dist_from_link )
{
if (Link->X > current_enemy->X) {
current_enemy->X -= suck_dist;
}
else if (Link->X < current_enemy->X) {
current_enemy->X += suck_dist;
}
else if (Link->X == current_enemy->X) {
Quit();
if (Link->Y > current_enemy->Y) {
current_enemy->Y -= suck_dist;
}
else if (Link->Y < current_enemy->Y) {
current_enemy->X += suck_dist;
}
else if (Link->Y == current_enemy->Y) {
Quit();
}
}
}
}
}
float dist(float x1, float y1, float x2, float y2) {
return Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
}
This is an enemy vacuum that draws enemies closer to link in a set range. (See variables at top). It compiles fine, but does absolutely nothing. I'm testing the script with it attached to wand, if that may be a factor prevent the script from working.
Does anyone have wise words of advice?
Edited by Fire Wizzrobe, 10 March 2007 - 05:31 PM.