AMX Mod X Donor
|
11-06-2014
, 12:17
Re: NPC size
|
#7
|
Quote:
Originally Posted by Fr33m@n
get a random player min an max size (just get values if you don't know them), aply theses size * 2 on your ent.
|
Dont need to, klippy was correct. Already have it working. But the npc isnt moving. Maybe because of map. Movement function is working i guess cuz at least it plays the right animations and hit players when they are at the hit range. I will try a npc map when i am home, if still not working i post here the code. And thanks
Edit:
Well, when i use normal size it works but when i double the size, npc isnt moved:
PHP Code:
public walk(ent)
{
static Float:OriginAhead[3]
get_position(Ent, 300.0, 0.0, 0.0, OriginAhead)
Aim_To(Ent, EnemyOrigin)
hook_ent2(Ent, OriginAhead, 120.0)
}
public Aim_To(ent, Float:Origin[3])
{
static Float:Vec[3], Float:Angles[3]
pev(ent, pev_origin, Vec)
Vec[0] = Origin[0] - Vec[0]
Vec[1] = Origin[1] - Vec[1]
Vec[2] = Origin[2] - Vec[2]
engfunc(EngFunc_VecToAngles, Vec, Angles)
Angles[0] = Angles[2] = 0.0
set_pev(ent, pev_angles, Angles)
}
public FindClosetEnemy(ent, can_see)
{
static Float:maxdistance; maxdistance = 4980.0
static indexid; indexid = 0
static Float:current_dis; current_dis = maxdistance
for(new i = 1 ;i <= g_MaxPlayers; i++)
{
if(can_see)
{
if(is_user_alive(i) && can_see_fm(ent, i) && entity_range(ent, i) < current_dis)
{
current_dis = entity_range(ent, i)
indexid = i
}
} else {
if(is_user_alive(i) && entity_range(ent, i) < current_dis)
{
current_dis = entity_range(ent, i)
indexid = i
}
}
}
return indexid
}
public bool:can_see_fm(entindex1, entindex2)
{
if (!entindex1 || !entindex2)
return false
if (pev_valid(entindex1) && pev_valid(entindex1))
{
new flags = pev(entindex1, pev_flags)
if (flags & EF_NODRAW || flags & FL_NOTARGET)
{
return false
}
new Float:lookerOrig[3]
new Float:targetBaseOrig[3]
new Float:targetOrig[3]
new Float:temp[3]
pev(entindex1, pev_origin, lookerOrig)
pev(entindex1, pev_view_ofs, temp)
lookerOrig[0] += temp[0]
lookerOrig[1] += temp[1]
lookerOrig[2] += temp[2]
pev(entindex2, pev_origin, targetBaseOrig)
pev(entindex2, pev_view_ofs, temp)
targetOrig[0] = targetBaseOrig [0] + temp[0]
targetOrig[1] = targetBaseOrig [1] + temp[1]
targetOrig[2] = targetBaseOrig [2] + temp[2]
engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) // checks the had of seen player
if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater))
{
return false
}
else
{
new Float:flFraction
get_tr2(0, TraceResult:TR_flFraction, flFraction)
if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
{
return true
}
else
{
targetOrig[0] = targetBaseOrig [0]
targetOrig[1] = targetBaseOrig [1]
targetOrig[2] = targetBaseOrig [2]
engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) // checks the body of seen player
get_tr2(0, TraceResult:TR_flFraction, flFraction)
if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
{
return true
}
else
{
targetOrig[0] = targetBaseOrig [0]
targetOrig[1] = targetBaseOrig [1]
targetOrig[2] = targetBaseOrig [2] - 17.0
engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) // checks the legs of seen player
get_tr2(0, TraceResult:TR_flFraction, flFraction)
if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
{
return true
}
}
}
}
}
return false
}
stock get_position(ent, Float:forw, Float:right, Float:up, Float:vStart[])
{
if(!pev_valid(ent))
return
static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
pev(ent, pev_origin, vOrigin)
pev(ent, pev_view_ofs,vUp) //for player
xs_vec_add(vOrigin,vUp,vOrigin)
pev(ent, pev_angles, vAngle) // if normal entity ,use pev_angles
vAngle[0] = 0.0
angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward) //or use EngFunc_AngleVectors
angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}
stock hook_ent2(ent, Float:VicOrigin[3], Float:speed)
{
if(!pev_valid(ent))
return
static Float:fl_Velocity[3], Float:EntOrigin[3], Float:distance_f, Float:fl_Time
pev(ent, pev_origin, EntOrigin)
distance_f = get_distance_f(EntOrigin, VicOrigin)
fl_Time = distance_f / speed
fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time
fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time
fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
set_pev(ent, pev_velocity, fl_Velocity)
}
Maybe npc cant see player and i must change the angles? i am not sure whats the problem...
__________________
Last edited by Jhob94; 11-06-2014 at 16:58.
|
|