View difference between Paste ID: rL865H5t and kxBgetsB
SHOW: | | - or go back to the newest paste.
1
#include <sdktools>
2
 
3
#pragma newdecls required
4
#pragma semicolon 1
5
 
6
#define PARTICLE_BLOOD    "blood_bleedout"
7
 
8
static const char szVocalizes[][] =
9
{
10
    "scenes/Gambler/deathscream03.vcd",      //Nick
11
    "scenes/Gambler/deathscream04.vcd",
12
    "scenes/Gambler/deathscream05.vcd",
13
    "scenes/Gambler/deathscream06.vcd",
14
    "scenes/mechanic/hurtmajor02.vcd",   //Ellis
15
    "scenes/mechanic/hurtmajor06.vcd",
16
    "scenes/mechanic/defibrillator19.vcd",
17
    "scenes/Producer/deathscream01.vcd",   //Rochelle
18
    "scenes/Producer/deathscream02.vcd",
19
    "scenes/Coach/deathscream08.vcd",     //Coach
20
    "scenes/Coach/deathscream09.vcd",
21
    "scenes/Coach/hurtcritical01.vcd", 
22
    "scenes/Coach/hurtcritical03.vcd",
23
    "scenes/Coach/hurtcritical06.vcd",
24
    "scenes/teengirl/deathscream01.vcd",        //teengirl //L4D1
25
    "scenes/teengirl/deathscream02.vcd",
26
    "scenes/teengirl/deathscream03.vcd",
27
    "scenes/teengirl/deathscream04.vcd",
28
    "scenes/teengirl/deathscream07.vcd",
29
    "scenes/teengirl/deathscream09.vcd",
30
    "scenes/teengirl/exertionmajor01.vcd",
31
    "scenes/teengirl/exertionminor02.vcd",
32
    "scenes/namvet/deathscream08.vcd",   //Bill
33
    "scenes/namvet/deathscream07.vcd",
34
    "scenes/namvet/deathscream02.vcd",
35
    "scenes/namvet/exertioncritical01.vcd",
36
    "scenes/namvet/exertioncritical02.vcd",
37
    "scenes/namvet/exertionmajor01.vcd",
38
    "scenes/namvet/exertionmajor02.vcd",
39
    "scenes/manager/deathscream01.vcd", //Louis
40
    "scenes/manager/deathscream06.vcd",
41
    "scenes/manager/deathscream08.vcd",
42
    "scenes/manager/deathscream09.vcd",
43
    "scenes/manager/deathscream10.vcd",
44
    "scenes/manager/exertioncritical02.vcd",
45
    "scenes/manager/exertionmajor01.vcd",
46
    "scenes/manager/exertionminor03.vcd",
47
    "scenes/biker/deathscream01.vcd",     //Francis
48
    "scenes/biker/deathscream03.vcd",
49
    "scenes/biker/deathscream05.vcd",
50
    "scenes/biker/choke04.vcd",
51
    "scenes/biker/cough04.vcd",
52
    "scenes/biker/dying02.vcd",
53
    "scenes/biker/dying01.vcd",
54
    "scenes/biker/exertioncritical01.vcd",
55
    "scenes/biker/exertionmajor01.vcd",
56
    "scenes/biker/exertioncritical02.vcd",
57
    "scenes/biker/exertionminor05.vcd"
58
};
59
 
60
bool        g_bDie[MAXPLAYERS + 1];
61
float   g_iHelth[MAXPLAYERS + 1];
62
Handle  hTimer[MAXPLAYERS + 1], DoAnimationEvent, Blood;
63
 
64
public void OnPluginStart()
65
{
66
    HookEvent("revive_begin", eBegin);
67
    HookEvent("revive_success", eSuccess);
68
    HookEvent("player_death", eDeath);
69
    
70
    HookEvent("heal_success", eHeal);
71
    
72
    Handle hGameConf = LoadGameConfigFile("added_inkap-deadly");
73
 
74
    StartPrepSDKCall(SDKCall_Static);
75
    PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "CBloodStream");
76
    PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
77
    PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
78
    PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Pointer);
79
    PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Pointer);
80
    Blood = EndPrepSDKCall();
81
    
82
    StartPrepSDKCall(SDKCall_Player);
83
    PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "CTerrorPlayer::DoAnimationEvent");
84
    PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
85
    PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
86
    DoAnimationEvent = EndPrepSDKCall();
87
    
88
    delete hGameConf;
89
}
90
 
91
public void OnMapStart()
92
{
93
    int table = INVALID_STRING_TABLE;
94
 
95
    if( table == INVALID_STRING_TABLE )
96
    {
97
        table = FindStringTable("ParticleEffectNames");
98
    }
99
 
100
    if( FindStringIndex(table, PARTICLE_BLOOD) == INVALID_STRING_INDEX )
101
    {
102
        bool save = LockStringTables(false);
103
        AddToStringTable(table, PARTICLE_BLOOD);
104
        LockStringTables(save);
105
    }
106
}
107
 
108
public void eDeath (Event event, const char[] name, bool dontbroadcast)
109
{
110
    int client = GetClientOfUserId(event.GetInt("userid"));
111
    
112
    if(!client || !IsClientInGame(client))
113
        return;
114
        
115
    g_bDie[client] = false;
116
}
117
 
