getting rid of animation macros
Moderator: InsideQC Admins
9 posts
• Page 1 of 1
getting rid of animation macros
so I started talking about this in the 'what are you working on' thread and decided to move over to the proper forum.
I'm trying to do away with the macros by using self.frame:
(This code is called once when W_Reload(); happens, not every frame)
it worked fine as a macro but now the animation doesn't play
I'm trying to do away with the macros by using self.frame:
- Code: Select all
void() player_reload =
{
self.frame = $relo_onehanded_1;
while (self.frame < $relo_onehanded_31)
{
self.frame = self.frame + 1;
self.nextthink = time + .033; //30 FPS
}
player_walk(); //when done go back to walk
}
(This code is called once when W_Reload(); happens, not every frame)
it worked fine as a macro but now the animation doesn't play
- Boss429
- Posts: 39
- Joined: Sun Dec 03, 2006 7:29 pm
You're always reseting self.frame to $relo_onehanded_1 at the start of the function. Also, you're iterating thru $relo_onehanded_1 to $relo_onehanded_31 at once, not one frame per call as required to actually see any animation.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
But isn't the macro doing the exact same thing? it specifies an animation and then just goes into another void that specifies the next frame. Mine just does the work in one void. I guess my question is, why does a macro not play all the frames at once?
- Boss429
- Posts: 39
- Joined: Sun Dec 03, 2006 7:29 pm
I'm not sure I can explain it very well, but here goes:
In QuakeC you can set various things, like the model's frame, but it only has an effect when the QuakeC code has returned back to the engine and the engine redraws the screen.
So to make animations visible, you change the frame in QuakeC and set the 'nextthink' time and then return. The engine will draws the world and eventually call back into QuakeC (when that think time is reached) where you can set the next frame, and QuakeC returns and the engine redraws the world again, and will call back into QuakeC for the next frame, and so on........
Having a loop in QuakeC (like yours) doesn't work because the engine never gets a chance to redraw the screen with the updated information.
In QuakeC you can set various things, like the model's frame, but it only has an effect when the QuakeC code has returned back to the engine and the engine redraws the screen.
So to make animations visible, you change the frame in QuakeC and set the 'nextthink' time and then return. The engine will draws the world and eventually call back into QuakeC (when that think time is reached) where you can set the next frame, and QuakeC returns and the engine redraws the world again, and will call back into QuakeC for the next frame, and so on........
Having a loop in QuakeC (like yours) doesn't work because the engine never gets a chance to redraw the screen with the updated information.
- andrewj
- Posts: 133
- Joined: Mon Aug 30, 2010 3:29 pm
- Location: Australia
Boss429 wrote:But isn't the macro doing the exact same thing?
No.
From the original monsters.qc:
- Code: Select all
// name =[framenum, nexttime, nextthink] {code}
// expands to:
// name ()
// {
// self.frame=framenum;
// self.nextthink = time + nexttime;
// self.think = nextthink
// <code>
// };
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Thanks guys, I got it working beautifully:
- Code: Select all
void() player_smallreload =
{
if ((self.frame > $relo_onehanded_31) || (self.frame < $relo_onehanded_1))
{
self.frame = $relo_onehanded_1; // if your not playing reload animation, start at the beging
}
else if (self.frame == $relo_onehanded_31)
{
player_walk(); //if last frame go back to player_walk
return;
}
else
{
self.frame = self.frame + 1;
}
self.nextthink = time + .033; //30FPS
self.think = player_reload;
}
void() player_reload =
{
self.reloading = 1;
if (self.weapon == IT_PISTOL || IT_UZI)
player_smallreload(); // for single handed weapons
else
player_bigreload1(); // for full size weapons
};
- Boss429
- Posts: 39
- Joined: Sun Dec 03, 2006 7:29 pm
Great! 
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
When self.frame == $relo_onehanded_31, where does it get reset to $relo_onehanded_1?
Shouldn't the bit:
be:
?
Shouldn't the bit:
- Code: Select all
else if (self.frame == $relo_onehanded_31)
{
player_walk(); //if last frame go back to player_walk
return;
}
be:
- Code: Select all
else if (self.frame == $relo_onehanded_31)
{
player_walk(); //if last frame go back to player_walk
// for the next time we reload
self.frame = $relo_onehanded_1;
return;
}
?
- OneManClan
- Posts: 243
- Joined: Sat Feb 28, 2009 2:38 pm
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
