mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 07:43:21 +00:00
Cleanup code
This commit is contained in:
parent
89c777e016
commit
153a6c97a3
2 changed files with 13 additions and 14 deletions
Binary file not shown.
|
@ -619,20 +619,19 @@ static char WHITELISTED_AUTO_AIM_TARGETS[MAX_WHITELISTED_AUTO_AIM_TARGETS][] = {
|
||||||
|
|
||||||
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) {
|
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) {
|
||||||
if(client == manualTargetter && turretCount > 0) {
|
if(client == manualTargetter && turretCount > 0) {
|
||||||
static float pos[3], ang[3];
|
static float pos[3], orgPos[3];
|
||||||
static char classname[32];
|
static char classname[32];
|
||||||
GetClientEyePosition(client, pos);
|
GetClientEyePosition(client, orgPos);
|
||||||
GetClientEyeAngles(client, ang);
|
|
||||||
|
|
||||||
// Run a ray trace to find a suitable position
|
// Run a ray trace to find a suitable position
|
||||||
// TODO: Possibly run per-turret for more accurate preview... but it's already lag fest
|
// TODO: Possibly run per-turret for more accurate preview... but it's already lag fest
|
||||||
TR_TraceRayFilter(pos, ang, MASK_SHOT, RayType_Infinite, Filter_ManualTarget);
|
TR_TraceRayFilter(orgPos, angles, MASK_SHOT, RayType_Infinite, Filter_ManualTarget);
|
||||||
if(!IsValidEntity(manualTarget)) manualTarget = CreateTarget(ang, MANUAL_TARGETNAME);
|
if(!IsValidEntity(manualTarget)) manualTarget = CreateTarget(angles, MANUAL_TARGETNAME);
|
||||||
|
|
||||||
// Disable aim snapping if player is holding WALK (which is apparently IN_SPEED)
|
// Disable aim snapping if player is holding WALK (which is apparently IN_SPEED)
|
||||||
bool aimSnapping = ~buttons & IN_SPEED > 0;
|
bool aimSnapping = ~buttons & IN_SPEED > 0;
|
||||||
int targetEntity = TR_GetEntityIndex();
|
int targetEntity = TR_GetEntityIndex();
|
||||||
TR_GetEndPosition(ang);
|
TR_GetEndPosition(pos);
|
||||||
|
|
||||||
if(aimSnapping && targetEntity > 0) {
|
if(aimSnapping && targetEntity > 0) {
|
||||||
if(targetEntity > MaxClients) {
|
if(targetEntity > MaxClients) {
|
||||||
|
@ -640,22 +639,22 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
GetEntityClassname(targetEntity, classname, sizeof(classname));
|
GetEntityClassname(targetEntity, classname, sizeof(classname));
|
||||||
for(int i = 0; i < MAX_WHITELISTED_AUTO_AIM_TARGETS; i++) {
|
for(int i = 0; i < MAX_WHITELISTED_AUTO_AIM_TARGETS; i++) {
|
||||||
if(StrEqual(WHITELISTED_AUTO_AIM_TARGETS[i], classname)) {
|
if(StrEqual(WHITELISTED_AUTO_AIM_TARGETS[i], classname)) {
|
||||||
GetEntPropVector(targetEntity, Prop_Send, "m_vecOrigin", ang);
|
GetEntPropVector(targetEntity, Prop_Send, "m_vecOrigin", pos);
|
||||||
ang[2] += 40.0;
|
pos[2] += 40.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(GetClientTeam(targetEntity) == 3) {
|
} else if(GetClientTeam(targetEntity) == 3) {
|
||||||
// Target is an infected player, auto aim
|
// Target is an infected player, auto aim
|
||||||
GetClientEyePosition(targetEntity, ang);
|
GetClientEyePosition(targetEntity, pos);
|
||||||
ang[2] -= 10.0;
|
pos[2] -= 10.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TeleportEntity(manualTarget, ang, NULL_VECTOR, NULL_VECTOR);
|
TeleportEntity(manualTarget, pos, NULL_VECTOR, NULL_VECTOR);
|
||||||
|
|
||||||
if(buttons & IN_ATTACK) {
|
if(buttons & IN_ATTACK) {
|
||||||
PhysicsExplode(ang, 10, 20.0, true);
|
PhysicsExplode(pos, 10, 20.0, true);
|
||||||
TE_SetupExplodeForce(ang, 20.0, 10.0);
|
TE_SetupExplodeForce(pos, 20.0, 10.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate all turrets
|
// Activate all turrets
|
||||||
|
@ -663,7 +662,7 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
||||||
while ((entity = FindEntityByClassname(entity, "info_particle_system")) != INVALID_ENT_REFERENCE) {
|
while ((entity = FindEntityByClassname(entity, "info_particle_system")) != INVALID_ENT_REFERENCE) {
|
||||||
if(view_as<int>(turretState[entity]) > 0) {
|
if(view_as<int>(turretState[entity]) > 0) {
|
||||||
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
|
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
|
||||||
TE_SetupBeamPoints(pos, ang, g_iLaserIndex, 0, 0, 1, 0.1, 0.1, 0.1, 0, 0.0, COLOR_RED, 1);
|
TE_SetupBeamPoints(pos, orgPos, g_iLaserIndex, 0, 0, 1, 0.1, 0.1, 0.1, 0, 0.0, COLOR_RED, 1);
|
||||||
TE_SendToAll();
|
TE_SendToAll();
|
||||||
if(buttons & IN_ATTACK) {
|
if(buttons & IN_ATTACK) {
|
||||||
FireTurret(pos, MANUAL_TARGETNAME, cv_manualBaseDamage.FloatValue, tickcount % 10 == 10);
|
FireTurret(pos, MANUAL_TARGETNAME, cv_manualBaseDamage.FloatValue, tickcount % 10 == 10);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue