2004-07-01 21:57:12 +04:00
|
|
|
/*
|
|
|
|
* DoDX
|
|
|
|
* Copyright (c) 2004 Lukasz Wlasinski
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the author gives permission to
|
|
|
|
* link the code of this program with the Half-Life Game Engine ("HL
|
|
|
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
|
|
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
|
|
|
* respects for all of the code used other than the HL Engine and MODs
|
|
|
|
* from Valve. If you modify this file, you may extend this exception
|
|
|
|
* to your version of the file, but you are not obligated to do so. If
|
|
|
|
* you do not wish to do so, delete this exception statement from your
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "amxxmodule.h"
|
|
|
|
#include "dodx.h"
|
|
|
|
|
|
|
|
/* Weapon names aren't send in WeaponList message in DoD */
|
2007-03-09 06:04:40 +03:00
|
|
|
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 },
|
2004-07-01 21:57:12 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Function will select correct id */
|
2007-03-09 06:04:40 +03:00
|
|
|
int get_weaponid(CPlayer* pPlayer)
|
|
|
|
{
|
2004-07-01 21:57:12 +04:00
|
|
|
int weapon = pPlayer->current;
|
2005-07-24 15:07:49 +04:00
|
|
|
const char *sz;
|
2007-03-09 06:04:40 +03:00
|
|
|
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;
|
|
|
|
|
2004-07-01 21:57:12 +04:00
|
|
|
case 20:
|
2007-03-09 06:04:40 +03:00
|
|
|
if(g_map.detect_allies_paras) weapon = 33;
|
2004-07-01 21:57:12 +04:00
|
|
|
break;
|
2007-03-09 06:04:40 +03:00
|
|
|
|
2004-07-01 21:57:12 +04:00
|
|
|
case 23:
|
2005-07-24 15:07:49 +04:00
|
|
|
sz = STRING(pPlayer->pEdict->v.weaponmodel);
|
2007-03-09 06:04:40 +03:00
|
|
|
if(sz[13] == 's')
|
2004-07-20 03:57:05 +04:00
|
|
|
weapon = 32;
|
2004-07-01 21:57:12 +04:00
|
|
|
break;
|
2007-03-09 06:04:40 +03:00
|
|
|
|
|
|
|
case 24:
|
|
|
|
if(pPlayer->pEdict->v.button&IN_ATTACK2) weapon = 41;
|
|
|
|
break;
|
|
|
|
|
2004-07-01 21:57:12 +04:00
|
|
|
case 25:
|
2005-07-24 15:07:49 +04:00
|
|
|
sz = STRING(pPlayer->pEdict->v.weaponmodel);
|
2007-03-09 06:04:40 +03:00
|
|
|
if(sz[16] == 's')
|
2004-07-01 21:57:12 +04:00
|
|
|
weapon = 35;
|
2007-03-09 06:04:40 +03:00
|
|
|
else if(pPlayer->pEdict->v.button&IN_ATTACK2)
|
2004-07-01 21:57:12 +04:00
|
|
|
weapon = 39;
|
2005-07-24 15:07:49 +04:00
|
|
|
break;
|
2007-03-09 06:04:40 +03:00
|
|
|
|
2005-07-24 15:07:49 +04:00
|
|
|
case 15:
|
|
|
|
weapon = 14;
|
|
|
|
break;
|
2007-03-09 06:04:40 +03:00
|
|
|
|
2005-07-24 15:07:49 +04:00
|
|
|
case 16:
|
2007-03-09 06:04:40 +03:00
|
|
|
if(g_map.detect_allies_country) weapon = 36;
|
2005-07-24 15:07:49 +04:00
|
|
|
else weapon = 13;
|
|
|
|
break;
|
2004-07-01 21:57:12 +04:00
|
|
|
}
|
2007-03-09 06:04:40 +03:00
|
|
|
|
2004-07-01 21:57:12 +04:00
|
|
|
return weapon;
|
|
|
|
}
|
|
|
|
|
2007-03-09 06:04:40 +03:00
|
|
|
traceVault traceData[] =
|
|
|
|
{
|
2004-07-01 21:57:12 +04:00
|
|
|
{ "grenade", 13, ACT_NADE_PUT|ACT_NADE_SHOT, 2.0 }, // or 36
|
|
|
|
{ "grenade2", 14, ACT_NADE_PUT|ACT_NADE_SHOT, 2.0 },
|
2007-03-09 06:04:40 +03:00
|
|
|
{ "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 },
|
2004-07-01 21:57:12 +04:00
|
|
|
{ "monster_mortar", 40, ACT_NADE_PUT|ACT_NADE_SHOT, 2.0 },
|
|
|
|
};
|
|
|
|
|
2007-03-09 06:04:40 +03:00
|
|
|
bool ignoreBots (edict_t *pEnt, edict_t *pOther)
|
|
|
|
{
|
|
|
|
if(!rankBots && (pEnt->v.flags & FL_FAKECLIENT || (pOther && pOther->v.flags & FL_FAKECLIENT)))
|
2004-07-01 21:57:12 +04:00
|
|
|
return true;
|
2007-03-09 06:04:40 +03:00
|
|
|
|
2004-07-01 21:57:12 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-09 06:04:40 +03:00
|
|
|
bool isModuleActive()
|
|
|
|
{
|
|
|
|
if(!(int)CVAR_GET_FLOAT("dodstats_pause"))
|
2004-07-01 21:57:12 +04:00
|
|
|
return true;
|
2007-03-09 06:04:40 +03:00
|
|
|
|
2004-07-01 21:57:12 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
edict_t *FindEntityByString(edict_t *pentStart, const char *szKeyword, const char *szValue)
|
|
|
|
{
|
|
|
|
edict_t *pentEntity;
|
2007-03-09 06:04:40 +03:00
|
|
|
pentEntity = FIND_ENTITY_BY_STRING(pentStart, szKeyword, szValue);
|
|
|
|
|
2004-07-01 21:57:12 +04:00
|
|
|
if(!FNullEnt(pentEntity))
|
|
|
|
return pentEntity;
|
2007-03-09 06:04:40 +03:00
|
|
|
|
2004-07-01 21:57:12 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName)
|
|
|
|
{
|
|
|
|
return FindEntityByString(pentStart, "classname", szName);
|
|
|
|
}
|
2007-03-09 06:04:40 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|