Page 1 of 2

simple pac man game

Posted: Wed Aug 24, 2011 2:01 pm
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!

Posted: Wed Aug 24, 2011 2:58 pm
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.

Posted: Thu Aug 25, 2011 10:24 am
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

Posted: Thu Aug 25, 2011 7:33 pm
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.

Posted: Sun Aug 28, 2011 3:24 pm
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

Re: simple pac man game

Posted: Mon Sep 05, 2011 9:42 am
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

Re: simple pac man game

Posted: Tue Sep 06, 2011 11:27 am
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.

Re: simple pac man game

Posted: Wed Sep 07, 2011 3:27 am
by Error

Re: simple pac man game

Posted: Wed Sep 07, 2011 6:15 am
by ceriux
Error wrote:paqman by mauvebib

funny of you to mention that, i saw that earlier today before you posted it.

Re: simple pac man game

Posted: Wed Sep 07, 2011 11:51 am
by toneddu2000
Thanks a lot Error! I'll take a look at the code!

Re: simple pac man game

Posted: Sun Feb 19, 2012 9:08 pm
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

Re: simple pac man game

Posted: Wed Feb 22, 2012 12:53 pm
by toneddu2000
any hint guys?
EDIT: I found checkclient() function? Is it useful for what I want to do?

Re: simple pac man game

Posted: Wed Feb 22, 2012 10:44 pm
by frag.machine
checkclient() is useful to coop modes mostly: it cycles between clients, so not all monsters will attack the same player.

Re: simple pac man game

Posted: Thu Feb 23, 2012 5:04 am
by Baker
Reference materials:

Image

Ok, that probably wasn't too helpful ...

Re: simple pac man game

Posted: Thu Feb 23, 2012 5:08 am
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;
};