-
Notifications
You must be signed in to change notification settings - Fork 0
/
usermsg.cpp
270 lines (240 loc) · 5.73 KB
/
usermsg.cpp
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// CSX Module
//
#include "amxxmodule.h"
#include "rank.h"
weaponsVault weaponData[MAX_WEAPONS+MAX_CWEAPONS];
int damage;
int TA;
int weapon;
int aim;
bool ignore;
CPlayer *pAttacker;
void Client_ResetHUD(void* mValue){
if ( mPlayer ){
mPlayer->clearStats = gpGlobals->time + 0.25f;
}
}
void Client_DeathMsg(void *mValue)
{
static int killer_id;
//static int victim_id;
static int is_headshot;
const char *name;
switch (mState++)
{
case 0:
{
killer_id = *(int *)mValue;
break;
}
//case 1:
// {
// victim_id = *(int *)mValue;
// break;
// }
case 2:
{
is_headshot = *(int *)mValue;
break;
}
case 3:
{
name = (const char *)mValue;
if (killer_id
&& (strcmp(name, "knife") == 0))
{
CPlayer *pPlayer = GET_PLAYER_POINTER_I(killer_id);
pPlayer->aiming = is_headshot ? 1 : 0;
}
break;
}
}
}
void Client_WeaponList(void* mValue){
static int wpnList;
static int iSlot;
static const char* wpnName;
switch (mState++) {
case 0:
wpnName = (const char*)mValue;
break;
case 1:
iSlot = *(int*)mValue;
break;
case 7:
int iId = *(int*)mValue;
if ( (iId < 0 || iId >= MAX_WEAPONS ) || ( wpnList & (1<<iId) ) )
break;
wpnList |= (1<<iId);
weaponData[iId].ammoSlot = iSlot;
if ( strstr( wpnName,"weapon_") )
{
if ( strcmp(wpnName+7,"hegrenade") == 0 )
strcpy(weaponData[iId].name,wpnName+9);
else
strcpy(weaponData[iId].name,wpnName+7);
strcpy(weaponData[iId].logname,weaponData[iId].name);
}
}
}
void Client_Damage(void* mValue){
static int bits;
switch (mState++) {
case 1:
ignore = false;
damage = *(int*)mValue;
break;
case 2:
bits = *(int*)mValue;
break;
case 3:
if (!mPlayer || !damage || bits){
ignore = true;
break;
}
edict_t *enemy;
enemy = mPlayer->pEdict->v.dmg_inflictor;
if ( FNullEnt( enemy ) ){
ignore = true;
break;
}
aim = 0;
weapon = 0;
pAttacker = NULL;
if (enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ) {
pAttacker = GET_PLAYER_POINTER(enemy);
aim = pAttacker->aiming;
weapon = pAttacker->current;
pAttacker->saveHit( mPlayer , weapon , damage, aim);
break;
}
if( g_grenades.find(enemy , &pAttacker , &weapon ) )
pAttacker->saveHit( mPlayer , weapon , damage, aim );
else if ( strcmp("grenade",STRING(enemy->v.classname))==0 ) // ? more checks ?
weapon = CSW_C4;
}
}
void Client_Damage_End(void* mValue){
if ( ignore )
return;
if ( !pAttacker ) pAttacker = mPlayer;
TA = 0;
if ( (mPlayer->teamId == pAttacker->teamId) && (mPlayer != pAttacker) )
TA = 1;
MF_ExecuteForward( iFDamage, static_cast<cell>(pAttacker->index) , static_cast<cell>(mPlayer->index) ,
static_cast<cell>(damage), static_cast<cell>(weapon), static_cast<cell>(aim), static_cast<cell>(TA) );
if ( !mPlayer->IsAlive() ){
if ( weapon != CSW_C4 )
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
MF_ExecuteForward( iFDeath, static_cast<cell>(pAttacker->index), static_cast<cell>(mPlayer->index),
static_cast<cell>(weapon), static_cast<cell>(aim), static_cast<cell>(TA) );
}
}
void Client_CurWeapon(void* mValue){
static int iState;
static int iId;
switch (mState++){
case 0:
iState = *(int*)mValue;
break;
case 1:
if (!iState) break;
iId = *(int*)mValue;
break;
case 2:
if (!mPlayer || !iState ) break;
int iClip = *(int*)mValue;
if ((iClip > -1) && (iClip < mPlayer->weapons[iId].clip))
mPlayer->saveShot(iId);
mPlayer->weapons[iId].clip = iClip;
mPlayer->current = iId;
}
}
void Client_AmmoX(void* mValue){
static int iAmmo;
switch (mState++){
case 0:
iAmmo = *(int*)mValue;
break;
case 1:
if (!mPlayer ) break;
for(int i = 1; i < MAX_WEAPONS ; ++i)
if (iAmmo == weaponData[i].ammoSlot)
mPlayer->weapons[i].ammo = *(int*)mValue;
}
}
void Client_AmmoPickup(void* mValue){
static int iSlot;
switch (mState++){
case 0:
iSlot = *(int*)mValue;
break;
case 1:
if (!mPlayer ) break;
for(int i = 1; i < MAX_WEAPONS ; ++i)
if (weaponData[i].ammoSlot == iSlot)
mPlayer->weapons[i].ammo += *(int*)mValue;
}
}
void Client_ScoreInfo(void* mValue){
static int index;
switch (mState++){
case 0:
index = *(int*)mValue;
break;
case 4:
if ( index > 0 && index <= gpGlobals->maxClients )
GET_PLAYER_POINTER_I( index )->teamId = *(int*)mValue;
}
}
void Client_SendAudio(void* mValue){
static const char* szText;
if ( mState == 1 ){
szText = (const char*)mValue;
if ( !mPlayer && szText[7]=='B' ) {
if ( szText[11]=='P' && g_Planter ){
GET_PLAYER_POINTER_I(g_Planter)->saveBPlant();
g_bombAnnounce = BOMB_PLANTED;
}
else if ( szText[11]=='D' && g_Defuser ){
GET_PLAYER_POINTER_I(g_Defuser)->saveBDefused();
g_bombAnnounce = BOMB_DEFUSED;
}
}
}
mState++;
}
void Client_TextMsg(void* mValue){
static const char* szText;
if ( !mPlayer && mState==1 ){
szText = (const char*)mValue;
if ( szText[1]=='T' && szText[8]=='B' && g_Planter ){
GET_PLAYER_POINTER_I(g_Planter)->saveBExplode();
g_bombAnnounce = BOMB_EXPLODE;
}
}
mState++;
}
void Client_BarTime(void* mValue){
int iTime = *(int*)mValue;
if ( !iTime || !mPlayer->IsAlive() ) return;
if ( iTime == 3 ){
g_Planter = mPlayerIndex;
g_bombAnnounce = BOMB_PLANTING;
g_Defuser = 0;
}
else {
mPlayer->saveBDefusing();
g_Defuser = mPlayerIndex;
g_bombAnnounce = BOMB_DEFUSING;
}
}