AlliedModders

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

Jhob94 11-05-2014 12:13

NPC size
 
When i create an npc, will the size match to the size of model i set to the npc or do i need to change entity size?

klippy 11-05-2014 12:29

Re: NPC size
 
No, it will not, you have to specify the size by yourself. Otherwise, I think it will just be non-solid. Although, there seems to be some cool new natives in 1.8.3(fakemeta I think) which may succeed to achieve that.

Arkshine 11-05-2014 12:37

Re: NPC size
 
(^ Probably not recommended to use them, some changes are planned around them.)

Jhob94 11-05-2014 13:04

Re: NPC size
 
Idk much about modeling and setting sizes.
Give me an example please. Let's say i want to edit GIGN model and set it 2x bigger than normal. How i edit the model and what size i must put on the code?

klippy 11-05-2014 13:14

Re: NPC size
 
If it is going to be 2 times bigger, I think it would be (mins){-32.0, -32.0, -72.0}, (maxs){32.0, 32.0, 72.0}, but this is only for player models. You need to set entity size depending on your needs and your model.

Fr33m@n 11-06-2014 11:38

Re: NPC size
 
get a random player min an max size (just get values if you don't know them), aply theses size * 2 on your ent.

Jhob94 11-06-2014 12:17

Re: NPC size
 
Quote:

Originally Posted by Fr33m@n (Post 2220884)
get a random player min an max size (just get values if you don't know them), aply theses size * 2 on your ent.

Dont need to, klippy was correct. Already have it working. But the npc isnt moving. Maybe because of map. Movement function is working i guess cuz at least it plays the right animations and hit players when they are at the hit range. I will try a npc map when i am home, if still not working i post here the code. And thanks :)

Edit:
Well, when i use normal size it works but when i double the size, npc isnt moved:
PHP Code:

public walk(ent)
{
    static 
Float:OriginAhead[3]
    
get_position(Ent300.00.00.0OriginAhead)
                        
    
Aim_To(EntEnemyOrigin
    
hook_ent2(EntOriginAhead120.0)
}

public 
Aim_To(entFloat:Origin[3]) 
{
    static 
Float:Vec[3], Float:Angles[3]
    
pev(entpev_originVec)
    
    
Vec[0] = Origin[0] - Vec[0]
    
Vec[1] = Origin[1] - Vec[1]
    
Vec[2] = Origin[2] - Vec[2]
    
engfunc(EngFunc_VecToAnglesVecAngles)
    
Angles[0] = Angles[2] = 0.0 
    
    set_pev
(entpev_anglesAngles)
}

public 
FindClosetEnemy(entcan_see)
{
    static 
Float:maxdistancemaxdistance 4980.0
    
static indexidindexid 0
    
static Float:current_discurrent_dis maxdistance

    
for(new ;<= g_MaxPlayersi++)
    {
        if(
can_see)
        {
            if(
is_user_alive(i) && can_see_fm(enti) && entity_range(enti) < current_dis)
            {
                
current_dis entity_range(enti)
                
indexid i
            
}
        } else {
            if(
is_user_alive(i) && entity_range(enti) < current_dis)
            {
                
current_dis entity_range(enti)
                
indexid i
            
}            
        }
    }    
    
    return 
indexid
}

public 
bool:can_see_fm(entindex1entindex2)
{
    if (!
entindex1 || !entindex2)
        return 
false

    
if (pev_valid(entindex1) && pev_valid(entindex1))
    {
        new 
flags pev(entindex1pev_flags)
        if (
flags EF_NODRAW || flags FL_NOTARGET)
        {
            return 
false
        
}

        new 
Float:lookerOrig[3]
        new 
Float:targetBaseOrig[3]
        new 
Float:targetOrig[3]
        new 
Float:temp[3]

        
pev(entindex1pev_originlookerOrig)
        
pev(entindex1pev_view_ofstemp)
        
lookerOrig[0] += temp[0]
        
lookerOrig[1] += temp[1]
        
lookerOrig[2] += temp[2]

        
pev(entindex2pev_origintargetBaseOrig)
        
pev(entindex2pev_view_ofstemp)
        
targetOrig[0] = targetBaseOrig [0] + temp[0]
        
targetOrig[1] = targetBaseOrig [1] + temp[1]
        
targetOrig[2] = targetBaseOrig [2] + temp[2]

        
engfunc(EngFunc_TraceLinelookerOrigtargetOrig0entindex10//  checks the had of seen player
        
if (get_tr2(0TraceResult:TR_InOpen) && get_tr2(0TraceResult:TR_InWater))
        {
            return 
false
        

        else 
        {
            new 
Float:flFraction
            get_tr2
(0TraceResult:TR_flFractionflFraction)
            if (
flFraction == 1.0 || (get_tr2(0TraceResult:TR_pHit) == entindex2))
            {
                return 
true
            
}
            else
            {
                
targetOrig[0] = targetBaseOrig [0]
                
targetOrig[1] = targetBaseOrig [1]
                
targetOrig[2] = targetBaseOrig [2]
                
engfunc(EngFunc_TraceLinelookerOrigtargetOrig0entindex10//  checks the body of seen player
                
get_tr2(0TraceResult:TR_flFractionflFraction)
                if (
flFraction == 1.0 || (get_tr2(0TraceResult:TR_pHit) == entindex2))
                {
                    return 
true
                
}
                else
                {
                    
targetOrig[0] = targetBaseOrig [0]
                    
targetOrig[1] = targetBaseOrig [1]
                    
targetOrig[2] = targetBaseOrig [2] - 17.0
                    engfunc
(EngFunc_TraceLinelookerOrigtargetOrig0entindex10//  checks the legs of seen player
                    
get_tr2(0TraceResult:TR_flFractionflFraction)
                    if (
flFraction == 1.0 || (get_tr2(0TraceResult:TR_pHit) == entindex2))
                    {
                        return 
true
                    
}
                }
            }
        }
    }
    return 
false
}

stock get_position(entFloat:forwFloat:rightFloat:upFloat:vStart[])
{
    if(!
pev_valid(ent))
        return
        
    static 
Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    
    
pev(entpev_originvOrigin)
    
pev(entpev_view_ofs,vUp//for player
    
xs_vec_add(vOrigin,vUp,vOrigin)
    
pev(entpev_anglesvAngle// if normal entity ,use pev_angles
    
    
vAngle[0] = 0.0
    
    angle_vector
(vAngle,ANGLEVECTOR_FORWARD,vForward//or use EngFunc_AngleVectors
    
angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
    
angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
    
    
vStart[0] = vOrigin[0] + vForward[0] * forw vRight[0] * right vUp[0] * up
    vStart
[1] = vOrigin[1] + vForward[1] * forw vRight[1] * right vUp[1] * up
    vStart
[2] = vOrigin[2] + vForward[2] * forw vRight[2] * right vUp[2] * up
}

stock hook_ent2(entFloat:VicOrigin[3], Float:speed)
{
    if(!
pev_valid(ent))
        return
    
    static 
Float:fl_Velocity[3], Float:EntOrigin[3], Float:distance_fFloat:fl_Time
    
    pev
(entpev_originEntOrigin)
    
    
distance_f get_distance_f(EntOriginVicOrigin)
    
fl_Time distance_f speed
        
    fl_Velocity
[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time
    fl_Velocity
[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time
    fl_Velocity
[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time

    set_pev
(entpev_velocityfl_Velocity)


Maybe npc cant see player and i must change the angles? i am not sure whats the problem...

skz 11-08-2014 08:34

Re: NPC size
 
Why don't you try in a map larger than the map that you used? The npc could been stuck in some part of the map

Jhob94 11-08-2014 08:40

Re: NPC size
 
Quote:

Originally Posted by skz (Post 2221696)
Why don't you try in a map larger than the map that you used? The npc could been stuck in some part of the map

Thought about that too but isnt that the problem. I think it is at can_see_fm. Since npc is bigger, maybe cant find the player. But idk how much should i reduce the vision.


All times are GMT -4. The time now is 17:29.

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