Spawn monsters on command
Spawn monsters on command
Let's say I wanted to make a gun that spawned monsters. Would I just spawn a new entity, just like spawning a shot entity, then call the 'monster_bla' function for it? Where are those functions, and what is the syntax for calling them in that context?
-
hondobondo
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
- Contact:
Re: Spawn monsters on command
EMR wrote:Let's say I wanted to make a gun that spawned monsters. Would I just spawn a new entity, just like spawning a shot entity, then call the 'monster_bla' function for it? Where are those functions, and what is the syntax for calling them in that context?
Code: Select all
local entity new,temp;
new = spawn();
setorigin(new,SOMEORIGIN);
temp = self;
self = new;
monster_knight();
spawn_tfog (self.origin);
spawn_tdeath (self.origin,self);
new = self;
self = temp;
you can set the velocity beforehand like any projectile, but don't set avelocity. use the grenade launcher code. if you want to do that you can set the model for the grenade, and then just set the think to the monster_knight function
Code: Select all
self.think = monster_knight;
self.nextthink = time + 1;
You should also set the classname, like
self.classname = "monster_knight";
monster_knight();
Because otherwise the classname will be blank, and some gameplay behaviours are dependent on classname (e.g. sightsounds iirc)
self.classname = "monster_knight";
monster_knight();
Because otherwise the classname will be blank, and some gameplay behaviours are dependent on classname (e.g. sightsounds iirc)
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.
-
frag.machine
- Posts: 2126
- Joined: Sat Nov 25, 2006 1:49 pm
To use Sajt's approach you'll need to make sure all required models were previously precached by your code, not the regular monster code. Actually, you'll need to change existing code to not try to precache any model or sound during game execution (this leads to a fatal error in most if not all engines). One easy way to do this is replacing precache_model and precache_sound builtin references in defs.h like this:
And use some QuakeC wrappers to deal with:
Code: Select all
// void (string s) precache_model = ...
void (string s) __precache_model = ...
Code: Select all
void (string s) precache_model = {
if (time < 3) { // silently prevent precaches beyond the very initial seconds
__precache_model (s);
}
};
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-
hondobondo
- Posts: 207
- Joined: Tue Sep 26, 2006 2:48 am
- Contact:
oh yeah. or you could precache in world.qcfrag.machine wrote:To use Sajt's approach you'll need to make sure all required models were previously precached by your code, not the regular monster code. Actually, you'll need to change existing code to not try to precache any model or sound during game execution (this leads to a fatal error in most if not all engines). One easy way to do this is replacing precache_model and precache_sound builtin references in defs.h like this:And use some QuakeC wrappers to deal with:Code: Select all
// void (string s) precache_model = ... void (string s) __precache_model = ...Code: Select all
void (string s) precache_model = { if (time < 3) { // silently prevent precaches beyond the very initial seconds __precache_model (s); } };
so i was wanting to do something similar... but what i want to do is call a traceline and at the end of that traceline spawn a monster...
thing is i still dont understand traceline at all... i was looking in defs but i think the only thing i know i have to use is trace_endpos
any idea where i can start? (i think the code above shows for something like the grenade launcher?)
maybe add some comments if its not too far out of the way of what each of the lines do? cause traceline confuses me pretty bad.
thing is i still dont understand traceline at all... i was looking in defs but i think the only thing i know i have to use is trace_endpos
any idea where i can start? (i think the code above shows for something like the grenade launcher?)
maybe add some comments if its not too far out of the way of what each of the lines do? cause traceline confuses me pretty bad.
hope this helps..
Start by looking in weapons.qc at void() W_FireAxe.
you'll see that the start vector used in the traceline
is based on your position:
and the vector used for the end position is as well
(its 64 units past the start vector along v_forward which is straight
ahead of the player)
after you've called a traceline things like trace_endpos (the
location where your line is interrupted ) and
trace_ent (the entity hit if any) are available for you to use
local to the function you called it in.
and as always keep this or the pdf version handy
http://www.gamers.org/dEngine/quake/Qc/qc-built.htm
you'll see that the start vector used in the traceline
is based on your position:
Code: Select all
source = self.origin + '0 0 16';
(its 64 units past the start vector along v_forward which is straight
ahead of the player)
after you've called a traceline things like trace_endpos (the
location where your line is interrupted ) and
trace_ent (the entity hit if any) are available for you to use
local to the function you called it in.
and as always keep this or the pdf version handy
http://www.gamers.org/dEngine/quake/Qc/qc-built.htm
Just using traceline can cause all sorts of trouble; you could spawn monsters into a wall, for instance. You need to take account of the monster bounding box size when you spawn them, and make sure it doesn't interact with the map or any other objects in the game. So trace a line, take the endpos, and then from there trace the size of the bounding box. I think there's a function lurking in the frikbot code to do this but I don't remember what it is offhand.
-
Mexicouger
- Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
- Contact:
-
Mexicouger
- Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
- Contact: