Raised This Month: $27 Target: $400
 6% 

Npc jump


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Point
Junior Member
Join Date: Oct 2014
Old 03-31-2020 , 08:26   Npc jump
Reply With Quote #1

Hello!
I'm looking for a way to make the npc jump when there is an obstacle, as shown in the image.
I don't know how can i detect that in an effective way..

If someone can help me with ideas, thanks.


Last edited by Point; 03-31-2020 at 08:26.
Point is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-31-2020 , 08:32   Re: Npc jump
Reply With Quote #2

The way i would do it is, detect if player is pressing any movement button (forward, backward, sideways). Check if movement's current speed is 0, if it is, jump.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 03-31-2020 , 12:10   Re: Npc jump
Reply With Quote #3

I would suggest something like this:

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <xs>

#define bot_classname "bot"

new Float:g_client_jumpdelay[33]

public 
plugin_init()
{
    
// Register: Touch
    
register_touch("worldspawn"bot_classname"touch_wall")
    
register_touch("func_brush"bot_classname"touch_wall")
    
register_touch("func_breakable"bot_classname"touch_wall")
}

public 
touch_wall(entityclient)
{
    if(
is_user_alive(client))
    {
        if(
g_client_jumpdelay[client] < get_gametime())
        {
            
g_client_jumpdelay[client] = (get_gametime() + 1.0)

            new 
Float:client_origin[3], Float:client_angle[3]
            
pev(clientpev_originclient_origin)
            
client_origin[2] -= 36.0 // Checking origin from the feet (not sure value is correct)
            
pev(clientpev_v_angleclient_angle)

            
//client_angle[0] = -10.0 // Not sure why exactly I used this in 'Walk Through Walls'

            // Get the origin in front of the player, and see if something is standing between the 2 points
            
new Float:futur_origin[3]
            
origin_infront(client_angleclient_origin17.0futur_origin)

            new 
trace_handle create_tr2()
            
engfunc(EngFunc_TraceLineclient_originfutur_originDONT_IGNORE_MONSTERSclienttrace_handle)
            
get_tr2(trace_handleTR_vecEndPosfutur_origin)

            if(
get_distance_f(client_originfutur_origin) < 17.0)
            {
                
// Going to force a jump
                
client_print(0print_chat"Bot %i - Is forced to jump"client)

                
engfunc(EngFunc_MakeVectorsclient_angle)
                new 
Float:forward_vector[3]
                
get_global_vector(GL_v_forwardforward_vector)

                
client_angle[0] = forward_vector[0] * 200.0
                client_angle
[1] = forward_vector[1] * 200.0
                client_angle
[2] = 220.0

                set_pev
(clientpev_velocityclient_angle)
            }
        }
    }
}

origin_infront(Float:vAngles[3], Float:vecOrigin[3], Float:flDistanceFloat:vecOutput[3]) // By Exolent
{
    static 
Float:vecAngles[3]
    
xs_vec_copy(vAnglesvecAngles)

    
engfunc(EngFunc_MakeVectorsvecAngles)
    
global_get(glb_v_forwardvecAngles)

    
xs_vec_mul_scalar(vecAnglesflDistancevecAngles)

    
xs_vec_add(vecOriginvecAnglesvecOutput)

__________________
Retired.
Xalus is offline
Reply


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 00:47.


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