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

Getting cappable capture points.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aderic
Senior Member
Join Date: Oct 2011
Old 02-25-2014 , 17:05   Getting cappable capture points.
Reply With Quote #1

Alright! So my goal is to make point captures blocked by certain players.
I managed to achieve this using SDKHooks and blocking the OnTouchStart event.

Code for anyone who wants to see it:
Code:
capturePointScan() {
    new capPoint = -1;
    
    while (capPoint > -2) {
        capPoint = FindEntityByClassname(capPoint, "trigger_capture_area");
        
        if (capPoint == -1) {
            capPoint = -2;
            break;
        }
        
        SDKHook(capPoint, SDKHook_StartTouch,     OnPointEnter);
    }        
}
The issue now is this; I'll need to check to see if they're on the point at a later time.
So what I've done essentially is store a boolean per client that updates OnPointEnter and OnPointLeave. This will work fine... but I need to determine if the capture point is in a capture-able state.

Basically, OnPointEnter will fire on any control point, regardless of if the control point is locked or not! I need to know if the point that OnPointEnter fired on can be captured by said player.

So I decide to look at the GetEntProp route.
I apparently do not know how to read boolean properties, or I'm doing something wrong completely.
I've looked at two possible properties; m_bCPLocked and m_bTeamCanCap.
Code:
public Action:OnPointEnter(point, client)
{

    new ent = FindEntityByClassname(-1, "tf_objective_resource");
    new cpCount = GetEntProp(ent, Prop_Send, "m_iNumControlPoints");
    
    for (new i = 0; i < cpCount; i++) {
        PrintToChatAll("------- Capture Point %i", i);
        
        new owner = GetEntProp(ent, Prop_Send, "m_iOwner", 4, i);
        PrintToChatAll("---- Owner: %i", owner);
        
        for (new i2 = i * 8; i2 < (i * 8) + 8; i2++) {
            new canCap = GetEntProp(ent, Prop_Send, "m_bTeamCanCap", 1, i2);
            PrintToChatAll("-- Capture: %i  (%i)", canCap, i2);
        }
    }
}
m_bTeamCanCap seems to be a table consisting of 64 properties, each being 1 bit.

On cp_dustbowl this is the printout I get:
Spoiler


m_iNumControlPoints is returning 6, this is correct.
m_iOwner returns 2 or 3, red or blue.
m_bTeamCanCap is returning numbers that do not change on each round. Maybe I'm pulling this value incorrectly?

Thanks,

Mark.
__________________

Last edited by Aderic; 02-25-2014 at 19:46. Reason: A little elaboration
Aderic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-26-2014 , 10:37   Re: Getting cappable capture points.
Reply With Quote #2

As you've found the hard way, some of these properties represent what the game looked like at round start rather than the current state.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
rcbotCheeseh
Junior Member
Join Date: May 2013
Old 05-06-2014 , 10:17   Re: Getting cappable capture points.
Reply With Quote #3

I've also been trying to dig into this recently.

this is my dump of badlands after capping the first, second and final cap point

Code:
[RCBot] m_iNumControlPoints = 5
[RCBot] m_bBlocked[8] [N,N,N,N,N,N,N,N]
[RCBot] m_bCPLocked[8] [N,N,N,N,N,N,N,N]
[RCBot] m_bCPIsVisible[8] [Y,N,N,N,Y,N,N,N]
[RCBot] m_iOwner[8] [blue,blue,blue,red,red,unassigned,unassigned,unassigned]
-------------
[RCBot] m_bCPIsVisible[8] [Y,N,N,N,Y,N,N,N]
[RCBot] m_iOwner[8] [blue,blue,blue,blue,red,unassigned,unassigned,unassigned]
[RCBot] m_iNumControlPoints = 5
[RCBot] m_bCPLocked[8] [N,N,N,N,N,N,N,N]
---------
[RCBot] m_iNumControlPoints = 5
[RCBot] m_bBlocked[8] [N,N,N,N,N,N,N,N]
[RCBot] m_bCPLocked[8] [N,N,N,N,N,N,N,N]
[RCBot] m_bCPIsVisible[8] [Y,N,N,N,Y,N,N,N]
[RCBot] m_iOwner[8] [blue,blue,blue,blue,blue,unassigned,unassigned,unassigned]
I see no change in m_bCPLocked what so ever, CPISVisible seems to be YES for the base control points only, and doesn't change when capping. Only the owners change. The only way I could possibly detect capable waypoints in this case is to detect a red cap point next to a blue cap point, but that's not always the case.

