Please help me with my Qung Fu mod.

Discuss programming in the QuakeC language.
Phenom
Posts: 10
Joined: Wed Mar 12, 2008 7:47 pm
Location: Guthrie, OK
Contact:

Please help me with my Qung Fu mod.

Post by Phenom »

I normally only post on QuakeOne.com since I'm mostly a player not a modder, anyway.

I have this Quake mod I'm working on called Qung Fu with a completely remade ranger model(except for the texture).

Currently there is run,jump,idle and punch animations though I am no good at QC.

I had someone help me out this far but they're very busy so I turned to the Inside3d gang for assistance.

The run animation is slightly off, I can't figure out how to fine tune the player.qc for either run or jump
animations. There is no actual animation tied to jumping yet but when the player jumps he is supposed to do a front flip.

I have my model's frames mimicking the original player.mdl except I use dummy frames for unused animations(all jump flip frames)
Image

Here is an in-game video demonstrating what I have so far.

YouTube Video Link
[ihttp://www.youtube.com/watch?v=v00IK7Gw4n0

Can someone help me with player animations? Thank you!
Best sig ever.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Please help me with my Qung Fu mod.

Post by frag.machine »

Not sure if it's exactly what you want to know, but...

Since you're using Darkplaces, you can resort to the .movement vector (self.movement_x for forward/backward, self.movement_y for left/right strafing). For jumping, you can test self.button2 combined with self.flags & FL_ONGROUND and self.movement_z (to determine if you're going up or down). <pimp>my multi part model animation is controlled this way.</pimp>

Finally, Darkplaces supports AVI capture (either direct gameplay or a demo playback). I'd suggest to use the later mode. Here follows a small script I use to grab AVI gameplay for posterior Youtube upload with reasonable quality (you may adjust the dimensions and framerate according your hardware):

Code: Select all

cl_capturevideo_fps 30
cl_capturevideo_width 640
cl_capturevideo_height 480
cl_capturevideo_ogg 0
bind f4 "record mydemo start"
bind f5 "cl_capturevideo 1"
bind f6 "playdemo mydemo"
bind f7 "cl_capturevideo 0"
say "f4=record;f5=start vidcap;f6=playback demo;f7=stop vidcap."
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Phenom
Posts: 10
Joined: Wed Mar 12, 2008 7:47 pm
Location: Guthrie, OK
Contact:

Re: Please help me with my Qung Fu mod.

Post by Phenom »

thanks, however I just finished my first Inside3D tutorial "jump like a fiend" so i'm a QC noob!

i don't understand QC syntax fluently enough to start adding stuff.

whenever I jump the model should play

$frame jump jump1 jump2 jump3 jump4 jump5 jump6 jump7 jump8 jump9 jump10.

the player.qc is original except for the modifications found under the "Jump like a fiend" tutorial
and Ive remade the player.mdl.
Best sig ever.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Please help me with my Qung Fu mod.

Post by Seven »

Hello Phenom,

I am not a good coder, but I want to try to help you with that "jump" idea.
I think it is a great idea.

First of all, be aware, that the jump code is not inside "player.qc". It is declared inside "client.qc"
So what you want to do first, open that file and go to function: PlayerJump ()
It is called every frame via: PlayerPreThink() by the way.
Read through it and you will see what happens when you are inside water and so on.
Lets say you only want to make your "front flip" when you are out of water.
So scroll down til the very end of that function and add:

Code: Select all

player_flip1();
Now, to be able to compile your new code later on, you need to know that "client.qc" is read before "player.qc"
during compilation (because this order is declared inside "progs.scr" ).
So what you need to do now is to add one single line on the very top of the file "client.qc":

Code: Select all

void() player_flip1;
So that the compiler already knows the new function which we will add later on.

That is all you need to do to "client.qc".

Next is the file "player.qc".
Open it and go to the very end of it.
Here you need to add these lines:

Code: Select all

$frame jump jump1 jump2 jump3 jump4 jump5 jump6 jump7 jump8 jump9 jump10  // these are your new animation frames, as you told us.

void()	player_flip1	=	[	$jump,	player_flip2	] {};
void()	player_flip2	=	[	$jump1,	player_flip3	] {};
void()	player_flip3	=	[	$jump2,	player_flip4	] {};
void()	player_flip4	=	[	$jump3,	player_flip5	] {};
void()	player_flip5	=	[	$jump4,	player_flip6	] {};
void()	player_flip6	=	[	$jump5,	player_flip7	] {};
void()	player_flip7	=	[	$jump6,	player_flip8	] {};
void()	player_flip8	=	[	$jump7,	player_flip9	] {};
void()	player_flip9	=	[	$jump8,	player_flip10	] {};
void()	player_flip10	=	[	$jump9,	player_flip11	] {};
void()	player_flip11	=	[	$jump10,	player_run		] {};
Be aware though that there is an automatic "nextthink" of 0.1 second between each frame.
That means, your 11 frame jump animation is long. "Maybe" too long.
You maybe will still make your flip, when you already landed.
So try to shorten your animation if it is the case.
If it is not the case, then your new code should work.
That is it.

