Results 1 to 4 of 4

Thread: player setAnim(string);

  1. #1
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts

    player setAnim(string);

    With this function you can force a player to play a specified animation using gsc. It can also be used to force a bot to change stance.



    Usage:
    PHP Code:
    player setAnim("pb_crouch_run_forward");
    player setAnim("none"); //reset back to normal 
    It is recommended doing the following on player connect to ensure there are no conflicts;
    PHP Code:
    self setAnim("none"); 
    Installation:
    Open gsc.cpp, CTRL + F and search for "setweaponfiremeleedelay". Then add the following on a new line;
    PHP Code:
    {"setanim"               gsc_player_set_anim           0}, 
    Open gsc_player.hpp, CTRL + F and search for "void gsc_player_setweaponfiremeleedelay(int id);". Then add the following on a new line;
    PHP Code:
    void gsc_player_set_anim(int id); 
    Open gsc_player.cpp, CTRL + F and search for "// entity functions". Then add the following on a new line;
    PHP Code:
    void gsc_player_set_anim(int id)
    {
        
    charanimation;
        
        if ( ! 
    stackGetParams("s", &animation)) {
            
    printf("scriptengine> ERROR: gsc_player_set_anim(): param \"animation\"[1] has to be an string!\n");
            
    stackPushUndefined();
            return;
        }
        
        
    #if COD_VERSION == COD2_1_0
            
    int anim_offset 0x080D46AC;
        
    #elif COD_VERSION == COD2_1_2
            
    int anim_offset 0x080D6C8C;
        
    #elif COD_VERSION == COD2_1_3
            
    int anim_offset 0x080D6DD0;
        
    #endif
        
        
    int (*BG_AnimationIndexForString)(char *src);
        *(
    int *)&BG_AnimationIndexForString anim_offset;
        
        
    int animationIndex 0;
        
    extern int custom_animation[64];
        
        if(
    strcmp(animation"none"))
            
    animationIndex BG_AnimationIndexForString(animation);
        
        
    custom_animation[id] = (animationIndex);

    Open libcod.cpp, CTRL + F and search for "void hook_SV_WriteDownloadToClient(int cl, int msg)". Then add the following function before "void hook_SV_WriteDownloadToClient(int cl, int msg)";
    PHP Code:
    int clientaddress_to_num(int client);
    int custom_animation[64] = {0};
    cHook *hook_set_anim;
    int set_anim(int a1int a2signed int a3int a4int a5int a6int a7)
    {
        
    int clientnum clientaddress_to_num(a1);
        
    extern int playerinfo_baseplayerinfo_size;
        
        if(*(
    int*)(*(int*)playerinfo_base clientnum playerinfo_size) == && custom_animation[clientnum])
        {
            
    a2 custom_animation[clientnum];
            
    a4 0;
            
    a5 1;
            
    a6 0;
            
    a7 1;
        }
        
        
    hook_set_anim->unhook();
        
    int (*sig)(int a1int a2signed int a3int a4int a5int a6int a7);
        *(
    int *)&sig hook_set_anim->from;
        
    int ret sig(a1a2a3a4a5a6a7);
        
    hook_set_anim->hook();
        
        return 
    ret;

    Also while in libcod.cpp, search and add the following new lines depending on your version;

    1.0;
    Search for "cracking_hook_call(0x080707C3, (int)Scr_GetCustomMethod);"
    Add the following on a new line;
    PHP Code:
                hook_set_anim = new cHook(0x080D69B2, (int)set_anim);
                
    hook_set_anim->hook(); 
    1.2;
    Search for "cracking_hook_call(0x08070D3F, (int)Scr_GetCustomMethod);"
    Add the following on a new line;
    PHP Code:
                hook_set_anim = new cHook(0x080D8F92, (int)set_anim);
                
    hook_set_anim->hook(); 
    1.3;
    Search for "cracking_hook_call(0x08070E0B, (int)Scr_GetCustomMethod);"
    Add the following on a new line;
    PHP Code:
                hook_set_anim = new cHook(0x080D90D6, (int)set_anim);
                
    hook_set_anim->hook(); 
    Compile your libcod version and you are done.

    Or download the attached file and compile.
    Attached Files Attached Files
    Last edited by filthy_freak_; 1st July 2015 at 02:01.

  2. The Following 4 Users Say Thank You to filthy_freak_ For This Useful Post:

    kung foo man (1st July 2015),Lonsofore (13th October 2017),maxdamage99 (12th August 2015),Mitch (1st July 2015)

  3. #2
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Good work

  4. #3
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    How do you know all anims? Where are they listed?

  5. #4
    Private First Class php's Avatar
    Join Date
    Nov 2012
    Posts
    142
    Thanks
    28
    Thanked 116 Times in 59 Posts
    for cod2 in iw_07.iwd in file mp\playeranim.script or animtrees\multiplayer.atr

  6. The Following 3 Users Say Thank You to php For This Useful Post:

    kung foo man (4th September 2015),Lonsofore (13th October 2017),Ni3ls (5th September 2015)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •