forked from jeremyvillanuevar/scripting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLMCEDeathHandler.sp
More file actions
117 lines (97 loc) · 3.5 KB
/
LMCEDeathHandler.sp
File metadata and controls
117 lines (97 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* LMCEDeathHandler - Manages deaths regarding lmc for entities ragdolls, module required to handle (witch & common deaths)
* Copyright (C) 2019 LuxLuma acceliacat@gmail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#define REQUIRE_PLUGIN
#include <LMCCore>
#undef REQUIRE_PLUGIN
#pragma newdecls required
#define PLUGIN_NAME "LMCEDeathHandler"
#define PLUGIN_VERSION "1.1.4"
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
EngineVersion iEngineVersion = GetEngineVersion();
if(iEngineVersion != Engine_Left4Dead2 && iEngineVersion != Engine_Left4Dead)
{
strcopy(error, err_max, "Plugin only supports Left 4 Dead 1/2");
return APLRes_SilentFailure;
}
RegPluginLibrary("LMCEDeathHandler");
return APLRes_Success;
}
public Plugin myinfo =
{
name = PLUGIN_NAME,
author = "Lux",
description = "Manages deaths regarding lmc for entities ragdolls, module required to handle (witch & common deaths)",
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/showthread.php?p=2607394"
};
public void OnPluginStart()
{
CreateConVar("lmcedeathhandler_version", PLUGIN_VERSION, "LMCL4D2EDeathHandler_version", FCVAR_DONTRECORD|FCVAR_NOTIFY);
}
public void OnAllPluginsLoaded()// makesure my hook is last if it can
{
HookEvent("player_death", ePlayerDeath);
}
public void ePlayerDeath(Handle hEvent, const char[] sEventName, bool bDontBroadcast)
{
int iVictim = GetEventInt(hEvent, "entityid");
if(iVictim < MaxClients+1 || iVictim > 2048 || !IsValidEntity(iVictim))
return;
int iEntity = LMC_GetEntityOverlayModel(iVictim);
if(iEntity < 1)
return;
NextBotRagdollHandler(iVictim, iEntity);
}
void NextBotRagdollHandler(int iEntity, int iPreRagdoll)
{
if(GetEntProp(iEntity, Prop_Send, "m_bIsBurning", 1))
{
int iRagdoll = CreateEntityByName("cs_ragdoll");
if(iRagdoll > 0)
{
float fPos[3];
float fAng[3];
GetEntPropVector(iEntity, Prop_Data, "m_vecOrigin", fPos);
GetEntPropVector(iEntity, Prop_Data, "m_angRotation", fAng);
TeleportEntity(iRagdoll, fPos, fAng, NULL_VECTOR);
SetEntProp(iRagdoll, Prop_Send, "m_nModelIndex", GetEntProp(iPreRagdoll, Prop_Send, "m_nModelIndex", 2), 2);
SetEntProp(iRagdoll, Prop_Send, "m_iTeamNum", 3, 1);
SetEntProp(iRagdoll, Prop_Send, "m_hPlayer", -1, 3);
SetEntProp(iRagdoll, Prop_Send, "m_ragdollType", 1, 1);
SetEntProp(iRagdoll, Prop_Send, "m_bOnFire", 1, 1);
SetVariantString("OnUser1 !self:Kill::0.1:1");
AcceptEntityInput(iRagdoll, "AddOutput");
AcceptEntityInput(iRagdoll, "FireUser1");
AcceptEntityInput(iPreRagdoll, "Kill");
}
else
AcceptEntityInput(iPreRagdoll, "BecomeRagdoll");
}
else
AcceptEntityInput(iPreRagdoll, "BecomeRagdoll");
SDKHook(iEntity, SDKHook_SetTransmit, HideNextBot);
}
public Action HideNextBot(int iEntity, int iClient)
{
return Plugin_Handled;
}