Hi, long time no post.
This maybe someone had ask about this, I want to make v_handmodel works like garry's mod,
I've seen there's a plugin called
backweapons for cs 1.6.
They use Engine method to instance info_target entity and then use pev_aiment & MOVETYPE_FOLLOW to make it attached to player models.
I will show his code and analyze it as far as I know, please review it (since i've longtime not to learn amx again)
PHP Code:
public client_putinserver(id) //this method will called whenever player is connected, uses id variable as entity_id (which is player itself)
{
static infotarget //why it's static? I don't know, is that because this is declaration dump?
if(!infotarget) infotarget = engfunc(EngFunc_AllocString, "info_target") //instance an entity
g_weaponent[id] = engfunc(EngFunc_CreateNamedEntity, infotarget) //this is also another declaration but this is create new entity with previous 'infotarget' object
if(pev_valid(g_weaponent[id])) //does this for checking pev_ ?
{
engfunc(EngFunc_SetModel, g_weaponent[id], g_weaponmodel) //g_weaponmodel is attachment backweapons
set_pev(g_weaponent[id], pev_classname, g_weaponclass) //why need g_weaponclass? they just attached object
set_pev(g_weaponent[id], pev_movetype, MOVETYPE_FOLLOW) //command to follow target(?)
set_pev(g_weaponent[id], pev_effects, EF_NODRAW) //no idea
set_pev(g_weaponent[id], pev_aiment, id) //I suppose this is for positioning target
}
}
and that plugins also have backweapons.mdl which is had submodel and bone of player model.
my thought it's for following bones of their target (player itself)
This is similar how p_models works, so I think we can do the same thing for viewmodels but since they're tend to
visual purpose only objects which is always on player screen
and not something spawned to game world as backweapons did.
my idea is I make hand model separately and attach it to v_model since backweapons had synchronize hierarchy bones, making they sharing animation clip. This method is closely to gmod.
But I am not sure since entity is something spawned to game world so v_model is part of player entity, this means if my thought correct, I need information how I can attach to entity attribute like v_model.
Anyway I found it on the specialists v_model, they have attachment point.