Вечер добрый, хотел сделать чтобы стрела наносила урон зомби, но при этом еще и отталкивала зомби в сторону на определенную дистанцию, подскажите, что я делаю не так? Напрочь отказывается отталкивать....
Код:
public CEntity__Touch_Pre(iEntity, iTouch)
{
if(pev_valid(iEntity) != PDATA_SAFE) return HAM_IGNORED;
if(pev(iEntity, pev_classname) == g_AllocString_EntityClass)
{
new iOwner = pev(iEntity, pev_owner);
new Float: vecOrigin[3]; pev(iEntity, pev_origin, vecOrigin);
new Float: flGameTime = get_gametime();
if(engfunc(EngFunc_PointContents, vecOrigin) == CONTENTS_SKY)
{
set_pev(iEntity, pev_flags, FL_KILLME);
return HAM_IGNORED;
}
if(iTouch == iOwner) return HAM_SUPERCEDE;
if(is_user_alive(iTouch) && zp_get_user_zombie(iTouch))
{
set_pev(iEntity, pev_movetype, MOVETYPE_FOLLOW)
set_pev(iEntity, pev_solid, SOLID_NOT)
set_pev(iEntity, pev_aiment, iTouch)
static Float:MyOrigin[3]
pev(iOwner, pev_origin, MyOrigin)
hook_ent2(iTouch, MyOrigin, 500.0, 2)
}
else if(!is_user_alive(iTouch))
{
set_pev(iEntity, pev_movetype, MOVETYPE_NONE)
set_pev(iEntity, pev_solid, SOLID_NOT)
}
// Damage
if(iTouch)
{
if(pev(iTouch, pev_takedamage) == DAMAGE_NO)
return HAM_IGNORED;
if(is_user_alive(iTouch))
{
if(iTouch == iOwner || zp_get_user_zombie(iOwner) || !zp_get_user_zombie(iTouch))
return HAM_IGNORED;
}
else if(pev(iTouch, pev_solid) == SOLID_BSP)
{
if(pev(iTouch, pev_spawnflags) & SF_BREAK_TRIGGER_ONLY)
return HAM_IGNORED;
}
new Float: flDamage = ENTITY_DAMAGE;
if(is_user_connected(iTouch) && zp_get_user_zombie(iTouch))
{
new Float: vecVelocity[3]; pev(iEntity, pev_velocity, vecVelocity);
vecVelocity[0] += vecOrigin[0];
vecVelocity[1] += vecOrigin[1];
vecVelocity[2] += vecOrigin[2];
new iTrace = create_tr2();
engfunc(EngFunc_TraceLine, vecOrigin, vecVelocity, DONT_IGNORE_MONSTERS, iEntity, iTrace);
new iHitGroup = get_tr2(iTrace, TR_iHitgroup);
set_pdata_int(iTouch, m_LastHitGroup, iHitGroup, linux_diff_player);
switch(iHitGroup)
{
case HIT_HEAD: flDamage *= 3.0;
case HIT_LEFTARM, HIT_RIGHTARM: flDamage *= 0.75;
case HIT_LEFTLEG, HIT_RIGHTLEG: flDamage *= 0.75;
case HIT_STOMACH: flDamage *= 1.5;
}
new Float: vecEndPos[3]; get_tr2(iTrace, TR_vecEndPos, vecEndPos);
UTIL_BloodDrips(vecEndPos, ExecuteHamB(Ham_BloodColor, iTouch), floatround(flDamage));
free_tr2(iTrace);
}
ExecuteHamB(Ham_TakeDamage, iTouch, iOwner, iOwner, flDamage, DMG_BULLET|DMG_NEVERGIB);
}
}
return HAM_IGNORED;
}
stock hook_ent2(ent, Float:VicOrigin[3], Float:speed, type)
{
static Float:fl_Velocity[3]
static Float:EntOrigin[3]
pev(ent, pev_origin, EntOrigin)
static Float:distance_f
distance_f = 100.0
new Float:fl_Time = distance_f / speed
if(type == 1)
{
fl_Velocity[0] = ((VicOrigin[0] - EntOrigin[0]) / fl_Time) * 1.5
fl_Velocity[1] = ((VicOrigin[1] - EntOrigin[1]) / fl_Time) * 1.5
fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
}
else if(type == 2)
{
fl_Velocity[0] = ((EntOrigin[0] - VicOrigin[0]) / fl_Time) * 1.5
fl_Velocity[1] = ((EntOrigin[1] - VicOrigin[1]) / fl_Time) * 1.5
fl_Velocity[2] = (EntOrigin[2] - VicOrigin[2]) / fl_Time
}[/SPOILER]
entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
}