I just tested it with the original "axedeath" player animation. LOOL
Everytime I jumped, the player died midair, hehe. :lol:

Of course my knowledge is very limited, so there is most probably a better way in doing it.
But at least you can now start to flip around in Quake :)


PS: You can of course add a ninja scream during your flip animation.
If you want, just add a sound line into the second or third frame:
Example:

Code: Select all

sound (self, CHAN_VOICE, "player/ninja_scream.wav", 1, ATTN_NORM);
Put the .wav file "ninja_scream.wav" into your subfolder: ID1\sound\player

If you want to spawn the scream not everytime you jump, but only every 25% or so,
you need to add a random line to do it.
This would be your final code in "player.qc" then:

Code: Select all

$frame jump jump1 jump2 jump3 jump4 jump5 jump6 jump7 jump8 jump9 jump10  // these are your new animation frames, as you told us.

void()	player_flip1	=	[	$jump,	player_flip2	] {};
void()	player_flip2	=	[	$jump1,	player_flip3	] {
local float zufall;
zufall = random();
if (zufall < 0.25)
	sound (self, CHAN_VOICE, "player/ninja_scream.wav", 1, ATTN_NORM);
};
void()	player_flip3	=	[	$jump2,	player_flip4	] {};
void()	player_flip4	=	[	$jump3,	player_flip5	] {};
void()	player_flip5	=	[	$jump4,	player_flip6	] {};
void()	player_flip6	=	[	$jump5,	player_flip7	] {};
void()	player_flip7	=	[	$jump6,	player_flip8	] {};
void()	player_flip8	=	[	$jump7,	player_flip9	] {};
void()	player_flip9	=	[	$jump8,	player_flip10	] {};
void()	player_flip10	=	[	$jump9,	player_flip11	] {};
void()	player_flip11	=	[	$jump10,	player_run		] {};
Good luck with your mod Phenom.

Best wishes,
Seven
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Please help me with my Qung Fu mod.

Post by Cobalt »

The front flip is not too hard to do really. First I would check for a V_forward value or a vlen(self.velocity) that matches running straight ahead at top speed. Do a quick calculation using the playerjump()'s maximum value for when the jump is pressed so that we know the value of z_origin when he is at his maximum height at the jump. Do another calculation so that we know the z_origin about half way between that point and his original z_origin before the jump. Set self.frame = 69....do the jump, then give him an avelocity_y positive value so that his moel tips forward at a speed you desire. Once his z_origin is at or near close to the origin point when he first jumped, remove the avelocity, set self.angles as they were before the jump. The frame ought to reset by itself to a walking or standing frame. I am experimenting a little myself with frame 69 as the jump frame in my mod, and have it so that it checks for self.flags & FL_JUMPRELEASED or if self.flags& FL_ONGROUND and !self.button2 then it sets the frame as #69 , making it look like he is really jumping. If you want to be precise, you also ought to resize the model when its frame 69 because its alot smaller than the hull max and min values the qc has it set to.
Phenom
Posts: 10
Joined: Wed Mar 12, 2008 7:47 pm
Location: Guthrie, OK
Contact:

Re: Please help me with my Qung Fu mod.

Post by Phenom »

I'm in over my head here :)

Thnks so far for all the information!

Qung Fu was originally going to be 100% completely 3D animated in Blender, however the community showed interest in an actual game/mod so since the project was at it's infancy and easily transferable I made the model "Quake 1 friendly".

I don't understand when you say "Do a quick calculation using the playerjump()'s maximum value for when the jump is pressed" I'm a real noob and only made it through getting my model walking and punching by spending 2 days playing with the first 50 lines of frame code in player.qc.

I don't know how to do anything fancy or anything really, the Qc guy who was going to help suddenly became very busy and suggested I find someone else to code for the project.

At this point I've setup a local multiplayer game and had 2 "Qung Fu" guys running around punching/killing each-other the animations and over all-ness of the project is still very blocky and unpolished, I was hoping I could get some talented QC coder to help me straighten things out.
Best sig ever.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Please help me with my Qung Fu mod.

Post by frag.machine »

