AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2] change crit of a person. (https://forums.alliedmods.net/showthread.php?t=94970)

slipvyne 06-17-2009 19:46

[TF2] change crit of a person.
 
1 Attachment(s)
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.

retsam 06-17-2009 21:29

Re: [TF2] change crit of a person.
 
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;
}


slipvyne 06-17-2009 21:52

Re: [TF2] change crit of a person.
 
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).

retsam 06-18-2009 01:47

Re: [TF2] change crit of a person.
 
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?

Fyren 06-18-2009 23:41

Re: [TF2] change crit of a person.
 
What retsam said. The docs for TF2_CalcIsAttackCritical clearly say to return Plugin_Continue to let the normal crit calculation occur.

slipvyne 06-22-2009 07:50

Re: [TF2] change crit of a person.
 
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.

Fyren 06-22-2009 09:15

Re: [TF2] change crit of a person.
 
Your code works as it seems it's intented to, for me. Do you have another plugin loaded that uses the crit forward?

slipvyne 06-22-2009 16:51

Re: [TF2] change crit of a person.
 
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.

Fyren 06-23-2009 02:08

Re: [TF2] change crit of a person.
 
1 Attachment(s)
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).

slipvyne 06-23-2009 03:49

Re: [TF2] change crit of a person.
 
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.


All times are GMT -4. The time now is 06:29.

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