Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,561 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Following one entity with another #260943
04/14/09 20:29
04/14/09 20:29
Joined: Mar 2009
Posts: 23
S
Siegewolf Offline OP
Newbie
Siegewolf  Offline OP
Newbie
S

Joined: Mar 2009
Posts: 23
I have a bit of a general problem (I am still new to lite C). Suppose I have code as below; In follower_action, how to make the follower's coordinates always be the same as that of the entity which was passed to add_follower?

Code:
action follower_action()
{
	while(1)
	{
		me.x = ?;
		me.y = ?;
		me.z = ?;
		
		wait(1);
	}
}

function add_follower(ENTITY* ent)
{
	ENTITY* follower = ent_create(... ,follower_action);
}


Last edited by Siegewolf; 04/14/09 20:30.
Re: Following one entity with another [Re: Siegewolf] #260945
04/14/09 20:53
04/14/09 20:53
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
As i remember, you pointer in created entity points to the parent.
so,

Code:
while(1)
{
me.x = you.x;
me.y = you.y;
me.z = you.z;
wait(1);
}


or, the shorter variant
Code:
while(1)
{
vec_set(me.x,you.x);
wait(1);
}



1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Following one entity with another [Re: Siegewolf] #260946
04/14/09 20:56
04/14/09 20:56
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
Ralph Offline
Senior Member
Ralph  Offline
Senior Member

Joined: Feb 2006
Posts: 385
Oldenburg,Germany
Try this:
Code:
action follower_action()
{
        ENTITY* ent = ptr_for_handle(my.skill10);
	while(1)
	{
		vec_set(my.x,ent.x);	
		wait(1);
	}
}

function add_follower(ENTITY* ent)
{
	ENTITY* follower = ent_create(... ,follower_action);
        if(ent != NULL)follower.skill10 = handle(ent);
}


EDIT:
I never heard about that...

Last edited by Ralph; 04/14/09 21:07.
Re: Following one entity with another [Re: Ralph] #260947
04/14/09 20:58
04/14/09 20:58
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Ralph, you may odmit that skill40 may not be used anymore smile


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Following one entity with another [Re: Ralph] #261111
04/15/09 21:34
04/15/09 21:34
Joined: Mar 2009
Posts: 23
S
Siegewolf Offline OP
Newbie
Siegewolf  Offline OP
Newbie
S

Joined: Mar 2009
Posts: 23
Originally Posted By: Ralph
Try this:


The code exactly as you wrote it does not work for me (it is not following), but if I put ENTITY* ent = ptr_for_handle(my.skill10); within the loop, as below, it does work. I have no clue why is this happening. Any explanation?

Code:
action follower_action()
{
	while(1)
	{
		ENTITY* ent = ptr_for_handle(my.skill10);
		vec_set(my.x,ent.x);	
		wait(1);
	}
}


Re: Following one entity with another [Re: Siegewolf] #261124
04/15/09 22:31
04/15/09 22:31
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Could be because follower action is starting "too" quickly, before my is finished being created.
Try this.
Code:
action follower_action()
{
	wait(1);
	ENTITY* ent = ptr_for_handle(my.skill10);
	while(1)
	{
		vec_set(my.x,ent.x);	
		wait(1);
	}
}



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Following one entity with another [Re: EvilSOB] #261302
04/16/09 20:24
04/16/09 20:24
Joined: Mar 2009
Posts: 23
S
Siegewolf Offline OP
Newbie
Siegewolf  Offline OP
Newbie
S

Joined: Mar 2009
Posts: 23
Originally Posted By: EvilSOB
Could be because follower action is starting "too" quickly, before my is finished being created.
Try this.


Thanks EvilSOB, that works.

Now I must know when entity is destroyed to stop setting position of follower. I wrote something like this:

Code:
action follower_action()
{
        wait(1);
        while(1)
        {
                ENTITY* ent = ptr_for_handle(my.skill10);
                if (ent != NULL)
                    vec_set(my.x,ent.x);
                wait(1);
        }
}


If new entity appears in the meantime after current one is destroyed, follower jumps on that new entity as if handle has been reassigned to new entity. How can I positively detect that the original entity has been destroyed?

Re: Following one entity with another [Re: Siegewolf] #261365
04/17/09 07:30
04/17/09 07:30
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Easy, use this, it what I understand you to be after.
Code:
action follower_action()
{
        wait(1);
        ENTITY* ent = ptr_for_handle(my.skill10);
        while(ent)
        {
                vec_set(my.x,ent.x);
                wait(1);
                if(ent != ptr_for_handle(my.skill10))     ent = NULL;
        }
}



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Following one entity with another [Re: EvilSOB] #261583
04/18/09 18:04
04/18/09 18:04
Joined: Mar 2009
Posts: 23
S
Siegewolf Offline OP
Newbie
Siegewolf  Offline OP
Newbie
S

Joined: Mar 2009
Posts: 23
Originally Posted By: EvilSOB
Easy, use this, it what I understand you to be after.


Yup, this is it! Thanks a lot EvilSOB.

***

Thanks everyone for the help so far!

Re: Following one entity with another [Re: Siegewolf] #261595
04/18/09 19:27
04/18/09 19:27
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
anytime


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1