/* Plugin Template generated by Pawn Studio */
// Thanks to Damizean for starting this craze!
#include <sourcemod>
#include <sdktools>
#include <sdktools_functions>
#define CVAR_FLAGS FCVAR_PLUGIN
#define PLUGIN_VERSION "1.0"
#define FL_PISTOL_PRIMARY (1<<6) //Is 1 when you have a primary weapon and dual pistols
#define FL_PISTOL (1<<7) //Is 1 when you have dual pistols
#define TICKS 10
#define ZOMBIECLASS_SMOKER 1
#define ZOMBIECLASS_BOOMER 2
#define ZOMBIECLASS_HUNTER 3
#define ZOMBIECLASS_TANK 5
new Handle:DropTimers[MAXPLAYERS+1];
new Handle:drop_drag;
new Handle:drop_pounce;
new Handle:drop_splash;
new Handle:drop_incap;
new Handle:drop_num;
static Handle:SplashEnabled = INVALID_HANDLE;
static Handle:SplashRadius = INVALID_HANDLE;
static Handle:SplashDamage = INVALID_HANDLE;
new Handle:startscalehandle;
new Handle:increasehandle;
new Handle:increasehandle2;
new Handle:ConVarTimeScale;
new Handle:ConVarTimeScaleMinPlayer;
new Handle:TimeScaleTimers=INVALID_HANDLE;
new Float:timescale=1.0;
new Float:timeadd=0.0;
public Plugin:myinfo =
{
name = "生还者物品掉落",
author = " 小海
description = "生还者物品掉落",
version = PLUGIN_VERSION,
url = "http://forums.alliedmods.net"
}
public OnPluginStart()
{
drop_drag = CreateConVar("l4d_drop_drag", "20", "被拖掉东西概率",FCVAR_PLUGIN);
drop_pounce = CreateConVar("l4d_drop_pounce", "20", "被扑掉东西概率",FCVAR_PLUGIN);
drop_incap = CreateConVar("l4d_drop_incap", "30", "倒地掉东西概率",FCVAR_PLUGIN);
drop_splash = CreateConVar("l4d_drop_splash", "15", "被胖子炸掉东西概率",FCVAR_PLUGIN);
drop_num = CreateConVar("l4d_drop_maxnum", "2", "掉的最大件数",FCVAR_PLUGIN);
SplashEnabled = CreateConVar("l4d_splash_damage_enabled", "0", "是否启动胖子爆炸伤害", CVAR_FLAGS);
SplashDamage = CreateConVar("l4d_splash_damage_damage", "5.0", "爆炸伤害值", CVAR_FLAGS);
SplashRadius = CreateConVar("l4d_splash_damage_radius", "200", "爆炸半径", CVAR_FLAGS);
new h_GameMode = FindConVar("mp_gamemode");
decl String:GameName[16];
GetConVarString(h_GameMode, GameName, sizeof(GameName));
new GameMode;
if (StrEqual(GameName, "survival", false))
GameMode = 3;
else if (StrEqual(GameName, "versus", false) || StrEqual(GameName, "teamversus", false) || StrEqual(GameName, "scavenge", false) || StrEqual(GameName, "teamscavenge", false))
GameMode = 2;
else if (StrEqual(GameName, "coop", false) || StrEqual(GameName, "realism", false))
GameMode = 1;
else
{
GameMode = 0;
}
if(GameMode==2)return;
HookEvent("tongue_grab", EventTongueGrab, EventHookMode_Post);
HookEvent("tongue_release", EventTongueRelease, EventHookMode_Post);
HookEvent("lunge_pounce", EventPlayerPounced, EventHookMode_Post);
HookEvent("player_incapacitated", EventPlayerIncap, EventHookMode_Post);
HookEvent("player_connect_full", PlayerConnectFull);
HookEvent("player_death", PlayerDeath);
//player_incapacitated_start
//startscalehandle = CreateConVar("l4d_timescale_start", "0.0", " ", CVAR_FLAGS);
//increasehandle = CreateConVar("l4d_timescale_increase", "0.15", " ", CVAR_FLAGS);
//increasehandle2 = CreateConVar("l4d_timescale_increase2", "1.0", " ", CVAR_FLAGS);
//ConVarTimeScaleMinPlayer = CreateConVar("l4d_timescale_miniplayer", "2", " ", CVAR_FLAGS);
// ConVarTimeScale=FindConVar("host_timescale");
RegConsoleCmd("sm_drop", Command_Drop);
RegConsoleCmd("sm_g", Command_Drop);
RegConsoleCmd("sm_sea", Command_sea);
AutoExecConfig(true, "l4d_drop_v10");
}
public Action:Command_sea(client, args)
{
PrintToChatAll("生还者物品掉落 小海");
return Plugin_Handled;
}
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (!client || !IsClientInGame(client)) return;
if (GetClientTeam(client)!=3) return;
// PrintToChatAll("death");
Splashdamage(client);
}
public PlayerConnectFull (Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
ClientCommand(client, "bind g \"say /g\"");
}
Splashdamage(client)
{
decl String:class[100];
GetClientModel(client, class, sizeof(class));
if (StrContains(class, "boomer", false) != -1)
{
//PrintToChatAll("Boomerdeath caught, Plugin running");
decl Float:g_pos[3];
GetClientEyePosition(client,g_pos);
new damage=GetConVarInt(SplashDamage);
new String:arg1[10];
Format(arg1, sizeof(arg1), "%i", damage);
new String:arg2[10];
Format(arg2, sizeof(arg2), "%i", damage*3);
new eanbledamage=GetConVarInt(SplashEnabled);
new Float:radius=GetConVarFloat(SplashRadius);
new Float:numplayer=0;
new splashed=0;
for (new target = 1; target <= MaxClients; target++)
{
if (IsClientInGame(target))
{
if (IsPlayerAlive(target))
{
if (GetClientTeam(target) ==2)
{
decl Float:targetVector[3];
GetClientEyePosition(target, targetVector);
new Float:distance = GetVectorDistance(targetVector, g_pos);
//PrintToChatAll("%f %f",distance, radius);
if (distance < radius)
{
//PrintToChatAll("splash");
splashed++;
numplayer=numplayer+1.0;
if (GetRandomInt(0, 100) < GetConVarInt(drop_splash))
{
DropItem(target);
}
DamageEffect(target);
if(eanbledamage && damage>0)
{
PrintHintText(target, "Boomer爆炸伤害!");
if (IsPlayerIncapped(target))
{
CheatCommand(target, "hurtme", arg1, "");
}
else
{
CheatCommand(target, "hurtme", arg2, "");
}
}
}
}
}
}
}
// if(splashed>=GetConVarInt(ConVarTimeScaleMinPlayer))
//{
// if(TimeScaleTimers==INVALID_HANDLE)
// {
// timescale=GetConVarFloat(startscalehandle);
// timeadd=GetConVarFloat(increasehandle);
// SetTimeScale(timescale);
// CreateTimer(1.0/TICKS, PlayerTimer, _, TIMER_REPEAT);
// }
// else
// {
// timescale=GetConVarFloat(startscalehandle);
// timeadd=GetConVarFloat(increasehandle);
// SetTimeScale(timescale);
// }
//
//}
}
}
//public Action:PlayerTimer(Handle:timer, any:client)
//{
// timescale = timescale+timeadd;
// timeadd=timeadd*GetConVarFloat(increasehandle2);
// PrintToChatAll("%f ,%f",timescale, timeadd);
// if (timescale>=1.0)
// {
// timescale=1.0;
// SetTimeScale(timescale);
// TimeScaleTimers=INVALID_HANDLE;
// return Plugin_Stop;
// }
// SetTimeScale(timescale);
// return Plugin_Continue;
//}
//SetTimeScale(Float:value)
//{
// // LogAction(0, -1, "DEBUG:stripandchangeserverconvarint 段落");
// new flags = GetConVarFlags(ConVarTimeScale);
// SetConVarFlags(ConVarTimeScale, flags & ~FCVAR_CHEAT);
// SetConVarFloat(ConVarTimeScale, value );
// SetConVarFlags(ConVarTimeScale, flags);
//}
stock DamageEffect(target)
{
new pointHurt = CreateEntityByName("point_hurt"); // Create point_hurt
DispatchKeyValue(target, "targetname", "hurtme"); // mark target
DispatchKeyValue(pointHurt, "Damage", "0"); // No Damage, just HUD display. Does stop Reviving though
DispatchKeyValue(pointHurt, "DamageTarget", "hurtme"); // Target Assignment
DispatchKeyValue(pointHurt, "DamageType", "65536"); // Type of damage
DispatchSpawn(pointHurt); // Spawn descriped point_hurt
AcceptEntityInput(pointHurt, "Hurt"); // Trigger point_hurt execute
AcceptEntityInput(pointHurt, "Kill"); // Remove point_hurt
DispatchKeyValue(target, "targetname", "cake"); // Clear target's mark
}
public Action:Command_Drop(client, args)
{
if (client == 0 || GetClientTeam(client) != 2 || !IsPlayerAlive(client))
return Plugin_Handled;
if (args > 1)
{
ReplyToCommand(client, "[SM] Usage: sm_drop [weapon]");
return Plugin_Handled;
}
new String:weapon[32];
GetClientWeapon(client, weapon, 32);
if (StrContains(weapon, "claw") != -1 || StrEqual(weapon, "weapon_pumpshotgun") || StrEqual(weapon, "weapon_autoshotgun") || StrEqual(weapon, "weapon_rifle") || StrEqual(weapon, "weapon_smg") || StrEqual(weapon, "weapon_hunting_rifle"))
DropSlot(client, 0, 1);
else if (StrEqual(weapon, "weapon_pistol"))
DropSlot(client, 1, 1);
else if (StrEqual(weapon, "weapon_pipe_bomb") || StrEqual(weapon, "weapon_molotov"))
DropSlot(client, 2, 1);
else if (StrEqual(weapon, "weapon_first_aid_kit"))
DropSlot(client, 3, 1);
else if (StrEqual(weapon, "weapon_pain_pills"))
DropSlot(client, 4, 1);
return Plugin_Handled;
}
public EventTongueGrab(Handle:event, const String:name[], bool:dontBroadcast)
{
if (GetRandomInt(0, 100) < GetConVarInt(drop_drag) )
{
new client = GetClientOfUserId(GetEventInt(event, "victim"));
DropTimers[client] = CreateTimer(1.0, DropItemDelay, client);
}
}
public EventTongueRelease(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "victim"));
if (DropTimers[client] != INVALID_HANDLE)
{
KillTimer(DropTimers[client]);
DropTimers[client] = INVALID_HANDLE;
}
}
public EventPlayerPounced(Handle:event, const String:name[], bool:dontBroadcast)
{
if (GetRandomInt(0, 100) < GetConVarInt(drop_pounce) )
{
new client = GetClientOfUserId(GetEventInt(event, "victim"));
CreateTimer(1.0, DropItemProun, client);
}
}
public EventPlayerIncap(Handle:event, const String:name[], bool:dontBroadcast)
{
if (GetRandomInt(0, 100) < GetConVarInt(drop_incap) )
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
CreateTimer(1.0, DropItemIncap, client);
}
}
bool:IsPlayerIncapped(client)
{
if (GetEntProp(client, Prop_Send, "m_isIncapacitated", 1)) return true;
return false;
}
public Action:DropItemProun(Handle:timer, any:client)
{
DropItem(client);
}
public Action:DropItemIncap(Handle:timer, any:client)
{
if (!IsPlayerIncapped(client)) return ;
DropItem(client);
}
public Action:DropItemDelay(Handle:timer, any:client)
{
if (!IsClientInGame(client)) return;
DropItem(client);
DropTimers[client] = INVALID_HANDLE;
}
Give(Client, String:itemId[])
{
new String:command[] = "give";
new flags = GetCommandFlags(command);
SetCommandFlags(command, flags & ~FCVAR_CHEAT);
FakeClientCommand(Client, "%s %s", command, itemId);
SetCommandFlags(command, flags);
//ExecuteCommand(Client, "give", itemId);
}
public DropItem(client)
{
if (IsClientInGame(client) && IsPlayerAlive(client))
{
new String:weapon[32];
new String:msg[132];
GetClientWeapon(client, weapon, 32);
new slot=-1;
if(StrContains(weapon, "pistol")>=0)
{
//Give(client, "pistol");
slot=1;
Format(msg, sizeof(msg), "手枪");
}
else if(StrContains(weapon, "smg")>=0)
{
//Give(client, "smg");
slot=0;
Format(msg, sizeof(msg), "冲锋枪");
}
else if(StrContains(weapon, "hunting_rifle")>=0)
{
//Give(client, "hunting_rifle");
slot=0;
Format(msg, sizeof(msg), "狙击枪");
}
else if(StrContains(weapon, "rifle")>=0)
{
//Give(client, "rifle");
slot=0;
Format(msg, sizeof(msg), "机枪");
}
else if(StrContains(weapon, "autoshotgun")>=0)
{
//Give(client, "autoshotgun");
slot=0;
Format(msg, sizeof(msg), "连发散弹枪");
}
else if(StrContains(weapon, "pumpshotgun")>=0)
{
//Give(client, "pumpshotgun");
slot=0;
Format(msg, sizeof(msg), "单发散弹枪");
}
else if(StrContains(weapon, "kit")>=0)
{
//Give(client, "first_aid_kit");
slot=3;
Format(msg, sizeof(msg), "医疗包");
}
else if(StrContains(weapon, "pill")>=0)
{
//Give(client, "pain_pills");
slot=4;
Format(msg, sizeof(msg), "药瓶");
}
else if(StrContains(weapon, "molotov")>=0)
{
//Give(client, "molotov");
slot=2;
Format(msg, sizeof(msg), "燃烧弹");
}
else if(StrContains(weapon, "pipe")>=0)
{
//Give(client, "pipe_bomb");
slot=2;
Format(msg, sizeof(msg), "炸弹");
}
new bool:ok=false;
if(slot!=-1)
{
//RemovePlayerItem(client, slot);
DropSlot(client, slot, 0);
ok=true;
}
new num=0;
if(ok) num=GetRandomInt(0, GetConVarInt(drop_num)-1);
else num=GetRandomInt(1, GetConVarInt(drop_num))
//PrintToChat(client, "%i %i", num, GetConVarInt(drop_num));
for(new i=0; i<num; i++)
{
new r1=GetRandomInt(0, 4);
if(slot==1 && r1==1)r1=0;
new Slot = GetPlayerWeaponSlot(client, r1);
if (Slot != -1)
{
//RemovePlayerItem(client, Slot);
DropSlot(client, r1, 0);
ok=true;
if(r1==0)
{
Format(msg, sizeof(msg), "%s 主武器", msg);
//PrintToChatAll("抢劫 主武器");
}
if(r1==1)
{
Format(msg, sizeof(msg), "%s 手枪", msg);
//PrintToChatAll("抢劫 手枪");
}
if(r1==2)
{
Format(msg, sizeof(msg), "%s 炸弹", msg);
//PrintToChatAll("抢劫 炸弹");
}
if(r1==3)
{
Format(msg, sizeof(msg), "%s 医疗包", msg);
//PrintToChatAll("抢劫 医疗包");
}
if(r1==4)
{
Format(msg, sizeof(msg), "%s 药丸", msg);
//PrintToChatAll("抢劫 药丸");
}
}
}
if(ok)
{
PrintToChat(client, "\x01[sea]\x03你的 \x04%s \x03掉了", msg);
}
}
}
public DropSlot(client, slot, flag)
{
if (GetPlayerWeaponSlot(client, slot) > 0)
{
new String:sWeapon[32];
new ammo;
new clip;
new ammoOffset = FindSendPropInfo("CTerrorPlayer", "m_iAmmo");
GetEdictClassname(GetPlayerWeaponSlot(client, slot), sWeapon, 32);
new bool:remove=false;
if (slot == 0)
{
clip = GetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_iClip1")
if (StrEqual(sWeapon, "weapon_pumpshotgun") || StrEqual(sWeapon, "weapon_autoshotgun"))
{
ammo = GetEntData(client, ammoOffset+(6*4));
SetEntData(client, ammoOffset+(6*4), 0);
}
else if (StrEqual(sWeapon, "weapon_smg"))
{
ammo = GetEntData(client, ammoOffset+(5*4));
SetEntData(client, ammoOffset+(5*4), 0);
}
else if (StrEqual(sWeapon, "weapon_rifle"))
{
ammo = GetEntData(client, ammoOffset+(3*4));
SetEntData(client, ammoOffset+(3*4), 0);
}
else if (StrEqual(sWeapon, "weapon_hunting_rifle"))
{
ammo = GetEntData(client, ammoOffset+(2*4));
SetEntData(client, ammoOffset+(2*4), 0);
}
else if (StrContains(sWeapon, "claw") != -1)
{
remove=true;
}
}
if (slot == 1)
{
if ((GetEntProp(client, Prop_Send, "m_iAddonBits") & (FL_PISTOL|FL_PISTOL_PRIMARY)) > 0)
//if ((GetEntProp(client, Prop_Send, "m_iAddonBits") ) > 0)
{
clip = GetEntProp(GetPlayerWeaponSlot(client, 1), Prop_Send, "m_iClip1")
RemovePlayerItem(client, GetPlayerWeaponSlot(client, 1));
SetCommandFlags("give", GetCommandFlags("give") & ~FCVAR_CHEAT);
FakeClientCommand(client, "give pistol", sWeapon);
SetCommandFlags("give", GetCommandFlags("give") | FCVAR_CHEAT);
if (clip < 15)
SetEntProp(GetPlayerWeaponSlot(client, 1), Prop_Send, "m_iClip1", 0);
else
SetEntProp(GetPlayerWeaponSlot(client, 1), Prop_Send, "m_iClip1", clip-15);
new index = CreateEntityByName(sWeapon);
//new Float:cllocation[3];
// GetEntPropVector(client, Prop_Send, "m_vecOrigin", cllocation);
//cllocation[2]+=20;
//TeleportEntity(index,cllocation, NULL_VECTOR, NULL_VECTOR);
//DispatchSpawn(index);
//ActivateEntity(index);
new Handle:g_iVelocity = FindSendPropOffs("CBasePlayer", "m_vecVelocity[0]");
decl Float:pos[3];
decl Float:angles[3];
decl Float:velocity[3];
GetClientEyePosition(client, pos);
GetClientEyeAngles(client, angles);
GetEntDataVector(client, g_iVelocity, velocity);
new Float:force=300.0;
velocity[0] += force * Cosine(DegToRad(angles[1])) * Cosine(DegToRad(angles[0]));
velocity[1] += force * Sine(DegToRad(angles[1])) * Cosine(DegToRad(angles[0]));
velocity[2] += force * Sine(DegToRad(angles[0])) * -1.0;
pos[0]+=velocity[0]*0.1;
pos[1]+=velocity[1]*0.1;
pos[2]+=velocity[2]*0.05;
DispatchSpawn(index);
TeleportEntity(index, pos, NULL_VECTOR, velocity);
ActivateEntity(index);
}
else
{
clip = GetEntProp(GetPlayerWeaponSlot(client, 1), Prop_Send, "m_iClip1")
RemovePlayerItem(client, GetPlayerWeaponSlot(client, 1));
//SetCommandFlags("give", GetCommandFlags("give") & ~FCVAR_CHEAT);
//FakeClientCommand(client, "give pistol", sWeapon);
//SetCommandFlags("give", GetCommandFlags("give") | FCVAR_CHEAT);
//if (clip < 15)
// SetEntProp(GetPlayerWeaponSlot(client, 1), Prop_Send, "m_iClip1", 0);
//else
// SetEntProp(GetPlayerWeaponSlot(client, 1), Prop_Send, "m_iClip1", clip-15);
new index = CreateEntityByName(sWeapon);
//new Float:cllocation[3];
//GetEntPropVector(client, Prop_Send, "m_vecOrigin", cllocation);
//cllocation[2]+=20;
//TeleportEntity(index,cllocation, NULL_VECTOR, NULL_VECTOR);
//DispatchSpawn(index);
//ActivateEntity(index);
new Handle:g_iVelocity = FindSendPropOffs("CBasePlayer", "m_vecVelocity[0]");
decl Float:pos[3];
decl Float:angles[3];
decl Float:velocity[3];
GetClientEyePosition(client, pos);
GetClientEyeAngles(client, angles);
GetEntDataVector(client, g_iVelocity, velocity);
new Float:force=300.0;
if(flag==0)force=100;
velocity[0] += force * Cosine(DegToRad(angles[1])) * Cosine(DegToRad(angles[0]));
velocity[1] += force * Sine(DegToRad(angles[1])) * Cosine(DegToRad(angles[0]));
velocity[2] += force * Sine(DegToRad(angles[0])) * -1.0;
pos[0]+=velocity[0]*0.1;
pos[1]+=velocity[1]*0.1;
pos[2]+=velocity[2]*0.05;
DispatchSpawn(index);
TeleportEntity(index, pos, NULL_VECTOR, velocity);
ActivateEntity(index);
}
return;
}
new index = CreateEntityByName(sWeapon);
//new Float:cllocation[3];
//GetEntPropVector(client, Prop_Send, "m_vecOrigin", cllocation);
//cllocation[2]+=20;
//TeleportEntity(index,cllocation, NULL_VECTOR, NULL_VECTOR);
//DispatchSpawn(index);
//ActivateEntity(index);
RemovePlayerItem(client, GetPlayerWeaponSlot(client, slot));
new Handle:g_iVelocity = FindSendPropOffs("CBasePlayer", "m_vecVelocity[0]");
decl Float:pos[3];
decl Float:angles[3];
decl Float:velocity[3];
GetClientEyePosition(client, pos);
GetClientEyeAngles(client, angles);
GetEntDataVector(client, g_iVelocity, velocity);
new Float:force=350.0;
if(flag==0)force=150;
velocity[0] += force * Cosine(DegToRad(angles[1])) * Cosine(DegToRad(angles[0]));
velocity[1] += force * Sine(DegToRad(angles[1])) * Cosine(DegToRad(angles[0]));
velocity[2] += force * Sine(DegToRad(angles[0])) * -1.0;
pos[0]+=velocity[0]*0.1;
pos[1]+=velocity[1]*0.1;
pos[2]+=velocity[2]*0.05;
DispatchSpawn(index);
TeleportEntity(index, pos, NULL_VECTOR, velocity);
ActivateEntity(index);
if(remove )RemoveEdict(index);
if (slot == 0)
{
SetEntProp(index, Prop_Send, "m_iExtraPrimaryAmmo", ammo);
SetEntProp(index, Prop_Send, "m_iClip1", clip);
}
}
}
stock CheatCommand(client, String:command[], String:parameter1[], String:parameter2[])
{
new userflags = GetUserFlagBits(client);
SetUserFlagBits(client, ADMFLAG_ROOT);
new flags = GetCommandFlags(command);
SetCommandFlags(command, flags & ~FCVAR_CHEAT);
FakeClientCommand(client, "%s %s %s", command, parameter1, parameter2);
SetCommandFlags(command, flags);
SetUserFlagBits(client, userflags);
}
求生之路 物品掉落-源码
评论
(0)