AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved sentry turn to target using pev_controller (https://forums.alliedmods.net/showthread.php?t=324132)

NOVA GAMING 05-07-2020 05:52

sentry turn to target using pev_controller
 
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 ?

NOVA GAMING 05-09-2020 04:33

Re: sentry turn to target using pev_controller
 
bump
nobody is helping :-(

+ARUKARI- 05-10-2020 02:06

Re: sentry turn to target using pev_controller
 
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


NOVA GAMING 05-10-2020 04:40

Re: sentry turn to target using pev_controller
 
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 05-15-2020 02:42

Re: sentry turn to target using pev_controller
 
Bump :( please help me i will pay you

+ARUKARI- 05-17-2020 20:44

Re: sentry turn to target using pev_controller
 
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.

NOVA GAMING 05-17-2020 22:06

Re: sentry turn to target using pev_controller
 
Quote:

Originally Posted by +ARUKARI- (Post 2700782)
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 :(

+ARUKARI- 05-18-2020 00:37

Re: sentry turn to target using pev_controller
 
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.

NOVA GAMING 05-18-2020 02:37

Re: sentry turn to target using pev_controller
 
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

+ARUKARI- 05-18-2020 02:57

Re: sentry turn to target using pev_controller
 
FYI.
https://f.easyuploader.app/eu-prd/up...6f6a544248.png
https://f.easyuploader.app/eu-prd/up...6f6a544248.png


All times are GMT -4. The time now is 13:37.

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