mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 17:33:21 +00:00
Troll changes
This commit is contained in:
parent
2013d0c7bc
commit
71889d6788
7 changed files with 149 additions and 45 deletions
|
@ -4,7 +4,7 @@
|
|||
//Allow MAX_TROLLS to be defined elsewhere
|
||||
#if defined MAX_TROLLS
|
||||
#else
|
||||
#define MAX_TROLLS 38
|
||||
#define MAX_TROLLS 40
|
||||
#endif
|
||||
|
||||
enum trollModifier {
|
||||
|
@ -362,6 +362,17 @@ void ApplyTroll(int victim, const char[] name, int activator, trollModifier modi
|
|||
LogAction(activator, victim, "\"%L\" deactivated \"%s\" on \"%L\"", activator, troll.name, victim);
|
||||
} else {
|
||||
static char flagName[MAX_TROLL_FLAG_LENGTH];
|
||||
flagName[0] = '\0';
|
||||
for(int i = 0; i < 32; i++) {
|
||||
if(flags & (1 << i)) {
|
||||
// If at least one flag already, reset to none:
|
||||
if(flagName[0] != '\0') {
|
||||
flagName[0] = '\0';
|
||||
break;
|
||||
}
|
||||
troll.GetFlagName(i, flagName, sizeof(flagName));
|
||||
}
|
||||
}
|
||||
if(flags > 0 && flags & flags - 1 == 0 && flags & flags + 1 == 0) {
|
||||
// Get the flag name if there is only one flag set
|
||||
troll.GetFlagName(GetIndexFromPower(flags), flagName, sizeof(flagName));
|
||||
|
|
|
@ -90,6 +90,11 @@ public void OnClientAuthorized(int client, const char[] auth) {
|
|||
if(!IsFakeClient(client)) {
|
||||
strcopy(steamids[client], 64, auth);
|
||||
}
|
||||
for(int i = 1; i <= MAX_TROLLS; i++) {
|
||||
if(Trolls[i].IsActive(client) && Trolls[i].HasMod(TrollMod_Constant)) { //Add activeFlagClients >= 0 check possibly?
|
||||
ApplyAffect(client, Trolls[i], -1, TrollMod_Constant, Trolls[i].activeFlagClients[client]);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast) {
|
||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||
|
@ -150,17 +155,13 @@ public void Event_CarAlarm(Event event, const char[] name, bool dontBroadcast) {
|
|||
int client = GetClientOfUserId(user);
|
||||
if(client) {
|
||||
PrintToChatAll("%N has alerted the horde!", client);
|
||||
CreateTimer(0.5, RushPlayer, user);
|
||||
CreateTimer(0.2, RushPlayer, user);
|
||||
CreateTimer(0.6, RushPlayer, user);
|
||||
CreateTimer(1.5, RushPlayer, user);
|
||||
}
|
||||
//Ignore car alarms for autopunish
|
||||
lastButtonUser = -1;
|
||||
}
|
||||
public void Event_EnteredSpit(Event event, const char[] name, bool dontBroadcast) {
|
||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||
if(client) {
|
||||
g_iInSpit[client] = true;
|
||||
}
|
||||
}
|
||||
public Action RushPlayer(Handle h, int user) {
|
||||
L4D2_RunScript("RushVictim(GetPlayerFromUserID(%d), %d)", user, 15000);
|
||||
}
|
||||
|
@ -799,4 +800,23 @@ public Action OnAntiRush(int client, int &type, float distance) {
|
|||
PrintToConsoleAll("[FTT] Spawning anti-rush special on %N (dist=%f) (special=%N)", client, distance, SPECIAL_NAMES[view_as<int>(special)-1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void L4D2_CInsectSwarm_CanHarm_Post(int acid, int spitter, int entity) {
|
||||
if(entity <= MaxClients)
|
||||
iLastInSpit[entity] = GetGameTime();
|
||||
}
|
||||
|
||||
public void Event_EnteredSpit(Event event, const char[] name, bool dontBroadcast) {
|
||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||
if(Trolls[stickyGooIndex].IsActive(stickyGooIndex)) {
|
||||
float movement = 0.0;
|
||||
if(Trolls[stickyGooIndex].activeFlagClients[client] & 1) movement = 0.6;
|
||||
else if(Trolls[stickyGooIndex].activeFlagClients[client] & 2) movement = 0.3;
|
||||
|
||||
SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", movement);
|
||||
iLastInSpit[client] = GetGameTime();
|
||||
CreateTimer(0.2, Timer_CheckIsInSpit, GetClientUserId(client), TIMER_REPEAT);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,19 +9,23 @@ public int Insta_PlayerHandler(Menu menu, MenuAction action, int client, int par
|
|||
|
||||
int userid = StringToInt(str[0]);
|
||||
int instaMode = StringToInt(str[1]);
|
||||
|
||||
Menu spMenu = new Menu(Insta_SpecialHandler);
|
||||
spMenu.SetTitle("Choose a Insta-Special™");
|
||||
for(int i = 1; i <= 8; i++) {
|
||||
Format(info, sizeof(info), "%d|%d|%d", userid, instaMode, i);
|
||||
spMenu.AddItem(info, SPECIAL_NAMES[i-1]);
|
||||
}
|
||||
spMenu.ExitButton = true;
|
||||
spMenu.Display(client, 0);
|
||||
ShowInstaSpecialChooser(client, userid, instaMode);
|
||||
} else if (action == MenuAction_End)
|
||||
delete menu;
|
||||
}
|
||||
|
||||
void ShowInstaSpecialChooser(int activator, int userid, int instaMode) {
|
||||
Menu spMenu = new Menu(Insta_SpecialHandler);
|
||||
spMenu.SetTitle("Choose a Insta-Special™");
|
||||
static char data[16];
|
||||
for(int i = 1; i <= 8; i++) {
|
||||
Format(data, sizeof(data), "%d|%d|%d", userid, instaMode, i);
|
||||
spMenu.AddItem(data, SPECIAL_NAMES[i-1]);
|
||||
}
|
||||
spMenu.ExitButton = true;
|
||||
spMenu.Display(activator, 0);
|
||||
}
|
||||
|
||||
public int Insta_SpecialHandler(Menu menu, MenuAction action, int client, int param2) {
|
||||
/* If an option was selected, tell the client about the item. */
|
||||
if (action == MenuAction_Select) {
|
||||
|
@ -29,12 +33,13 @@ public int Insta_SpecialHandler(Menu menu, MenuAction action, int client, int pa
|
|||
menu.GetItem(param2, info, sizeof(info));
|
||||
static char str[3][8];
|
||||
ExplodeString(info, "|", str, 3, 8, false);
|
||||
int target = GetClientOfUserId(StringToInt(str[0]));
|
||||
int userid = StringToInt(str[0]);
|
||||
int target = GetClientOfUserId(userid);
|
||||
bool inFace = StrEqual(str[1], "1");
|
||||
int specialInt = StringToInt(str[2]);
|
||||
if(specialInt < 0 || specialInt > 8) {
|
||||
ReplyToCommand(client, "Invalid special id");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
SpecialType special = view_as<SpecialType>(specialInt);
|
||||
if(inFace) {
|
||||
|
@ -52,8 +57,10 @@ public int Insta_SpecialHandler(Menu menu, MenuAction action, int client, int pa
|
|||
ReplyToCommand(client, "Could not spawn special.");
|
||||
}
|
||||
}
|
||||
ShowInstaSpecialChooser(client, userid, inFace);
|
||||
} else if (action == MenuAction_End)
|
||||
delete menu;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -404,24 +404,50 @@ bool SpawnCarOnPlayer(int target) {
|
|||
return false;
|
||||
}
|
||||
|
||||
stock int CreateProp(const char[] entClass, const char[] model, const float pos[3], const float ang[3]) {
|
||||
stock int CreateProp(const char[] entClass, const char[] model, const float pos[3], const float ang[3] = { 0.0, 0.0, 0.0 }, const float vel[3] = {0.0, 0.0, 0.0}) {
|
||||
int entity = CreateEntityByName(entClass);
|
||||
DispatchKeyValue(entity, "model", model);
|
||||
DispatchKeyValue(entity, "solid", "6");
|
||||
DispatchKeyValue(entity, "targetname", "hsprop");
|
||||
DispatchKeyValue(entity, "disableshadows", "1");
|
||||
TeleportEntity(entity, pos, ang, NULL_VECTOR);
|
||||
TeleportEntity(entity, pos, ang, vel);
|
||||
DispatchSpawn(entity);
|
||||
TeleportEntity(entity, pos, ang, vel);
|
||||
#if defined DEBUG_LOG_MAPSTART
|
||||
PrintToServer("spawn prop %.1f %.1f %.1f model %s", pos[0], pos[1], pos[2], model[7]);
|
||||
#endif
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
public bool Filter_Solid(int entity, int contentsMask, any data) {
|
||||
return entity <= 0;
|
||||
}
|
||||
|
||||
public Action Timer_Delete(Handle h, int id) {
|
||||
AcceptEntityInput(id, "Kill");
|
||||
|
||||
float VEH_MIN[3] = { -30.0, -30.0, 2.0};
|
||||
float VEH_MAX[3] = { 30.0, 30.0, 20.0 };
|
||||
|
||||
bool SpawnCarToPlayer(int target, float distance) {
|
||||
float pos[3], ang[3];
|
||||
GetClientAbsOrigin(target, pos);
|
||||
pos[2] += 40.0;
|
||||
GetClientEyeAngles(target, ang);
|
||||
ang[2] = ang[0] = 0.0;
|
||||
|
||||
float endPos[3];
|
||||
GetHorizontalPositionFromOrigin(pos, ang, distance, endPos);
|
||||
|
||||
TR_TraceHullFilter(endPos, pos, VEH_MIN, VEH_MAX, MASK_SOLID, Filter_Solid);
|
||||
if(TR_DidHit()) {
|
||||
return false;
|
||||
}
|
||||
if(distance > 0.0)
|
||||
ang[1] -= 180;
|
||||
float vel[3];
|
||||
vel[0] = Cosine(DegToRad(ang[1])) * 1500.0;
|
||||
vel[1] = Sine(DegToRad(ang[1])) * 1500.0;
|
||||
int id = CreateProp("prop_physics", MODEL_CAR, endPos, ang, vel);
|
||||
CreateTimer(6.0, Timer_Delete, id);
|
||||
return true;
|
||||
}
|
|
@ -113,6 +113,10 @@ public Action Timer_KickBot(Handle timer, int client) {
|
|||
}
|
||||
}
|
||||
|
||||
public Action Timer_Delete(Handle h, int id) {
|
||||
AcceptEntityInput(id, "Kill");
|
||||
}
|
||||
|
||||
public Action Timer_ShootReverse(Handle h, DataPack pack) {
|
||||
pack.Reset();
|
||||
int attacker = pack.ReadCell();
|
||||
|
@ -148,4 +152,13 @@ public Action Timer_CheckSpecialSpawned(Handle h, int id) {
|
|||
g_iSpId++;
|
||||
ProcessSpecialQueue();
|
||||
}
|
||||
}
|
||||
|
||||
public Action Timer_CheckIsInSpit(Handle h, int userid) {
|
||||
int client = GetClientOfUserId(userid);
|
||||
if(client && GetGameTime() - iLastInSpit[userid] > 3.0) {
|
||||
SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||
return Plugin_Stop;
|
||||
}
|
||||
return Plugin_Continue;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
// UP THE VALUE 'MAX_TROLLS' in base.inc before adding new ones!
|
||||
|
||||
int slipperyShoesIndex = 0;
|
||||
int stickyGooIndex = 0;
|
||||
|
||||
void SetupTrolls() {
|
||||
trollKV = new StringMap();
|
||||
|
@ -24,14 +25,13 @@ void SetupTrolls() {
|
|||
SetupTroll("Inface Special", "Shortcut to sm_inface", TrollMod_Instant);
|
||||
SetupTroll("Insta Special", "Shortcut to sm_insta", TrollMod_Instant);
|
||||
SetupTroll("Goo", "Spawns a spitter puddle underneath them", TrollMod_Instant);
|
||||
index = SetupTroll("Amazon Special Combo", "Choose multiple different specials to spawn", TrollMod_Instant);
|
||||
Trolls[index].AddFlagPrompt(true);
|
||||
for(int i = 0; i < 8; i++) {
|
||||
Trolls[index].AddFlag(SPECIAL_NAMES[i], false); // 1 << 7 max
|
||||
}
|
||||
index = SetupTroll("Sticky Goo", "Slows player down in goo", TrollMod_Constant);
|
||||
Trolls[index].AddFlagPrompt(false);
|
||||
Trolls[index].AddFlag("Spawn On Face", false); // 1 << 8
|
||||
Trolls[index].AddFlag("Spawn Near", false); // 1 << 9
|
||||
Trolls[index].AddFlag("60% Movement Speed", true);
|
||||
Trolls[index].AddFlag("30% Movement Speed", false);
|
||||
Trolls[index].AddFlag("0% Movement Speed", false);
|
||||
stickyGooIndex = index;
|
||||
SetupTroll("Instant Commons", "Spawns commons behind or infront", TrollMod_Instant);
|
||||
|
||||
// CATEGORY: Items
|
||||
SetCategory("Items");
|
||||
|
@ -112,7 +112,11 @@ void SetupTrolls() {
|
|||
|
||||
/// CATEGORY: Movement
|
||||
SetCategory("Movement");
|
||||
SetupTroll("Slow Speed", "Sets player speed to 0.8x of normal speed", TrollMod_Constant);
|
||||
index = SetupTroll("Slow Speed", "Sets player speed to 0.8x of normal speed", TrollMod_Constant);
|
||||
Trolls[index].AddFlagPrompt(false);
|
||||
Trolls[index].AddFlag("60% Movement Speed", true);
|
||||
Trolls[index].AddFlag("30% Movement Speed", false);
|
||||
Trolls[index].AddFlag("0% Movement Speed", false);
|
||||
SetupTroll("Higher Gravity", "Sets player gravity to 1.3x of normal gravity", TrollMod_Constant);
|
||||
SetupTroll("Inverted Controls", "Well, aint it obvious", TrollMod_Constant);
|
||||
SetupTroll("Stagger", "Like a slap, but different", TrollMod_Instant);
|
||||
|
@ -131,6 +135,10 @@ void SetupTrolls() {
|
|||
SetupTroll("No Shove", "Prevents a player from shoving", TrollMod_Constant);
|
||||
SetupTroll("CameTooEarly", "When they shoot, random chance they empty whole clip", 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);
|
||||
index = SetupTroll("Meta: Inverse", "Uhm you are not supposed to see this...", TrollMod_Instant);
|
||||
Trolls[index].hidden = true;
|
||||
Trolls[index].AddFlagPrompt(false);
|
||||
|
@ -167,9 +175,15 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
|
|||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||
SetEntityGravity(victim, 1.0);
|
||||
return false;
|
||||
} else if(StrEqual(troll.name, "Slow Speed"))
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", isActive ? 1.0 : 0.8);
|
||||
else if(StrEqual(troll.name, "Higher Gravity"))
|
||||
} else if(StrEqual(troll.name, "Slow Speed")) {
|
||||
float movement = 1.0;
|
||||
if(isActive) {
|
||||
if(flags & 1) movement = 0.6;
|
||||
else if(flags & 2) movement = 0.3;
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", movement);
|
||||
} else
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", movement);
|
||||
} else if(StrEqual(troll.name, "Higher Gravity"))
|
||||
SetEntityGravity(victim, isActive ? 1.0 : 1.3);
|
||||
else if(StrEqual(troll.name, "Half Primary Ammo")) {
|
||||
int current = GetPrimaryReserveAmmo(victim);
|
||||
|
@ -237,19 +251,30 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
|
|||
BaseComm_SetClientMute(victim, !isActive);
|
||||
} else if(StrEqual(troll.name, "Spicy Gas")) {
|
||||
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
|
||||
} else if(StrEqual(troll.name, "Amazon Special Combo")) {
|
||||
SpecialSpawnFlags spawnFlag = Special_Anywhere;
|
||||
if(flags & (1 << 8)) spawnFlag = Special_OnTarget;
|
||||
for(int i = 1; i < 7; i++) {
|
||||
if(flags & (1 << i)) {
|
||||
SpawnSpecialForTarget(view_as<SpecialType>(i), victim, spawnFlag);
|
||||
} else if(StrEqual(troll.name, "Car Splat")) {
|
||||
if(flags & 1) {
|
||||
if(!SpawnCarOnPlayer(victim)) {
|
||||
ReplyToCommand(activator, "Could not find a suitable area to spawn a car. Requires vertical space above victim.");
|
||||
return false;
|
||||
}
|
||||
} else if(flags & 2) {
|
||||
if(!SpawnCarToPlayer(victim, 450.0)) {
|
||||
ReplyToCommand(activator, "Could not find a suitable area to spawn a car. Requires space ahead of victim");
|
||||
return false;
|
||||
}
|
||||
} else if(flags & 4) {
|
||||
if(!SpawnCarToPlayer(victim, -450.0)) {
|
||||
ReplyToCommand(activator, "Could not find a suitable area to spawn a car. Requires space behind victim");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if(StrEqual(troll.name, "Car Splat")) {
|
||||
if(!SpawnCarOnPlayer(victim)) {
|
||||
ReplyToCommand(activator, "Could not find a suitable area to spawn a car");
|
||||
return false;
|
||||
} else if(StrEqual(troll.name, "Instant Commons")) {
|
||||
float pos[3];
|
||||
GetHorizontalPositionFromClient(victim, -40.0, pos);
|
||||
for(int i = 0; i < 30; i++) {
|
||||
L4D_SpawnCommonInfected(pos);
|
||||
}
|
||||
CreateTimer(0.1, RushPlayer, victim);
|
||||
} else if(modifier != TrollMod_Constant) {
|
||||
PrintToServer("[FTT] Warn: Possibly invalid troll, no apply action defined for \"%s\"", troll.name);
|
||||
#if defined DEBUG
|
||||
|
@ -258,3 +283,4 @@ bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier mod
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue