#include <litec.h>
#include <default.c>
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);
}
action rotater()
{
my.skill99 = (void*)rotater;
while(1)
{
my.pan += time_step * 5;
wait(1);
}
}
function main()
{
wait(5); level_load(NULL); wait(5); camera.x = -130;
//
me = ent_create(CUBE_MDL, vector(0,50,0), rotater);
me.skill10 = str_create("testing");
wait(2);
printf("source.skill10 = \'%s\'", _chr((STRING*)my.skill10));
wait(-2);
you = ent_duplicate(me); you.y = -50;
wait(2);
printf("cloned.skill10 = \'%s\'", _chr((STRING*)you.skill10));
wait(-2);
you.skill10 = str_create("something new");
printf("cloned.skill10 reset to = \'%s\'", _chr((STRING*)you.skill10));
wait(2);
printf("source.skill10 still = \'%s\'", _chr((STRING*)me.skill10));
}