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

[TF2] change crit of a person.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
slipvyne
Junior Member
Join Date: Jun 2009
Old 06-17-2009 , 19:46   [TF2] change crit of a person.
Reply With Quote #1

First off i wanna say thank you to pRED for a model on how to do this. I wrote this from scratch, but took some concepts from his plugin found here: http://forums.alliedmods.net/showthr...ht=crit+change


I am having trouble with a critical change/modify plugin i have written.

Functionality-
It has 3 main working parts.
-The first being given a player name and a bool var, that player will always crit
-The second is a class "restrict" cvars. If turned to 0, they that class will always crit.
-The third is a simple % change. This changes how often, server wide, plays will crit. The mechanics of this is dumbed down, and i would like help on this to give it better rates that are more like server crits. Right now its random. Unlike when the pyro/heavy/medic crits with their respective weapons in a vanilla server, this will just do a percentage. IE, when a heavy crits, the next 30 or so bullets from its chaingun will crit as well, while this, a random one in cvar% will crit

The main problem I am having though, is i want to create a bool cvar that will essentially turn off the plugin, so crits act like a vanilla unmodified server. What it does now, is completely turns off crits. I was told in MIRC chat that as long as i do not change the result arguement in the function i am overloading, it will not effect the server's calculations. But the only time i ahve found it to crit is when i have the backburner. And yes, the kritskreig does not crit either.

This is my first plugin I have written so I am still very new to the game. I am a CS major at ASU, and really looking for a way to practice code. I have a coding background, but I am very new to scripting so please be gentle on the faults you do find. Any help and posts is much appreciated.

Side note, there is alot of commented out code, I am also working with a few others who are not as well adjusted to coding. Basiclly trying to help them understand what each function does.
Attached Files
File Type: sp Get Plugin or Get Source (critChange.sp - 519 views - 6.7 KB)
slipvyne is offline
Send a message via AIM to slipvyne Send a message via MSN to slipvyne
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 06-17-2009 , 21:29   Re: [TF2] change crit of a person.
Reply With Quote #2

So its completely turning off any crits from happening when the plugin is disabled? Are you sure? You checked? Im not the most experienced coder around but it shouldnt do that. I have that crit code in my rtd plugin and all it does is set a variable to 1 on a player(PlayerCrits = 1;) and have a check under the crit code. (This is obviously for 100% crits for a specific player).

Not sure that helps you any but..it shouldnt change the normal rate of crits on the server, I know it doesnt on mine. Maybe its how you did the enabled check or something. I only glanced at the script.

Code:
public Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:result)
{
        if(pluginInUse && PlayerCrits && client == PlayerUsing)
        {
                result = true;
                return Plugin_Handled;
        }
    
    return Plugin_Continue;
}

Last edited by retsam; 06-17-2009 at 21:34.
retsam is offline
slipvyne
Junior Member
Join Date: Jun 2009
Old 06-17-2009 , 21:52   Re: [TF2] change crit of a person.
Reply With Quote #3

Yea as i said, the only time we got crits was the back burner. And this included doing the kritskreig on someone. Again, we did not crit at all with the kritskreig.

When the cvar sm_crit_turnon == 0, no-one crits. I guess i should also clarify something else. It appears to crit to the shooter, when i was testing it, i saw myself criting, the others watching did not. when i was criting with the heavy gun and killed some1, it did not show the kill as a crit(no red background).
slipvyne is offline
Send a message via AIM to slipvyne Send a message via MSN to slipvyne
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 06-18-2009 , 01:47   Re: [TF2] change crit of a person.
Reply With Quote #4

Hopefully someone more experienced will check it out for you.

I notice you dont have return Plugin_Continue; in yours. See mine? Would that do it?
retsam is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 06-18-2009 , 23:41   Re: [TF2] change crit of a person.
Reply With Quote #5

What retsam said. The docs for TF2_CalcIsAttackCritical clearly say to return Plugin_Continue to let the normal crit calculation occur.
Fyren is offline
slipvyne
Junior Member
Join Date: Jun 2009
Old 06-22-2009 , 07:50   Re: [TF2] change crit of a person.
Reply With Quote #6

Thanks and I do see that now. I updated the mod and retested the plugin and it still does not crit normalyl when bool var is turned off.

