Page 1 of 1
Quake AI diagrams
Posted: Thu May 12, 2011 10:30 pm
by daemonicky
Oh page, where were you when I was browsing Quake C
http://ai-depot.com/FiniteStateMachines ... tical.html
Does anyone have experience with making such nice diagrams out of some code? I think taht it would be cool to do it for arbitrary QuakeC, it can make it easier to orient in your code and easier for others to dive into it.
Posted: Fri May 13, 2011 4:59 am
by Sajt
Those sort of diagrams are confusing
The code is much easier to understand for me...
Posted: Fri May 13, 2011 11:57 am
by daemonicky
Sajt wrote:Those sort of diagrams are confusing
The code is much easier to understand for me...
I believe each person has its own way of understanding. BUt, I would really like to recommend you just getting to know some UML, I found some of them usable. They are quite obvious and they are standard.
I am a visual guy, so I like Venn diagrams, ERD ... I have done little coding in visual languages, but they appeal asi nice to me :
Posted: Sat May 14, 2011 1:14 am
by frag.machine
A state diagram would be cool to describe Quake's AI. But in a nutshell this is the monster "brain":
Code: Select all
1) do I have a movetarget ? If so, then I'll run self.th_walk towards it;
2) if not, I'll just hang on here running my self.th_stand function every 0.1 seconds(*), hopeffuly awaiting some player find me;
3) if I see a client, I'll set my .enemy field to point him, play my sight sound to show how pissed off I am, turn to him calling ai_face() and exec my self.th_run function;
4) if my self.th_missile is set and I have a clear path, I'll call it randomly;
5) if I am close enough and I have self.th_melee set, I'll exec it;
6) at any time, if somebody hurts me I may (or may not) play my pain animation and, if it has a different classname(**), I'll save my current value for self.enemy in self.oldenemy, set self.enemy with my agressor entity and go on;
7) if my health is below zero, I'm done. I play one of my cool death animations, turn non-solid(***) and eventually I'll drop a backpack with some goodies. If my health is too low, I'll just turn a rain of rotten meat giblets;
8) I am very stupid to deal with obstacles, specially long walls, and human clients abuse this limitation in several ways. Also, I have no understanding of the world where I roam aimlessly: I use to avoid water, even small puddles that would be otherwise safe to cross on foot. I don't distinguish water from lava or slime, and gaps deeper than 32 Quake units are virtually show stoppers to me.
(*) some QuakeC coders (read: me mostly) may set higher frequencies to the standing AI. This requires handling animation in a independent timing;
(**) monster_army (and monster_enforcer IIRC) are the exceptions, they'll try to kill another of their kind;
(***) except of course if you're running some gibbable corpse mod
Posted: Sat May 14, 2011 2:59 am
by Lardarse
frag.machine wrote:monster_army (and monster_enforcer IIRC) are the exceptions, they'll try to kill another of their kind
Nope. Enforcers are "smart" enough not to.