Forum

simple pac man game

Discuss Artificial Intelligence and Bot programming.

Moderator: InsideQC Admins

simple pac man game

Postby toneddu2000 » Wed Aug 24, 2011 2:01 pm

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!
toneddu2000
 
Posts: 1305
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Postby Spike » Wed Aug 24, 2011 2:58 pm

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.
Spike
 
Posts: 2881
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby toneddu2000 » Thu Aug 25, 2011 10:24 am

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
toneddu2000
 
Posts: 1305
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Postby DusterdooSmock » Thu Aug 25, 2011 7:33 pm

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.
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby toneddu2000 » Sun Aug 28, 2011 3:24 pm

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
toneddu2000
 
Posts: 1305
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: simple pac man game

Postby daemonicky » Mon Sep 05, 2011 9:42 am

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 ...
User avatar
daemonicky
 
Posts: 185
Joined: Wed Apr 13, 2011 1:34 pm

Re: simple pac man game

Postby toneddu2000 » Tue Sep 06, 2011 11:27 am

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.
toneddu2000
 
Posts: 1305
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: simple pac man game

Postby Error » Wed Sep 07, 2011 3:27 am

User avatar
Error
InsideQC Staff
 
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA

Re: simple pac man game

Postby ceriux » Wed Sep 07, 2011 6:15 am

Error wrote:paqman by mauvebib



funny of you to mention that, i saw that earlier today before you posted it.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: simple pac man game

Postby toneddu2000 » Wed Sep 07, 2011 11:51 am

Thanks a lot Error! I'll take a look at the code!
toneddu2000
 
Posts: 1305
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: simple pac man game

Postby toneddu2000 » Sun Feb 19, 2012 9:08 pm

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
toneddu2000
 
Posts: 1305
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: simple pac man game

Postby toneddu2000 » Wed Feb 22, 2012 12:53 pm

any hint guys?
EDIT: I found checkclient() function? Is it useful for what I want to do?
toneddu2000
 
Posts: 1305
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: simple pac man game

Postby frag.machine » Wed Feb 22, 2012 10:44 pm

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)
User avatar
frag.machine
 
Posts: 2066
Joined: Sat Nov 25, 2006 1:49 pm

Re: simple pac man game

Postby Baker » Thu Feb 23, 2012 5:04 am

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 ..
User avatar
Baker
 
Posts: 3662
Joined: Tue Mar 14, 2006 5:15 am

Re: simple pac man game

Postby Baker » Thu Feb 23, 2012 5:08 am

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 ..
User avatar
Baker
 
Posts: 3662
Joined: Tue Mar 14, 2006 5:15 am

Next

Return to Artificial Intelligence

Who is online

Users browsing this forum: No registered users and 1 guest