The new code looks like:
PHP Code:
public Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[], &bool:result)  //over-writes the native soucemod function for our own purposes.
{
    if(
GetConVarBool(turn_crit_on) == 0)
    {
        
PrintToServer("true");
        return 
Plugin_Continue;  //if set to 0, use the normal source crit check.  if set to 1, use my checks.
    
}
    else
    {
        if(
gCritBool[client] == 1)
        {
            
result true;
            return 
Plugin_Handled;
        }
        else if(
classcheck(TF2_GetPlayerClass(client)))
        {
            
//PrintToServer("true");
            
result true;  //result true = crit
            
return Plugin_Handled;  //plugin is then exited.
        
}
        else if(
GetConVarFloat(crit_rate) > GetRandomFloat(0.01.0)) //if not solider, gets the crit change rate, and gets a random number between 0 and 1 to check against.  if our crit rate is bigger, crit is ture and exited.
        
{
            
result true;
            return 
Plugin_Handled;    
        }
        else 
//else, since we are not a solider, and we did not "roll" a succsessful crit, it is obivously not a crit, and exited so source engine will use it's calc.
        
{
            return 
Plugin_Continue;
        }
    }

ignore the print to server, i was testing to make sure it was entering the correct tree. We did some more testing and found backstabs and ambass crits, lol. But sadly, it does not crit as it should without a plugin.

Any more thoughts or concerns?

**EDIT**

I have tried a couple different ways to work around the problem. First i was digging through other's code and saw that everytime they wanted the engine to handle the crits, it was in it's own if statement, looking like this:

PHP Code:
public Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[], &bool:result)  //over-writes the native soucemod function for our own purposes.
{
    if(
GetConVarBool(turn_crit_on) == 0)
    {
        return 
Plugin_Continue;  
    }
    if(
GetConVarBool(turn_crit_on) == 1)
    {
        if(
gCritBool[client] == 1)
        {
            
result true;
            return 
Plugin_Handled;
        }
        else if(
classcheck(TF2_GetPlayerClass(client)))
        {
            
//PrintToServer("true");
            
result true;  //result true = crit
            
return Plugin_Handled;  //plugin is then exited.
        
}
        else if(
GetConVarFloat(crit_rate) > GetRandomFloat(0.01.0)) //if not solider, gets the crit change rate, and gets a random number between 0 and 1 to check against.  if our crit rate is bigger, crit is ture and exited.
        
{
            
result true;
            return 
Plugin_Handled;    
        }
        else 
//else, since we are not a solider, and we did not "roll" a succsessful crit, it is obivously not a crit, and exited so source engine will use it's calc.
        
{
            return 
Plugin_Continue;
        }
    }

This did not work. And while on the MIRC channel asking for advice, some1 had suggested i get rid of that step completely and have it look like this:

PHP Code:
public Action:TF2_CalcIsAttackCritical(clientweaponString:weaponname[], &bool:result)  //over-writes the native soucemod function for our own purposes.
{
    if(
GetConVarBool(turn_crit_on) == 1)
    {
        if(
gCritBool[client] == 1)
        {
            
result true;
            return 
Plugin_Handled;
        }
        else if(
classcheck(TF2_GetPlayerClass(client)))
        {
            
//PrintToServer("true");
            
result true;  //result true = crit
            
return Plugin_Handled;  //plugin is then exited.
        
}
        else if(
GetConVarFloat(crit_rate) > GetRandomFloat(0.01.0)) //if not solider, gets the crit change rate, and gets a random number between 0 and 1 to check against.  if our crit rate is bigger, crit is ture and exited.
        
{
            
result true;
            return 
Plugin_Handled;    
        }
        else 
//else, since we are not a solider, and we did not "roll" a succsessful crit, it is obivously not a crit, and exited so source engine will use it's calc.
        
{
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;

this also did not work. Granted i did test it by myself, but noticed that when testing with others, if the heavy did not uppercut with the KGB, it was not a critical. no uppercuts on either of these iterations.

Last edited by slipvyne; 06-22-2009 at 08:37.
slipvyne is offline
Send a message via AIM to slipvyne Send a message via MSN to slipvyne
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 06-22-2009 , 09:15   Re: [TF2] change crit of a person.
Reply With Quote #7

Your code works as it seems it's intented to, for me. Do you have another plugin loaded that uses the crit forward?
Fyren is offline
slipvyne
Junior Member
Join Date: Jun 2009
Old 06-22-2009 , 16:51   Re: [TF2] change crit of a person.
Reply With Quote #8

no, its just this plugin thats loaded, besides sourcemod. are you sure its working? remember i was saying it looks like it works to the shooter as you will see the crit and hear it on the shooter end. but ppl wont see it, and when you hit some1 it wont crit.
slipvyne is offline
Send a message via AIM to slipvyne Send a message via MSN to slipvyne
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 06-23-2009 , 02:08   Re: [TF2] change crit of a person.
Reply With Quote #9

I attached the code I tested with. It's the code you pasted above, plus the minimal amount of changes to get it to function (and one to get rid of a warning).
Attached Files
File Type: sp Get Plugin or Get Source (crit.sp - 387 views - 1.3 KB)
Fyren is offline
slipvyne
Junior Member
Join Date: Jun 2009
Old 06-23-2009 , 03:49   Re: [TF2] change crit of a person.
Reply With Quote #10

i just tested it with bots. its still not criting. but it shows the player criting, but theres no crit damage, no crit kills. im using sourcemod's basic package, with the only new plgin introdced is this one.
slipvyne is offline
Send a message via AIM to slipvyne Send a message via MSN to slipvyne
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 21:57.


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