Page 1 of 3

How to reset the player's sound to normal on player_blind?

Posted: Fri Jan 30, 2015 3:56 pm
by BackRaw
Hi,

the topic title says it lol. Is it possible? On a PreHook maybe? If so, how would I go about that?

Posted: Fri Jan 30, 2015 4:12 pm
by satoon101
You don't want players to be blinded either, correct? If so, I would say to hook CFlashbang::Detonate (not fully sure on the names there). I am at work, so I cannot provide an example till I get home.

*Edit: perhaps CCSPlayer::Blind might work, too. Not sure if that also causes the sound, though.

Posted: Fri Jan 30, 2015 5:05 pm
by BackRaw
satoon101 wrote:You don't want players to be blinded either, correct? If so, I would say to hook CFlashbang: :D etonate (not fully sure on the names there). I am at work, so I cannot provide an example till I get home.

*Edit: perhaps CCSPlayer::Blind might work, too. Not sure if that also causes the sound, though.


Alright, I'm not sure if I want players to be blinded or not yet. That's why I have to figure it out :) Either way, I definitely need to stop the sound from playing, that would add more "Fun" lol :D

Posted: Fri Jan 30, 2015 5:10 pm
by Ayuto
Do you want an anti-flash for everyone or just for some people? In the first case you can just hook CFlashbangProjectile::Detonate().

If you only want to disable that for some specific users, you need to hook CCSPlayer::Deafen() to disable the sound and CCSPlayer::Blind() to disable the blinding part.

Posted: Fri Jan 30, 2015 5:15 pm
by BackRaw
Ayuto wrote:Do you want an anti-flash for everyone or just for some people? In the first case you can just hook CFlashbangProjectile: :D etonate().

If you only want to disable that for some specific users, you need to hook CCSPlayer: :D eafen() to disable the sound and CCSPlayer::Blind() to disable the blinding part.


Awesome, thanks. Can i do it the same way you provided here?

Posted: Fri Jan 30, 2015 5:16 pm
by Ayuto
Yep, that should work.

Posted: Fri Jan 30, 2015 5:29 pm
by BackRaw
How do I find out what parameters I need lol? :D

Posted: Fri Jan 30, 2015 5:42 pm
by Ayuto
Just open IDA and look up those functions:

CCSPlayer::Blind(float, float, float)
CCSPlayer::Deafen(float)

Posted: Fri Jan 30, 2015 6:26 pm
by BackRaw
ayuto wrote:just open ida and look up those functions:

Ccsplayer::blind(float, float, float)
ccsplayer::deafen(float)


ida? =d

Posted: Fri Jan 30, 2015 6:39 pm
by Ayuto
http://en.wikipedia.org/wiki/Interactive_Disassembler

But of course you can also use a different disassembler if you want.

Posted: Fri Jan 30, 2015 7:26 pm
by BackRaw
Ayuto wrote:http://en.wikipedia.org/wiki/Interactive_Disassembler

But of course you can also use a different disassembler if you want.


Good to know!! Thanks :D

Posted: Sat Jan 31, 2015 4:45 am
by satoon101
I have added CFlashbangProjectile::Detonate and CCSPlayer::Blind for CS:S and CS:GO to my data locally. CCSPlayer::Deafen will require a symbol/signature, and seems to be a bit tricky at first glance (no time to work on now, need some sleep). Once we get all 3 added to the repo, you will be able to use/hook them in your scripts more easily.

Posted: Sat Jan 31, 2015 9:52 am
by Ayuto
This is for CS:S:

Code: Select all

_ZN9CCSPlayer6DeafenEf
55 8B EC 83 EC 28 89 4D FC 8B 45 FC 8B 10
I will take a look at CS:GO's signature later today.

Posted: Sat Jan 31, 2015 11:54 am
by BackRaw
I'll be patient :)

Posted: Sat Jan 31, 2015 4:46 pm
by Ayuto
I have now taken a look at CS:GO and found this signature.

Code: Select all

55 8B EC 83 EC 28 56 57 8B F9 F3 0F 11 4D FC
However, this is a special function as it uses a custom calling convention on Windows. The "this" pointer is passed through the ecx register (that's usual for a Windows thiscall), but the other argument is passed through the xmm1 register and that's unusual. There is nothing pushed onto the stack. We can still hook the function, but we can't access its arguments.

Syntax: Select all

import memory

from memory import Convention
from memory import Argument
from memory import Return

from memory.hooks import PreHook

server = memory.find_binary('server')

deafen = server[b'\x55\x8B\xEC\x83\xEC\x28\x56\x57\x8B\xF9\xF3\x0F\x11\x4D\xFC'].make_function(
Convention.THISCALL,
(Argument.POINTER,),
Return.VOID
)

@PreHook(deafen)
def my_hook(args):
print(tuple(args))
return 0

Posted: Sun Feb 01, 2015 1:18 am
by satoon101
Does this also mean we cannot call that function? Stinks that we can't get the arguments, but at least in this instance I don't think he needs them.

Thank you for the signatures :)

Posted: Sun Feb 01, 2015 12:26 pm
by Ayuto
satoon101 wrote:Does this also mean we cannot call that function?
Yep, currently we can't, but we can update our plugin so that we can also handle these special cases. I have several ideas, but I need some time to think about them.

Posted: Sun Feb 01, 2015 2:34 pm
by BackRaw
satoon101 wrote:Does this also mean we cannot call that function? Stinks that we can't get the arguments, but at least in this instance I don't think he needs them.

I guess not. I just need the player_blind event to not fire, e.g. return False or something in the pre event function. I only want the players to be flashed visually, so I would do something like this:

Syntax: Select all

@PreEvent
def pre_player_blind(userid):

player = Player(index_from_userid(userid))

# simulate flashing without sound, just visually
player.set_property_float("m_flFlashMaxAlpha", 200.0)
player.set_property_float("m_flFlashDuration", 1.4)


# either set the player's sound somehow

# or stop player_blind from firing
return False

Posted: Sun Feb 01, 2015 8:24 pm
by satoon101
That's not exactly what I meant. I just mean you don't need access to the float value that is passed to CCSPlayer::Deafen. You can still return False from hooking that method to stop the deafening sound from playing. And, if you do want to know which player is being deafened, you have access to that through args[0] (which is a Pointer).

Posted: Sun Feb 01, 2015 8:31 pm
by BackRaw
satoon101 wrote:That's not exactly what I meant. I just mean you don't need access to the float value that is passed to CCSPlayer: :D eafen. You can still return False from hooking that method to stop the deafening sound from playing. And, if you do want to know which player is being deafened, you have access to that through args[0] (which is a Pointer).


Ooooh, true. I have to think about how I want to implement it first :)