- Added new forwards as well as new stocks

This commit is contained in:
Zor 2006-06-11 21:47:11 +00:00
parent 07e55f3b71
commit 84ec8ef007
8 changed files with 409 additions and 88 deletions

View File

@ -1,5 +1,5 @@
/* /*
* DoDx * DoDx
* Copyright (c) 2004 Lukasz Wlasinski * Copyright (c) 2004 Lukasz Wlasinski
* *
* *
@ -93,6 +93,14 @@ void CPlayer::Disconnect(){
bot = false; bot = false;
savedScore = 0; savedScore = 0;
// Zors
olddeadflag=0;
oldteam=0;
oldplayerclass=0;
is_model_set=false;
body_num=0;
position = 0;
if ( ignoreBots(pEdict) || !isModuleActive() ) // ignore if he is bot and bots rank is disabled or module is paused if ( ignoreBots(pEdict) || !isModuleActive() ) // ignore if he is bot and bots rank is disabled or module is paused
return; return;
@ -108,18 +116,18 @@ void CPlayer::PutInServer(){
return; return;
restartStats(); restartStats();
const char* unique; const char* unique;
const char* name = STRING(pEdict->v.netname); const char* name = STRING(pEdict->v.netname);
switch((int)dodstats_rank->value) { switch((int)dodstats_rank->value) {
case 1: case 1:
if ( (unique = GETPLAYERAUTHID(pEdict)) == 0 ) if ( (unique = GETPLAYERAUTHID(pEdict)) == 0 )
unique = name; // failed to get authid unique = name; // failed to get authid
break; break;
case 2: case 2:
unique = ip; unique = ip;
break; break;
default: default:
unique = name; unique = name;
} }
if ( ( rank = g_rank.findEntryInRank( unique , name ) ) == 0 ) if ( ( rank = g_rank.findEntryInRank( unique , name ) ) == 0 )
@ -153,6 +161,14 @@ void CPlayer::Init( int pi, edict_t* pe )
ingame = false; ingame = false;
bot = false; bot = false;
savedScore = 0; savedScore = 0;
// Zors
olddeadflag=0;
oldteam=0;
oldplayerclass=0;
is_model_set=false;
body_num=0;
position = 0;
} }
void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){ void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
@ -182,13 +198,13 @@ void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
pVictim->weapons[0].deaths++; pVictim->weapons[0].deaths++;
pVictim->life.deaths++; pVictim->life.deaths++;
pVictim->round.deaths++; pVictim->round.deaths++;
pVictim->weaponsLife[vw].deaths++; // DEC-Weapon (life) stats pVictim->weaponsLife[vw].deaths++; // DEC-Weapon (life) stats
pVictim->weaponsLife[0].deaths++; // DEC-Weapon (life) stats pVictim->weaponsLife[0].deaths++; // DEC-Weapon (life) stats
pVictim->weaponsRnd[vw].deaths++; // DEC-Weapon (round) stats pVictim->weaponsRnd[vw].deaths++; // DEC-Weapon (round) stats
pVictim->weaponsRnd[0].deaths++; // DEC-Weapon (round) stats pVictim->weaponsRnd[0].deaths++; // DEC-Weapon (round) stats
int vi = pVictim->index; int vi = pVictim->index;
victims[vi].name = (char*)weaponData[wweapon].name; victims[vi].name = (char*)weaponData[wweapon].name;
victims[vi].deaths++; victims[vi].deaths++;
@ -197,8 +213,8 @@ void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
victims[0].deaths++; victims[0].deaths++;
victims[0].hs += hhs; victims[0].hs += hhs;
victims[0].tks += ttk; victims[0].tks += ttk;
weaponsLife[wweapon].kills++; // DEC-Weapon (life) stats weaponsLife[wweapon].kills++; // DEC-Weapon (life) stats
weaponsLife[wweapon].hs += hhs; // DEC-Weapon (life) stats weaponsLife[wweapon].hs += hhs; // DEC-Weapon (life) stats
weaponsLife[wweapon].tks += ttk; // DEC-Weapon (life) stats weaponsLife[wweapon].tks += ttk; // DEC-Weapon (life) stats
@ -212,7 +228,7 @@ void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
weaponsRnd[0].kills++; // DEC-Weapon (round) stats weaponsRnd[0].kills++; // DEC-Weapon (round) stats
weaponsRnd[0].hs += hhs; // DEC-Weapon (round) stats weaponsRnd[0].hs += hhs; // DEC-Weapon (round) stats
weaponsRnd[0].tks += ttk; // DEC-Weapon (round) stats weaponsRnd[0].tks += ttk; // DEC-Weapon (round) stats
weapons[wweapon].kills++; weapons[wweapon].kills++;
weapons[wweapon].hs += hhs; weapons[wweapon].hs += hhs;
weapons[wweapon].tks += ttk; weapons[wweapon].tks += ttk;
@ -317,11 +333,67 @@ void CPlayer::killPlayer(){
pEdict->v.weapons = 0; pEdict->v.weapons = 0;
} }
void CPlayer::initModel(char* model)
{
newmodel = model;
is_model_set = true;
}
void CPlayer::clearModel()
{
is_model_set = false;
}
bool CPlayer::setModel()
{
if(!ingame || ignoreBots(pEdict))
return false;
if(is_model_set)
{
ENTITY_SET_KEYVALUE(pEdict, "model", newmodel);
pEdict->v.body = body_num;
return true;
}
return false;
}
void CPlayer::setBody(int bn)
{
if(!ingame || ignoreBots(pEdict))
return;
body_num = bn;
return;
}
void CPlayer::checkStatus()
{
if(!ingame || ignoreBots(pEdict))
return;
if(olddeadflag != 0 && pEdict->v.deadflag == 0 && iFSpawnForward != -1)
MF_ExecuteForward(iFSpawnForward, index);
if(oldteam != pEdict->v.team && iFTeamForward != -1)
MF_ExecuteForward(iFTeamForward, index, pEdict->v.team, oldteam);
if(oldplayerclass != pEdict->v.playerclass)
MF_ExecuteForward(iFClassForward, index, pEdict->v.playerclass, oldplayerclass);
olddeadflag = pEdict->v.deadflag;
oldteam = pEdict->v.team;
oldplayerclass = pEdict->v.playerclass;
}
// ***************************************************** // *****************************************************
// class CMapInfo // class CMapInfo
// ***************************************************** // *****************************************************
void CMapInfo::Init(){ void CMapInfo::Init()
{
pEdict = 0; pEdict = 0;
initialized = false; initialized = false;

View File

@ -1,5 +1,5 @@
/* /*
* DoDX * DoDX
* Copyright (c) 2004 Lukasz Wlasinski * Copyright (c) 2004 Lukasz Wlasinski
* *
* *
@ -110,6 +110,24 @@ public:
void restartStats(bool all = true); void restartStats(bool all = true);
void killPlayer(); void killPlayer();
// Zors
int oldteam;
int olddeadflag;
int oldplayerclass;
bool is_model_set;
char* newmodel;
int body_num;
int position;
void initModel(char*);
void clearModel();
bool setModel();
void setBody(int);
void checkStatus();
// Zors
inline bool IsBot(){ inline bool IsBot(){
const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict); const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict);
return ( auth && !strcmp( auth , "BOT" ) ); return ( auth && !strcmp( auth , "BOT" ) );
@ -125,7 +143,7 @@ public:
class Grenades class Grenades
{ {
struct Obj struct Obj
{ {
CPlayer* player; CPlayer* player;
edict_t* grenade; edict_t* grenade;

View File

@ -343,7 +343,50 @@ static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params){ // player,wid
MF_SetAmxString(amx,params[2],szTeam,params[3]); MF_SetAmxString(amx,params[2],szTeam,params[3]);
} }
return iTeam; return iTeam;
} }
static cell AMX_NATIVE_CALL dod_set_model(AMX *amx, cell *params) // player,model
{
int index = params[1];
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if(!pPlayer->ingame)
return false;
int length;
pPlayer->initModel((char*)STRING(ALLOC_STRING(MF_GetAmxString(amx, params[2], 1, &length))));
return true;
}
static cell AMX_NATIVE_CALL dod_set_body(AMX *amx, cell *params) // player,bodynumber
{
int index = params[1];
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if(!pPlayer->ingame)
return false;
pPlayer->setBody(params[2]);
return true;
}
static cell AMX_NATIVE_CALL dod_clear_model(AMX *amx, cell *params) // player
{
int index = params[1];
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if(!pPlayer->ingame)
return false;
pPlayer->clearModel();
return true;
}
AMX_NATIVE_INFO base_Natives[] = { AMX_NATIVE_INFO base_Natives[] = {
@ -383,6 +426,11 @@ AMX_NATIVE_INFO base_Natives[] = {
{ "dod_get_wpnlogname", get_weapon_logname }, { "dod_get_wpnlogname", get_weapon_logname },
{ "dod_is_melee", is_melee }, { "dod_is_melee", is_melee },
// Zors
{"dod_set_model", dod_set_model},
{"dod_set_body_number", dod_set_body},
{"dod_clear_model", dod_clear_model},
///******************* ///*******************
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -1,5 +1,5 @@
/* /*
* DoDX * DoDX
* Copyright (c) 2004 Lukasz Wlasinski * Copyright (c) 2004 Lukasz Wlasinski
* *
* *
@ -40,7 +40,7 @@
#define GET_PLAYER_POINTER_I(i) (&players[i]) #define GET_PLAYER_POINTER_I(i) (&players[i])
#ifndef GETPLAYERAUTHID #ifndef GETPLAYERAUTHID
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) #define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
#endif #endif
extern AMX_NATIVE_INFO stats_Natives[]; extern AMX_NATIVE_INFO stats_Natives[];
@ -68,19 +68,34 @@ void Client_RoundState(void*);
void Client_AmmoX(void*); void Client_AmmoX(void*);
void Client_AmmoShort(void*); void Client_AmmoShort(void*);
// Zors
//void WeaponList(void*);
//void WeaponList_End(void*);
typedef void (*funEventCall)(void*); typedef void (*funEventCall)(void*);
extern int AlliesScore; extern int AlliesScore;
extern int AxisScore; extern int AxisScore;
extern int gmsgCurWeapon;
extern int gmsgHealth;
extern int gmsgResetHUD;
extern int gmsgObjScore;
extern int gmsgRoundState;
extern int gmsgTeamScore;
extern int gmsgScoreShort; extern int gmsgScoreShort;
extern int gmsgPTeam; extern int gmsgPTeam;
extern int gmsgAmmoX;
extern int gmsgAmmoShort;
extern int iFDamage; extern int iFDamage;
extern int iFDeath; extern int iFDeath;
extern int iFScore; extern int iFScore;
// Zors
extern int iFSpawnForward;
extern int iFTeamForward;
extern int iFClassForward;
extern cvar_t* dodstats_maxsize; extern cvar_t* dodstats_maxsize;
extern cvar_t* dodstats_rank; extern cvar_t* dodstats_rank;

View File

@ -1,5 +1,5 @@
/* /*
* DoDX * DoDX
* Copyright (c) 2004 Lukasz Wlasinski * Copyright (c) 2004 Lukasz Wlasinski
* *
* *
@ -47,27 +47,33 @@ int mPlayerIndex;
int AlliesScore; int AlliesScore;
int AxisScore; int AxisScore;
int iFDamage; int iFDamage = -1;
int iFDeath; int iFDeath = -1;
int iFScore; int iFScore = -1;
// Zors
int iFSpawnForward = -1;
int iFTeamForward = -1;
int iFClassForward = -1;
int gmsgCurWeapon; int gmsgCurWeapon;
int gmsgHealth; int gmsgHealth;
int gmsgResetHUD; int gmsgResetHUD;
int gmsgObjScore; int gmsgObjScore;
int gmsgRoundState; int gmsgRoundState;
int gmsgTeamScore; int gmsgTeamScore;
int gmsgScoreShort; int gmsgScoreShort;
int gmsgPTeam; int gmsgPTeam;
int gmsgAmmoX; int gmsgAmmoX;
int gmsgAmmoShort; int gmsgAmmoShort;
// Zors
//int gmsgWeaponList;
//int gmsgWeaponList_End;
RankSystem g_rank; RankSystem g_rank;
Grenades g_grenades; Grenades g_grenades;
cvar_t init_dodstats_maxsize ={"dodstats_maxsize","3500", 0 , 3500.0 }; cvar_t init_dodstats_maxsize ={"dodstats_maxsize","3500", 0 , 3500.0 };
cvar_t init_dodstats_reset ={"dodstats_reset","0"}; cvar_t init_dodstats_reset ={"dodstats_reset","0"};
cvar_t init_dodstats_rank ={"dodstats_rank","0"}; cvar_t init_dodstats_rank ={"dodstats_rank","0"};
@ -90,13 +96,16 @@ struct sUserMsg {
{ "RoundState",&gmsgRoundState,Client_RoundState,false }, { "RoundState",&gmsgRoundState,Client_RoundState,false },
{ "Health",&gmsgHealth,Client_Health_End,true }, { "Health",&gmsgHealth,Client_Health_End,true },
{ "ResetHUD",&gmsgResetHUD,Client_ResetHUD_End,true }, { "ResetHUD",&gmsgResetHUD,Client_ResetHUD_End,true },
{ "TeamScore",&gmsgTeamScore,Client_TeamScore,false }, { "TeamScore",&gmsgTeamScore,Client_TeamScore,false },
{ "ScoreShort",&gmsgScoreShort,NULL,false }, { "ScoreShort",&gmsgScoreShort,NULL,false },
{ "PTeam",&gmsgPTeam,NULL,false }, { "PTeam",&gmsgPTeam,NULL,false },
{ "AmmoX",&gmsgAmmoX,Client_AmmoX,false}, { "AmmoX",&gmsgAmmoX,Client_AmmoX,false},
{ "AmmoShort",&gmsgAmmoShort,Client_AmmoShort,false}, { "AmmoShort",&gmsgAmmoShort,Client_AmmoShort,false},
{ "ScoreShort",&gmsgScoreShort,NULL,false },
//Zors
//{ "WeaponList",&gmsgWeaponList,WeaponList,true },
//{ "WeaponList",&gmsgWeaponList_End,WeaponList_End,true },
{ 0,0,0,false } { 0,0,0,false }
}; };
@ -115,7 +124,7 @@ int RegUserMsg_Post(const char *pszName, int iSize){
int id = META_RESULT_ORIG_RET( int ); int id = META_RESULT_ORIG_RET( int );
*g_user_msg[ i ].id = id; *g_user_msg[ i ].id = id;
if ( g_user_msg[ i ].endmsg ) if ( g_user_msg[ i ].endmsg )
modMsgsEnd[ id ] = g_user_msg[ i ].func; modMsgsEnd[ id ] = g_user_msg[ i ].func;
else else
@ -129,7 +138,7 @@ int RegUserMsg_Post(const char *pszName, int iSize){
} }
void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){ void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){
rankBots = (int)dodstats_rankbots->value ? true:false; rankBots = (int)dodstats_rankbots->value ? true:false;
for( int i = 1; i <= gpGlobals->maxClients; ++i ) for( int i = 1; i <= gpGlobals->maxClients; ++i )
@ -140,13 +149,16 @@ void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){
} }
void PlayerPreThink_Post( edict_t *pEntity ) { void PlayerPreThink_Post( edict_t *pEntity ) {
if ( !isModuleActive() ) if ( !isModuleActive() )
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if ( !pPlayer->ingame ) if ( !pPlayer->ingame )
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
// Zors
pPlayer->checkStatus();
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time){ if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time){
if ( !ignoreBots(pEntity) ){ if ( !ignoreBots(pEntity) ){
pPlayer->clearStats = 0.0f; pPlayer->clearStats = 0.0f;
@ -165,7 +177,7 @@ void PlayerPreThink_Post( edict_t *pEntity ) {
pPlayer->sendScore = 0.0f; pPlayer->sendScore = 0.0f;
MF_ExecuteForward( iFScore,pPlayer->index, pPlayer->lastScore, pPlayer->savedScore ); MF_ExecuteForward( iFScore,pPlayer->index, pPlayer->lastScore, pPlayer->savedScore );
} }
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
@ -180,7 +192,7 @@ void ServerDeactivate() {
CVAR_SET_FLOAT("dodstats_reset",0.0); CVAR_SET_FLOAT("dodstats_reset",0.0);
g_rank.clear(); g_rank.clear();
} }
g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("dodstats") ) ); g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("dodstats") ) );
// clear custom weapons info // clear custom weapons info
@ -323,7 +335,8 @@ void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void DispatchKeyValue_Post( edict_t *pentKeyvalue, KeyValueData *pkvd ){ void DispatchKeyValue_Post( edict_t *pentKeyvalue, KeyValueData *pkvd )
{
if ( !pkvd->szClassName ){ if ( !pkvd->szClassName ){
// info_doddetect // info_doddetect
@ -338,22 +351,48 @@ void DispatchKeyValue_Post( edict_t *pentKeyvalue, KeyValueData *pkvd ){
if ( pkvd->szKeyName[0]=='d' && pkvd->szKeyName[7]=='a' ){ if ( pkvd->szKeyName[0]=='d' && pkvd->szKeyName[7]=='a' ){
if ( pkvd->szKeyName[8]=='l' ){ if ( pkvd->szKeyName[8]=='l' ){
switch ( pkvd->szKeyName[14] ){ switch ( pkvd->szKeyName[14] ){
case 'c': case 'c':
g_map.detect_allies_country=atoi(pkvd->szValue); g_map.detect_allies_country=atoi(pkvd->szValue);
break; break;
case 'p': case 'p':
g_map.detect_allies_paras=atoi(pkvd->szValue); g_map.detect_allies_paras=atoi(pkvd->szValue);
break; break;
} }
} }
else if ( pkvd->szKeyName[12]=='p' ) g_map.detect_axis_paras=atoi(pkvd->szValue); else if ( pkvd->szKeyName[12]=='p' ) g_map.detect_axis_paras=atoi(pkvd->szValue);
} }
} }
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void OnMetaAttach() { void SetClientKeyValue(int id, char *protocol, char *type, char *var)
{
// ID: Number
// protocol: \name\Sgt.MEOW\topcolor\1\bottomcolor\1\cl_lw\1\team\axis\model\axis-inf
// type: model
// var: axis-inf
// Check to see if its a player and we are setting a model
if(strcmp(type, "model") == 0 &&
(strcmp(var, "axis-inf") == 0 ||
strcmp(var, "axis-para") == 0 ||
strcmp(var, "us-inf") == 0 ||
strcmp(var, "us-para") == 0 ||
strcmp(var, "brit-inf") == 0))
{
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if(!pPlayer->ingame)
RETURN_META(MRES_IGNORED);
if(pPlayer->setModel())
RETURN_META(MRES_SUPERCEDE);
}
RETURN_META(MRES_IGNORED);
}
void OnMetaAttach()
{
CVAR_REGISTER (&init_dodstats_maxsize); CVAR_REGISTER (&init_dodstats_maxsize);
CVAR_REGISTER (&init_dodstats_reset); CVAR_REGISTER (&init_dodstats_reset);
CVAR_REGISTER (&init_dodstats_rank); CVAR_REGISTER (&init_dodstats_rank);
@ -366,34 +405,45 @@ void OnMetaAttach() {
dodstats_pause = CVAR_GET_POINTER(init_dodstats_pause.name); dodstats_pause = CVAR_GET_POINTER(init_dodstats_pause.name);
} }
void OnAmxxAttach() { void OnAmxxAttach()
{
MF_AddNatives( stats_Natives ); MF_AddNatives( stats_Natives );
MF_AddNatives( base_Natives ); MF_AddNatives( base_Natives );
const char* path = get_localinfo("dodstats_score","addons/amxmodx/data/dodstats.amxx"); const char* path = get_localinfo("dodstats_score","addons/amxmodx/data/dodstats.amxx");
if ( path && *path ) {
if ( path && *path )
{
char error[128]; char error[128];
g_rank.loadCalc( MF_BuildPathname("%s",path) , error ); g_rank.loadCalc( MF_BuildPathname("%s",path) , error );
} }
if ( !g_rank.begin() ){ if ( !g_rank.begin() )
{
g_rank.loadRank( MF_BuildPathname("%s", g_rank.loadRank( MF_BuildPathname("%s",
get_localinfo("dodstats","addons/amxmodx/data/dodstats.dat") ) ); get_localinfo("dodstats","addons/amxmodx/data/dodstats.dat") ) );
} }
g_map.Init(); g_map.Init();
} }
void OnAmxxDetach() { void OnAmxxDetach()
{
g_rank.clear(); g_rank.clear();
g_grenades.clear(); g_grenades.clear();
g_rank.unloadCalc(); g_rank.unloadCalc();
} }
void OnPluginsLoaded(){ void OnPluginsLoaded()
{
iFDeath = MF_RegisterForward("client_death",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE); 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); iFDamage = MF_RegisterForward("client_damage",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
iFScore = MF_RegisterForward("client_score",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_DONE); iFScore = MF_RegisterForward("client_score",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
// Zors
iFTeamForward = MF_RegisterForward("dod_client_changeteam",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*team*/,FP_CELL/*oldteam*/,FP_DONE);
iFSpawnForward = MF_RegisterForward("dod_client_spawn",ET_IGNORE,FP_CELL/*id*/,FP_DONE);
iFClassForward = MF_RegisterForward("dod_client_changeclass",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*class*/,FP_CELL/*oldclass*/,FP_DONE);
} }

