Page 1 of 1

distance enabled/disabled actors

PostPosted: Mon Apr 09, 2007 3:09 pm
by rconnor
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

PostPosted: Mon Apr 09, 2007 6:36 pm
by Sgt. Sparky
the draw actor event would work best for that,
but I am really confused about what you are trying to do and what you are having a problem with.

I think distance is read only,
but if it is working, great!
:)

is there any other way you can type this out so I can understand your problem better? :D

re:

PostPosted: Mon Apr 09, 2007 8:52 pm
by rconnor
Hey Sarge,

Yeah, it works. Let’s say I’m creating a multi-player golf game. Up to 4 players can play at once, taking turns. Only the actor/player who is the greatest distance away from the flag/pin should be enabled. Here’s the rub. If there are only 3 players playing, actor4 is a factor in the game play even when it has not yet been created. Which means that it disables all actors/players who are closer to the flag/pin.

This has me stumped because "Actor Control - Create at Start Up" is set to "No” on all the actors including actor4.

Whew! Hope that makes sense!

PostPosted: Mon Apr 09, 2007 9:04 pm
by Sgt. Sparky
okay,
you must use
Code: Select all
if(ActorCount("Player_4") == 1)
{
   ExecuteAction;
}


or you must use
Code: Select all
if(ActorCount("Player_4") == 1)ExecuteAction;

:D
I hope that helps :)

Re: re:

PostPosted: Mon Apr 09, 2007 10:44 pm
by makslane
rconnor wrote:If there are only 3 players playing, actor4 is a factor in the game play even when it has not yet been created.


May be a bug. Can you send me the game?

PostPosted: Tue Apr 10, 2007 1:57 pm
by rconnor
Thanks Sarge. I'll give it a try after Makslane takes a look at it.