Forum

find() map entitites in CSQC

Discuss CSQC related programming.

Moderator: InsideQC Admins

find() map entitites in CSQC

Postby toneddu2000 » Sat Sep 05, 2015 3:26 pm

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

Re: find() map entitites in CSQC

Postby frag.machine » Sat Sep 05, 2015 4:46 pm

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)
User avatar
frag.machine
 
Posts: 2063
Joined: Sat Nov 25, 2006 1:49 pm

Re: find() map entitites in CSQC

Postby Spike » Sun Sep 06, 2015 3:17 am

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).
Spike
 
Posts: 2878
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: find() map entitites in CSQC

Postby toneddu2000 » Sun Sep 06, 2015 9:51 am

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


Return to CSQC Programming

Who is online

Users browsing this forum: No registered users and 1 guest