Here is plugin, that blocks GhostMining in HL (lamp shooting).
PHP Code:
/* AMX Mod X
GhostMineBlock plugin by KORD_12.7 and Lev
http://aghl.ru/forum/ - Russian Half-Life and Adrenaline Gamer Community
This file is provided as is (no warranties)
URL: http://aghl.ru/forum/viewtopic.php?f=19&t=305
Info:
This plugin blocks bugged explosions known as GhostMining.
Fixed to do this in correct way.
Metamod plugin by Jussi Kivilinna has some bugs like blocking explosions right under feet. This one blocks only GM explosions.
Shootings from gauss on lamps also blocked by this plugin, because they are GhostMine explosions.
CVARs:
gm_block_on "1" // (Default: 1) Enable/disable GhostMine blocking.
ChangeLog:
v1.0 [2011.03.06]
Algorithm by Jussi Kivilinna impelmented in AMXX.
Initial release.
v1.1 [2012.02.19]
[!] Fixed: Will not block anymore correct types of explosions (for example one right under feet).
*/
#pragma semicolon 1
#pragma ctrlchar '\'
#include <amxmodx>
#include <fakemeta>
#define AUTHOR "KORD_12.7, Lev, Jussi Kivilinna"
#define PLUGIN "GhostMineBlock"
#define VERSION "1.1"
#define VERSION_CVAR "gm_block"
new pcvar_gm_block_on;
new _pSearchEntity;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_cvar(VERSION_CVAR, VERSION, FCVAR_SPONLY | FCVAR_SERVER | FCVAR_UNLOGGED);
pcvar_gm_block_on = register_cvar("gm_block_on", "1"); // Enable/disable GhostMine blocking
register_forward(FM_FindEntityInSphere, "Fw_FindEntityInSphere_Post", 1);
register_forward(FM_TraceLine, "Fw_TraceLine_Post", 1);
}
public Fw_FindEntityInSphere_Post(start, Float:origin[3], Float:radius)
{
_pSearchEntity = get_orig_retval();
}
public Fw_TraceLine_Post(const Float: vecSrc[3], const Float: vecDest[3], fNoMonsters, pentToSkip, ptr)
{
if (!pev_valid(_pSearchEntity) || !pev_valid(pentToSkip) || !get_pcvar_num(pcvar_gm_block_on))
return FMRES_IGNORED;
static pHit, fStartSolid, Float:flFraction, Float:vecEndPos[3], ptr2, pHit2, fStartSolid2, Float:flFraction2;
pHit = get_tr2(ptr, TR_pHit);
fStartSolid = get_tr2(ptr, TR_StartSolid);
get_tr2(ptr, TR_flFraction, flFraction);
// Bug number 2: TraceLine starts from solid (BSP object) and doesn't hits anything on it's way.
// fStartSolid is set to '1', fAllSolid is set to '1' and flFraction is set to '1.0'.
// More over, pHit is set to 'worldspawn' and vecEndPos is correctly set to spot to where we asked it to trace to.
// Bug here may be in that that engine sets fAllSolid to '1' (part of the path is not in the wall) or
// in that that we doesn't hit an entity or
// in that that engine doesn't set flFraction and vecEndPos correctly when it hits same BSP object.
if (pHit != _pSearchEntity && (flFraction == 1.0 && fStartSolid))
{
// Bypass checks in game dll
set_tr2(ptr, TR_flFraction, 0.1);
// Only need fix for the very first "TraceLine" after "FindEntityIsSphere"
_pSearchEntity = FM_NULLENT;
return FMRES_SUPERCEDE;
}
if ((flFraction == 1.0 || pHit == _pSearchEntity) && fStartSolid)
{
// Bug number 1: Explosion has been happen inside BSP object.
// But trace results are the same as for explosion inside a player, so we just trace back and see what we will hit.
ptr2 = create_tr2();
get_tr2(ptr, TR_vecEndPos, vecEndPos);
engfunc(EngFunc_TraceLine, vecEndPos, vecSrc, fNoMonsters, pentToSkip, ptr2);
pHit2 = get_tr2(ptr2, TR_pHit);
fStartSolid2 = get_tr2(ptr2, TR_StartSolid);
get_tr2(ptr2, TR_flFraction, flFraction2);
free_tr2(ptr2);
if (flFraction2 != 1.0 && !fStartSolid2 && pHit2 != _pSearchEntity)
{
// Bypass checks in game dll
set_tr2(ptr, TR_flFraction, 0.1);
set_tr2(ptr, TR_pHit, pentToSkip);
// Only need fix for the very first "TraceLine" after "FindEntityIsSphere"
_pSearchEntity = FM_NULLENT;
return FMRES_SUPERCEDE;
}
}
// Only need fix for the very first "TraceLine" after "FindEntityIsSphere"
_pSearchEntity = FM_NULLENT;
return FMRES_IGNORED;
}
http://aghl.ru/forum/viewtopic.php?f=19&t=305
__________________