2014-08-04 10:55:54 +00:00
|
|
|
// 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.
|
|
|
|
// Copyright (C) 2004 Lukasz Wlasinski.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
|
|
|
//
|
|
|
|
// TSX Module
|
|
|
|
//
|
2005-12-11 18:42:19 +00:00
|
|
|
|
|
|
|
#include "amxxmodule.h"
|
|
|
|
#include "tsx.h"
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
|
2006-02-26 08:11:25 +00:00
|
|
|
void Client_ResetHUD_End(void* mValue)
|
|
|
|
{
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( mPlayer->IsAlive() ){ // ostatni przed spawn'em
|
|
|
|
mPlayer->clearStats = gpGlobals->time + 0.25f; // teraz czysc statystyki
|
2005-12-11 18:42:19 +00:00
|
|
|
}
|
2006-02-26 06:42:48 +00:00
|
|
|
else { // dalej "dead" nie czysc statystyk!
|
2005-12-11 18:42:19 +00:00
|
|
|
mPlayer->items = 0;
|
|
|
|
mPlayer->is_specialist = 0;
|
|
|
|
mPlayer->killingSpree = 0;
|
|
|
|
mPlayer->killFlags = 0;
|
|
|
|
mPlayer->frags = (int)mPlayer->pEdict->v.frags;
|
2006-02-26 06:42:48 +00:00
|
|
|
/*
|
|
|
|
fix dla user_kill() z addfrag
|
|
|
|
oraz self kills
|
|
|
|
*/
|
2005-12-11 18:42:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-26 08:11:25 +00:00
|
|
|
void Client_ScoreInfo(void* mValue)
|
|
|
|
{
|
2005-12-11 18:42:19 +00:00
|
|
|
static int iId;
|
2006-02-26 06:42:48 +00:00
|
|
|
switch(mState++){
|
2005-12-11 18:42:19 +00:00
|
|
|
case 0:
|
|
|
|
iId = *(int*)mValue;
|
|
|
|
break;
|
|
|
|
case 4:
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( iId && (iId < 33) ){
|
2005-12-11 18:42:19 +00:00
|
|
|
GET_PLAYER_POINTER_I(iId)->teamId = *(int*)mValue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-26 08:11:25 +00:00
|
|
|
void Client_WeaponInfo(void* mValue)
|
|
|
|
{
|
2005-12-11 18:42:19 +00:00
|
|
|
static int wpn;
|
2006-02-26 06:42:48 +00:00
|
|
|
switch(mState++){
|
2005-12-11 18:42:19 +00:00
|
|
|
case 0:
|
|
|
|
wpn = *(int*)mValue;
|
|
|
|
if ( !wpn ) wpn = 36; // kung fu
|
|
|
|
mPlayer->current = wpn;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
mPlayer->weapons[wpn].clip = *(int*)mValue;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
mPlayer->weapons[wpn].ammo = *(int*)mValue;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
mPlayer->weapons[wpn].mode = *(int*)mValue;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
mPlayer->weapons[wpn].attach = *(int*)mValue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-26 08:11:25 +00:00
|
|
|
void Client_ClipInfo(void* mValue)
|
|
|
|
{
|
2005-12-11 18:42:19 +00:00
|
|
|
int iValue = *(int*)mValue;
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( iValue < mPlayer->weapons[mPlayer->current].clip ) {
|
2005-12-11 18:42:19 +00:00
|
|
|
mPlayer->saveShot(mPlayer->current);
|
|
|
|
}
|
|
|
|
mPlayer->weapons[mPlayer->current].clip = iValue;
|
|
|
|
}
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
void Client_TSHealth_End(void* mValue){
|
2005-12-11 18:42:19 +00:00
|
|
|
edict_t *enemy = mPlayer->pEdict->v.dmg_inflictor;
|
|
|
|
int damage = (int)mPlayer->pEdict->v.dmg_take;
|
2006-03-04 08:16:00 +00:00
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( !damage || !enemy )
|
|
|
|
return;
|
2005-12-11 18:42:19 +00:00
|
|
|
|
|
|
|
int aim = 0;
|
|
|
|
int weapon = 0;
|
|
|
|
mPlayer->pEdict->v.dmg_take = 0.0;
|
|
|
|
|
|
|
|
CPlayer* pAttacker = NULL;
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ){
|
2005-12-11 18:42:19 +00:00
|
|
|
pAttacker = GET_PLAYER_POINTER(enemy);
|
|
|
|
weapon = pAttacker->current;
|
|
|
|
aim = pAttacker->aiming;
|
|
|
|
pAttacker->saveHit( mPlayer , weapon , damage, aim );
|
|
|
|
}
|
2006-02-26 06:42:48 +00:00
|
|
|
else {
|
2005-12-11 18:42:19 +00:00
|
|
|
char szCName[16];
|
|
|
|
strcpy( szCName,STRING(enemy->v.classname) );
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( szCName[0] == 'g' ) {
|
|
|
|
if ( enemy->v.owner && enemy->v.owner->v.flags & (FL_CLIENT | FL_FAKECLIENT) ){
|
2005-12-11 18:42:19 +00:00
|
|
|
pAttacker = GET_PLAYER_POINTER(enemy->v.owner);
|
|
|
|
weapon = 24; // grenade
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( pAttacker != mPlayer )
|
|
|
|
pAttacker->saveHit( mPlayer , weapon , damage, 0 );
|
2005-12-11 18:42:19 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-26 06:42:48 +00:00
|
|
|
else if ( szCName[0] == 'k' ) {
|
2006-03-04 08:16:00 +00:00
|
|
|
edict_t *pOwner = (edict_t *)*( (int*)enemy->pvPrivateData + gKnifeOffset );
|
2005-12-11 18:42:19 +00:00
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( FNullEnt( (edict_t*)pOwner) )
|
|
|
|
return;
|
2006-03-04 08:16:00 +00:00
|
|
|
|
|
|
|
pAttacker = GET_PLAYER_POINTER( pOwner );
|
2005-12-11 18:42:19 +00:00
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
weapon = 37; // throwing knife
|
2006-03-04 08:16:00 +00:00
|
|
|
aim = pAttacker ? pAttacker->aiming : 0;
|
2021-12-02 21:47:57 +00:00
|
|
|
if (pAttacker)
|
|
|
|
pAttacker->saveHit( mPlayer , weapon , damage, aim );
|
2005-12-11 18:42:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !pAttacker ) pAttacker = mPlayer;
|
|
|
|
|
|
|
|
int TA = 0;
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( mPlayer->teamId || is_theonemode ){
|
|
|
|
if ( (mPlayer->teamId == pAttacker->teamId ) && (mPlayer != pAttacker) )
|
|
|
|
TA = 1;
|
2005-12-11 18:42:19 +00:00
|
|
|
}
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( weaponData[weapon].melee )
|
|
|
|
pAttacker->saveShot(weapon);
|
2005-12-11 18:42:19 +00:00
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
MF_ExecuteForward(g_damage_info,
|
|
|
|
(cell)pAttacker->index,
|
|
|
|
(cell)mPlayer->index,
|
|
|
|
(cell)damage,
|
|
|
|
(cell)weapon,
|
|
|
|
(cell)aim,
|
|
|
|
(cell)TA
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( mPlayer->IsAlive() )
|
|
|
|
return;
|
2005-12-11 18:42:19 +00:00
|
|
|
|
|
|
|
// death
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( (int)pAttacker->pEdict->v.frags - pAttacker->frags == 0 ) // nie bylo fraga ? jest tak dla bledu z granatem ..
|
|
|
|
pAttacker = mPlayer;
|
2005-12-11 18:42:19 +00:00
|
|
|
|
|
|
|
int killFlags = 0;
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( !TA && mPlayer!=pAttacker ) {
|
2005-12-11 18:42:19 +00:00
|
|
|
int sflags = pAttacker->pEdict->v.iuser4;
|
|
|
|
|
|
|
|
int stuntKill = 0;
|
|
|
|
int slpos = 0;
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( weapon == 24 ) // dla granata nie liczy sie sflags
|
|
|
|
; // nic nie rob..
|
|
|
|
else if ( sflags == 20 || sflags == 1028 || sflags == 2052 )
|
|
|
|
stuntKill = 1;
|
|
|
|
else if ( sflags == 36)
|
|
|
|
slpos = 1;
|
2005-12-11 18:42:19 +00:00
|
|
|
|
|
|
|
int doubleKill = 0;
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( gpGlobals->time - pAttacker->lastKill < 1.0 )
|
|
|
|
doubleKill = 1;
|
2005-12-11 18:42:19 +00:00
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( stuntKill )
|
|
|
|
killFlags |= TSKF_STUNTKILL;
|
2005-12-11 18:42:19 +00:00
|
|
|
|
|
|
|
pAttacker->lastKill = gpGlobals->time;
|
|
|
|
|
|
|
|
pAttacker->killingSpree++;
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( pAttacker->killingSpree == 10 )
|
|
|
|
pAttacker->is_specialist = 1;
|
2005-12-11 18:42:19 +00:00
|
|
|
|
|
|
|
pAttacker->lastFrag = weaponData[weapon].bonus + 2*stuntKill;
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( doubleKill ){
|
2005-12-11 18:42:19 +00:00
|
|
|
pAttacker->lastFrag *= 2;
|
|
|
|
killFlags |= TSKF_DOUBLEKILL;
|
|
|
|
}
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( pAttacker->is_specialist ){
|
2005-12-11 18:42:19 +00:00
|
|
|
pAttacker->lastFrag *= 2;
|
|
|
|
killFlags |= TSKF_ISSPEC;
|
|
|
|
}
|
|
|
|
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( mPlayer->is_specialist ){
|
2005-12-11 18:42:19 +00:00
|
|
|
pAttacker->lastFrag += 5;
|
|
|
|
killFlags |= TSKF_KILLEDSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
pAttacker->frags += pAttacker->lastFrag;
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( pAttacker->frags != pAttacker->pEdict->v.frags ){
|
|
|
|
// moze to sliding kill ?
|
|
|
|
if ( slpos )
|
|
|
|
killFlags |= TSKF_SLIDINGKILL;
|
|
|
|
else // moze to kung fu z bronia ?
|
|
|
|
weapon = 36;
|
2005-12-11 18:42:19 +00:00
|
|
|
pAttacker->lastFrag += (int)pAttacker->pEdict->v.frags - pAttacker->frags;
|
|
|
|
pAttacker->frags = (int)pAttacker->pEdict->v.frags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pAttacker->killFlags = killFlags;
|
|
|
|
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
|
2006-02-26 06:42:48 +00:00
|
|
|
MF_ExecuteForward(g_death_info,
|
|
|
|
(cell)pAttacker->index,
|
|
|
|
(cell)mPlayer->index,
|
|
|
|
(cell)weapon,
|
|
|
|
(cell)aim,
|
|
|
|
(cell)TA);
|
2005-12-11 18:42:19 +00:00
|
|
|
}
|
|
|
|
|
2006-02-26 08:11:25 +00:00
|
|
|
void Client_TSState(void* mValue)
|
|
|
|
{
|
|
|
|
mPlayer->oldstate = mPlayer->state;
|
|
|
|
mPlayer->checkstate = 1;
|
|
|
|
mPlayer->state = *(int*)mValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client_WStatus(void* mValue)
|
|
|
|
{
|
2006-02-26 06:42:48 +00:00
|
|
|
switch(mState++){
|
2005-12-11 18:42:19 +00:00
|
|
|
case 1:
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( !*(int*)mValue ){
|
2005-12-11 18:42:19 +00:00
|
|
|
mPlayer->current = 36; // fix dla wytraconej broni
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-26 08:11:25 +00:00
|
|
|
void Client_TSCash(void* mValue)
|
|
|
|
{
|
2005-12-11 18:42:19 +00:00
|
|
|
mPlayer->money = *(int*)mValue;
|
|
|
|
}
|
|
|
|
|
2006-02-26 08:11:25 +00:00
|
|
|
void Client_TSSpace(void* mValue)
|
|
|
|
{
|
2005-12-11 18:42:19 +00:00
|
|
|
mPlayer->space = *(int*)mValue;
|
|
|
|
}
|
|
|
|
|
2006-02-26 08:11:25 +00:00
|
|
|
void Client_PwUp(void* mValue)
|
|
|
|
{
|
2005-12-11 18:42:19 +00:00
|
|
|
static int iPwType;
|
|
|
|
switch(mState++){
|
|
|
|
case 0:
|
|
|
|
iPwType = *(int*)mValue;
|
2006-02-26 06:42:48 +00:00
|
|
|
switch(iPwType){
|
2005-12-11 18:42:19 +00:00
|
|
|
case TSPWUP_KUNGFU :
|
|
|
|
mPlayer->items |= TSITEM_KUNGFU;
|
|
|
|
break;
|
|
|
|
case TSPWUP_SJUMP:
|
|
|
|
mPlayer->items |= TSITEM_SUPERJUMP;
|
|
|
|
break;
|
|
|
|
default: mPlayer->PwUp = iPwType;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2006-02-26 06:42:48 +00:00
|
|
|
if ( iPwType != TSPWUP_KUNGFU && iPwType != TSPWUP_SJUMP )
|
|
|
|
mPlayer->PwUpValue = *(int*)mValue;
|
2005-12-11 18:42:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-03-04 08:16:00 +00:00
|
|
|
}
|