Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: setStance() possible?

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

    setStance() possible?

    I'v spent the past 5 hours trying to figure out if it's possible to change a player stance using libcod without any luck.

    Is it even possible to do? Or is it a client-side only?

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Did you try to "reverse" the function? Never tested that, but could work.

    Otherwise you could do exexclientcommand("gocrouch") for example.

    http://killtube.org/showthread.php?1...boobs-quot-%29
    timescale 0.01

  3. #3
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by kung foo man View Post
    Did you try to "reverse" the function? Never tested that, but could work.
    Not sure what you mean here.

    Quote Originally Posted by kung foo man View Post
    Otherwise you could do exexclientcommand("gocrouch") for example.
    Won't work for bots.

  4. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Reading from the address (https://github.com/kungfooman/libcod...layer.cpp#L331)

    PHP Code:
    void gsc_player_stance_get(int id) {
        
    int entity gentities id gentities_size;
        
    unsigned char *stance_address = (unsigned char *)(entity 8);
        
    int code = *stance_address 0x0F// just the last 4 bits tell the state

        
    char *stance "";
        switch (
    code) {
            case  
    0stance "stand"; break; // also in spec
            
    case  2stance "stand"; break;
            case  
    4stance "duck"; break;
            case  
    6stance "duck"; break;
            case  
    8stance "lie"; break;
            case 
    10stance "lie"; break;
            default: 
    printf("unknown stance for player id=%d, code=%d\n"idcode);
        }

        
    stackPushString(stance);

    Writing to the address (untested):

    PHP Code:
    void gsc_player_stance_set(int id) {
        
    char *stance;
        if ( ! 
    stackGetParams("s", &stance)) {
            
    printf("scriptengine> ERROR: gsc_player_stance_set(): param \"stance\" has to be a string!\n");
            
    stackPushUndefined();
            return;
        }
        
    int entity gentities id gentities_size;
        
    unsigned char *stance_address = (unsigned char *)(entity 8);
        if ( ! 
    strcmp(stance"stand"))
            *
    stance_address |= 0x00// maybe 0x02
        
    if ( ! strcmp(stance"duck"))
            *
    stance_address |= 0x04// maybe 0x06
        
    if ( ! strcmp(stance"lie"))
            *
    stance_address |= 0x08// maybe 0x0a
        
    stackPushUndefined();

    Last edited by kung foo man; 3rd June 2015 at 10:35. Reason: s/strlen/strcmp
    timescale 0.01

  5. #5
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by kung foo man View Post
    Reading from the address (https://github.com/kungfooman/libcod...layer.cpp#L331)

    PHP Code:
    void gsc_player_stance_get(int id) {
        
    int entity gentities id gentities_size;
        
    unsigned char *stance_address = (unsigned char *)(entity 8);
        
    int code = *stance_address 0x0F// just the last 4 bits tell the state

        
    char *stance "";
        switch (
    code) {
            case  
    0stance "stand"; break; // also in spec
            
    case  2stance "stand"; break;
            case  
    4stance "duck"; break;
            case  
    6stance "duck"; break;
            case  
    8stance "lie"; break;
            case 
    10stance "lie"; break;
            default: 
    printf("unknown stance for player id=%d, code=%d\n"idcode);
        }

        
    stackPushString(stance);

    Writing to the address (untested):

    PHP Code:
    void gsc_player_stance_set(int id) {
        
    char *stance;
        if ( ! 
    stackGetParams("s", &stance)) {
            
    printf("scriptengine> ERROR: gsc_player_stance_set(): param \"stance\" has to be a string!\n");
            
    stackPushUndefined();
            return;
        }
        
    int entity gentities id gentities_size;
        
    unsigned char *stance_address = (unsigned char *)(entity 8);
        if ( ! 
    strcmp(stance"stand"))
            *
    stance_address |= 0x00// maybe 0x02
        
    if ( ! strcmp(stance"duck"))
            *
    stance_address |= 0x04// maybe 0x06
        
    if ( ! strcmp(stance"lie"))
            *
    stance_address |= 0x08// maybe 0x0a
        
    stackPushUndefined();

    Oh yeah tried that but it didn't do anything.

    Also decompiled allowstand/allowcrouch/allowprone (With some help) and came up with this;
    PHP Code:
    inttest = (int*)((*(int*)(gentities id gentities_size 344)) + 12);
    *
    test = *test 0x800001//80001 = prone I believe. 
    Which does have some effect on the stance but seems to get overridden (Player starts prone animation for a split second before it will cancel).
    Last edited by filthy_freak_; 3rd June 2015 at 10:53.

  6. #6
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Maybe you need to add the code below after you set it.
    PHP Code:
    *(int *)(state 216) = 11
    Like the melee first bash bug.
    https://github.com/M-itch/libcod/com...a4f6d86ac2ce74

  7. #7
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Still same problems.

    Here is the output i get before & after setting stance_address;
    PHP Code:
    stance_address //currently standing
    stance_address //set to crouch
    stance_address //reverted back to standing
    stance_address //rinse and repeat 
    Also for the "test" variable, it seems to do the weird split second animation no matter what I set it to which makes me think its not going to be helpful despite being related to player stance.
    Last edited by filthy_freak_; 3rd June 2015 at 11:38. Reason: Added more info

  8. #8
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Did you actually try my version and tested the other "maybe-values"? Only 4 bits define the state, maybe the other 4 bits cause the problem, hence the xor-assignment.

    You can also try to breakpoint on the "write" of that address: http://stackoverflow.com/questions/5...-access-in-gdb

    So you can trace back which function resets the value.
    timescale 0.01

  9. #9
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Hmm, just had a thought of another way to do it.

    Currently meatbot makes the bot play the stand/crouch/prone animation when it shoots their gun. This can only be done via mp/playeranim.script

    So maybe it could be possible to make a libcod function that sets the players current animation using gsc? Could be useful for many things other than bot stances.

    Example;
    PHP Code:
    if(player.isSprinting)
        
    player setAnimation("pb_sprint");
    else
        
    player setAnimation("none"); //reset back to default/reset back to mp/playeranim.script 
    Having a quick look, setting g_dumpAnims will report current animations being played so that is a start.
    Last edited by filthy_freak_; 30th June 2015 at 09:43. Reason: Improved example

  10. #10
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    After doing a bit more research, I have discovered that if you hook bg_playeranimation (sub_80D82A4 on 1.0) and make it return 0, it does have some sort of effect on animations. However only if sv_cheats/devmap is enabled.

Posting Permissions

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