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

2D velocity vector and sloped surfaces


Post New Thread Reply   
 
Thread Tools Display Modes
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2016 , 09:41   Re: 2D velocity vector and sloped surfaces
Reply With Quote #11

As i said, it is a solution for the example... i can't find a work around if i don't know how the entity is behaving exactly

Basically all you have to do is detect when the entity gets suck at the start of a ramp and make it hop over without breaking it's actual behavior
__________________

Last edited by Depresie; 10-04-2016 at 09:43.
Depresie is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 09:44   Re: 2D velocity vector and sloped surfaces
Reply With Quote #12

Depresie
Here is not good way to detect If entity gets stuck start of a ramp and I have no idea how to make hop over.
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 10-04-2016 at 09:45.
Hedgehog Fog is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2016 , 09:48   Re: 2D velocity vector and sloped surfaces
Reply With Quote #13

It is a good way to detect if the entity it's stuck on the start of the ramp, just that you have to perform couple more checks, depending on the entity's actual behavior

You can either make the hop over by either setting it's velocity on Z vector or it's origin ( but this may result into unpleasant issues, which will need additional checks to be fixed )

As i said, i cannot provide the right solution unless i know exactly how the entity actually behave
__________________

Last edited by Depresie; 10-04-2016 at 09:49.
Depresie is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 09:49   Re: 2D velocity vector and sloped surfaces
Reply With Quote #14

Quote:
It is a good way to detect if the entity it's stuck on the start of the ramp, just that you have to perform couple more checks, depending on the entity's actual behavior
I see only one way, traces.


Quote:
As i said, i cannot provide the right solution unless i know exactly how the entity actually behaves
Quote:
I can't change Z velocity and must set previous Z value all time, because it's reserved for a gravity.

Velocity sets during Think call, here is fast and bad solution:
Add 0.1 to Z velocity before think and substract 0.1 from Z velocity after.

But I have no way to use this solution, because I limited in the number of hooks.
Anyway it's undefined strange behavior. As we can see, NPC can move to the sloped surfaces.
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 10-04-2016 at 09:54.
Hedgehog Fog is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2016 , 09:53   Re: 2D velocity vector and sloped surfaces
Reply With Quote #15

There is always a way, you just have to think it through
__________________
Depresie is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 10:09   Re: 2D velocity vector and sloped surfaces
Reply With Quote #16

Depresie
I can't make some tests now and show full code, because I'm working. I'll write later.
Thanks.
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 10-04-2016 at 10:10.
Hedgehog Fog is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2016 , 10:21   Re: 2D velocity vector and sloped surfaces
Reply With Quote #17

No problem
__________________
Depresie is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 10:48   Re: 2D velocity vector and sloped surfaces
Reply With Quote #18

I have no idea why, but it's works. On default maps... But some algorithm didn't work on my map earlier:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

new g_allocClassname;

new 
g_testEnt;
new 
g_mdlTest;

public 
plugin_init()
{
    
register_plugin("""""");
    
    
register_clcmd("ent_spawn""clcmd_ent_spawn");
    
    
RegisterHam(Ham_Think"info_target""OnThink");
    
    
g_allocClassname engfunc(EngFunc_AllocString"info_target");
}

public 
plugin_precache()
{
    
g_mdlTest precache_model("models/gman.mdl");
}

public 
clcmd_ent_spawn(id)
{
    if (
g_testEnt 0) {
        
engfunc(EngFunc_RemoveEntityg_testEnt);
    }

    static 
Float:fOrigin[3];
    
GetAimOrigin(idfOrigin);
    
    
g_testEnt engfunc(EngFunc_CreateNamedEntityg_allocClassname);
    
dllfunc(DLLFunc_Spawng_testEnt);
        
    
engfunc(EngFunc_SetSizeg_testEntFloat:{-16.0, -16.00.0}, Float:{16.016.064.0});
    
engfunc(EngFunc_SetOriging_testEntfOrigin);
    
engfunc(EngFunc_DropToFloorg_testEnt);
    
    
set_pev(g_testEntpev_classname"test_ent");
    
set_pev(g_testEntpev_solidSOLID_BBOX);
    
set_pev(g_testEntpev_movetypeMOVETYPE_PUSHSTEP);
    
set_pev(g_testEntpev_gravity1.0);    
    
set_pev(g_testEntpev_iuser4id);
    
set_pev(g_testEntpev_modelindexg_mdlTest);
    
    
dllfunc(DLLFunc_Thinkg_testEnt);
}

