Raised This Month: $ Target: $400
 0% 

[HELP] Set Entity Angle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
m4m3ts
Senior Member
Join Date: Jun 2012
Old 11-02-2013 , 20:26   [HELP] Set Entity Angle
Reply With Quote #1

i got throwing knife plugin
the problem is, when i throw the knife horizontal, it has the right angle.
but if i throw it with lookdown, it has wrong angle...not based on view angle
please if anyone can fix it...

this is right angle, horisontal



this is wrong angle when i throw down



PHP Code:
public throw_knife(id)
{
    static 
Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3]
    
get_position(id2.00.00.0StartOrigin)

    
pev(id,pev_angles,angles)
    static 
EntEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    if(!
pev_valid(Ent)) return
    
    
set_pev(Entpev_movetypeMOVETYPE_FLY)
    
set_pev(Entpev_ownerid)
    
set_pev(Entpev_fuser1get_gametime() + 4.0)
    
set_pev(Entpev_nextthinkhalflife_time() + 0.1)
    
    
entity_set_string(EntEV_SZ_classname"knife_class")
    
engfunc(EngFunc_SetModelEnt"models/w_knifepack.mdl")
    
set_pev(Entpev_minsFloat:{-1.0, -1.0, -1.0})
    
set_pev(Entpev_maxsFloat:{1.01.01.0})
    
set_pev(Entpev_originStartOrigin)
    
set_pev(Entpev_anglesangles)
    
set_pev(Entpev_gravity0.01)
    
set_pev(Entpev_solidSOLID_BBOX)
    
set_pev(Entpev_frame0.0)
    
    static 
Float:Velocity[3]
    
fm_get_aim_origin(idTargetOrigin)
    
get_speed_vector(StartOriginTargetOrigin3500.0Velocity)
    
set_pev(Entpev_velocityVelocity)
}

stock get_position(id,Float:forwFloat:rightFloat:upFloat:vStart[])
{
    static 
Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    
    
pev(idpev_originvOrigin)
    
pev(idpev_view_ofsvUp)
    
xs_vec_add(vOriginvUpvOrigin)
    
pev(idpev_v_anglevAngle)
    
    
angle_vector(vAngleANGLEVECTOR_FORWARDvForward)
    
angle_vector(vAngleANGLEVECTOR_RIGHTvRight)
    
angle_vector(vAngleANGLEVECTOR_UPvUp)
    
    
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 get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speedFloat:new_velocity[3])
{
    
new_velocity[0] = origin2[0] - origin1[0]
    
new_velocity[1] = origin2[1] - origin1[1]
    
new_velocity[2] = origin2[2] - origin1[2]
    static 
Float:numnum floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    
new_velocity[0] *= num
    new_velocity
[1] *= num
    new_velocity
[2] *= num
    
    
return 1;


Last edited by m4m3ts; 11-02-2013 at 20:28.
m4m3ts is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 11-08-2013 , 11:19   Re: [HELP] Set Entity Angle
Reply With Quote #2

pev(id,pev_angles,angles) chage to pev(id,pev_v_angle,angles)

and I if I remember right, there were cases when player vertical angle should be inverted, so angles[1]*=-1.0;
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode