|
2 registered members (Grant, AndrewAMD),
911
guests, and 9
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Perfect copy of an entity
[Re: Vinous_Beret]
#328168
06/10/10 19:52
06/10/10 19:52
|
Joined: Sep 2009
Posts: 987 Budapest
Aku_Aku
OP
User
|
OP
User
Joined: Sep 2009
Posts: 987
Budapest
|
The manual doesn't write this function duplicates the entity. Will be good to do that for? What/Where will be the pointer of the new entity?
Last edited by Aku_Aku; 06/10/10 19:56. Reason: one more question
|
|
|
Re: Perfect copy of an entity
[Re: Vinous_Beret]
#328173
06/10/10 20:21
06/10/10 20:21
|
Joined: Sep 2009
Posts: 987 Budapest
Aku_Aku
OP
User
|
OP
User
Joined: Sep 2009
Posts: 987
Budapest
|
You know, i have my own solution. I create the entity, set its attributes etc. Later, when it needs, i create a new one, with loading from disk again and set everything again. And, i change those attributes what i need.
But i am searching for an elegant way to do this process. Perhaps no loading again from disk, no copying all the attributes and so on...
Last edited by Aku_Aku; 06/10/10 20:21.
|
|
|
Re: Perfect copy of an entity
[Re: Aku_Aku]
#328176
06/10/10 20:26
06/10/10 20:26
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Beret, ent_clone is needed, but it doesnt actually DO the cloning process. Aku, there is no built-in function for duplicating an entity, you'll need to write your own. This SHOULD do the job though... (Untested Lite-C, Im typing out of my head here... I cant help with c-script though.)
...
// duplicates entity called "me" into a new entity stored in "you"
// duplicates EVERYTHING except the source entities action
you = ent_create(me.type, nullvector, NULL);
memcpy(&you.scale_x, &me.scale_x, sizeof(ENTITY)-(sizeof(C_LINK)+sizeof(var)));
ent_clone(you);
...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|