mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-05 20:13:21 +00:00
Attempt to get rock throwing to work
This commit is contained in:
parent
08874d5266
commit
b6ccd98725
7 changed files with 105 additions and 3 deletions
|
@ -4,7 +4,7 @@
|
||||||
//Allow MAX_TROLLS to be defined elsewhere
|
//Allow MAX_TROLLS to be defined elsewhere
|
||||||
#if defined MAX_TROLLS
|
#if defined MAX_TROLLS
|
||||||
#else
|
#else
|
||||||
#define MAX_TROLLS 41
|
#define MAX_TROLLS 42
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum trollModifier {
|
enum trollModifier {
|
||||||
|
|
|
@ -38,10 +38,36 @@ public void OnEntityCreated(int entity, const char[] classname) {
|
||||||
SDKHook(entity, SDKHook_OnTakeDamageAlive, NerfGun_OnTakeDamage);
|
SDKHook(entity, SDKHook_OnTakeDamageAlive, NerfGun_OnTakeDamage);
|
||||||
else if(StrContains(classname, "_projectile", true) > -1 ) {
|
else if(StrContains(classname, "_projectile", true) > -1 ) {
|
||||||
RequestFrame(EntityCreateCallback, entity);
|
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) {
|
void EntityCreateCallback(int entity) {
|
||||||
if(!HasEntProp(entity, Prop_Send, "m_hOwnerEntity") || !IsValidEntity(entity)) return;
|
if(!HasEntProp(entity, Prop_Send, "m_hOwnerEntity") || !IsValidEntity(entity)) return;
|
||||||
static char class[16];
|
static char class[16];
|
||||||
|
|
|
@ -476,4 +476,53 @@ void StopHealingBots() {
|
||||||
}
|
}
|
||||||
if(hAbmAutoHard != null) hAbmAutoHard.IntValue = wasAbmAutoHard;
|
if(hAbmAutoHard != null) hAbmAutoHard.IntValue = wasAbmAutoHard;
|
||||||
if(hSbFixEnabled != null) hSbFixEnabled.BoolValue = wasSbFixEnabled;
|
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;
|
||||||
}
|
}
|
|
@ -138,7 +138,8 @@ public Action Timer_KickBot(Handle timer, int client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Timer_Delete(Handle h, int id) {
|
public Action Timer_Delete(Handle h, int id) {
|
||||||
AcceptEntityInput(id, "Kill");
|
if(IsValidEntity(id))
|
||||||
|
AcceptEntityInput(id, "Kill");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,10 @@ void SetupTrolls() {
|
||||||
|
|
||||||
/// CATEGORY: MISC
|
/// CATEGORY: MISC
|
||||||
SetCategory("Misc");
|
SetCategory("Misc");
|
||||||
|
/*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);*/
|
||||||
SetupTroll("Gun Jam", "On reload, small chance their gun gets jammed - Can't reload.", TrollMod_Constant);
|
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);
|
SetupTroll("No Shove", "Prevents a player from shoving", TrollMod_Constant);
|
||||||
index = SetupTroll("Car Splat", "Car. splats.", TrollMod_Instant);
|
index = SetupTroll("Car Splat", "Car. splats.", TrollMod_Instant);
|
||||||
|
@ -302,6 +306,21 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
|
||||||
SetEntProp(primaryWpn, Prop_Send, "m_iClip1", GetRandomInt(0, maxCap));
|
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;
|
||||||
|
}
|
||||||
|
PrintToServer("running: ThrowRockAtEntity at %f %f %f", dropPos[0], dropPos[1], dropPos[2]);
|
||||||
|
if(!ThrowRockAtEntity(dropPos, victim, 100.0)) {
|
||||||
|
ReplyToCommand(activator, "Rock dropper failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else if(~modifier & TrollMod_Constant) {
|
} else if(~modifier & TrollMod_Constant) {
|
||||||
PrintToServer("[FTT] Warn: Possibly invalid troll, no apply action defined for \"%s\"", troll.name);
|
PrintToServer("[FTT] Warn: Possibly invalid troll, no apply action defined for \"%s\"", troll.name);
|
||||||
#if defined DEBUG
|
#if defined DEBUG
|
||||||
|
@ -309,4 +328,8 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Filter_IgnorePlayer(int entity, int contentsMask, any data) {
|
||||||
|
return entity != data;
|
||||||
}
|
}
|
|
@ -89,6 +89,8 @@ enum SpecialInternalFlags {
|
||||||
int healTargetPlayer;
|
int healTargetPlayer;
|
||||||
float healTargetPos[3];
|
float healTargetPos[3];
|
||||||
|
|
||||||
|
int g_iRockThrows;
|
||||||
|
|
||||||
#define MODEL_CAR "models/props_vehicles/cara_95sedan.mdl"
|
#define MODEL_CAR "models/props_vehicles/cara_95sedan.mdl"
|
||||||
|
|
||||||
#include <feedthetrolls/base>
|
#include <feedthetrolls/base>
|
||||||
|
|
|
@ -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_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_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.");
|
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_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_scharge", Command_SmartCharge, ADMFLAG_CHEATS, "Auto Smart charge");
|
||||||
RegAdminCmd("sm_healbots", Command_HealTarget, ADMFLAG_CHEATS, "Make bots heal a player");
|
RegAdminCmd("sm_healbots", Command_HealTarget, ADMFLAG_CHEATS, "Make bots heal a player");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue