Understanding Animation.

Discuss programming in the QuakeC language.
Post Reply
ScatterBox
Posts: 50
Joined: Sun Oct 13, 2013 7:53 pm

Understanding Animation.

Post by ScatterBox »

Well, lately I've been running through all of the QC files and reading the code and learning from it (as well as removing un-used things) I've learned a lot about the syntax and how QC works, and it's been an interesting experience.. Well, lately I've been looking at the enemy QC files and their animations. The way animations are coded in seem to be a hard concept for me to grasp.. :/

Well, here's a bit I needed help understanding.

Code: Select all

void()	army_run2	=[	$run2,		army_run3	] {ai_run(15);};
void()	army_run3	=[	$run3,		army_run4	] {ai_run(10);};
void()	army_run4	=[	$run4,		army_run5	] {ai_run(10);};
void()	army_run5	=[	$run5,		army_run6	] {ai_run(8);};
void()	army_run6	=[	$run6,		army_run7	] {ai_run(15);};
void()	army_run7	=[	$run7,		army_run8	] {ai_run(10);};
void()	army_run8	=[	$run8,		army_run9	] {ai_run(8);};
void()	army_run9	=[	$run9,		army_run10	] {ai_run(15);};
void()	army_run10	=[	$run10,		army_run11	] {ai_run(10);};
void()	army_run11	=[	$run11,		army_run12	] {ai_run(10);};
void()	army_run12	=[	$run12,		army_run13	] {ai_run(8);};
void()	army_run13	=[	$run13,		army_run14	] {ai_run(15);};
void()	army_run14	=[	$run14,		army_run15	] {ai_run(10);};
void()	army_run15	=[	$run15,		army_run16	] {ai_run(8);};
void()	army_run16	=[	$run16,		army_run17	] {ai_run(8);};
void()	army_run17	=[	$run17,		army_run18	] {ai_run(15);};
void()	army_run18	=[	$run18,		army_run19	] {ai_run(10);};
void()	army_run19	=[	$run19,		army_run1	] {ai_run(8);};


OK, so really this part makes some sense to me yet it doesn't... but what I don't understand here is what this bit is for (reference from the same code above)

Code: Select all

{ai_run(10);}
What does the number 10 stand for in this encounter?

Any other help on animations in QC would be awesome as well. :) Thanks!

Also, if you could ignore the issues in the spacing of the code up above it would be great... I had a bit of trouble getting it on here, and this is the best I could do..
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Understanding Animation.

Post by Spike »

void() army_run2 =[ $run2, army_run3 ] {ai_run(15);};

expands to:
void() army_run2 =
{
//this is the 'op_state' part from the square brackets
self.frame = $run2; //frame macros expand to immediates (read: constants). Each name defined by the "$frame" directive at the top of the qc file defines a $yourconstant that has 1 value more than the previous one, starting at 0. The qcc expands them to float immediates when it encounters them.
self.think = army_run3; //the named function from op_state is automatically prototyped as returning void and taking no arguments.
self.nextthink = time + 0.1; //op_state implies a specific 0.1 second interval. you can always override after.

ai_run(15); //yup, that's a regular function call.
};

the ai_run function executes the ai code for the 'run' behaviour. 'run' basically means running at the monster's .enemy and probably switching to attack animations randomly.
the argument is the number of quake units to move forward by. remember that its specified at 0.1 intervals, so 15 is effectively 150qu per second, but only for a 10th of a second...
per-frame values allow a lurching sort of animation, which nicely ties to the monster's lurching animation.
there's other ai functions like ai_stand() and ai_walk(x) for other states also there's ai_pain to step around. your attack states should probably update the angle the monster is facing, but they typically don't bother running any other ai while shooting.

side note: more modern animation styles for player-type characters would use a constant value for each frame, and have the model itself provide the staggering. you can then have the clientside gamecode update the animation at a rate relative to the actual distance traveled. this covers lag and all sorts of other issues, ensuring foot-sync. of course, if you're using vanilla content, your code needs vanilla-compatible lurches. yay!... *cough*. it doesn't matter too much with monsters, its players that can strafe and do other non-axial movements that make life fun that really need it.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Understanding Animation.

Post by Cobalt »

Lots of mods I see dont use the " $ " type commands at all for the frame macros and such. Did the original release of progs < 1.06 use these ? For example:

$cd id1/models/player_4
$origin 0 -6 24
$base base
$skin skin


player.qc file seems to have these commands in some cases, but not every one has them. I have been told before they are basicly useless ?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Understanding Animation.

Post by Spike »

those ones you listed were part of some tool to convert 'alias' models to quake's .mdl format. id were fans of scanning sourcecode, I guess.
ignored by the qcc, they're not used by the engine and can be stripped out without problems. just don't strip the $frame parts.
consider them as comments.
Post Reply