Inside3D!
     

world.qc
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Tue Nov 06, 2007 3:47 am    Post subject: world.qc Reply with quote

Guys, I'm trying to get creatures to spawn when new maps load.
I put 3 creature creating functions in WorldSpawn().
Problem is the creatures spawn in the same spot, and the 3rd seems to get stuck in the ceiling. They are actually stacked up when they spawn.
My question is, how can I put a time delay between the functions?
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Tue Nov 06, 2007 7:33 am    Post subject: Reply with quote

There are multiple ways of doing it. The best way in your case would be to spawn an entity, which has a delayed nextthink, and a think function which sets all the different parameters to make it a solid monster, much like the way respawning items is handled, where they are not actually removed, they are just invisible
_________________
Look out for Twigboy
Back to top
View user's profile Send private message Visit poster's website
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Tue Nov 06, 2007 8:19 am    Post subject: Reply with quote

I hope you weren't just calling entity spawn functions (e.g. monster_dog)...

If so, this is what you should be doing:

Code:
local entity oldself;

...

oldself = self;

self = spawn ();
self.classname = "monster_dog";
self.origin = '1 2 3';
monster_dog ();

self = spawn ();
self.classname = "monster_dog";
self.origin = '4 5 6';
monster_dog ();

self = spawn ();
self.classname = "monster_dog";
self.origin = '7 8 9';
monster_dog ();

self = oldself;

_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
Nash



Joined: 19 Oct 2007
Posts: 95
Location: Kuala Lumpur, Malaysia

PostPosted: Tue Nov 06, 2007 9:35 am    Post subject: Reply with quote

Interesting, Sajt. I'd think that simply calling the monster function would work.

Can you explain why this has to be done?
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Preach



Joined: 25 Nov 2004
Posts: 122

PostPosted: Tue Nov 06, 2007 9:57 am    Post subject: Reply with quote

Nash wrote:
Interesting, Sajt. I'd think that simply calling the monster function would work.

Can you explain why this has to be done?


Because the monster_dog function is intended to be run on an entity that's already listed in the entity section of a map. When the map is loaded, the engine runs through each of the entries in the bsp. It then creates a blank entry, adds all the fields that have been set by the mapper, then runs the function with the same name as the specified classname. So the origin and classname are assumed to have been set already, otherwise it wouldn't have been added to the map.
Back to top
View user's profile Send private message
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Tue Nov 06, 2007 9:58 am    Post subject: Reply with quote

When the engine loads the map, it looks at each entity and spawns it - basically just like calling spawn(), which spawns a blank entity. Then it loads all the key/value pairs out of the map file, which includes classname (string field), origin, angles, etc. Then it searches for a QC function with the same name as the classname and calls it, with 'self' set to the newly spawned entity.

The QC spawn functions (e.g. monster_dog) are just regular functions that work with an entity (self) that has already been spawned, and has some fields already set (classname, origin, etc.)

edit:
Curse you Preach. Now my post is useless. I shall attempt to give it something worthwhile:

It's a frog.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Tue Nov 06, 2007 4:32 pm    Post subject: Reply with quote

of course you must not call any of the precache functions outside of the initial level spawn, so if you intend to spawn the entities after a certain amount of time, move their precaches to some other function - e.g. worldspawn.
_________________
Back to top
View user's profile Send private message Send e-mail
Nash



Joined: 19 Oct 2007
Posts: 95
Location: Kuala Lumpur, Malaysia

PostPosted: Tue Nov 06, 2007 4:58 pm    Post subject: Reply with quote

Thanks for your explanations, Sajt and Preach. That makes sense.

(Yuck I hate frogs)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
RenegadeC



Joined: 15 Oct 2004
Posts: 370
Location: The freezing hell; Canada

PostPosted: Tue Nov 06, 2007 5:05 pm    Post subject: Reply with quote

Sajt wrote:




Why is this frog red?
Back to top
View user's profile Send private message AIM Address MSN Messenger
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Tue Nov 06, 2007 5:36 pm    Post subject: Reply with quote

Why is the sky black?
Back to top
View user's profile Send private message Send e-mail
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Tue Nov 06, 2007 5:36 pm    Post subject: Reply with quote

Nash wrote:
Thanks for your explanations, Sajt and Preach. That makes sense.

(Yuck I hate frogs)


no thanks for me?
Back to top
View user's profile Send private message Send e-mail
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Tue Nov 06, 2007 9:29 pm    Post subject: Reply with quote

FrikaC got hosed!
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
Nash



Joined: 19 Oct 2007
Posts: 95
Location: Kuala Lumpur, Malaysia

PostPosted: Wed Nov 07, 2007 1:32 am    Post subject: Reply with quote

Er, no I guess because your post doesn't look like it was answering my question.

(omg your signature is randomized lololol)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Wed Nov 07, 2007 2:14 am    Post subject: Reply with quote

RenegadeC wrote:
Sajt wrote:




Why is this frog red?


Cheese grater.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Wed Nov 07, 2007 8:11 am    Post subject: Reply with quote

Nash wrote:
Er, no I guess because your post doesn't look like it was answering my question.


I'd say he did point out something important though...
_________________
Look out for Twigboy
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group