AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   NPC Duck problem (https://forums.alliedmods.net/showthread.php?t=308255)

spamipolito 06-13-2018 07:07

NPC Duck problem
 
Hi guys. I'm trying to make a perfect npc. I have a problem.

When being crouched, it works perfect, or so I think.. But when standing, the NPC gets on the ground

This is my code:
PHP Code:

        case ACTIVITY_DUCK:
        {
            
NPC_PlayAction(iEntAI_ACTIONS[5][NPC_SEQUENCE], AI_ACTIONS[5][NPC_ANIMTIME], AI_ACTIONS[5][NPC_FRAMERATE])

            
NPC_MoveToTarget(iEntvecVictimOrigin240.0)

            new 
Float:vecMins[3];
            new 
Float:vecMax[3];
            
//new Float:VecSize[3]
    
            
vecMins Float:{-16.0, -16.0, -18.0};
            
vecMax Float:{16.016.032.0};
            
//VecSize = Float:{32.0, 32.0, 50.0};
    
            //entity_set_size(iEnt, vecMins, vecMax);
    
            
entity_set_vector(iEntEV_VEC_minsvecMins);
            
entity_set_vector(iEntEV_VEC_maxsvecMax);

            
client_print(0print_chat"Duck")

            if(
fDistance <= 64.0)
            {    
                
// Sequence Duck And Attack 

                
entity_set_int(iEntEV_INT_sequence81);
                
entity_set_float(iEntEV_FL_animtimeg_animtime);
                
entity_set_float(iEntEV_FL_framerateg_framerate);

                
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 0.5);
            
                return;    

             }

            
//if( !(pev(iVictim, pev_oldbuttons) & IN_DUCK) )
            //{
                
entity_set_int(iEntZOMBIE_ACTIVITYACTIVITY_STAND)

            
//}

            
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 0.5);
            
            return;

        }
        case 
ACTIVITY_STAND:
        {
            
NPC_PlayAction(iEntAI_ACTIONS[0][NPC_SEQUENCE], AI_ACTIONS[0][NPC_ANIMTIME], AI_ACTIONS[0][NPC_FRAMERATE])

            new 
Float:vecMins[3];
            new 
Float:vecMax[3];
           
// new Float:VecSize[3]
    
            
vecMins Float:{-16.0, -16.0, -36.0};
            
vecMax Float:{16.016.036.0};
            
//VecSize = Float:{32.0, 32.0, 72.0};
    
            //entity_set_size(iEnt, vecMins, vecMax);
    
            
entity_set_vector(iEntEV_VEC_minsvecMins);
            
entity_set_vector(iEntEV_VEC_maxsvecMax);

            
entity_set_int(iEntZOMBIE_ACTIVITYACTIVITY_RUN)

            
client_print(0print_chat"Stand")

            
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 0.5);

            return;
        } 

Duck:

https://i.imgur.com/jM1R73W.jpg

Problem:

https://i.imgur.com/AHAlYtx.jpg

Sorry for my english, I'm spanish speaking

Natsheh 06-13-2018 13:38

Re: NPC Duck problem
 
PHP Code:


 vecMins 
Float:{-16.0, -16.0, -36.0};
 
vecMax Float:{16.016.016.0}; 

In case ACTIVITY_DUCK

E1_531G 06-13-2018 16:03

Re: NPC Duck problem
 
I think, when NCP stands after ducking, you should set him on origin Z axis half of the duck height (or something like this).

Natsheh 06-13-2018 19:04

Re: NPC Duck problem
 
Quote:

Originally Posted by E1_531G (Post 2596784)
I think, when NCP stands after ducking, you should set him on origin Z axis half of the duck height (or something like this).

No he shouldnt because he. Simply can just change the maxsize z vector
And not touch the z minsize

spamipolito 06-14-2018 17:24

Re: NPC Duck problem
 
Quote:

Originally Posted by Natsheh (Post 2596767)
PHP Code:


 vecMins 
Float:{-16.0, -16.0, -36.0};
 
vecMax Float:{16.016.016.0}; 

In case ACTIVITY_DUCK

it did not work :(

CrazY. 06-14-2018 17:54

Re: NPC Duck problem
 
Try with entity_set_size instead.

spamipolito 06-14-2018 18:43

Re: NPC Duck problem
 
Quote:

Originally Posted by CrazY. (Post 2597017)
Try with entity_set_size instead.

No bro :/ . I already testing with entity_set_size :/. Anyway, i tried again.

This result:

Use this code in case ACTIVITY_DUCK:

PHP Code:

            new Float:vecMins[3];
            new 
Float:vecMax[3];
            
//new Float:VecSize[3]
    
            
vecMins Float:{-16.0, -16.0, -32.0};
            
vecMax Float:{16.016.018.0};
            
//VecSize = Float:{32.0, 32.0, 50.0};
    
            
entity_set_size(iEntvecMinsvecMax);
    
            
entity_set_vector(iEntEV_VEC_minsvecMins);
            
entity_set_vector(iEntEV_VEC_maxsvecMax); 

And case ACTIVITY_STAND:

PHP Code:

            new Float:vecMins[3];
            new 
Float:vecMax[3];
           
// new Float:VecSize[3]
    
            
vecMins Float:{-16.0, -16.0, -36.0};
            
vecMax Float:{16.016.036.0};
            
//VecSize = Float:{32.0, 32.0, 72.0};
    
            
entity_set_size(iEntvecMinsvecMax);
    
            
entity_set_vector(iEntEV_VEC_minsvecMins);
            
entity_set_vector(iEntEV_VEC_maxsvecMax); 

This result:

Ducking:
https://i.imgur.com/DClo0SZ.jpg


Standing up:
https://i.imgur.com/aqt7W40.jpg

Natsheh 06-14-2018 20:09

Re: NPC Duck problem
 
Quote:

Originally Posted by spamipolito (Post 2597022)
No bro :/ . I already testing with entity_set_size :/. Anyway, i tried again.

This result:

Use this code in case ACTIVITY_DUCK:

PHP Code:

            new Float:vecMins[3];
            new 
Float:vecMax[3];
            
//new Float:VecSize[3]
    
            
vecMins Float:{-16.0, -16.0, -32.0};
            
vecMax Float:{16.016.018.0};
            
//VecSize = Float:{32.0, 32.0, 50.0};
    
            
entity_set_size(iEntvecMinsvecMax);
    
            
entity_set_vector(iEntEV_VEC_minsvecMins);
            
entity_set_vector(iEntEV_VEC_maxsvecMax); 


Didnt i told you to not change the mins of z vector, mins ducking should be equal to the mins of the standing position.

It shouldbe

vecMins = Float:{-16.0, -16.0, -36.0};
vecMax = Float:{16.0, 16.0, 16.0};

CrazY. 06-14-2018 21:10

Re: NPC Duck problem
 
Take a look at Half-Life/ReGameDLL source code.

spamipolito 07-04-2018 14:35

Re: NPC Duck problem
 
Dont work guys :(


All times are GMT -4. The time now is 04:40.

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