求生之路2致命武器(电磁炮)插件 l4d2_lethal_weapon 插件源码

  • A+
所属分类:lcx

L4D2: Lethal Weapon v2.1 求生之路2致命武器(电磁炮)插件 l4d2_lethal_weapon 插件源码 l4d2_lethal_weapon.sp l4d2_lethal_weapon.smx。求生之路2,l4d,l4d2,SourceMOD 插件源码。

官方地址:http://forums.alliedmods.net/showthread.php?p=1122337

[L4D2] Lethal Weapon (Charge Shot)

First, I'm not good at English. Sorry for poor Sentence.
It's my second plugin. This plugin allows you to shoot LETHAL WEAPON.

Elektramode uploaded introduction movie. Thanks a lot!
http://www.youtube.com/watch?v=eknnFr3mAhQ

* How to shoot *
- 1.Equip sniper rifle (HR, G3, Scout, AWP)
- 2.Crouch and charge until the gauge becomes full. When you move, Gauge is reset.
- 3.Aim and shoot! All bullet in clip and Half of your ammunition is consumed.

* 如何射击 *
- 1.装备狙击步枪 (HR, G3, Scout, AWP)
- 2.蹲下并等待蓄力表充满. 如果你移动, 蓄力表将重置.
- 3.瞄准并射击! 这将消耗你所有弹药的一半.

* effect *
It deals 3000(default value) damage to target and causes Huge explosion and burning.

* 效果 *
将对目标造成3000点伤害(默认值,可以在cfg中修改),并造成了巨大的爆炸声和燃烧。

* warning *
- Heavy particle effect is used, so If you feel discomfort, try to use SIMPLE MODE.(See below)
- It is extremely powerful so there is danger of losing game balance.

* 警告 *
- 重粒子效果,所以如果你感到不适,尽量使用简单的模式(见下文)。
- 这是非常强大的,所以将失去游戏的平衡性。

Cvar:
sm_lw_lethalweapon : 1 (0:OFF 1:ON 2:SIMPLE)
sm_lw_lethaldamage : 3000 (If direct hit)
sm_lw_lethalforce : 800 (Force of blowing off)
sm_lw_chargetime : 7.0 (Charge time)
sm_lw_shootonce : 0 (If 1, You can shoot only once per round)
sm_lw_ff : 0 (Survivor can damage other survivors)
sm_lw_scout : 1 (allow using)
sm_lw_awp : 1 (allow using)
sm_lw_huntingrifle : 1 (allow using)
sm_lw_g3sg1 : 1 (allow using)

设置:
sm_lw_lethalweapon : 1 (0:关闭 1:开启 2:简单)
sm_lw_lethaldamage : 3000 (直接命中的伤害)
sm_lw_lethalforce : 800 (击退力度)
sm_lw_chargetime : 7.0 (充电时间)
sm_lw_shootonce : 0 (如果是1,你每回合只能使用一次)
sm_lw_ff : 0 (幸存者可以损害其他幸存者,就是队友伤害)
sm_lw_scout : 1 (狙击枪scout,允许使用插件)
sm_lw_awp : 1 (狙击枪awp,允许使用插件)
sm_lw_huntingrifle : 1 (狙击枪hunting rifle,允许使用插件)
sm_lw_g3sg1 : 1 (狙击枪g3sg1,允许使用插件)

Change:
1.0 - Initial release
1.1 - Fix some bag and Add Cvar. (Thanks for alexip121093, Acecombat2.)


源码文件:l4d2_lethal_weapon.sp

/*******************************************************
*
* 		L4D2: Lethal Weapon v2.1
*
* 		      Author: ztar
* 		   Edited: M249-M4A1
* http://forums.alliedmods.net/showthread.php?p=1121995
*
********************************************************
* CHANGELOG:
*
* - Added several ConVars to customize effects
*   - Enable/disable sounds
*   - Enable/disable use of extra ammo
*   - Enable/disable some effects (to be discreet)
*   - Enable/disable charging while crouched and moving
*
* - Renamed ConVars and CFG to be more uniform
* - Fixed some grammar and spelling issues
* - Removed text gauge as it was kinda annoying
* - Made it easier to change sounds (#define)
* - Updated some sounds
* - Fixed bug where Survivors would be launched away
*   and killed unless "l4d2_lw_ff" is enabled
* - Fixed bug where if you were limited to 1 lethal
*   charged shot, you fired, then the limit was
*   removed, you wouldn't be able to charge again
* - Added screen shake
*
*******************************************************/
#include 
#include 