public 
OnThink(ent)
{
    static 
classname[32];
    
pev(entpev_classnameclassnamecharsmax(classname));
    
    if (!
equal(classname"test_ent")) {
        return;
    }
    
    new 
target pev(entpev_iuser4);
    if (
target 0) {
        static 
Float:fTarget[3];
        
pev(targetpev_originfTarget);
        
        
TurnTo(fTarget);
        
MoveForward(200.0);
    }


    
DrawBox(ent)

    
set_pev(entpev_nextthinkget_gametime() + 0.1);
}

MoveForward(Float:fSpeed)
{
    if (
g_testEnt <= 0) {
        return;
    }

    static 
Float:fDirection[3];
    
GetDirectionVector(g_testEntfDirection);
    
xs_vec_mul_scalar(fDirectionfSpeedfDirection);
    
    static 
Float:fVelocity[3];
    
pev(g_testEntpev_velocityfVelocity);
    
fDirection[2] = fVelocity[2];
    
    
set_pev(g_testEntpev_velocityfDirection);
}

TurnTo(const Float:fTarget[3]) 
{
    static 
Float:fOrigin[3];
    
pev(g_testEntpev_originfOrigin);
    
    
xs_vec_sub(fTargetfOriginfOrigin);

    static 
Float:fAngles[3];
    
engfunc(EngFunc_VecToAnglesfOriginfAngles);
    
fAngles[0] = 0.0;
    
fAngles[2] = 0.0
    
    
set_pev(g_testEntpev_anglesfAngles);
    
set_pev(g_testEntpev_v_anglefAngles);
}

stock GetDirectionVector(entFloat:fOut[3])
{
    static 
Float:fAngles[3];
    
pev(entpev_anglesfAngles);
    
angle_vector(fAnglesANGLEVECTOR_FORWARDfOut);
    
xs_vec_normalize(fOutfOut);
}

stock GetAimOrigin(idFloat:fOut[3], Float:fDistance 1024.0)
{
    static 
Float:fStart[3];    
    
pev(idpev_originfStart);
    
    static 
Float:view_ofs[3];
    
pev(idpev_view_ofsview_ofs);
    
    
xs_vec_add(fStartview_ofsfStart);

    static 
Float:fEnd[3];
    
pev(idpev_v_anglefEnd);
    
engfunc(EngFunc_MakeVectorsfEnd);
    
global_get(glb_v_forwardfEnd);
    
xs_vec_mul_scalar(fEndfDistancefEnd);
    
xs_vec_add(fStartfEndfEnd);

    
engfunc(EngFunc_TraceLinefStartfEnd0id0);
    
get_tr2(0TR_vecEndPosfOut);
}

stock DrawBox(ent)
{
    new 
Float:fMins[3];
    
pev(entpev_absminfMins);
    
    new 
Float:fMaxs[3];       
    
pev(entpev_absmaxfMaxs);  
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_BOX);
    
engfunc(EngFunc_WriteCoordfMins[0]);
    
engfunc(EngFunc_WriteCoordfMins[1]);
    
engfunc(EngFunc_WriteCoordfMins[2]);
    
engfunc(EngFunc_WriteCoordfMaxs[0]);
    
engfunc(EngFunc_WriteCoordfMaxs[1]);
    
engfunc(EngFunc_WriteCoordfMaxs[2]);
    
write_short(1);
    
write_byte(255);
    
write_byte(255);
    
write_byte(255);
    
message_end();

__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 10-04-2016 at 10:49.
Hedgehog Fog is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2016 , 11:46   Re: 2D velocity vector and sloped surfaces
Reply With Quote #19

Probably because there was a negative value on velocity Z.. can't go up if it's going down lol
__________________

Last edited by Depresie; 10-04-2016 at 11:48.
Depresie is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 10-04-2016 , 12:08   Re: 2D velocity vector and sloped surfaces
Reply With Quote #20

Depresie
Nope, Z velocity is equal to 0. I think it's just a magic surface.
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities
Hedgehog Fog is offline
Old 10-04-2016, 13:06
Depresie
This message has been deleted by Depresie.
Old 10-04-2016, 13:16
Depresie
This message has been deleted by Depresie.
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 06:11.


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