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

Firing inputs / Setting KeyValues of Entities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
your-name-here
Member
Join Date: May 2007
Old 09-23-2008 , 22:36   Firing inputs / Setting KeyValues of Entities
Reply With Quote #1

Ok so I'm messing around with CreateEntityByName in my C++ plugin. I've managed to set up the signatures and whatnot and am able to spawn an entity (and set it's model). All fine and dandy.

Now, my second objective is to mess around with it's KeyValues and inputs. This is the entity I am looking at http://developer.valvesoftware.com/wiki/Prop_physics.

I remember pRED pointing me to a few virtual functions that set the KeyValues. Ok, got those done too (haven't fully tested them).

My question is this: Check out the inputs for prop_physics http://developer.valvesoftware.com/w...physics#Inputs. Is there a way I can use these inputs?

I'm thinking I'd have to use the virtual function 35 CBaseEntity::AcceptInput(char const*,CBaseEntity*,CBaseEntity*,variant_t,in t), but I'm not sure. If anyone has been able to mess with entity inputs, and would like to point me in the right direction, I'd be greatful
your-name-here is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 09-23-2008 , 23:14   Re: Firing inputs / Setting KeyValues of Entities
Reply With Quote #2

Have a look at the sdktools wrapper-implementation of this function:

Code:
static cell_t AcceptEntityInput(IPluginContext *pContext, const cell_t *params)
{
    if (!g_pAcceptInput)
    {
        int offset;
        if (!g_pGameConf->GetOffset("AcceptInput", &offset))
        {
            return pContext->ThrowNativeError("\"AcceptEntityInput\" not supported by this mod");
        }

        PassInfo pass[6];
        pass[0].type = PassType_Basic;
        pass[0].flags = PASSFLAG_BYVAL;
        pass[0].size = sizeof(const char *);
        pass[1].type = pass[2].type = PassType_Basic;
        pass[1].flags = pass[2].flags = PASSFLAG_BYVAL;
        pass[1].size = pass[2].size = sizeof(CBaseEntity *);
        pass[3].type = PassType_Object;
        pass[3].flags = PASSFLAG_BYVAL|PASSFLAG_OCTOR|PASSFLAG_ODTOR|PASSFLAG_OASSIGNOP;
        pass[3].size = SIZEOF_VARIANT_T;
        pass[4].type = PassType_Basic;
        pass[4].flags = PASSFLAG_BYVAL;
        pass[4].size = sizeof(int);
        pass[5].type = PassType_Basic;
        pass[5].flags = PASSFLAG_BYVAL;
        pass[5].size = sizeof(bool);

        if (!(g_pAcceptInput=g_pBinTools->CreateVCall(offset, 0, 0, &pass[5], pass, 5)))
        {
            pContext->ThrowNativeError("\"AcceptEntityInput\" wrapper failed to initialized");
        }
    }

    CBaseEntity *pActivator, *pCaller, *pDest;
    edict_t *pEdict;
    IServerUnknown *pUnk;

    char *inputname;
    unsigned char vstk[sizeof(void *) + sizeof(const char *) + sizeof(CBaseEntity *)*2 + SIZEOF_VARIANT_T + sizeof(int)];
    unsigned char *vptr = vstk;

    ENTINDEX_TO_CBASEENTITY(params[1], pDest);
    pContext->LocalToString(params[2], &inputname);
    if (params[3] == -1)
    {
        pActivator = NULL;
    } else {
        ENTINDEX_TO_CBASEENTITY(params[3], pActivator);
    }
    if (params[4] == -1)
    {
        pCaller = NULL;
    } else {
        ENTINDEX_TO_CBASEENTITY(params[4], pCaller);
    }

    *(void **)vptr = pDest;
    vptr += sizeof(void *);
    *(const char **)vptr = inputname;
    vptr += sizeof(const char *);
    *(CBaseEntity **)vptr = pActivator;
    vptr += sizeof(CBaseEntity *);
    *(CBaseEntity **)vptr = pCaller;
    vptr += sizeof(CBaseEntity *);
    memcpy(vptr, g_Variant_t, SIZEOF_VARIANT_T);
    vptr += SIZEOF_VARIANT_T;
    *(int *)vptr = params[5];

    bool ret;
    g_pAcceptInput->Execute(vstk, &ret);

    _init_variant_t();

    return (ret) ? 1 : 0;
}
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
your-name-here
Member
Join Date: May 2007
Old 09-24-2008 , 07:52   Re: Firing inputs / Setting KeyValues of Entities
Reply With Quote #3

EDIT AGAIN: I found a post by BAILOPAN which pretty much sums it up for me. http://forums.alliedmods.net/showthread.php?t=61391

+Karma for the help anyway

Last edited by your-name-here; 09-24-2008 at 14:11.
your-name-here 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 09:18.


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