I am posting this here cause It's a work in progress that i don't have much desire to finish. I believe it to be working in this condition but just incase someone else feels like using the code, or improving it.
i get sick and tired of the "w+m1" pyros, its annoying when players instantly ignite so i wrote this little plugin to delay the ignition. Basically pyros have to burn someone for a little bit before igniting. It requires Dukehacks.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>
#include <dukehacks>
public Plugin:myinfo =
{
name = "Delay Ignition",
author = "DeviusCreed",
description = "Requires a constant flame for a set period of time before igniting",
version = "1.1",
url = "<- URL ->"
}
new bool:CanBurn[MAXPLAYERS +1] = false;
new bool:IsBurning[MAXPLAYERS +1] = false;
new Handle:cvClassThreshhold[10];
new Handle:Burn[MAXPLAYERS +1] = INVALID_HANDLE;
new Handle:Pyro_Threshhold = INVALID_HANDLE;
new Float:SecondsBeforeBurn[MAXPLAYERS +1] = 0.0;
//new maxplayers;
public OnPluginStart()
{
//Change to 0.1 for normal gameplay. 20.0 for no ignition. Player would be dead before 20.0 could be reached.
cvClassThreshhold[1] = CreateConVar("sm_th_scout", "1", "Threshhold applies to Scouts")
cvClassThreshhold[2] = CreateConVar("sm_th_sniper", "1", "Threshhold applies to Snipers")
cvClassThreshhold[3] = CreateConVar("sm_th_soldier", "1", "Threshhold applies to Soldiers")
cvClassThreshhold[4] = CreateConVar("sm_th_demo", "1", "Threshhold applies to Demos")
cvClassThreshhold[5] = CreateConVar("sm_th_medic", "1", "Threshhold applies to Medics")
cvClassThreshhold[6] = CreateConVar("sm_th_heavy", "1", "Threshhold applies to Heavys")
cvClassThreshhold[7] = CreateConVar("sm_th_pyro", "1", "Threshhold applies to Pyros")
cvClassThreshhold[8] = CreateConVar("sm_th_spy", "1", "Threshhold applies to Spies")
cvClassThreshhold[9] = CreateConVar("sm_th_engineer", "1", "Threshhold applies to Engies")
Pyro_Threshhold = CreateConVar("sm_flame_delay","1.0","Amount of constant flame before ignition");
HookEvent("player_hurt", Event_PlayerHurt);
HookEvent("player_spawn", Event_PlayerSpawn);
dhAddClientHook(CHK_TakeDamage, TakeDamageHook);
}
public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new target = GetClientOfUserId(GetEventInt(event, "userid"))
CanBurn[target] = false;
SecondsBeforeBurn[target] = 0.0;
IsBurning[target] = false;
//not sure why i did this this way. but it functions so bleh.
if(Burn[target] == INVALID_HANDLE)
Burn[target] = CreateTimer(0.1, CheckTrue, target, TIMER_REPEAT);
}
public OnClientDisconnect(client){
KillTimer(Burn[client])
Burn[client] = INVALID_HANDLE;
CanBurn[client] = false;
SecondsBeforeBurn[client] = 0.0;
IsBurning[client] = false;
}
public Action:TakeDamageHook(client, attacker, inflictor, Float:damage, &Float:multiplier)
{
new String:weapon[32];
GetEntityNetClass(inflictor, weapon, sizeof(weapon));
if(StrEqual(weapon, "CTFProjectile_Flare"))
IsBurning[client] = true;
return Plugin_Continue;
}
public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new target = GetClientOfUserId(GetEventInt(event, "userid"))
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new class = _:TF2_GetPlayerClass(target);
new Applies = GetConVarInt(cvClassThreshhold[class]);
if(Applies == 0)
return;
decl String:sWeapon[32];
GetClientWeapon(attacker, sWeapon, sizeof(sWeapon));
//make sure its a flame thrower doing the damage, and make sure target isn't already on fire.
//Dukehacks triggers before playercond is set, so i have to check in player_hurt
//Dukehacks is used however to check if the flare gun damage was done, otherwise a player can shoot a flare,
//switch to the flamethrower before impact and the flare won't ignite player.
if (StrEqual("tf_weapon_flamethrower",sWeapon) && !IsBurning[target])
{
new playerstate = GetEntProp(target, Prop_Send, "m_nPlayerCond")
if ((playerstate & 131072) != 0)
{
SecondsBeforeBurn[target] += 0.3;
if(!CanBurn[target])
SetEntProp(target, Prop_Send, "m_nPlayerCond", (playerstate & (~131072)))
else
IsBurning[target] = true;
}
}
}
public Action:CheckTrue(Handle:timer, any:client)
{
//If the player gets healed or flame runs out, this could be put in OnGameFrame, but this fires every .1 second anyway.
new playerstate = GetEntProp(client, Prop_Send, "m_nPlayerCond")
if ((playerstate & 131072) == 0)
IsBurning[client] = false;
//This is the only way i could find reliable to check for a constant burn.
//This triggers every 0.1 second, so during player_hurt while the player is actually hit with flame
//SecondsBeforeBurn goes up by 0.3. In effect if the player is no longer being hit with flames
//this mimics it by reduction.
//This also effects the number of pyros flaming someone. The more pyros, the faster the ignition.
if(SecondsBeforeBurn[client] > 0.0)
SecondsBeforeBurn[client] -= 0.1;
else{
SecondsBeforeBurn[client] = 0.0;
CanBurn[client] = false;
}
if(SecondsBeforeBurn[client] >= GetConVarFloat(Pyro_Threshhold))
CanBurn[client] = true;
}