Gamestudio Links
Zorro Links
Newest Posts
FXCM => AVA Trade Plugin???
by Martin_HH. 11/25/26 21:59
No connection to MT4
by Martin_HH. 11/23/26 06:38
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
contractUpdate() is filtering if >2 rows
by mistery. 11/09/26 12:06
New Zorro version 3.15
by jcl. 11/09/26 09:24
Removing outliers from files
by jcl. 11/04/26 10:30
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 9,630 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 4 1 2 3 4
Re: Perfect copy of an entity [Re: Superku] #328177
06/10/10 20:33
06/10/10 20:33
Joined: Sep 2009
Posts: 1,035
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,035
Budapest
Quote:
As you want to have two unique objects with the same attributes, there is always going to be some process of copying.

I knew, but if it is possible, i would save as much coding as possible.
Quote:
When you use ent_create and the entity is already in your level, ent_create does not load from hard disk.

This is good news.

Re: Perfect copy of an entity [Re: EvilSOB] #328179
06/10/10 20:38
06/10/10 20:38
Joined: Sep 2009
Posts: 1,035
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,035
Budapest
Code:
you = ent_create(me.type, nullvector, NULL);


According to the manual the first parameter of the ent_create() function is STRING* filename. Please explain to me how and why will work with me.type.
Can i instance the new entity with a function name instead of NULL?

Re: Perfect copy of an entity [Re: Aku_Aku] #328181
06/10/10 20:46
06/10/10 20:46
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
(Assuming you are using lite-c...)

When you create an entity the filename of the model/sprite is stored in the 'type' property.
ie :: me = ent_create("sphere.mdl", ....); //now me.type=="sphere.mdl"
so by saying ent_create(me.type, ....);, you are using the same model as 'me' has...

And, yes, you can assign an action to the entity, but I dont know of any way to find out
what action is assigned to the source entity. In theory there can be more than one...




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Perfect copy of an entity [Re: Superku] #328182
06/10/10 20:47
06/10/10 20:47
Joined: Sep 2009
Posts: 1,035
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,035
Budapest
Quote:
When you use ent_create and the entity is already in your level, ent_create does not load from hard disk.

3D GS uses a cache technology to do that?
Is there a threshold for that? Perhaps it is able to cache 1000 entities?
It could happen i'll use more than 2000 objects.

Re: Perfect copy of an entity [Re: EvilSOB] #328185
06/10/10 20:54
06/10/10 20:54
Joined: Sep 2009
Posts: 1,035
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,035
Budapest
Quote:
When you create an entity the filename of the model/sprite is stored in the 'type' property.

That is half solution for me, but i appreciate that.
I use alternate paths to load entities. Fortunately i stored the needful info of that.

Quote:
And, yes, you can assign an action to the entity, but I dont know of any way to find out
what action is assigned to the source entity. In theory there can be more than one...

That could cause some problems. If i have two identical entities with differing functions, ent1-func1, ent2-func2. How can i guess out which function have to use?

Yes, i use lite-C.


Last edited by Aku_Aku; 06/10/10 20:55.
Re: Perfect copy of an entity [Re: Aku_Aku] #328187
06/10/10 20:58
06/10/10 20:58
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Originally Posted By: myself
Don't think too complicated, f.i. you could set some skill to a specified value that indicates its action.


The watched entity displays its functions, so there is some way to retrieve them without skills.

Last edited by Superku; 06/10/10 20:58.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Perfect copy of an entity [Re: Aku_Aku] #328188
06/10/10 20:58
06/10/10 20:58
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Pick an un-used entity skill to store some form of "reference number" to your action.
So when you load an entity, its action stores an identification number in the skill.

Then when you do the entity-duplication, look to that number to know what action is attached...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Perfect copy of an entity [Re: EvilSOB] #328193
06/10/10 21:32
06/10/10 21:32
Joined: Sep 2009
Posts: 1,035
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,035
Budapest
Thanks Superku and EvilSOB for the advices.
So there isn't elegant way.

Last edited by Aku_Aku; 06/10/10 21:32.
Re: Perfect copy of an entity [Re: Aku_Aku] #328203
06/10/10 22:23
06/10/10 22:23
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
The problem is how to determine the action of the entity. The only way to have a control over it without adding superfluous stuff like assigning (by yourself) numbers for action indication is assigning a function to the my.event of an event and setting ENABLE_FRAME.

This way you can duplicate the entity easily:

Code:
ENTITY* createEntity (char* filename, VECTOR* position, void* fnc)
{
   ENTITY* ent = ent_create(filename, position, NULL);

   ent->emask |= ENABLE_FRAME;
   ent->event = fnc;

   return(ent);
}

ENTITY* duplicate (ENTITY* src)
{
   // Duplicate model
   ENTITY* clone = ent_create(src->type, src->x, NULL);

   // Assign event function
   clone->event = src->event;
   clone->emask |= ENABLE_FRAME;
   
   // Copy attributes
   {
      vec_set(clone->pan, src->pan); // Orientation
      vec_set(clone->scale_x, src->scale_x); // Scale
      //... and the rest
   }
   
   return(clone);
}



This way, you can't work with wait(1) but this is a low price for this neat and self-build feature!

Re: Perfect copy of an entity [Re: HeelX] #328218
06/11/10 02:01
06/11/10 02:01
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
If you're still interested Aku, here is an ALMOST elegant way of doing it...
Complete duplication, including "prime" action, and its fully tested too.
Code:
action MyAction()
{
	my.skill99 = (void*)MyAction;
	...
}

action YourAction()
{
	my.skill99 = (void*)YourAction;
	...
}

ENTITY* ent_duplicate(ENTITY* source_ent)
{
	ENTITY* target_ent = ent_create(source_ent.type, 0, (void*)source_ent.skill99);
	memcpy(&target_ent.x, &source_ent.x, sizeof(ENTITY)-(sizeof(C_LINK)+sizeof(var)));
	//	ent_clone(target_ent);	//if required
	return(target_ent);
}




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

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