#define PLUGIN_VERSION "2.1"
#define CVAR_FLAGS FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY
#define MOLOTOV 0
#define EXPLODE 1

new ChargeLock[65];
new ReleaseLock[65];
new CurrentWeapon;
new ClipSize;
new ChargeEndTime[65];
new Handle:ClientTimer[65];
new g_sprite;
new Float:myPos[3], Float:trsPos[3], Float:trsPos002[3];

/* Sound */
#define CHARGESOUND 	"ambient/spacial_loops/lights_flicker.wav"
#define CHARGEDUPSOUND	"level/startwam.wav"
#define AWPSHOT			"weapons/awp/gunfire/awp1.wav"
#define EXPLOSIONSOUND	"animation/bombing_run_01.wav"

/* Sprite */
#define SPRITE_BEAM		"materials/sprites/laserbeam.vmt"

new Handle:l4d2_lw_lethalweapon		= INVALID_HANDLE;
new Handle:l4d2_lw_lethaldamage		= INVALID_HANDLE;
new Handle:l4d2_lw_lethalforce		= INVALID_HANDLE;
new Handle:l4d2_lw_chargetime		= INVALID_HANDLE;
new Handle:l4d2_lw_shootonce		= INVALID_HANDLE;
new Handle:l4d2_lw_ff				= INVALID_HANDLE;
new Handle:l4d2_lw_scout			= INVALID_HANDLE;
new Handle:l4d2_lw_awp				= INVALID_HANDLE;
new Handle:l4d2_lw_huntingrifle		= INVALID_HANDLE;
new Handle:l4d2_lw_g3sg1			= INVALID_HANDLE;
new Handle:l4d2_lw_flash			= INVALID_HANDLE;
new Handle:l4d2_lw_chargingsound	= INVALID_HANDLE;
new Handle:l4d2_lw_chargedsound		= INVALID_HANDLE;
new Handle:l4d2_lw_moveandcharge	= INVALID_HANDLE;
new Handle:l4d2_lw_chargeparticle	= INVALID_HANDLE;
new Handle:l4d2_lw_useammo			= INVALID_HANDLE;
new Handle:l4d2_lw_shake			= INVALID_HANDLE;
new Handle:l4d2_lw_shake_intensity	= INVALID_HANDLE;
new Handle:l4d2_lw_shake_shooteronly= INVALID_HANDLE;
new Handle:l4d2_lw_laseroffset		= INVALID_HANDLE;

public Plugin:myinfo = 
{
	name = "[L4D2] Lethal Weapon",
	author = "ztar",
	description = "Sniper rifles can be charged up and fired to create a huge explosion",
	version = PLUGIN_VERSION,
	url = "http://forums.alliedmods.net/showthread.php?p=1121995"
}

