//Terminate:
#pragma semicolon 1
//Includes:
#include <sourcemod>
#include <sdktools>
new Handle:h_BloodAmount, String:s_BloodAmount[33];
new Handle:h_BloodLoop, i_BloodLoop;
//Information:
public Plugin:myinfo =
{
//Initialize:
name = "More Blood",
author = "Stiker",
description = "More Blood",
version = "2.2.new",
url = "Skype: stikkkkker"
}
public OnPluginStart()
{
h_BloodAmount = CreateConVar("bb_blood_amount", "14", "Amount of blood per squirt for spray effects.");
h_BloodLoop = CreateConVar("bb_blood_loop", "3", "Amount of squirts per spray effect. (Reduce this if lag occurs.)");
HookConVarChange(h_BloodAmount, CvarChanges);
HookConVarChange(h_BloodLoop, CvarChanges);
HookEvent("player_hurt", EventPlayerHurt);
AutoExecConfig(true, "moreblood");
}
public OnConfigsExecuted()
{
GetConVarString(h_BloodAmount, s_BloodAmount, sizeof(s_BloodAmount));
i_BloodLoop = GetConVarInt(h_BloodLoop);
}
public CvarChanges(Handle:convar, const String:oldValue[], const String:newValue[])
{
if (convar == h_BloodLoop)
{
i_BloodLoop = StringToInt(newValue);
}
else if (convar == h_BloodAmount)
{
strcopy(s_BloodAmount, sizeof(s_BloodAmount), newValue);
}
}
public Action:EventPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new hitgroup = GetEventInt(event, "hitgroup");
if((victim > 0 && victim <= MaxClients) && (attacker > 0 && attacker <= MaxClients))
{
if(IsClientInGame(victim) && IsClientInGame(attacker))
{
if(IsPlayerAlive(victim) && IsPlayerAlive(attacker))
{
new Float:clientloc[3];
GetClientAbsOrigin(victim, clientloc);
clientloc[2] += 35.0;
for(new i = 0; i < i_BloodLoop; i++)
{
env_blood(s_BloodAmount, clientloc, attacker);
if(hitgroup == 1)
{
headshotblood(s_BloodAmount, clientloc);
}
}
}
}
}
}
env_blood(const String:amount[], const Float:origin[3], attacker)
{
new blood = CreateEntityByName("env_blood");
if (blood == -1)
{
return;
}
DispatchKeyValue(blood, "amount", amount);
DispatchKeyValue(blood, "color", "0");
new Float:ang[3] = {0.0,0.0,0.0};
if(GetClientEyeAngles(attacker, ang))
{
new Float:fwd[3] = {0.0,0.0,0.0};
new Float:right[3] = {0.0,0.0,0.0};
new Float:up[3] = {0.0,0.0,0.0};
new Float:Dfg[3] = {0.0,0.0,0.0};
GetAngleVectors(ang, fwd, right, up);
Dfg[0] = -(fwd[0]);
Dfg[1] = -(fwd[1]);
Dfg[2] = -(fwd[2]);
DispatchKeyValue(blood, "spawnflags", "104");
DispatchKeyValueVector(blood, "spraydir", Dfg);
}
else
{
DispatchKeyValue(blood, "spawnflags", "1321");
}
DispatchKeyValueVector(blood, "origin", origin);
AcceptEntityInput(blood, "emitblood");
AcceptEntityInput(blood, "kill");
}
headshotblood(const String:amount[], const Float:origin[3])
{
new blood = CreateEntityByName("env_blood");
if (blood == -1)
{
return;
}
DispatchKeyValue(blood, "amount", amount);
DispatchKeyValue(blood, "color", "0");
DispatchKeyValue(blood, "spawnflags", "1321");
DispatchKeyValueVector(blood, "origin", origin);
AcceptEntityInput(blood, "emitblood");
AcceptEntityInput(blood, "kill");
}