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?
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?
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
Reading from the address (https://github.com/kungfooman/libcod...layer.cpp#L331)
Writing to the address (untested):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 0: stance = "stand"; break; // also in spec
case 2: stance = "stand"; break;
case 4: stance = "duck"; break;
case 6: stance = "duck"; break;
case 8: stance = "lie"; break;
case 10: stance = "lie"; break;
default: printf("unknown stance for player id=%d, code=%d\n", id, code);
}
stackPushString(stance);
}
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
Oh yeah tried that but it didn't do anything.
Also decompiled allowstand/allowcrouch/allowprone (With some help) and came up with this;
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).PHP Code:
int* test = (int*)((*(int*)(gentities + id * gentities_size + 344)) + 12);
*test = *test | 0x800001; //80001 = prone I believe.
Last edited by filthy_freak_; 3rd June 2015 at 10:53.
Maybe you need to add the code below after you set it.
Like the melee first bash bug.PHP Code:
*(int *)(state + 216) = 11;
https://github.com/M-itch/libcod/com...a4f6d86ac2ce74
Still same problems.
Here is the output i get before & after setting stance_address;
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.PHP Code:
stance_address = 0 //currently standing
stance_address = 4 //set to crouch
stance_address = 0 //reverted back to standing
stance_address = 4 //rinse and repeat
Last edited by filthy_freak_; 3rd June 2015 at 11:38. Reason: Added more info
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
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;
Having a quick look, setting g_dumpAnims will report current animations being played so that is a start.PHP Code:
if(player.isSprinting)
player setAnimation("pb_sprint");
else
player setAnimation("none"); //reset back to default/reset back to mp/playeranim.script
Last edited by filthy_freak_; 30th June 2015 at 09:43. Reason: Improved example
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.