Page 1 of 1

find() map entitites in CSQC

Posted: Sat Sep 05, 2015 3:26 pm
by toneddu2000
In FTEQW, I'm doing something like

Code: Select all

local entity e = find(world,classname,"my_spawning_point");
myentity = spawn();
setorigin(myentity ,e.origin);
myentity.origin = e.origin;
cprint(vtos(e.origin));
setmodel(myentity ,ENEMY_MODEL);
myentity .drawmask = MASK_NORMAL;
myentity .movetype = MOVETYPE_STEP;
myentity .solid = SOLID_BBOX;
myentity .predraw = EnemyPredraw;
But csqc places the entity always at 0 0 0 (also cprint said that).

I print that code in CSQC_Init, but I think that's pretty useless where I execute that

In map there's an entity my_spawning_point. Infact in SSQC it works. How is it possible to find map entities in CSQC?

Thanks in advance guyyyys!! :biggrin:

Re: find() map entitites in CSQC

Posted: Sat Sep 05, 2015 4:46 pm
by frag.machine
I don't know if it's possible to find() server-side entities in CSQC at all, but I notice that your code isn't ready to deal with invalid returns from find(). I suggest you rewrite it as:

Code: Select all

local entity spot;
spot=find(world, classname, "my_spawning_point");
if(spot!=world) {
... // place your spawning code here
}
IMHO a way to avoid the problem would be the server to push this information to the client in putclientonserver(). Not saying this is the correct or even the only way to deal with the situation tho. Let's see what Spike says.

Re: find() map entitites in CSQC

Posted: Sun Sep 06, 2015 3:17 am
by Spike
ssqc and csqc are separate and independant. entities in ssqc do not exist in csqc unless you explicitly create them (SendEntity, deltalisten, or other writes/prints/etc).

If you want to parse the maps entity section clientside, you can find an example of this in my purecsqc mod (CSQC_WorldLoaded is called once the worldmodel (and thus the entity lump / .ent file) have actually been loaded, and the qc then calls spawn.qc:SpawnEntities which does the actual work in purecsqc).

Re: find() map entitites in CSQC

Posted: Sun Sep 06, 2015 9:51 am
by toneddu2000
Thanks a lot Spike, SpawnEntities() function in CSQC_WorldLoaded did the trick! For everyone that wants to try, don't forget to copy parsenewmapentity() which actually does the parsing.
There's some sideeffect to make a pure csqc game? There's some limitation(of course talking about a single player game, obviously)?