Merge branch 'ftt/rockthrow'

This commit is contained in:
Jackz 2022-07-23 18:40:43 -05:00
commit 0f02d0ee6d
No known key found for this signature in database
GPG key ID: E0BBD94CF657F603
8 changed files with 150 additions and 17 deletions

Binary file not shown.

View file

@ -4,7 +4,7 @@
//Allow MAX_TROLLS to be defined elsewhere
#if defined MAX_TROLLS
#else
#define MAX_TROLLS 41
#define MAX_TROLLS 43
#endif
enum trollModifier {

View file

@ -38,10 +38,36 @@ public void OnEntityCreated(int entity, const char[] classname) {
SDKHook(entity, SDKHook_OnTakeDamageAlive, NerfGun_OnTakeDamage);
else if(StrContains(classname, "_projectile", true) > -1 ) {
RequestFrame(EntityCreateCallback, entity);
}
} /*else if(g_iRockThrows > 0 && StrEqual(classname, "tank_rock")) {
--g_iRockThrows;
SDKHook(entity, SDKHook_SpawnPost, SpawnPost);
}*/
}
}
/*void SpawnPost(int entity) {
RequestFrame(SetRockVelocity, EntIndexToEntRef(entity))
}
void SetRockVelocity(int entity) {
entity = EntRefToEntIndex(entity);
if(!IsValidEntity(entity)) return;
float vel[3];
GetEntPropVector(entity, Prop_Send, "m_vecVelocity", vel);
ScaleVector(vel, 0.4);
// z_tank_throw_force
//SetEntPropVector(entity, Prop_Send, "m_vecVelocity", vel);
vel[2] += 150.0;
TeleportEntity(entity, NULL_VECTOR, NULL_VECTOR, vel);
PrintToChatAll("set rock %d vel", entity);
}*/
void EntityCreateCallback(int entity) {
if(!HasEntProp(entity, Prop_Send, "m_hOwnerEntity") || !IsValidEntity(entity)) return;
static char class[16];

View file

@ -477,3 +477,52 @@ void StopHealingBots() {
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);
}
PrintToServer("Created info_target at %f %f %f", origin[0], origin[1], origin[2]);
return target;
}

View file

@ -138,7 +138,8 @@ public Action Timer_KickBot(Handle timer, int client) {
}
public Action Timer_Delete(Handle h, int id) {
AcceptEntityInput(id, "Kill");
if(IsValidEntity(id))
AcceptEntityInput(id, "Kill");
return Plugin_Handled;
}

View file

@ -44,20 +44,33 @@ void SetupTrolls() {
Trolls[index].AddFlagPrompt(false);
Trolls[index].AddFlag("In Back", true);
Trolls[index].AddFlag("In Front", false);
index = SetupTroll("Smart Charge", "Waits until coast is clear to charge", TrollMod_Constant);
Trolls[index].AddCustomFlagPrompt("Attempt Timeout", false);
Trolls[index].AddFlag("15 Seconds", true);
Trolls[index].AddFlag("30 Seconds", false);
Trolls[index].AddFlag("1 minute", false);
Trolls[index].AddFlag("5 minutes", false);
// CATEGORY: Items
SetCategory("Items");
index = SetupTroll("Throw It All", "Player throws their item(s) periodically to a nearby player", TrollMod_Instant);
//Can't add directly, is custom troll:
// Trolls[index].AddFlag("Throw to Admin", true);
// Trolls[index].AddFlag("Drop At Feet", false);
// Trolls[index].AddFlag("Drop At Admin", false);
// CATEGORY: Projectiles
SetCategory("Projectiles");
index = SetupTroll("Rock Dropper", "Drops on a rock. On their head.", TrollMod_Instant);
// Trolls[index].AddFlagPrompt(false);
// Trolls[index].AddFlag("Drop From Above", true);
// Trolls[index].AddFlag("From behind", false);
index = SetupTroll("Car Splat", "Car. splats.", TrollMod_Instant);
Trolls[index].AddFlagPrompt(false);
Trolls[index].AddFlag("On Top", true);
Trolls[index].AddFlag("Into (Infront)", false);
Trolls[index].AddFlag("Into (Behind)", false);
index = SetupTroll("Bad Throw", "Player drops throwables on throw, and biles/molotovs themselves", TrollMod_Constant);
Trolls[index].AddFlagPrompt(true);
Trolls[index].AddFlag("Biles", true);
Trolls[index].AddFlag("Molotovs", true);
Trolls[index].AddFlag("Pipebombs", true);
// CATEGORY: Items
SetCategory("Items");
SetupTroll("Throw It All", "Player throws their item(s) periodically to a nearby player", TrollMod_Instant);
index = SetupTroll("Spicy Gas", "Gascans player picks up just ignite. Magic.", TrollMod_Constant);
Trolls[index].AddFlagPrompt(false);
Trolls[index].AddFlag("Always (100%)", false);
@ -83,6 +96,8 @@ void SetupTrolls() {
Trolls[index].AddFlag("Rare (10%)", false);
SetupTroll("Nerf Gun", "When they shoot it does no damage.", TrollMod_Constant);
SetupTroll("Randomize Clip Ammo", "Randomly changes their clip ammo downwards", TrollMod_Constant | TrollMod_Instant);
SetupTroll("CameTooEarly", "When they shoot, random chance they empty whole clip", TrollMod_Constant);
/// CATEGORY: Chat
SetCategory("Chat");
@ -124,6 +139,21 @@ void SetupTrolls() {
Trolls[index].AddFlag("0.0x Ratio (None)", false); //8
Trolls[index].AddFlag("3x Ratio", false); //16
Trolls[index].AddFlag("-2x Ratio", false); //16
/*index = SetupTroll("Dep Bots", "Makes bots heal a player. At any cost", TrollMod_Constant);
Trolls[index].AddFlagPrompt(false);
Trolls[index].AddFlag("Do not spawn extra", true);
Trolls[index].AddFlag("Spawn extra bots", false);
Trolls[index].AddCustomFlagPrompt("# Of Bots", false);
Trolls[index].AddFlag("1", false);
Trolls[index].AddFlag("2", false);
Trolls[index].AddFlag("3", false);
Trolls[index].AddFlag("4", true);
Trolls[index].AddFlag("5", false);
Trolls[index].AddCustomFlagPrompt("Auto Timeout", false);
Trolls[index].AddFlag("Forever / Until Healed", false);
Trolls[index].AddFlag("15 seconds", true);
Trolls[index].AddFlag("30", false);
Trolls[index].AddFlag("1 minute", false);*/
/// CATEGORY: Movement
SetCategory("Movement");
@ -148,12 +178,6 @@ void SetupTrolls() {
SetCategory("Misc");
SetupTroll("Gun Jam", "On reload, small chance their gun gets jammed - Can't reload.", TrollMod_Constant);
SetupTroll("No Shove", "Prevents a player from shoving", TrollMod_Constant);
index = SetupTroll("Car Splat", "Car. splats.", TrollMod_Instant);
Trolls[index].AddFlagPrompt(false);
Trolls[index].AddFlag("On Top", true);
Trolls[index].AddFlag("Into (Infront)", false);
Trolls[index].AddFlag("Into (Behind)", false);
SetupTroll("CameTooEarly", "When they shoot, random chance they empty whole clip", TrollMod_Constant);
index = SetupTroll("Meta: Inverse", "Uhm you are not supposed to see this...", TrollMod_Instant);
Trolls[index].hidden = true;
Trolls[index].AddFlagPrompt(false);
@ -302,6 +326,32 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
SetEntProp(primaryWpn, Prop_Send, "m_iClip1", GetRandomInt(0, maxCap));
}
}
} else if(StrEqual(troll.name, "Rock Dropper")) {
float pos[3], dropPos[3];
GetClientEyePosition(victim, pos);
dropPos = pos;
dropPos[2] += 150.0;
TR_TraceRayFilter(pos, dropPos, MASK_SOLID, RayType_EndPoint, Filter_IgnorePlayer, victim);
if(TR_DidHit()) {
ReplyToCommand(activator, "Could not find a suitable area. Requires vertical space.");
return false;
}
float vel[3];
vel[0] = 90.0;
L4D_TankRockPrj(0, dropPos, vel);
} else if(StrEqual(troll.name, "Smart Charge")) {
if(pdata[victim].smartChargeActivator > 0) {
ReplyToCommand(activator, "Target already has smart charge enabled");
return false;
}
int timeout = 15;
if(flags & 2) timeout = 30;
else if(flags & 4) timeout = 60;
else if(flags & 8) timeout = 300;
pdata[victim].smartChargeAttempts = 0;
pdata[victim].smartChargeMaxAttempts = timeout;
pdata[victim].smartChargeActivator = GetClientUserId(activator);
CreateTimer(1.0, Timer_CheckForChargerOpportunity, GetClientUserId(victim), TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
} else if(~modifier & TrollMod_Constant) {
PrintToServer("[FTT] Warn: Possibly invalid troll, no apply action defined for \"%s\"", troll.name);
#if defined DEBUG
@ -310,3 +360,7 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
}
return true;
}
bool Filter_IgnorePlayer(int entity, int contentsMask, any data) {
return entity != data;
}

View file

@ -89,6 +89,8 @@ enum SpecialInternalFlags {
int healTargetPlayer;
float healTargetPos[3];
int g_iRockThrows;
#define MODEL_CAR "models/props_vehicles/cara_95sedan.mdl"
#include <feedthetrolls/base>

View file

@ -89,6 +89,7 @@ public void OnPluginStart() {
RegAdminCmd("sm_insta", Command_InstaSpecial, ADMFLAG_KICK, "Spawns a special that targets them, close to them.");
RegAdminCmd("sm_stagger", Command_Stagger, ADMFLAG_KICK, "Stagger a player");
RegAdminCmd("sm_inface", Command_InstaSpecialFace, ADMFLAG_KICK, "Spawns a special that targets them, right in their face.");
// TODO: Merge as trolls
RegAdminCmd("sm_bots_attack", Command_BotsAttack, ADMFLAG_CHEATS, "Instructs all bots to attack a player until they have X health.");
RegAdminCmd("sm_scharge", Command_SmartCharge, ADMFLAG_CHEATS, "Auto Smart charge");
RegAdminCmd("sm_healbots", Command_HealTarget, ADMFLAG_CHEATS, "Make bots heal a player");