Ok, so here's my update:
void SP_misc_model_ghoul( gentity_t *ent )
{
ent->s.modelindex = G_ModelIndex( ent->model );
gi.G2API_InitGhoul2Model(ent->ghoul2, ent->model, ent->s.modelindex, NULL_HANDLE, NULL_HANDLE, 0, 0);
ent->s.radius = 50;
G_SetOrigin( ent, ent->s.origin );
G_SetAngles( ent, ent->s.angles );
qboolean bHasScale = G_SpawnVector( "modelscale_vec", "1 1 1", ent->s.modelScale );
if ( !bHasScale ) {
float temp;
G_SpawnFloat( "modelscale", "0", &temp );
if ( temp != 0.0f ) {
ent->s.modelScale[0] = ent->s.modelScale[1] = ent->s.modelScale[2] = temp;
bHasScale = qtrue;
}
}
if ( bHasScale ) {
//scale the x axis of the bbox up.
ent->maxs[0] *= ent->s.modelScale[0];
ent->mins[0] *= ent->s.modelScale[0];
//scale the y axis of the bbox up.
ent->maxs[1] *= ent->s.modelScale[1];
ent->mins[1] *= ent->s.modelScale[1];
//scale the z axis of the bbox up and adjust origin accordingly
ent->maxs[2] *= ent->s.modelScale[2];
float oldMins2 = ent->mins[2];
ent->mins[2] *= ent->s.modelScale[2];
ent->s.origin[2] += (oldMins2 - ent->mins[2]);
}
//DT EDIT: Added Ghoul2 animation code - START
G_SpawnInt("startframe", "0", &ent->startFrame);
G_SpawnInt("endframe", "0", &ent->endFrame);
gi.G2API_SetBoneAnim(&ent->ghoul2[0], "model_root", ent->startFrame, ent->endFrame, BONE_ANIM_OVERRIDE_LOOP, 1.0f + crandom() * 0.1f, 0, -1, -1);
ent->endFrame = 0; // don't allow it to do anything with the animation function in G_main
//DT EDIT: Added Ghoul2 animation code - END
gi.linkentity (ent);
Not sure about this line if it's needed:
ent->endFrame = 0; // don't allow it to do anything with the animation function in G_main
I can't work out how to do a pull request thing, so you'll have to manually add it for me.