Reload Help
Moderator: InsideQC Admins
17 posts
• Page 1 of 2 • 1, 2
Reload Help
I'm using this tutorial to add reloading to the shotgun in quake.
http://www.moddb.com/games/solitude/tut ... g-to-quake
I've already replaced the model, and it's fully textured and animated, but i need help to call the animation and play a sound when the gun reloads.
Please help!
http://www.moddb.com/games/solitude/tut ... g-to-quake
I've already replaced the model, and it's fully textured and animated, but i need help to call the animation and play a sound when the gun reloads.
Please help!
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
The animation frames are defined in "player.qc". If you wish to add additional animations, you'll need to define the frames and their sequence. The syntax for this is a little obscure, but it's very powerful, as an animation frame can also execute arbitrary code (such as playing the reloading sound, or changing the variable that represents the amount of ammo in the gun.)
If you can't figure it out how it works by looking at the existing examples, there are tutorials on quake animation out there that should be helpful. Unfortunately, I don't have a link handy.
If you can't figure it out how it works by looking at the existing examples, there are tutorials on quake animation out there that should be helpful. Unfortunately, I don't have a link handy.
- Karatorian
- Posts: 31
- Joined: Tue Aug 17, 2010 4:26 am
- Location: Rindge, NH, USA
Ok, i did some looking around in "player.qc" and i came up with this:
// At the top of "player.qc"
$frame shotrel1 shotrel2 shotrel3 shotrel4 shotrel5 shotrel6
// A little bit after that
void() player_sreload1 = [$shotrel1, player_sreload2 ] {self.weaponframe=1;};
void() player_sreload2 = [$shotrel2, player_sreload3 ] {self.weaponframe=2;};
void() player_sreload3 = [$shotrel3, player_sreload4 ] {self.weaponframe=3;};
void() player_sreload4 = [$shotrel4, player_sreload5 ] {self.weaponframe=4;};
void() player_sreload5 = [$shotrel5, player_sreload6 ] {self.weaponframe=5;};
void() player_sreload6 = [$shotrel6, player_run ] {self.weaponframe=6;};
But, i have no idea how to trigger the animation....
// At the top of "player.qc"
$frame shotrel1 shotrel2 shotrel3 shotrel4 shotrel5 shotrel6
// A little bit after that
void() player_sreload1 = [$shotrel1, player_sreload2 ] {self.weaponframe=1;};
void() player_sreload2 = [$shotrel2, player_sreload3 ] {self.weaponframe=2;};
void() player_sreload3 = [$shotrel3, player_sreload4 ] {self.weaponframe=3;};
void() player_sreload4 = [$shotrel4, player_sreload5 ] {self.weaponframe=4;};
void() player_sreload5 = [$shotrel5, player_sreload6 ] {self.weaponframe=5;};
void() player_sreload6 = [$shotrel6, player_run ] {self.weaponframe=6;};
But, i have no idea how to trigger the animation....
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
The animation frames are actually just functions with some syntax sugar. So, all you have to do is call the first one in the sequence.
This tutorial, while at it's core about adding a monster behavior, has a nice introduction to how animation in Quake works.
http://web.archive.org/web/200708280745 ... tutor3.htm
This tutorial, while at it's core about adding a monster behavior, has a nice introduction to how animation in Quake works.
http://web.archive.org/web/200708280745 ... tutor3.htm
- Karatorian
- Posts: 31
- Joined: Tue Aug 17, 2010 4:26 am
- Location: Rindge, NH, USA
I looked at that tutorial, and i'm pretty sure that i didn't do this right:
void() player_sreload1 =
{
self.frame = $shotrel1;
self.think = player_sreload2;
self.nextthink = time + 4;
reload ();
};
Because, when i try to compile i get this error:
"weapons.qc:56: error: Unknown frame macro $shotrel1"
Any help would be appreciated.
void() player_sreload1 =
{
self.frame = $shotrel1;
self.think = player_sreload2;
self.nextthink = time + 4;
reload ();
};
Because, when i try to compile i get this error:
"weapons.qc:56: error: Unknown frame macro $shotrel1"
Any help would be appreciated.
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
DusterdooSmock wrote:I looked at that tutorial, and i'm pretty sure that i didn't do this right:
void() player_sreload1 =
{
self.frame = $shotrel1;
self.think = player_sreload2;
self.nextthink = time + 4;
reload ();
};
Because, when i try to compile i get this error:
"weapons.qc:56: error: Unknown frame macro $shotrel1"
Any help would be appreciated.
Have you defined $shotrel1 before trying to use it ?
Is $shotrel1 defined in the same file you're trying to use it ?
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
I think that i defined $shotrel1, but if i didn't what do i have to do to define it?
This is what i have so far:
-- Top of "player.qc"
//
// Reload
//
$frame shotrel1 shotrel2 shotrel3 shotrel4 shotrel5 shotrel6 shotrel7 shotrel8 shotrel9 shotrel10 shotrel11 shotrel12 shotrel13 shotrel14 shotrel15 shotrel16 shotrel17 shotrel18 shotrel19 shotrel20
-- Somewhere right after that
void() player_sreload1 = [$shotrel1, player_sreload2 ] {self.weaponframe=10;};
void() player_sreload2 = [$shotrel2, player_sreload3 ] {self.weaponframe=11;};
void() player_sreload3 = [$shotrel3, player_sreload4 ] {self.weaponframe=12;};
void() player_sreload4 = [$shotrel4, player_sreload5 ] {self.weaponframe=13;};
void() player_sreload5 = [$shotrel5, player_sreload6 ] {self.weaponframe=14;};
void() player_sreload6 = [$shotrel6, player_sreload7 ] {self.weaponframe=15;};
void() player_sreload7 = [$shotrel7, player_sreload8 ] {self.weaponframe=16;};
void() player_sreload8 = [$shotrel8, player_sreload9 ] {self.weaponframe=17;};
void() player_sreload9 = [$shotrel9, player_sreload10 ] {self.weaponframe=18;};
void() player_sreload10 = [$shotrel10, player_sreload11 ] {self.weaponframe=19;};
void() player_sreload11 = [$shotrel11, player_sreload12 ] {self.weaponframe=20;};
void() player_sreload12 = [$shotrel12, player_sreload13 ] {self.weaponframe=21;};
void() player_sreload13 = [$shotrel13, player_sreload14 ] {self.weaponframe=22;};
void() player_sreload14 = [$shotrel14, player_sreload15 ] {self.weaponframe=23;};
void() player_sreload15 = [$shotrel15, player_sreload16 ] {self.weaponframe=24;};
void() player_sreload16 = [$shotrel16, player_sreload17 ] {self.weaponframe=25;};
void() player_sreload17 = [$shotrel17, player_sreload18 ] {self.weaponframe=26;};
void() player_sreload18 = [$shotrel18, player_sreload19 ] {self.weaponframe=27;};
void() player_sreload19 = [$shotrel19, player_sreload20 ] {self.weaponframe=28;};
void() player_sreload20 = [$shotrel20, player_run ] {self.weaponframe=29;};
-- "weapons.qc" after main reload function
void() player_sreload1 =
{
self.frame = $shotrel1;
self.think = player_sreload2;
self.nextthink = time + 0.1;
reload ();
};
This is what i have so far:
-- Top of "player.qc"
//
// Reload
//
$frame shotrel1 shotrel2 shotrel3 shotrel4 shotrel5 shotrel6 shotrel7 shotrel8 shotrel9 shotrel10 shotrel11 shotrel12 shotrel13 shotrel14 shotrel15 shotrel16 shotrel17 shotrel18 shotrel19 shotrel20
-- Somewhere right after that
void() player_sreload1 = [$shotrel1, player_sreload2 ] {self.weaponframe=10;};
void() player_sreload2 = [$shotrel2, player_sreload3 ] {self.weaponframe=11;};
void() player_sreload3 = [$shotrel3, player_sreload4 ] {self.weaponframe=12;};
void() player_sreload4 = [$shotrel4, player_sreload5 ] {self.weaponframe=13;};
void() player_sreload5 = [$shotrel5, player_sreload6 ] {self.weaponframe=14;};
void() player_sreload6 = [$shotrel6, player_sreload7 ] {self.weaponframe=15;};
void() player_sreload7 = [$shotrel7, player_sreload8 ] {self.weaponframe=16;};
void() player_sreload8 = [$shotrel8, player_sreload9 ] {self.weaponframe=17;};
void() player_sreload9 = [$shotrel9, player_sreload10 ] {self.weaponframe=18;};
void() player_sreload10 = [$shotrel10, player_sreload11 ] {self.weaponframe=19;};
void() player_sreload11 = [$shotrel11, player_sreload12 ] {self.weaponframe=20;};
void() player_sreload12 = [$shotrel12, player_sreload13 ] {self.weaponframe=21;};
void() player_sreload13 = [$shotrel13, player_sreload14 ] {self.weaponframe=22;};
void() player_sreload14 = [$shotrel14, player_sreload15 ] {self.weaponframe=23;};
void() player_sreload15 = [$shotrel15, player_sreload16 ] {self.weaponframe=24;};
void() player_sreload16 = [$shotrel16, player_sreload17 ] {self.weaponframe=25;};
void() player_sreload17 = [$shotrel17, player_sreload18 ] {self.weaponframe=26;};
void() player_sreload18 = [$shotrel18, player_sreload19 ] {self.weaponframe=27;};
void() player_sreload19 = [$shotrel19, player_sreload20 ] {self.weaponframe=28;};
void() player_sreload20 = [$shotrel20, player_run ] {self.weaponframe=29;};
-- "weapons.qc" after main reload function
void() player_sreload1 =
{
self.frame = $shotrel1;
self.think = player_sreload2;
self.nextthink = time + 0.1;
reload ();
};
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
Are you using proqcc or proqccw ? There's a bug (don't remember if frikqcc/fteqcc suffers from the same problem) that don't let you use macros without trailing spaces.
This doesn't compile in proqcc:
But this works just fine:
This doesn't compile in proqcc:
- Code: Select all
void() player_sreload1 = [$shotrel1, player_sreload2 ] {self.weaponframe=10;};
But this works just fine:
- Code: Select all
void() player_sreload1 = [ $shotrel1 , player_sreload2 ] {self.weaponframe=10;};
Last edited by frag.machine on Fri Aug 27, 2010 3:12 am, edited 1 time in total.
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
I'm using the FTEQCC GUI v3343.
But, i have a question about my code; will the part in "weapons.qc" play the whole animation, or do i have to add something to it?
But, i have a question about my code; will the part in "weapons.qc" play the whole animation, or do i have to add something to it?
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
Sorry for not realizing the error before: you defined the player_sreload1 function twice - one in player.qc (correct) and again in weapons.qc (wrong). That's why you're getting that message stating $shotrel1 was undefined: in QuakeC macros does only exists in the scope of the file where they are defined.
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
Well, you need to replace the default player run/stand animations with your code. Unfortunately, it's not as straight as changing the calls. I suggest you read carefully the original player_stand1() and player_run1() functions to adapt it for your new animations instead.
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
Is this the function that you are talking about?
void() player_run;
void() player_stand1 =[ $axstnd1, player_stand1 ]
{
self.weaponframe=0;
if (self.velocity_x || self.velocity_y)
{
self.walkframe=0;
player_run();
return;
}
void() player_run;
void() player_stand1 =[ $axstnd1, player_stand1 ]
{
self.weaponframe=0;
if (self.velocity_x || self.velocity_y)
{
self.walkframe=0;
player_run();
return;
}
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
Yes, that's it.
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
Ok, my reload is now working at about 99%. The only problem is that when the player spawns, there are no bullets in the gun.
Any Help?
Any Help?
- DusterdooSmock
- Posts: 170
- Joined: Thu Aug 19, 2010 9:58 pm
17 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest