changing NPC walking speed Created 2 months ago2018-09-12 12:21:04 UTC by hfc hfc

Created 2 months ago2018-09-12 12:21:04 UTC by hfc hfc

Posted 2 months ago2018-09-12 12:21:04 UTC Post #340855
i couldn't find in the sdk
Posted 2 months ago2018-09-12 13:40:55 UTC Post #340856
The code doesn't handle that, the sequence/animation in the model's QC does.
Shepard62700FR Shepard62700FRHalf-Cat is watching...
Posted 2 months ago2018-09-12 13:47:50 UTC Post #340857
ok thanks :)
Posted 2 months ago2018-09-12 13:57:42 UTC Post #340858
but how game knows which animation sequence belongs to movement?
Posted 2 months ago2018-09-12 16:04:29 UTC Post #340859
The game looks up animations based on which activity is associated with the animation.
Posted 2 months ago2018-09-12 16:18:17 UTC Post #340860
are there any associations on codes? i dont see walk animations' names defined in sdk.
Posted 2 months ago2018-09-12 16:51:09 UTC Post #340861
This is the list of activities:

The game looks up which animation has the activity set for it. Check the QC file for which animations have which activities.

As far as movement goes, each animation defines how far it moves. The root bone is used to determine where the animation starts and ends, end - start (position in last frame - position in first frame) determines how far movement goes, the rotation defined for the animation affects which direction movement will go in.

Movement speed is determined by movement distance * (framerate / number of frames - 1). The fewer frames and the higher the framerate, the faster movement will be.
If there are no frames then movement speed is always 0.

None of the models in the SDK specify rotation, so don't be surprised if it doesn't work properly.

The function used to extract movement speed can be found here:

pflGroundSpeed is movement speed, pflFrameRate is the framerate for the animation, which is independent of the entity framerate. The final framerate is pflFrameRate * entity framerate, so movement speed will be affected by that as well.

The actual movement is performed here:

Some entities may override this so check their MoveExecute method. If you wanted to, you could add a keyvalue that overrides the animation movement speed, or that multiplies it to speed up/slow down the entity.
Posted 2 months ago2018-09-13 06:36:07 UTC Post #340862
I have to ask more sorry but im not a professional coder. :)

void CXenTree :: Attack( void )
if ( GetActivity() == ACT_IDLE )
SetActivity( ACT_MELEE_ATTACK1 );
pev->framerate = RANDOM_FLOAT( 1.0, 1.4 );

When i check tree.mdl there is 2 animations. idle1 and attack
Second animation is attack and indexed 1 (the other one is indexed 0)
But how game knows attack in model file is actually ACT_MELEE_ATTACK1 from activity.h

Is there a list says;
ACT_IDLE = idle1
Posted 2 months ago2018-09-13 07:16:49 UTC Post #340863
QC file
Shepard62700FR Shepard62700FRHalf-Cat is watching...
Posted 2 months ago2018-09-13 08:30:07 UTC Post #340864
thank you both of you :) problem solved. But unfortunatery it seems i have to study way more for modding.
Posted 2 months ago2018-09-14 01:31:28 UTC Post #340872
Yes, it will have to be done via animation creation. A quick breakdown:

Here is an imported scientist model walk and what it looks like in blender:
User posted image
Im using an example from the gordon scientist model in bshift who's walking sequence moves Bip01 forward about 48 units (-48Y as it says in the blender inspector) which means he will move 48 hammer units per animation cycle (how ever many frames at how ever fps, this gif does not represent final fps).

Now basically in order to make an NPC "move" you make a walking animation and have the root bone (Often called "Bip01" as per standard HL skeletons) keyframed to move forward a set distance (depending how fast your custom NPC is moving) and with linear keyframes for just that root bone. See my above example of that scientist walk

The way I test to see if extraction is working is open the compiled model in HLMV and go to the "walk" animation. If it is walking in place then the extraction worked.

A while back I made 2 methods of "fixing" walk animations that drag but this exact method can be used to change existing NPC movement speeds, so use a higher number for more distance per loop cycle and a lower number for slower distance per loop cycle
Blender method
3dsmax method
Posted 2 months ago2018-09-14 15:40:05 UTC Post #340877
gonna read all of your tuts thanks.
You must be logged in to post a response.