endless enemy spawn
Moderator: InsideQC Admins
26 posts
• Page 1 of 2 • 1, 2
endless enemy spawn
how would I make an endless enemy spawn?
edit: forgot about zombie thing my idea worked
edit: forgot about zombie thing my idea worked
-

Hazematman - Posts: 54
- Joined: Thu Jul 15, 2010 1:58 am
- Location: Canada
You solved your problem? Please share how you did it.
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
- Spirit
- Posts: 1031
- Joined: Sat Nov 20, 2004 9:00 pm
Well I only solved half my problem. I'm trying to make a small mod where you fight and endless onslaught of zombies. I manged to make it so you did not need to use a rocket to kill zombies, by removing zombie_pain from zombie.qc, but now I need to make a zombie spawn that sends a new zombie after the last one died. Which I am completely lost at doing, so it would be of great help if someone could point me in the right direction for doing this.
edit: After looking through some of the qc files and seeing how the player re spawns I figured out I would need to call a function inside zombie_die(edit: Or I would call a function at the end saying something like "if the zombie is dead, re spawn") that would spawn the zombie, the thing is I don't know what this function is, could someone please help me with this?
edit: After looking through some of the qc files and seeing how the player re spawns I figured out I would need to call a function inside zombie_die(edit: Or I would call a function at the end saying something like "if the zombie is dead, re spawn") that would spawn the zombie, the thing is I don't know what this function is, could someone please help me with this?
-

Hazematman - Posts: 54
- Joined: Thu Jul 15, 2010 1:58 am
- Location: Canada
The problem is a bit more complicated than this.
What you need is an entity that spawns another entity (the zombie), and keep checking if it stills alive. If is dead, then spawn another one, and repeat.
What you need is an entity that spawns another entity (the zombie), and keep checking if it stills alive. If is dead, then spawn another one, and repeat.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Ok so I'm not very good with qc right now so it would help a lot if you guys tell me what the names of the functions I need to put in but right now I'm guessing I'm going to have to do something like this:
and I would put this at the bottom of zombie.qc.
- Code: Select all
if(self.health <= 0) // or if(zombie_die == true) something like that :)
{
create monster_zombie entity where the last one was();
}
and I would put this at the bottom of zombie.qc.
-

Hazematman - Posts: 54
- Joined: Thu Jul 15, 2010 1:58 am
- Location: Canada
No exactly. Ok, let's start from start.
What you need is to create a new map entity that works pretty much like the info_player_start: it's something that you put in a map to tell Quake "I want to spawn zombies in this place".
This thing (let's call it "info_zombie_start" to make things easier) will work in the following way:
1) when spawned, the first thing it does is precache all models and sounds used by the zombie;
2) we want to spawn a new zombie once ours is killed, so we need to track it. To do this, we can either create a specific field in the entity structure (for example, ".entity myzombie;" at the end of defs.qc) or reuse one of the already existing .entity fields. Since our info_zombie_start is not a monster, it won't have enemies, so we can reuse the .enemy field (and save a couple bytes);
3) we need to set a "think" function to the info_zombie_start to check, every fews seconds, if the zombie pointed by .enemy is dead:
If that's the case, we create a new entity, set its origin to the info_zombie_start origin (plus a bit in the z axis so the zombie don't get stuck in ground) and we can repeat the initialization steps that you can see in zombie.qc (setmodel, setsize, etc). Then, we store a reference to the new zombie into our .enemy field, and we can schedule our return to the checking loop above.
There are a lot more of details, but this covers the main idea.
What you need is to create a new map entity that works pretty much like the info_player_start: it's something that you put in a map to tell Quake "I want to spawn zombies in this place".
This thing (let's call it "info_zombie_start" to make things easier) will work in the following way:
1) when spawned, the first thing it does is precache all models and sounds used by the zombie;
2) we want to spawn a new zombie once ours is killed, so we need to track it. To do this, we can either create a specific field in the entity structure (for example, ".entity myzombie;" at the end of defs.qc) or reuse one of the already existing .entity fields. Since our info_zombie_start is not a monster, it won't have enemies, so we can reuse the .enemy field (and save a couple bytes);
3) we need to set a "think" function to the info_zombie_start to check, every fews seconds, if the zombie pointed by .enemy is dead:
- Code: Select all
if (self.enemy.health <= 0)
If that's the case, we create a new entity, set its origin to the info_zombie_start origin (plus a bit in the z axis so the zombie don't get stuck in ground) and we can repeat the initialization steps that you can see in zombie.qc (setmodel, setsize, etc). Then, we store a reference to the new zombie into our .enemy field, and we can schedule our return to the checking loop above.
There are a lot more of details, but this covers the main idea.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
I did something similar, except I made a projectile spawn at a certain point. I made an entity called misc_marion, and it spawned a projectile every few seconds using think and nextthink. It is fairly easy to do.
My code was as easy as something like this(To spawn the actual thing that Shot the projectile. It is invisible of course)
He pretty much removes himself every second, and thus refreshes his thinking on shooting the projectile. Works fairly well.
My code was as easy as something like this(To spawn the actual thing that Shot the projectile. It is invisible of course)
- Code: Select all
void() misc_marion =
{
local entity mario;
mario = spawn();
mario.solid = SOLID_SLIDEBOX;
mario.movetype = MOVETYPE_NONE;
mario.classname = "Mario";
setsize (mario, '-25 -25 -10', '25 25 50');
setorigin (mario, self.origin);
mario.think = W_FireMario && SUB_Remove;
mario.nextthink = (time + 1);
};
He pretty much removes himself every second, and thus refreshes his thinking on shooting the projectile. Works fairly well.
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
In the case of the zombie, you'd see a head morphing back to the full zombie corpse, which would look weird. 
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Especially if you have the head float up a bit and spawn a few gibs from random directions that get pulled into the head before you spawn the teleport fog. >=D
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
I wanted something like this myself, so I am working on a code for it.
So far, I have the monster spawn 5 seconds after the enemy dies. But he spawns right where the monster Dies.
I have the code split into fragments. I made an object that you spawn in worldcraft to precache the monster. The entity deletes itself in a second, and the monster spawns in 5. If you want this code, I will gladly share it with you. Otherwise, I am working on making the monster spawn at an appointed spawn point
So far, I have the monster spawn 5 seconds after the enemy dies. But he spawns right where the monster Dies.
I have the code split into fragments. I made an object that you spawn in worldcraft to precache the monster. The entity deletes itself in a second, and the monster spawns in 5. If you want this code, I will gladly share it with you. Otherwise, I am working on making the monster spawn at an appointed spawn point
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
Hazematman wrote:Thanks Mexicouger, I would love to see that code, maybe I could learn some stuff from it.
I am not sure what messy code is considered, but I feel like my code isn't the most efficient it can be. I'll work on it. The problem I am having right now, is that the monster doesn't spawn at it's appointed spawn point, He spawns at '0 0 0', But he faithfully respawns.
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
26 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest

