diff --git a/dlls/ts/tsx/Makefile b/dlls/ts/tsx/Makefile index adc956b1..1a35b52e 100755 --- a/dlls/ts/tsx/Makefile +++ b/dlls/ts/tsx/Makefile @@ -11,7 +11,7 @@ DEBUG_FLAGS = -g -ggdb3 CPP = gcc NAME = tsx_amxx -OBJECTS = amxxmodule.cpp CRank.cpp CMisc.cpp NBase.cpp NRank.cpp usermsg.cpp Utils.cpp moduleconfig.cpp +OBJECTS = amxxmodule.cpp CRank.cpp CMisc.cpp Utils.cpp tsx.cpp StatsNatives.cpp LINK = diff --git a/dlls/ts/tsx/NBase.cpp b/dlls/ts/tsx/NBase.cpp deleted file mode 100755 index 620848e1..00000000 --- a/dlls/ts/tsx/NBase.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (c) 2003-2004 Lukasz Wlasinski - * - * This file is part of TS XMod. - * - * TS XMod 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 2 of the License, or (at - * your option) any later version. - * - * TS XMod 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 TS XMod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#include "amxxmodule.h" -#include "tsx.h" - -static cell AMX_NATIVE_CALL get_weapon_name(AMX *amx, cell *params){ // from id to name 3 params id, name, len - int id = params[1]; - if (id<0 || id>=TSMAX_WEAPONS){ - MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id); - return 0; - } - return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]); -} - -static cell AMX_NATIVE_CALL wpnlog_to_name(AMX *amx, cell *params){ // from log to name - int iLen; - char *log = MF_GetAmxString(amx,params[1],0,&iLen); - int i; - for ( i=1; i=TSMAX_WEAPONS){ - MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id); - return 0; - } - return MF_SetAmxString(amx,params[2],weaponData[id].logname,params[3]); -} - -static cell AMX_NATIVE_CALL is_melee(AMX *amx, cell *params){ - int id = params[1]; - if (id<1 || id>=TSMAX_WEAPONS){ - MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id); - return 0; - } - if ( weaponData[id].melee ) - return 1; - return 0; -} - -static cell AMX_NATIVE_CALL ts_get_user_weapon(AMX *amx, cell *params){ - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( pPlayer->ingame ){ - int wpn = pPlayer->current; - cell *cpTemp = MF_GetAmxAddr(amx,params[2]); - *cpTemp = pPlayer->weapons[wpn].clip; - cpTemp = MF_GetAmxAddr(amx,params[3]); - *cpTemp = pPlayer->weapons[wpn].ammo; - cpTemp = MF_GetAmxAddr(amx,params[4]); - *cpTemp = pPlayer->weapons[wpn].mode; - cpTemp = MF_GetAmxAddr(amx,params[5]); - *cpTemp = pPlayer->weapons[wpn].attach; - return wpn; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){ - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( pPlayer->ingame ){ - int wpn = pPlayer->current; - cell *cpTemp = MF_GetAmxAddr(amx,params[2]); - *cpTemp = pPlayer->weapons[wpn].clip; - cpTemp = MF_GetAmxAddr(amx,params[3]); - *cpTemp = pPlayer->weapons[wpn].ammo; - return wpn; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_user_cash(AMX *amx, cell *params){ - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( pPlayer->ingame ){ - return pPlayer->money; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_user_space(AMX *amx, cell *params){ - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( pPlayer->ingame ){ - return pPlayer->space; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_user_pwup(AMX *amx, cell *params){ - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( pPlayer->ingame ){ - cell *cpTemp = MF_GetAmxAddr(amx,params[2]); - *cpTemp = pPlayer->PwUpValue; - return pPlayer->PwUp; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_user_items(AMX *amx, cell *params){ - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( pPlayer->ingame ){ - return pPlayer->items; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_killingStreak(AMX *amx, cell *params){ - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( pPlayer->ingame ){ - return pPlayer->killingSpree; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_lastFrag(AMX *amx, cell *params){ - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( pPlayer->ingame ){ - return pPlayer->lastFrag; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_killflags(AMX *amx, cell *params){ - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( pPlayer->ingame ){ - return pPlayer->killFlags; - } - return 0; -} - -static cell AMX_NATIVE_CALL give_weapon(AMX *amx, cell *params){ // index,weapon,clips,extra - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( !pPlayer->ingame || !pPlayer->IsAlive() ){ - return 0; - } - - // can he carry this weapon check ? - - string_t item = MAKE_STRING("ts_groundweapon"); - edict_t *pent = CREATE_NAMED_ENTITY( item ); - if ( FNullEnt( pent ) ){ - return 0; - } - - KeyValueData pkvd; - char szTemp[16]; - - sprintf(szTemp,"%d",(int)params[2]); - - pkvd.szClassName = (char *)STRING(pent->v.classname); - pkvd.szKeyName = "tsweaponid"; // weapon - pkvd.szValue = szTemp; - pkvd.fHandled = false; - MDLL_KeyValue(pent, &pkvd); - - pkvd.szClassName = (char *)STRING(pent->v.classname); - pkvd.szKeyName = "wduration"; // duration - pkvd.szValue = "180"; - pkvd.fHandled = false; - MDLL_KeyValue(pent, &pkvd); - - sprintf(szTemp,"%d",(int)params[3]); - - pkvd.szClassName = (char *)STRING(pent->v.classname); - pkvd.szKeyName = "wextraclip"; // clips - pkvd.szValue = szTemp; - pkvd.fHandled = false; - MDLL_KeyValue(pent, &pkvd); - - sprintf(szTemp,"%d",(int)params[4]); - - pkvd.szClassName = (char *)STRING(pent->v.classname); - pkvd.szKeyName = "spawnflags"; // attachements :flashlight,lasersight,scope.. - pkvd.szValue = szTemp; - pkvd.fHandled = false; - MDLL_KeyValue(pent, &pkvd); - -/* - pkvd.szClassName = "ts_groundweapon"; - pkvd.szKeyName = "message"; - pkvd.szValue = ""; - pMDLL_KeyValue(pEntity, &pkvd); -*/ - - MDLL_Spawn(pent); - - pent->v.origin = pPlayer->pEdict->v.origin; - - MDLL_Use(pent, pPlayer->pEdict); - - REMOVE_ENTITY(pent); - - return 1; - -} - -static cell AMX_NATIVE_CALL create_pwup(AMX *amx, cell *params){ // pwup ,origin[3] - - string_t item = MAKE_STRING("ts_powerup"); - edict_t *pent = CREATE_NAMED_ENTITY( item ); - if ( FNullEnt( pent ) ){ - return 0; - } - - KeyValueData pkvd; - char szTemp[16]; - - sprintf(szTemp,"%d",(int)params[1]); - - pkvd.szClassName = (char *)STRING(pent->v.classname); - pkvd.szKeyName = "pwuptype"; // type - pkvd.szValue = szTemp; - pkvd.fHandled = false; - MDLL_KeyValue(pent, &pkvd); - - pkvd.szClassName = (char *)STRING(pent->v.classname); - pkvd.szKeyName = "pwupduration"; // duration - pkvd.szValue = "60"; - pkvd.fHandled = false; - MDLL_KeyValue(pent, &pkvd); - -/* - pkvd.szClassName = (char *)STRING(pent->v.classname); - pkvd.szKeyName = "message"; - pkvd.szValue = ""; - pMDLL_KeyValue(pEntity, &pkvd); -*/ - cell *vInput = MF_GetAmxAddr(amx,params[2]); - - float fNewX = *(float *)((void *)&vInput[0]); - float fNewY = *(float *)((void *)&vInput[1]); - float fNewZ = *(float *)((void *)&vInput[2]); - - vec3_t vNewValue = vec3_t(fNewX, fNewY, fNewZ); - - MDLL_Spawn(pent); - pent->v.origin = vNewValue; - - return ENTINDEX(pent); -} - -// create_pwup -> !wait! -> give_pwup -static cell AMX_NATIVE_CALL give_pwup(AMX *amx, cell *params){ // index,pwupentindex - - edict_t* pent = INDEXENT(params[2]); - if ( FNullEnt( pent ) || strcmp("ts_powerup",STRING(pent->v.classname))!=0 ){ - return 0; - } - - int id = params[1]; - CHECK_PLAYER(id); - CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); - if ( !pPlayer->ingame || !pPlayer->IsAlive() ){ - REMOVE_ENTITY(pent); - return 0; - } - - pent->v.origin = pPlayer->pEdict->v.origin; - - MDLL_Touch(pent, pPlayer->pEdict); - - REMOVE_ENTITY(pent); - - return 1; - -} - -static cell AMX_NATIVE_CALL ts_setup(AMX *amx, cell *params){ // index,pwupentindex - gKnifeOffset = params[1]; - return 1; - -} - -static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){ - return TSMAX_WEAPONS; -} - -static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){ - return 8; -} - -static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params){ - int weapon = params[1]; - if ( weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS ){ - return 0; - } - return 1; -} - -AMX_NATIVE_INFO base_Natives[] = { - - { "xmod_get_wpnname", get_weapon_name }, - { "xmod_get_wpnlogname", get_weapon_logname }, - { "xmod_is_melee_wpn", is_melee }, - { "xmod_get_maxweapons", get_maxweapons }, - { "xmod_get_stats_size", get_stats_size }, - { "xmod_is_custom_wpn", is_custom }, - - { "ts_wpnlogtoname", wpnlog_to_name }, - { "ts_wpnlogtoid", wpnlog_to_id }, - - { "ts_getuserwpn", ts_get_user_weapon }, - { "ts_getusercash", get_user_cash }, - { "ts_getuserspace", get_user_space }, - { "ts_getuserpwup",get_user_pwup }, - { "ts_getuseritems",get_user_items }, - { "ts_getkillingstreak",get_killingStreak }, - { "ts_getuserlastfrag",get_lastFrag }, - { "ts_getuserkillflags",get_killflags }, - - { "ts_giveweapon",give_weapon }, - { "ts_createpwup",create_pwup }, - { "ts_givepwup",give_pwup }, - - { "ts_setpddata",ts_setup }, - - //**************************************** - { "get_weaponname", get_weapon_name }, - { "get_user_weapon", get_user_weapon }, - - //"*******************" - { NULL, NULL } -}; \ No newline at end of file diff --git a/dlls/ts/tsx/NRank.cpp b/dlls/ts/tsx/NRank.cpp deleted file mode 100755 index bcf530f1..00000000 --- a/dlls/ts/tsx/NRank.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/* - * TFCX - * Copyright (c) 2004 Lukasz Wlasinski - * - * - * 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 2 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, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - - -#include "amxxmodule.h" -#include "tsx.h" - -static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param */ -{ - int index = params[1]; - CHECK_PLAYERRANGE(index); - int attacker = params[2]; - CHECK_PLAYERRANGE(attacker); - CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); - if (pPlayer->attackers[attacker].hits){ - cell *cpStats = MF_GetAmxAddr(amx,params[3]); - cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]); - CPlayer::PlayerWeapon* stats = &pPlayer->attackers[attacker]; - cpStats[0] = stats->kills; - cpStats[1] = stats->deaths; - cpStats[2] = stats->hs; - cpStats[3] = stats->tks; - cpStats[4] = stats->shots; - cpStats[5] = stats->hits; - cpStats[6] = stats->damage; - for(int i = 1; i < 8; ++i) - cpBodyHits[i] = stats->bodyHits[i]; - if (params[6] && attacker && stats->name ) - MF_SetAmxString(amx,params[5],stats->name,params[6]); - return 1; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param */ -{ - int index = params[1]; - CHECK_PLAYERRANGE(index); - int victim = params[2]; - CHECK_PLAYERRANGE(victim); - CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); - if (pPlayer->victims[victim].hits){ - cell *cpStats = MF_GetAmxAddr(amx,params[3]); - cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]); - CPlayer::PlayerWeapon* stats = &pPlayer->victims[victim]; - cpStats[0] = stats->kills; - cpStats[1] = stats->deaths; - cpStats[2] = stats->hs; - cpStats[3] = stats->tks; - cpStats[4] = stats->shots; - cpStats[5] = stats->hits; - cpStats[6] = stats->damage; - for(int i = 1; i < 8; ++i) - cpBodyHits[i] = stats->bodyHits[i]; - if (params[6] && victim && stats->name) - MF_SetAmxString(amx,params[5],stats->name,params[6]); - return 1; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param */ // DEC-Weapon (round) stats (end) -{ - int index = params[1]; - CHECK_PLAYERRANGE(index); - int weapon = params[2]; - if (weapon<0||weapon>=TSMAX_WEAPONS){ - MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon); - return 0; - } - CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); - if (pPlayer->weaponsRnd[weapon].shots){ - cell *cpStats = MF_GetAmxAddr(amx,params[3]); - cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]); - Stats* stats = &pPlayer->weaponsRnd[weapon]; - cpStats[0] = stats->kills; - cpStats[1] = stats->deaths; - cpStats[2] = stats->hs; - cpStats[3] = stats->tks; - cpStats[4] = stats->shots; - cpStats[5] = stats->hits; - cpStats[6] = stats->damage; - for(int i = 1; i < 8; ++i) - cpBodyHits[i] = stats->bodyHits[i]; - return 1; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param */ -{ - int index = params[1]; - CHECK_PLAYERRANGE(index); - int weapon = params[2]; - if (weapon<0||weapon>=TSMAX_WEAPONS){ - MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon); - return 0; - } - CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); - if (pPlayer->weapons[weapon].shots){ - cell *cpStats = MF_GetAmxAddr(amx,params[3]); - cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]); - CPlayer::PlayerWeapon* stats = &pPlayer->weapons[weapon]; - cpStats[0] = stats->kills; - cpStats[1] = stats->deaths; - cpStats[2] = stats->hs; - cpStats[3] = stats->tks; - cpStats[4] = stats->shots; - cpStats[5] = stats->hits; - cpStats[6] = stats->damage; - for(int i = 1; i < 8; ++i) - cpBodyHits[i] = stats->bodyHits[i]; - return 1; - } - return 0; -} - -static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param */ -{ - int index = params[1]; - CHECK_PLAYERRANGE(index); - GET_PLAYER_POINTER_I(index)->restartStats(); - return 1; -} - -static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */ -{ - int index = params[1]; - CHECK_PLAYERRANGE(index); - CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); - if ( pPlayer->rank ){ - cell *cpStats = MF_GetAmxAddr(amx,params[2]); - cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]); - cpStats[0] = pPlayer->rank->kills; - cpStats[1] = pPlayer->rank->deaths; - cpStats[2] = pPlayer->rank->hs; - cpStats[3] = pPlayer->rank->tks; - cpStats[4] = pPlayer->rank->shots; - cpStats[5] = pPlayer->rank->hits; - cpStats[6] = pPlayer->rank->damage; - cpStats[7] = pPlayer->rank->getPosition(); - for(int i = 1; i < 8; ++i) - cpBodyHits[i] = pPlayer->rank->bodyHits[i]; - return pPlayer->rank->getPosition(); - } - return 0; - -} - -static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param */ -{ - int index = params[1]; - CHECK_PLAYERRANGE(index); - CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); - if (pPlayer->rank){ - cell *cpStats = MF_GetAmxAddr(amx,params[2]); - cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]); - cpStats[0] = pPlayer->life.kills; - cpStats[1] = pPlayer->life.deaths; - cpStats[2] = pPlayer->life.hs; - cpStats[3] = pPlayer->life.tks; - cpStats[4] = pPlayer->life.shots; - cpStats[5] = pPlayer->life.hits; - cpStats[6] = pPlayer->life.damage; - for(int i = 1; i < 8; ++i) - cpBodyHits[i] = pPlayer->life.bodyHits[i]; - return 1; - } - return 0; -} - -static cell AMX_NATIVE_CALL get_stats(AMX *amx, cell *params) /* 3 param */ -{ - - int index = params[1] + 1; - - for(RankSystem::iterator a = g_rank.front(); a ;--a){ - if ((*a).getPosition() == index) { - cell *cpStats = MF_GetAmxAddr(amx,params[2]); - cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]); - cpStats[0] = (*a).kills; - cpStats[1] = (*a).deaths; - cpStats[2] = (*a).hs; - cpStats[3] = (*a).tks; - cpStats[4] = (*a).shots; - cpStats[5] = (*a).hits; - cpStats[6] = (*a).damage; - cpStats[7] = (*a).getPosition(); - MF_SetAmxString(amx,params[4],(*a).getName(),params[5]); - for(int i = 1; i < 8; ++i) - cpBodyHits[i] = (*a).bodyHits[i]; - return --a ? index : 0; - } - } - - return 0; -} - -static cell AMX_NATIVE_CALL get_statsnum(AMX *amx, cell *params) -{ - return g_rank.getRankNum(); -} - - -static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logname,melee=0 - int i; - bool bFree = false; - for ( i=TSMAX_WEAPONS-TSMAX_CUSTOMWPNS;i 7 ){ - MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim); - return 0; - } - - CPlayer* pAtt = GET_PLAYER_POINTER_I(att); - CPlayer* pVic = GET_PLAYER_POINTER_I(vic); - - pVic->pEdict->v.dmg_inflictor = NULL; - pAtt->saveHit( pVic , weapon , dmg, aim ); - - if ( !pAtt ) pAtt = pVic; - int TA = 0; - if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) ) - TA = 1; - MF_ExecuteForward(g_damage_info, pAtt->index, pVic->index, dmg, weapon, aim, TA ); - - if ( pVic->IsAlive() ) - return 1; - - pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA); - MF_ExecuteForward(g_death_info, pAtt->index, pVic->index, weapon, aim, TA ); - - return 1; -} - -static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid - int index = params[2]; - CHECK_PLAYERRANGE(index); - - int weapon = params[1]; - if ( weapon < TSMAX_WEAPONS-TSMAX_CUSTOMWPNS ){ - MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon); - return 0; - } - - CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); - pPlayer->saveShot(weapon); - - return 1; -} - -static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params) -{ - return 1; -} - -AMX_NATIVE_INFO stats_Natives[] = { - { "get_stats", get_stats}, - { "get_statsnum", get_statsnum}, - { "get_user_astats", get_user_astats }, - { "get_user_rstats", get_user_rstats }, - { "get_user_lstats", get_user_rstats }, // for backward compatibility - { "get_user_stats", get_user_stats }, - { "get_user_vstats", get_user_vstats }, - { "get_user_wrstats", get_user_wrstats}, // DEC-Weapon(Round) Stats - { "get_user_wstats", get_user_wstats}, - { "reset_user_wstats", reset_user_wstats }, - - // Custom Weapon Support - { "custom_weapon_add", register_cwpn }, - { "custom_weapon_dmg", cwpn_dmg }, - { "custom_weapon_shot", cwpn_shot }, - { "register_statsfwd",register_forward }, - - { NULL, NULL } -}; - diff --git a/dlls/ts/tsx/moduleconfig.cpp b/dlls/ts/tsx/moduleconfig.cpp deleted file mode 100755 index 8c049357..00000000 --- a/dlls/ts/tsx/moduleconfig.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2003-2004 Lukasz Wlasinski - * - * This file is part of TS XMod. - * - * TS XMod 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 2 of the License, or (at - * your option) any later version. - * - * TS XMod 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 TS XMod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#include "tsx.h" - -funEventCall modMsgsEnd[MAX_REG_MSGS]; -funEventCall modMsgs[MAX_REG_MSGS]; -void (*function)(void*); -void (*endfunction)(void*); -CPlayer* mPlayer; -int mPlayerIndex; -int mState; -CPlayer players[33]; - -bool is_theonemode; -bool rankBots; - -int g_death_info; -int g_damage_info; - -int gKnifeOffset; - -int gmsgResetHUD; -int gmsgWeaponInfo; -int gmsgClipInfo; -int gmsgScoreInfo; -int gmsgTSHealth; - -int gmsgWStatus; -int gmsgTSCash; -int gmsgTSSpace; -int gmsgPwUp; - -RankSystem g_rank; - -cvar_t init_tsstats_maxsize ={"tsstats_maxsize","3500", 0 , 3500.0 }; -cvar_t init_tsstats_reset ={"tsstats_reset","0"}; -cvar_t init_tsstats_rank ={"tsstats_rank","0"}; -cvar_t *tsstats_rankbots; -cvar_t *tsstats_pause; - -cvar_t init_tsstats_rankbots ={"tsstats_rankbots","1"}; -cvar_t init_tsstats_pause = {"tsstats_pause","0"}; -cvar_t *tsstats_maxsize; -cvar_t *tsstats_reset; -cvar_t *tsstats_rank; - -struct sUserMsg { - const char* name; - int* id; - funEventCall func; - bool endmsg; -} g_user_msg[] = { - { "ResetHUD",&gmsgResetHUD,Client_ResetHUD_End,true }, - { "WeaponInfo",&gmsgWeaponInfo,Client_WeaponInfo,false }, - { "ClipInfo",&gmsgClipInfo,Client_ClipInfo,false }, - { "ScoreInfo",&gmsgScoreInfo,Client_ScoreInfo,false }, - { "TSHealth",&gmsgTSHealth,Client_TSHealth_End,true }, - - { "WStatus",&gmsgWStatus,Client_WStatus,false }, - { "TSCash",&gmsgTSCash,Client_TSCash,false }, - { "TSSpace",&gmsgTSSpace,Client_TSSpace,false }, - { "PwUp",&gmsgPwUp,Client_PwUp,false}, - - { 0,0,0,false } -}; - -const char* get_localinfo( const char* name , const char* def = 0 ) -{ - const char* b = LOCALINFO( (char*)name ); - if (((b==0)||(*b==0)) && def ) - SET_LOCALINFO((char*)name,(char*)(b = def) ); - return b; -} - -int RegUserMsg_Post(const char *pszName, int iSize){ - for (int i = 0; g_user_msg[ i ].name; ++i ){ - if ( !*g_user_msg[i].id && strcmp( g_user_msg[ i ].name , pszName ) == 0 ){ - int id = META_RESULT_ORIG_RET( int ); - - *g_user_msg[ i ].id = id; - - if ( g_user_msg[ i ].endmsg ) - modMsgsEnd[ id ] = g_user_msg[ i ].func; - else - modMsgs[ id ] = g_user_msg[ i ].func; - - break; - } - } - - RETURN_META_VALUE(MRES_IGNORED, 0); -} - -void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){ - - is_theonemode = (int)CVAR_GET_FLOAT("mp_theonemode") ? true:false; - - rankBots = (int)tsstats_rankbots->value ? true:false; - - for( int i = 1; i <= gpGlobals->maxClients; ++i ) - GET_PLAYER_POINTER_I(i)->Init( i , pEdictList + i ); - - RETURN_META(MRES_IGNORED); -} - -void PlayerPreThink_Post( edict_t *pEntity ) { - CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); - - if ( !isModuleActive() ) // stats only - return; - - if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time && pPlayer->ingame){ - pPlayer->clearStats = 0.0f; - pPlayer->rank->updatePosition( &pPlayer->life ); - pPlayer->restartStats(false); - } - RETURN_META(MRES_IGNORED); -} - -void ServerDeactivate() -{ - int i; - for(i = 1;i<=gpGlobals->maxClients; ++i){ - CPlayer *pPlayer = GET_PLAYER_POINTER_I(i); - if (pPlayer->rank) pPlayer->Disconnect(); - } - - if ( (g_rank.getRankNum() >= (int)tsstats_maxsize->value) || ((int)tsstats_reset->value == 1) ) { - CVAR_SET_FLOAT("tsstats_reset",0.0); - g_rank.clear(); - } - - g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("tsstats") ) ); - - // clear custom weapons info - for ( i=TSMAX_WEAPONS-TSMAX_CUSTOMWPNS;iConnect(pszAddress); - RETURN_META_VALUE(MRES_IGNORED, TRUE); -} - -void ClientDisconnect( edict_t *pEntity ) { - CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); - if (pPlayer->ingame) pPlayer->Disconnect(); - RETURN_META(MRES_IGNORED); -} - -void ClientPutInServer_Post( edict_t *pEntity ) { - GET_PLAYER_POINTER(pEntity)->PutInServer(); - RETURN_META(MRES_IGNORED); -} - -void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) { - CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); - const char* name = INFOKEY_VALUE(infobuffer,"name"); - const char* oldname = STRING(pEntity->v.netname); - - if ( pPlayer->ingame ){ - if ( strcmp(oldname,name) ) { - if (!tsstats_rank->value) - pPlayer->rank = g_rank.findEntryInRank( name, name ); - else - pPlayer->rank->setName( name ); - } - } - else if ( pPlayer->IsBot() ) { - pPlayer->PutInServer(); - } - - RETURN_META(MRES_IGNORED); -} - -void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) { - if (ed){ - mPlayerIndex = ENTINDEX(ed); - mPlayer = GET_PLAYER_POINTER_I(mPlayerIndex); - } else { - mPlayerIndex = 0; - mPlayer = NULL; - } - mState = 0; - if ( msg_type < 0 || msg_type >= MAX_REG_MSGS ) - msg_type = 0; - function=modMsgs[msg_type]; - endfunction=modMsgsEnd[msg_type]; - RETURN_META(MRES_IGNORED); -} - -void MessageEnd_Post(void) { - if (endfunction) (*endfunction)(NULL); - RETURN_META(MRES_IGNORED); -} - -void WriteByte_Post(int iValue) { - if (function) (*function)((void *)&iValue); - RETURN_META(MRES_IGNORED); -} - -void WriteChar_Post(int iValue) { - if (function) (*function)((void *)&iValue); - RETURN_META(MRES_IGNORED); -} - -void WriteShort_Post(int iValue) { - if (function) (*function)((void *)&iValue); - RETURN_META(MRES_IGNORED); -} - -void WriteLong_Post(int iValue) { - if (function) (*function)((void *)&iValue); - RETURN_META(MRES_IGNORED); -} - -void WriteAngle_Post(float flValue) { - if (function) (*function)((void *)&flValue); - RETURN_META(MRES_IGNORED); -} - -void WriteCoord_Post(float flValue) { - if (function) (*function)((void *)&flValue); - RETURN_META(MRES_IGNORED); -} - -void WriteString_Post(const char *sz) { - if (function) (*function)((void *)sz); - RETURN_META(MRES_IGNORED); -} - -void WriteEntity_Post(int iValue) { - if (function) (*function)((void *)&iValue); - RETURN_META(MRES_IGNORED); -} - -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) )&& - e&&(e->v.flags& (FL_CLIENT | FL_FAKECLIENT) )){ - GET_PLAYER_POINTER(e)->aiming = ptr->iHitgroup; - } - RETURN_META(MRES_IGNORED); -} - -void OnMetaAttach() { - - CVAR_REGISTER (&init_tsstats_maxsize); - CVAR_REGISTER (&init_tsstats_reset); - CVAR_REGISTER (&init_tsstats_rank); - tsstats_maxsize=CVAR_GET_POINTER(init_tsstats_maxsize.name); - tsstats_reset=CVAR_GET_POINTER(init_tsstats_reset.name); - tsstats_rank=CVAR_GET_POINTER(init_tsstats_rank.name); - - CVAR_REGISTER (&init_tsstats_rankbots); - CVAR_REGISTER (&init_tsstats_pause); - tsstats_rankbots = CVAR_GET_POINTER(init_tsstats_rankbots.name); - tsstats_pause = CVAR_GET_POINTER(init_tsstats_pause.name); - -} - -void OnAmxxAttach() { - - gKnifeOffset = TSKNIFE_OFFSET; - - MF_AddNatives( stats_Natives ); - //TSFun does these now - //MF_AddNatives( base_Natives ); - - const char* path = get_localinfo("tsstats_score","addons/amxmodx/data/tsstats.amxx"); - if ( path && *path ) - { - char error[128]; - g_rank.loadCalc( MF_BuildPathname("%s",path) , error ); - } - if ( !g_rank.begin() ) - { - g_rank.loadRank( MF_BuildPathname("%s",get_localinfo("tsstats","addons/amxmodx/data/tsstats.dat") ) ); - } -} - -void OnPluginsLoaded() -{ - g_damage_info = MF_RegisterForward("client_damage", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); - g_death_info = MF_RegisterForward("client_death", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); -} diff --git a/dlls/ts/tsx/tsx.cpp b/dlls/ts/tsx/tsx.cpp index 8224593c..ad4d5408 100644 --- a/dlls/ts/tsx/tsx.cpp +++ b/dlls/ts/tsx/tsx.cpp @@ -30,7 +30,6 @@ */ #include "tsx.h" -#include "StatsNatives.h" #include "UserMsg.h" funEventCall modMsgsEnd[MAX_REG_MSGS]; @@ -293,6 +292,8 @@ void OnMetaAttach() { } + + void OnAmxxAttach() { gKnifeOffset = TSKNIFE_OFFSET; diff --git a/dlls/ts/tsx/tsx.h b/dlls/ts/tsx/tsx.h index e2870f1a..4ddad6f2 100755 --- a/dlls/ts/tsx/tsx.h +++ b/dlls/ts/tsx/tsx.h @@ -45,8 +45,8 @@ #define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) #endif -//extern AMX_NATIVE_INFO stats_Natives[]; -extern AMX_NATIVE_INFO base_Natives[]; +extern AMX_NATIVE_INFO stats_Natives[]; +//extern AMX_NATIVE_INFO base_Natives[]; typedef void (*funEventCall)(void*); extern funEventCall modMsgsEnd[MAX_REG_MSGS]; diff --git a/dlls/ts/tsx/usermsg.cpp b/dlls/ts/tsx/usermsg.cpp deleted file mode 100755 index cabd72cc..00000000 --- a/dlls/ts/tsx/usermsg.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2003-2004 Lukasz Wlasinski - * - * This file is part of TS XMod. - * - * TS XMod 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 2 of the License, or (at - * your option) any later version. - * - * TS XMod 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 TS XMod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#include "amxxmodule.h" -#include "tsx.h" - - -void Client_ResetHUD_End(void* mValue){ - if ( mPlayer->IsAlive() ){ // ostatni przed spawn'em - mPlayer->clearStats = gpGlobals->time + 0.25f; // teraz czysc statystyki - } - else { // dalej "dead" nie czysc statystyk! - mPlayer->items = 0; - mPlayer->is_specialist = 0; - mPlayer->killingSpree = 0; - mPlayer->killFlags = 0; - mPlayer->frags = (int)mPlayer->pEdict->v.frags; - /* - fix dla user_kill() z addfrag - oraz self kills - */ - } -} - -void Client_ScoreInfo(void* mValue){ - static int iId; - switch(mState++){ - case 0: - iId = *(int*)mValue; - break; - case 4: - if ( iId && (iId < 33) ){ - GET_PLAYER_POINTER_I(iId)->teamId = *(int*)mValue; - } - break; - } -} - -void Client_WeaponInfo(void* mValue){ - static int wpn; - switch(mState++){ - 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; - } -} - -void Client_ClipInfo(void* mValue){ - int iValue = *(int*)mValue; - if ( iValue < mPlayer->weapons[mPlayer->current].clip ) { - mPlayer->saveShot(mPlayer->current); - } - mPlayer->weapons[mPlayer->current].clip = iValue; -} - -void Client_TSHealth_End(void* mValue){ - edict_t *enemy = mPlayer->pEdict->v.dmg_inflictor; - int damage = (int)mPlayer->pEdict->v.dmg_take; - if ( !damage || !enemy ) - return; - - int aim = 0; - int weapon = 0; - mPlayer->pEdict->v.dmg_take = 0.0; - - CPlayer* pAttacker = NULL; - if ( enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ){ - pAttacker = GET_PLAYER_POINTER(enemy); - weapon = pAttacker->current; - aim = pAttacker->aiming; - pAttacker->saveHit( mPlayer , weapon , damage, aim ); - } - else { - char szCName[16]; - strcpy( szCName,STRING(enemy->v.classname) ); - - if ( szCName[0] == 'g' ) { - if ( enemy->v.owner && enemy->v.owner->v.flags & (FL_CLIENT | FL_FAKECLIENT) ){ - pAttacker = GET_PLAYER_POINTER(enemy->v.owner); - weapon = 24; // grenade - if ( pAttacker != mPlayer ) - pAttacker->saveHit( mPlayer , weapon , damage, 0 ); - } - } - else if ( szCName[0] == 'k' ) { - int pOwner = *( (int*)enemy->pvPrivateData + gKnifeOffset ); - - if ( FNullEnt( (edict_t*)pOwner) ) - return; - pAttacker = GET_PLAYER_POINTER( (edict_t*)pOwner ); - - weapon = 37; // throwing knife - aim = pAttacker->aiming; - pAttacker->saveHit( mPlayer , weapon , damage, aim ); - } - } - if ( !pAttacker ) pAttacker = mPlayer; - - int TA = 0; - if ( mPlayer->teamId || is_theonemode ){ - if ( (mPlayer->teamId == pAttacker->teamId ) && (mPlayer != pAttacker) ) - TA = 1; - } - - if ( weaponData[weapon].melee ) - pAttacker->saveShot(weapon); - - MF_ExecuteForward(g_damage_info, pAttacker->index, mPlayer->index, damage, weapon, aim, TA ); - - if ( mPlayer->IsAlive() ) - return; - - // death - - if ( (int)pAttacker->pEdict->v.frags - pAttacker->frags == 0 ) // nie bylo fraga ? jest tak dla bledu z granatem .. - pAttacker = mPlayer; - - int killFlags = 0; - - if ( !TA && mPlayer!=pAttacker ) { - - int sflags = pAttacker->pEdict->v.iuser4; - - int stuntKill = 0; - int slpos = 0; - - 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; - - int doubleKill = 0; - - if ( gpGlobals->time - pAttacker->lastKill < 1.0 ) - doubleKill = 1; - - if ( stuntKill ) - killFlags |= TSKF_STUNTKILL; - - pAttacker->lastKill = gpGlobals->time; - - pAttacker->killingSpree++; - - if ( pAttacker->killingSpree == 10 ) - pAttacker->is_specialist = 1; - - pAttacker->lastFrag = weaponData[weapon].bonus + 2*stuntKill; - - if ( doubleKill ){ - pAttacker->lastFrag *= 2; - killFlags |= TSKF_DOUBLEKILL; - } - - if ( pAttacker->is_specialist ){ - pAttacker->lastFrag *= 2; - killFlags |= TSKF_ISSPEC; - } - - if ( mPlayer->is_specialist ){ - pAttacker->lastFrag += 5; - killFlags |= TSKF_KILLEDSPEC; - } - - pAttacker->frags += pAttacker->lastFrag; - 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; - 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); - MF_ExecuteForward(g_death_info, pAttacker->index, mPlayer->index, weapon, aim, TA ); - -} - -void Client_WStatus(void* mValue){ - switch(mState++){ - case 1: - if ( !*(int*)mValue ){ - mPlayer->current = 36; // fix dla wytraconej broni - } - break; - } -} - -void Client_TSCash(void* mValue){ - mPlayer->money = *(int*)mValue; -} - -void Client_TSSpace(void* mValue){ - mPlayer->space = *(int*)mValue; -} - -void Client_PwUp(void* mValue){ - static int iPwType; - switch(mState++){ - case 0: - iPwType = *(int*)mValue; - switch(iPwType){ - case TSPWUP_KUNGFU : - mPlayer->items |= TSITEM_KUNGFU; - break; - case TSPWUP_SJUMP: - mPlayer->items |= TSITEM_SUPERJUMP; - break; - default: mPlayer->PwUp = iPwType; - } - break; - case 1: - if ( iPwType != TSPWUP_KUNGFU && iPwType != TSPWUP_SJUMP ) - mPlayer->PwUpValue = *(int*)mValue; - break; - } -} \ No newline at end of file