Fill levels with zombie.

Discuss programming in the QuakeC language.
Post Reply
IHateThisMap
Posts: 14
Joined: Wed Mar 18, 2009 2:34 am
Location: Quake, ID, B-Movies, Comic

Fill levels with zombie.

Post by IHateThisMap »

So I have been working on this for over a week now and I'm finally giving up on trying figuring it out on my own. I Know that a person who just asks how to do everything without trying to figure it out on their own first is bothersome at best, but I still I'm really new to coding.

I want to know how to make monsters spawn until a certain number of them is reached, and then if one was killed it would be replaced. I will spare you my code on how I attempts to do this. Let’s just say it didn't work. Any info will do but the more specific you can be the better, I'm kind of stupid.

Thank for your time.
Last edited by IHateThisMap on Wed Mar 25, 2009 9:05 pm, edited 1 time in total.
Electro
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia
Contact:

Post by Electro »

are they for your maps? (can you place specific entities to have them spawn from?)
Benjamin Darling
http://www.bendarling.net/

Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
IHateThisMap
Posts: 14
Joined: Wed Mar 18, 2009 2:34 am
Location: Quake, ID, B-Movies, Comic

Post by IHateThisMap »

Electro wrote:are they for your maps? (can you place specific entities to have them spawn from?)
No, not really. Right now I just want to remove the monsters in the game and replace them with zombies. I have allready done this my modifying the random monsters tutorial. I just need them to respawn utlll a certen number.

An example might help, if you know of another mod that did something like what I want. One I found was Qoetia who respawned monsters if the skill was set to nightmare. I found this code to complicated thought when reading it and couldn't really apply it like I wanted.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

Rune mods spawn runes in random locations. You might want to look there for inspiration.

One method I used a while ago for something entirely unrelated to zombies was to keep the light entities around and pick a random location near a random light to spawn stuff. Disclaimer: you get more zombies outside.

if you use eg:

for (e = nextent(world) ; e ; e = nextent(e))
numents = numents + 1;
numents = floor(random()*numents);
for (e = nextent(world) ; numents ; e = nextent(e))
numents = numents - 1;
then e should refer to a random entity somewhere on the map. You can then pick a random location within 256 units of that spot and use it as your spawn location. Use droptofloor to test if its a valid spot (note: for solid_bsp use (absmins+absmaxs)/2).

The above method will pick spots around 'crowded' areas. Ammo boxes/armour/etc all become spawn spots.
Empty areas remain empty.
A large concentration of zombies in one area means they'll get denser more often than not, creating armies.
Or, you can opt to leave lights in the map (ie: don't remove(self) on spawn), and this will give a more even covering of the map. There are a lot of light ents generally.

in worldspawn(), make an ent that just ticks once a second, if the number of zombies is less than desired, spawn a new one and reset the nextthink timer for the next tick. Decrement the count each time a zombie dies. Make sure you remove() gibbed zombie heads (usually gibbed heads are permanent decoration). This'll spawn and replace dead zombies.
IHateThisMap
Posts: 14
Joined: Wed Mar 18, 2009 2:34 am
Location: Quake, ID, B-Movies, Comic

Post by IHateThisMap »

My monsters spawn as soild un moving entitys, whats wrong with this? Oh BTW do you have a link to Rune Quake SRC.

Code: Select all

void(vector start) spawn_monster =
{
	local entity zombie
	local float r;
	spawn() = zombie;
	self.origin = start;

	r = floor(random()*10);
	if (self.classname == "monster_wizard")
		remove(self);
// Rottweiler
	if (r > 8 && self.waterlevel < 1)
	{
		self.classname = "monster_dog";
		self.solid = SOLID_SLIDEBOX;
		self.movetype = MOVETYPE_STEP;

		setmodel (self, "progs/dog.mdl");

		setsize (self, '-32 -32 -24', '32 32 40');
		self.health = 500;

		self.th_stand = dog_stand1;
		self.th_walk = dog_walk1;
		self.th_run = dog_run1;
		self.th_pain = dog_pain;
		self.th_die = dog_die;
		self.th_melee = dog_atta1;
		self.th_missile = dog_leap1;
	}


// Zombie
	else
	{
		QF_Count = QF_Count + 1;
		self.classname = "monster_zombie";
		self.solid = SOLID_SLIDEBOX;
		self.movetype = MOVETYPE_STEP;


		setmodel (self, "progs/zombie.mdl");

		setsize (self, '-16 -16 -24', '16 16 40');
		self.health = 60;

		self.th_stand = zombie_stand1;
		self.th_walk = zombie_walk1;
		self.th_run = zombie_run1;
		self.th_pain = zombie_pain;
		self.th_die = zombie_die;
		self.th_missile = zombie_missile;
}
		walkmonster_start ();
};

void random_monster()
{
	local vector s_point;

	self.classname = "zspawn";
	self.movetype = MOVETYPE_NONE;
	self.solid = SOLID_BBOX;
	setsize(self, '-1 -1 -1', '1 1 1');

	s_point = self.origin;

	spawn_monster(s_point);

	self.nextthink = time + 10 + random() * 5;
	self.think = random_monster;

};
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

spawn() = zombie;

that would be wrong. Very wrong.
try:
local entity oself;
oself = self;
self = spawn();
rest_of_function_here();
self = oself;

walkmonster_start requires self to be the monster so using self is required. Seeing as your spawner assumes self is unchanged, you need to save/restore it, hence 'oself'. This is why globals are baaad. your monsters don't move because the random_monster function changes 'self.think' when 'self' refers to both the spawner and the monster *at the same time*.

remove(self);
self.XXXX = XXXX;

would also be wrong.

self.health = 500;

lol, that's also wrong, but the code is at least okay there :)
doggies that take 5 rockets to kill ehehe
IHateThisMap
Posts: 14
Joined: Wed Mar 18, 2009 2:34 am
Location: Quake, ID, B-Movies, Comic

Post by IHateThisMap »

Thanks a ton. I have writen this same code seven times trying to get it to work. I knew it was a little thing like that that was stopping it. Thank you.
Post Reply