theres a good dump of the net props here http://styria-games.eu/tf2/netprops.txt which states that the m_bCPIsVisible is actually not 1 byte but four bytes (one integer) per array value so I'm going to try that
__________________

Last edited by rcbotCheeseh; 05-06-2014 at 10:24.
rcbotCheeseh is offline
rcbotCheeseh
Junior Member
Join Date: May 2013
Old 05-06-2014 , 19:08   Re: Getting cappable capture points.
Reply With Quote #4

so after fixing m_bCPIsVisible, they are all TRUE no matter what. m_bCPLocked is always FALSE no matter what.

this is the function to check if the team can capture

Code:
bool TeamCanCapPoint( int index, int team )
{
 return m_bTeamCanCap[ (index + (team * MAX_CONTROL_POINTS)) ];
}
I'm not sure if it changes much but in cp_dustbowl I can successfully pick up capable waypoints until point 4 , after blue caps point 3, team can cap returns TRUE for red on point 3 which they shouldn't be able to capture any points on dustbowl!
__________________

Last edited by rcbotCheeseh; 05-06-2014 at 19:09.
rcbotCheeseh is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-06-2014 , 21:54   Re: Getting cappable capture points.
Reply With Quote #5

You could recreate the functionality and the guess if it is locked.
Would require to check the gamemode too.
so like:
1 belongs to red
2 belongs to red
3 belongs to blue
4 belongs to blue
5 belongs to blue
then depending on the gamemode, which right now i cant remember each one, say it's attack/defend control point, red is attacking.
so 1,2,4,5 are assumed locked.
Mitchell is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-06-2014 , 22:33   Re: Getting cappable capture points.
Reply With Quote #6

I meant to try this out again... in theory you can use the team_control_point's m_bLocked datamap (the starting lock value), the teamplay_point_locked event, and the teamplay_point_unlocked event to manually track the status of control points.

However, multi-round maps map need some special handing using the teamplay_round_selected (which is the m_iName of a team_control_point_round) and the team_control_point_round's m_iszCPNames datamap (which are a space separated list of team_control_point m_iName) to figure out which points are in the current round.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-06-2014 at 22:33.
Powerlord is offline
rcbotCheeseh
Junior Member
Join Date: May 2013
Old 05-07-2014 , 04:00   Re: Getting cappable capture points.
Reply With Quote #7

Quote:
1 belongs to red
2 belongs to red
3 belongs to blue
4 belongs to blue
5 belongs to blue
then depending on the gamemode, which right now i cant remember each one, say it's attack/defend control point, red is attacking.
so 1,2,4,5 are assumed locked.
Yeah I think for normal game modes it should be fine to do this, although on dustbowl etc (maps with more than one round or attack defend maps) will be different

Quote:
I meant to try this out again... in theory you can use the team_control_point's m_bLocked datamap (the starting lock value), the teamplay_point_locked event, and the teamplay_point_unlocked event to manually track the status of control points.
Yeah I tried looking out for teamplay_point_locked / unlocked events but they never occurred. even though its in the documentation, perhaps its now out of date?

Will need to manually reverse engineer these control points , boo!
__________________
rcbotCheeseh is offline
Tylerst
Veteran Member
Join Date: Oct 2010
Old 05-07-2014 , 05:04   Re: Getting cappable capture points.
Reply With Quote #8

Quote:
Originally Posted by Aderic View Post
Alright! So my goal is to make point captures blocked by certain players.
Are you saying you want to make it so that certain players can't cap?

If so, I would just add item attribute 68(increase player capture value) to them with a negative value.
Tylerst is offline
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 08:14.


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