Vanilla Quake doesn't play specific animations for jumping, or swimming, or strafing, or backpedaling... Well, you got the idea. So it's not just a matter of find & replace animation frames; you have to code things from scratch. It's quite feasible, but not exactly a beginner task. But don't let this discourage you: we are here to help. :)
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Please help me with my Qung Fu mod.

Post by Cobalt »

Ok, playerprethink () calls playerjump() via this in client.qc :

Code: Select all

if (self.button2)
PlayerJump ();
else
self.flags = (self.flags | FL_JUMPRELEASED);

At least thats what my mod does. So just before that playerjump call, you do someting like this:

Code: Select all

if (self.button2)
{
self.sjumpz = self.origin_z; // Where you define sjump (somersault jump) specific float in defs qc via .float sjumpz
PlayerJump ();
}
else
self.flags = (self.flags | FL_JUMPRELEASED);
Then in playerjump () you will have something like:
self.velocity_z = (self.velocity_z + 360);

This is what makes the player jump. I dont think it means his new origin_z will be exactly 360 units from where it is before the jump, because physics is involved etc. So what I would do is put some tracing code im maybe playerpostthink () that will print out the actual height as you do some test jumps:

Code: Select all

if (!self.flags & FL_ONGROUND && self.velocity_z)
{
bprint (ftos (self.origin_z));
bprint ("\n");
}
...do a few test jumps while standing still, and take note of the max and min values. (in the tests I did looks like he jumps about 40 units) That will give you the general range you will need for the rest of the code, where you will compare the players .origin_z to about 40 units of the .sjumpz value you previously stored. Check maybe if its 38 units higher than max, now you are ready to set the avelocity and the frame if you want. My code actually uses frame 66, not 69 when jumpreleased flag is active.

As the other coder says, the engine will be trying to manage the frames depending on what it sees physics-wise.....so I am not really sure how it will look in the end. So far tests I have done , the engine does not seem to mess with player frames when its not on the ground....so that opens up some possibilities here like the somersaulting....and the idea I posted here a while back about some improved air-death scenes in playerdie().

Other things I have seen coders do in the Quake 3 engine mod world, is create a 'doublejump', probably using this same idea. Once the z origin is at the max jump value, and the player releases jump, and jumps again, the player actually jumps a second time, but from the new height already achieved. I suppose with some tweaking , the somersault could be blended into the original jump like that.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Please help me with my Qung Fu mod.

Post by Seven »

Cobalt wrote:So far tests I have done , the engine does not seem to mess with player frames when its not on the ground....so that opens up some possibilities here like the somersaulting....
Hmmm, as far as I understood Phenom in his 1st post, he said, that he already ceated animation frames of his player model and named it:
jump jump1 jump2 jump3 jump4 jump5 jump6 jump7 jump8 jump9 jump10
And he asked for a way to implement this flip animation, so when the player jumps, he does a flip.
My example code does exactly this.
Didnt you try it Phenom ? You did not reply to it.
Is it too complex ? I tried to explain step by step what to do.
I was thinking that this is what you asked for. Hmmm, maybe I was wrong.
My english is not very good and I sometimes misunderstand things :)

The code does not change the original QC-jump in any way. It simply puts your animations into it.
You will still jump exactly as far and high as before.
The only difference is that you do a front flip instead of a animation-less jump.
If this is not what you asked for, please at least reply to it.
So that others, like Cobalt which have a better QC-knowledge, can help your further.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Please help me with my Qung Fu mod.

Post by Cobalt »

Hi Seven:

Sorry I didnt notice the new frames he made. But its just as simple to call them when at the max z_origin, as opposed to my frame 66 or 69 like I am testing with in my mod. I also didnt know there are automatic nextthinks called between frames like that, thanks.


Seven wrote: Hmmm, as far as I understood Phenom in his 1st post, he said, that he already ceated animation frames of his player model and named it:
jump jump1 jump2 jump3 jump4 jump5 jump6 jump7 jump8 jump9 jump10
Phenom
Posts: 10
Joined: Wed Mar 12, 2008 7:47 pm
Location: Guthrie, OK
Contact:

Re: Please help me with my Qung Fu mod.

Post by Phenom »

Thanks so far everybody, I'm going to try and let all this information soak in over the next few days.

The ultimate goal is to have a player be able to run, sprint, super jump while sprinting(near top speed) and wall-jump where the player springs upward when they hit a wall and press jump again.

The idea is to add another basic button (Jump,shoot,*action*) which gives the player extra functions in the world like sprinting, special moves.

Also I'd like to include some basic runes maybe like power, focus, fire skin and speed.
The levels could be standard e1m1 maps or dm1 maps but I'm thinking levels
to be custom made to fit the play style of vertical leaping/fighting (ala fantasy kung fu films)
so levels maybe with twin towers with multiple levels for fighting with teleports leading to the next level up
with equipment and items at the top.

