Raised This Month: $ Target: $400
 0% 

Solved sentry turn to target using pev_controller


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NOVA GAMING
Member
Join Date: Apr 2020
Old 05-07-2020 , 06: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-19-2020 at 00:46.
NOVA GAMING is offline
NOVA GAMING
Member
Join Date: Apr 2020
Old 05-09-2020 , 05:33   Re: sentry turn to target using pev_controller
Reply With Quote #2

bump
nobody is helping :-(
__________________
NOVA GAMING is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 05-10-2020 , 03:06   Re: sentry turn to target using pev_controller
Reply With Quote #3

I don't know if it work.
PHP Code:
set_pev(iEntpev_controller_00.0); // 0 to 360.
set_pev(iEntpev_controller_10.0); // -50 to 50. 
Hint: This Model Infomation.
Code:
Number of Bone Controllers: 2

Bone Controller 1 Bone: 0
Bone Controller 1 Type: 32800
Bone Controller 1 Start: 0.000000
Bone Controller 1 End: 360.000000
Bone Controller 1 Rest: 0
Bone Controller 1 Index: 0

Bone Controller 2 Bone: 2
Bone Controller 2 Type: 8
Bone Controller 2 Start: 50.000000
Bone Controller 2 End: -50.000000
Bone Controller 2 Rest: 0
Bone Controller 2 Index: 1
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
NOVA GAMING
Member
Join Date: Apr 2020
Old 05-10-2020 , 05:40   Re: sentry turn to target using pev_controller
Reply With Quote #4

atlast , thank you for reply but i think you don't understand me
i wanted to make sentry gun aim at target , if target moves than it should rotate also with PEV_CONTROLLER

you can see sentry_turntotarget function which i given , in that sentry tilt to target only Vertically like target move up and down than sentry aim up and down by pev_controller and what i wanted is that sentry tilt target if he moves horizontal (rotating on axis) also by pev_controller
__________________
NOVA GAMING is offline
NOVA GAMING
Member
Join Date: Apr 2020
Old 05-15-2020 , 03:42   Re: sentry turn to target using pev_controller
Reply With Quote #5

Bump please help me i will pay you
__________________
NOVA GAMING is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 05-17-2020 , 21:44   Re: sentry turn to target using pev_controller
Reply With Quote #6

pev_controller_0 is horizontal angle.

Since you can specify from 0 to 360, it seems that you can calculate the value by the angle with the target + your own direction.
However, the JGHG source is esoteric, so it behaved unnaturally when I tried.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
NOVA GAMING
Member
Join Date: Apr 2020
Old 05-17-2020 , 23:06   Re: sentry turn to target using pev_controller
Reply With Quote #7

Quote:
Originally Posted by +ARUKARI- View Post
pev_controller_0 is horizontal angle.

Since you can specify from 0 to 360, it seems that you can calculate the value by the angle with the target + your own direction.
However, the JGHG source is esoteric, so it behaved unnaturally when I tried.
thats the problem i am not able to find correct value of controller with angle for turning to target
, my calculation is horrible when sentry see the target it turn to other locations
yes JGHG code is esoteric maybe he can only help me with this
__________________
NOVA GAMING is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 05-18-2020 , 01:37   Re: sentry turn to target using pev_controller
Reply With Quote #8

came up with.
1. Set all angles to 0 when deploying.
2. Find the angle between the turret and the target.
(xs_vec_angle (turret, target), [1] in the array are both zero)
3. Set the angle to pev_controller_0.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
NOVA GAMING
Member
Join Date: Apr 2020
Old 05-18-2020 , 03:37   Re: sentry turn to target using pev_controller
Reply With Quote #9

okay thanks i will try

and i have find this code which do exactly what i wanted but problem is it is in module coding and i don't know how to apply in plugin . any way i will try your method

PHP Code:
    if (m_vecCurAngles.!= m_vecGoalAngles.y)
    {
        
float flDir m_vecGoalAngles.m_vecCurAngles.: -;
        
float flDist fabs(m_vecGoalAngles.m_vecCurAngles.y);
        
        if (
flDist 180)
        {
            
flDist 360 flDist;
            
flDir = -flDir;
        }
        if (
flDist 30)
        {
            if (
m_fTurnRate m_iBaseTurnRate 10)
            {
                
m_fTurnRate += m_iBaseTurnRate;
            }
        }
        else if (
m_fTurnRate 45)
        {
            
m_fTurnRate -= m_iBaseTurnRate;
        }
        else
        {
            
m_fTurnRate += m_iBaseTurnRate;
        }

        
m_vecCurAngles.+= 0.1 m_fTurnRate flDir;

        if (
m_vecCurAngles.0)
            
m_vecCurAngles.+= 360;
        else if (
m_vecCurAngles.>= 360)
            
m_vecCurAngles.-= 360;

        if (
flDist < (0.05 m_iBaseTurnRate))
            
m_vecCurAngles.m_vecGoalAngles.y;

        
//ALERT(at_console, "%.2f -> %.2f\n", m_vecCurAngles.y, y);
        
if (m_iOrientation == 0)
            
SetBoneController(0m_vecCurAngles.pev->angles.);
        else 
            
SetBoneController(0pev->angles.180 m_vecCurAngles.);
        
state 1;
    } 
FULL LINK :- https://github.com/ValveSoftware/hal...lls/turret.cpp
__________________

Last edited by NOVA GAMING; 05-18-2020 at 03:38. Reason: WRONG LINK
NOVA GAMING is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 05-18-2020 , 03:57   Re: sentry turn to target using pev_controller
Reply With Quote #10

FYI.
https://f.easyuploader.app/eu-prd/up...6f6a544248.png
__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 05-18-2020 at 03:57.
+ARUKARI- is offline
Reply


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 12:07.


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