public OnPluginStart()
{
	// ConVars
	l4d2_lw_lethalweapon	= CreateConVar("l4d2_lw_lethalweapon","1", "Enable Lethal Weapon (0:OFF 1:ON 2:SIMPLE)", CVAR_FLAGS);
	l4d2_lw_lethaldamage	= CreateConVar("l4d2_lw_lethaldamage","3000.0", "Lethal Weapon base damage", CVAR_FLAGS);
	l4d2_lw_lethalforce		= CreateConVar("l4d2_lw_lethalforce","500.0", "Lethal Weapon force", CVAR_FLAGS);
	l4d2_lw_chargetime		= CreateConVar("l4d2_lw_chargetime","7", "Lethal Weapon charge time", CVAR_FLAGS);
	l4d2_lw_shootonce		= CreateConVar("l4d2_lw_shootonce","0", "Survivor can use Lethal Weapon once per round", CVAR_FLAGS);
	l4d2_lw_ff				= CreateConVar("l4d2_lw_ff","0", "Lethal Weapon can deal direct damage to other survivors", CVAR_FLAGS);
	l4d2_lw_scout			= CreateConVar("l4d2_lw_scout","1", "Enable Lethal Weapon for Scout", CVAR_FLAGS);
	l4d2_lw_awp				= CreateConVar("l4d2_lw_awp","1", "Enable Lethal Weapon for AWP", CVAR_FLAGS);
	l4d2_lw_huntingrifle	= CreateConVar("l4d2_lw_huntingrifle","1", "Enable Lethal Weapon for Hunting Rifle", CVAR_FLAGS);
	l4d2_lw_g3sg1			= CreateConVar("l4d2_lw_g3sg1","1", "Enable Lethal Weapon for G3SG1", CVAR_FLAGS);
	l4d2_lw_laseroffset		= CreateConVar("l4d2_lw_laseroffset", "36", "Tracker offeset", FCVAR_NOTIFY);
	
	// Additional ConVars
	l4d2_lw_flash				= CreateConVar("l4d2_lw_flash", "1", "Enable screen flash");
	l4d2_lw_chargingsound		= CreateConVar("l4d2_lw_chargingsound", "1", "Enable charging sound");
	l4d2_lw_chargedsound		= CreateConVar("l4d2_lw_chargedsound", "1", "Enable charged up sound");
	l4d2_lw_moveandcharge		= CreateConVar("l4d2_lw_moveandcharge", "1", "Enable charging while crouched and moving");
	l4d2_lw_chargeparticle		= CreateConVar("l4d2_lw_chargeparticle", "1", "Enable showing electric particles when charged");
	l4d2_lw_useammo				= CreateConVar("l4d2_lw_useammo", "1", "Enable and require use of addtional ammunition");
	l4d2_lw_shake				= CreateConVar("l4d2_lw_shake", "1", "Enable screen shake during explosion");
	l4d2_lw_shake_intensity		= CreateConVar("l4d2_lw_shake_intensity", "50.0", "Intensity of screen shake");
	l4d2_lw_shake_shooteronly	= CreateConVar("l4d2_lw_shake_shooteronly", "0", "Only the shooter experiences screen shake");
	
	// Hooks
	HookEvent("player_spawn", Event_Player_Spawn);
	HookEvent("weapon_fire", Event_Weapon_Fire);
	HookEvent("bullet_impact", Event_Bullet_Impact);
	HookEvent("player_incapacitated", Event_Player_Incap, EventHookMode_Pre);
	HookEvent("player_hurt", Event_Player_Hurt, EventHookMode_Pre);
	HookEvent("player_death", Event_Player_Hurt, EventHookMode_Pre);
	HookEvent("infected_death", Event_Infected_Hurt, EventHookMode_Pre);
	HookEvent("infected_hurt", Event_Infected_Hurt, EventHookMode_Pre);
	HookEvent("round_end", Event_Round_End, EventHookMode_Pre);
	
	// Weapon stuff
	CurrentWeapon	= FindSendPropOffs ("CTerrorPlayer", "m_hActiveWeapon");
	ClipSize	= FindSendPropInfo("CBaseCombatWeapon", "m_iClip1");
	
	InitCharge();
	
	AutoExecConfig(true, "l4d2_lethal_weapon");
}

public OnMapStart()
{
	InitPrecache();
}

public OnConfigsExecuted()
{
	InitPrecache();
}

InitCharge()
{
	/* Initalize charge parameter */
	new i;
	for (i = 1; i  0 && client  50.0)
				GaugeNum = 50.0;
			
			for(i=0; i= 15)
			{
				/* Gauge meter is 30% or more */
				decl Float:pos[3];
				GetClientAbsOrigin(client, pos);
				pos[2] += 45;
				if (GetConVarInt(l4d2_lw_chargeparticle))
				{
					ShowParticle(pos, "electrical_arc_01_cp0", 5.0);
				}
				if (GetConVarInt(l4d2_lw_chargingsound))
				{
					EmitSoundToAll(CHARGESOUND, client);
				}
			}
			/* Display gauge */
			PrintCenterText(client, "           >n0%% %s %3.0f%%", ChargeBar, GaugeNum*2);
		}
	}
	else
	{
		/* Not matching condition */
		StopSound(client, SNDCHAN_AUTO, CHARGESOUND);
		ReleaseLock[client] = 0;
		ChargeEndTime[client] = gt + ct;
	}
	return Plugin_Continue;
}

public ExplodeMain(Float:pos[3])
{
	/* Main effect when hit */
	if (GetConVarInt(l4d2_lw_chargeparticle))
	{
		ShowParticle(pos, "electrical_arc_01_system", 5.0);
	}
	LittleFlower(pos, EXPLODE);
	
	if (GetConVarInt(l4d2_lw_lethalweapon) == 1)
	{
		ShowParticle(pos, "gas_explosion_main", 5.0);
		LittleFlower(pos, MOLOTOV);
	}
}

public ShowParticle(Float:pos[3], String:particlename[], Float:time)
{
	/* Show particle effect you like */
	new particle = CreateEntityByName("info_particle_system");
	if (IsValidEdict(particle))
	{
		TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
		DispatchKeyValue(particle, "effect_name", particlename);
		DispatchKeyValue(particle, "targetname", "particle");
		DispatchSpawn(particle);
		ActivateEntity(particle);
		AcceptEntityInput(particle, "start");
		CreateTimer(time, DeleteParticles, particle);
	}  
}

public PrecacheParticle(String:particlename[])
{
	/* Precache particle */
	new particle = CreateEntityByName("info_particle_system");
	if (IsValidEdict(particle))
	{
		DispatchKeyValue(particle, "effect_name", particlename);
		DispatchKeyValue(particle, "targetname", "particle");
		DispatchSpawn(particle);
		ActivateEntity(particle);
		AcceptEntityInput(particle, "start");
		CreateTimer(0.01, DeleteParticles, particle);
	}  
}

public Action:DeleteParticles(Handle:timer, any:particle)
{
	/* Delete particle */
    if (IsValidEntity(particle))
	{
		new String:classname[64];
		GetEdictClassname(particle, classname, sizeof(classname));
		if (StrEqual(classname, "info_particle_system", false))
            		RemoveEdict(particle);
	}
}

public LittleFlower(Float:pos[3], type)
{
	/* Cause fire(type=0) or explosion(type=1) */
	new entity = CreateEntityByName("prop_physics");
	if (IsValidEntity(entity))
	{
		pos[2] += 10.0;
		if (type == 0)
			/* fire */
			DispatchKeyValue(entity, "model", "models/props_junk/gascan001a.mdl");
		else
			/* explode */
			DispatchKeyValue(entity, "model", "models/props_junk/propanecanister001a.mdl");
		DispatchSpawn(entity);
		SetEntData(entity, GetEntSendPropOffs(entity, "m_CollisionGroup"), 1, 1, true);
		TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR);
		AcceptEntityInput(entity, "break");
	}
}

public Action:GetEntityAbsOrigin(entity,Float:origin[3])
{
	/* Get target posision */
	decl Float:mins[3], Float:maxs[3];
	GetEntPropVector(entity,Prop_Send,"m_vecOrigin",origin);
	GetEntPropVector(entity,Prop_Send,"m_vecMins",mins);
	GetEntPropVector(entity,Prop_Send,"m_vecMaxs",maxs);
	
	origin[0] += (mins[0] + maxs[0]) * 0.5;
	origin[1] += (mins[1] + maxs[1]) * 0.5;
	origin[2] += (mins[2] + maxs[2]) * 0.5;
}

Smash(client, target, Float:power, Float:powHor, Float:powVec)
{
	/* Smash target */
	// Check so that we don't "smash" other Survivors (only if "l4d2_lw_ff" is 0)
	if (GetConVarInt(l4d2_lw_ff) || GetClientTeam(target) != 2)
	{
		decl Float:HeadingVector[3], Float:AimVector[3];
		GetClientEyeAngles(client, HeadingVector);
	
		AimVector[0] = FloatMul(Cosine(DegToRad(HeadingVector[1])) ,power * powHor);
		AimVector[1] = FloatMul(Sine(DegToRad(HeadingVector[1])) ,power * powHor);
	
		decl Float:current[3];
		GetEntPropVector(target, Prop_Data, "m_vecVelocity", current);
	
		decl Float:resulting[3];
		resulting[0] = FloatAdd(current[0], AimVector[0]);	
		resulting[1] = FloatAdd(current[1], AimVector[1]);
		resulting[2] = power * powVec;
	
		TeleportEntity(target, NULL_VECTOR, NULL_VECTOR, resulting);
	}
}

public ScreenFade(target, red, green, blue, alpha, duration, type)
{
	new Handle:msg = StartMessageOne("Fade", target);
	BfWriteShort(msg, 500);
	BfWriteShort(msg, duration);
	if (type == 0)
	{
		BfWriteShort(msg, (0x0002 | 0x0008));
	}
	else
	{
		BfWriteShort(msg, (0x0001 | 0x0010));
	}
	BfWriteByte(msg, red);
	BfWriteByte(msg, green);
	BfWriteByte(msg, blue);
	BfWriteByte(msg, alpha);
	EndMessage();
}

