Raised This Month: $12 Target: $400
 3% 

[TF2] detecting if the current shot is critical or not


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
_KaszpiR_
AMX Mod X Beta Tester
Join Date: Feb 2004
Location: Warsaw, Poland
Old 03-29-2009 , 16:21   [TF2] detecting if the current shot is critical or not
Reply With Quote #1

Hey,
I'm trying to detect in game if the currently performed shot (for example rocket) is set as critical or not.
I know game generates those randomly, and I know there is a function to set up shot as critical - I've got a wroking script to change the chanses of the critical shots ( yea, 100% means crits only ;D )

Tried with player_shoot but I feel like it's not hookable in TF2 (I haven't tried actually, though, just some event scritp detector just not triggers as it should disring player_shoot)

I need that to count how many critical shots player performed for statistical measurments.
__________________
= Ave Cesar, morituri Te salutant. = http://nvt.prv.pl = http://hlds.pl/

Last edited by _KaszpiR_; 03-29-2009 at 16:23.
_KaszpiR_ is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 03-29-2009 , 16:30   Re: [TF2] detecting if the current shot is critical or not
Reply With Quote #2

I believe theres a m_bCritical netprop that is set when a shot is critical. There is no weapon_fire or player_shoot in TF2 though. The best option is using TF2_CalcIsAttackCritical.
__________________
CrimsonGT is offline
_KaszpiR_
AMX Mod X Beta Tester
Join Date: Feb 2004
Location: Warsaw, Poland
Old 03-29-2009 , 16:36   Re: [TF2] detecting if the current shot is critical or not
Reply With Quote #3

TF2_CalcIsAttackCritical is just for setting the critical shot or not
it does not show if the current shot is critical or not - ried with debug messages:

PHP Code:
public Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[], &bool:result)
{
    if(
b_critenabled && crits_enabled[client])
    { 
//is plugin enabled?
#if defined DEBUG
        
new String:name[MAX_NAME_LENGTH]
        
GetClientName(clientnamesizeof(name))
#endif 
        
new Float:r=GetRandomFloat(0.01.0);
        if ( 
crits_percent[client]) // if the generated random number is less than percent then set the crit, so 1.0 means always make crit, 0.0 means never crit
        
{
#if defined DEBUG
          
PrintToChat(client"RAW %s : r=%f cp=%f => %d"namer,crits_percent[client],FloatCompare(r,crits_percent[client]))
#endif 
          
result true;

        }
        else {
#if defined DEBUG
          
PrintToChat(client"RAW %s : r=%f cp=%f => %d"namer,crits_percent[client],FloatCompare(r,crits_percent[client]))
#endif 
          
result false;
        }

        if(
result
        {
            
crits_count[client]++
        }
        else 
        {
            
nocrits_count[client]++
        }

#if defined DEBUG2
          
PrintToChat(client"+CRIT/NOCRITS: %d / %d"crits_count[client],nocrits_count[client] )
#endif 

        
return Plugin_Handled;

}
    if(
result)
    {
        
crits_count[client]++
    }
    else 
    {
        
nocrits_count[client]++
    }
#if defined DEBUG2
          
PrintToChat(client"-CRIT/NOCRITS: %d / %d / %b"crits_count[client],nocrits_count[client], result )
#endif 


    
return Plugin_Continue;


__________________
= Ave Cesar, morituri Te salutant. = http://nvt.prv.pl = http://hlds.pl/
_KaszpiR_ is offline
MikeJS
Senior Member
Join Date: Nov 2008
Old 03-29-2009 , 16:43   Re: [TF2] detecting if the current shot is critical or not
Reply With Quote #4

He means use it as a substitute for weapon_fire/player_shoot.
__________________
MikeJS is offline
_KaszpiR_
AMX Mod X Beta Tester
Join Date: Feb 2004
Location: Warsaw, Poland
Old 03-29-2009 , 17:36   Re: [TF2] detecting if the current shot is critical or not
Reply With Quote #5

hmm could you be more specific?
(my first sm plugin, i was writing ppreviously in amxmodx)
__________________
= Ave Cesar, morituri Te salutant. = http://nvt.prv.pl = http://hlds.pl/
_KaszpiR_ is offline
MikeJS
Senior Member
Join Date: Nov 2008
Old 03-29-2009 , 18:01   Re: [TF2] detecting if the current shot is critical or not
Reply With Quote #6

I have no clue how you'd do it, sorry (maybe CTEFireBullets?)
__________________
MikeJS is offline
_KaszpiR_
AMX Mod X Beta Tester
Join Date: Feb 2004
Location: Warsaw, Poland
Old 03-29-2009 , 18:10   Re: [TF2] detecting if the current shot is critical or not
Reply With Quote #7

hmm I guess I gonna resign from this, then
just wanted to get some stats for tests, but I guess its too much hassle to implement it.

thanks for the answers.
__________________
= Ave Cesar, morituri Te salutant. = http://nvt.prv.pl = http://hlds.pl/
_KaszpiR_ is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:59.


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