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

Solved NPC rotate (aiming) speed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
roosolek
Junior Member
Join Date: May 2014
Old 11-13-2018 , 07:43   NPC rotate (aiming) speed
Reply With Quote #1

Hello.

I'm trying to remake the boss Dr.Rex from Dias. Maybe some people have heard about this plugin and I have a question. Does anyone know how to speed up the monster's turn towards the player? Because it is slow in my opinion. It's so slow that I can run behind him without any problems and it will never turn to me: https://www.youtube.com/watch?v=OAre...ature=youtu.be

I would like him to rotate like in this movie: https://www.youtube.com/watch?v=Z9cYFix-D_0&t=296s

I talked to the author of the film but he did not want to help me, he said that I have to do it myself although I told him that I had no idea about scripting.

I only know that it has something to do with the functions Aim_To and REX_STATE_MOVE:

PHP Code:
public Aim_To(iEntFloat:vTargetOrigin[3], Float:flSpeedStyle)
{
    if(!
pev_valid(iEnt))    
        return
        
    if(!
Style)
    {
        static 
Float:Vec[3], Float:Angles[3]
        
pev(iEntpev_originVec)
        
        
Vec[0] = vTargetOrigin[0] - Vec[0]
        
Vec[1] = vTargetOrigin[1] - Vec[1]
        
Vec[2] = vTargetOrigin[2] - Vec[2]
        
engfunc(EngFunc_VecToAnglesVecAngles)
        
//Angles[0] = Angles[2] = 0.0 
        
        
set_pev(iEntpev_v_angleAngles)
        
set_pev(iEntpev_anglesAngles)
    } else {
        new 
Float:f1Float:f2Float:fAnglesFloat:vOrigin[3], Float:vAim[3], Float:vAngles[3];
        
pev(iEntpev_originvOrigin);
        
xs_vec_sub(vTargetOriginvOriginvOrigin);
        
xs_vec_normalize(vOriginvAim);
        
vector_to_angle(vAimvAim);
        
        if (
vAim[1] > 180.0vAim[1] -= 360.0;
        if (
vAim[1] < -180.0vAim[1] += 360.0;
        
        
fAngles vAim[1];
        
pev(iEntpev_anglesvAngles);
        
        if (
vAngles[1] > fAngles)
        {
            
f1 vAngles[1] - fAngles;
            
f2 360.0 vAngles[1] + fAngles;
            if (
f1 f2)
            {
                
vAngles[1] -= flSpeed;
                
vAngles[1] = floatmax(vAngles[1], fAngles);
            }
            else
            {
                
vAngles[1] += flSpeed;
                if (
vAngles[1] > 180.0vAngles[1] -= 360.0;
            }
        }
        else
        {
            
f1 fAngles vAngles[1];
            
f2 360.0 fAngles vAngles[1];
            if (
f1 f2)
            {
                
vAngles[1] += flSpeed;
                
vAngles[1] = floatmin(vAngles[1], fAngles);
            }
            else
            {
                
vAngles[1] -= flSpeed;
                if (
vAngles[1] < -180.0vAngles[1] += 360.0;
            }        
        }
    
        
set_pev(iEntpev_v_anglevAngles)
        
set_pev(iEntpev_anglesvAngles)
    }


PHP Code:
case REX_STATE_SEARCHING_ENEMY:
        {
            static 
VictimVictim FindClosetEnemy(ent1)
            
            if(
is_user_alive(Victim))
            {
                
set_pev(entpev_enemyVictim)
                
g_BossState REX_STATE_MOVE
            
} else {
                
set_pev(entpev_enemy0)
                
g_BossState REX_STATE_IDLE
            
}
        }
        case 
REX_STATE_MOVE:
        {
            static 
EnemyEnemy pev(entpev_enemy)
            static 
Float:EnemyOrigin[3]
            
pev(Enemypev_originEnemyOrigin)
            
            if(
is_user_alive(Enemy))
            {
                if(
entity_range(Enemyent) <= floatround(REX_ATTACK_RANGE))
                {
                    
g_BossState REX_STATE_ATTACK
                    
                    Aim_To
(entEnemyOrigin2.01
                    
                    if(
random_num(01) == 1Rex_StartAttack11(ent+TASK_ATTACK)
                    else 
Rex_StartAttack12(ent+TASK_ATTACK)
                } else {
                    if(
pev(entpev_movetype) == MOVETYPE_PUSHSTEP)
                    {
                        static 
Float:OriginAhead[3]
                        
get_position(ent300.00.00.0OriginAhead)
                        
                        
Aim_To(entEnemyOrigin1.01
                        
hook_ent2(entOriginAheadREX_MOVESPEED)
                        
                        
Set_EntAnim(entREX_RUN1.00)
                    } else {
                        
set_pev(entpev_movetypeMOVETYPE_PUSHSTEP)
                    }
                }
            } else {
                
g_BossState REX_STATE_SEARCHING_ENEMY
            
}
        } 
I just want to give him the function of rotation speed towards the player with the possibility of changing ;)

Last edited by roosolek; 11-13-2018 at 09:09.
roosolek is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-13-2018 , 08:26   Re: NPC rotate (aiming) speed
Reply With Quote #2

Increase the 3rd parameter in Aim_To calls, that is in
Code:
Aim_To(ent, EnemyOrigin, 1.0, 1)
__________________
klippy is offline
roosolek
Junior Member
Join Date: May 2014
Old 11-13-2018 , 09:09   Re: NPC rotate (aiming) speed
Reply With Quote #3

Thanks a lot :d

Such a small thing to change in this code was and I did not know about it. Solved.
roosolek is offline
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 09:48.


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