Raised This Month: $51 Target: $400
 12% 

Attached model in v_model (The Specialists)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gian_Yagami
Member
Join Date: Apr 2014
Old 04-09-2020 , 13:03   Attached model in v_model (The Specialists)
Reply With Quote #1

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(!infotargetinfotarget engfunc(EngFunc_AllocString"info_target"//instance an entity
    
    
g_weaponent[id] = engfunc(EngFunc_CreateNamedEntityinfotarget//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_SetModelg_weaponent[id], g_weaponmodel//g_weaponmodel is attachment backweapons
        
set_pev(g_weaponent[id], pev_classnameg_weaponclass//why need g_weaponclass? they just attached object
        
set_pev(g_weaponent[id], pev_movetypeMOVETYPE_FOLLOW//command to follow target(?)
        
set_pev(g_weaponent[id], pev_effectsEF_NODRAW//no idea
        
set_pev(g_weaponent[id], pev_aimentid//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.

Last edited by Gian_Yagami; 04-12-2020 at 01:20. Reason: specific mod
Gian_Yagami is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-09-2020 , 13:09   Re: Attached model in v_model
Reply With Quote #2

Attachments are used for muzzle flashes. Most v_ models in all games use them.
__________________
gabuch2 is offline
Gian_Yagami
Member
Join Date: Apr 2014
Old 04-09-2020 , 21:28   Re: Attached model in v_model
Reply With Quote #3

I've tried to modify to fit on the specialists and make it attached to v_model entity by calling event CurWeapon on the specialists, but my script does not catch this event.


PHP Code:
#include <amxmodx> 
#include <engine> 
#include <fakemeta> 
#include <tsconst>


#define PLUGIN_NAME    "Custom Hands Model"
#define PLUGIN_AUTHOR    "Gian_Yagami"
#define PLUGIN_VERSION    "0.1"

#define MAX_PLAYERS         32

new VIEW_MODEL[]    = "models/v_knife.mdl" 

new g_handClass[] = "v_hands"

new g_handEnt[MAX_PLAYERS+1]


public 
plugin_init() 
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)     
    
register_event("CurWeapon""Event_CurWeapon""be","1=1")
    
//register_forward(FM_SetModel, "fw_SetModel")


public 
plugin_precache() 
{    
    
precache_model(VIEW_MODEL)


public 
Event_CurWeapon(id
{     
    
log_amx("this is called!!")
    new 
weaponID read_data(2

    if(
weaponID != TSW_KUNG_FU)
        return 
PLUGIN_CONTINUE

    
static infotarget
    
if(!infotarget)
        
infotarget engfunc(EngFunc_AllocString"info_target")

    
g_handEnt[id] = engfunc(EngFunc_CreateNamedEntityinfotarget)
    if(
pev_valid(g_handEnt[id]))
    {
        
log_amx("this is running!")
        
engfunc(EngFunc_SetModelg_handEnt[id], VIEW_MODEL//I just want to try that is work to attached model into v_model, so I am attach knife when player unarmed/kung fu
        
set_pev(g_handEnt[id], pev_classnameg_handClass)
        
set_pev(g_handEnt[id], pev_movetypeMOVETYPE_FOLLOW)
        
set_pev(g_handEnt[id], pev_effects1)
        
set_pev(g_handEnt[id], pev_aimentid)
    }
    
    return 
PLUGIN_CONTINUE 
}

public 
client_disconnect(id)
{
    if(
g_handEnt[id] > && pev_valid(g_handEnt[id]))
        
engfunc(EngFunc_RemoveEntityg_handEnt[id])
    
    
g_handEnt[id] = 0
}

/*public fw_SetModel(entity, model[])
{
    if(!is_valid_ent(entity)) 
        return FMRES_IGNORED

    if(!equali(model, OLDWORLD_MODEL)) 
        return FMRES_IGNORED

    new className[33]
    entity_get_string(entity, EV_SZ_classname, className, 32)
    
    if(equal(className, "weaponbox") || equal(className, "armoury_entity") || equal(className, "grenade"))
    {
        engfunc(EngFunc_SetModel, entity, WORLD_MODEL)
        return FMRES_SUPERCEDE
    }
    return FMRES_IGNORED
}*/ 
Gian_Yagami is offline
Gian_Yagami
Member
Join Date: Apr 2014
Old 04-09-2020 , 22:35   Re: Attached model in v_model
Reply With Quote #4

I tried to use hamsandwich but it gaves me error:

Code:
L 04/10/2020 - 09:32:29: Info (map "ts_awaken") (file "addons/amxmodx/logs/error_20200410.log")
L 04/10/2020 - 09:32:29: [HAMSANDWICH] Failed to retrieve classtype for "AK47", hook for "Event_CurWeapon" not active.
L 04/10/2020 - 09:32:29: [AMXX] Displaying debug trace (plugin "hands.amxx")
L 04/10/2020 - 09:32:29: [AMXX] Run time error 10: native error (native "RegisterHam")
L 04/10/2020 - 09:32:29: [AMXX]    [0] hands.sma::plugin_init (line 19)
PHP Code:
#include <amxmodx> 
#include <engine> 
#include <tsconst>
#include <fakemeta>
#include <hamsandwich>


#define PLUGIN_NAME    "Custom Hands Model"
#define PLUGIN_AUTHOR    "Gian_Yagami"
#define PLUGIN_VERSION    "0.1"


public plugin_init() 
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)     
    
//register_event("CurWeapon", "Event_CurWeapon", "be","1=1")
    
RegisterHam(Ham_Item_Deploy"AK47""Event_CurWeapon"1//I don't have information with entity name



public 
Event_CurWeapon(ent
{
    static 
idid pev(entpev_owner)
    
client_print(idprint_chat"Hi!")

Gian_Yagami is offline
Gian_Yagami
Member
Join Date: Apr 2014
Old 04-10-2020 , 03:51   Re: Attached model in v_model (The Specialists)
Reply With Quote #5

Solved: This is nothing wrong with my code, the specialists has different fundamental code or whatever you call this. I try my code to half-life and CurWeapon is works fine.

And my guess was right, v_models are part of player entity and it will render only in first person mode. This making my new entity attached to game world. still can't figure it how to do with first person model
Gian_Yagami is offline
DJBosma
Member
Join Date: Dec 2009
Old 04-10-2020 , 05:28   Re: Attached model in v_model (The Specialists)
Reply With Quote #6

Quote:
Originally Posted by Gian_Yagami View Post
I want to make v_handmodel works like garry's mod
What does that even mean?
DJBosma is offline
Gian_Yagami
Member
Join Date: Apr 2014
Old 04-10-2020 , 06:25   Re: Attached model in v_model (The Specialists)
Reply With Quote #7

Quote:
Originally Posted by DJBosma View Post
What does that even mean?
lol, sorry for not clearly.
Like this: https://wiki.facepunch.com/gmod/Using_Viewmodel_Hands
Gian_Yagami is offline
DJBosma
Member
Join Date: Dec 2009
Old 04-10-2020 , 06:55   Re: Attached model in v_model (The Specialists)
Reply With Quote #8

Quote:
Originally Posted by Gian_Yagami View Post
lol, sorry for not clearly.
Like this: https://wiki.facepunch.com/gmod/Using_Viewmodel_Hands
I do not understand it. v_hands is a texture in the weapon model in CS 1.6, are you talking about hands_reference ? What is it you are trying to accomplish exactly?

Last edited by DJBosma; 04-10-2020 at 06:57.
DJBosma is offline
Gian_Yagami
Member
Join Date: Apr 2014
Old 04-10-2020 , 07:52   Re: Attached model in v_model (The Specialists)
Reply With Quote #9

Quote:
Originally Posted by DJBosma View Post
I do not understand it. v_hands is a texture in the weapon model in CS 1.6, are you talking about hands_reference ? What is it you are trying to accomplish exactly?
have u tried cs:go? it's similar.

the game uses different hand, u can check it here: https://gamebanana.com/skins/cats/7640

the point that I want to achieve is implement same method as they do in cs:go or garry's mod.

as I write above, I make it on the specialists. But that game uses different event for weaponswich so I tried to half-life with TS model as a sample.

afaik there's a method implemented in counter-strike online (now become nexon studios) using submodel. But sub-model had limitation

Anyway it's not 100% solved but I figured out my own question

Last edited by Gian_Yagami; 04-10-2020 at 07:55.
Gian_Yagami is offline
DJBosma
Member
Join Date: Dec 2009
Old 04-10-2020 , 09:06   Re: Attached model in v_model (The Specialists)
Reply With Quote #10

Didn't knew that. I know that the texture is laying on the mesh. So in your case, overlap in some way but how is it going to detect the UI map. If you have 10 guns X 4 hands - 40 models wouldn't be the brightest solution either.

I've been thinking about this, I will follow this thread for any further updates.

Last edited by DJBosma; 04-10-2020 at 09:08.
DJBosma is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode