So I did some looking around on this topic, and I eventually found
this helpful thread. I followed Powerlord's suggestion, and I wound up with the following code:
If you're curious, IsValidMulti is a custom stock that checks if a client is valid, as well as if they meet various conditions depending on what's passed to it. In this case, I use it to make sure the possessed player is alive, and to make sure the possessor is both alive and a boss (this is meant as part of a Freak Fortress ability pack).
Code:
public Action:possessed(client) //PreThink hook, used to set the client's buttons each frame.
{
if (IsValidMulti(client, true, true, false) && IsValidMulti(possession_Possessor[client]) && FF2_HasAbility(FF2_GetBossIndex(possession_Possessor[client]), SPOOK, POSSESSION))
{
new buttons = GetClientButtons(possession_Possessor[client]); //Grab the buttons of whoever is controlling this player
SetClientButtons(client, buttons); //Set the possessed player's buttons in accordance with the above
}
}
public void SetClientButtons(int client, int buttons) //Borrowed from entity_prop_stocks and modified
{
if (IsValidClient(client))
{
char datamap[32];
GameData gc = new GameData("core.games");
bool exists = gc.GetKeyValue("m_nButtons", datamap, sizeof(datamap));
delete gc;
if (!exists)
{
strcopy(datamap, sizeof(datamap), "m_nButtons");
}
SetEntProp(client, Prop_Data, datamap, buttons);
}
}
The code is successful in letting me control when the possessed player shoots or uses alt-fire, but it doesn't do anything else. Does anyone have any ideas?
__________________
Professional retard. I might borrow some code, but I always try to give credit when I do! If you've noticed I've borrowed some of your code, and you have a problem with that, please
add me on Steam and let me know so I can correct the problem as soon as possible!