simple pac man game

Discuss Artificial Intelligence and Bot programming.
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

simple pac man game

Post by toneddu2000 »

Hy guys, I'd like to create a simple pac man game in quakec, just to learn the language. I'm learning the movetogoal (dist); function(but in the ai.qc it says that is done in c code...where I can find it?). So, where there's the diffecerence between movetogoal and movetarget function?
I'd like to create a VERY basic ai where a monster searches ALWAYS a player and when he touches the player something happens. That's it.
Thanks folks!
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

if you want to make a true pac-man clone, you probably want to use walkmove() instead of movetogoal() as you can more easily adhere to a grid. movetogoal() will move in whatever direction it feels like.

both functions are implemented inside sv_move.c in the engine.
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Post by toneddu2000 »

but, there's a way to stick the enemy to a target (player, for example),so that,every moves the player takes, the enemy will follow him?
thanks
DusterdooSmock
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Post by DusterdooSmock »

toneddu2000 wrote:but, there's a way to stick the enemy to a target (player, for example),so that,every moves the player takes, the enemy will follow him?
thanks
Use Darkplaces' MOVETYPE_FOLLOW.
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Post by toneddu2000 »

For what I read on dp_extensions.qc MOVETYPE_FOLLOW should be used for "things" that don't have ai (like decals for bullets and so on) but I found out how to do it. I just duplicated ogre.qc and polish it a bit removing damages and stuff
thanks anyway
daemonicky
Posts: 185
Joined: Wed Apr 13, 2011 1:34 pm

Re: simple pac man game

Post by daemonicky »

toneddu2000 wrote: simple pac man game in quakec, just to learn the language. ...
http://web.archive.org/web/200904121251 ... _Diffusion might help later on
Think, touch, movetype, solid, traceline ...
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: simple pac man game

Post by toneddu2000 »

Thanks daemonicky! It sure is useful(unfortunately images are missing,nevermind)! But, first of all I'd like to know how an entity (a monster for example) will simply follow the player. I'd like to know if the entity would follow a classname(player) or a target, and with which function(movetarget?). This would help me a lot.
Error
InsideQC Staff
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA
Contact:

Re: simple pac man game

Post by Error »

ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: simple pac man game

Post by ceriux »

Error wrote:paqman by mauvebib

funny of you to mention that, i saw that earlier today before you posted it.
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: simple pac man game

Post by toneddu2000 »

Thanks a lot Error! I'll take a look at the code!
Meadow Fun!! - my first commercial game, made with FTEQW game engine
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: simple pac man game

Post by toneddu2000 »

Useless starting another thread for the same problem:
I'm creating a game from scratch and I'm stuck on the A.I
I can't create a simple monster that, once spawned, it searches ALWAYS player (not interested in fighting other monsters) and its only goal is to attack player.
I googled a lot, I read movetogoal function done in C code but the monster stands still (and I think is not the right function because I don't need the monster roams for the level searching the player, it already knows where the player is!), I took a look at ai_charge() function from id (which seems to me the most useful) but the monster is always there, fixed like an idiot, it doesn't move, it doesn't turn...nothing!
Can someone explains to me how start ai fighting from the very basic?
Thanks
Meadow Fun!! - my first commercial game, made with FTEQW game engine
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: simple pac man game

Post by toneddu2000 »

any hint guys?
EDIT: I found checkclient() function? Is it useful for what I want to do?
Meadow Fun!! - my first commercial game, made with FTEQW game engine
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: simple pac man game

Post by frag.machine »

checkclient() is useful to coop modes mostly: it cycles between clients, so not all monsters will attack the same player.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: simple pac man game

Post by Baker »

Reference materials:

Image

Ok, that probably wasn't too helpful ...
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: simple pac man game

Post by Baker »

More helpful ...

self.enemy <- that is what a monster is looking for to kill.

Look at fight.qc

http://www.inside3d.com/browse.php?show=fight.qc

Code: Select all

/*
===========
SoldierCheckAttack

The player is in view, so decide to move or launch an attack
Returns FALSE if movement should continue
============
*/
float() SoldierCheckAttack =
{
	local vector	spot1, spot2;	
	local entity	targ;
	local float		chance;

	targ = self.enemy;
	
// see if any entities are in the way of the shot
	spot1 = self.origin + self.view_ofs;
	spot2 = targ.origin + targ.view_ofs;

	traceline (spot1, spot2, FALSE, self);

	if (trace_inopen && trace_inwater)
		return FALSE;			// sight line crossed contents

	if (trace_ent != targ)
		return FALSE;	// don't have a clear shot
			
	
// missile attack
	if (time < self.attack_finished)
		return FALSE;
		
	if (enemy_range == RANGE_FAR)
		return FALSE;
		
	if (enemy_range == RANGE_MELEE)
		chance = 0.9;
	else if (enemy_range == RANGE_NEAR)
		chance = 0.4;
	else if (enemy_range == RANGE_MID)
		chance = 0.05;
	else
		chance = 0;

	if (random () < chance)
	{
		self.th_missile ();
		SUB_AttackFinished (1 + random());
		if (random() < 0.3)
			self.lefty = !self.lefty;

		return TRUE;
	}

	return FALSE;
};
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Post Reply