Page 1 of 1

What repercussions for this work around?

PostPosted: Sun Jun 30, 2013 5:15 pm
by Grynde
I have been struggling with clones.

After reading this threadhttp://game-editor.com/forum/viewtopic.php?f=27&t=12650.

And using the following:
Code: Select all
if ( distance(Player.x, Player.y, Enemy.x, Enemy.y)<=someDistance) {
    //do Stuff
                                                                  }

I ran into the obvious problem that the x,y position goes of clone.0. However I have a slew of cloned mobs and couldn't find a workable workaround for my skill.

However, I noticed that if I used this instead, I have the enemy doing what I want.
Code: Select all
if ( distance(Player.x, Player.y, Enemy.x, Enemy.y)>=someDistance) {
    //do Stuff
                                                                  }

With it continuously checking against the greater than value of the original enemy the other clones shoot like I want, but I am aware that what I'm doing is not correct.
What are the long term ramifications for doing such?

Re: What repercussions for this work around?

PostPosted: Sun Jun 30, 2013 10:59 pm
by AliceXIII
Are you calling this code on the enemy?

If so just assign the enemies x and y:
Code: Select all
distance(Player.x, Player.y, Enemy.x, Enemy.y); \\ instead of Enemy.x/y just do x and y


Because if your enemy is initiating the search for whether the player is close to them which it should then you would already have each clone independently searching whether it's within a certain distance of the player just instead of specifying Enemy.x which won't return the desired result with clones use a plain x or y.

Hierarchy of clones:

Enemy.1 -> Draw Event -> Script Event -> "check distance"
Enemy.2 -> Draw Event -> Script Event -> "check distance"

Enemy.1 and Enemy.2 know what actors they are when calling what is the same code but on a different clone so using a normal x and y would work because the clones effectively know which clone is calling what code at said time.

I believe this is what your looking for although I'm not a 100% sure.

Re: What repercussions for this work around?

PostPosted: Mon Jul 01, 2013 1:29 am
by Grynde
AliceXIII wrote:Are you calling this code on the enemy?

If so just assign the enemies x and y:
Code: Select all
distance(Player.x, Player.y, Enemy.x, Enemy.y); \\ instead of Enemy.x/y just do x and y


Because if your enemy is initiating the search for whether the player is close to them which it should then you would already have each clone independently searching whether it's within a certain distance of the player just instead of specifying Enemy.x which won't return the desired result with clones use a plain x or y.

Hierarchy of clones:

Enemy.1 -> Draw Event -> Script Event -> "check distance"
Enemy.2 -> Draw Event -> Script Event -> "check distance"

Enemy.1 and Enemy.2 know what actors they are when calling what is the same code but on a different clone so using a normal x and y would work because the clones effectively know which clone is calling what code at said time.

I believe this is what your looking for although I'm not a 100% sure.

I am calling this on the enemy. Thanks Alice XIII, that makes sense. I new I was doing it a goofy way.

Re: What repercussions for this work around?

PostPosted: Mon Jul 01, 2013 1:45 am
by AliceXIII
Works well now?