With one catch however. I'm trying to include realistic fall damage so players will have to
think before they leap since jumping to high or falling to far will result in severe injury or death.

I know this is a lot for a noobie to even think of coding but like I said earlier, It was supposed to be something else
in the beginning and just kind of manifested into an actual mod from the QuakeOne community.

So any beginner tips or easy explanations would be appreciated!

Thanks!
Best sig ever.
Phenom
Posts: 10
Joined: Wed Mar 12, 2008 7:47 pm
Location: Guthrie, OK
Contact:

Re: Please help me with my Qung Fu mod.

Post by Phenom »

Seven,

I've tried your guide to getting flips to work
however I get a compile error stating:

oldone.qc:283: error: Function player_flip was not defined.

I've went through your instructions 2 times now, am i missing something?

If it would help I offer you the current work to look at the location is
http://theendstudios.com/files/QungFu.rar

Just extract and run the go.bat to see the model ingame. The archive has
DP engine and a basic level for model testing. Use chase_active 1 to see
the player model BTW(Player model is default Q1 in this archive).

The new playerX.mdl is also included in this development pack.

Thanks!
Best sig ever.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Please help me with my Qung Fu mod.

Post by Cobalt »

BTW I watched the utube video, could not tell a whole lot from it cause of the way it was made. What you may wana do is make a regular demo via recorddemo-blah, then play it back while the DP AVI capture is running. I have found this is better as you can do full screen, and gives a better overall utube experience.

That error you are seeing in compile is likely because player_flip is being called in oldone.qc and the actual player_flip function is located in a file to be compiled lower in sequence (via progs.src) than oldone.qc ..... Seven said to put: void() player_flip1; in client.qc which means any file processed lower in sequence below client.qc will be able to use that function. What I do is place stuff like that in defs.qc or I make my own new qc file, IE: k-FUdefs.qc and compile it right below defs.qc to make it easier. If you put it in defs.qc you have to put it below the comment in the file that says END sys_globals, otherwise there will be compile problems.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Please help me with my Qung Fu mod.

Post by Seven »

Hello Phenom,

You have this error ?
oldone.qc:283: error: Function player_flip was not defined.
I dont use this function: "player_flip". Neither is this function used in vanilla QC in: oldone.qc
In my example code above i use this function name: "player_flip1"
You most probably have a typo in your file.
The compiler does not excuse any typos :)

The line 283 inside oldone.qc is the very very very last line of the complete Quake QC-source.
So it is the last line that the compiler reads.
oldone.qc has exactly 283 lines and it is the last file inside "progs.src".
So this error message is excpected and correct when you have that typo I mentioned above.
It will compile fine after you corrected your typo.

Have fun,
Seven
Phenom
Posts: 10
Joined: Wed Mar 12, 2008 7:47 pm
Location: Guthrie, OK
Contact:

Re: Please help me with my Qung Fu mod.

Post by Phenom »

Cobalt wrote: if (self.button2)
{
self.sjumpz = self.origin_z; // Where you define sjump (somersault jump) specific float in defs qc via .float sjumpz
PlayerJump ();
}
else
self.flags = (self.flags | FL_JUMPRELEASED);
[/code]

Then in playerjump () you will have something like:
self.velocity_z = (self.velocity_z + 360);

This is what makes the player jump. I dont think it means his new origin_z will be exactly 360 units from where it is before the jump, because physics is involved etc. So what I would do is put some tracing code im maybe playerpostthink () that will print out the actual height as you do some test jumps:

Code: Select all

if (!self.flags & FL_ONGROUND && self.velocity_z)
{
bprint (ftos (self.origin_z));
bprint ("\n");
}
Thank you very much Cobalt, I'm still having an issue.

I'm trying to butcher my way through these QC files every-time an error pops up in my compiler...
However I still don't understand the error syntax and or why files have to be in a specific order,
or what void is and why I get 20% of these errors, that's not including things like forgetting to include "; and ()".

I'm still unable to get any type of frontflip working. it seems like I'm right on the verge but since I've butchered so much
and understand so little I'm probably "trimming the trees with a monster truck" in a sense... heh...

I'd like to get to a point with QC that I could turn around and help a QC noobie learn something new! First I must be the noobie! :)

Here is where I am stuck at now.

Code: Select all

compiling world.qc
compiling client.qc
in function PlayerPreThink (line 72),
client.qc:962: error: Unknown value "sjumpz".
client.qc:962: error: "." - not a name

************ ERROR ************
Errors have occured

It seems "sjumpz" is an unknown value (derrrr) I'm still clueless?
Best sig ever.
Post Reply