I try to convert the radius damage from valve sdk in amxx, i do it but i have a problem.
PHP Code:
stock RadiusDamage(Float:vecSrc[3], pevInflictor, pevAttacker, Float:flDamage, Float:flRadius, iClassIgnore, bitsDamageType)
{
static pEntity, tr, bInWater;
static Float:flAdjustedDamage, Float:falloff;
static Float:vecSpot;
if (flRadius)
falloff = flDamage / flRadius;
else
falloff = 1.0;
tr = create_tr2();
pEntity = FM_NULLENT;
bInWater = (engfunc(EngFunc_PointContents, vecSrc) == CONTENTS_WATER);
vecSrc[2] += 1;// in case grenade is lying on the ground
if (!pevAttacker)
pevAttacker = pevInflictor;
// iterate on all entities in the vicinity.
while((pEntity = fm_find_ent_in_sphere(pEntity, vecSrc, flRadius)) != FM_NULLENT)
{
if (pev(pEntity, pev_takedamage) != DAMAGE_NO)
{
static Classify;
Classify = ExecuteHamB(Ham_Classify, pEntity);
// UNDONE: this should check a damage mask, not an ignore
if (iClassIgnore != 0 && Classify == iClassIgnore)
{// houndeyes don't hurt other houndeyes with their attack
continue;
}
// blast's don't tavel into or out of water
if (bInWater && pev(pEntity, pev_waterlevel) == 0)
continue;
if (!bInWater && pev(pEntity, pev_waterlevel) == 3)
continue;
ExecuteHamB(Ham_BodyTarget, pEntity, vecSrc, vecSpot);
engfunc(EngFunc_TraceLine, vecSrc, vecSpot, DONT_IGNORE_MONSTERS, pevInflictor, tr);
static Float:flFraction, pHit, fStartSolid, Float:vecEndPos[3];
get_tr2(tr, TR_flFraction, flFraction);
get_tr2(tr, TR_pHit, pHit);
get_tr2(tr, TR_StartSolid, fStartSolid);
if (flFraction == 1.0 || pHit == pEntity)
{// the explosion can 'see' this entity, so hurt them!
if (fStartSolid)
{
// if we're stuck inside them, fixup the position and distance
set_tr2(tr, TR_vecEndPos, vecSrc)
set_tr2(tr, TR_flFraction, 0.0)
}
// decrease damage for an ent that's farther from the bomb.
get_tr2(tr, TR_vecEndPos, vecEndPos);
xs_vec_sub(vecSrc, vecEndPos, vecEndPos);
flAdjustedDamage = xs_vec_len(vecEndPos) * falloff
flAdjustedDamage = flDamage - flAdjustedDamage;
if (flAdjustedDamage < 0)
{
flAdjustedDamage = 0.0;
}
if (flFraction != 1.0)
{
get_tr2(tr, TR_vecEndPos, vecEndPos);
xs_vec_sub(vecEndPos, vecSrc, vecSrc);
xs_vec_normalize(vecSrc, vecSrc);
ExecuteHamB(Ham_TraceAttack, pEntity, pevInflictor, flAdjustedDamage, vecSrc, tr, bitsDamageType);
ExecuteHamB(Ham_TakeDamage, pEntity, pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType);
}
else
{
ExecuteHamB(Ham_TakeDamage, pEntity, pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType);
}
}
}
}
free_tr2(tr);
}