distance enabled/disabled actors
Posted: Mon Apr 09, 2007 3:09 pm
Good Day to All!
Problem:
I have 4 actors that need to be enabled/disabled according to their
distance from the actorTarget.
I have actors1-4 out of view. Each one is created..., "Create Actor" (button down) to a specific x,y starting point. "Actor Control - Create at Start Up" is set to "No" on actors1-4.
Each actors1-4 are to be dragged and dropped pre-determined distances to the actorTarget taking turns according to how far they are from actorTarget. The actor that is the longest distance from actorTarget is to be enabled.
For Example, actor1 & actor2 are created and players 1 & 2 are taking turns to move closer to actorTarget. The following script works fine to the point in which actor1 and/or actor2 get closer to actorTarget than the remaining actors(3-4), out of view. This has me stumped because "Actor Control - Create at Start Up" is set to "No" on actors1-4.
The following script would be assigned to each actor accordingly on "Move Finish - Script Editor" and Global vars?
int d1;
int d2;
int d3;
int d4;
d1 = distance(actor1.x, actor1.y, actorTarget.x, actorTarget.y);
d2 = distance(actor2.x, actor2.y, actorTarget.x, actorTarget.y);
d3 = distance(actor3.x, actor3.y, actorTarget.x, actorTarget.y);
d4 = distance(actor4.x, actor4.y, actorTarget.x, actorTarget.y);
if (d1 >= d2 && d1 >= d3 && d1 >= d4)
{
EventEnable("actor1", EVENTALL);
EventDisable("actor2", EVENTALL);
EventDisable("actor3", EVENTALL);
EventDisable("actor4", EVENTALL);
}
else if (d1 < d2 || d1 < d3 || d1 < d4)
EventDisable("actor1", EVENTALL);
Help is most appreciated!
TIA
Rob
Problem:
I have 4 actors that need to be enabled/disabled according to their
distance from the actorTarget.
I have actors1-4 out of view. Each one is created..., "Create Actor" (button down) to a specific x,y starting point. "Actor Control - Create at Start Up" is set to "No" on actors1-4.
Each actors1-4 are to be dragged and dropped pre-determined distances to the actorTarget taking turns according to how far they are from actorTarget. The actor that is the longest distance from actorTarget is to be enabled.
For Example, actor1 & actor2 are created and players 1 & 2 are taking turns to move closer to actorTarget. The following script works fine to the point in which actor1 and/or actor2 get closer to actorTarget than the remaining actors(3-4), out of view. This has me stumped because "Actor Control - Create at Start Up" is set to "No" on actors1-4.
The following script would be assigned to each actor accordingly on "Move Finish - Script Editor" and Global vars?
int d1;
int d2;
int d3;
int d4;
d1 = distance(actor1.x, actor1.y, actorTarget.x, actorTarget.y);
d2 = distance(actor2.x, actor2.y, actorTarget.x, actorTarget.y);
d3 = distance(actor3.x, actor3.y, actorTarget.x, actorTarget.y);
d4 = distance(actor4.x, actor4.y, actorTarget.x, actorTarget.y);
if (d1 >= d2 && d1 >= d3 && d1 >= d4)
{
EventEnable("actor1", EVENTALL);
EventDisable("actor2", EVENTALL);
EventDisable("actor3", EVENTALL);
EventDisable("actor4", EVENTALL);
}
else if (d1 < d2 || d1 < d3 || d1 < d4)
EventDisable("actor1", EVENTALL);
Help is most appreciated!
TIA
Rob