View File

@ -296,7 +296,7 @@
// #define FN_GetInfoKeyBuffer GetInfoKeyBuffer // #define FN_GetInfoKeyBuffer GetInfoKeyBuffer
// #define FN_InfoKeyValue InfoKeyValue // #define FN_InfoKeyValue InfoKeyValue
// #define FN_SetKeyValue SetKeyValue // #define FN_SetKeyValue SetKeyValue
// #define FN_SetClientKeyValue SetClientKeyValue #define FN_SetClientKeyValue SetClientKeyValue
// #define FN_IsMapValid IsMapValid // #define FN_IsMapValid IsMapValid
// #define FN_StaticDecal StaticDecal // #define FN_StaticDecal StaticDecal
// #define FN_PrecacheGeneric PrecacheGeneric // #define FN_PrecacheGeneric PrecacheGeneric

View File

@ -31,31 +31,40 @@
#include "amxxmodule.h" #include "amxxmodule.h"
#include "dodx.h" #include "dodx.h"
void Client_ResetHUD_End(void* mValue){ void Client_ResetHUD_End(void* mValue)
{
mPlayer->clearStats = gpGlobals->time + 0.25f; mPlayer->clearStats = gpGlobals->time + 0.25f;
} }
void Client_RoundState(void* mValue){ void Client_RoundState(void* mValue)
{
if ( mPlayer ) return; if ( mPlayer ) return;
int result = *(int*)mValue; int result = *(int*)mValue;
if ( result == 1 ){ if ( result == 1 )
for (int i=1;i<=gpGlobals->maxClients;i++){ {
for (int i=1;i<=gpGlobals->maxClients;i++)
{
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i); CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame) { if (pPlayer->ingame)
{
pPlayer->clearRound = gpGlobals->time + 0.25f; pPlayer->clearRound = gpGlobals->time + 0.25f;
} }
} }
} }
} }
void Client_TeamScore(void* mValue){ void Client_TeamScore(void* mValue)
{
static int index; static int index;
switch(mState++){
switch(mState++)
{
case 0: case 0:
index = *(int*)mValue; index = *(int*)mValue;
break; break;
case 1: case 1:
switch (index){ switch (index)
{
case 1: case 1:
AlliesScore = *(int*)mValue; AlliesScore = *(int*)mValue;
break; break;
@ -67,16 +76,20 @@ void Client_TeamScore(void* mValue){
} }
} }
void Client_ObjScore(void* mValue){ void Client_ObjScore(void* mValue)
{
static CPlayer *pPlayer; static CPlayer *pPlayer;
static int score; static int score;
switch(mState++){
switch(mState++)
{
case 0: case 0:
pPlayer = GET_PLAYER_POINTER_I(*(int*)mValue); pPlayer = GET_PLAYER_POINTER_I(*(int*)mValue);
break; break;
case 1: case 1:
score = *(int*)mValue; score = *(int*)mValue;
if ( (pPlayer->lastScore = score - pPlayer->savedScore) && isModuleActive() ){ if ( (pPlayer->lastScore = score - pPlayer->savedScore) && isModuleActive() )
{
pPlayer->updateScore(pPlayer->current,pPlayer->lastScore); pPlayer->updateScore(pPlayer->current,pPlayer->lastScore);
pPlayer->sendScore = gpGlobals->time + 0.25f; pPlayer->sendScore = gpGlobals->time + 0.25f;
} }
@ -86,10 +99,13 @@ void Client_ObjScore(void* mValue){
} }
void Client_CurWeapon(void* mValue){ void Client_CurWeapon(void* mValue)
{
static int iState; static int iState;
static int iId; static int iId;
switch (mState++){
switch (mState++)
{
case 0: case 0:
iState = *(int*)mValue; iState = *(int*)mValue;
break; break;
@ -103,17 +119,20 @@ void Client_CurWeapon(void* mValue){
int iClip = *(int*)mValue; int iClip = *(int*)mValue;
mPlayer->current = iId; mPlayer->current = iId;
if ( weaponData[iId].needcheck ){ if ( weaponData[iId].needcheck )
{
iId = get_weaponid(mPlayer); iId = get_weaponid(mPlayer);
mPlayer->current = iId; mPlayer->current = iId;
} }
if (iClip > -1) { if (iClip > -1) {
if ( mPlayer->current == 17 ){ if ( mPlayer->current == 17 )
{
if ( iClip+2 == mPlayer->weapons[iId].clip) if ( iClip+2 == mPlayer->weapons[iId].clip)
mPlayer->saveShot(iId); mPlayer->saveShot(iId);
} }
else { else
{
if ( iClip+1 == mPlayer->weapons[iId].clip) if ( iClip+1 == mPlayer->weapons[iId].clip)
mPlayer->saveShot(iId); mPlayer->saveShot(iId);
} }
@ -140,16 +159,19 @@ void Client_Health_End(void* mValue){
int aim = 0; int aim = 0;
mPlayer->pEdict->v.dmg_take = 0.0; mPlayer->pEdict->v.dmg_take = 0.0;
CPlayer* pAttacker = NULL; CPlayer* pAttacker = NULL;
if ( enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ){ if ( enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) )
{
pAttacker = GET_PLAYER_POINTER(enemy); pAttacker = GET_PLAYER_POINTER(enemy);
weapon = pAttacker->current; weapon = pAttacker->current;
if ( weaponData[weapon].needcheck ) if ( weaponData[weapon].needcheck )
weapon = get_weaponid(pAttacker); weapon = get_weaponid(pAttacker);
aim = pAttacker->aiming; aim = pAttacker->aiming;
if ( weaponData[weapon].melee ) if ( weaponData[weapon].melee )
pAttacker->saveShot(weapon); pAttacker->saveShot(weapon);
} }
@ -158,49 +180,125 @@ void Client_Health_End(void* mValue){
int TA = 0; int TA = 0;
if ( !pAttacker ){ if ( !pAttacker )
{
pAttacker = mPlayer; pAttacker = mPlayer;
} }
if ( pAttacker->index != mPlayer->index ){ if ( pAttacker->index != mPlayer->index )
{
pAttacker->saveHit( mPlayer , weapon , damage, aim ); pAttacker->saveHit( mPlayer , weapon , damage, aim );
if ( mPlayer->pEdict->v.team == pAttacker->pEdict->v.team ) if ( mPlayer->pEdict->v.team == pAttacker->pEdict->v.team )
TA = 1; TA = 1;
} }
MF_ExecuteForward( iFDamage,pAttacker->index, mPlayer->index, damage, weapon, aim, TA ); MF_ExecuteForward( iFDamage, pAttacker->index, mPlayer->index, damage, weapon, aim, TA );
if ( !mPlayer->IsAlive() ){ if ( !mPlayer->IsAlive() )
{
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA); pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
MF_ExecuteForward( iFDeath, pAttacker->index, mPlayer->index, weapon, aim, TA );
MF_ExecuteForward( iFDeath,pAttacker->index, mPlayer->index, weapon, aim, TA );
} }
} }
void Client_AmmoX(void* mValue){ void Client_AmmoX(void* mValue)
{
static int iAmmo; static int iAmmo;
switch (mState++){
switch (mState++)
{
case 0: case 0:
iAmmo = *(int*)mValue; iAmmo = *(int*)mValue;
break; break;
case 1: case 1:
if (!mPlayer ) break; if (!mPlayer )
for(int i = 1; i < MAX_WEAPONS ; ++i) break;
for(int i = 1; i < MAX_WEAPONS ; ++i)
{
if (iAmmo == weaponData[i].ammoSlot) if (iAmmo == weaponData[i].ammoSlot)
mPlayer->weapons[i].ammo = *(int*)mValue; mPlayer->weapons[i].ammo = *(int*)mValue;
}
} }
} }
void Client_AmmoShort(void* mValue){ void Client_AmmoShort(void* mValue)
{
static int iAmmo; static int iAmmo;
switch (mState++){
switch (mState++)
{
case 0: case 0:
iAmmo = *(int*)mValue; iAmmo = *(int*)mValue;
break; break;
case 1: case 1:
if (!mPlayer ) break; if (!mPlayer ) break;
for(int i = 1; i < MAX_WEAPONS ; ++i) for(int i = 1; i < MAX_WEAPONS ; ++i)
{
if (iAmmo == weaponData[i].ammoSlot) if (iAmmo == weaponData[i].ammoSlot)
mPlayer->weapons[i].ammo = *(int*)mValue; mPlayer->weapons[i].ammo = *(int*)mValue;
}
} }
} }
/*
Working on being able to modify and switch weapons as they are sent to the client
void WeaponList(void* value)
{
if(!mPlayer)
return;
if(!mPlayer->ingame || ignoreBots(mPlayer->pEdict))
return;
switch(mPlayer->position)
{
case 0: MF_Log("pszName = %s", value); break; // string weapon name
case 1: MF_Log("pszAmmo1 = %d", (int)value); break; // byte Ammo Type
case 2: MF_Log("iMaxAmmo1 = %d", (int)value); break; // byte Max Ammo 1
case 3: MF_Log("pszAmmo2 = %d", (int)value); break; // byte Ammo2 Type
case 4: MF_Log("iMaxAmmo2 = %d", (int)value); break; // byte Max Ammo 2
case 5: MF_Log("iSlot = %d", (int)value); break; // byte bucket
case 6: MF_Log("iPosition = %d", (int)value); break; // byte bucket pos
case 7: MF_Log("iId = %d", (int)value); break; // byte id (bit index into pev->weapons)
case 8: MF_Log("iFlags = %d", (int)value); break; // byte Flags
};
mPlayer->position++;
}
void WeaponList_End(void* mValue)
{
if(!mPlayer)
return;
MF_Log("Done with %d", mPlayer->position);
mPlayer->position = 0;
}
struct weapon_info_s
{
char *pszName; // string weapon name
int pszAmmo1; // byte Ammo Type
int iMaxAmmo1; // byte Max Ammo 1
int pszAmmo2; // byte Ammo2 Type
int iMaxAmmo2; // byte Max Ammo 2
int iSlot; // byte bucket
int iPosition; // byte bucket pos
int iId; // byte id (bit index into pev->weapons)
int iFlags; // byte Flags
}weapon_info_t;
MESSAGE_BEGIN( MSG_ONE, gmsgWeaponList, NULL, pev );
WRITE_STRING(pszName); // string weapon name
WRITE_BYTE(GetAmmoIndex(II.pszAmmo1)); // byte Ammo Type
WRITE_BYTE(II.iMaxAmmo1); // byte Max Ammo 1
WRITE_BYTE(GetAmmoIndex(II.pszAmmo2)); // byte Ammo2 Type
WRITE_BYTE(II.iMaxAmmo2); // byte Max Ammo 2
WRITE_BYTE(II.iSlot); // byte bucket
WRITE_BYTE(II.iPosition); // byte bucket pos
WRITE_BYTE(II.iId); // byte id (bit index into pev->weapons)
WRITE_BYTE(II.iFlags); // byte Flags
MESSAGE_END();
*/

View File

@ -31,35 +31,55 @@ enum {
} }
/* Use this function to register forwards */ /* Use this function to register forwards */
native register_statsfwd( ftype ); native register_statsfwd(ftype);
/* Function is called after player to player attacks , /* Function is called after player to player attacks ,
* if players were damaged by teammate TA is set to 1 */ * if players were damaged by teammate TA is set to 1 */
forward client_damage(attacker,victim,damage,wpnindex,hitplace,TA); forward client_damage(attacker, victim, damage, wpnindex, hitplace, TA);
/* Function is called after player death , /* Function is called after player death ,
* if player was killed by teammate TK is set to 1 */ * if player was killed by teammate TK is set to 1 */
forward client_death(killer,victim,wpnindex,hitplace,TK); forward client_death(killer, victim, wpnindex, hitplace, TK);
/* Function is called if player scored */ /* Function is called if player scored */
forward client_score(index,score,total); forward client_score(id, score, total);
/* This Forward is called when a player changes team */
forward dod_client_changeteam(id, team, oldteam);
/* This Forward is called if a player changes class, but just after spawn */
forward dod_client_changeclass(id, class, oldclass);
/* This Forward is called when a player spawns */
forward dod_client_spawn(id);
/* Sets the model for a player */
native dod_set_model(id, model[]);
/* Sets the model for a player */
native dod_set_body_number(id, bodynumber);
/* Un-Sets the model for a player */
native dod_clear_model(id);
/* Custom Weapon Support */ /* Custom Weapon Support */
/* function will return index of new weapon */ /* function will return index of new weapon */
native custom_weapon_add( wpnname[],melee = 0,logname[]="" ); native custom_weapon_add( wpnname[], melee = 0, logname[]="" );
/* Function will pass damage done by this custom weapon to stats module and other plugins */ /* 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 ); native custom_weapon_dmg( weapon, att, vic, damage, hitplace=0 );
/* Function will pass info about custom weapon shot to stats module */ /* Function will pass info about custom weapon shot to stats module */
native custom_weapon_shot( weapon,index ); // weapon id , player id native custom_weapon_shot( weapon, index ); // weapon id , player id
/* function will return 1 if true */ /* function will return 1 if true */
native xmod_is_melee_wpn(wpnindex); native xmod_is_melee_wpn(wpnindex);
/* Returns weapon name. */ /* Returns weapon name. */
native xmod_get_wpnname(wpnindex,name[],len); native xmod_get_wpnname(wpnindex, name[], len);
/* Returns weapon logname. */ /* Returns weapon logname. */
native xmod_get_wpnlogname(wpnindex,name[],len); native xmod_get_wpnlogname(wpnindex, name[], len);
/* Returns weapons array size */ /* Returns weapons array size */
native xmod_get_maxweapons(); native xmod_get_maxweapons();