attempted merge at 1.77 back into trunk... Oh MY GOD
This commit is contained in:
@ -2773,7 +2773,7 @@ void ValidateMacros_DontCallThis_Smiley()
|
||||
MF_FindLibrary(NULL, LibType_Class);
|
||||
MF_AddLibraries(NULL, LibType_Class, NULL);
|
||||
MF_RemoveLibraries(NULL);
|
||||
MF_OverrideNatives(NULL);
|
||||
MF_OverrideNatives(NULL, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -57,6 +57,7 @@ extern int gmsgInitObj;
|
||||
extern int gmsgSetObj;
|
||||
|
||||
extern int iFGrenade;
|
||||
extern int iFRocket;
|
||||
extern int iFInitCP;
|
||||
|
||||
extern CPlayer players[33];
|
||||
|
@ -29,6 +29,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "amxxmodule.h"
|
||||
#include "dodfun.h"
|
||||
|
||||
@ -37,6 +38,7 @@ funEventCall modMsgs[MAX_REG_MSGS];
|
||||
void (*function)(void*);
|
||||
void (*endfunction)(void*);
|
||||
CPlayer* mPlayer;
|
||||
CPlayer* gPlayerRocket;
|
||||
CPlayer players[33];
|
||||
|
||||
CObjective mObjects;
|
||||
@ -46,6 +48,7 @@ int mDest;
|
||||
int mPlayerIndex;
|
||||
|
||||
int iFGrenade;
|
||||
int iFRocket;
|
||||
int iFInitCP;
|
||||
|
||||
int gmsgCurWeapon;
|
||||
@ -96,20 +99,6 @@ void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void PlayerPreThink_Post( edict_t *pEntity ) {
|
||||
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
|
||||
if ( pPlayer->staminaSet ) {
|
||||
if ( (int)pEntity->v.fuser4 > pPlayer->staminaMax )
|
||||
pEntity->v.fuser4 = (float)pPlayer->staminaMax;
|
||||
else if ( (int)pEntity->v.fuser4 < pPlayer->staminaMin )
|
||||
pEntity->v.fuser4 = (float)pPlayer->staminaMin;
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void ServerDeactivate() {
|
||||
for(int i = 1;i<=gpGlobals->maxClients; ++i){
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
@ -208,55 +197,108 @@ void WriteEntity_Post(int iValue) {
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void SetModel_Post(edict_t *e, const char *m){
|
||||
if ( !e->v.owner || !e->v.dmgtime )
|
||||
RETURN_META(MRES_IGNORED);
|
||||
void PlayerPreThink_Post(edict_t *pEntity)
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
|
||||
int owner = ENTINDEX(e->v.owner);
|
||||
if ( owner && owner<33 && m[7]=='w' && m[8]=='_' ){
|
||||
// Stamina
|
||||
if(pPlayer->staminaSet)
|
||||
{
|
||||
if ( (int)pEntity->v.fuser4 > pPlayer->staminaMax)
|
||||
pEntity->v.fuser4 = (float)pPlayer->staminaMax;
|
||||
|
||||
int w_id = 0;
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(owner);
|
||||
bool newNade = ( pPlayer->current == 13 || pPlayer->current == 14 ) ? true:false;
|
||||
|
||||
if ( m[9]=='g' && m[10]=='r' && m[11]=='e' && m[12]=='n' )
|
||||
newNade ? w_id = 13 : w_id = 16; // grenade
|
||||
else if ( m[9]=='m' && m[10]=='i' )
|
||||
newNade ? w_id = 36 : w_id = 16 ; // mills ; should I add mills_grenade_ex weapon ?
|
||||
else if ( m[9]=='s' && m[10]=='t' && m[11]=='i')
|
||||
newNade ? w_id = 14 : w_id = 15; // stick
|
||||
|
||||
if ( !w_id )
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
MF_ExecuteForward( iFGrenade, pPlayer->index, ENTINDEX(e) ,w_id );
|
||||
/* fuse start */
|
||||
if ( pPlayer->fuseSet ){
|
||||
if ( newNade ){
|
||||
if ( pPlayer->fuseType & 1<<0 ){
|
||||
e->v.dmgtime += pPlayer->nadeFuse - 5.0;
|
||||
}
|
||||
}
|
||||
else{ // cought
|
||||
bool ownNade = ( (pPlayer->pEdict->v.team == 1 && pPlayer->current == 16) || (pPlayer->pEdict->v.team == 2 && pPlayer->current == 15) ) ? true:false;
|
||||
if ( ownNade ){
|
||||
float fExp = e->v.dmgtime - gpGlobals->time;
|
||||
e->v.dmgtime += pPlayer->nadeFuse - fExp;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* fuse end */
|
||||
else if ( (int)pEntity->v.fuser4 < pPlayer->staminaMin)
|
||||
pEntity->v.fuser4 = (float)pPlayer->staminaMin;
|
||||
}
|
||||
|
||||
if(pPlayer->current == 29 || pPlayer->current == 30 || pPlayer->current == 31)
|
||||
{
|
||||
if(!(pPlayer->pEdict->v.oldbuttons&IN_ATTACK) && (pPlayer->pEdict->v.button&IN_ATTACK))
|
||||
gPlayerRocket = GET_PLAYER_POINTER(pEntity);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void OnAmxxAttach() {
|
||||
void SetModel_Post(edict_t *e, const char *m)
|
||||
{
|
||||
int w_id = 0;
|
||||
|
||||
if(!e->v.owner || !e->v.dmgtime)
|
||||
{
|
||||
int owner = ENTINDEX(e->v.owner);
|
||||
|
||||
if(owner && owner < 33 && m[7]=='w' && m[8]=='_')
|
||||
{
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(owner);
|
||||
bool newNade = (pPlayer->current == 13 || pPlayer->current == 14) ? true : false;
|
||||
|
||||
if(m[9]=='g' && m[10]=='r' && m[11]=='e' && m[12]=='n')
|
||||
w_id = newNade ? 13 : 16; // grenade
|
||||
|
||||
else if(m[9]=='m' && m[10]=='i')
|
||||
w_id = newNade ? 36 : 16 ; // mills ; should I add mills_grenade_ex weapon ?
|
||||
|
||||
else if(m[9]=='s' && m[10]=='t' && m[11]=='i')
|
||||
w_id = newNade ? 14 : 15; // stick
|
||||
|
||||
if(!w_id)
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
if(w_id == 13 || w_id == 14 || w_id == 15 || w_id == 16 || w_id == 36)
|
||||
{
|
||||
MF_ExecuteForward(iFGrenade, pPlayer->index, ENTINDEX(e), w_id);
|
||||
|
||||
/* fuse start */
|
||||
if(pPlayer->fuseSet)
|
||||
{
|
||||
if(newNade)
|
||||
{
|
||||
if(pPlayer->fuseType & 1<<0)
|
||||
{
|
||||
e->v.dmgtime += pPlayer->nadeFuse - 5.0;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
float fExp = e->v.dmgtime - gpGlobals->time;
|
||||
e->v.dmgtime += pPlayer->nadeFuse - fExp;
|
||||
}
|
||||
}
|
||||
/* fuse end */
|
||||
}
|
||||
}
|
||||
|
||||
else if(strstr(m, "rocket") && gPlayerRocket)
|
||||
{
|
||||
if(strstr(m, "bazooka"))
|
||||
w_id = 29;
|
||||
|
||||
else if(strstr(m, "piat"))
|
||||
w_id = 30;
|
||||
|
||||
else if(strstr(m, "pschreck"))
|
||||
w_id = 31;
|
||||
|
||||
MF_ExecuteForward(iFRocket, gPlayerRocket->index, ENTINDEX(e), w_id);
|
||||
|
||||
gPlayerRocket = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void OnAmxxAttach()
|
||||
{
|
||||
MF_AddNatives( base_Natives );
|
||||
MF_AddNatives( pd_Natives );
|
||||
}
|
||||
|
||||
void OnPluginsLoaded(){
|
||||
iFGrenade = MF_RegisterForward("grenade_throw",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
|
||||
void OnPluginsLoaded()
|
||||
{
|
||||
iFGrenade = MF_RegisterForward("grenade_throw",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*Grenade Ent*/,FP_CELL/*Weapon ID*/,FP_DONE);
|
||||
iFRocket = MF_RegisterForward("rocket_shoot",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*Rocket Ent*/,FP_CELL/*Weapon ID*/,FP_DONE);
|
||||
iFInitCP = MF_RegisterForward("controlpoints_init",ET_IGNORE,FP_DONE);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
// Module info
|
||||
#define MODULE_NAME "DoD Fun"
|
||||
#define MODULE_VERSION "1.76b"
|
||||
#define MODULE_VERSION "1.76c_beta_a"
|
||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||
#define MODULE_URL "http://www.amxmodx.org"
|
||||
#define MODULE_LOGTAG "DODFUN"
|
||||
|
@ -33,73 +33,31 @@
|
||||
#include "CMisc.h"
|
||||
#include "dodx.h"
|
||||
|
||||
// *****************************************************
|
||||
// class Grenades
|
||||
// *****************************************************
|
||||
void Grenades::put( edict_t* grenade, float time, int type, CPlayer* player )
|
||||
{
|
||||
Obj* a = new Obj;
|
||||
a->player = player;
|
||||
a->grenade = grenade;
|
||||
a->time = gpGlobals->time + time;
|
||||
a->type = type;
|
||||
a->next = head;
|
||||
head = a;
|
||||
}
|
||||
|
||||
bool Grenades::find( edict_t* enemy, CPlayer** p, int& type )
|
||||
{
|
||||
bool found = false;
|
||||
float lastTime = 0.0;
|
||||
Obj** a = &head;
|
||||
while ( *a ){
|
||||
if ( (*a)->time > gpGlobals->time ) {
|
||||
if ( (*a)->grenade == enemy ) {
|
||||
found = true;
|
||||
if ( (*a)->time > lastTime ){ // we need this because of catched grenades
|
||||
(*p) = (*a)->player; // two people can have the same nade in our list
|
||||
type = (*a)->type;
|
||||
lastTime = (*a)->time;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Obj* next = (*a)->next;
|
||||
delete *a;
|
||||
*a = next;
|
||||
continue;
|
||||
|
||||
}
|
||||
a = &(*a)->next;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void Grenades::clear()
|
||||
{
|
||||
while(head){
|
||||
Obj* a = head->next;
|
||||
delete head;
|
||||
head = a;
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************
|
||||
// class CPlayer
|
||||
// *****************************************************
|
||||
|
||||
void CPlayer::Disconnect(){
|
||||
void CPlayer::Disconnect()
|
||||
{
|
||||
ingame = false;
|
||||
bot = false;
|
||||
savedScore = 0;
|
||||
|
||||
// Zors
|
||||
olddeadflag=0;
|
||||
oldteam=0;
|
||||
oldplayerclass=0;
|
||||
is_model_set=false;
|
||||
body_num=0;
|
||||
position = 0;
|
||||
olddeadflag = 0;
|
||||
oldteam = 0;
|
||||
oldclass = 0;
|
||||
oldprone = 0;
|
||||
oldstamina = 0.0f;
|
||||
|
||||
// Model Stuff
|
||||
sModel.is_model_set = false;
|
||||
sModel.body_num = 0;
|
||||
|
||||
// Object stuff
|
||||
object.pEdict = NULL;
|
||||
object.type = 0;
|
||||
object.carrying = false;
|
||||
object.do_forward = false;
|
||||
|
||||
if ( ignoreBots(pEdict) || !isModuleActive() ) // ignore if he is bot and bots rank is disabled or module is paused
|
||||
return;
|
||||
@ -141,11 +99,13 @@ void CPlayer::Connect(const char* nn,const char* ippp ){
|
||||
|
||||
void CPlayer::restartStats(bool all)
|
||||
{
|
||||
if ( all ){
|
||||
if ( all )
|
||||
{
|
||||
memset(weapons,0,sizeof(weapons));
|
||||
memset(&round,0,sizeof(round));
|
||||
memset(weaponsRnd,0,sizeof(weaponsRnd));
|
||||
}
|
||||
|
||||
memset(weaponsLife,0,sizeof(weaponsLife)); //DEC-Weapon (Round) stats
|
||||
memset(attackers,0,sizeof(attackers));
|
||||
memset(victims,0,sizeof(victims));
|
||||
@ -154,6 +114,12 @@ void CPlayer::restartStats(bool all)
|
||||
|
||||
void CPlayer::Init( int pi, edict_t* pe )
|
||||
{
|
||||
aiming = 0;
|
||||
wpnModel = 0;
|
||||
wpnscount = 0;
|
||||
lastScore = 0;
|
||||
sendScore = 0;
|
||||
clearRound = 0.0f;
|
||||
pEdict = pe;
|
||||
index = pi;
|
||||
current = 0;
|
||||
@ -161,14 +127,24 @@ void CPlayer::Init( int pi, edict_t* pe )
|
||||
ingame = false;
|
||||
bot = false;
|
||||
savedScore = 0;
|
||||
olddeadflag = 0;
|
||||
oldteam = 0;
|
||||
oldclass = 0;
|
||||
oldprone = 0;
|
||||
oldstamina = 0.0f;
|
||||
|
||||
// Zors
|
||||
olddeadflag=0;
|
||||
oldteam=0;
|
||||
oldplayerclass=0;
|
||||
is_model_set=false;
|
||||
body_num=0;
|
||||
position = 0;
|
||||
do_scoped = false;
|
||||
is_scoped = false;
|
||||
|
||||
// Model Stuff
|
||||
sModel.is_model_set = false;
|
||||
sModel.body_num = 0;
|
||||
|
||||
// Object stuff
|
||||
object.pEdict = NULL;
|
||||
object.type = 0;
|
||||
object.carrying = false;
|
||||
object.do_forward = false;
|
||||
}
|
||||
|
||||
void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
|
||||
@ -176,7 +152,8 @@ void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
|
||||
if ( ignoreBots(pEdict,pVictim->pEdict) )
|
||||
return;
|
||||
|
||||
if ( pVictim->index == index ){ // killed self
|
||||
if ( pVictim->index == index )
|
||||
{ // killed self
|
||||
pVictim->weapons[0].deaths++;
|
||||
pVictim->life.deaths++;
|
||||
pVictim->round.deaths++;
|
||||
@ -293,7 +270,8 @@ void CPlayer::saveHit(CPlayer* pVictim, int wweapon, int ddamage, int bbody){
|
||||
round.bodyHits[bbody]++;
|
||||
}
|
||||
|
||||
void CPlayer::saveShot(int weapon){
|
||||
void CPlayer::saveShot(int weapon)
|
||||
{
|
||||
|
||||
if ( ignoreBots(pEdict) )
|
||||
return;
|
||||
@ -310,7 +288,8 @@ void CPlayer::saveShot(int weapon){
|
||||
weaponsRnd[0].shots++; // DEC-Weapon (round) stats
|
||||
}
|
||||
|
||||
void CPlayer::updateScore(int weapon, int score){
|
||||
void CPlayer::updateScore(int weapon, int score)
|
||||
{
|
||||
|
||||
if ( ignoreBots(pEdict) )
|
||||
return;
|
||||
@ -325,7 +304,8 @@ void CPlayer::updateScore(int weapon, int score){
|
||||
weapons[0].points += score;
|
||||
}
|
||||
|
||||
void CPlayer::killPlayer(){
|
||||
void CPlayer::killPlayer()
|
||||
{
|
||||
pEdict->v.dmg_inflictor = NULL;
|
||||
pEdict->v.health = 0;
|
||||
pEdict->v.deadflag = DEAD_RESPAWNABLE;
|
||||
@ -335,13 +315,13 @@ void CPlayer::killPlayer(){
|
||||
|
||||
void CPlayer::initModel(char* model)
|
||||
{
|
||||
newmodel = model;
|
||||
is_model_set = true;
|
||||
strcpy(sModel.modelclass, (const char*)model);
|
||||
sModel.is_model_set = true;
|
||||
}
|
||||
|
||||
void CPlayer::clearModel()
|
||||
{
|
||||
is_model_set = false;
|
||||
sModel.is_model_set = false;
|
||||
}
|
||||
|
||||
bool CPlayer::setModel()
|
||||
@ -349,10 +329,10 @@ bool CPlayer::setModel()
|
||||
if(!ingame || ignoreBots(pEdict))
|
||||
return false;
|
||||
|
||||
if(is_model_set)
|
||||
if(sModel.is_model_set)
|
||||
{
|
||||
ENTITY_SET_KEYVALUE(pEdict, "model", newmodel);
|
||||
pEdict->v.body = body_num;
|
||||
ENTITY_SET_KEYVALUE(pEdict, "model", sModel.modelclass);
|
||||
pEdict->v.body = sModel.body_num;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -364,12 +344,17 @@ void CPlayer::setBody(int bn)
|
||||
if(!ingame || ignoreBots(pEdict))
|
||||
return;
|
||||
|
||||
body_num = bn;
|
||||
sModel.body_num = bn;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void CPlayer::checkStatus()
|
||||
/*
|
||||
iuser3 = 0 standing up
|
||||
iuser3 = 1 going prone or mg tearing down
|
||||
iuser3 = 2 setting up mg
|
||||
*/
|
||||
void CPlayer::PreThink()
|
||||
{
|
||||
if(!ingame || ignoreBots(pEdict))
|
||||
return;
|
||||
@ -380,12 +365,160 @@ void CPlayer::checkStatus()
|
||||
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);
|
||||
if(oldclass != pEdict->v.playerclass && iFClassForward != -1)
|
||||
MF_ExecuteForward(iFClassForward, index, pEdict->v.playerclass, oldclass);
|
||||
|
||||
if(oldprone != pEdict->v.iuser3 && oldprone != 2 && pEdict->v.iuser3 != 2 && iFProneForward != -1)
|
||||
MF_ExecuteForward(iFProneForward, index, pEdict->v.iuser3);
|
||||
|
||||
if(oldstamina > pEdict->v.fuser4 && iFStaminaForward != -1)
|
||||
MF_ExecuteForward(iFStaminaForward, index, ((int)pEdict->v.fuser4));
|
||||
|
||||
if(wpns_bitfield != pEdict->v.weapons)
|
||||
WeaponsCheck(pEdict->v.weapons & ~(1<<31));
|
||||
|
||||
// Set the old variables for
|
||||
oldprone = pEdict->v.iuser3;
|
||||
olddeadflag = pEdict->v.deadflag;
|
||||
oldteam = pEdict->v.team;
|
||||
oldplayerclass = pEdict->v.playerclass;
|
||||
oldclass = pEdict->v.playerclass;
|
||||
oldstamina = pEdict->v.fuser4;
|
||||
|
||||
wpns_bitfield = pEdict->v.weapons & ~(1<<31);
|
||||
}
|
||||
|
||||
void CPlayer::Scoping(int value)
|
||||
{
|
||||
// Everyone gets a 0 then another call for 90, so I need to figure out
|
||||
// what weapon they have before I can then check if they are scoped or not
|
||||
|
||||
do_scoped = false;
|
||||
|
||||
switch(value)
|
||||
{
|
||||
// This is when the scope is dropped from the eye
|
||||
case 0:
|
||||
// Is this an initial call
|
||||
if(mPlayer->current == 0)
|
||||
return;
|
||||
|
||||
// SKar Spring SFG42 SEnfield
|
||||
if((mPlayer->current == 6 || mPlayer->current == 9 || mPlayer->current == 32 || mPlayer->current == 35) && is_scoped)
|
||||
{
|
||||
is_scoped = false;
|
||||
do_scoped = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// This is when the scope is put up to the eye
|
||||
case 20:
|
||||
// SKar Spring SFG42 SEnfield
|
||||
if((mPlayer->current == 6 || mPlayer->current == 9 || mPlayer->current == 32 || mPlayer->current == 35) && !is_scoped)
|
||||
{
|
||||
is_scoped = true;
|
||||
do_scoped = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// This means the scope has been initialized
|
||||
case 90:
|
||||
is_scoped = false;
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
void CPlayer::ScopingCheck()
|
||||
{
|
||||
if(do_scoped)
|
||||
MF_ExecuteForward(iFScopeForward, index, (int)is_scoped);
|
||||
}
|
||||
|
||||
void CPlayer::WeaponsCheck(int weapons)
|
||||
{
|
||||
if(wpns_bitfield == 0)
|
||||
return;
|
||||
|
||||
else if(pEdict->v.weapons == 0)
|
||||
return;
|
||||
|
||||
int old;
|
||||
int cur;
|
||||
|
||||
for(int i = 1; i < MAX_WEAPONS; ++i)
|
||||
{
|
||||
// Check to see we are not talking about a grenade and we have changed
|
||||
if(i != 13 && i != 14 && i != 15 && i != 16 && i != 36)
|
||||
{
|
||||
old = wpns_bitfield&(1<<i);
|
||||
cur = weapons&(1<<i);
|
||||
|
||||
if(old != cur)
|
||||
MF_ExecuteForward(iFWpnPickupForward, index, i, ((weapons&(1<<i)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************
|
||||
// class Grenades
|
||||
// *****************************************************
|
||||
void Grenades::put(edict_t* grenade, float time, int type, CPlayer* player )
|
||||
{
|
||||
Obj* a = new Obj;
|
||||
a->player = player;
|
||||
a->grenade = grenade;
|
||||
a->time = gpGlobals->time + time;
|
||||
a->type = type;
|
||||
a->next = head;
|
||||
head = a;
|
||||
}
|
||||
|
||||
bool Grenades::find( edict_t* enemy, CPlayer** p, int& type )
|
||||
{
|
||||
bool found = false;
|
||||
float lastTime = 0.0;
|
||||
Obj** a = &head;
|
||||
|
||||
while(*a)
|
||||
{
|
||||
if((*a)->time > gpGlobals->time)
|
||||
{
|
||||
if((*a)->grenade == enemy)
|
||||
{
|
||||
found = true;
|
||||
|
||||
// we need this because of catched grenades
|
||||
if((*a)->time > lastTime)
|
||||
{
|
||||
(*p) = (*a)->player; // two people can have the same nade in our list
|
||||
type = (*a)->type;
|
||||
lastTime = (*a)->time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Obj* next = (*a)->next;
|
||||
delete *a;
|
||||
*a = next;
|
||||
continue;
|
||||
}
|
||||
|
||||
a = &(*a)->next;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void Grenades::clear()
|
||||
{
|
||||
while(head)
|
||||
{
|
||||
Obj* a = head->next;
|
||||
delete head;
|
||||
head = a;
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************
|
||||
|
@ -47,101 +47,131 @@
|
||||
|
||||
#define MAX_TRACE 6
|
||||
|
||||
struct traceVault {
|
||||
struct traceVault
|
||||
{
|
||||
char szName[16];
|
||||
int iId;
|
||||
int iAction;
|
||||
float fDel;
|
||||
};
|
||||
|
||||
#define ACT_NADE_NONE 0
|
||||
#define ACT_NADE_SHOT 1<<0
|
||||
#define ACT_NADE_PUT 1<<1
|
||||
#define ACT_NADE_THROW 1<<2
|
||||
#define ACT_NADE_NONE (0)
|
||||
#define ACT_NADE_SHOT (1<<0)
|
||||
#define ACT_NADE_PUT (1<<1)
|
||||
#define ACT_NADE_THROW (1<<2)
|
||||
|
||||
#define ACT_ROCKET_NONE (0)
|
||||
#define ACT_ROCKET_SHOT (1<<0)
|
||||
#define ACT_ROCKET_PUT (1<<3)
|
||||
|
||||
|
||||
// *****************************************************
|
||||
// class CPlayer
|
||||
// *****************************************************
|
||||
|
||||
class CPlayer {
|
||||
private:
|
||||
char ip[32];
|
||||
public:
|
||||
edict_t* pEdict;
|
||||
int index;
|
||||
int aiming;
|
||||
int current;
|
||||
int wpnModel;
|
||||
class CPlayer
|
||||
{
|
||||
private:
|
||||
char ip[32];
|
||||
|
||||
float savedScore;
|
||||
int lastScore;
|
||||
int sendScore;
|
||||
public:
|
||||
edict_t* pEdict;
|
||||
int index;
|
||||
int aiming;
|
||||
int current;
|
||||
int old;
|
||||
int wpnModel;
|
||||
int wpnscount;
|
||||
int wpns_bitfield;
|
||||
int old_weapons[DODMAX_WEAPONS];
|
||||
|
||||
bool ingame;
|
||||
bool bot;
|
||||
float clearStats;
|
||||
float clearRound;
|
||||
float savedScore;
|
||||
int lastScore;
|
||||
int sendScore;
|
||||
|
||||
struct PlayerWeapon : public Stats {
|
||||
char* name;
|
||||
int ammo;
|
||||
int clip;
|
||||
};
|
||||
bool ingame;
|
||||
bool bot;
|
||||
float clearStats;
|
||||
float clearRound;
|
||||
|
||||
PlayerWeapon weapons[DODMAX_WEAPONS];
|
||||
PlayerWeapon attackers[33];
|
||||
PlayerWeapon victims[33];
|
||||
Stats weaponsLife[DODMAX_WEAPONS]; // DEC-Weapon (Life) stats
|
||||
Stats weaponsRnd[DODMAX_WEAPONS]; // DEC-Weapon (Round) stats
|
||||
Stats life;
|
||||
Stats round;
|
||||
int oldteam;
|
||||
int olddeadflag;
|
||||
int oldclass;
|
||||
float oldstamina;
|
||||
|
||||
RankSystem::RankStats* rank;
|
||||
struct ModelStruct
|
||||
{
|
||||
int body_num;
|
||||
bool is_model_set;
|
||||
char* modelclass;
|
||||
}
|
||||
sModel;
|
||||
|
||||
void Init( int pi, edict_t* pe );
|
||||
void Connect(const char* name,const char* ip );
|
||||
void PutInServer();
|
||||
void Disconnect();
|
||||
void saveKill(CPlayer* pVictim, int weapon, int hs, int tk);
|
||||
void saveHit(CPlayer* pVictim, int weapon, int damage, int aiming);
|
||||
void saveShot(int weapon);
|
||||
void updateScore(int weapon, int score);
|
||||
void restartStats(bool all = true);
|
||||
void killPlayer();
|
||||
int oldprone;
|
||||
bool do_scoped;
|
||||
bool is_scoped;
|
||||
|
||||
// Zors
|
||||
int oldteam;
|
||||
int olddeadflag;
|
||||
int oldplayerclass;
|
||||
struct ObjectStruct
|
||||
{
|
||||
edict_t* pEdict;
|
||||
bool carrying;
|
||||
bool do_forward;
|
||||
int type;
|
||||
}
|
||||
object;
|
||||
|
||||
bool is_model_set;
|
||||
char* newmodel;
|
||||
int body_num;
|
||||
struct PlayerWeapon : public Stats
|
||||
{
|
||||
char* name;
|
||||
int ammo;
|
||||
int clip;
|
||||
};
|
||||
|
||||
int position;
|
||||
PlayerWeapon weapons[DODMAX_WEAPONS];
|
||||
PlayerWeapon attackers[33];
|
||||
PlayerWeapon victims[33];
|
||||
Stats weaponsLife[DODMAX_WEAPONS]; // DEC-Weapon (Life) stats
|
||||
Stats weaponsRnd[DODMAX_WEAPONS]; // DEC-Weapon (Round) stats
|
||||
Stats life;
|
||||
Stats round;
|
||||
|
||||
void initModel(char*);
|
||||
void clearModel();
|
||||
bool setModel();
|
||||
void setBody(int);
|
||||
void checkStatus();
|
||||
// Zors
|
||||
RankSystem::RankStats* rank;
|
||||
|
||||
inline bool IsBot(){
|
||||
const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict);
|
||||
return ( auth && !strcmp( auth , "BOT" ) );
|
||||
}
|
||||
inline bool IsAlive(){
|
||||
return ((pEdict->v.deadflag==DEAD_NO)&&(pEdict->v.health>0));
|
||||
}
|
||||
void Init( int pi, edict_t* pe );
|
||||
void Connect(const char* name,const char* ip );
|
||||
void PutInServer();
|
||||
void Disconnect();
|
||||
void saveKill(CPlayer* pVictim, int weapon, int hs, int tk);
|
||||
void saveHit(CPlayer* pVictim, int weapon, int damage, int aiming);
|
||||
void saveShot(int weapon);
|
||||
void updateScore(int weapon, int score);
|
||||
void restartStats(bool all = true);
|
||||
void killPlayer();
|
||||
void initModel(char*);
|
||||
void clearModel();
|
||||
bool setModel();
|
||||
void setBody(int);
|
||||
void PreThink();
|
||||
void Scoping(int);
|
||||
void ScopingCheck();
|
||||
void WeaponsCheck(int);
|
||||
|
||||
inline bool IsBot()
|
||||
{
|
||||
const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict);
|
||||
return ( auth && !strcmp( auth , "BOT" ) );
|
||||
}
|
||||
|
||||
inline bool IsAlive()
|
||||
{
|
||||
return ((pEdict->v.deadflag==DEAD_NO)&&(pEdict->v.health>0));
|
||||
}
|
||||
};
|
||||
|
||||
// *****************************************************
|
||||
// class Grenades
|
||||
// *****************************************************
|
||||
|
||||
class Grenades
|
||||
class Grenades // : public CObject
|
||||
{
|
||||
struct Obj
|
||||
{
|
||||
@ -154,11 +184,11 @@ class Grenades
|
||||
|
||||
|
||||
public:
|
||||
Grenades() { head = 0; }
|
||||
~Grenades() { clear(); }
|
||||
void put( edict_t* grenade, float time, int type, CPlayer* player );
|
||||
bool find( edict_t* enemy, CPlayer** p, int& type );
|
||||
void clear();
|
||||
Grenades() { head = 0; }
|
||||
~Grenades() { clear(); }
|
||||
void put(edict_t* grenade, float time, int type, CPlayer* player);
|
||||
bool find(edict_t* enemy, CPlayer** p, int& type);
|
||||
void clear();
|
||||
};
|
||||
|
||||
// *****************************************************
|
||||
@ -178,5 +208,7 @@ public:
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CMISC_H
|
||||
|
||||
|
@ -32,62 +32,134 @@
|
||||
#include "amxxmodule.h"
|
||||
#include "dodx.h"
|
||||
|
||||
static cell AMX_NATIVE_CALL get_weapon_name(AMX *amx, cell *params){ // from id to name 3 params id, name, len
|
||||
#define WEAPONLIST 71
|
||||
|
||||
/* Weapon names aren't send in WeaponList message in DoD */
|
||||
weaponlist_s weaponlist[] =
|
||||
{
|
||||
{ 0, 0, 0, false}, // 0,
|
||||
{ -1, 0, -1, true }, // DODW_AMERKNIFE = 1,
|
||||
{ -1, 0, -1, true }, // DODW_GERKNIFE,
|
||||
{ 4, 64, 7, true }, // DODW_COLT,
|
||||
{ 4, 64, 8, true }, // DODW_LUGER,
|
||||
{ 3, 128, 8, true }, // DODW_GARAND,
|
||||
{ 3, 128, 5, true }, // DODW_SCOPED_KAR,
|
||||
{ 1, 128, 30, true }, // DODW_THOMPSON,
|
||||
{ 6, 128, 30, true }, // DODW_STG44,
|
||||
{ 5, 128, 5, true }, // DODW_SPRINGFIELD,
|
||||
{ 3, 128, 5, true }, // DODW_KAR,
|
||||
{ 6, 128, 20, true }, // DODW_BAR,
|
||||
{ 1, 130, 30, true }, // DODW_MP40,
|
||||
{ 9, 24, -1, true }, // DODW_HANDGRENADE,
|
||||
{ 11, 24, -1, true }, // DODW_STICKGRENADE,
|
||||
{ 12, 24, -1, true }, // DODW_STICKGRENADE_EX,
|
||||
{ 10, 24, -1, true }, // DODW_HANDGRENADE_EX,
|
||||
{ 7, 2178, 250, true }, // DODW_MG42,
|
||||
{ 8, 130, 150, true }, // DODW_30_CAL,
|
||||
{ -1, 0, -1, true }, // DODW_SPADE,
|
||||
{ 2, 128, 15, true }, // DODW_M1_CARBINE,
|
||||
{ 2, 130, 75, true }, // DODW_MG34,
|
||||
{ 1, 128, 30, true }, // DODW_GREASEGUN,
|
||||
{ 6, 128, 20, true }, // DODW_FG42,
|
||||
{ 2, 128, 10, true }, // DODW_K43,
|
||||
{ 3, 128, 10, true }, // DODW_ENFIELD,
|
||||
{ 1, 128, 30, true }, // DODW_STEN,
|
||||
{ 6, 128, 30, true }, // DODW_BREN,
|
||||
{ 4, 64, 6, true }, // DODW_WEBLEY,
|
||||
{ 13, 642, 1, true }, // DODW_BAZOOKA,
|
||||
{ 13, 642, 1, true }, // DODW_PANZERSCHRECK,
|
||||
{ 13, 642, 1, true }, // DODW_PIAT,
|
||||
{ 3, 128, 20, true }, // DODW_SCOPED_FG42, UNSURE ABOUT THIS ONE
|
||||
{ 2, 128, 15, true }, // DODW_FOLDING_CARBINE,
|
||||
{ 0, 0, 0, false}, // DODW_KAR_BAYONET,
|
||||
{ 3, 128, 10, true }, // DODW_SCOPED_ENFIELD, UNSURE ABOUT THIS ONE
|
||||
{ 9, 24, -1, true }, // DODW_MILLS_BOMB,
|
||||
{ -1, 0, -1, true }, // DODW_BRITKNIFE,
|
||||
{ 38, 0, 0, false}, // DODW_GARAND_BUTT,
|
||||
{ 39, 0, 0, false}, // DODW_ENFIELD_BAYONET,
|
||||
{ 40, 0, 0, false}, // DODW_MORTAR,
|
||||
{ 41, 0, 0, false}, // DODW_K43_BUTT,
|
||||
};
|
||||
|
||||
// from id to name 3 params id, name, len
|
||||
static cell AMX_NATIVE_CALL get_weapon_name(AMX *amx, cell *params)
|
||||
{
|
||||
int id = params[1];
|
||||
if (id<0 || id>=DODMAX_WEAPONS){
|
||||
|
||||
if(id < 0 || id >= DODMAX_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
|
||||
// from log to name
|
||||
static cell AMX_NATIVE_CALL wpnlog_to_name(AMX *amx, cell *params)
|
||||
{
|
||||
int iLen;
|
||||
char *log = MF_GetAmxString(amx,params[1],0,&iLen);
|
||||
int i;
|
||||
for ( i=0; i<DODMAX_WEAPONS; i++ ){
|
||||
if ( strcmp(log,weaponData[i].logname ) == 0 )
|
||||
|
||||
for(int i = 0; i < DODMAX_WEAPONS; i++)
|
||||
{
|
||||
if(strcmp(log,weaponData[i].logname ) == 0)
|
||||
return MF_SetAmxString(amx,params[2],weaponData[i].name,params[3]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL wpnlog_to_id(AMX *amx, cell *params){ // from log to id
|
||||
// from log to id
|
||||
static cell AMX_NATIVE_CALL wpnlog_to_id(AMX *amx, cell *params)
|
||||
{
|
||||
int iLen;
|
||||
char *log = MF_GetAmxString(amx,params[1],0,&iLen);
|
||||
char *log = MF_GetAmxString(amx, params[1], 0, &iLen);
|
||||
|
||||
int i;
|
||||
for ( i=0; i<DODMAX_WEAPONS; i++ ){
|
||||
if ( strcmp(log,weaponData[i].logname) == 0 )
|
||||
for(int i = 0; i < DODMAX_WEAPONS; i++)
|
||||
{
|
||||
if(strcmp(log,weaponData[i].logname) == 0)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_weapon_logname(AMX *amx, cell *params){ // from id to log
|
||||
// from id to log
|
||||
static cell AMX_NATIVE_CALL get_weapon_logname(AMX *amx, cell *params)
|
||||
{
|
||||
int id = params[1];
|
||||
if (id<0 || id>=DODMAX_WEAPONS){
|
||||
|
||||
if (id<0 || id>=DODMAX_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){
|
||||
static cell AMX_NATIVE_CALL is_melee(AMX *amx, cell *params)
|
||||
{
|
||||
int id = params[1];
|
||||
if (id<0 || id>=DODMAX_WEAPONS){
|
||||
|
||||
if(id < 0 || id >= DODMAX_WEAPONS)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return weaponData[id].melee;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_team_score(AMX *amx, cell *params){
|
||||
static cell AMX_NATIVE_CALL get_team_score(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
switch ( index ){
|
||||
|
||||
switch ( index )
|
||||
{
|
||||
case 1:
|
||||
return AlliesScore;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
return AxisScore;
|
||||
break;
|
||||
@ -95,30 +167,38 @@ static cell AMX_NATIVE_CALL get_team_score(AMX *amx, cell *params){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_user_score(AMX *amx, cell *params){
|
||||
static cell AMX_NATIVE_CALL get_user_score(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
return (cell)pPlayer->savedScore;
|
||||
return (cell)pPlayer->savedScore;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_user_class(AMX *amx, cell *params){
|
||||
static cell AMX_NATIVE_CALL get_user_class(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
return pPlayer->pEdict->v.playerclass;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL user_kill(AMX *amx, cell *params){
|
||||
static cell AMX_NATIVE_CALL user_kill(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (pPlayer->ingame && pPlayer->IsAlive() ){
|
||||
if(pPlayer->ingame && pPlayer->IsAlive())
|
||||
{
|
||||
pPlayer->killPlayer();
|
||||
return 1;
|
||||
}
|
||||
@ -126,17 +206,22 @@ static cell AMX_NATIVE_CALL user_kill(AMX *amx, cell *params){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_map_info(AMX *amx, cell *params){
|
||||
switch( params[1] ){
|
||||
static cell AMX_NATIVE_CALL get_map_info(AMX *amx, cell *params)
|
||||
{
|
||||
switch(params[1])
|
||||
{
|
||||
case 0:
|
||||
return g_map.detect_allies_country;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
return g_map.detect_allies_paras;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
return g_map.detect_axis_paras;
|
||||
break;
|
||||
|
||||
default:
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid map info id %d", params[1]);
|
||||
break;
|
||||
@ -144,21 +229,26 @@ static cell AMX_NATIVE_CALL get_map_info(AMX *amx, cell *params){
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_user_pronestate(AMX *amx, cell *params){
|
||||
static cell AMX_NATIVE_CALL get_user_pronestate(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
return pPlayer->pEdict->v.iuser3;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){
|
||||
static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (pPlayer->ingame){
|
||||
|
||||
if (pPlayer->ingame)
|
||||
{
|
||||
int wpn = pPlayer->current;
|
||||
cell *cpTemp = MF_GetAmxAddr(amx,params[2]);
|
||||
*cpTemp = pPlayer->weapons[wpn].clip;
|
||||
@ -170,55 +260,100 @@ static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
|
||||
{ // forward
|
||||
/* We want to get just the weapon of whichever type that the player is on him */
|
||||
static cell AMX_NATIVE_CALL dod_weapon_type(AMX *amx, cell *params) /* 2 params */
|
||||
{
|
||||
int index = params[1];
|
||||
int type = params[2];
|
||||
|
||||
#ifdef FORWARD_OLD_SYSTEM
|
||||
CHECK_PLAYER(index);
|
||||
|
||||
int iFunctionIndex;
|
||||
int err;
|
||||
switch( params[1] ){
|
||||
case 0:
|
||||
if( (err=MF_AmxFindPublic(amx, "client_damage", &iFunctionIndex)) == AMX_ERR_NONE )
|
||||
g_damage_info.put( amx , iFunctionIndex );
|
||||
else
|
||||
MF_LogError(amx, err, "client_damage not found");
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
if( (err=MF_AmxFindPublic(amx, "client_death", &iFunctionIndex)) == AMX_ERR_NONE )
|
||||
g_death_info.put( amx , iFunctionIndex );
|
||||
else
|
||||
MF_LogError(amx, err, "client_Death not found");
|
||||
return 0;
|
||||
break;
|
||||
case 2:
|
||||
if( (err=MF_AmxFindPublic(amx, "client_score", &iFunctionIndex)) == AMX_ERR_NONE )
|
||||
g_score_info.put( amx , iFunctionIndex );
|
||||
else
|
||||
MF_LogError(amx, err, "client_score not found");
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid forward id %d", params[2]);
|
||||
if(type < DODWT_PRIMARY || type > DODWT_OTHER)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon type id %d", type);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if(pPlayer->ingame)
|
||||
{
|
||||
int weaponsbit = pPlayer->pEdict->v.weapons & ~(1<<31); // don't count last element
|
||||
|
||||
for(int x = 1; x < MAX_WEAPONS; ++x)
|
||||
{
|
||||
if((weaponsbit&(1<<x)) > 0)
|
||||
{
|
||||
if(weaponData[x].type == type)
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// forward
|
||||
static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
|
||||
{
|
||||
|
||||
#ifdef FORWARD_OLD_SYSTEM
|
||||
int iFunctionIndex;
|
||||
int err;
|
||||
switch( params[1] )
|
||||
{
|
||||
case 0:
|
||||
if((err = MF_AmxFindPublic(amx, "client_damage", &iFunctionIndex)) == AMX_ERR_NONE)
|
||||
g_damage_info.put( amx , iFunctionIndex );
|
||||
|
||||
else
|
||||
MF_LogError(amx, err, "client_damage not found");
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if((err = MF_AmxFindPublic(amx, "client_death", &iFunctionIndex)) == AMX_ERR_NONE)
|
||||
g_death_info.put( amx , iFunctionIndex );
|
||||
|
||||
else
|
||||
MF_LogError(amx, err, "client_Death not found");
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if((err = MF_AmxFindPublic(amx, "client_score", &iFunctionIndex)) == AMX_ERR_NONE)
|
||||
g_score_info.put( amx , iFunctionIndex );
|
||||
|
||||
else
|
||||
MF_LogError(amx, err, "client_score not found");
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid forward id %d", params[2]);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logname,melee=0
|
||||
// name,logname,melee=0
|
||||
static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params)
|
||||
{
|
||||
int i;
|
||||
bool bFree = false;
|
||||
for ( i=DODMAX_WEAPONS-DODMAX_CUSTOMWPNS;i<DODMAX_WEAPONS;i++){
|
||||
if ( !weaponData[i].needcheck ){
|
||||
|
||||
for(i = DODMAX_WEAPONS - DODMAX_CUSTOMWPNS; i < DODMAX_WEAPONS; i++)
|
||||
{
|
||||
if(!weaponData[i].needcheck)
|
||||
{
|
||||
bFree = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !bFree )
|
||||
if(!bFree)
|
||||
return 0;
|
||||
|
||||
int iLen;
|
||||
@ -232,9 +367,14 @@ static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logna
|
||||
return i;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
|
||||
// wid,att,vic,dmg,hp=0
|
||||
static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params)
|
||||
{
|
||||
int weapon = params[1];
|
||||
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){ // only for custom weapons
|
||||
|
||||
// only for custom weapons
|
||||
if(weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon);
|
||||
return 0;
|
||||
}
|
||||
@ -246,13 +386,15 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg
|
||||
CHECK_PLAYER(params[3]);
|
||||
|
||||
int dmg = params[4];
|
||||
if ( dmg<1 ){
|
||||
if(dmg<1)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid damage %d", dmg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int aim = params[5];
|
||||
if ( aim < 0 || aim > 7 ){
|
||||
if(aim < 0 || aim > 7)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim);
|
||||
return 0;
|
||||
}
|
||||
@ -262,33 +404,39 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg
|
||||
|
||||
pVic->pEdict->v.dmg_inflictor = NULL;
|
||||
|
||||
if ( pAtt->index != pVic->index )
|
||||
pAtt->saveHit( pVic , weapon , dmg, aim );
|
||||
if(pAtt->index != pVic->index)
|
||||
pAtt->saveHit(pVic , weapon , dmg, aim);
|
||||
|
||||
if(!pAtt)
|
||||
pAtt = pVic;
|
||||
|
||||
if ( !pAtt ) pAtt = pVic;
|
||||
int TA = 0;
|
||||
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) )
|
||||
|
||||
if((pVic->pEdict->v.team == pAtt->pEdict->v.team) && (pVic != pAtt))
|
||||
TA = 1;
|
||||
|
||||
MF_ExecuteForward( iFDamage,pAtt->index, pVic->index, dmg, weapon, aim, TA );
|
||||
MF_ExecuteForward(iFDamage,pAtt->index, pVic->index, dmg, weapon, aim, TA);
|
||||
|
||||
if ( pVic->IsAlive() )
|
||||
if(pVic->IsAlive())
|
||||
return 1;
|
||||
|
||||
pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);
|
||||
|
||||
MF_ExecuteForward( iFDeath,pAtt->index, pVic->index, weapon, aim, TA );
|
||||
MF_ExecuteForward(iFDeath,pAtt->index, pVic->index, weapon, aim, TA);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid
|
||||
// player,wid
|
||||
static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[2];
|
||||
|
||||
CHECK_PLAYER(index);
|
||||
|
||||
int weapon = params[1];
|
||||
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){
|
||||
if(weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon);
|
||||
return 0;
|
||||
}
|
||||
@ -299,23 +447,30 @@ static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){
|
||||
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){
|
||||
static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params)
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params){
|
||||
static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params)
|
||||
{
|
||||
int weapon = params[1];
|
||||
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){
|
||||
|
||||
if(weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL dod_get_user_team(AMX *amx, cell *params){ // player,wid
|
||||
// player,wid
|
||||
static cell AMX_NATIVE_CALL dod_get_user_team(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
|
||||
@ -324,22 +479,29 @@ static cell AMX_NATIVE_CALL dod_get_user_team(AMX *amx, cell *params){ // player
|
||||
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params){ // player,wid
|
||||
// player,wid
|
||||
static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
CHECK_PLAYER(index);
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
int iTeam = pPlayer->pEdict->v.team;
|
||||
if ( params[3] ){
|
||||
|
||||
if ( params[3] )
|
||||
{
|
||||
char *szTeam = "";
|
||||
switch(iTeam){
|
||||
switch(iTeam)
|
||||
{
|
||||
case 1:
|
||||
szTeam = "Allies";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
szTeam = "Axis";
|
||||
break;
|
||||
}
|
||||
|
||||
MF_SetAmxString(amx,params[2],szTeam,params[3]);
|
||||
}
|
||||
return iTeam;
|
||||
@ -352,7 +514,10 @@ static cell AMX_NATIVE_CALL dod_set_model(AMX *amx, cell *params) // player,mode
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if(!pPlayer->ingame)
|
||||
return false;
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid Player, Not on Server");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int length;
|
||||
pPlayer->initModel((char*)STRING(ALLOC_STRING(MF_GetAmxString(amx, params[2], 1, &length))));
|
||||
@ -367,7 +532,10 @@ static cell AMX_NATIVE_CALL dod_set_body(AMX *amx, cell *params) // player,bodyn
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if(!pPlayer->ingame)
|
||||
return false;
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid Player, Not on Server");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pPlayer->setBody(params[2]);
|
||||
|
||||
@ -388,8 +556,70 @@ static cell AMX_NATIVE_CALL dod_clear_model(AMX *amx, cell *params) // player
|
||||
return true;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO base_Natives[] = {
|
||||
/*
|
||||
0 [Byte] 1 // Weapons Groupings
|
||||
1 [Byte] 210 // Total Rounds Allowed
|
||||
2 [Byte] -1 // Undefined Not Used
|
||||
3 [Byte] -1 // Undefined Not Used
|
||||
4 [Byte] 2 // Weapon Slot
|
||||
5 [Byte] 0 // Bucket ( Position Under Weapon Slot )
|
||||
6 [Short] 7 // Weapon Number / Bit Field for the weapon
|
||||
7 [Byte] 128 // Bit Field for the Ammo or Ammo Type
|
||||
8 [Byte] 30 // Rounds Per Mag
|
||||
|
||||
id, wpnID, slot, position, totalrds
|
||||
*/
|
||||
static cell AMX_NATIVE_CALL dod_weaponlist(AMX *amx, cell *params) // player
|
||||
{
|
||||
if(!weaponlist[params[1]].changeable)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "This Weapon Cannot be Changed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int id = params[1];
|
||||
int wpnID = params[2];
|
||||
int slot = params[3];
|
||||
int position = params[4];
|
||||
int totalrds = params[5];
|
||||
|
||||
UTIL_LogPrintf("ID (%d) WpnID (%d) Slot (%d) Pos (%d) Rounds (%d)", id, wpnID, slot, position, totalrds);
|
||||
|
||||
CHECK_PLAYER(id);
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(id);
|
||||
if(!pPlayer->ingame)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid Player, Not on Server");
|
||||
return 0;
|
||||
}
|
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "WeaponList", NULL), NULL, INDEXENT(id));
|
||||
WRITE_BYTE(weaponlist[wpnID].grp);
|
||||
WRITE_BYTE(totalrds);
|
||||
WRITE_BYTE(-1);
|
||||
WRITE_BYTE(-1);
|
||||
WRITE_BYTE(slot - 1);
|
||||
WRITE_BYTE(position);
|
||||
WRITE_SHORT(wpnID);
|
||||
WRITE_BYTE(weaponlist[wpnID].bitfield);
|
||||
|
||||
// Is it grenades
|
||||
if(wpnID == 13 || wpnID == 14 || wpnID == 15 || wpnID == 16 || wpnID == 36)
|
||||
WRITE_BYTE(-1);
|
||||
else if(wpnID == 29 || wpnID == 30 || wpnID == 31)
|
||||
WRITE_BYTE(1);
|
||||
else
|
||||
WRITE_BYTE(weaponlist[wpnID].clip);
|
||||
MESSAGE_END();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AMX_NATIVE_INFO base_Natives[] =
|
||||
{
|
||||
{ "dod_wpnlog_to_name", wpnlog_to_name },
|
||||
{ "dod_wpnlog_to_id", wpnlog_to_id },
|
||||
|
||||
@ -397,6 +627,8 @@ AMX_NATIVE_INFO base_Natives[] = {
|
||||
{ "dod_get_user_score", get_user_score },
|
||||
{ "dod_get_user_class", get_user_class },
|
||||
{ "dod_get_user_weapon", get_user_weapon },
|
||||
|
||||
{ "dod_weapon_type", dod_weapon_type },
|
||||
|
||||
{ "dod_get_map_info", get_map_info },
|
||||
{ "dod_user_kill", user_kill },
|
||||
@ -426,10 +658,10 @@ AMX_NATIVE_INFO base_Natives[] = {
|
||||
{ "dod_get_wpnlogname", get_weapon_logname },
|
||||
{ "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},
|
||||
{"dod_set_weaponlist", dod_weaponlist},
|
||||
|
||||
///*******************
|
||||
{ NULL, NULL }
|
||||
|
@ -33,113 +33,140 @@
|
||||
#include "dodx.h"
|
||||
|
||||
/* Weapon names aren't send in WeaponList message in DoD */
|
||||
weapon_t weaponData[] = {
|
||||
{ false,false,"mortar","mortar",0 },
|
||||
{ true,true,"amerknife","knife",0 }, // aknife->bknife
|
||||
{ false,true,"gerknife","knife",0 },
|
||||
{ false,false,"colt","Colt",4 },
|
||||
{ false,false,"luger","Luger",4 },
|
||||
{ true,false,"garand","Garand",3 }, // Garand->Garand butt
|
||||
{ false,false,"scopedkar","scoped K98",3 },
|
||||
{ false,false,"thompson","Thompson",1 },
|
||||
{ false,false,"mp44","STG44",6 },
|
||||
{ false,false,"spring","Springfield",5 },
|
||||
{ true,false,"kar","K98",3 }, // KAR->KAR bayonet
|
||||
{ false,false,"bar","BAR",6 },
|
||||
{ false,false,"mp40","MP40",1 },
|
||||
{ false,false,"grenade","handgrenade",9 },
|
||||
{ false,false,"grenade2","stickgrenade",11 },
|
||||
{ false,false,"stickgrenade_ex","stickgrenade_ex",11 },
|
||||
{ false,false,"handgrenade_ex","handgrenade_ex",9 },
|
||||
{ false,false,"mg42","MG42",7 },
|
||||
{ false,false,"30cal",".30 cal",8 },
|
||||
{ false,true,"spade","spade",0 },
|
||||
{ true,false,"m1carbine","M1 Carbine",2 }, // M1 Carbine->Folding Carbine
|
||||
{ false,false,"mg34","MG34",2 },
|
||||
{ false,false,"greasegun","Greasegun",1 },
|
||||
{ true,false,"fg42","FG42",6 }, // FG42 -> scoped FG42
|
||||
{ true,false,"k43","K43",2 },
|
||||
{ true,false,"enfield","Enfield",3 }, // Enfield->Scoped Enfield->Enfield bayonet
|
||||
{ false,false,"sten","Sten",1 },
|
||||
{ false,false,"bren","Bren",6 },
|
||||
{ false,false,"webley","Webley",4 },
|
||||
{ false,false,"bazooka","Bazooka",13 },
|
||||
{ false,false,"pschreck","Panzerschrek",13 },
|
||||
{ false,false,"piat","Piat",13 },
|
||||
{ false,false,"scoped_fg42","scoped FG42",6 },
|
||||
{ false,false,"fcarbine","Folding Carbine" },
|
||||
{ false,true,"bayonet","K98 bayonet",0 }, // KAR bayonet
|
||||
{ false,false,"scoped_enfield","scoped Enfield",3 },
|
||||
{ false,false,"mills_bomb","mills bomb",9 },
|
||||
{ false,true,"brit_knife","knife",0 },
|
||||
{ false,true,"garandbutt","Garand butt",0 }, // Garand butt
|
||||
{ false,true,"enf_bayonet","Enfield bayonet",0 },
|
||||
{ false,false,"mortar","mortar",0 }, // mortar new id
|
||||
{ false,true,"k43butt","K43 butt",0 },
|
||||
weapon_t weaponData[] =
|
||||
{
|
||||
{ false, false, "mortar", "mortar", 0, DODWT_OTHER },
|
||||
{ true, true, "amerknife", "knife", 0, DODWT_MELEE }, // aknife->bknife
|
||||
{ false, true, "gerknife", "knife", 0, DODWT_MELEE },
|
||||
{ false, false, "colt", "Colt", 4, DODWT_SECONDARY },
|
||||
{ false, false, "luger", "Luger", 4, DODWT_SECONDARY },
|
||||
{ true, false, "garand", "Garand", 3, DODWT_PRIMARY }, // Garand->Garand butt
|
||||
{ false, false, "scopedkar", "scoped K98", 3, DODWT_PRIMARY },
|
||||
{ false, false, "thompson", "Thompson", 1, DODWT_PRIMARY },
|
||||
{ false, false, "mp44", "STG44", 6, DODWT_PRIMARY },
|
||||
{ false, false, "spring", "Springfield", 5, DODWT_PRIMARY },
|
||||
{ true, false, "kar", "K98", 3, DODWT_PRIMARY }, // KAR->KAR bayonet
|
||||
{ false, false, "bar", "BAR", 6, DODWT_PRIMARY },
|
||||
{ false, false, "mp40", "MP40", 1, DODWT_PRIMARY },
|
||||
{ false, false, "grenade", "handgrenade", 9, DODWT_GRENADE },
|
||||
{ false, false, "grenade2", "stickgrenade", 11, DODWT_GRENADE },
|
||||
{ false, false, "stickgrenade_ex", "stickgrenade_ex", 11, DODWT_GRENADE },
|
||||
{ false, false, "handgrenade_ex", "handgrenade_ex", 9, DODWT_GRENADE },
|
||||
{ false, false, "mg42", "MG42", 7, DODWT_PRIMARY },
|
||||
{ false, false, "30cal", ".30 cal", 8, DODWT_PRIMARY },
|
||||
{ false, true, "spade", "spade", 0, DODWT_MELEE },
|
||||
{ true, false, "m1carbine", "M1 Carbine", 2, DODWT_PRIMARY }, // M1 Carbine->Folding Carbine
|
||||
{ false, false, "mg34", "MG34", 2, DODWT_PRIMARY },
|
||||
{ false, false, "greasegun", "Greasegun", 1, DODWT_PRIMARY },
|
||||
{ true, false, "fg42", "FG42", 6, DODWT_PRIMARY }, // FG42 -> scoped FG42
|
||||
{ true, false, "k43", "K43", 2, DODWT_PRIMARY },
|
||||
{ true, false, "enfield", "Enfield", 3, DODWT_PRIMARY }, // Enfield->Scoped Enfield->Enfield bayonet
|
||||
{ false, false, "sten", "Sten", 1, DODWT_PRIMARY },
|
||||
{ false, false, "bren", "Bren", 6, DODWT_PRIMARY },
|
||||
{ false, false, "webley", "Webley", 4, DODWT_PRIMARY },
|
||||
{ false, false, "bazooka", "Bazooka", 13, DODWT_PRIMARY },
|
||||
{ false, false, "pschreck", "Panzerschrek", 13, DODWT_PRIMARY },
|
||||
{ false, false, "piat", "Piat", 13, DODWT_PRIMARY },
|
||||
{ false, false, "scoped_fg42", "scoped FG42", 6, DODWT_PRIMARY },
|
||||
{ false, false, "fcarbine", "Folding Carbine", 0, DODWT_PRIMARY },
|
||||
{ false, true, "bayonet", "K98 bayonet", 0, DODWT_MELEE }, // KAR bayonet
|
||||
{ false, false, "scoped_enfield", "scoped Enfield", 3, DODWT_PRIMARY },
|
||||
{ false, false, "mills_bomb", "mills bomb", 9, DODWT_GRENADE },
|
||||
{ false, true, "brit_knife", "knife", 0, DODWT_MELEE },
|
||||
{ false, true, "garandbutt", "Garand butt", 0, DODWT_MELEE }, // Garand butt
|
||||
{ false, true, "enf_bayonet", "Enfield bayonet", 0, DODWT_MELEE },
|
||||
{ false, false, "mortar", "mortar", 0, DODWT_OTHER }, // mortar new id
|
||||
{ false, true, "k43butt", "K43 butt", 0, DODWT_MELEE },
|
||||
};
|
||||
|
||||
/* Function will select correct id */
|
||||
int get_weaponid(CPlayer* pPlayer){
|
||||
int get_weaponid(CPlayer* pPlayer)
|
||||
{
|
||||
int weapon = pPlayer->current;
|
||||
const char *sz;
|
||||
switch(weapon) {
|
||||
case 1: if ( g_map.detect_allies_country ) weapon = 37; break;
|
||||
case 5: if ( pPlayer->pEdict->v.button&IN_ATTACK2 ) weapon = 38; break;
|
||||
case 10: if ( pPlayer->pEdict->v.button&IN_ATTACK2 ) weapon = 34; break;
|
||||
case 20:
|
||||
if ( g_map.detect_allies_paras ) weapon = 33;
|
||||
switch(weapon)
|
||||
{
|
||||
case 1:
|
||||
if(g_map.detect_allies_country) weapon = 37;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if(pPlayer->pEdict->v.button&IN_ATTACK2) weapon = 38;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
if(pPlayer->pEdict->v.button&IN_ATTACK2) weapon = 34;
|
||||
break;
|
||||
|
||||
case 20:
|
||||
if(g_map.detect_allies_paras) weapon = 33;
|
||||
break;
|
||||
|
||||
case 23:
|
||||
sz = STRING(pPlayer->pEdict->v.weaponmodel);
|
||||
if ( sz[13] == 's' )
|
||||
if(sz[13] == 's')
|
||||
weapon = 32;
|
||||
break;
|
||||
case 24: if ( pPlayer->pEdict->v.button&IN_ATTACK2 ) weapon = 41; break;
|
||||
|
||||
case 24:
|
||||
if(pPlayer->pEdict->v.button&IN_ATTACK2) weapon = 41;
|
||||
break;
|
||||
|
||||
case 25:
|
||||
sz = STRING(pPlayer->pEdict->v.weaponmodel);
|
||||
if ( sz[16] == 's' )
|
||||
if(sz[16] == 's')
|
||||
weapon = 35;
|
||||
else if ( pPlayer->pEdict->v.button&IN_ATTACK2 )
|
||||
else if(pPlayer->pEdict->v.button&IN_ATTACK2)
|
||||
weapon = 39;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
weapon = 14;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
if ( g_map.detect_allies_country ) weapon = 36;
|
||||
if(g_map.detect_allies_country) weapon = 36;
|
||||
else weapon = 13;
|
||||
break;
|
||||
}
|
||||
|
||||
return weapon;
|
||||
}
|
||||
|
||||
traceVault traceData[] = {
|
||||
traceVault traceData[] =
|
||||
{
|
||||
{ "grenade", 13, ACT_NADE_PUT|ACT_NADE_SHOT, 2.0 }, // or 36
|
||||
{ "grenade2", 14, ACT_NADE_PUT|ACT_NADE_SHOT, 2.0 },
|
||||
{ "shell_bazooka", 29, ACT_NADE_PUT, 2.0 },
|
||||
{ "shell_pschreck", 30, ACT_NADE_PUT, 2.0 },
|
||||
{ "shell_piat", 31, ACT_NADE_PUT, 2.0 },
|
||||
{ "shell_bazooka", 29, ACT_ROCKET_PUT|ACT_ROCKET_SHOT, 2.0 },
|
||||
{ "shell_pschreck", 30, ACT_ROCKET_PUT|ACT_ROCKET_SHOT, 2.0 },
|
||||
{ "shell_piat", 31, ACT_ROCKET_PUT|ACT_ROCKET_SHOT, 2.0 },
|
||||
{ "monster_mortar", 40, ACT_NADE_PUT|ACT_NADE_SHOT, 2.0 },
|
||||
};
|
||||
|
||||
bool ignoreBots (edict_t *pEnt, edict_t *pOther){
|
||||
if ( !rankBots && ( pEnt->v.flags & FL_FAKECLIENT || ( pOther && pOther->v.flags & FL_FAKECLIENT ) ) )
|
||||
bool ignoreBots (edict_t *pEnt, edict_t *pOther)
|
||||
{
|
||||
if(!rankBots && (pEnt->v.flags & FL_FAKECLIENT || (pOther && pOther->v.flags & FL_FAKECLIENT)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isModuleActive(){
|
||||
if ( !(int)CVAR_GET_FLOAT("dodstats_pause") )
|
||||
bool isModuleActive()
|
||||
{
|
||||
if(!(int)CVAR_GET_FLOAT("dodstats_pause"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
edict_t *FindEntityByString(edict_t *pentStart, const char *szKeyword, const char *szValue)
|
||||
{
|
||||
edict_t *pentEntity;
|
||||
pentEntity=FIND_ENTITY_BY_STRING(pentStart, szKeyword, szValue);
|
||||
pentEntity = FIND_ENTITY_BY_STRING(pentStart, szKeyword, szValue);
|
||||
|
||||
if(!FNullEnt(pentEntity))
|
||||
return pentEntity;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -147,3 +174,13 @@ edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName)
|
||||
{
|
||||
return FindEntityByString(pentStart, "classname", szName);
|
||||
}
|
||||
|
||||
edict_t *FindEntityInSphere(edict_t *pentStart, edict_t *origin, float radius)
|
||||
{
|
||||
edict_t* temp = FIND_ENTITY_IN_SPHERE(pentStart, origin->v.origin, radius);
|
||||
|
||||
if(!temp)
|
||||
return NULL;
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
@ -47,30 +47,64 @@ extern AMX_NATIVE_INFO stats_Natives[];
|
||||
extern AMX_NATIVE_INFO base_Natives[];
|
||||
extern AMX_NATIVE_INFO pd_Natives[];
|
||||
|
||||
struct weapon_t {
|
||||
// Weapons grabbing by type
|
||||
enum
|
||||
{
|
||||
DODWT_PRIMARY = 0,
|
||||
DODWT_SECONDARY,
|
||||
DODWT_MELEE,
|
||||
DODWT_GRENADE,
|
||||
DODWT_OTHER
|
||||
};
|
||||
|
||||
// Model Sequences
|
||||
enum
|
||||
{
|
||||
DOD_SEQ_PRONE_IDLE = 15,
|
||||
DOD_SEQ_PRONE_FORWARD,
|
||||
DOD_SEQ_PRONE_DOWN,
|
||||
DOD_SEQ_PRONE_UP
|
||||
};
|
||||
|
||||
// Weapons Structure
|
||||
struct weapon_t
|
||||
{
|
||||
bool needcheck;
|
||||
bool melee;
|
||||
char logname[16];
|
||||
char name[32];
|
||||
char hashname[32];
|
||||
int ammoSlot;
|
||||
int type;
|
||||
};
|
||||
|
||||
struct weaponlist_s
|
||||
{
|
||||
int grp;
|
||||
int bitfield;
|
||||
int clip;
|
||||
bool changeable;
|
||||
};
|
||||
|
||||
extern bool rankBots;
|
||||
extern int mState;
|
||||
extern int mDest;
|
||||
extern int mCurWpnEnd;
|
||||
extern int mPlayerIndex;
|
||||
|
||||
void Client_CurWeapon(void*);
|
||||
void Client_CurWeapon_End(void*);
|
||||
void Client_Health_End(void*);
|
||||
void Client_ResetHUD_End(void*);
|
||||
void Client_ObjScore(void*);
|
||||
void Client_TeamScore(void*);
|
||||
void Client_RoundState(void*);
|
||||
void Client_AmmoX(void*);
|
||||
void Client_AmmoShort(void*);
|
||||
void Client_Health_End(void*);
|
||||
|
||||
// Zors
|
||||
//void WeaponList(void*);
|
||||
//void WeaponList_End(void*);
|
||||
void Client_SetFOV(void*);
|
||||
void Client_SetFOV_End(void*);
|
||||
void Client_Object(void*);
|
||||
void Client_Object_End(void*);
|
||||
|
||||
typedef void (*funEventCall)(void*);
|
||||
|
||||
@ -78,6 +112,8 @@ extern int AlliesScore;
|
||||
extern int AxisScore;
|
||||
|
||||
extern int gmsgCurWeapon;
|
||||
extern int gmsgCurWeaponEnd;
|
||||
extern int gmsgHealth;
|
||||
extern int gmsgResetHUD;
|
||||
extern int gmsgObjScore;
|
||||
extern int gmsgRoundState;
|
||||
@ -86,7 +122,10 @@ extern int gmsgScoreShort;
|
||||
extern int gmsgPTeam;
|
||||
extern int gmsgAmmoX;
|
||||
extern int gmsgAmmoShort;
|
||||
extern int gmsgHealth_End;
|
||||
extern int gmsgSetFOV;
|
||||
extern int gmsgSetFOV_End;
|
||||
extern int gmsgObject;
|
||||
extern int gmsgObject_End;
|
||||
|
||||
extern int iFDamage;
|
||||
extern int iFDeath;
|
||||
@ -94,6 +133,14 @@ extern int iFScore;
|
||||
extern int iFSpawnForward;
|
||||
extern int iFTeamForward;
|
||||
extern int iFClassForward;
|
||||
extern int iFScopeForward;
|
||||
extern int iFProneForward;
|
||||
extern int iFWpnPickupForward;
|
||||
extern int iFCurWpnForward;
|
||||
extern int iFGrenadeExplode;
|
||||
extern int iFRocketExplode;
|
||||
extern int iFObjectTouched;
|
||||
extern int iFStaminaForward;
|
||||
|
||||
extern cvar_t* dodstats_maxsize;
|
||||
extern cvar_t* dodstats_rank;
|
||||
@ -113,7 +160,9 @@ extern CMapInfo g_map;
|
||||
int get_weaponid(CPlayer* player);
|
||||
bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL );
|
||||
bool isModuleActive();
|
||||
edict_t *FindEntityByString(edict_t *pentStart, const char *szKeyword, const char *szValue);
|
||||
edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName);
|
||||
edict_t *FindEntityInSphere(edict_t *pentStart, edict_t *origin, float radius);
|
||||
|
||||
#define CHECK_ENTITY(x) \
|
||||
if (x < 0 || x > gpGlobals->maxEntities) { \
|
||||
|
@ -42,6 +42,8 @@ CMapInfo g_map;
|
||||
|
||||
bool rankBots;
|
||||
int mState;
|
||||
int mDest;
|
||||
int mCurWpnEnd;
|
||||
int mPlayerIndex;
|
||||
|
||||
int AlliesScore;
|
||||
@ -50,13 +52,21 @@ int AxisScore;
|
||||
int iFDamage = -1;
|
||||
int iFDeath = -1;
|
||||
int iFScore = -1;
|
||||
|
||||
// Zors
|
||||
int iFSpawnForward = -1;
|
||||
int iFTeamForward = -1;
|
||||
int iFClassForward = -1;
|
||||
int iFScopeForward = -1;
|
||||
int iFProneForward = -1;
|
||||
int iFWpnPickupForward = -1;
|
||||
int iFCurWpnForward = -1;
|
||||
int iFGrenadeExplode = -1;
|
||||
int iFRocketExplode = -1;
|
||||
int iFObjectTouched = -1;
|
||||
int iFStaminaForward = -1;
|
||||
|
||||
int gmsgCurWeapon;
|
||||
int gmsgCurWeaponEnd;
|
||||
int gmsgHealth;
|
||||
int gmsgResetHUD;
|
||||
int gmsgObjScore;
|
||||
int gmsgRoundState;
|
||||
@ -65,11 +75,10 @@ int gmsgScoreShort;
|
||||
int gmsgPTeam;
|
||||
int gmsgAmmoX;
|
||||
int gmsgAmmoShort;
|
||||
int gmsgHealth_End;
|
||||
|
||||
// Zors
|
||||
//int gmsgWeaponList;
|
||||
//int gmsgWeaponList_End;
|
||||
int gmsgSetFOV;
|
||||
int gmsgSetFOV_End;
|
||||
int gmsgObject;
|
||||
int gmsgObject_End;
|
||||
|
||||
RankSystem g_rank;
|
||||
Grenades g_grenades;
|
||||
@ -85,29 +94,31 @@ cvar_t *dodstats_rank;
|
||||
cvar_t *dodstats_rankbots;
|
||||
cvar_t *dodstats_pause;
|
||||
|
||||
struct sUserMsg {
|
||||
// User Messages
|
||||
struct sUserMsg
|
||||
{
|
||||
const char *name;
|
||||
int* id;
|
||||
funEventCall func;
|
||||
bool endmsg;
|
||||
} g_user_msg[] =
|
||||
}
|
||||
g_user_msg[] =
|
||||
{
|
||||
{ "CurWeapon", &gmsgCurWeapon, Client_CurWeapon, false },
|
||||
{ "ObjScore", &gmsgObjScore, Client_ObjScore, false },
|
||||
{ "RoundState", &gmsgRoundState, Client_RoundState, false },
|
||||
{ "ResetHUD", &gmsgResetHUD, Client_ResetHUD_End, true },
|
||||
{ "TeamScore", &gmsgTeamScore, Client_TeamScore, false },
|
||||
{ "AmmoX", &gmsgAmmoX, Client_AmmoX, false },
|
||||
{ "AmmoShort", &gmsgAmmoShort, Client_AmmoShort, false },
|
||||
{ "Health", &gmsgHealth_End, Client_Health_End, true },
|
||||
|
||||
//Zors
|
||||
//{ "WeaponList", &gmsgWeaponList, WeaponList, true },
|
||||
//{ "WeaponList", &gmsgWeaponList_End, WeaponList_End, true },
|
||||
|
||||
{ "PTeam", &gmsgPTeam, NULL, false },
|
||||
{ "ScoreShort", &gmsgScoreShort, NULL, false },
|
||||
|
||||
{ "CurWeapon", &gmsgCurWeapon, Client_CurWeapon, false },
|
||||
{ "CurWeapon", &gmsgCurWeaponEnd, Client_CurWeapon_End, true },
|
||||
{ "ObjScore", &gmsgObjScore, Client_ObjScore, false },
|
||||
{ "RoundState", &gmsgRoundState, Client_RoundState, false },
|
||||
{ "Health", &gmsgHealth, Client_Health_End, true },
|
||||
{ "ResetHUD", &gmsgResetHUD, Client_ResetHUD_End, true },
|
||||
{ "TeamScore", &gmsgTeamScore, Client_TeamScore, false },
|
||||
{ "AmmoX", &gmsgAmmoX, Client_AmmoX, false },
|
||||
{ "AmmoShort", &gmsgAmmoShort, Client_AmmoShort, false },
|
||||
{ "SetFOV", &gmsgSetFOV, Client_SetFOV, false },
|
||||
{ "SetFOV", &gmsgSetFOV_End, Client_SetFOV_End, true },
|
||||
{ "Object", &gmsgObject, Client_Object, false },
|
||||
{ "Object", &gmsgObject_End, Client_Object_End, true },
|
||||
{ "ScoreShort", &gmsgScoreShort, NULL, false },
|
||||
{ "PTeam", &gmsgPTeam, NULL, false },
|
||||
{ 0,0,0,false }
|
||||
};
|
||||
|
||||
@ -119,18 +130,20 @@ const char* get_localinfo( const char* name , const char* def = 0 )
|
||||
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 );
|
||||
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;
|
||||
*g_user_msg[i].id = id;
|
||||
|
||||
if ( g_user_msg[ i ].endmsg )
|
||||
modMsgsEnd[ id ] = g_user_msg[ i ].func;
|
||||
if(g_user_msg[i].endmsg)
|
||||
modMsgsEnd[id] = g_user_msg[i].func;
|
||||
else
|
||||
modMsgs[ id ] = g_user_msg[ i ].func;
|
||||
|
||||
modMsgs[id] = g_user_msg[i].func;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -149,47 +162,55 @@ void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void PlayerPreThink_Post( edict_t *pEntity ) {
|
||||
void PlayerPreThink_Post(edict_t *pEntity)
|
||||
{
|
||||
if ( !isModuleActive() )
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
if ( !pPlayer->ingame )
|
||||
if (!pPlayer->ingame)
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
// Zors
|
||||
pPlayer->checkStatus();
|
||||
pPlayer->PreThink();
|
||||
|
||||
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time){
|
||||
if ( !ignoreBots(pEntity) ){
|
||||
if(pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time)
|
||||
{
|
||||
if(!ignoreBots(pEntity))
|
||||
{
|
||||
pPlayer->clearStats = 0.0f;
|
||||
pPlayer->rank->updatePosition( &pPlayer->life );
|
||||
pPlayer->restartStats(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (pPlayer->clearRound && pPlayer->clearRound < gpGlobals->time){
|
||||
if(pPlayer->clearRound && pPlayer->clearRound < gpGlobals->time)
|
||||
{
|
||||
pPlayer->clearRound = 0.0f;
|
||||
memset(&pPlayer->round,0,sizeof(pPlayer->round));
|
||||
memset(pPlayer->weaponsRnd,0,sizeof(pPlayer->weaponsRnd));
|
||||
}
|
||||
|
||||
if (pPlayer->sendScore && pPlayer->sendScore < gpGlobals->time){
|
||||
if (pPlayer->sendScore && pPlayer->sendScore < gpGlobals->time)
|
||||
{
|
||||
pPlayer->sendScore = 0;
|
||||
MF_ExecuteForward( iFScore,pPlayer->index, pPlayer->lastScore, pPlayer->savedScore );
|
||||
MF_ExecuteForward(iFScore, pPlayer->index, pPlayer->lastScore, pPlayer->savedScore);
|
||||
}
|
||||
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void ServerDeactivate() {
|
||||
void ServerDeactivate()
|
||||
{
|
||||
int i;
|
||||
for( i = 1;i<=gpGlobals->maxClients; ++i){
|
||||
for( i = 1;i<=gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
if (pPlayer->ingame) pPlayer->Disconnect();
|
||||
}
|
||||
|
||||
if ( (g_rank.getRankNum() >= (int)dodstats_maxsize->value) || ((int)dodstats_reset->value == 1) ) {
|
||||
if ( (g_rank.getRankNum() >= (int)dodstats_maxsize->value) || ((int)dodstats_reset->value == 1) )
|
||||
{
|
||||
CVAR_SET_FLOAT("dodstats_reset",0.0);
|
||||
g_rank.clear();
|
||||
}
|
||||
@ -205,13 +226,15 @@ void ServerDeactivate() {
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ){
|
||||
BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] )
|
||||
{
|
||||
GET_PLAYER_POINTER(pEntity)->Connect(pszName,pszAddress);
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
||||
}
|
||||
|
||||
void ClientDisconnect( edict_t *pEntity ) {
|
||||
void ClientDisconnect( edict_t *pEntity )
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
@ -220,27 +243,33 @@ void ClientDisconnect( edict_t *pEntity ) {
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void ClientPutInServer_Post( edict_t *pEntity ) {
|
||||
void ClientPutInServer_Post( edict_t *pEntity )
|
||||
{
|
||||
GET_PLAYER_POINTER(pEntity)->PutInServer();
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) {
|
||||
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 ( pPlayer->ingame)
|
||||
{
|
||||
if ( strcmp(oldname,name) )
|
||||
{
|
||||
if (!dodstats_rank->value)
|
||||
pPlayer->rank = g_rank.findEntryInRank( name, name );
|
||||
else
|
||||
pPlayer->rank->setName( name );
|
||||
}
|
||||
}
|
||||
else if ( pPlayer->IsBot() ) {
|
||||
|
||||
else if ( pPlayer->IsBot() )
|
||||
{
|
||||
pPlayer->Connect( name , "127.0.0.1" );
|
||||
pPlayer->PutInServer();
|
||||
}
|
||||
@ -248,17 +277,26 @@ void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) {
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {
|
||||
if (ed){
|
||||
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 {
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
mPlayerIndex = 0;
|
||||
mPlayer = NULL;
|
||||
}
|
||||
|
||||
mDest = msg_dest;
|
||||
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);
|
||||
@ -309,26 +347,48 @@ void WriteEntity_Post(int 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) )){
|
||||
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);
|
||||
}
|
||||
|
||||
if ( e && e->v.owner && e->v.owner->v.flags& (FL_CLIENT | FL_FAKECLIENT) ){
|
||||
if(e && e->v.owner && e->v.owner->v.flags&(FL_CLIENT | FL_FAKECLIENT))
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(e->v.owner);
|
||||
for ( int i=0;i<MAX_TRACE;i++){
|
||||
if ( strcmp( traceData[i].szName,STRING(e->v.classname)) == 0 ){
|
||||
if ( traceData[i].iAction & ACT_NADE_SHOT ){
|
||||
if ( traceData[i].iId == 13 && g_map.detect_allies_country )
|
||||
pPlayer->saveShot(36);
|
||||
|
||||
for(int i = 0;i < MAX_TRACE; i++)
|
||||
{
|
||||
if(strcmp(traceData[i].szName, STRING(e->v.classname)) == 0)
|
||||
{
|
||||
int grenId = (traceData[i].iId == 13 && g_map.detect_allies_country) ? 36 : traceData[i].iId;
|
||||
int rocketId = traceData[i].iId;
|
||||
|
||||
if(traceData[i].iAction&ACT_NADE_SHOT)
|
||||
{
|
||||
if(traceData[i].iId == 13 && g_map.detect_allies_country)
|
||||
pPlayer->saveShot(grenId);
|
||||
else
|
||||
pPlayer->saveShot(traceData[i].iId);
|
||||
}
|
||||
if ( traceData[i].iAction & ACT_NADE_PUT ){
|
||||
g_grenades.put(e,traceData[i].fDel, (traceData[i].iId == 13 && g_map.detect_allies_country )?36:traceData[i].iId ,GET_PLAYER_POINTER(e->v.owner));
|
||||
|
||||
else if(traceData[i].iAction&ACT_ROCKET_SHOT)
|
||||
pPlayer->saveShot(traceData[i].iId);
|
||||
|
||||
cell position[3] = {v2[0], v2[1], v2[2]};
|
||||
cell pos = MF_PrepareCellArray(position, 3);
|
||||
|
||||
if(traceData[i].iAction&ACT_NADE_PUT)
|
||||
{
|
||||
g_grenades.put(e, traceData[i].fDel, grenId, GET_PLAYER_POINTER(e->v.owner));
|
||||
MF_ExecuteForward(iFGrenadeExplode, GET_PLAYER_POINTER(e->v.owner)->index, pos, grenId);
|
||||
}
|
||||
|
||||
if(traceData[i].iAction&ACT_ROCKET_PUT)
|
||||
MF_ExecuteForward(iFRocketExplode, pPlayer->index, pos, rocketId);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -338,7 +398,6 @@ void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *
|
||||
|
||||
void DispatchKeyValue_Post( edict_t *pentKeyvalue, KeyValueData *pkvd )
|
||||
{
|
||||
|
||||
if ( !pkvd->szClassName ){
|
||||
// info_doddetect
|
||||
if ( pkvd->szValue[0]=='i' && pkvd->szValue[5]=='d' ){
|
||||
@ -392,6 +451,7 @@ void SetClientKeyValue(int id, char *protocol, char *type, char *var)
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
|
||||
void OnMetaAttach()
|
||||
{
|
||||
CVAR_REGISTER (&init_dodstats_maxsize);
|
||||
@ -408,7 +468,6 @@ void OnMetaAttach()
|
||||
|
||||
void OnAmxxAttach()
|
||||
{
|
||||
|
||||
MF_AddNatives( stats_Natives );
|
||||
MF_AddNatives( base_Natives );
|
||||
|
||||
@ -444,5 +503,12 @@ void OnPluginsLoaded()
|
||||
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);
|
||||
}
|
||||
|
||||
iFScopeForward = MF_RegisterForward("dod_client_scope",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*value*/,FP_DONE);
|
||||
iFWpnPickupForward = MF_RegisterForward("dod_client_weaponpickup",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*weapon*/,FP_CELL/*value*/,FP_DONE);
|
||||
iFProneForward = MF_RegisterForward("dod_client_prone",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*value*/,FP_DONE);
|
||||
iFCurWpnForward = MF_RegisterForward("dod_client_weaponswitch",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*wpnold*/,FP_CELL/*wpnew*/,FP_DONE);
|
||||
iFGrenadeExplode = MF_RegisterForward("dod_grenade_explosion",ET_IGNORE,FP_CELL/*id*/,FP_ARRAY/*pos[3]*/,FP_CELL/*wpnid*/,FP_DONE);
|
||||
iFRocketExplode = MF_RegisterForward("dod_rocket_explosion",ET_IGNORE,FP_CELL/*id*/,FP_ARRAY/*pos[3]*/,FP_CELL/*wpnid*/,FP_DONE);
|
||||
iFObjectTouched = MF_RegisterForward("dod_client_objectpickup",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*object*/,FP_ARRAY/*pos[3]*/,FP_CELL/*value*/,FP_DONE);
|
||||
iFStaminaForward = MF_RegisterForward("dod_client_stamina",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*stamina*/,FP_DONE);
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
|
||||
// Module info
|
||||
#define MODULE_NAME "DoDX"
|
||||
#define MODULE_VERSION "1.76b"
|
||||
#define MODULE_VERSION "1.76c_beta_6"
|
||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||
#define MODULE_URL "http://www.amxmodx.org"
|
||||
#define MODULE_LOGTAG "DODX"
|
||||
|
@ -98,47 +98,129 @@ void Client_ObjScore(void* mValue)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Client_CurWeapon(void* mValue)
|
||||
{
|
||||
static int iState;
|
||||
static int iId;
|
||||
static int iState;
|
||||
static int iId;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
iState = *(int*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
if (!iState) break;
|
||||
iId = *(int*)mValue;
|
||||
break;
|
||||
case 2:
|
||||
if ( !iState || !isModuleActive() )
|
||||
break;
|
||||
int iClip = *(int*)mValue;
|
||||
mPlayer->current = iId;
|
||||
|
||||
if ( weaponData[iId].needcheck )
|
||||
switch (mState++)
|
||||
{
|
||||
iId = get_weaponid(mPlayer);
|
||||
mPlayer->current = iId;
|
||||
case 0:
|
||||
iState = *(int*)mValue;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (!iState)
|
||||
break;
|
||||
|
||||
iId = *(int*)mValue;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if(!iState || !isModuleActive())
|
||||
break;
|
||||
|
||||
int iClip = *(int*)mValue;
|
||||
mPlayer->old = mPlayer->current;
|
||||
mPlayer->current = iId;
|
||||
|
||||
if(weaponData[iId].needcheck)
|
||||
{
|
||||
iId = get_weaponid(mPlayer);
|
||||
mPlayer->current = iId;
|
||||
}
|
||||
|
||||
if(iClip > -1)
|
||||
{
|
||||
if(mPlayer->current == 17)
|
||||
{
|
||||
if(iClip+2 == mPlayer->weapons[iId].clip)
|
||||
mPlayer->saveShot(iId);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ( iClip+1 == mPlayer->weapons[iId].clip)
|
||||
mPlayer->saveShot(iId);
|
||||
}
|
||||
}
|
||||
|
||||
mPlayer->weapons[iId].clip = iClip;
|
||||
mCurWpnEnd = 1;
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
void Client_CurWeapon_End(void*)
|
||||
{
|
||||
if(mCurWpnEnd == 1 && mPlayer->index && mPlayer->current && mPlayer->old && (mPlayer->current != mPlayer->old))
|
||||
MF_ExecuteForward(iFCurWpnForward, mPlayer->index, mPlayer->current, mPlayer->old);
|
||||
|
||||
mCurWpnEnd = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Nie ma damage event ...
|
||||
*/
|
||||
void Client_Health_End(void* mValue)
|
||||
{
|
||||
if ( !isModuleActive() )
|
||||
return;
|
||||
|
||||
edict_t *enemy = mPlayer->pEdict->v.dmg_inflictor;
|
||||
int damage = (int)mPlayer->pEdict->v.dmg_take;
|
||||
|
||||
if ( !mPlayer || !damage || !enemy )
|
||||
return;
|
||||
|
||||
int weapon = 0;
|
||||
int aim = 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;
|
||||
|
||||
if ( weaponData[weapon].needcheck )
|
||||
weapon = get_weaponid(pAttacker);
|
||||
|
||||
aim = pAttacker->aiming;
|
||||
|
||||
if ( weaponData[weapon].melee )
|
||||
pAttacker->saveShot(weapon);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_grenades.find(enemy , &pAttacker , weapon);
|
||||
}
|
||||
|
||||
if (iClip > -1) {
|
||||
if ( mPlayer->current == 17 )
|
||||
{
|
||||
if ( iClip+2 == mPlayer->weapons[iId].clip)
|
||||
mPlayer->saveShot(iId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( iClip+1 == mPlayer->weapons[iId].clip)
|
||||
mPlayer->saveShot(iId);
|
||||
}
|
||||
int TA = 0;
|
||||
|
||||
if ( !pAttacker )
|
||||
{
|
||||
pAttacker = mPlayer;
|
||||
}
|
||||
|
||||
if ( pAttacker->index != mPlayer->index )
|
||||
{
|
||||
pAttacker->saveHit( mPlayer , weapon , damage, aim );
|
||||
|
||||
if ( mPlayer->pEdict->v.team == pAttacker->pEdict->v.team )
|
||||
TA = 1;
|
||||
}
|
||||
|
||||
MF_ExecuteForward( iFDamage, pAttacker->index, mPlayer->index, damage, weapon, aim, TA );
|
||||
|
||||
if ( !mPlayer->IsAlive() )
|
||||
{
|
||||
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
|
||||
MF_ExecuteForward( iFDeath, pAttacker->index, mPlayer->index, weapon, aim, TA );
|
||||
}
|
||||
mPlayer->weapons[iId].clip = iClip;
|
||||
}
|
||||
}
|
||||
|
||||
void Client_AmmoX(void* mValue)
|
||||
@ -170,135 +252,97 @@ void Client_AmmoShort(void* mValue)
|
||||
case 0:
|
||||
iAmmo = *(int*)mValue;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (!mPlayer ) break;
|
||||
if(!mPlayer )
|
||||
break;
|
||||
|
||||
for(int i = 1; i < MAX_WEAPONS ; ++i)
|
||||
{
|
||||
if (iAmmo == weaponData[i].ammoSlot)
|
||||
mPlayer->weapons[i].ammo = *(int*)mValue;
|
||||
mPlayer->weapons[i].ammo = *(int*)mValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Client_Health_End(void* mValue)
|
||||
{
|
||||
if ( !isModuleActive() )
|
||||
return;
|
||||
|
||||
CPlayer* pVictim = mPlayer;
|
||||
|
||||
edict_t *enemy = pVictim->pEdict->v.dmg_inflictor;
|
||||
int damage = (int)pVictim->pEdict->v.dmg_take;
|
||||
|
||||
if(!pVictim || !damage || !enemy)
|
||||
return;
|
||||
|
||||
int weapon = 0;
|
||||
int aim = 0;
|
||||
|
||||
pVictim->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;
|
||||
|
||||
if(weaponData[weapon].needcheck)
|
||||
weapon = get_weaponid(pAttacker);
|
||||
|
||||
aim = pAttacker->aiming;
|
||||
|
||||
if(weaponData[weapon].melee)
|
||||
pAttacker->saveShot(weapon);
|
||||
}
|
||||
|
||||
else
|
||||
g_grenades.find(enemy , &pAttacker , weapon);
|
||||
|
||||
int TA = 0;
|
||||
|
||||
if(!pAttacker)
|
||||
{
|
||||
pAttacker = pVictim;
|
||||
}
|
||||
|
||||
if(pAttacker->index != pVictim->index)
|
||||
{
|
||||
pAttacker->saveHit(pVictim , weapon , damage, aim);
|
||||
|
||||
if(pVictim->pEdict->v.team == pAttacker->pEdict->v.team)
|
||||
TA = 1;
|
||||
}
|
||||
|
||||
MF_ExecuteForward(iFDamage, pAttacker->index, pVictim->index, damage, weapon, aim, TA);
|
||||
|
||||
if(!pVictim->IsAlive())
|
||||
{
|
||||
pAttacker->saveKill(pVictim, weapon, (aim == 1) ? 1:0 , TA);
|
||||
MF_ExecuteForward(iFDeath, pAttacker->index, pVictim->index, weapon, aim, TA);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Working on being able to modify and switch weapons as they are sent to the client
|
||||
|
||||
void WeaponList(void* value)
|
||||
// Called with a value of 90 at start 20 when someone scopes in and 0 when they scope out
|
||||
void Client_SetFOV(void* mValue)
|
||||
{
|
||||
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++;
|
||||
mPlayer->Scoping(*(int*)mValue);
|
||||
}
|
||||
|
||||
void WeaponList_End(void* mValue)
|
||||
void Client_SetFOV_End(void* mValue)
|
||||
{
|
||||
if(!mPlayer)
|
||||
return;
|
||||
|
||||
MF_Log("Done with %d", mPlayer->position);
|
||||
mPlayer->position = 0;
|
||||
mPlayer->ScopingCheck();
|
||||
}
|
||||
|
||||
struct weapon_info_s
|
||||
void Client_Object(void* mValue)
|
||||
{
|
||||
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;
|
||||
if(!mPlayer)
|
||||
return;
|
||||
|
||||
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();
|
||||
*/
|
||||
// First need to find out what was picked up
|
||||
const char *classname;
|
||||
edict_t* pObject = NULL;
|
||||
|
||||
const char* value;
|
||||
|
||||
if(mValue)
|
||||
{
|
||||
value = (char*)mValue;
|
||||
}
|
||||
|
||||
if(!mPlayer->object.carrying)
|
||||
{
|
||||
// We grab the first object within the sphere of our player
|
||||
pObject = FindEntityInSphere(mPlayer->pEdict, mPlayer->pEdict, 50.0);
|
||||
|
||||
// The loop through all the objects within the sphere
|
||||
while(pObject && !FNullEnt(pObject))
|
||||
{
|
||||
classname = STRING(pObject->v.classname);
|
||||
|
||||
if(strcmp(classname, "dod_object") == 0)
|
||||
{
|
||||
mPlayer->object.pEdict = pObject;
|
||||
mPlayer->object.do_forward = true;
|
||||
return;
|
||||
}
|
||||
|
||||
pObject = FindEntityInSphere(pObject, mPlayer->pEdict, 50.0);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
mPlayer->object.do_forward = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Client_Object_End(void* mValue)
|
||||
{
|
||||
if(!mPlayer)
|
||||
return;
|
||||
|
||||
float fposition[3];
|
||||
|
||||
if(mPlayer->object.do_forward)
|
||||
{
|
||||
mPlayer->object.do_forward = (mPlayer->object.do_forward) ? false : true;
|
||||
mPlayer->object.carrying = (mPlayer->object.carrying) ? false : true;
|
||||
|
||||
mPlayer->object.pEdict->v.origin.CopyToArray(fposition);
|
||||
cell position[3] = {fposition[0], fposition[1], fposition[2]};
|
||||
cell pos = MF_PrepareCellArray(position, 3);
|
||||
MF_ExecuteForward(iFObjectTouched, mPlayer->index, ENTINDEX(mPlayer->object.pEdict), pos, mPlayer->object.carrying);
|
||||
|
||||
if(!mPlayer->object.carrying)
|
||||
mPlayer->object.pEdict = NULL;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user