Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Masquer les espaces
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Styles de texte
Modifier l’apparence
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
Untitled diff
Créé
il y a 11 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
569 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
575 lignes
Copier tout
185 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
187 lignes
Copier tout
#include <sourcemod>
#include <sourcemod>
#include <sdktools>
#include <sdktools>
Copier
Copié
Copier
Copié
#include <sdkhooks>
#define PLUGIN_VERSION "0.8.1"
#define PISTOL 1
#define SMG 2
#define PUMPSHOTGUN 3
#define AUTOSHOTGUN 4
#define RIFLE 5
#define HUNTING_RIFLE 6
#define SMG_SILENCED 7
#define SHOTGUN_CHROME 8
#define RIFLE_DESERT 9
#define SNIPER_MILITARY 10
#define SHOTGUN_SPAS 11
#define MOLOTOV 13
#define PIPE_BOMB 14
#define VOMITJAR 25
#define RIFLE_AK47 26
#define PISTOL_MAGNUM 32
#define SMG_MP5 33
#define RIFLE_SG552 34
#define SNIPER_AWP 35
#define SNIPER_SCOUT 36
//Cvar handles.
new Handle:h_Enabled
new Handle:h_AWPEnabled
new Handle:h_MP5Enabled
new Handle:h_ScoutEnabled
new Handle:h_SG552Enabled
new Handle:h_ScoutBoost
new Handle:h_AWPBoost
//new Handle:h_BatterUp
//Used to store weapon spawns.
new WeaponSpawn_ID[64]
new WeaponSpawn_IDMod[64]
new Float:WeaponSpawn_X[64]
new Float:WeaponSpawn_Y[64]
new Float:WeaponSpawn_Z[64]
new String:Map[64]
new String:GameMode[16]
//Used to keep spawns the same for both teams on competitive modes.
new bool:g_bNewMap
new bool:g_bScavengeHalftime
public Plugin:myinfo =
{
name = "[L4D2] Weapon Unlock",
author = "Crimson_Fox",
description = "Unlocks the hidden CSS weapons.",
version = PLUGIN_VERSION,
url = "http://forums.alliedmods.net/showthread.php?p=1041458"
}
public OnPluginStart()
{
//Look up what game we're running,
decl String:game[16]
GetGameFolderName(game, sizeof(game))
//and don't load if it's not L4D2.
if (!StrEqual(game, "left4dead2", false)) SetFailState("Plugin supports Left 4 Dead 2 only.")
//Set up cvars and event hooks.
CreateConVar("l4d2_WeaponUnlock", PLUGIN_VERSION, "Weapon Unlock version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD)
h_Enabled = CreateConVar("l4d2_wu_enable", "1", "Is Weapon Unlock plug-in enabled?", FCVAR_PLUGIN|FCVAR_DONTRECORD)
h_AWPEnabled = CreateConVar("l4d2_wu_awp", "1", "Enable AWP sniper rifle?", FCVAR_PLUGIN)
h_MP5Enabled = CreateConVar("l4d2_wu_mp5", "1", "Enable MP5 submachine gun?", FCVAR_PLUGIN)
h_ScoutEnabled = CreateConVar("l4d2_wu_scout", "1", "Enable Scout sniper rifle?", FCVAR_PLUGIN)
h_SG552Enabled = CreateConVar("l4d2_wu_sg552", "1", "Enable SG552 assault rifle?", FCVAR_PLUGIN)
h_AWPBoost = CreateConVar("l4d2_wu_awpboost", "135", "Amount of damage added to AWP sniper rifle.", FCVAR_PLUGIN)
h_ScoutBoost = CreateConVar("l4d2_wu_scoutboost", "110", "Amount of damage added to scout sniper rifle.", FCVAR_PLUGIN)
// h_BatterUp = CreateConVar("l4d2_wu_bat", "0", "Spawn baseball bats for survivors?", FCVAR_PLUGIN)
AutoExecConfig(true, "l4d2_WeaponUnlock")
HookEvent("round_start", Event_RoundStart)
HookEvent("scavenge_round_halftime", Event_ScavengeRoundHalftime)
HookEvent("player_hurt", Event_PlayerHurt)
HookConVarChange(h_Enabled, ConVarChange_Enabled)
//Precache hidden weapon models and initialize them after one second.
PrecacheWeaponModels()
CreateTimer(1.0, InitHiddenWeaponsDelay)
}
Copier
Copié
Copier
Copié
PrecacheWeaponModels()
#define STRING_SIZE 1024
{
#define FLAG_WEAPON_SPAWN true
//Precache weapon models if they're not loaded.
if (!IsModelPrecached("models/w_models/weapons/w_rifle_sg552.mdl")) PrecacheModel("models/w_models/weapons/w_rifle_sg552.mdl")
if (!IsModelPrecached("models/w_models/weapons/w_smg_mp5.mdl")) PrecacheModel("models/w_models/weapons/w_smg_mp5.mdl")
if (!IsModelPrecached("models/w_models/weapons/w_sniper_awp.mdl")) PrecacheModel("models/w_models/weapons/w_sniper_awp.mdl")
if (!IsModelPrecached("models/w_models/weapons/w_sniper_scout.mdl")) PrecacheModel("models/w_models/weapons/w_sniper_scout.mdl")
if (!IsModelPrecached("models/w_models/weapons/w_eq_bile_flask.mld")) PrecacheModel("models/w_models/weapons/w_eq_bile_flask.mld")
if (!IsModelPrecached("models/v_models/v_rif_sg552.mdl")) PrecacheModel("models/v_models/v_rif_sg552.mdl")
if (!IsModelPrecached("models/v_models/v_smg_mp5.mdl")) PrecacheModel("models/v_models/v_smg_mp5.mdl")
if (!IsModelPrecached("models/v_models/v_snip_awp.mdl")) PrecacheModel("models/v_models/v_snip_awp.mdl")
if (!IsModelPrecached("models/v_models/v_snip_scout.mdl")) PrecacheModel("models/v_models/v_snip_scout.mdl")
}
Copier
Copié
Copier
Copié
public Action:InitHiddenWeaponsDelay(Handle:timer, any:client)
#define AWP_LIMIT 1
{
#define SCOUT_LIMIT 3
//Spawn and delete the hidden weapons,
#define WEAPONID_MP5 33
new index = CreateEntityByName("weapon_rifle_sg552")
#define WEAPONID_SG552 34
DispatchSpawn(index)
#define WEAPONID_AWP 35
RemoveEdict(index)
#define WEAPONID_SCOUT 36
index = CreateEntityByName("weapon_smg_mp5")
#define WEAPONID_SMG 2
DispatchSpawn(index)
#define WEAPONID_HUNTING 6
RemoveEdict(index)
#define WEAPONID_DESERT 9
index = CreateEntityByName("weapon_sniper_awp")
#define WEAPONID_MILITARY 10
DispatchSpawn(index)
RemoveEdict(index)
index = CreateEntityByName("weapon_sniper_scout")
DispatchSpawn(index)
RemoveEdict(index)
GetCurrentMap(Map, sizeof(Map))
ForceChangeLevel(Map, "Hidden weapon initialization.")
}
Copier
Copié
Copier
Copié
public
ConVarChange_Enabled(Handle:convar, const String:oldValue[], const String:newValue[])
public
OnPluginStart() {
{
HookEvent("round_start", eventRoundStart);
if ((StringToInt(oldValue) == 1) && (StringToInt(newValue) == 0)) RestoreWeaponSpawns()
lateLoadSDKHook();
if ((StringToInt(oldValue) == 0) && (StringToInt(newValue) == 1)) CreateTimer(0.1, RoundStartDelay)
}
}
Copier
Copié
Copier
Copié
public OnMapStart()
public OnMapStart()
{
{
precacheModels();
g_bNewMap = true
g_bScavengeHalftime = false
for (new i = 0; i < sizeof(WeaponSpawn_ID); i++) WeaponSpawn_ID[i] = -1
}
}
Copier
Copié
Copier
Copié
public
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
public
OnClientPostAdminCheck(client) {
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
if (GetConVarInt(h_Enabled) == 0) return
//Spawn baseball bats if the option is enabled.
// if (GetConVarInt(h_BatterUp) != 0) CreateTimer(15.0, SpawnBatsDelay)
//Need a delay here to let OnMapStart() run.
CreateTimer(1.0, RoundStartDelay)
}
}
Copier
Copié
Copier
Copié
public Action:
RoundStartDelay(Handle:timer)
public Action:
eventRoundStart(Handle:event, const String:name[], bool:dontBroadcast) {
{
if (isMapAllowed()) {
//Look up the map and type of game we're running.
CreateTimer(1.0, roundStartDelay, TIMER_FLAG_NO_MAPCHANGE);
GetConVarString(FindConVar("mp_gamemode"), GameMode, sizeof(GameMode))
if (StrEqual(GameMode, "survival")) return
if (StrEqual(GameMode, "scavenge"))
{
if (g_bScavengeHalftime == true) g_bScavengeHalftime = false
else GetWeaponSpawns()
SetWeaponSpawns()
return
}
if (StrEqual(GameMode, "versus"))
{
if (g_bNewMap == true)
{
GetWeaponSpawns()
g_bNewMap = false
}
SetWeaponSpawns()
return
}
}
Copier
Copié
Copier
Copié
GetCurrentMap(Map, sizeof(Map))
//If we're in a coop mode and running c4m1-4, don't modify spawns as it causes crashes on transitions.
if (
(StrEqual(GameMode, "coop") ||
StrEqual(GameMode, "realism")) &&
(StrEqual(Map, "c4m1_milltown_a") ||
StrEqual(Map, "c4m2_sugarmill_a") ||
StrEqual(Map, "c4m3_sugarmill_b") ||
StrEqual(Map, "c4m4_milltown_b")))
return
GetWeaponSpawns()
SetWeaponSpawns()
}
}
Copier
Copié
Copier
Copié
public Action:Event_ScavengeRoundHalftime(Handle:event, const String:name[], bool:dontBroadcast)
stock isMapAllowed() {
{
new String:currentMap[STRING_SIZE];
g_bScavengeHalftime = true
GetCurrentMap(currentMap, sizeof(currentMap));
if (StrEqual(currentMap, "c4m1_milltown_a", false) || StrEqual(currentMap, "c4m2_sugarmill_a", false) || StrEqual(currentMap, "c4m3_sugarmill_b", false) || StrEqual(currentMap, "c4m4_milltown_b", false)) {
return false;
}
return true;
}
}
Copier
Copié
Copier
Copié
/*
public Action:roundStartDelay(Handle:timer) {
//Spawn bats at the survivors' position.
precacheModels();
public Action:SpawnBatsDelay(Handle:timer)
proccessReplace();
{
for (new i = 1; i <= MaxClients; i++)
{
if ((IsClientInGame(i)) && (GetClientTeam(i)==2))
{
new Float:Origin[3]
new index = CreateEntityByName("weapon_melee")
GetClientAbsOrigin(i, Origin)
TeleportEntity(index, Origin, NULL_VECTOR, NULL_VECTOR)
DispatchKeyValue(index, "melee_script_name", "baseball_bat")
DispatchSpawn(index)
}
}
}
*/
public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new target = GetClientOfUserId(GetEventInt(event, "userid"))
if (target == 0) return
//If the player that was hurt was not infected, go back.
if (GetClientTeam(target) != 3) return
decl String:weapon[16]
GetEventString(event, "weapon", weapon, sizeof(weapon))
if (StrEqual(weapon, "sniper_awp"))
{
new health = GetClientHealth(target)
new damage = GetConVarInt(h_AWPBoost)
if (health-damage < 0) SetEntityHealth(target, 0)
else SetEntityHealth(target, health-damage)
}
if (StrEqual(weapon, "sniper_scout"))
{
new health = GetClientHealth(target)
new damage = GetConVarInt(h_ScoutBoost)
if (health-damage < 0) SetEntityHealth(target, 0)
else SetEntityHealth(target, health-damage)
}
}
}
Copier
Copié
Copier
Copié
GetWeaponSpawns()
stock proccessReplace() {
{
new spawnedAwp, spawnedScout;
//Search for dynamic weapon spawns,
for (new i = GetMaxClients(); i < GetMaxEntities(); i++) {
decl String:EdictClassName[32]
if (
IsValidEdict(i) &&
IsValidEntity(i))
{
new count = 0
new String:classname[STRING_SIZE];
for (new i = 0; i <= GetEntityCount(); i++)
GetEdictClassname(i,
c
lass
n
ame, sizeof(
c
lass
n
ame))
;
{
if (
IsValidEntity(i))
new weaponSpawnId;
{
if (StrEqual(
c
lass
n
ame, "weapon_spawn"))
{
GetEdictClassname(i,
EdictC
lass
N
ame, sizeof(
EdictC
lass
N
ame))
weaponSpawnId
= GetEntProp(i, Prop_Send, "m_weaponID")
;
if (StrEqual(
EdictC
lass
N
ame, "weapon_spawn"))
{
//and record their position.
new Float:Location[3]
GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location)
WeaponSpawn_ID[count]
= GetEntProp(i, Prop_Send, "m_weaponID")
WeaponSpawn_X[count] = Location[0]
WeaponSpawn_Y[count] = Location[1]
WeaponSpawn_Z[count] = Location[2]
count++
}
}
Copier
Copié
Copier
Copié
}
}
if (StrEqual(classname, "weapon_sniper_military") || StrEqual(classname, "weapon_sniper_military_spawn") || weaponSpawnId == WEAPONID_MILITARY) {
//If dynamic spawns were found, and we're not running scavenge, modify the stored spawns like this:
if (spawnedAwp < AWP_LIMIT && isRandomAllowing(50)) {
if (count != 0 && !StrEqual(GameMode, "scavenge"))
new weapon = replace(i, "weapon_sniper_awp");
{
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 180, 4);
for (new i = 0; i < sizeof(WeaponSpawn_ID); i++)
spawnedAwp++;
{
}
if (WeaponSpawn_ID[i] == -1) break
WeaponSpawn_IDMod[i] = WeaponSpawn_ID[i]
switch(WeaponSpawn_ID[i])
{
case RIFLE_AK47: if ((GetConVarInt(h_SG552Enabled) == 1) && (GetRandomInt(1, 4) == 1)) WeaponSpawn_IDMod[i] = RIFLE_SG552;
case SNIPER_MILITARY: if ((GetConVarInt(h_AWPEnabled) == 1) && (GetRandomInt(1, 2) == 1)) WeaponSpawn_IDMod[i] = SNIPER_AWP;
case RIFLE_DESERT: if ((GetConVarInt(h_SG552Enabled) == 1) && (GetRandomInt(1, 4) == 1)) WeaponSpawn_IDMod[i] = RIFLE_SG552;
case SMG_SILENCED: if ((GetConVarInt(h_MP5Enabled) == 1) && (GetRandomInt(1, 3) == 1)) WeaponSpawn_IDMod[i] = SMG_MP5;
case HUNTING_RIFLE: if ((GetConVarInt(h_ScoutEnabled) == 1) && (GetRandomInt(1, 2) == 1)) WeaponSpawn_IDMod[i] = SNIPER_SCOUT;
case RIFLE: if ((GetConVarInt(h_SG552Enabled) == 1) && (GetRandomInt(1, 4) == 1)) WeaponSpawn_IDMod[i] = RIFLE_SG552;
case SMG: if ((GetConVarInt(h_MP5Enabled) == 1) && (GetRandomInt(1, 3) == 1)) WeaponSpawn_IDMod[i] = SMG_MP5;
}
}
Copier
Copié
Copier
Copié
}
else if (
StrEqual(
c
lass
n
ame, "weapon_
hunting_rifle
") ||
StrEqual(
c
lass
n
ame, "weapon_hunting_rifle_spawn") ||
weaponSpawnId == WEAPONID_HUNTING) {
}
if (spawnedScout < SCOUT_LIMIT && isRandomAllowing(50)) {
//Otherwise, search for static spawns,
new weapon = replace(i, "weapon_sniper_scout");
else
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 180, 4);
{
spawnedScout++;
for (new i = 0; i <= GetEntityCount(); i++)
{
if (IsValidEntity(i))
{
GetEdictClassname(i, EdictClassName, sizeof(EdictClassName))
if (
StrEqual(
EdictC
lass
N
ame, "weapon_
autoshotgun_spawn
") ||
StrEqual(
EdictC
lass
N
ame, "weapon_hunting_rifle_spawn") ||
StrEqual(EdictClassName, "weapon_molotov_spawn") ||
StrEqual(EdictClassName, "weapon_pipe_bomb_spawn") ||
StrEqual(EdictClassName, "weapon_pistol_magnum_spawn") ||
StrEqual(EdictClassName, "weapon_pistol_spawn") ||
StrEqual(EdictClassName, "weapon_pumpshotgun_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_ak47_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_desert_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_spawn") ||
StrEqual(EdictClassName, "weapon_shotgun_chrome_spawn") ||
StrEqual(EdictClassName, "weapon_shotgun_spas_spawn") ||
StrEqual(EdictClassName, "weapon_smg_spawn") ||
StrEqual(EdictClassName, "weapon_smg_silenced_spawn") ||
StrEqual(EdictClassName, "weapon_sniper_military_spawn") ||
StrEqual(EdictClassName, "weapon_vomitjar_spawn"))
{
//record their position,
new Float:Location[3]
GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location)
WeaponSpawn_ID[count] = GetEntProp(i, Prop_Send, "m_weaponID")
WeaponSpawn_X[count] = Location[0]
WeaponSpawn_Y[count] = Location[1]
WeaponSpawn_Z[count] = Location[2]
count++
}
}
}
}
Copier
Copié
Copier
Copié
}
else if (StrEqual(classname, "weapon_rifle_desert")) {
//and modify them like this:
new weapon = replace(i, "weapon_rifle_sg552");
for (new i = 0; i < sizeof(WeaponSpawn_ID); i++)
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 360, 4);
{
}
if (WeaponSpawn_ID[i] == -1) break
else if (StrEqual(classname, "weapon_rifle_desert_spawn") || weaponSpawnId == WEAPONID_DESERT) {
WeaponSpawn_IDMod[i] = WeaponSpawn_ID[i]
replace(i, "weapon_rifle_sg552", FLAG_WEAPON_SPAWN);
switch(WeaponSpawn_ID[i])
}
{
else if (StrEqual(classname, "weapon_smg")) {
case PISTOL_MAGNUM: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PISTOL;
new weapon = replace(i, "weapon_smg_mp5");
case RIFLE_AK47:
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 650, 4);
if (GetConVarInt(h_SG552Enabled) == 1)
}
{
else if (StrEqual(classname, "weapon_smg_spawn") || weaponSpawnId == WEAPONID_SMG) {
switch(GetRandomInt(1, 4))
replace(i, "weapon_smg_mp5", FLAG_WEAPON_SPAWN);
{
case 3: WeaponSpawn_IDMod[i] = RIFLE;
case 2: WeaponSpawn_IDMod[i] = RIFLE_DESERT;
case 1: WeaponSpawn_IDMod[i] = RIFLE_SG552;
}
}
else
{
switch(GetRandomInt(1, 3) == 1)
{
case 2: WeaponSpawn_IDMod[i] = RIFLE;
case 1: WeaponSpawn_IDMod[i] = RIFLE_DESERT;
}
}
case VOMITJAR:
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = PIPE_BOMB;
case 1: WeaponSpawn_IDMod[i] = MOLOTOV;
}
case PIPE_BOMB:
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = MOLOTOV;
case 1: WeaponSpawn_IDMod[i] = VOMITJAR;
}
case MOLOTOV:
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = VOMITJAR;
case 1: WeaponSpawn_IDMod[i] = PIPE_BOMB;
}
case SHOTGUN_SPAS: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = AUTOSHOTGUN;
case SNIPER_MILITARY: if ((GetConVarInt(h_AWPEnabled) == 1) && (GetRandomInt(1, 2) == 1)) WeaponSpawn_IDMod[i] = SNIPER_AWP;
case RIFLE_DESERT:
if (GetConVarInt(h_SG552Enabled) == 1)
{
switch(GetRandomInt(1, 4))
{
case 3: WeaponSpawn_IDMod[i] = RIFLE;
case 2: WeaponSpawn_IDMod[i] = RIFLE_AK47;
case 1: WeaponSpawn_IDMod[i] = RIFLE_SG552;
}
}
else
{
switch(GetRandomInt(1, 3) == 1)
{
case 2: WeaponSpawn_IDMod[i] = RIFLE;
case 1: WeaponSpawn_IDMod[i] = RIFLE_AK47;
}
}
case SHOTGUN_CHROME: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PUMPSHOTGUN;
case SMG_SILENCED:
if (GetConVarInt(h_MP5Enabled) == 1)
{
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = SMG;
case 1: WeaponSpawn_IDMod[i] = SMG_MP5;
}
}
else if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SMG;
//Since the hunting rifle is a T1 weapon in L4D2, we'll upgrade it to a T2 sniper rifle for L4D1 maps.
case HUNTING_RIFLE:
if (GetConVarInt(h_AWPEnabled) == 1)
{
switch(GetRandomInt(1, 2))
{
case 2: WeaponSpawn_IDMod[i] = SNIPER_MILITARY;
case 1: WeaponSpawn_IDMod[i] = SNIPER_AWP;
}
}
else WeaponSpawn_IDMod[i] = SNIPER_MILITARY;
case RIFLE:
if (GetConVarInt(h_SG552Enabled) == 1)
{
switch(GetRandomInt(1, 4))
{
case 3: WeaponSpawn_IDMod[i] = RIFLE_AK47;
case 2: WeaponSpawn_IDMod[i] = RIFLE_DESERT;
case 1: WeaponSpawn_IDMod[i] = RIFLE_SG552;
}
}
else
{
switch(GetRandomInt(1, 3) == 1)
{
case 2: WeaponSpawn_IDMod[i] = RIFLE_AK47;
case 1: WeaponSpawn_IDMod[i] = RIFLE_DESERT;
}
}
case AUTOSHOTGUN: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SHOTGUN_SPAS;
case PUMPSHOTGUN: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SHOTGUN_CHROME;
case SMG:
if (GetConVarInt(h_MP5Enabled) == 1)
{
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = SMG_SILENCED;
case 1: WeaponSpawn_IDMod[i] = SMG_MP5;
}
}
else if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SMG_SILENCED;
case PISTOL: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PISTOL_MAGNUM;
}
}
}
}
}
}
}
}
Copier
Copié
Copier
Copié
SetWeaponSpawns()
stock replace(oldWeapon, const String:newWeaponName[], bool:isSpawn = false) {
{
new Float:origin[3], Float:angles[3];
PrecacheWeaponModels()
GetEntPropVector(oldWeapon, Prop_Send, "m_vecOrigin", origin);
decl String:EdictClassName[32]
GetEntPropVector(oldWeapon, Prop_Send, "m_angRotation", angles);
for (new i = 0; i <= GetEntityCount(); i++)
RemoveEdict(oldWeapon);
{
new newItemEntity;
if (IsValidEntity(i))
if (isSpawn) {
{
newItemEntity = CreateEntityByName("weapon_spawn");
GetEdictClassname(i, EdictClassName, sizeof(EdictClassName))
if (StrEqual(newWeaponName, "weapon_rifle_sg552")) {
if (
SetEntityModel(newItemEntity, "models/w_models/weapons/w
_rifle_
sg552.mdl");
StrEqual(EdictClassName, "weapon_spawn") ||
SetEntProp(newItemEntity, Prop_Send, "m_
weapon
ID", WEAPONID_SG552);
StrEqual(EdictClassName, "weapon_autoshotgun_spawn") ||
} else if (
StrEqual(
newWeaponName
, "weapon_smg_
mp5")) {
StrEqual(EdictClassName, "weapon_hunting_rifle_spawn") ||
if (IsModelPrecached("models/w_models/
weapon
s/w
_smg_
mp5.mdl")) {
StrEqual(EdictClassName, "weapon_molotov_spawn") ||
SetEntityModel(newItemEntity
, "
models/w_models/
weapon
s/w_smg_mp5.mdl");
StrEqual(EdictClassName, "weapon_pipe_bomb_spawn") ||
SetEntProp(newItemEntity
, Prop_Send, "m_weaponID"
, WEAPONID_MP5);
StrEqual(EdictClassName, "weapon_pistol_magnum_spawn") ||
} else {
StrEqual(EdictClassName, "weapon_pistol_spawn") ||
SetEntityModel(newItemEntity, "models/w_models/weapons/w_smg_uzi.mdl");
StrEqual(EdictClassName, "weapon_pumpshotgun_spawn") ||
SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_SMG);
StrEqual(EdictClassName, "weapon_rifle_ak47_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_desert_spawn") ||
StrEqual(EdictClassName, "weapon
_rifle_
spawn") ||
StrEqual(EdictClassName, "weapon_shotgun_chrome_spawn") ||
StrEqual(EdictClassName, "
weapon
_shotgun_spas_spawn") ||
StrEqual(
EdictClassName
, "weapon_smg_
spawn") ||
StrEqual(EdictClassName, "
weapon
_smg_
silenced_spawn") ||
StrEqual(EdictClassName
, "
weapon_sniper_military_spawn") ||
StrEqual(EdictClassName, "
weapon
_vomitjar_spawn"))
{
new Float:Location[3]
GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location)
new weaponID = GetEntProp(i
, Prop_Send, "m_weaponID"
)
for (new x = 0; x < sizeof(WeaponSpawn_IDMod); x++)
{
if (WeaponSpawn_ID[x] == -1) break
if (
((FloatAbs(WeaponSpawn_X[x] - Location[0]) < 2) &&
(FloatAbs(WeaponSpawn_Y[x] - Location[1]) < 2) &&
(FloatAbs(WeaponSpawn_Z[x] - Location[2]) < 2)) &&
(weaponID != WeaponSpawn_IDMod[x]))
{
ReplaceWeaponSpawn(i, x)
break
}
}
}
}
Copier
Copié
Copier
Copié
} else {
return 0;
}
}
Copier
Copié
Copier
Copié
} else {
newItemEntity = CreateEntityByName(newWeaponName);
}
if (IsValidEdict(newItemEntity)) {
TeleportEntity(newItemEntity, origin, angles, NULL_VECTOR);
if (isSpawn) DispatchKeyValue(newItemEntity, "count", "4");
DispatchSpawn(newItemEntity);
}
return newItemEntity;
}
public OnEntityCreated(entity, const String:classname[]) {
if (StrEqual(classname, "infected") || StrEqual(classname, "witch")) {
SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
}
}
}
}
Copier
Copié
Copier
Copié
RestoreWeaponSpawns()
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype) {
{
if (inflictor && attacker && victim && IsValidEdict(victim) && IsValidEdict(inflictor)) {
decl String:EdictClassName[32]
if (IsClientInGame(victim) && GetClientTeam(victim) == 2) {
for (new i = 0; i <= GetEntityCount(); i++)
return Plugin_Continue;
{
}
if (IsValidEntity(i))
new String:classname[STRING_SIZE];
{
new weapon = GetEntPropEnt(attacker, Prop_Data, "m_hActiveWeapon");
GetEdictClassname(i, EdictClassName, sizeof(EdictClassName))
GetEdictClassname(weapon, classname, sizeof(classname));
if (StrEqual(EdictClassName, "weapon_spawn"))
{
if (StrEqual(classname, "weapon_sniper_awp")) {
new Float:Location[3]
damage = 600.0;
GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location)
return Plugin_Changed;
new weaponID = GetEntProp(i, Prop_Send, "m_weaponID")
}
for (new x = 0; x < sizeof(WeaponSpawn_ID); x++)
if (StrEqual(classname, "weapon_sniper_scout")) {
{
damage = 350.0;
if (WeaponSpawn_ID[x] == -1) break
return Plugin_Changed;
if (
}
((FloatAbs(WeaponSpawn_X[x] - Location[0]) < 2) &&
if (StrEqual(classname, "weapon_rifle_sg552")) {
(FloatAbs(WeaponSpawn_Y[x] - Location[1]) < 2) &&
damage = 50.0;
(FloatAbs(WeaponSpawn_Z[x] - Location[2]) < 2)) &&
return Plugin_Changed;
(weaponID != WeaponSpawn_ID[x]))
}
{
if (StrEqual(classname, "weapon_smg_mp5")) {
new Float:Angles[3]
damage = 25.0;
GetEntPropVector(i, Prop_Send, "m_angRotation", Angles)
return Plugin_Changed;
RemoveEdict(i)
new index = CreateEntityByName("weapon_spawn")
switch(WeaponSpawn_ID[x])
{
case PISTOL_MAGNUM: SetEntityModel(index, "models/w_models/weapons/w_desert_eagle.mdl");
case RIFLE_AK47: SetEntityModel(index, "models/w_models/weapons/w_rifle_ak47.mdl");
case VOMITJAR: SetEntityModel(index, "models/w_models/weapons/w_eq_bile_flask.mld");
case PIPE_BOMB: SetEntityModel(index, "models/w_models/weapons/w_eq_pipebomb.mdl");
case MOLOTOV: SetEntityModel(index, "models/w_models/weapons/w_eq_molotov.mdl");
case SHOTGUN_SPAS: SetEntityModel(index, "models/w_models/weapons/w_shotgun_spas.mdl");
case SNIPER_MILITARY: SetEntityModel(index, "models/w_models/weapons/w_sniper_military.mdl");
case RIFLE_DESERT: SetEntityModel(index, "models/w_models/weapons/w_desert_rifle.mdl");
case SHOTGUN_CHROME: SetEntityModel(index, "models/w_models/weapons/w_pumpshotgun_a.mdl");
case SMG_SILENCED: SetEntityModel(index, "models/w_models/weapons/w_smg_a.mdl");
case HUNTING_RIFLE: SetEntityModel(index, "models/w_models/weapons/w_sniper_mini14.mdl");
case RIFLE: SetEntityModel(index, "models/w_models/weapons/w_rifle_m16a2.mdl");
case AUTOSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_autoshot_m4super.mdl");
case PUMPSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_shotgun.mdl");
case SMG: SetEntityModel(index, "models/w_models/weapons/w_smg_uzi.mdl");
case PISTOL: SetEntityModel(index, "models/w_models/weapons/w_pistol_a.mdl");
}
SetEntProp(index, Prop_Send, "m_weaponID", WeaponSpawn_ID[x])
TeleportEntity(index, Location, Angles, NULL_VECTOR)
if (
WeaponSpawn_ID[x] == VOMITJAR ||
WeaponSpawn_ID[x] == PIPE_BOMB ||
WeaponSpawn_ID[x] == MOLOTOV)
DispatchKeyValue(index, "count", "1")
else DispatchKeyValue(index, "count", "4")
DispatchSpawn(index)
}
}
}
}
}
}
}
Copier
Copié
Copier
Copié
return Plugin_Continue;
}
}
Copier
Copié
Copier
Copié
ReplaceWeaponSpawn(target, source)
stock isRandomAllowing(chance) {
{
if (GetRandomInt(1, 100) <= chance) return true;
new Float:Origin[3]
return false;
Origin[0] = WeaponSpawn_X[source]
}
Origin[1] = WeaponSpawn_Y[source]
Origin[2] = WeaponSpawn_Z[source]
stock precacheModels() {
new Float:Angles[3]
PrecacheModel(
"models/w_models/weapons/w_
smg_mp5
.mdl");
GetEntPropVector(target, Prop_Send, "m_angRotation", Angles)
PrecacheModel(
"models/w_models/weapons/w_rifle_sg552.mdl");
RemoveEdict(target)
PrecacheModel(
"models/w_models/weapons/w_
sniper_awp
.mdl");
new index = CreateEntityByName("weapon_spawn")
PrecacheModel(
"models/w_models/weapons/w_
sniper_scout
.mdl");
switch(WeaponSpawn_IDMod[source])
PrecacheModel(
"models/
v
_models/
v_rif_sg552
.mdl");
{
PrecacheModel(
"models/
v
_models/
v_smg_mp5
.mdl");
case SNIPER_SCOUT: SetEntityModel(index, "models/w_models/weapons/w_sniper_scout.mdl");
PrecacheModel(
"models/
v
_models/
v
_snip
_awp
.mdl");
case SNIPER_AWP: SetEntityModel(index,
"models/w_models/weapons/w_
sniper_awp
.mdl");
PrecacheModel(
"models/
v
_models/
v_snip_scout
.mdl");
case RIFLE_SG552: SetEntityModel(index,
"models/w_models/weapons/w_rifle_sg552.mdl");
}
case SMG_MP5: SetEntityModel(index,
"models/w_models/weapons/w_
smg_mp5.mdl");
case PISTOL_MAGNUM: SetEntityModel(index, "models/w_models/weapons/w_desert_eagle.mdl");
stock lateLoadSDKHook() {
case RIFLE_AK47: SetEntityModel(index, "models/w_models/weapons/w_rifle_ak47
.mdl");
for (new i = 1; i <= MaxClients; i++) {
case VOMITJAR: SetEntityModel(index,
"models/w_models/weapons/w_
eq_bile_flask.mld");
if (IsClientInGame(i)) {
case PIPE_BOMB: SetEntityModel(index, "models/w_models/weapons/w_eq_pipebomb
.mdl");
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
case MOLOTOV: SetEntityModel(index,
"models/
w
_models/
weapons/w_eq_molotov
.mdl");
}
case SHOTGUN_SPAS: SetEntityModel(index,
"models/
w
_models/
weapons/w_shotgun_spas
.mdl");
case SNIPER_MILITARY: SetEntityModel(index,
"models/
w
_models/
weapons/w
_snip
er_military
.mdl");
case RIFLE_DESERT: SetEntityModel(index,
"models/
w
_models/
weapons/w_desert_rifle.mdl");
case SHOTGUN_CHROME: SetEntityModel(index, "models/w_models/weapons/w_pumpshotgun_a
.mdl");
case SMG_SILENCED: SetEntityModel(index, "models/w_models/weapons/w_smg_a.mdl");
case HUNTING_RIFLE: SetEntityModel(index, "models/w_models/weapons/w_sniper_mini14.mdl");
case RIFLE: SetEntityModel(index, "models/w_models/weapons/w_rifle_m16a2.mdl");
case AUTOSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_autoshot_m4super.mdl");
case PUMPSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_shotgun.mdl");
case SMG: SetEntityModel(index, "models/w_models/weapons/w_smg_uzi.mdl");
case PISTOL: SetEntityModel(index, "models/w_models/weapons/w_pistol_a.mdl");
}
}
Copier
Copié
Copier
Copié
SetEntProp(index, Prop_Send, "m_weaponID", WeaponSpawn_IDMod[source])
TeleportEntity(index, Origin, Angles, NULL_VECTOR)
if (
WeaponSpawn_IDMod[source] == VOMITJAR ||
WeaponSpawn_IDMod[source] == PIPE_BOMB ||
WeaponSpawn_IDMod[source] == MOLOTOV)
DispatchKeyValue(index, "count", "1")
else DispatchKeyValue(index, "count", "4")
DispatchSpawn(index)
}
}
Différences enregistrées
Texte d'origine
Ouvrir un fichier
#include <sourcemod> #include <sdktools> #define PLUGIN_VERSION "0.8.1" #define PISTOL 1 #define SMG 2 #define PUMPSHOTGUN 3 #define AUTOSHOTGUN 4 #define RIFLE 5 #define HUNTING_RIFLE 6 #define SMG_SILENCED 7 #define SHOTGUN_CHROME 8 #define RIFLE_DESERT 9 #define SNIPER_MILITARY 10 #define SHOTGUN_SPAS 11 #define MOLOTOV 13 #define PIPE_BOMB 14 #define VOMITJAR 25 #define RIFLE_AK47 26 #define PISTOL_MAGNUM 32 #define SMG_MP5 33 #define RIFLE_SG552 34 #define SNIPER_AWP 35 #define SNIPER_SCOUT 36 //Cvar handles. new Handle:h_Enabled new Handle:h_AWPEnabled new Handle:h_MP5Enabled new Handle:h_ScoutEnabled new Handle:h_SG552Enabled new Handle:h_ScoutBoost new Handle:h_AWPBoost //new Handle:h_BatterUp //Used to store weapon spawns. new WeaponSpawn_ID[64] new WeaponSpawn_IDMod[64] new Float:WeaponSpawn_X[64] new Float:WeaponSpawn_Y[64] new Float:WeaponSpawn_Z[64] new String:Map[64] new String:GameMode[16] //Used to keep spawns the same for both teams on competitive modes. new bool:g_bNewMap new bool:g_bScavengeHalftime public Plugin:myinfo = { name = "[L4D2] Weapon Unlock", author = "Crimson_Fox", description = "Unlocks the hidden CSS weapons.", version = PLUGIN_VERSION, url = "http://forums.alliedmods.net/showthread.php?p=1041458" } public OnPluginStart() { //Look up what game we're running, decl String:game[16] GetGameFolderName(game, sizeof(game)) //and don't load if it's not L4D2. if (!StrEqual(game, "left4dead2", false)) SetFailState("Plugin supports Left 4 Dead 2 only.") //Set up cvars and event hooks. CreateConVar("l4d2_WeaponUnlock", PLUGIN_VERSION, "Weapon Unlock version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD) h_Enabled = CreateConVar("l4d2_wu_enable", "1", "Is Weapon Unlock plug-in enabled?", FCVAR_PLUGIN|FCVAR_DONTRECORD) h_AWPEnabled = CreateConVar("l4d2_wu_awp", "1", "Enable AWP sniper rifle?", FCVAR_PLUGIN) h_MP5Enabled = CreateConVar("l4d2_wu_mp5", "1", "Enable MP5 submachine gun?", FCVAR_PLUGIN) h_ScoutEnabled = CreateConVar("l4d2_wu_scout", "1", "Enable Scout sniper rifle?", FCVAR_PLUGIN) h_SG552Enabled = CreateConVar("l4d2_wu_sg552", "1", "Enable SG552 assault rifle?", FCVAR_PLUGIN) h_AWPBoost = CreateConVar("l4d2_wu_awpboost", "135", "Amount of damage added to AWP sniper rifle.", FCVAR_PLUGIN) h_ScoutBoost = CreateConVar("l4d2_wu_scoutboost", "110", "Amount of damage added to scout sniper rifle.", FCVAR_PLUGIN) // h_BatterUp = CreateConVar("l4d2_wu_bat", "0", "Spawn baseball bats for survivors?", FCVAR_PLUGIN) AutoExecConfig(true, "l4d2_WeaponUnlock") HookEvent("round_start", Event_RoundStart) HookEvent("scavenge_round_halftime", Event_ScavengeRoundHalftime) HookEvent("player_hurt", Event_PlayerHurt) HookConVarChange(h_Enabled, ConVarChange_Enabled) //Precache hidden weapon models and initialize them after one second. PrecacheWeaponModels() CreateTimer(1.0, InitHiddenWeaponsDelay) } PrecacheWeaponModels() { //Precache weapon models if they're not loaded. if (!IsModelPrecached("models/w_models/weapons/w_rifle_sg552.mdl")) PrecacheModel("models/w_models/weapons/w_rifle_sg552.mdl") if (!IsModelPrecached("models/w_models/weapons/w_smg_mp5.mdl")) PrecacheModel("models/w_models/weapons/w_smg_mp5.mdl") if (!IsModelPrecached("models/w_models/weapons/w_sniper_awp.mdl")) PrecacheModel("models/w_models/weapons/w_sniper_awp.mdl") if (!IsModelPrecached("models/w_models/weapons/w_sniper_scout.mdl")) PrecacheModel("models/w_models/weapons/w_sniper_scout.mdl") if (!IsModelPrecached("models/w_models/weapons/w_eq_bile_flask.mld")) PrecacheModel("models/w_models/weapons/w_eq_bile_flask.mld") if (!IsModelPrecached("models/v_models/v_rif_sg552.mdl")) PrecacheModel("models/v_models/v_rif_sg552.mdl") if (!IsModelPrecached("models/v_models/v_smg_mp5.mdl")) PrecacheModel("models/v_models/v_smg_mp5.mdl") if (!IsModelPrecached("models/v_models/v_snip_awp.mdl")) PrecacheModel("models/v_models/v_snip_awp.mdl") if (!IsModelPrecached("models/v_models/v_snip_scout.mdl")) PrecacheModel("models/v_models/v_snip_scout.mdl") } public Action:InitHiddenWeaponsDelay(Handle:timer, any:client) { //Spawn and delete the hidden weapons, new index = CreateEntityByName("weapon_rifle_sg552") DispatchSpawn(index) RemoveEdict(index) index = CreateEntityByName("weapon_smg_mp5") DispatchSpawn(index) RemoveEdict(index) index = CreateEntityByName("weapon_sniper_awp") DispatchSpawn(index) RemoveEdict(index) index = CreateEntityByName("weapon_sniper_scout") DispatchSpawn(index) RemoveEdict(index) GetCurrentMap(Map, sizeof(Map)) ForceChangeLevel(Map, "Hidden weapon initialization.") } public ConVarChange_Enabled(Handle:convar, const String:oldValue[], const String:newValue[]) { if ((StringToInt(oldValue) == 1) && (StringToInt(newValue) == 0)) RestoreWeaponSpawns() if ((StringToInt(oldValue) == 0) && (StringToInt(newValue) == 1)) CreateTimer(0.1, RoundStartDelay) } public OnMapStart() { g_bNewMap = true g_bScavengeHalftime = false for (new i = 0; i < sizeof(WeaponSpawn_ID); i++) WeaponSpawn_ID[i] = -1 } public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) { if (GetConVarInt(h_Enabled) == 0) return //Spawn baseball bats if the option is enabled. // if (GetConVarInt(h_BatterUp) != 0) CreateTimer(15.0, SpawnBatsDelay) //Need a delay here to let OnMapStart() run. CreateTimer(1.0, RoundStartDelay) } public Action:RoundStartDelay(Handle:timer) { //Look up the map and type of game we're running. GetConVarString(FindConVar("mp_gamemode"), GameMode, sizeof(GameMode)) if (StrEqual(GameMode, "survival")) return if (StrEqual(GameMode, "scavenge")) { if (g_bScavengeHalftime == true) g_bScavengeHalftime = false else GetWeaponSpawns() SetWeaponSpawns() return } if (StrEqual(GameMode, "versus")) { if (g_bNewMap == true) { GetWeaponSpawns() g_bNewMap = false } SetWeaponSpawns() return } GetCurrentMap(Map, sizeof(Map)) //If we're in a coop mode and running c4m1-4, don't modify spawns as it causes crashes on transitions. if ( (StrEqual(GameMode, "coop") || StrEqual(GameMode, "realism")) && (StrEqual(Map, "c4m1_milltown_a") || StrEqual(Map, "c4m2_sugarmill_a") || StrEqual(Map, "c4m3_sugarmill_b") || StrEqual(Map, "c4m4_milltown_b"))) return GetWeaponSpawns() SetWeaponSpawns() } public Action:Event_ScavengeRoundHalftime(Handle:event, const String:name[], bool:dontBroadcast) { g_bScavengeHalftime = true } /* //Spawn bats at the survivors' position. public Action:SpawnBatsDelay(Handle:timer) { for (new i = 1; i <= MaxClients; i++) { if ((IsClientInGame(i)) && (GetClientTeam(i)==2)) { new Float:Origin[3] new index = CreateEntityByName("weapon_melee") GetClientAbsOrigin(i, Origin) TeleportEntity(index, Origin, NULL_VECTOR, NULL_VECTOR) DispatchKeyValue(index, "melee_script_name", "baseball_bat") DispatchSpawn(index) } } } */ public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) { new target = GetClientOfUserId(GetEventInt(event, "userid")) if (target == 0) return //If the player that was hurt was not infected, go back. if (GetClientTeam(target) != 3) return decl String:weapon[16] GetEventString(event, "weapon", weapon, sizeof(weapon)) if (StrEqual(weapon, "sniper_awp")) { new health = GetClientHealth(target) new damage = GetConVarInt(h_AWPBoost) if (health-damage < 0) SetEntityHealth(target, 0) else SetEntityHealth(target, health-damage) } if (StrEqual(weapon, "sniper_scout")) { new health = GetClientHealth(target) new damage = GetConVarInt(h_ScoutBoost) if (health-damage < 0) SetEntityHealth(target, 0) else SetEntityHealth(target, health-damage) } } GetWeaponSpawns() { //Search for dynamic weapon spawns, decl String:EdictClassName[32] new count = 0 for (new i = 0; i <= GetEntityCount(); i++) { if (IsValidEntity(i)) { GetEdictClassname(i, EdictClassName, sizeof(EdictClassName)) if (StrEqual(EdictClassName, "weapon_spawn")) { //and record their position. new Float:Location[3] GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location) WeaponSpawn_ID[count] = GetEntProp(i, Prop_Send, "m_weaponID") WeaponSpawn_X[count] = Location[0] WeaponSpawn_Y[count] = Location[1] WeaponSpawn_Z[count] = Location[2] count++ } } } //If dynamic spawns were found, and we're not running scavenge, modify the stored spawns like this: if (count != 0 && !StrEqual(GameMode, "scavenge")) { for (new i = 0; i < sizeof(WeaponSpawn_ID); i++) { if (WeaponSpawn_ID[i] == -1) break WeaponSpawn_IDMod[i] = WeaponSpawn_ID[i] switch(WeaponSpawn_ID[i]) { case RIFLE_AK47: if ((GetConVarInt(h_SG552Enabled) == 1) && (GetRandomInt(1, 4) == 1)) WeaponSpawn_IDMod[i] = RIFLE_SG552; case SNIPER_MILITARY: if ((GetConVarInt(h_AWPEnabled) == 1) && (GetRandomInt(1, 2) == 1)) WeaponSpawn_IDMod[i] = SNIPER_AWP; case RIFLE_DESERT: if ((GetConVarInt(h_SG552Enabled) == 1) && (GetRandomInt(1, 4) == 1)) WeaponSpawn_IDMod[i] = RIFLE_SG552; case SMG_SILENCED: if ((GetConVarInt(h_MP5Enabled) == 1) && (GetRandomInt(1, 3) == 1)) WeaponSpawn_IDMod[i] = SMG_MP5; case HUNTING_RIFLE: if ((GetConVarInt(h_ScoutEnabled) == 1) && (GetRandomInt(1, 2) == 1)) WeaponSpawn_IDMod[i] = SNIPER_SCOUT; case RIFLE: if ((GetConVarInt(h_SG552Enabled) == 1) && (GetRandomInt(1, 4) == 1)) WeaponSpawn_IDMod[i] = RIFLE_SG552; case SMG: if ((GetConVarInt(h_MP5Enabled) == 1) && (GetRandomInt(1, 3) == 1)) WeaponSpawn_IDMod[i] = SMG_MP5; } } } //Otherwise, search for static spawns, else { for (new i = 0; i <= GetEntityCount(); i++) { if (IsValidEntity(i)) { GetEdictClassname(i, EdictClassName, sizeof(EdictClassName)) if ( StrEqual(EdictClassName, "weapon_autoshotgun_spawn") || StrEqual(EdictClassName, "weapon_hunting_rifle_spawn") || StrEqual(EdictClassName, "weapon_molotov_spawn") || StrEqual(EdictClassName, "weapon_pipe_bomb_spawn") || StrEqual(EdictClassName, "weapon_pistol_magnum_spawn") || StrEqual(EdictClassName, "weapon_pistol_spawn") || StrEqual(EdictClassName, "weapon_pumpshotgun_spawn") || StrEqual(EdictClassName, "weapon_rifle_ak47_spawn") || StrEqual(EdictClassName, "weapon_rifle_desert_spawn") || StrEqual(EdictClassName, "weapon_rifle_spawn") || StrEqual(EdictClassName, "weapon_shotgun_chrome_spawn") || StrEqual(EdictClassName, "weapon_shotgun_spas_spawn") || StrEqual(EdictClassName, "weapon_smg_spawn") || StrEqual(EdictClassName, "weapon_smg_silenced_spawn") || StrEqual(EdictClassName, "weapon_sniper_military_spawn") || StrEqual(EdictClassName, "weapon_vomitjar_spawn")) { //record their position, new Float:Location[3] GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location) WeaponSpawn_ID[count] = GetEntProp(i, Prop_Send, "m_weaponID") WeaponSpawn_X[count] = Location[0] WeaponSpawn_Y[count] = Location[1] WeaponSpawn_Z[count] = Location[2] count++ } } } //and modify them like this: for (new i = 0; i < sizeof(WeaponSpawn_ID); i++) { if (WeaponSpawn_ID[i] == -1) break WeaponSpawn_IDMod[i] = WeaponSpawn_ID[i] switch(WeaponSpawn_ID[i]) { case PISTOL_MAGNUM: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PISTOL; case RIFLE_AK47: if (GetConVarInt(h_SG552Enabled) == 1) { switch(GetRandomInt(1, 4)) { case 3: WeaponSpawn_IDMod[i] = RIFLE; case 2: WeaponSpawn_IDMod[i] = RIFLE_DESERT; case 1: WeaponSpawn_IDMod[i] = RIFLE_SG552; } } else { switch(GetRandomInt(1, 3) == 1) { case 2: WeaponSpawn_IDMod[i] = RIFLE; case 1: WeaponSpawn_IDMod[i] = RIFLE_DESERT; } } case VOMITJAR: switch(GetRandomInt(1, 3)) { case 2: WeaponSpawn_IDMod[i] = PIPE_BOMB; case 1: WeaponSpawn_IDMod[i] = MOLOTOV; } case PIPE_BOMB: switch(GetRandomInt(1, 3)) { case 2: WeaponSpawn_IDMod[i] = MOLOTOV; case 1: WeaponSpawn_IDMod[i] = VOMITJAR; } case MOLOTOV: switch(GetRandomInt(1, 3)) { case 2: WeaponSpawn_IDMod[i] = VOMITJAR; case 1: WeaponSpawn_IDMod[i] = PIPE_BOMB; } case SHOTGUN_SPAS: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = AUTOSHOTGUN; case SNIPER_MILITARY: if ((GetConVarInt(h_AWPEnabled) == 1) && (GetRandomInt(1, 2) == 1)) WeaponSpawn_IDMod[i] = SNIPER_AWP; case RIFLE_DESERT: if (GetConVarInt(h_SG552Enabled) == 1) { switch(GetRandomInt(1, 4)) { case 3: WeaponSpawn_IDMod[i] = RIFLE; case 2: WeaponSpawn_IDMod[i] = RIFLE_AK47; case 1: WeaponSpawn_IDMod[i] = RIFLE_SG552; } } else { switch(GetRandomInt(1, 3) == 1) { case 2: WeaponSpawn_IDMod[i] = RIFLE; case 1: WeaponSpawn_IDMod[i] = RIFLE_AK47; } } case SHOTGUN_CHROME: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PUMPSHOTGUN; case SMG_SILENCED: if (GetConVarInt(h_MP5Enabled) == 1) { switch(GetRandomInt(1, 3)) { case 2: WeaponSpawn_IDMod[i] = SMG; case 1: WeaponSpawn_IDMod[i] = SMG_MP5; } } else if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SMG; //Since the hunting rifle is a T1 weapon in L4D2, we'll upgrade it to a T2 sniper rifle for L4D1 maps. case HUNTING_RIFLE: if (GetConVarInt(h_AWPEnabled) == 1) { switch(GetRandomInt(1, 2)) { case 2: WeaponSpawn_IDMod[i] = SNIPER_MILITARY; case 1: WeaponSpawn_IDMod[i] = SNIPER_AWP; } } else WeaponSpawn_IDMod[i] = SNIPER_MILITARY; case RIFLE: if (GetConVarInt(h_SG552Enabled) == 1) { switch(GetRandomInt(1, 4)) { case 3: WeaponSpawn_IDMod[i] = RIFLE_AK47; case 2: WeaponSpawn_IDMod[i] = RIFLE_DESERT; case 1: WeaponSpawn_IDMod[i] = RIFLE_SG552; } } else { switch(GetRandomInt(1, 3) == 1) { case 2: WeaponSpawn_IDMod[i] = RIFLE_AK47; case 1: WeaponSpawn_IDMod[i] = RIFLE_DESERT; } } case AUTOSHOTGUN: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SHOTGUN_SPAS; case PUMPSHOTGUN: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SHOTGUN_CHROME; case SMG: if (GetConVarInt(h_MP5Enabled) == 1) { switch(GetRandomInt(1, 3)) { case 2: WeaponSpawn_IDMod[i] = SMG_SILENCED; case 1: WeaponSpawn_IDMod[i] = SMG_MP5; } } else if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SMG_SILENCED; case PISTOL: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PISTOL_MAGNUM; } } } } SetWeaponSpawns() { PrecacheWeaponModels() decl String:EdictClassName[32] for (new i = 0; i <= GetEntityCount(); i++) { if (IsValidEntity(i)) { GetEdictClassname(i, EdictClassName, sizeof(EdictClassName)) if ( StrEqual(EdictClassName, "weapon_spawn") || StrEqual(EdictClassName, "weapon_autoshotgun_spawn") || StrEqual(EdictClassName, "weapon_hunting_rifle_spawn") || StrEqual(EdictClassName, "weapon_molotov_spawn") || StrEqual(EdictClassName, "weapon_pipe_bomb_spawn") || StrEqual(EdictClassName, "weapon_pistol_magnum_spawn") || StrEqual(EdictClassName, "weapon_pistol_spawn") || StrEqual(EdictClassName, "weapon_pumpshotgun_spawn") || StrEqual(EdictClassName, "weapon_rifle_ak47_spawn") || StrEqual(EdictClassName, "weapon_rifle_desert_spawn") || StrEqual(EdictClassName, "weapon_rifle_spawn") || StrEqual(EdictClassName, "weapon_shotgun_chrome_spawn") || StrEqual(EdictClassName, "weapon_shotgun_spas_spawn") || StrEqual(EdictClassName, "weapon_smg_spawn") || StrEqual(EdictClassName, "weapon_smg_silenced_spawn") || StrEqual(EdictClassName, "weapon_sniper_military_spawn") || StrEqual(EdictClassName, "weapon_vomitjar_spawn")) { new Float:Location[3] GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location) new weaponID = GetEntProp(i, Prop_Send, "m_weaponID") for (new x = 0; x < sizeof(WeaponSpawn_IDMod); x++) { if (WeaponSpawn_ID[x] == -1) break if ( ((FloatAbs(WeaponSpawn_X[x] - Location[0]) < 2) && (FloatAbs(WeaponSpawn_Y[x] - Location[1]) < 2) && (FloatAbs(WeaponSpawn_Z[x] - Location[2]) < 2)) && (weaponID != WeaponSpawn_IDMod[x])) { ReplaceWeaponSpawn(i, x) break } } } } } } RestoreWeaponSpawns() { decl String:EdictClassName[32] for (new i = 0; i <= GetEntityCount(); i++) { if (IsValidEntity(i)) { GetEdictClassname(i, EdictClassName, sizeof(EdictClassName)) if (StrEqual(EdictClassName, "weapon_spawn")) { new Float:Location[3] GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location) new weaponID = GetEntProp(i, Prop_Send, "m_weaponID") for (new x = 0; x < sizeof(WeaponSpawn_ID); x++) { if (WeaponSpawn_ID[x] == -1) break if ( ((FloatAbs(WeaponSpawn_X[x] - Location[0]) < 2) && (FloatAbs(WeaponSpawn_Y[x] - Location[1]) < 2) && (FloatAbs(WeaponSpawn_Z[x] - Location[2]) < 2)) && (weaponID != WeaponSpawn_ID[x])) { new Float:Angles[3] GetEntPropVector(i, Prop_Send, "m_angRotation", Angles) RemoveEdict(i) new index = CreateEntityByName("weapon_spawn") switch(WeaponSpawn_ID[x]) { case PISTOL_MAGNUM: SetEntityModel(index, "models/w_models/weapons/w_desert_eagle.mdl"); case RIFLE_AK47: SetEntityModel(index, "models/w_models/weapons/w_rifle_ak47.mdl"); case VOMITJAR: SetEntityModel(index, "models/w_models/weapons/w_eq_bile_flask.mld"); case PIPE_BOMB: SetEntityModel(index, "models/w_models/weapons/w_eq_pipebomb.mdl"); case MOLOTOV: SetEntityModel(index, "models/w_models/weapons/w_eq_molotov.mdl"); case SHOTGUN_SPAS: SetEntityModel(index, "models/w_models/weapons/w_shotgun_spas.mdl"); case SNIPER_MILITARY: SetEntityModel(index, "models/w_models/weapons/w_sniper_military.mdl"); case RIFLE_DESERT: SetEntityModel(index, "models/w_models/weapons/w_desert_rifle.mdl"); case SHOTGUN_CHROME: SetEntityModel(index, "models/w_models/weapons/w_pumpshotgun_a.mdl"); case SMG_SILENCED: SetEntityModel(index, "models/w_models/weapons/w_smg_a.mdl"); case HUNTING_RIFLE: SetEntityModel(index, "models/w_models/weapons/w_sniper_mini14.mdl"); case RIFLE: SetEntityModel(index, "models/w_models/weapons/w_rifle_m16a2.mdl"); case AUTOSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_autoshot_m4super.mdl"); case PUMPSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_shotgun.mdl"); case SMG: SetEntityModel(index, "models/w_models/weapons/w_smg_uzi.mdl"); case PISTOL: SetEntityModel(index, "models/w_models/weapons/w_pistol_a.mdl"); } SetEntProp(index, Prop_Send, "m_weaponID", WeaponSpawn_ID[x]) TeleportEntity(index, Location, Angles, NULL_VECTOR) if ( WeaponSpawn_ID[x] == VOMITJAR || WeaponSpawn_ID[x] == PIPE_BOMB || WeaponSpawn_ID[x] == MOLOTOV) DispatchKeyValue(index, "count", "1") else DispatchKeyValue(index, "count", "4") DispatchSpawn(index) } } } } } } ReplaceWeaponSpawn(target, source) { new Float:Origin[3] Origin[0] = WeaponSpawn_X[source] Origin[1] = WeaponSpawn_Y[source] Origin[2] = WeaponSpawn_Z[source] new Float:Angles[3] GetEntPropVector(target, Prop_Send, "m_angRotation", Angles) RemoveEdict(target) new index = CreateEntityByName("weapon_spawn") switch(WeaponSpawn_IDMod[source]) { case SNIPER_SCOUT: SetEntityModel(index, "models/w_models/weapons/w_sniper_scout.mdl"); case SNIPER_AWP: SetEntityModel(index, "models/w_models/weapons/w_sniper_awp.mdl"); case RIFLE_SG552: SetEntityModel(index, "models/w_models/weapons/w_rifle_sg552.mdl"); case SMG_MP5: SetEntityModel(index, "models/w_models/weapons/w_smg_mp5.mdl"); case PISTOL_MAGNUM: SetEntityModel(index, "models/w_models/weapons/w_desert_eagle.mdl"); case RIFLE_AK47: SetEntityModel(index, "models/w_models/weapons/w_rifle_ak47.mdl"); case VOMITJAR: SetEntityModel(index, "models/w_models/weapons/w_eq_bile_flask.mld"); case PIPE_BOMB: SetEntityModel(index, "models/w_models/weapons/w_eq_pipebomb.mdl"); case MOLOTOV: SetEntityModel(index, "models/w_models/weapons/w_eq_molotov.mdl"); case SHOTGUN_SPAS: SetEntityModel(index, "models/w_models/weapons/w_shotgun_spas.mdl"); case SNIPER_MILITARY: SetEntityModel(index, "models/w_models/weapons/w_sniper_military.mdl"); case RIFLE_DESERT: SetEntityModel(index, "models/w_models/weapons/w_desert_rifle.mdl"); case SHOTGUN_CHROME: SetEntityModel(index, "models/w_models/weapons/w_pumpshotgun_a.mdl"); case SMG_SILENCED: SetEntityModel(index, "models/w_models/weapons/w_smg_a.mdl"); case HUNTING_RIFLE: SetEntityModel(index, "models/w_models/weapons/w_sniper_mini14.mdl"); case RIFLE: SetEntityModel(index, "models/w_models/weapons/w_rifle_m16a2.mdl"); case AUTOSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_autoshot_m4super.mdl"); case PUMPSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_shotgun.mdl"); case SMG: SetEntityModel(index, "models/w_models/weapons/w_smg_uzi.mdl"); case PISTOL: SetEntityModel(index, "models/w_models/weapons/w_pistol_a.mdl"); } SetEntProp(index, Prop_Send, "m_weaponID", WeaponSpawn_IDMod[source]) TeleportEntity(index, Origin, Angles, NULL_VECTOR) if ( WeaponSpawn_IDMod[source] == VOMITJAR || WeaponSpawn_IDMod[source] == PIPE_BOMB || WeaponSpawn_IDMod[source] == MOLOTOV) DispatchKeyValue(index, "count", "1") else DispatchKeyValue(index, "count", "4") DispatchSpawn(index) }
Texte modifié
Ouvrir un fichier
#include <sourcemod> #include <sdktools> #include <sdkhooks> #define STRING_SIZE 1024 #define FLAG_WEAPON_SPAWN true #define AWP_LIMIT 1 #define SCOUT_LIMIT 3 #define WEAPONID_MP5 33 #define WEAPONID_SG552 34 #define WEAPONID_AWP 35 #define WEAPONID_SCOUT 36 #define WEAPONID_SMG 2 #define WEAPONID_HUNTING 6 #define WEAPONID_DESERT 9 #define WEAPONID_MILITARY 10 public OnPluginStart() { HookEvent("round_start", eventRoundStart); lateLoadSDKHook(); } public OnMapStart() { precacheModels(); } public OnClientPostAdminCheck(client) { SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); } public Action:eventRoundStart(Handle:event, const String:name[], bool:dontBroadcast) { if (isMapAllowed()) { CreateTimer(1.0, roundStartDelay, TIMER_FLAG_NO_MAPCHANGE); } } stock isMapAllowed() { new String:currentMap[STRING_SIZE]; GetCurrentMap(currentMap, sizeof(currentMap)); if (StrEqual(currentMap, "c4m1_milltown_a", false) || StrEqual(currentMap, "c4m2_sugarmill_a", false) || StrEqual(currentMap, "c4m3_sugarmill_b", false) || StrEqual(currentMap, "c4m4_milltown_b", false)) { return false; } return true; } public Action:roundStartDelay(Handle:timer) { precacheModels(); proccessReplace(); } stock proccessReplace() { new spawnedAwp, spawnedScout; for (new i = GetMaxClients(); i < GetMaxEntities(); i++) { if (IsValidEdict(i) && IsValidEntity(i)) { new String:classname[STRING_SIZE]; GetEdictClassname(i, classname, sizeof(classname)); new weaponSpawnId; if (StrEqual(classname, "weapon_spawn")) { weaponSpawnId = GetEntProp(i, Prop_Send, "m_weaponID"); } if (StrEqual(classname, "weapon_sniper_military") || StrEqual(classname, "weapon_sniper_military_spawn") || weaponSpawnId == WEAPONID_MILITARY) { if (spawnedAwp < AWP_LIMIT && isRandomAllowing(50)) { new weapon = replace(i, "weapon_sniper_awp"); if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 180, 4); spawnedAwp++; } } else if (StrEqual(classname, "weapon_hunting_rifle") || StrEqual(classname, "weapon_hunting_rifle_spawn") || weaponSpawnId == WEAPONID_HUNTING) { if (spawnedScout < SCOUT_LIMIT && isRandomAllowing(50)) { new weapon = replace(i, "weapon_sniper_scout"); if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 180, 4); spawnedScout++; } } else if (StrEqual(classname, "weapon_rifle_desert")) { new weapon = replace(i, "weapon_rifle_sg552"); if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 360, 4); } else if (StrEqual(classname, "weapon_rifle_desert_spawn") || weaponSpawnId == WEAPONID_DESERT) { replace(i, "weapon_rifle_sg552", FLAG_WEAPON_SPAWN); } else if (StrEqual(classname, "weapon_smg")) { new weapon = replace(i, "weapon_smg_mp5"); if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 650, 4); } else if (StrEqual(classname, "weapon_smg_spawn") || weaponSpawnId == WEAPONID_SMG) { replace(i, "weapon_smg_mp5", FLAG_WEAPON_SPAWN); } } } } stock replace(oldWeapon, const String:newWeaponName[], bool:isSpawn = false) { new Float:origin[3], Float:angles[3]; GetEntPropVector(oldWeapon, Prop_Send, "m_vecOrigin", origin); GetEntPropVector(oldWeapon, Prop_Send, "m_angRotation", angles); RemoveEdict(oldWeapon); new newItemEntity; if (isSpawn) { newItemEntity = CreateEntityByName("weapon_spawn"); if (StrEqual(newWeaponName, "weapon_rifle_sg552")) { SetEntityModel(newItemEntity, "models/w_models/weapons/w_rifle_sg552.mdl"); SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_SG552); } else if (StrEqual(newWeaponName, "weapon_smg_mp5")) { if (IsModelPrecached("models/w_models/weapons/w_smg_mp5.mdl")) { SetEntityModel(newItemEntity, "models/w_models/weapons/w_smg_mp5.mdl"); SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_MP5); } else { SetEntityModel(newItemEntity, "models/w_models/weapons/w_smg_uzi.mdl"); SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_SMG); } } else { return 0; } } else { newItemEntity = CreateEntityByName(newWeaponName); } if (IsValidEdict(newItemEntity)) { TeleportEntity(newItemEntity, origin, angles, NULL_VECTOR); if (isSpawn) DispatchKeyValue(newItemEntity, "count", "4"); DispatchSpawn(newItemEntity); } return newItemEntity; } public OnEntityCreated(entity, const String:classname[]) { if (StrEqual(classname, "infected") || StrEqual(classname, "witch")) { SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage); } } public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype) { if (inflictor && attacker && victim && IsValidEdict(victim) && IsValidEdict(inflictor)) { if (IsClientInGame(victim) && GetClientTeam(victim) == 2) { return Plugin_Continue; } new String:classname[STRING_SIZE]; new weapon = GetEntPropEnt(attacker, Prop_Data, "m_hActiveWeapon"); GetEdictClassname(weapon, classname, sizeof(classname)); if (StrEqual(classname, "weapon_sniper_awp")) { damage = 600.0; return Plugin_Changed; } if (StrEqual(classname, "weapon_sniper_scout")) { damage = 350.0; return Plugin_Changed; } if (StrEqual(classname, "weapon_rifle_sg552")) { damage = 50.0; return Plugin_Changed; } if (StrEqual(classname, "weapon_smg_mp5")) { damage = 25.0; return Plugin_Changed; } } return Plugin_Continue; } stock isRandomAllowing(chance) { if (GetRandomInt(1, 100) <= chance) return true; return false; } stock precacheModels() { PrecacheModel("models/w_models/weapons/w_smg_mp5.mdl"); PrecacheModel("models/w_models/weapons/w_rifle_sg552.mdl"); PrecacheModel("models/w_models/weapons/w_sniper_awp.mdl"); PrecacheModel("models/w_models/weapons/w_sniper_scout.mdl"); PrecacheModel("models/v_models/v_rif_sg552.mdl"); PrecacheModel("models/v_models/v_smg_mp5.mdl"); PrecacheModel("models/v_models/v_snip_awp.mdl"); PrecacheModel("models/v_models/v_snip_scout.mdl"); } stock lateLoadSDKHook() { for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage); } } }
Trouver la différence