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

[L4D2] help fix the firstperson attachment position and angle when survivor is limp


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
little_froy
Senior Member
Join Date: May 2021
Old 10-21-2021 , 10:39   [L4D2] help fix the firstperson attachment position and angle when survivor is limp
Reply With Quote #1

i desgin to create a attachment and show whether the owner is on firstperson.
once the owner is limp, the position and angle will skewing when look at firstperson.



i need some help to make the attachment look the same whether the owner is limp ...
code is able to find at
https://forums.alliedmods.net/showthread.php?p=2755232
also upload and post the core.
Code:
void set_attach_model(int client, int entity)
{
    if(Infor[client].Has_melee == true)
    {
        char model[PLATFORM_MAX_PATH];
        int melee = create_weapon("weapon_melee", Infor[client].Melee_name);
        if(get_useable_weapon_type(melee) == TYPE_MELEE)
        {
            GetEntPropString(melee, Prop_Data, "m_ModelName", model, PLATFORM_MAX_PATH);
            SetEntityModel(entity, model);
        }
        if(melee > 0 && IsValidEntity(melee))
        {
            RemoveEdict(melee);
        }
    }
    else if(Infor[client].Has_chainsaw == true)
    {
        SetEntityModel(entity, MODEL_W_CHAINSAW);
    }
}

void teleport_attach(int entity)
{
    char model[PLATFORM_MAX_PATH];
    GetEntPropString(entity, Prop_Data, "m_ModelName", model, PLATFORM_MAX_PATH);
    if(strcmp(model, MODEL_W_CHAINSAW) == 0)
    {
        TeleportEntity(entity, O_pos_chainsaw, O_ang_chainsaw, NULL_VECTOR);
    }
    else
    {
        TeleportEntity(entity, O_pos_melee, O_ang_melee, NULL_VECTOR);
    }
}

void add_attach(int client)
{
    if(Infor[client].Attach_ref == 0)
    {
        int entity = CreateEntityByName("prop_dynamic_override");
        if(is_prop_dynamic(entity, true))
        {
            set_attach_model(client, entity);
            DispatchSpawn(entity);
            ActivateEntity(entity);
            SetVariantString("!activator");
            AcceptEntityInput(entity, "SetParent", client);
            SetVariantString("medkit");
            AcceptEntityInput(entity, "SetParentAttachment", entity);
            AcceptEntityInput(entity, "TurnOn");
            AcceptEntityInput(entity, "DisableShadow");
            AcceptEntityInput(entity, "DisableCollision");
            SetEntProp(entity, Prop_Send, "m_noGhostCollision", 1, 1);
            SetEntProp(entity, Prop_Data, "m_CollisionGroup", 0x0004);
            SetEntPropVector(entity, Prop_Send, "m_vecMins", view_as<float>({0.0, 0.0, 0.0}));
            SetEntPropVector(entity, Prop_Send, "m_vecMaxs", view_as<float>({0.0, 0.0, 0.0}));
            teleport_attach(entity);
            SetEntProp(entity, Prop_Data, "m_iEFlags", 0);
            SDKHook(entity, SDKHook_SetTransmit, set_transmit);
            Infor[client].Attach_ref = EntIndexToEntRef(entity);
            Attach_owner[entity] = client;
        }
    }
}
----------------------------------------------
the reason cause the skewing is, when survivor is limp, the model and animation will change.
haven't found a good way fix if still keep to design to show it on firstperson.

Last edited by little_froy; 04-18-2023 at 08:32.
little_froy is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 10-21-2021 , 11:09   Re: [L4D2] help fix the firstperson attachment position and angle when survivor is li
Reply With Quote #2

I couldn't understand what you need.
If is something related to only show on third/first person you can check the Legs plugin from Lux which has some rules whether display or not
__________________
Marttt is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-21-2021 , 12:09   Re: [L4D2] help fix the firstperson attachment position and angle when survivor is li
Reply With Quote #3

Problem maybe is, when you do all things in same code sequence.
It need little delay between create entity and teleport+attach entity.
Either with timer 0.1 sec or try request next frame.
Bacardi 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 18:30.


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