Jump to content

Setting animations via console? (SP)


Recommended Posts

Posted

I wanna write a command into g_svcmds that lets you play animations/freeze them at a certain frame, but I have no idea how (What's new, right?). I've searched VS for anything related to "pause", but the closest I got was this:

 

 

 


if ( self->playerModel >= 0 )
{
// don't let 'em animate
gi.G2API_PauseBoneAnimIndex( &self->ghoul2[self->playerModel], self->rootBone, cg.time );
gi.G2API_PauseBoneAnimIndex( &self->ghoul2[self->playerModel], self->motionBone, cg.time );
gi.G2API_PauseBoneAnimIndex( &self->ghoul2[self->playerModel], self->lowerLumbarBone, cg.time );
anim = -1;
}

 

 

Posted

The ghoul2 code should always be a place you look if you're trying to do something like this.

 

At a glance, that looks like what you'd need. You can use it to pause parts of the bone hierarchy or all of it. The "anim" line looks to be forcing no animation to play, though.

Posted

Here's what I put in, if it helps:

 

 

 

static void Svcmd_SetAnim_f(int animNumber)
{
char *cmd;
char *cmd2;
const char *newVal = gi.argv(1);
int anim;
int val = atoi(newVal);
 
if (!&g_entities[0] || !g_entities[0].client)
{
return;
}
 
cmd = gi.argv(1);
cmd2 = gi.argv(2);
 
if (!*cmd)
{
gi.Printf("USAGE: setAnim <anim> <frame>\n");
}
 
if (!VALIDSTRING(newVal))
{
gi.Printf(S_COLOR_RED "Invalid amimation or frame value\n");
gi.Printf(S_COLOR_RED "USAGE: setAnim <animNumber> <frame>\n");
return;
}
 
else if (Q_stricmp(cmd, g_entities[0].client->activeAnim[animNumber]) == 0)
{
if (g_entities[0].client->playerModel >= 0)
{
g_entities[0].client->ps.torsoAnimTimer = g_entities[0].client->ps.legsAnimTimer = g_entities[0].client->activeAnim[animNumber];
if (Q_stricmp(cmd2, val) == 0)
{
// don't let 'em animate
gi.G2API_PauseBoneAnimIndex(&g_entities[0].client->ghoul2[self->playerModel], g_entities[0].client->rootBone, val);
gi.G2API_PauseBoneAnimIndex(&g_entities[0].client->ghoul2[self->playerModel], g_entities[0].client->motionBone, val);
gi.G2API_PauseBoneAnimIndex(&g_entities[0].client->ghoul2[self->playerModel], g_entities[0].client->lowerLumbarBone, val);
anim = -1;
}
}
}
}
 
static void Svcmd_AnimReset_f(void)
{
if (!&g_entities[0] || !g_entities[0].client)
{
return;
}
 
else
{
NPC_SetAnim(g_entities[0], SETANIM_LEGS, g_entities[0].client->ps.legsAnim, SETANIM_FLAG_NORMAL | SETANIM_FLAG_RESTART);
NPC_SetAnim(g_entities[0], SETANIM_TORSO, g_entities[0].client->ps.torsoAnim, SETANIM_FLAG_NORMAL | SETANIM_FLAG_RESTART);
}
}

 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...