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

Keeping entity at a distance


Post New Thread Reply   
 
Thread Tools Display Modes
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-25-2021 , 06:35   Re: Keeping entity at a distance
Reply With Quote #11

PHP Code:
public ent_ThinkPre(iEnt)
{
    if(!
pev_valid(iEnt))
        return

    static 
className[32]
    
pev(iEntpev_classnameclassNamecharsmax(className))

    if(!
equali(classNameg_szClassName)) 
    {
        return
    }

    new 
id pev(iEntpev_owner)

    if(
is_user_alive(id))
    {
        new 
Float:fStartPos[3], Float:fvOFS[3], Float:fAngles[3]
        
pev(idpev_originfStartPos)
        
pev(idpev_view_ofsfvOFS)
        
pev(idpev_anglesfAngles)
        
fAngles[0] = 0.0
        fStartPos
[2] += fvOFS[2]
        
set_pev(iEntpev_originfStartPos)
        
set_pev(iEntpev_anglesfAngles)
        
shift_entity_position(iEnt100.00.0, -fvOFS[2])
        
        if(
get_user_button(id) & IN_FORWARD)
        {
            
entity_set_aim(iEntidtrue);
        }
        else
        {
            
entity_set_aim(iEntid);
        }
    } 

    
engfunc(EngFunc_DropToFlooriEnt)

    
set_pev(iEntpev_nextthinkget_gametime() + 0.01)

Uncomment the part you commented out, inside the shift_entity_position function and undo all the modification you did to the function.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 08-25-2021 at 06:43.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-25-2021 , 07:35   Re: Keeping entity at a distance
Reply With Quote #12

After some tests, it didn't worked. I decided to substract fvOFS[2] from fStartPos[2] at it seems working, but when a player is ducking, the entity gets close to it.

Code:
public ent_ThinkPre(iEnt) {     if(!pev_valid(iEnt))         return     static className[32]     pev(iEnt, pev_classname, className, charsmax(className))     if(!equali(className, g_szClassName))     {         return     }     new id = pev(iEnt, pev_owner)     if(is_user_alive(id))     {         new Float:fStartPos[3], Float:fvOFS[3], Float:fAngles[3]         pev(id, pev_origin, fStartPos)         pev(id, pev_view_ofs, fvOFS)         pev(id, pev_angles, fAngles)         fAngles[0] = 0.0
        fStartPos[2] -= fvOFS[2]
        set_pev(iEnt, pev_origin, fStartPos)         set_pev(iEnt, pev_angles, fAngles)         shift_entity_position(iEnt, 100.0, 0.0, -fvOFS[2])                 if(get_user_button(id) & IN_FORWARD)         {             entity_set_aim(iEnt, id, true);         }         else         {             entity_set_aim(iEnt, id);         }     }     engfunc(EngFunc_DropToFloor, iEnt)     set_pev(iEnt, pev_nextthink, get_gametime() + 0.01) }
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-25-2021 , 08:03   Re: Keeping entity at a distance
Reply With Quote #13

Whats/where the model origin ?

Also you don't need to subtract the view offset from the origin its already doing it here

shift_entity_position(iEnt, 100.0, 0.0, -fvOFS[2])

Its seems the origin of the model is in the model feet try to subtract the offset and player origin offset from the origin

shift_entity_position(iEnt, 100.0, 0.0, -fvOFS[2] - 36.0)

Now if the user is crouching you can decrease the player origin offset

shift_entity_position(iEnt, 100.0, 0.0, -fvOFS[2] - (pev(id, pev_flags) & FL_DUCKING ? 18.0 : 36.0))
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 08-25-2021 at 08:38.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
NOVA GAMING
Member
Join Date: Apr 2020
Old 08-25-2021 , 08:23   Re: Keeping entity at a distance
Reply With Quote #14

does it can help you

https://forums.alliedmods.net/showpo...30&postcount=6
__________________
NOVA GAMING is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-25-2021 , 09:06   Re: Keeping entity at a distance
Reply With Quote #15

Quote:
Originally Posted by Natsheh View Post
Whats/where the model origin ?

Also you don't need to subtract the view offset from the origin its already doing it here

shift_entity_position(iEnt, 100.0, 0.0, -fvOFS[2])

Its seems the origin of the model is in the model feet try to subtract the offset and player origin offset from the origin

shift_entity_position(iEnt, 100.0, 0.0, -fvOFS[2] - 36.0)

Now if the user is crouching you can decrease the player origin offset

shift_entity_position(iEnt, 100.0, 0.0, -fvOFS[2] - (pev(id, pev_flags) & FL_DUCKING ? 18.0 : 36.0))
Yes, now I checking if player is in duck using get_user_button(). Now it works as intended. Thank you all

PHP Code:
public ent_ThinkPre(iEnt)
{
    if(!
pev_valid(iEnt))
        return

    static 
className[32]
    
pev(iEntpev_classnameclassNamecharsmax(className))

    if(!
equali(classNameg_szClassName)) 
    {
        return
    }

    new 
id pev(iEntpev_owner)

    if(
is_user_alive(id))
    {
        new 
button get_user_button(id)
        new 
Float:fStartPos[3], Float:fvOFS[3], Float:fAngles[3]
        
pev(idpev_originfStartPos)
        
pev(idpev_view_ofsfvOFS)
        
pev(idpev_anglesfAngles)
        
fAngles[0] = 0.0
        
if(!(button IN_DUCK))
        {
            
fStartPos[2] -= fvOFS[2]
        }
        
set_pev(iEntpev_originfStartPos)
        
set_pev(iEntpev_anglesfAngles)
        if(
button IN_FORWARD)
        {
            
entity_set_aim(iEntidtrue);
        }
        else
        {
            
entity_set_aim(iEntid);
        }

        
shift_entity_position(iEnt100.00.0, -fvOFS[2])
        
engfunc(EngFunc_DropToFlooriEnt)
        
set_pev(iEntpev_nextthinkget_gametime() + 0.01)
    }

__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi 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 19:46.


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