Forum

Spawn entities in real-time

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Spawn entities in real-time

Postby JasonX » Sat Sep 07, 2013 12:16 am

Without a modified engine, is it possible to spawn entities in real-time? I'm working on a small TD mod for Q1, but i'm curious if i'm able to spawn entities (like zombies, or dogs) to attack my enemies, as well boxes and other models (to block the way).
JasonX
 
Posts: 411
Joined: Tue Apr 21, 2009 2:08 pm

Re: Spawn entities in real-time

Postby ceriux » Sat Sep 07, 2013 12:38 am

i did it. i think you just spawn a spawn entity at the position you want but only spawn the monster according to some variable.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Spawn entities in real-time

Postby leileilol » Sat Sep 07, 2013 1:15 am

You can spawn entities in real-time, it's just the precaching you can't do in real-time - because it's not really precaching if you do it post-load. So you'd have to make the precaching bit in a conditional and precache the relevant monster stuff in another init funciton.
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Spawn entities in real-time

Postby ajay » Sat Sep 07, 2013 9:57 am

User avatar
ajay
 
Posts: 559
Joined: Fri Oct 29, 2004 6:44 am
Location: Swindon, UK

Re: Spawn entities in real-time

Postby JasonX » Sat Sep 07, 2013 1:25 pm

Alright, thank you guys! Another quick question: with QC, can i grab the player view point, so i can spawn an entity where the player is looking at? Like a bullet?
JasonX
 
Posts: 411
Joined: Tue Apr 21, 2009 2:08 pm

Re: Spawn entities in real-time

Postby mankrip » Sat Sep 07, 2013 2:06 pm

JasonX wrote:Alright, thank you guys! Another quick question: with QC, can i grab the player view point, so i can spawn an entity where the player is looking at? Like a bullet?

Yes. Do a traceline, and set the new entity origin as trace_endpos:
Code: Select all
local entity myentity;
local vector org;
org = self.origin + '0 0 22';
// self must be the player
makevectors   (self.v_angle);   // calculate forward angle for velocity
traceline (org, org + v_forward*2000, TRUE, self);
myentity = spawn ();
// set model, solid and everything else before
setorigin (myentity, trace_endpos);
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Re: Spawn entities in real-time

Postby JasonX » Sun Sep 08, 2013 10:52 pm

mankrip wrote:
JasonX wrote:Alright, thank you guys! Another quick question: with QC, can i grab the player view point, so i can spawn an entity where the player is looking at? Like a bullet?

Yes. Do a traceline, and set the new entity origin as trace_endpos:
Code: Select all
local entity myentity;
local vector org;
org = self.origin + '0 0 22';
// self must be the player
makevectors   (self.v_angle);   // calculate forward angle for velocity
traceline (org, org + v_forward*2000, TRUE, self);
myentity = spawn ();
// set model, solid and everything else before
setorigin (myentity, trace_endpos);


Wow! It works perfectly. Thank you! :mrgreen:
JasonX
 
Posts: 411
Joined: Tue Apr 21, 2009 2:08 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest