From 5bf3577d9cb67973f8019d94e088dcee901d234a Mon Sep 17 00:00:00 2001 From: Lukasz Wlasinksi Date: Thu, 5 Aug 2004 01:02:39 +0000 Subject: [PATCH] xmod shared natives --- dlls/csstats2/amxx_package/csstats.inc | 53 +++++++++++++++++++++----- dlls/csstats2/csstats/rank.cpp | 48 ++++++++++++++++++++--- dlls/csstats2/csstats/rank.h | 2 + dlls/csstats2/csstats/usermsg.cpp | 1 + dlls/dod2/dodx/NBase.cpp | 17 +++++++-- dlls/dod2/dodx/NRank.cpp | 2 +- dlls/tfc/tfcx/NBase.cpp | 19 +++++++-- dlls/tfc/tfcx/NRank.cpp | 2 +- dlls/ts/tsx/CMisc.h | 1 + dlls/ts/tsx/NBase.cpp | 34 +++++++++++++++-- dlls/ts/tsx/NRank.cpp | 4 +- dlls/ts/tsx/Utils.cpp | 2 +- dlls/ts/tsx/usermsg.cpp | 4 +- 13 files changed, 159 insertions(+), 30 deletions(-) diff --git a/dlls/csstats2/amxx_package/csstats.inc b/dlls/csstats2/amxx_package/csstats.inc index 3fd58f1f..499adb31 100755 --- a/dlls/csstats2/amxx_package/csstats.inc +++ b/dlls/csstats2/amxx_package/csstats.inc @@ -61,12 +61,6 @@ native get_statsnum(); native get_user_stats2(index,stats[4]); native get_stats2(index,stats[4]); -/* Custom weapons support ( like: gasnades, lasers ) */ -native reg_custom_weapon( wpnname[],melee = 0,logname[]="" ); -native custom_weapon_dmg( weapon, att, vic, damage, hitplace ); -native custom_weapon_shot( weapon,index ); // weapon id , player id -native get_custom_wpnname( weapon,szName[],len ); - /* * Forwards */ @@ -78,7 +72,46 @@ enum { CSF_DEATH, } -/* You must register client_* forwards using register_statsfwd native */ -native register_statsfwd( ftype ) -forward client_damage( attacker,victim,damage,wpnindex,hitplace,TA ); -forward client_death( killer,victim,wpnindex,hitplace,TK ); +/************* Shared Natives Start ********************************/ + +/* Forward types */ +enum { + XMF_DAMAGE = 0, + XMF_DEATH, +} + +/* Use this function to register forwards */ +native register_statsfwd( ftype ); + +/* Function is called after player to player attacks , +* if players were damaged by teammate TA is set to 1 */ +forward client_damage(attacker,victim,damage,wpnindex,hitplace,TA); + +/* Function is called after player death , +* if player was killed by teammate TK is set to 1 */ +forward client_death(killer,victim,wpnindex,hitplace,TK); + +/* Custom Weapon Support */ +/* function will return index of new weapon */ +native custom_weapon_add( wpnname[],melee = 0,logname[]="" ); +/* Function will pass damage done by this custom weapon to stats module and other plugins */ +native custom_weapon_dmg( weapon, att, vic, damage, hitplace=0 ); +/* Function will pass info about custom weapon shot to stats module */ +native custom_weapon_shot( weapon,index ); // weapon id , player id + +/* function will return 1 if true */ +native xmod_is_melee_wpn(wpnindex); + +/* Returns weapon name. */ +native xmod_get_wpnname(wpnindex,name[],len); + +/* Returns weapon logname. */ +native xmod_get_wpnlogname(wpnindex,name[],len); + +/* Returns weapons array size */ +native xmod_get_maxweapons(); + +/* Returns stats array size */ +native xmod_get_stats_size(); + +/************* Shared Natives End ********************************/ diff --git a/dlls/csstats2/csstats/rank.cpp b/dlls/csstats2/csstats/rank.cpp index 2ef40791..2a87a214 100755 --- a/dlls/csstats2/csstats/rank.cpp +++ b/dlls/csstats2/csstats/rank.cpp @@ -290,9 +290,12 @@ static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logna int iLen; char *szName = MF_GetAmxString(amx, params[1], 0, &iLen); + char *szLogName = MF_GetAmxString(amx, params[3], 0, &iLen); strcpy(weaponData[i].name,szName); + strcpy(weaponData[i].logname,szLogName); weaponData[i].ammoSlot = 1; + weaponData[i].melee = params[2] ? true:false; return i; } @@ -370,9 +373,9 @@ static cell AMX_NATIVE_CALL custom_wpn_shot(AMX *amx, cell *params){ // player,w return 1; } -static cell AMX_NATIVE_CALL get_custom_wpnname(AMX *amx, cell *params){ +static cell AMX_NATIVE_CALL get_wpnname(AMX *amx, cell *params){ int id = params[1]; - if (id=MAX_WEAPONS+MAX_CWEAPONS ){ + if (id<0 || id>=MAX_WEAPONS+MAX_CWEAPONS ){ MF_RaiseAmxError(amx,AMX_ERR_NATIVE); MF_PrintSrvConsole("Weapon ID Is Not Valid!\n"); return 0; @@ -380,6 +383,28 @@ static cell AMX_NATIVE_CALL get_custom_wpnname(AMX *amx, cell *params){ return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]); } +static cell AMX_NATIVE_CALL get_wpnlogname(AMX *amx, cell *params){ + int id = params[1]; + if (id<0 || id>=MAX_WEAPONS+MAX_CWEAPONS ){ + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + MF_PrintSrvConsole("Weapon ID Is Not Valid!\n"); + 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<0 || id>=MAX_WEAPONS+MAX_CWEAPONS ){ + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + MF_PrintSrvConsole("Weapon ID Is Not Valid!\n"); + return 0; + } + if ( id = 29 ) + return 1; + return weaponData[id].melee ? 1:0; +} + static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward int iFunctionIndex; switch( params[1] ){ @@ -404,6 +429,14 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward return 1; } +static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){ + return MAX_WEAPONS+MAX_CWEAPONS; +} + +static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){ + return 8; +} + AMX_NATIVE_INFO stats_Natives[] = { { "get_stats", get_stats}, { "get_stats2", get_stats2}, @@ -419,12 +452,17 @@ AMX_NATIVE_INFO stats_Natives[] = { { "reset_user_wstats", reset_user_wstats }, // Custom Weapon Support - { "reg_custom_weapon", register_cwpn }, + { "custom_weapon_add", register_cwpn }, { "custom_weapon_dmg", custom_wpn_dmg }, { "custom_weapon_shot", custom_wpn_shot }, - { "get_custom_wpnname", get_custom_wpnname }, - {"register_statsfwd",register_forward }, + { "xmod_get_wpnname", get_wpnname }, + { "xmod_get_wpnlogname", get_wpnlogname }, + { "xmod_is_melee_wpn", is_melee }, + { "xmod_get_maxweapons", get_maxweapons }, + { "xmod_get_stats_size", get_stats_size }, + + { "register_statsfwd",register_forward }, ///******************* { NULL, NULL } diff --git a/dlls/csstats2/csstats/rank.h b/dlls/csstats2/csstats/rank.h index 6b490df5..5d3391c7 100755 --- a/dlls/csstats2/csstats/rank.h +++ b/dlls/csstats2/csstats/rank.h @@ -19,7 +19,9 @@ extern AMX_NATIVE_INFO stats_Natives[]; struct weaponsVault { char* name; + char* logname; short int ammoSlot; + bool melee; }; extern bool rankBots; diff --git a/dlls/csstats2/csstats/usermsg.cpp b/dlls/csstats2/csstats/usermsg.cpp index 6a4d26a2..5edbbe5f 100755 --- a/dlls/csstats2/csstats/usermsg.cpp +++ b/dlls/csstats2/csstats/usermsg.cpp @@ -46,6 +46,7 @@ void Client_WeaponList(void* mValue){ weaponData[iId].name = wpnPrefix + 7; if ( strcmp( weaponData[iId].name, "hegrenade" ) == 0 ) weaponData[iId].name += 2; + weaponData[iId].logname = weaponData[iId].name; } } } diff --git a/dlls/dod2/dodx/NBase.cpp b/dlls/dod2/dodx/NBase.cpp index bdc1de23..b65282e4 100755 --- a/dlls/dod2/dodx/NBase.cpp +++ b/dlls/dod2/dodx/NBase.cpp @@ -213,13 +213,18 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward return 1; } +static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){ + return DODMAX_WEAPONS; +} + +static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){ + return 9; +} + AMX_NATIVE_INFO base_Natives[] = { - { "dod_get_wpnname", get_weapon_name }, - { "dod_get_wpnlogname", get_weapon_logname }, { "dod_wpnlog_to_name", wpnlog_to_name }, { "dod_wpnlog_to_id", wpnlog_to_id }, - { "dod_is_melee", is_melee }, { "dod_get_team_score", get_team_score }, { "dod_get_user_score", get_user_score }, @@ -230,6 +235,12 @@ AMX_NATIVE_INFO base_Natives[] = { { "dod_user_kill", user_kill }, { "dod_get_pronestate", get_user_pronestate }, + { "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 }, + {"register_statsfwd",register_forward }, ///******************* diff --git a/dlls/dod2/dodx/NRank.cpp b/dlls/dod2/dodx/NRank.cpp index f3915eb0..9558e9d1 100755 --- a/dlls/dod2/dodx/NRank.cpp +++ b/dlls/dod2/dodx/NRank.cpp @@ -439,7 +439,7 @@ AMX_NATIVE_INFO stats_Natives[] = { { "reset_user_wstats", reset_user_wstats }, // Custom Weapon Support - { "reg_custom_weapon", register_cwpn }, // name,melee,logname + { "custom_weapon_add", register_cwpn }, // name,melee,logname { "custom_weapon_dmg", cwpn_dmg }, { "custom_weapon_shot", cwpn_shot }, diff --git a/dlls/tfc/tfcx/NBase.cpp b/dlls/tfc/tfcx/NBase.cpp index 6ce158b1..b2779c80 100755 --- a/dlls/tfc/tfcx/NBase.cpp +++ b/dlls/tfc/tfcx/NBase.cpp @@ -267,6 +267,8 @@ static cell AMX_NATIVE_CALL TFC_GetWeaponBAmmo(AMX *amx, cell *params) { case TFC_WPN_GASGRENADE: case TFC_WPN_EMPGRENADE: return *( (int*)pPlayer->pEdict->pvPrivateData + PD_AMMO_NADE2); + + break; default : return 0; @@ -415,6 +417,14 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward return 1; } +static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){ + return TFCMAX_WEAPONS; +} + +static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){ + return 8; +} + // Native list. AMX_NATIVE_INFO base_Natives[] = { {"tfc_setmodel", TFC_SetModel}, @@ -423,10 +433,13 @@ AMX_NATIVE_INFO base_Natives[] = { {"tfc_getbammo", TFC_GetBAmmo}, {"tfc_getweaponbammo", TFC_GetWeaponBAmmo}, {"tfc_setweaponbammo", TFC_SetWeaponBAmmo}, - {"tfc_getwpnname", TFC_GetWpnName}, - {"tfc_getwpnlogname", TFC_GetWpnLogName}, - {"tfc_ismelee", TFC_IsMelee}, + {"xmod_get_wpnname", TFC_GetWpnName}, + {"xmod_get_wpnlogname", TFC_GetWpnLogName}, + {"xmod_is_melee_wpn", TFC_IsMelee}, + {"xmod_get_maxweapons", get_maxweapons}, + {"xmod_get_stats_size", get_stats_size}, + {"tfc_userkill" , TFC_UserKill}, {"tfc_setpddata", TFC_SetPDdata }, diff --git a/dlls/tfc/tfcx/NRank.cpp b/dlls/tfc/tfcx/NRank.cpp index 46eff464..7982b558 100755 --- a/dlls/tfc/tfcx/NRank.cpp +++ b/dlls/tfc/tfcx/NRank.cpp @@ -363,7 +363,7 @@ AMX_NATIVE_INFO stats_Natives[] = { { "reset_user_wstats", reset_user_wstats }, // Custom Weapon Support - { "reg_custom_weapon", register_cwpn }, + { "custom_weapon_add", register_cwpn }, { "custom_weapon_dmg", cwpn_dmg }, { "custom_weapon_shot", cwpn_shot }, diff --git a/dlls/ts/tsx/CMisc.h b/dlls/ts/tsx/CMisc.h index 734c3ec3..923dde29 100755 --- a/dlls/ts/tsx/CMisc.h +++ b/dlls/ts/tsx/CMisc.h @@ -83,6 +83,7 @@ struct CPlayer { // int killingSpree; int is_specialist; + int killFlags; int lastFrag; // oblicz ostatni frag, sprawdza czy poprawna jest detekcja broni i bonusow float lastKill; // kiedy ostatni , dla double kill // diff --git a/dlls/ts/tsx/NBase.cpp b/dlls/ts/tsx/NBase.cpp index dbdfb5b8..bd01926b 100755 --- a/dlls/ts/tsx/NBase.cpp +++ b/dlls/ts/tsx/NBase.cpp @@ -186,6 +186,19 @@ static cell AMX_NATIVE_CALL get_lastFrag(AMX *amx, cell *params){ return 0; } +static cell AMX_NATIVE_CALL get_killflags(AMX *amx, cell *params){ + int id = params[1]; + if ( id<1 || id>gpGlobals->maxClients ){ + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + return 0; + } + 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]; if ( id<1 || id>gpGlobals->maxClients ){ @@ -361,12 +374,26 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward 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; +} + + AMX_NATIVE_INFO base_Natives[] = { - { "ts_getwpnname", get_weapon_name }, - { "ts_getwpnlogname", get_weapon_logname }, + + { "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 }, + { "ts_wpnlogtoname", wpnlog_to_name }, { "ts_wpnlogtoid", wpnlog_to_id }, - { "ts_ismelee", is_melee }, + { "ts_getuserwpn", get_user_weapon }, { "ts_getusercash", get_user_cash }, { "ts_getuserspace", get_user_space }, @@ -374,6 +401,7 @@ AMX_NATIVE_INFO base_Natives[] = { { "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 }, diff --git a/dlls/ts/tsx/NRank.cpp b/dlls/ts/tsx/NRank.cpp index ac08a9c4..053270e6 100755 --- a/dlls/ts/tsx/NRank.cpp +++ b/dlls/ts/tsx/NRank.cpp @@ -1,5 +1,5 @@ /* - * TFCX + * TSX * Copyright (c) 2004 Lukasz Wlasinski * * @@ -363,7 +363,7 @@ AMX_NATIVE_INFO stats_Natives[] = { { "reset_user_wstats", reset_user_wstats }, // Custom Weapon Support - { "reg_custom_weapon", register_cwpn }, + { "custom_weapon_add", register_cwpn }, { "custom_weapon_dmg", cwpn_dmg }, { "custom_weapon_shot", cwpn_shot }, diff --git a/dlls/ts/tsx/Utils.cpp b/dlls/ts/tsx/Utils.cpp index fd52f9bf..b349ab4c 100755 --- a/dlls/ts/tsx/Utils.cpp +++ b/dlls/ts/tsx/Utils.cpp @@ -1,5 +1,5 @@ /* - * TFCX + * TSX * Copyright (c) 2004 Lukasz Wlasinski * * diff --git a/dlls/ts/tsx/usermsg.cpp b/dlls/ts/tsx/usermsg.cpp index 57d90e39..90a59227 100755 --- a/dlls/ts/tsx/usermsg.cpp +++ b/dlls/ts/tsx/usermsg.cpp @@ -41,6 +41,7 @@ void Client_ResetHUD_End(void* mValue){ 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 @@ -216,8 +217,9 @@ void Client_TSHealth_End(void* mValue){ } } + pAttacker->killFlags = killFlags; pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA); - g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, killFlags, TA ); + g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, TA ); }