dod_get_user_weapon added. Compile options for old/new forwards system

This commit is contained in:
Lukasz Wlasinksi 2004-07-30 12:49:11 +00:00
parent 77c887d514
commit 8e23ca757a
8 changed files with 96 additions and 4 deletions

View File

@ -330,6 +330,8 @@ void CMapInfo::Init(){
}
#ifdef FORWARD_OLD_SYSTEM
// *****************************************************
// class Forward
// *****************************************************
@ -369,4 +371,6 @@ void Forward::exec(int p1,int p2){
MF_AmxExec(a->amx, NULL, a->iFunctionIdx, 2,p1, p2);
a = a->next;
}
}
}
#endif

View File

@ -157,6 +157,8 @@ public:
void Init();
};
#ifdef FORWARD_OLD_SYSTEM
// *****************************************************
// class Forward
// *****************************************************
@ -178,5 +180,6 @@ public:
void exec(int p1,int p2,int p3,int p4,int p5);
void exec(int p1,int p2);
};
#endif
#endif // CMISC_H

View File

@ -178,7 +178,29 @@ static cell AMX_NATIVE_CALL get_user_pronestate(AMX *amx, cell *params){
return 0;
}
static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
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 register_forward(AMX *amx, cell *params){ // forward
#ifdef FORWARD_OLD_SYSTEM
int iFunctionIndex;
switch( params[1] ){
case 0:
@ -199,6 +221,7 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
#endif
return 1;
}
@ -214,6 +237,7 @@ AMX_NATIVE_INFO base_Natives[] = {
{ "dod_get_user_score", get_user_score },
{ "dod_get_user_class", get_user_class },
{ "dod_get_user_team", get_user_team },
{ "dod_get_user_weapon", get_user_weapon },
{ "dod_get_map_info", get_map_info },
{ "dod_user_kill", user_kill },

View File

@ -383,13 +383,25 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg
int TA = 0;
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) )
TA = 1;
#ifdef FORWARD_OLD_SYSTEM
g_damage_info.exec( pAtt->index, pVic->index, dmg, weapon, aim, TA );
#else
MF_ExecuteForward( iFDamage,pAtt->index, pVic->index, dmg, weapon, aim, TA );
#endif
if ( pVic->IsAlive() )
return 1;
pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);
#ifdef FORWARD_OLD_SYSTEM
g_death_info.exec( pAtt->index, pVic->index, weapon, aim, TA );
#else
MF_ExecuteForward( iFDeath,pAtt->index, pVic->index, weapon, aim, TA );
#endif
return 1;
}

View File

@ -73,9 +73,19 @@ extern int AxisScore;
extern int gmsgScoreShort;
extern int gmsgPTeam;
#ifdef FORWARD_OLD_SYSTEM
extern Forward g_death_info;
extern Forward g_damage_info;
#else
extern int iFDamage;
extern int iFDeath;
#endif
extern cvar_t* dodstats_maxsize;
extern cvar_t* dodstats_rank;
extern cvar_t* dodstats_reset;

View File

@ -47,9 +47,18 @@ int mPlayerIndex;
int AlliesScore;
int AxisScore;
#ifdef FORWARD_OLD_SYSTEM
Forward g_death_info;
Forward g_damage_info;
#else
int iFDamage;
int iFDeath;
#endif
int gmsgCurWeapon;
int gmsgHealth;
int gmsgResetHUD;
@ -164,9 +173,13 @@ void ServerDeactivate() {
g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("dodstats") ) );
#ifdef FORWARD_OLD_SYSTEM
g_damage_info.clear();
g_death_info.clear();
#endif
// clear custom weapons info
for ( i=DODMAX_WEAPONS-DODMAX_CUSTOMWPNS;i<DODMAX_WEAPONS;i++)
weaponData[i].needcheck = false;
@ -373,3 +386,13 @@ void OnAmxxDetach() {
g_grenades.clear();
g_rank.unloadCalc();
}
#ifndef FORWARD_OLD_SYSTEM
void OnPluginsLoaded(){
iFDeath = MF_RegisterForward("client_death",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
iFDamage = MF_RegisterForward("client_damage",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
}
#endif

View File

@ -21,6 +21,8 @@
// metamod plugin?
#define USE_METAMOD
#define FORWARD_OLD_SYSTEM
// - AMXX Init functions
// Also consider using FN_META_*
// AMXX query
@ -32,7 +34,10 @@
#define FN_AMXX_DETACH OnAmxxDetach
// All plugins loaded
// Do forward functions init here (MF_RegisterForward)
//#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
#ifndef FORWARD_OLD_SYSTEM
#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
#endif
/**** METAMOD ****/
// If your module doesn't use metamod, you may close the file now :)

View File

@ -97,7 +97,6 @@ void Client_CurWeapon(void* mValue){
case 1:
if (!iState) break;
iId = *(int*)mValue;
mPlayer->current = iId;
break;
case 2:
if ( !iState || !isModuleActive() )
@ -106,6 +105,7 @@ void Client_CurWeapon(void* mValue){
if ( weaponData[iId].needcheck ){
iId = get_weaponid(mPlayer);
mPlayer->current = iId;
}
if (iClip > -1) {
if ( mPlayer->current == 17 ){
@ -167,11 +167,22 @@ void Client_Health_End(void* mValue){
TA = 1;
}
#ifdef FORWARD_OLD_SYSTEM
g_damage_info.exec( pAttacker->index, mPlayer->index, damage, weapon, aim, TA );
#else
MF_ExecuteForward( iFDamage,pAttacker->index, mPlayer->index, damage, weapon, aim, TA );
#endif
if ( !mPlayer->IsAlive() ){
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
#ifdef FORWARD_OLD_SYSTEM
g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, TA );
#else
MF_ExecuteForward( iFDeath,pAttacker->index, mPlayer->index, weapon, aim, TA );
#endif
}
}