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

[SOLVED] How to check if a CP is being captured?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
93SHADoW
AlliedModders Donor
Join Date: Jul 2014
Location: Houston, TX
Old 08-05-2015 , 16:54   [SOLVED] How to check if a CP is being captured?
Reply With Quote #1

Is there a way to check if an active CP is currently being captured and it's capture percentage?

I run a fork of Freak Fortress 2 and i've been wanting to check if an active CP is being capped on when FF2's countdown timer reaches 0, and instead of ending the round, it would enter an "overtime" mode to give players/bosses a chance to finish capping or until they manage to defeat the boss/kill the last players while capping the point, or until the point is capped. If the CP has no capture percentage, it would then proceed with how FF2 ends the round like it normally would when the timer reaches 0.

Just like how on normal CP/KOTH maps, it would enter "overtime" if a CP is still being capped by the time the round timer reaches 0 until neither team is no longer capping it, or until it is capped.
__________________

Last edited by 93SHADoW; 02-11-2016 at 09:10.
93SHADoW is offline
Send a message via AIM to 93SHADoW Send a message via Skype™ to 93SHADoW
Akuba
Senior Member
Join Date: Oct 2013
Old 08-05-2015 , 18:05   Re: [TF2] How to check if a CP is being captured?
Reply With Quote #2

You could use the "teamplay_point_startcapture" event to track the control point.

Use the "teamplay_point_startcapture" and cache the cp entity.

Use the entity output "OnCapReset" to track if the point has no percentage anymore.

https://wiki.alliedmods.net/Team_For...t_startcapture
https://developer.valvesoftware.com/..._control_point

I am not sure if there is a better way to do it.

Last edited by Akuba; 08-05-2015 at 18:05.
Akuba is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 08-06-2015 , 04:45   Re: [TF2] How to check if a CP is being captured?
Reply With Quote #3

