Raised This Month: $12 Target: $400
 3% 

Solved sentry turn to target using pev_controller


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
NOVA GAMING
Member
Join Date: Apr 2020
Old 05-07-2020 , 05:52   sentry turn to target using pev_controller
Reply With Quote #1

hello allieds

As the titile says i am trying to turn sentry gun towards target by PEV_CONTROLLER

here is the picture

https://i.imgur.com/mLULWZM.png


the sentry gun model has two pev_controller
one is for tilt (aiming sentry gun up and down if player is above ground)
one is for rotating on his axis ( see in this video https://i.imgur.com/Zllr7Gp.mp4)

the code use for turning towards target is below , which rotate the sentry gun on his axis and aim towars its target (taken from JGHG's sentry gun)


PHP Code:
sentry_turntotarget(entFloat:sentryOrigin[3], targetFloat:closestOrigin[3]) {
    if (
target) {
        new 
name[32]
        
get_user_name(targetname31)
                
        
///--- THIS CODE IS FOR TURNING TOWARDS TARGET
        
new Float:newAngle[3]
        
entity_get_vector(entEV_VEC_anglesnewAngle)
        new 
Float:closestOrigin[0] - sentryOrigin[0]
        new 
Float:closestOrigin[1] - sentryOrigin[1]
        

        new 
Float:radians floatatan(z/xradian)
        
newAngle[1] = radians g_ONEEIGHTYTHROUGHPI
        
if (closestOrigin[0] < sentryOrigin[0])
            
newAngle[1] -= 180.0

        entity_set_float
(entSENTRY_FL_ANGLEnewAngle[1])
        


        
// THIS CODE IS FOR SETTING TILT

        
new Float:closestOrigin[2] - sentryOrigin[2]
        new 
Float:vector_distance(sentryOriginclosestOrigin)
        
radians floatatan(h/bradian)
        new 
Float:degs radians g_ONEEIGHTYTHROUGHPI;
        
// Now adjust EV_BYTE_controller1
        // Each degree corresponds to about 100/256 "bytes", = ~0,39 byte / degree (ok this is not entirely true, just tweaked for now with SENTRYTILTRADIUS)
        
new Float:RADIUS SENTRYTILTRADIUS // get_cvar_float("sentry_tiltradius");
        
new Float:degreeByte RADIUS/256.0// tweak radius later
        
new Float:tilt 127.0 degreeByte degs// 127 is center of 256... well, almost
        
set_pev(entPEV_SENTRY_TILT_TURRETfloatround(tilt)) 
        
entity_set_vector(entEV_VEC_anglesnewAngle)
    }
    else {
        
//entity_set_int(ent, SENTRY_INT_FIRE, 0)
        //entity_set_edict(ent, SENTRY_ENT_TARGET, 0)
        //client_print(0, print_chat, "%d: I don't see anyone.", ent)
    
}

so can anybody help me to use the pev_controller instead of
PHP Code:
entity_set_vector(entEV_VEC_anglesnewAngle
for turning the sentry gun and aim it to target

i am weak in maths so can anybody help me ?
__________________

Last edited by NOVA GAMING; 05-18-2020 at 23:46.
NOVA GAMING is offline
 


Thread Tools
Display Modes

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 19:46.


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