easy mapper placed waypoints monster follow?

Discuss programming in the QuakeC language.
Post Reply
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

easy mapper placed waypoints monster follow?

Post by ceriux »

is there an easy way to make waypoints that monsters will follow? iv been looking through some bot tutorials and the only ones iv found seem to place waypoints for the bots then have them follow them. id like to place my own that my monsters follow. is there an easy way to go about this?
metlslime
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Re: easy mapper placed waypoints monster follow?

Post by metlslime »

path_corner works for monsters as well as func_trains
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: easy mapper placed waypoints monster follow?

Post by ceriux »

metlslime wrote:path_corner works for monsters as well as func_trains

they automatically follow them? or would i use the ai code to direct them towards them?
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: easy mapper placed waypoints monster follow?

Post by frag.machine »

ceriux wrote:
metlslime wrote:path_corner works for monsters as well as func_trains
they automatically follow them? or would i use the ai code to direct them towards them?
It's as simple as setting target = "path1" in your monster, where targetname = "path1" in path_corner.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: easy mapper placed waypoints monster follow?

Post by ceriux »

nice, thanks ill be checking into that now. i cant sent target via worldcraft and the ai says basically if there is no player visible then the monsters target is "path_corner" so.. i shouldnt have to set a target... (the reason i cant choose a target is because im not using a monster_army to spawn my monsters)

Code: Select all

void() walkmonster_start_go =
{
local string	stemp;
local entity	etemp;

	self.origin_z = self.origin_z + 1;	// raise off floor a bit
	droptofloor();
	
	if (!walkmove(0,0))
	{
		dprint ("walkmonster in wall at: ");
		dprint (vtos(self.origin));
		dprint ("\n");
	}
	
	self.takedamage = DAMAGE_AIM;

	self.ideal_yaw = self.angles * '0 1 0';
	if (!self.yaw_speed)
		self.yaw_speed = 20;
	self.view_ofs = '0 0 25';
	self.use = monster_use;
	
	self.flags = self.flags | FL_MONSTER;
	
	if (self.target)
	{
		self.goalentity = self.movetarget = find(world, targetname, self.target);
		self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
		if (!self.movetarget)
		{
			dprint ("Monster can't find target at ");
			dprint (vtos(self.origin));
			dprint ("\n");
		}
// this used to be an objerror
		if (self.movetarget.classname == "path_corner")
			self.th_walk ();
		else
			self.pausetime = 99999999;
			self.th_stand ();
	}
	else
	{
		self.pausetime = 99999999;
		self.th_stand ();
	}

// spread think times so they don't all happen at same time
	self.nextthink = self.nextthink + random()*0.5;
};
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: easy mapper placed waypoints monster follow?

Post by ceriux »

okay... so iv set the bots target as "path" // ------------------------------------------------

Code: Select all

void() create_armybot =
// ------------------------------------------------
{

local entity bot, spawn_spot;

// start entity and place it in world 
	bot = spawn();
	spawn_spot = MonsterSpawnPoint ();
	
	bot.target = "path"; // my target is "path" 
	bot.origin = spawn_spot.origin + '0 0 1';
	bot.angles = spawn_spot.angles;
	bot.fixangle = TRUE;	
	soldiers = soldiers + 1;
	spawn_tfog (bot.origin);
	spawn_tdeath (bot.origin, bot);
	

// set size and shape
	setsize (bot, VEC_HULL2_MIN, VEC_HULL2_MAX);
	bot.solid = SOLID_SLIDEBOX;
	bot.movetype = MOVETYPE_STEP;
	setmodel(bot, "progs/soldier.mdl");
	bot.flags = bot.flags | FL_MONSTER;
	bot.takedamage = DAMAGE_AIM;

// define his animation
	bot.th_stand = army_stand1;
	bot.th_walk = army_walk1;
	bot.th_run = army_run1;
	bot.th_die = army_die;
	//bot.th_melee = ogre_melee;
	bot.th_missile = army_atk1;
	bot.th_pain = army_pain;
	bot.health = 30;

// polish him up
	bot.classname = "monster";
	bot.ideal_yaw = bot.angles * '0 1 0';
	bot.yaw_speed = 120;
	bot.view_ofs = '0 0 22';
	//bprint("an ogre joins the game\n");

// begin his thinking
	bot.nextthink = time + 0.1 + random();
	bot.think = bot.th_walk;
	


};


in worldcraft i placed a "path" of path_corners with the name "path" my monster still just guards where he spawns?
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: easy mapper placed waypoints monster follow?

Post by ceriux »

i fixed my problem by editing the function in ai.qc to return TRUE instead of FALSE for when the players behind a wall. this way the monster always knows where the players at and attempts to attack him.
kinda cheap way, but works so far. (sometimes the monsters are like derp... ima run at this for a min) i fixed this by speeding up the monster_army by removing every 3rd frame except the last one (seems to make him run a bit faster) making the game seem to have a tad bit more action and sped up the process in which he was able to navigate to me (even when stuck on a wall.) i wasnt able to get the monsters to follow waypoints/path_corners. but this seems to have given me what i wanted either way.

edit: actually... it just seems that i was lucky they were walking through.. -.-
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: easy mapper placed waypoints monster follow?

Post by ceriux »

figured this out too with out the lazy approach thanks guys!
Post Reply