and having no success making the common infected skin/model color change like how a SI plugin could change their color on spawn i tried rendercolor renderfx and rendermode can't seem to figure it out
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#define L4D2 Nightmarish Common
#define PLUGIN_VERSION "1.1"
#define DEBUG 1
ConVar cvarNightmareChance;
ConVar cvarType1Size;
ConVar cvarType1HP;
ConVar cvarType1Speed;
ConVar cvarType1Damage;
ConVar cvarType1Armor;
ConVar cvarType2Size;
ConVar cvarType2HP;
ConVar cvarType2Speed;
ConVar cvarType2Damage;
ConVar cvarType2Armor;
ConVar cvarType3Size;
ConVar cvarType3HP;
ConVar cvarType3Speed;
ConVar cvarType3Damage;
ConVar cvarType3Armor;
ConVar cvarType4Size;
ConVar cvarType4HP;
ConVar cvarType4Speed;
ConVar cvarType4Damage;
ConVar cvarType4Armor;
int CommonType[4097];
bool isMapRunning = false;
Handle PluginStartTimer = null;
public Plugin myinfo =
{
name = "[L4D2] Nightmarish Common",
author = "Mortiegama",
description = "Empowering the lowest of the infected to make sure that hordes become your worst nightmare.",
version = PLUGIN_VERSION,
url = ""
}
//AtomicStryker - Damage Mod (SDK Hooks):
//https://forums.alliedmods.net/showthread.php?p=1184761
//Bacardi - Cleaning up code:
//https://forums.alliedmods.net/showpost.php?p=2128853&postcount=4
public void OnPluginStart()
{
CreateConVar("l4d_ncm_version", PLUGIN_VERSION, "Nightmarish Common Version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
cvarNightmareChance = CreateConVar("l4d_ncm_nightmarechance", "90", "Chance that the common infected will be turned into Nightmares. (Def 90)", 0, true, 0.0, false, _);
cvarType1Size= CreateConVar("l4d_ncm_type1size", "0.7", "Type 1: Size of common. (Def 0.7)", 0, true, 0.0, false, _);
cvarType1HP= CreateConVar("l4d_ncm_type1hp", "20", "Type 1: HP for the Common. (Def 20)", 0, true, 0.0, false, _);
cvarType1Speed= CreateConVar("l4d_ncm_type1speed", "1.5", "Type 1: speed adjustment for the Common. (Def 1.5)", 0, true, 0.0, false, _);
cvarType1Damage= CreateConVar("l4d_ncm_type1damage", "1.5", "Type 1: Multiplier for damage done to the Survivors (Def 1.5)", 0, true, 0.0, false, _);
cvarType1Armor= CreateConVar("l4d_ncm_type1armor", "1.8", "Type 1: Multiplier for damage done by the Survivors. (Def 1.2)", 0, true, 0.0, false, _);
cvarType2Size= CreateConVar("l4d_ncm_type2size", "0.9", "Type 2: Size of zombie. (Def 0.9)", 0, true, 0.0, false, _);
cvarType2HP= CreateConVar("l4d_ncm_type2hp", "65", "Type 2: HP for the Common. (Def 65)", 0, true, 0.0, false, _);
cvarType2Speed= CreateConVar("l4d_ncm_type2speed", "1.2", "Type 2: speed adjustment for the Common. (Def 1.2)", 0, true, 0.0, false, _);
cvarType2Damage= CreateConVar("l4d_ncm_type2damage", "0.8", "Type 2: Multiplier for damage done to the Survivors (Def 0.8)", 0, true, 0.0, false, _);
cvarType2Armor= CreateConVar("l4d_ncm_type2armor", "0.7", "Type 2: Multiplier for damage done by the Survivors. (Def 0.7)", 0, true, 0.0, false, _);
cvarType3Size= CreateConVar("l4d_ncm_type3size", "1.1", "Type 3: Size of zombie. (Def 1.1)", 0, true, 0.0, false, _);
cvarType3HP= CreateConVar("l4d_ncm_type3hp", "30", "Type 3: HP for the Common. (Def 30)", 0, true, 0.0, false, _);
cvarType3Speed= CreateConVar("l4d_ncm_type3speed", "1.1", "Type 3: speed adjustment for the Common. (Def 1.1)", 0, true, 0.0, false, _);
cvarType3Damage= CreateConVar("l4d_ncm_type3damage", "1.3", "Type 3: Multiplier for damage done to the Survivors (Def 1.3)", 0, true, 0.0, false, _);
cvarType3Armor= CreateConVar("l4d_ncm_type3armor", "1.1", "Type 3: Multiplier for damage done by the Survivors. (Def 1.1)", 0, true, 0.0, false, _);
cvarType4Size= CreateConVar("l4d_ncm_type4size", "1.2", "Type 4: Size of zombie. (Def 1.2)", 0, true, 0.0, false, _);
cvarType4HP= CreateConVar("l4d_ncm_type4hp", "80", "Type 4: HP for the Common. (Def 80)", 0, true, 0.0, false, _);
cvarType4Speed= CreateConVar("l4d_ncm_type4speed", "0.4", "Type 4: speed adjustment for the Common. (Def 0.4)", 0, true, 0.0, false, _);
cvarType4Damage= CreateConVar("l4d_ncm_type4damage", "0.6", "Type 4: Multiplier for damage done to the Survivors (Def 0.6)", 0, true, 0.0, false, _);
cvarType4Armor= CreateConVar("l4d_ncm_type4armor", "0.5", "Type 4: Multiplier for damage done by the Survivors. (Def 0.5)", 0, true, 0.0, false, _);
AutoExecConfig(true, "L4D2_Nightmarish_Common");
PluginStartTimer = CreateTimer(3.0, OnPluginStart_Delayed);
}
public Action OnPluginStart_Delayed(Handle timer)
{
if(PluginStartTimer != null)
{
KillTimer(PluginStartTimer);
PluginStartTimer = null;
}
return Plugin_Stop;
}
public void OnMapStart()
{
isMapRunning = true;
}
public void OnClientPostAdminCheck(int client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage_Survivor);
}
public void OnEntityCreated(int entity, const char[] classname)
{
if (!isMapRunning || IsServerProcessing() == false) return;
if (StrEqual(classname, "infected", false))
{ CreateTimer(0.5, Timer_CommonSpawn, EntIndexToEntRef(entity), TIMER_FLAG_NO_MAPCHANGE); }
}
public Action Timer_CommonSpawn(Handle timer, any ref)
{
int entity = EntRefToEntIndex(ref);
if(entity == INVALID_ENT_REFERENCE || !IsValidEntity(entity) || !IsValidEdict(entity))
{ return Plugin_Stop; }
int NightmareChance = GetRandomInt(0, 99);
int NightmarePercent = (GetConVarInt(cvarNightmareChance));
if (NightmareChance < NightmarePercent)
{
int integer = GetRandomInt(1, 4);
#if DEBUG
PrintToChatAll("Entity is a common infected, type %i.", integer);
#endif
int iHP;
float iSpeed;
float iScale;
int iCP;
int c1;
int c2;
int c3;
switch (integer)
{
case 1:
{
#if DEBUG
PrintToChatAll("Zombie type small strong fast low.");
#endif
iHP = GetConVarInt(cvarType1HP);
iSpeed = GetConVarFloat(cvarType1Speed);
iScale = GetConVarFloat(cvarType1Size);
iCP = (0, 200, 0, 225);
CommonType[entity] = 1;
}
case 2:
{
#if DEBUG
PrintToChatAll("Zombie type small weak quick sturdy.");
#endif
iHP = GetConVarInt(cvarType2HP);
iSpeed = GetConVarFloat(cvarType2Speed);
iScale = GetConVarFloat(cvarType2Size);
iCP = (0, 200, 0, 225);
CommonType[entity] = 2;
}
case 3:
{
#if DEBUG
PrintToChatAll("Zombie type big tough quick weak.");
#endif
iHP = GetConVarInt(cvarType3HP);
iSpeed = GetConVarFloat(cvarType3Speed);
iScale = GetConVarFloat(cvarType3Size);
iCP = (200, 0, 0, 225);
CommonType[entity] = 3;
}
case 4:
{
#if DEBUG
PrintToChatAll("Zombie type large titanic slow titanic.");
#endif
iHP = GetConVarInt(cvarType4HP);
iSpeed = GetConVarFloat(cvarType4Speed);
iScale = GetConVarFloat(cvarType4Size);
iCP = (200, 0, 0, 225);
CommonType[entity] = 4;
}
}
SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage_Infected);
SetEntPropFloat(entity, Prop_Send, "m_flModelScale", iScale);
SetEntProp(entity, Prop_Data, "m_iMaxHealth", iHP);
SetEntProp(entity, Prop_Data, "m_iHealth", iHP);
AcceptEntityInput(entity, "Disable");
SetEntPropFloat(entity, Prop_Send, "m_flSpeed", 1.0*iSpeed);
AcceptEntityInput(entity, "Enable");
SetEntProp(entity, Prop_Send, "m_iGlowType", 3 );
SetEntProp(entity, Prop_Send, "m_nGlowRange", 1000 );
SetEntProp(entity, Prop_Send, "m_nGlowRangeMin", 1 );
SetEntProp(entity, Prop_Send, "m_glowColorOverride", 200 + (0 * 256) + ( 0 * 65536));
c1 = GetRandomInt(0, 255);
c2 = GetRandomInt(0, 255);
c3 = GetRandomInt(0, 255);
SetEntityRenderMode(entity, RenderMode:2);
SetEntityRenderFx(entity, RENDERFX_HOLOGRAM);
SetEntityRenderColor(entity, c1, c2, c3, 255);
}
return Plugin_Continue;
}
public Action OnTakeDamage_Infected(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if (!isMapRunning || IsServerProcessing() == false) return Plugin_Stop;
if (IsValidCommon(victim))
{
switch (CommonType[victim])
{
case 1:
{
float damagemod = GetConVarFloat(cvarType1Armor);
#if DEBUG
PrintToChatAll("Damage Caught: %f damage times %f mod.", damage, damagemod);
#endif
if (FloatCompare(damagemod, 1.0) != 0) { damage = damage * damagemod; }
}
case 2:
{
float damagemod = GetConVarFloat(cvarType2Armor);
#if DEBUG
PrintToChatAll("Damage Caught: %f damage times %f mod.", damage, damagemod);
#endif
if (FloatCompare(damagemod, 1.0) != 0) { damage = damage * damagemod; }
}
case 3:
{
float damagemod = GetConVarFloat(cvarType3Armor);
#if DEBUG
PrintToChatAll("Damage Caught: %f damage times %f mod.", damage, damagemod);
#endif
if (FloatCompare(damagemod, 1.0) != 0) { damage = damage * damagemod; }
}
case 4:
{
float damagemod = GetConVarFloat(cvarType4Armor);
#if DEBUG
PrintToChatAll("Damage Caught: %f damage times %f mod.", damage, damagemod);
#endif
if (FloatCompare(damagemod, 1.0) != 0) { damage = damage * damagemod; }
}
}
}
return Plugin_Changed;
}
public Action OnTakeDamage_Survivor(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if (!isMapRunning || IsServerProcessing() == false) return Plugin_Stop;
if (IsValidCommon(attacker))
{
if (IsValidClient(victim) && GetClientTeam(victim) == 2)
{
switch (CommonType[attacker])
{
case 1:
{
float damagemod = GetConVarFloat(cvarType1Damage);
#if DEBUG
PrintToChatAll("Survivor damage Caught: %f damage times %f mod.", damage, damagemod);
#endif
if (FloatCompare(damagemod, 1.0) != 0) { damage = damage * damagemod; }
}
case 2:
{
float damagemod = GetConVarFloat(cvarType2Damage);
#if DEBUG
PrintToChatAll("Survivor damage Caught: %f damage times %f mod.", damage, damagemod);
#endif
if (FloatCompare(damagemod, 1.0) != 0) { damage = damage * damagemod; }
}
case 3:
{
float damagemod = GetConVarFloat(cvarType3Damage);
#if DEBUG
PrintToChatAll("Survivor damage Caught: %f damage times %f mod.", damage, damagemod);
#endif
if (FloatCompare(damagemod, 1.0) != 0) { damage = damage * damagemod; }
}
case 4:
{
float damagemod = GetConVarFloat(cvarType4Damage);
#if DEBUG
PrintToChatAll("Survivor damage Caught: %f damage times %f mod.", damage, damagemod);
#endif
if (FloatCompare(damagemod, 1.0) != 0) { damage = damage * damagemod; }
}
}
}
}
return Plugin_Changed;
}
public void OnMapEnd()
{
isMapRunning = false;
}
int IsValidCommon(int common)
{
if(common > MaxClients && IsValidEdict(common) && IsValidEntity(common))
{
char classname[32];
GetEdictClassname(common, classname, sizeof(classname));
if(StrEqual(classname, "infected")) { return true; }
}
return false;
}
public int IsValidClient(int client)
{
if (client <= 0) return false;
if (client > MaxClients) return false;
if (!IsClientInGame(client)) return false;
if (!IsPlayerAlive(client)) return false;
return true;
}