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.
Quake AI diagrams
-
- Posts: 185
- Joined: Wed Apr 13, 2011 1:34 pm
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.Sajt wrote:Those sort of diagrams are confusing The code is much easier to understand for me...
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 :
- http://www.theprodukkt.com/werkkzeug1 awesome idea of operator stacking, they saved time by not implementing wires to connect commands and it is usable
http://www.emil.input.sk/info_en.htm some graphical programming language, I believe it is czech (there has been this movie character, Robot Emil, http://www.youtube.com/watch?v=aDHSSTpG5-w / it is neither translated nor silent, title is "Robot Emil Fights Against Dirt")
http://panda38.sweb.cz/historie.htm This page is in czech, but there is image of some nice visual programing language (for kids to learn programming)
-
- Posts: 2126
- Joined: Sat Nov 25, 2006 1:49 pm
A state diagram would be cool to describe Quake's AI. But in a nutshell this is the monster "brain":
(*) 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
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.
(**) 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
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC (LordHavoc)