AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [TF2] Play unused Shortstop shove anim (https://forums.alliedmods.net/showthread.php?t=292910)

Pelipoika 01-17-2017 16:02

[TF2] Play unused Shortstop shove anim
 
PHP Code:

#include <sdktools>
#include <sdkhooks>
#include <dhooks>

#pragma newdecls required

//DHook
Handle g_hGetSecondaryAttackActivity

//SDKCall
Handle g_hSDKPlayGesture;

public 
Plugin myinfo 
{
    
name "[TF2] ",
    
author "Pelipoika",
    
description "",
    
version "1.0",
    
url "http://www.sourcemod.net/plugins.php?author=Pelipoika&search=1"
};

//tf_weapon_handgun_scout_primary 
//ACT_MP_PUSH_STAND_SECONDARY  1817
//ACT_MP_PUSH_CROUCH_SECONDARY 1818
//ACT_MP_PUSH_SWIM_SECONDARY   1819
//CTFPlayer::PlayGesture "mp_playgesture: unknown sequence or act"

public void OnPluginStart()
{
    
//CTFPistol_ScoutPrimary::SecondaryAttack
    
g_hGetSecondaryAttackActivity DHookCreate(279HookType_EntityReturnType_IntThisPointer_CBaseEntityCTFPistol_ScoutPrimary__SecondaryAttack);
    
DHookAddParam(g_hGetSecondaryAttackActivityHookParamType_CBaseEntity);
    
    
StartPrepSDKCall(SDKCall_Player);
    
PrepSDKCall_SetSignature(SDKLibrary_Server"\x55\x8B\xEC\x83\xEC\x30\x53\x56\x8B\x75\x08\x57\x56\x8B\xF9\xE8\x2A\x2A\x2A\x2A\x8B\xD8\x83\xFB\xFF\x74\x2A\x8B\x35\x2A\x2A\x2A\x2A\x8B\xCE\x8B\x16\xFF\x52\x64\x8B\x8F\xF0\x1F\x00\x00\x53\x6A\x14"49);
    
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
    if ((
g_hSDKPlayGesture EndPrepSDKCall()) == INVALID_HANDLESetFailState("Failed to create SDKCall for CTFPlayer::PlayGesture offset!");
}

public 
void OnEntityCreated(int ent, const char[] classname)
{
    if(
StrEqual(classname"tf_weapon_handgun_scout_primary"))
    {
        
SDKHook(entSDKHook_SpawnOnCTFPistol_ScoutPrimarySpawn);
    }
}

public 
void OnCTFPistol_ScoutPrimarySpawn(int wep)
{
    
DHookEntity(g_hGetSecondaryAttackActivitytruewep);
}

public 
MRESReturn CTFPistol_ScoutPrimary__SecondaryAttack(int pThisHandle hReturnHandle hParams)
{
    
int client GetEntPropEnt(pThisProp_Data"m_hOwnerEntity");
    if(
client 0)
    {
        if(
GetEntProp(clientProp_Send"m_nWaterLevel") >= 2)
        {
            
SDKCall(g_hSDKPlayGestureclient"ACT_MP_PUSH_SWIM_SECONDARY");
        }
        else if(
GetEntProp(clientProp_Send"m_bDucked")) 
        {
            
SDKCall(g_hSDKPlayGestureclient"ACT_MP_PUSH_CROUCH_SECONDARY");
        }
        else         
        {
            
SDKCall(g_hSDKPlayGestureclient"ACT_MP_PUSH_STAND_SECONDARY");
        }
    }
    
    return 
MRES_Ignored;


DHooks and stuff, if you're gonna release this or something put the gamedata in a config

404UserNotFound 01-17-2017 19:07

Re: [TF2] Play unused Shortstop shove anim
 
This started out as an idea for a plugin I had after reading that the shortstop's thirdperson (or "world") shove anims are present but unused entirely ingame.

After some dicking around with things myself for an hour and a half, Peli made a working plugin within like 5 minutes.

Yer a wizard, Peli.

And big thanks to /r/tf2 user Very_geeky_and_sad for a comment he posted regarding the unused shove animations. That's why this whole idea came to be.

xXDeathreusXx 01-19-2017 19:49

Re: [TF2] Play unused Shortstop shove anim
 
How did you find the ACT_ definitions? Are they stored in the model, or?

404UserNotFound 01-19-2017 21:18

Re: [TF2] Play unused Shortstop shove anim
 
Quote:

Originally Posted by xXDeathreusXx (Post 2488185)
How did you find the ACT_ definitions? Are they stored in the model, or?

I grabbed em from Hammer for Peli. Create prop_dynamic, set model, choose player model in the Hammer model browser. Select activities tab. Done. I'm sure there are easier ways to get the ACT_ definitions, but the Hammer method also has the 3D model preview so you can actually view the animation associated with each ACT_.

nosoop 01-19-2017 23:51

Re: [TF2] Play unused Shortstop shove anim
 
Quote:

Originally Posted by abrandnewday (Post 2488204)
I'm sure there are easier ways to get the ACT_ definitions, but the Hammer method also has the 3D model preview so you can actually view the animation associated with each ACT_.

Just took a look through HLMV myself. Turns out you can also use that, which is pretty handy since it already comes bundled with TF2.

Load in the model, tick View → Show Activities, and browse the animations with the dropdown in the Sequence tab.

404UserNotFound 01-20-2017 12:57

Re: [TF2] Play unused Shortstop shove anim
 
Shit, and here I thought it only showed the sequence names and not the "ACT" names. Good to know! Thanks nosoop, you've saved the day again :D


EDIT: I released an actual factual plugin for this that you can use for Windows/Linux servers!

Chdata 01-29-2017 04:35

Re: [TF2] Play unused Shortstop shove anim
 
Can any other animations be played through this method?

Pelipoika 01-29-2017 08:12

Re: [TF2] Play unused Shortstop shove anim
 
Quote:

Originally Posted by Chdata (Post 2490769)
Can any other animations be played through this method?

Spoiler

Chdata 01-29-2017 14:04

Re: [TF2] Play unused Shortstop shove anim
 
So combined with that stuff from Stop That Tank we have some neat stuff to play with

PHP Code:

/*
    Animation Sequences
    Thanks to Stop That Tank!
*/

static Handle:g_hSDKSendWeaponAnim;
static 
Handle:g_hSDKPlaySpecificSequence;

stock OnPluginStart_RegisterAnimData()
{
    new 
Handle:hGameData LoadGameConfigFile("anim.data");
    if (
hGameData == INVALID_HANDLE)
    {
        
SetFailState("Unable to load required gamedata (anim.data.txt)");
    }

    
// This call is used to play the knife blocked animation.
    
StartPrepSDKCall(SDKCall_Entity);
    
PrepSDKCall_SetFromConf(hGameDataSDKConf_Signature"CTFWeaponBase::SendWeaponAnim");
    
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
    
g_hSDKSendWeaponAnim EndPrepSDKCall();

    if (
g_hSDKSendWeaponAnim == INVALID_HANDLE)
    {
        
StartPrepSDKCall(SDKCall_Entity);
        
PrepSDKCall_SetFromConf(hGameDataSDKConf_Virtual"CTFWeaponBase::SendWeaponAnim");
        
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
        
g_hSDKSendWeaponAnim EndPrepSDKCall();
        if (
g_hSDKSendWeaponAnim == INVALID_HANDLE)
        {
            
LogMessage("Failed to create call: CTFWeaponBase::SendWeaponAnim!");
        }
    }

    
// This call is used to set the deploy animation on the robots with the bomb
    
StartPrepSDKCall(SDKCall_Player);
    
PrepSDKCall_SetFromConf(hGameDataSDKConf_Signature"CTFPlayer::PlaySpecificSequence");
    
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
    
g_hSDKPlaySpecificSequence EndPrepSDKCall();
    if (
g_hSDKPlaySpecificSequence == INVALID_HANDLE)
    {
        
LogMessage("Failed to create call: CTFPlayer::PlaySpecificSequence!");
    }
}

stock SDK_SendWeaponAnim(weaponanim)
{
    if (
g_hSDKSendWeaponAnim != INVALID_HANDLE)
    {
        
SDKCall(g_hSDKSendWeaponAnimweaponanim);
    }
}

stock SDK_PlaySpecificSequence(clientString:strSequence[])
{
    if (
g_hSDKPlaySpecificSequence != INVALID_HANDLE)
    {
        
SDKCall(g_hSDKPlaySpecificSequenceclientstrSequence);
    }


anim.data.txt
Code:

"Games"
{
    "tf"
    {
        "Signatures"
        {
            "CTFPlayer::PlaySpecificSequence"
            {
                "library"  "server"
                "linux"    "@_ZN9CTFPlayer20PlaySpecificSequenceEPKc"
                "windows"  "\x55\x8B\xEC\x83\xEC\x30\x53\x56\x8B\x75\x08\x57\x56\x8B\xF9\xE8\x2A\x2A\x2A\x2A\x8B\xD8\x83\xFB\xFF\x74\x2A\x8B\x35\x2A\x2A\x2A\x2A\x8B\xCE\x8B\x16\xFF\x52\x2A\x8B\x8F\x2A\x2A\x2A\x2A\x53\x6A\x13\x8B\x01\xFF\x50"
            }
            "CTFWeaponBase::SendWeaponAnim"
            {
                "library"  "server"
                "linux"    "@_ZN13CTFWeaponBase14SendWeaponAnimEi"
            }
        }
        "Offsets"
        {
            "CTFWeaponBase::SendWeaponAnim"
            {
                "library"  "server"
                "linux"    "247"
                "windows"  "241"
            }
        }
    }
}

Stun animation on knives when backstabbing Razorback.
PHP Code:

SDK_SendWeaponAnim(iWeapon0x61B); 

They also have one for CTFPlayer::Taunt or w/e, dunno if it's any much different from things like what tauntem does though.

404UserNotFound 01-29-2017 18:22

Re: [TF2] Play unused Shortstop shove anim
 
It's a shame that there's not yet any viable way of setting up an automatic gamedata generator or some sort of autoupdating "master gamedata" file that other developers could hook into when things requiring offsets/signatures come into play. Or even any way to actively make the plugin search for the offsets/signatures itself and have the plugin update them when they update in the gamedata file.


All times are GMT -4. The time now is 18:54.

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