weapon logging support

This commit is contained in:
Lukasz Wlasinksi 2004-06-25 12:21:47 +00:00
parent a9c5228c31
commit 6d8f61c4e0
5 changed files with 65 additions and 47 deletions

View File

@ -92,7 +92,7 @@ enum {
struct weaponsVault { struct weaponsVault {
char* name; char* name;
char fullName[32]; char* logName;
short int ammoSlot; short int ammoSlot;
bool melee; bool melee;
}; };

View File

@ -344,7 +344,15 @@ static cell AMX_NATIVE_CALL TFC_GetWpnName(AMX *amx, cell *params) {
} }
return MF_SetAmxString(amx,params[2],weaponData[iIndex].name,params[3]); return MF_SetAmxString(amx,params[2],weaponData[iIndex].name,params[3]);
} }
static cell AMX_NATIVE_CALL TFC_GetWpnLogName(AMX *amx, cell *params) {
int iIndex = params[1];
if ( iIndex < 1 || iIndex > TFCMAX_WEAPONS ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[iIndex].logName,params[3]);
}
static cell AMX_NATIVE_CALL TFC_SetPDdata(AMX *amx, cell *params) { static cell AMX_NATIVE_CALL TFC_SetPDdata(AMX *amx, cell *params) {
@ -392,6 +400,7 @@ AMX_NATIVE_INFO base_Natives[] = {
{"TFC_GetWeaponBAmmo", TFC_GetWeaponBAmmo}, {"TFC_GetWeaponBAmmo", TFC_GetWeaponBAmmo},
{"TFC_SetWeaponBAmmo", TFC_SetWeaponBAmmo}, {"TFC_SetWeaponBAmmo", TFC_SetWeaponBAmmo},
{"TFC_GetWpnName", TFC_GetWpnName}, {"TFC_GetWpnName", TFC_GetWpnName},
{"TFC_GetWpnLogName", TFC_GetWpnLogName},
{"TFC_IsMelee", TFC_IsMelee}, {"TFC_IsMelee", TFC_IsMelee},
{"TFC_UserKill" , TFC_UserKill}, {"TFC_UserKill" , TFC_UserKill},

View File

@ -84,35 +84,35 @@ knife,iSlot:-1,iId:23
*/ */
weaponsVault weaponData[] = { weaponsVault weaponData[] = {
{ "", "", -1 }, // 0 { "", "", -1 }, // 0
{ "timer", "", -1 }, // 1 { "timer", "infection", -1 }, // 1
{ "sentrygun", "", -1 }, // 2 { "sentrygun", "sentrygun", -1 }, // 2
{ "medikit", "", -1 , true}, { "medikit", "medikit", -1 , true},
{ "spanner", "", 2 , true }, { "spanner", "spanner", 2 , true },
{ "axe", "", -1 , true }, { "axe", "axe", -1 , true },
{ "sniperrifle", "", 1 }, { "sniperrifle", "sniperrifle", 1 },
{ "autorifle", "", 1 }, { "autorifle", "autorifle", 1 },
{ "shotgun", "", 1 }, { "shotgun", "shotgun", 1 },
{ "supershotgun", "", 1 }, { "supershotgun", "supershotgun", 1 },
{ "ng", "", 3 }, { "ng", "nails", 3 },
{ "superng", "", 3 }, { "superng", "supernails", 3 },
{ "gl", "", 4 }, { "gl", "gl_grenade", 4 },
{ "flamethrower", "", 2 }, { "flamethrower", "", 2 },
{ "rpg", "", 4 }, { "rpg", "rocket", 4 },
{ "ic", "", 4 }, { "ic", "ic", 4 },
{ "flames", "", -1 }, // 16 { "flames", "flames", -1 }, // 16
{ "ac", "", 1 }, { "ac", "ac", 1 },
{ "", "", -1 }, // 18 { "", "", -1 }, // 18
{ "", "", -1 }, // 19 { "", "", -1 }, // 19
{ "tranq", "", 1 }, { "tranq", "tranq", 1 },
{ "railgun", "", 3 }, { "railgun", "railgun", 3 },
{ "pl", "", 4 }, { "pl", "pipebomb", 4 },
{ "knife", "", -1 , true }, { "knife", "knife", -1 , true },
{ "caltrop", "", -1 }, // 24 { "caltrop", "caltrop", -1 }, // 24
{ "concussion", "", -1 }, { "concussion", "concussiongrenade", -1 },
{ "grenade", "", -1 }, { "grenade", "normalgrenade", -1 },
{ "nailgrenade", "", -1 }, { "nailgrenade", "nailgrenade", -1 },
{ "mirvgrenade", "", -1 }, { "mirvgrenade", "mirvgrenade", -1 },
{ "napalm", "", -1 }, { "napalm", "napalmgrenade", -1 },
{ "gas", "", -1 }, { "gas", "gasgrenade", -1 },
{ "emp", "", -1 }, { "emp", "empgrenade", -1 },
}; };

View File

@ -278,27 +278,31 @@ void SetModel_Post(edict_t *e, const char *m){
} }
void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr) { void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr) {
if (ptr->pHit&&(ptr->pHit->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&& if ( !e )
e&&(e->v.flags& (FL_CLIENT | FL_FAKECLIENT) )){
GET_PLAYER_POINTER(e)->aiming = ptr->iHitgroup;
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
}
if ( e->v.owner && e->v.owner->v.flags& (FL_CLIENT | FL_FAKECLIENT) ){ if (ptr->pHit&&(ptr->pHit->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&&
CPlayer *pPlayer = GET_PLAYER_POINTER(e->v.owner); (e->v.flags& (FL_CLIENT | FL_FAKECLIENT) )){
for ( int i=0;i<MAX_TRACE;i++){ GET_PLAYER_POINTER(e)->aiming = ptr->iHitgroup;
if ( strcmp( traceData[i].szName,STRING(e->v.classname)) == 0 ){ }
if ( traceData[i].iAction & ACT_NADE_SHOT ){ else{
pPlayer->saveShot(traceData[i].iId); if ( e->v.owner && e->v.owner->v.flags& (FL_CLIENT | FL_FAKECLIENT) ){
CPlayer *pPlayer = GET_PLAYER_POINTER(e->v.owner);
for ( int i=0;i<MAX_TRACE;i++){
if ( strcmp( traceData[i].szName,STRING(e->v.classname)) == 0 ){
if ( traceData[i].iAction & ACT_NADE_SHOT ){
pPlayer->saveShot(traceData[i].iId);
}
if ( traceData[i].iAction & ACT_NADE_PUT ){
g_grenades.put(e,traceData[i].fDel,traceData[i].iId,GET_PLAYER_POINTER(e->v.owner));
}
break;
} }
if ( traceData[i].iAction & ACT_NADE_PUT ){
g_grenades.put(e,traceData[i].fDel,traceData[i].iId,GET_PLAYER_POINTER(e->v.owner));
}
break;
} }
} }
} }
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }

View File

@ -87,9 +87,14 @@ void Client_Damage(void* mValue){
case 2: case 2:
edict_t* enemy; edict_t* enemy;
if ( !mPlayer || !damage )
break;
enemy = mPlayer->pEdict->v.dmg_inflictor; enemy = mPlayer->pEdict->v.dmg_inflictor;
if ( !mPlayer || !damage || FNullEnt( enemy ) ) break;
if ( FNullEnt( enemy ) )
break;
if (enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ) { // attacker is player and his active weapon if (enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ) { // attacker is player and his active weapon
pAttacker = GET_PLAYER_POINTER(enemy); pAttacker = GET_PLAYER_POINTER(enemy);