Raised This Month: $278 Target: $400

Solved sentry turn to target using pev_controller

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
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


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 Float:newAngle[3]
Float:closestOrigin[0] - sentryOrigin[0]
Float:closestOrigin[1] - sentryOrigin[1]

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



new Float:closestOrigin[2] - sentryOrigin[2]
radians floatatan(h/bradian)
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
    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:
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 04:16.

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