find() map entitites in CSQC

Discuss CSQC related programming.
Post Reply
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

find() map entitites in CSQC

Post 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:
Meadow Fun!! - my first commercial game, made with FTEQW game engine
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: find() map entitites in CSQC

Post 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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: find() map entitites in CSQC

Post 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).
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: find() map entitites in CSQC

Post 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)?
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Post Reply