118
public void eBegin (Event event, const char[] name, bool dontbroadcast)
119
{
120
    int client = GetClientOfUserId(event.GetInt("subject"));
121
    
122
    if(!client || !IsClientInGame(client))
123
        return;
124
    
125
    g_iHelth[client] = GetEntPropFloat(client, Prop_Send, "m_healthBuffer") + GetClientHealth(client);
126
}
127
 
128
public void eSuccess (Event event, const char[] name, bool dontbroadcast)
129
{
130
    int client = GetClientOfUserId(event.GetInt("subject"));
131
    
132
    if(!client || !IsClientInGame(client))
133
        return;
134
    
135
    g_bDie[client] = true;
136
    hTimer[client] = CreateTimer(g_iHelth[client] / 6, tToDie, GetClientUserId(client));
137
    CreateTimer(GetRandomFloat(0.0, 12.0), tBleed, GetClientUserId(client), TIMER_REPEAT);
138
}
139
 
140
public void eHeal (Event event, const char[] name, bool dontbroadcast)
141
{
142
    int client = GetClientOfUserId(event.GetInt("subject"));
143
    
144
    if(!client || !IsClientInGame(client) || !g_bDie[client])
145
        return;
146
    
147
    SetEntityHealth(client, 25);
148
    g_bDie[client] = false;
149
    
150
    if(hTimer[client] != null)
151
        delete hTimer[client];
152
}
153
 
154
public Action tBleed (Handle timer, any client)
155
{
156
    client = GetClientOfUserId(client);
157
    
158
    if(!client || !IsClientInGame(client))
159
        return Plugin_Continue;
160
    
161
    if(!g_bDie[client])
162
        return Plugin_Stop;
163
    
164
    float vPos[3], vAng[3];
165
    
166
    GetClientEyePosition(client, vPos);
167
    vAng[0] = 89.00;
168
    
169
    Handle hTrace = TR_TraceRayFilterEx(vPos, vAng, CONTENTS_SOLID, RayType_Infinite, TraceDontHitSelf, client);
170
    
171
    if( TR_DidHit(hTrace) )
172
        TR_GetEndPosition(vPos, hTrace);
173
    delete hTrace;
174
 
175
    int entity = CreateEntityByName("info_particle_system");
176
    
177
    if(!IsValidEntity(entity))
178
        return Plugin_Continue;
179
    
180
    DispatchKeyValue(entity, "effect_name", PARTICLE_BLOOD);
181
    TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
182
    DispatchSpawn(entity);
183
    ActivateEntity(entity);
184
 
185
    AcceptEntityInput(entity, "start");
186
    
187
    Vocalize(client);
188
    
189
    GetClientEyePosition(client, vPos);
190
    vPos[2] -= 4.0;
191
    for(int i = 1; i < GetRandomInt(1, 12); i++)
192
        SDKCall(Blood, vPos, vPos, 40, 40);
193
        
194
    return Plugin_Continue;
195
}
196
 
197
public bool TraceDontHitSelf(int entity, int mask, any data)
198
{
199
    if(entity == data)
200
        return false;
201
    return true;
202
}
203
 
204
public Action tToDie (Handle timer, any client)
205
{
206
    client = GetClientOfUserId(client);
207
    
208
    if(!client || !IsClientInGame(client) || !g_bDie[client])
209
        return;
210
    
211
    SDKCall(DoAnimationEvent, client, 10, 0);
212
    CreateTimer(3.15, tDeath, GetClientUserId(client));
213
}
214
 
215
public Action tDeath (Handle timer, any client)
216
{
217
    client = GetClientOfUserId(client);
218
    
219
    if(!client || !IsClientInGame(client))
220
        return;
221
        
222
    ForcePlayerSuicide(client);
223
    hTimer[client] = null;
224
    g_bDie[client] = false;
225
}
226
 
227
void Vocalize(int client)
228
{
229
    char sTemp[64];
230
    GetEntPropString(client, Prop_Data, "m_ModelName", sTemp, 64);
231
    
232
    int random;
233
    
234
    if( sTemp[26] == 'c' )                        // c = Coach
235
        random = GetRandomInt(10, 13);
236
    else if( sTemp[26] == 'g' )                  // g = Gambler
237
        random = GetRandomInt(0, 3);
238
    else if( sTemp[26] == 'm' && sTemp[27] == 'e' ) // me = Mechanic
239
        random = GetRandomInt(4, 6);
240
    else if( sTemp[26] == 'p' )                  // p = Producer
241
        random = GetRandomInt(7, 8);
242
    else if( sTemp[26] == 'b' )                  // b = biker
243
        random = GetRandomInt(37, 47);
244
    else if( sTemp[26] == 'n' )                  // n = namvet
245
        random = GetRandomInt(22, 28);
246
    else if( sTemp[26] == 'm' && sTemp[27] == 'a' ) // m = manager
247
        random = GetRandomInt(29, 36);
248
    else if( sTemp[26] == 't' )                  // t = teengirl
249
        random = GetRandomInt(14, 21);
250
    else
251
        return;
252
    
253
    int entity = CreateEntityByName("instanced_scripted_scene");
254
    DispatchKeyValue(entity, "SceneFile", szVocalizes[random]);
255
    DispatchSpawn(entity);
256
    SetEntPropEnt(entity, Prop_Data, "m_hOwner", client);
257
    ActivateEntity(entity);
258
    AcceptEntityInput(entity, "Start", client, client);
259
}