public ScreenShake(target)
{
	new Handle:msg;
	if (GetConVarInt(l4d2_lw_shake_shooteronly))
	{
		msg = StartMessageAll("Shake");
	}
	else
	{
		msg = StartMessageOne("Shake", target);
	}
	BfWriteByte(msg, 0);
 	BfWriteFloat(msg, GetConVarFloat(l4d2_lw_shake_intensity));
 	BfWriteFloat(msg, 10.0);
 	BfWriteFloat(msg, 3.0);
	EndMessage();
}

public GetTracePosition(client)
{
	decl Float:myAng[3];
	GetClientEyePosition(client, myPos);
	GetClientEyeAngles(client, myAng);
	new Handle:trace = TR_TraceRayFilterEx(myPos, myAng, CONTENTS_SOLID|CONTENTS_MOVEABLE, RayType_Infinite, TraceEntityFilterPlayer, client);
	if(TR_DidHit(trace))
		TR_GetEndPosition(trsPos, trace);
	CloseHandle(trace);
	for(new i = 0; i  GetMaxClients() || !entity;
}

public CreateLaserEffect(client, colRed, colGre, colBlu, alpha, Float:width, Float:duration)
{
	decl Float:tmpVec[3];
	SubtractVectors(myPos, trsPos, tmpVec);
	NormalizeVector(tmpVec, tmpVec);
	ScaleVector(tmpVec, GetConVarFloat(l4d2_lw_laseroffset));
	SubtractVectors(myPos, tmpVec, trsPos);
	
	decl color[4];
	color[0] = colRed; 
	color[1] = colGre;
	color[2] = colBlu;
	color[3] = alpha;
	TE_SetupBeamPoints(myPos, trsPos002, g_sprite, 0, 0, 0, duration, width, width, 1, 0.0, color, 0);
	TE_SendToAll();
}

配置文件:l4d2_lethal_weapon.cfg

// This file was auto-generated by SourceMod (v1.3.7-dev)
// ConVars for plugin "l4d2_lethal_weapon.smx"


// 是否启用AWP的致命武器
// -
// Default: "1"
l4d2_lw_awp "1"

// 启用充电的声音
// -
// Default: "1"
l4d2_lw_chargedsound "1"

// 启用充电时的电粒子
// -
// Default: "1"
l4d2_lw_chargeparticle "1"

// 致命武器的充电时间
// -
// Default: "7"
l4d2_lw_chargetime "5"

// 启用充电声
// -
// Default: "1"
l4d2_lw_chargingsound "1"

// 致命武器可以直接损害其他幸存者
// -
// Default: "0"
l4d2_lw_ff "0"

// 启用屏幕闪烁
// -
// Default: "1"
l4d2_lw_flash "1"

// 启用G3SG1致命武器
// -
// Default: "1"
l4d2_lw_g3sg1 "1"

// 启用猎枪的致命武器
// -
// Default: "1"
l4d2_lw_huntingrifle "1"

// 追踪偏移
// -
// Default: "36"
l4d2_lw_laseroffset "36"

// 致命武器的基础伤害
// -
// Default: "3000.0"
l4d2_lw_lethaldamage "5000.0"

// 致命武器力量
// -
// Default: "500.0"
l4d2_lw_lethalforce "1000.0"

// 启用致命武器 (0:OFF 1:ON 2:SIMPLE)
// -
// Default: "1"
l4d2_lw_lethalweapon "1"

// 启用充电直到蹲下并移动
// -
// Default: "1"
l4d2_lw_moveandcharge "1"

// 启用Scout的致命武器
// -
// Default: "1"
l4d2_lw_scout "1"

// 爆炸过程中启用屏幕晃动
// -
// Default: "1"
l4d2_lw_shake "1"

// 屏幕震动强度
// -
// Default: "50.0"
l4d2_lw_shake_intensity "50.0"

// 只有设计者屏幕晃动
// -
// Default: "0"
l4d2_lw_shake_shooteronly "0"

// 幸存者一轮只能使用一次致命武器
// -
// Default: "0"
l4d2_lw_shootonce "0"

// 启用和需要使用额外的弹药
// -
// Default: "1"
l4d2_lw_useammo "1"

文章来源于lcx.cc:求生之路2致命武器(电磁炮)插件 l4d2_lethal_weapon 插件源码

相关推荐: [PCH-009] Security risk of php string offset

[PCH-009]Security risk of php string offset by ryat_at_www.80vul.com 一、前言[关于PCH] "PCH"及"Php Codz Hacking"是80vul在2009年4月推出的一个项目,主要是…

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: