Quake 2 is another classic from id software.While not modded quite as much as it's predecessor or Q3A, it is still a blast to play and the mod's on offer are bundles of fun. Just step into Quake 2 Rocket Arena, armed with the new and almighty rocket and rail gun and you will be gibbing for hours on end.If you dig fast paced action, then load up the good ole Quake 2, fire up a mod or two and have some fun!

Post tutorial Report RSS Monsters Fighting Each-Other

Like monsters? Want them to hate each other? This is for you! Fun fun fun!

Posted by on - Basic Client Side Coding

[page=Introduction]
Hello!

Today, I'll be sharing with you a code I made for monsters to fight each other. Wether you like the Stroggos, or hate them, it'll be fun!

[page=The Code.]

Here we go!

Go to FindTarget. Above it, add this new function.

edict_t *FindMonster (edict_t *self)
{
	edict_t	*ent = NULL;
	edict_t	*best = NULL;

	while ((ent = findradius(ent, self->s.origin, 1024)) != NULL)
	{
		if (ent == self)
			continue;
		if (!(ent->svflags & SVF_MONSTER))
			continue;
		if (!ent->health)
			continue;
		if (ent->health < 1)
			continue;
		if (!visible(self, ent))
			continue;
		if (!best)
		{
			best = ent;
			continue;
		}
		if (ent->max_health <= best->max_health)
			continue;
		best = ent;
	}

	return best;
}

That will look for monsters. (Similar to the Medic's check for deaddies ;))

Now, go to FindTarget, change the beginning to this:

qboolean FindTarget (edict_t *self)
{
	edict_t		*client;
	qboolean	heardit;
	int			r;
	edict_t *monster;

	if (self->monsterinfo.aiflags & AI_GOOD_GUY)
	{
		if (self->goalentity && self->goalentity->inuse && self->goalentity->classname)
		{
			if (strcmp(self->goalentity->classname, "target_actor") == 0)
				return false;
		}

		return false;
	}

		//Look for monsters!
		monster = FindMonster(self);
		if (monster)
		{
			self->enemy = monster;
			FoundTarget (self);
			return true;
		}
                                           
                                           (the rest......)

..Have fun!

Post comment Comments
flobblob
flobblob - - 33 comments

You can just run around them and then they shoot each-other. Not saying that is pointless.

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: