Update tkstopper

This commit is contained in:
Jackzie 2022-06-18 18:02:35 -05:00
parent 6c0e7bc1f2
commit 9d06642e73
No known key found for this signature in database
GPG key ID: E0BBD94CF657F603
3 changed files with 62 additions and 2 deletions

View file

@ -161,4 +161,47 @@ public Action Timer_CheckIsInSpit(Handle h, int userid) {
return Plugin_Stop;
}
return Plugin_Continue;
}
float CHARGER_CHECK_MIN[3] = { -15.0, -15.0, 2.0};
float CHARGER_CHECK_MAX[3] = { 15.0, 15.0, 20.0 };
public Action Timer_CheckForChargerOpportunity(Handle h, int userid) {
int client = GetClientOfUserId(userid);
if(client) {
int activator = GetClientOfUserId(g_iSmartChargeActivator[client]);
if(!activator) {
g_iSmartChargeActivator[client] = 0;
}
float pos[3], ang[3], endPos[3], spawnPos[3];
GetClientAbsOrigin(client, pos);
GetClientEyeAngles(client, ang);
GetHorizontalPositionFromOrigin(pos, ang, -150.0, endPos);
TR_TraceHullFilter(endPos, pos, CHARGER_CHECK_MIN, CHARGER_CHECK_MAX, MASK_SOLID, Filter_CheckChargerValid, client);
if(!TR_DidHit()) {
spawnPos = endPos;
GetHorizontalPositionFromOrigin(pos, ang, 500.0, endPos);
TR_TraceHullFilter(endPos, pos, CHARGER_CHECK_MIN, CHARGER_CHECK_MAX, MASK_SOLID, Filter_CheckChargerValid, client);
if(!TR_DidHit()) {
SpawnSpecialAtPosition(Special_Charger, spawnPos, ang, client);
if(activator) PrintToChat(activator, "Auto charge %N successfully after %d tries", client, g_iSmartChargeAttempts[client]);
g_iSmartChargeAttempts[client] = 0;
g_iSmartChargeActivator[client] = 0;
return Plugin_Stop;
}
}
if(++g_iSmartChargeAttempts[client] > g_iSmartChargeMaxAttempts[client]) {
if(activator) PrintToChat(activator, "Auto charge timed out after %d attempts", g_iSmartChargeAttempts[client]);
g_iSmartChargeAttempts[client] = 0;
g_iSmartChargeActivator[client] = 0;
return Plugin_Stop;
}
return Plugin_Continue;
}
return Plugin_Stop;
}
public bool Filter_CheckChargerValid(int entity, int contentsMask, any data) {
return entity <= 0 || entity >= MaxClients || (entity != data && GetClientTeam(entity) == 2);
}