I'm sure there is a netprop for the percentage, I will try to found it.
But actually Akuba is right but not for OnCapReset that is never called(I don't know why), I use almost the same way in MvT for run a overtime to the robot team.
PHP Code:
//Define
bool:bControlPointInCapture=false;
//In OnPluginStart
HookEvent("teamplay_point_startcapture"StartCapture);
HookEntityOutput("trigger_capture_area""OnBreakTeam2"CaptureReset);
HookEntityOutput("trigger_capture_area""OnBreakTeam1"CaptureReset);

public 
Action:StartCapture(Handle eventchar name[], bool dontBroadcast)
{
    
bControlPointInCapture true;
    return 
Plugin_Continue;
}
public 
CaptureReset(char output[], int callerint activator,float delay)
{
    
bControlPointInCapture false;
    return 
Plugin_Continue;

__________________

Last edited by Benoist3012; 08-06-2015 at 04:46.
Benoist3012 is offline
Akuba
Senior Member
Join Date: Oct 2013
Old 08-06-2015 , 04:55   Re: [TF2] How to check if a CP is being captured?
Reply With Quote #4

Quote:
Originally Posted by Benoist3012 View Post
but not for OnCapReset that is never called(I don't know why)
I think you have to define it with "AddOutput" before its called.
https://forums.alliedmods.net/showpo...70&postcount=2
Akuba is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 08-06-2015 , 06:51   Re: [TF2] How to check if a CP is being captured?
Reply With Quote #5

Theres cp output called on cap start...

OnCapTeam1 Sent when RED capture this point.

OnCapTeam2 Sent when BLUE capture this point.

OnCapReset Sent when owner is changed to neutral.

https://developer.valvesoftware.com/..._control_point
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player

Last edited by Michalplyoutube; 08-06-2015 at 06:52.
Michalplyoutube is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 08-06-2015 , 08:57   Re: [TF2] How to check if a CP is being captured?
Reply With Quote #6

How to get capture point percentage:

gamedata
Code:
"Games"
{
	"tf"
	{
		"Signatures"
		{
			"CTeamControlPoint::GetTeamCapPercentage"	//CTeamControlPoint::GetTeamCapPercentage(CTeamControlPoint *this, int) team_control_point entindex, player team
			{
				"library"		"server"
				"windows"		"\x55\x8B\xEC\x56\x8B\xF1\x8B\x0D\x2A\x2A\x2A\x2A\x57\x8B\x86\x6C\x05\x00\x00"
				"linux"		"@_ZN17CTeamControlPoint20GetTeamCapPercentageEi"
				"mac"		"@_ZN17CTeamControlPoint20GetTeamCapPercentageEi"
			}
		}
	}
}
PHP Code:
#include <sdktools>

Handle g_hSDKGetTeamCapPercentage;

public 
void OnPluginStart()
{
    
Handle hConfig LoadGameConfigFile("serverstuff"); 
    if (
hConfig == INVALID_HANDLESetFailState("Couldn't find plugin serverstuff.txt!"); 

    
StartPrepSDKCall(SDKCall_Entity); 
    
PrepSDKCall_SetFromConf(hConfigSDKConf_Signature"CTeamControlPoint::GetTeamCapPercentage"); 
    
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
    
PrepSDKCall_SetReturnInfo(SDKType_FloatSDKPass_Plain);
    if ((
g_hSDKGetTeamCapPercentage EndPrepSDKCall()) == INVALID_HANDLESetFailState("Failed to create SDKCall for CTeamControlPoint::GetTeamCapPercentage signature!"); 
    
    
CloseHandle(hConfig); 
    
    
RegConsoleCmd("sm_percentages"Command_CapPercentages);
}

public 
Action Command_CapPercentages(int clientint args)
{
    
int cp = -1;
    while ((
cp FindEntityByClassname(cp"team_control_point")) != -1)
    {
        
PrintToChatAll("%i, %f%%"cpSDKCall(g_hSDKGetTeamCapPercentagecpTF2_GetClientTeam(client)));
    }
        
    return 
Plugin_Handled;
}
/*
68, 0.000000%
300, 0.317620%
304, 0.000000%
*/ 
__________________
Pelipoika is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 08-06-2015 , 09:13   Re: [TF2] How to check if a CP is being captured?
Reply With Quote #7

Quote:
Originally Posted by Michalplyoutube View Post
OnCapTeam1 Sent when RED capture this point.

OnCapTeam2 Sent when BLUE capture this point.
Actually those outputs are already handled by the event "teamplay_point_startcapture"
__________________

Last edited by Benoist3012; 08-06-2015 at 09:13.
Benoist3012 is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 08-06-2015 , 14:35   Re: [TF2] How to check if a CP is being captured?
Reply With Quote #8

Quote:
Originally Posted by Pelipoika View Post
How to get capture point percentage:

gamedata
Code:
"Games"
{
    "tf"
    {
        "Signatures"
        {
            "CTeamControlPoint::GetTeamCapPercentage"    //CTeamControlPoint::GetTeamCapPercentage(CTeamControlPoint *this, int) team_control_point entindex, player team
            {
                "library"        "server"
                "windows"        "\x55\x8B\xEC\x56\x8B\xF1\x8B\x0D\x2A\x2A\x2A\x2A\x57\x8B\x86\x6C\x05\x00\x00"
                "linux"        "@_ZN17CTeamControlPoint20GetTeamCapPercentageEi"
                "mac"        "@_ZN17CTeamControlPoint20GetTeamCapPercentageEi"
            }
        }
    }
}
PHP Code:
#include <sdktools>

Handle g_hSDKGetTeamCapPercentage;

public 
void OnPluginStart()
{
    
Handle hConfig LoadGameConfigFile("serverstuff"); 
    if (
hConfig == INVALID_HANDLESetFailState("Couldn't find plugin serverstuff.txt!"); 

    
StartPrepSDKCall(SDKCall_Entity); 
    
PrepSDKCall_SetFromConf(hConfigSDKConf_Signature"CTeamControlPoint::GetTeamCapPercentage"); 
    
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
    
PrepSDKCall_SetReturnInfo(SDKType_FloatSDKPass_Plain);
    if ((
g_hSDKGetTeamCapPercentage EndPrepSDKCall()) == INVALID_HANDLESetFailState("Failed to create SDKCall for CTeamControlPoint::GetTeamCapPercentage signature!"); 
    
    
CloseHandle(hConfig); 
    
    
RegConsoleCmd("sm_percentages"Command_CapPercentages);
}

public 
Action Command_CapPercentages(int clientint args)
{
    
int cp = -1;
    while ((
cp FindEntityByClassname(cp"team_control_point")) != -1)
    {
        
PrintToChatAll("%i, %f%%"cpSDKCall(g_hSDKGetTeamCapPercentagecpTF2_GetClientTeam(client)));
    }
        
    return 
Plugin_Handled;
}
/*
68, 0.000000%
300, 0.317620%
304, 0.000000%
*/ 
I bet this works too m_flCapPercentages in tf_objective_resource
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
93SHADoW
AlliedModders Donor
Join Date: Jul 2014
Location: Houston, TX
Old 02-11-2016 , 09:09   Re: [TF2] How to check if a CP is being captured?
Reply With Quote #9

#6 solved my question.
__________________
93SHADoW is offline
Send a message via AIM to 93SHADoW Send a message via Skype™ to 93SHADoW
Reply



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 02:58.


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