Add projectile magnet, fix dep bots

This commit is contained in:
Jackz 2022-07-26 20:10:08 -05:00
parent 280c67157e
commit c2e446750c
No known key found for this signature in database
GPG key ID: E0BBD94CF657F603
7 changed files with 206 additions and 92 deletions

View file

@ -465,7 +465,7 @@ void ClearInventory(int client) {
}
}
void StopHealingBots() {
void StopHealingBots(bool dontKill = false) {
healTargetPlayer = 0;
for(int i = 1; i <= MaxClients; i++) {
pdata[i].flags &= ~view_as<int>(Flag_IsTargettingHealer);
@ -474,57 +474,14 @@ void StopHealingBots() {
KickClient(i);
}
}
if(!dontKill && IsValidHandle(stopHealingTimer)) {
delete stopHealingTimer;
}
stopHealingTimer = null;
if(hAbmAutoHard != null) hAbmAutoHard.IntValue = wasAbmAutoHard;
if(hSbFixEnabled != null) hSbFixEnabled.BoolValue = wasSbFixEnabled;
}
// Spawns a env_rock_launcher to throw at a random specified target name.
// Does not auto fire, need to call input LaunchRock
// Damage -1 will not override damage
// autoDeleteTime of <= 0.0 will persist forever.
stock int CreateRockLauncher(const float origin[3], const float ang[3], const char[] targetName, float damage = -1.0, float autoDeleteTime = 0.0) {
int launcher = CreateEntityByName("env_rock_launcher");
if(launcher == -1) return -1;
// DispatchKeyValue(launcher, "targetname", "ftt_rock_launcher");
DispatchKeyValue(launcher, "RockTargetName", targetName);
if(damage >= 0.0) {
DispatchKeyValueFloat(launcher, "RockDamageOverride", damage);
}
if(autoDeleteTime > 0.0) CreateTimer(autoDeleteTime, Timer_Delete, launcher);
DispatchSpawn(launcher);
TeleportEntity(launcher, origin, ang, NULL_VECTOR);
PrintToChatAll("Created rock launcher at %f %f %f at ang %f %f %f", origin[0], origin[1], origin[2], ang[0], ang[1], ang[2]);
// AcceptEntityInput(launcher, "Kill");
return launcher;
}
#define FTT_TARGET_NAME "ftt_target"
stock bool ThrowRockAtPosition(const float origin[3], float pos[3], float damage = -1.0) {
CreateTarget(pos, FTT_TARGET_NAME, 0.2);
GetVectorAngles(pos, pos);
int launcher = CreateRockLauncher(origin, pos, FTT_TARGET_NAME, damage, 0.0);
g_iRockThrows++;
AcceptEntityInput(launcher, "LaunchRock");
AcceptEntityInput(launcher, "Kill");
return true;
}
stock bool ThrowRockAtEntity(const float origin[3], int target, float damage = -1.0) {
float pos[3];
GetEntPropVector(target, Prop_Send, "m_vecOrigin", pos);
return ThrowRockAtPosition(origin, pos, damage);
}
int CreateTarget(const float origin[3], const char[] targetName, float duration = 0.0) {
int target = CreateEntityByName("info_target");
DispatchKeyValue(target, "targetname", targetName);
TeleportEntity(target, origin, NULL_VECTOR, NULL_VECTOR);
DispatchSpawn(target);
if(duration > 0.0) {
CreateTimer(duration, Timer_Delete, target);
}
return target;
}
bool IsAnySurvivorInRange(const float origin[3], float range, int ignorePlayer = 0) {
float pos[3];
@ -538,4 +495,51 @@ bool IsAnySurvivorInRange(const float origin[3], float range, int ignorePlayer =
}
}
return false;
}
int GetRandomThrowableMagnetTarget(ProjectileMagnetType type, int owner = -1) {
static int throwMagnetIndex;
if(throwMagnetIndex == 0) throwMagnetIndex = GetTrollID("Projectile Magnet");
ArrayList checkList = new ArrayList();
for(int i = 1; i <= MaxClients; i++) {
if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && Trolls[throwMagnetIndex].IsActive(i)) {
if(type == ProjType_Survivors && owner != i) {
// If the projectile is not owned by player, check if troll flag not enabled
if(~Trolls[throwMagnetIndex].activeFlagClients[i] & view_as<int>(ProjType_Survivors)) continue;
} else if(~Trolls[throwMagnetIndex].activeFlagClients[i] & view_as<int>(type)) {
// Skip if client does not have flag
continue;
}
checkList.Push(i);
}
}
int target = -1;
if(checkList.Length > 0) {
target = checkList.Get(0, checkList.Length - 1);
}
delete checkList;
return target;
}
stock bool CanSeePoint(const float origin[3], const float point[3]) {
TR_TraceRay(origin, point, MASK_ALL, RayType_EndPoint);
return !TR_DidHit(); // Can see point if no collisions
}
stock LookAtPoint(int entity, const float destination[3]){
float angles[3], pos[3], result[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
MakeVectorFromPoints(destination, pos, result);
GetVectorAngles(result, angles);
if(angles[0] >= 270){
angles[0] -= 270;
angles[0] = (90-angles[0]);
}else{
if(angles[0] <= 90){
angles[0] *= -1;
}
}
angles[1] -= 180;
TeleportEntity(entity, NULL_VECTOR, angles, NULL_VECTOR);
}