Raised This Month: $ Target: $400
 0% 

[TF2] Determining if a shot missed?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Alfonso Crawford
Member
Join Date: Feb 2012
Old 03-18-2014 , 14:11   Re: [TF2] Determining if a shot missed?
Reply With Quote #4

Yeah; I just used Attribute #16 for hits. The trick was tying a function to when something didn't happen~

I hooked TF2_CalcIsAttackCritical, per Turt's suggestion, and ended up with this:
PHP Code:
public Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[],
    &
bool:result) {
    if(!
IsValidEntity(weapon)) return Plugin_Continue;
    new 
wIndex GetEntProp(weaponProp_Send"m_iItemDefinitionIndex");
    
    if(
wIndex == 41) {
        
NataschaPunishments[client] += 0.3;
    }
    
    return 
Plugin_Continue;
}


public 
OnClientPutInServer(client) {
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamagePre);
}


public 
Action:OnTakeDamagePre(victim, &attacker, &inflictor, &Float:damage,
    &
damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3]) {
    if(!
IsValidEntity(weapon)) return Plugin_Continue;
    new 
wIndex GetEntProp(weaponProp_Send"m_iItemDefinitionIndex");
    
    if(
wIndex == 41) {
        if(
damage >= 16NataschaPunishments[attacker] -= 1.0;
        else 
NataschaPunishments[attacker] -= 0.1;
    }
    
    return 
Plugin_Continue;
}



public 
OnGameFrame() {
    for(new 
1<= MaxClientsi++) {
        if(!
IsClientInGame(i) || !IsPlayerAlive(i)) {
            
NataschaPunishments[i] = 0.0;
            continue;
        }
        
        if(
NataschaPunishments[i] > 1.0) {
            if(
GetConVarBool(CvarVerbose)) {
                
PrintToChatAll("-%d for missing, baby!",
                    
NataschaPunishments[i]);
            }
            new 
GetEntProp(iProp_Send"m_iHealth");
            
SetEntProp(iProp_Send"m_iHealth"1);
            
NataschaPunishments[i] = 0.0;
        }
    }

This ended up working better than Attribute #204, ultimately. If #204 did decide to play nice, I wouldn't have been able to code in the nuance I needed for this new direction to work.
Alfonso Crawford is offline
 



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 21:28.


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