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

Trace hull custom box.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
artist
Member
Join Date: Nov 2013
Old 08-10-2017 , 15:47   Trace hull custom box.
Reply With Quote #1

Is it possible to check the space on their boxes?
Or can only these?

PHP Code:
new const Float:absmin[][] =
{
    {
0.00.00.0},    // POINT
    
{-16.0, -16.0, -36.0},    // HUMAN
    
{-32.0, -32.0, -32.0},    // LARGE
    
{-16.0, -16.0, -18.0}    // HEAD
}
new const 
Float:absmax[][] =
{
    {
0.00.00.0},    // POINT
    
{16.016.036.0},    // HUMAN
    
{32.032.032.0},    // LARGE
    
{16.016.018.0}    // HEAD

Only such an option comes to mind(check all corners):
PHP Code:
public functions(id)
{
    new 
Float:origin[3] = {-345.34503463.34340312.000000}
    new 
Float:absmin[3] = {-20.0, -10.00.0}
    new 
Float:absmax[3] = {20.010.040.0}
    
    if(
is_hull_vacant_box(originabsminabsmax))
}

stock bool:is_hull_vacant_box(Float:origin[3], Float:absmin[3], Float:absmax[3])
{
    static 
Float:point[3]
    
    
point[0] = origin[0] + absmax[0]; point[1] = origin[1] + absmax[1]; point[2] = origin[2] + absmax[2]
    
    if(!
is_hull_vacant(pointHULL_POINT)) return false
    
    point
[0] = origin[0] + absmax[0]; point[1] = origin[1] + absmin[1]; point[2] = origin[2] + absmax[2]
    
    if(!
is_hull_vacant(pointHULL_POINT)) return false
    
    point
[0] = origin[0] + absmin[0]; point[1] = origin[1] + absmin[1]; point[2] = origin[2] + absmax[2]
    
    if(!
is_hull_vacant(pointHULL_POINT)) return false
    
    point
[0] = origin[0] + absmin[0]; point[1] = origin[1] + absmax[1]; point[2] = origin[2] + absmax[2]
    
    if(!
is_hull_vacant(pointHULL_POINT)) return false
    
    point
[0] = origin[0] + absmax[0]; point[1] = origin[1] + absmax[1]; point[2] = origin[2] + absmin[2]
    
    if(!
is_hull_vacant(pointHULL_POINT)) return false
    
    point
[0] = origin[0] + absmax[0]; point[1] = origin[1] + absmin[1]; point[2] = origin[2] + absmin[2]
    
    if(!
is_hull_vacant(pointHULL_POINT)) return false
    
    point
[0] = origin[0] + absmin[0]; point[1] = origin[1] + absmin[1]; point[2] = origin[2] + absmin[2]
    
    if(!
is_hull_vacant(pointHULL_POINT)) return false
    
    point
[0] = origin[0] + absmin[0]; point[1] = origin[1] + absmax[1]; point[2] = origin[2] + absmin[2]
    
    if(!
is_hull_vacant(pointHULL_POINT)) return false
    
    
return true
}
stock bool:is_hull_vacant(Float:origin[3], hull)
{
    
engfunc(EngFunc_TraceHulloriginorigin0hull00)
    if(!
get_tr2(0TR_StartSolid) && !get_tr2(0TR_AllSolid) && get_tr2(0TR_InOpen)) return true
    
return false

Spied in the sdk, changed to amxx:
PHP Code:
stock bool:find_hull_intersection(Float:origin[3], Float:mins[3], Float:maxs[3], entignore)
{
    
engfunc(EngFunc_TraceHulloriginoriginignoreHULL_POINTent0)
    
    if(
get_tr2(0TR_StartSolid) || get_tr2(0TR_AllSolid) || !get_tr2(0TR_InOpen)) return 0
    
    
static ijkFloat:fractionFloat:end[3], Float:minmax[2][3]
    
    
minmax[0][0] = mins[0]
    
minmax[0][1] = mins[1]
    
minmax[0][2] = mins[2]
    
minmax[1][0] = maxs[0]
    
minmax[1][1] = maxs[1]
    
minmax[1][2] = maxs[2]

    
= -1
    
    
while(++2)
    {
        
= -1
        
        
while(++2)
        {
            
= -1
            
            
while(++2)
            {
                
end[0] = origin[0] + minmax[i][0]
                
end[1] = origin[1] + minmax[j][1]
                
end[2] = origin[2] + minmax[k][2]
                
                
engfunc(EngFunc_TraceLineoriginendignoreent0)
                
get_tr2(0TR_flFractionfraction)
                
                if(
fraction 1.0) return 0
            
}
        }
    }
    return 
1


Last edited by artist; 08-16-2017 at 13:52.
artist is offline
artist
Member
Join Date: Nov 2013
Old 08-11-2017 , 04:56   Re: Trace hull custom box.
Reply With Quote #2

And this:

Code:
EngFunc_TraceMonsterHull (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
Does not check on the boxes of the entity?
artist is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-11-2017 , 05:37   Re: Trace hull custom box.
Reply With Quote #3

Looks like TraceMonsterHull uses entity's pev_mins and pev_maxs to determine the size of the box to trace.
klippy is offline
artist
Member
Join Date: Nov 2013
Old 08-11-2017 , 06:15   Re: Trace hull custom box.
Reply With Quote #4

Incorrectly checks maxs:

code

Spoiler

Last edited by artist; 08-11-2017 at 06:22.
artist is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 08-12-2017 , 05:34   Re: Trace hull custom box.
Reply With Quote #5

You can use only predefined hulls for collisions world-* and *-world. But if your box is bigger than the minimal hull (head hull) then you can emulate your box with several hulls.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
artist
Member
Join Date: Nov 2013
Old 08-14-2017 , 01:15   Re: Trace hull custom box.
Reply With Quote #6

Thank you. ))
artist is offline
artist
Member
Join Date: Nov 2013
Old 08-16-2017 , 14:09   Re: Trace hull custom box.
Reply With Quote #7

Блин, перевод с русского на английский, а потом на русский...
Я так понял, что функция получает размеры объекта, и уже по этим размерам проверяет.
Я проверял не стандартные размеры, создал info_target и задал ему их.
По минимальным "стенкам" объекта всё верно работает, а по максимальным - нет.
_____________________________________________ ____________________________

Damn, a translation from Russian into English, and then into Russian ...
I understand that the function gets the size of the object, and already checks these sizes.
I checked for non-standard sizes, created info_target and set it to them.
On the minimal "walls" of the object, everything works correctly, and on the maximum - no.

Last edited by artist; 08-16-2017 at 14:09.
artist is offline
artist
Member
Join Date: Nov 2013
Old 08-17-2017 , 16:42   Re: Trace hull custom box.
Reply With Quote #8

I did a plug-in for testing:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new g_sync
new sprite_index[2]
new 
Float:g_step[33]
new 
g_idmenu[33]
new 
g_nums[33]
new 
g_ent[33]
new 
g_bbox[33]
new 
Float:g_mins[33][3]
new 
Float:g_maxs[33][3]

enum
{
    
MENU_HOME 0,
    
MENU_EDIT,
    
MENU_BBOX
}
new const 
Float:step[] = {0.10.51.05.010.020.050.0}

public 
plugin_init()
{
    
register_clcmd("say y""show_main_menus")
    
register_menucmd(register_menuid("main_menus"), 1023"main_menus_handler")
    
    
RegisterHam(Ham_Spawn"player""player_spawn"1)
    
register_forward(FM_PlayerPreThink"player_think")
    
    
g_sync CreateHudSyncObj()
}
public 
plugin_precache()
{
    
sprite_index[0] = precache_model("sprites/laserbeam.spr")
    
sprite_index[1] = precache_model("sprites/laserdot.spr")//yelflare2.spr")
}
public 
client_putinserver(id)
{
    
server_print("client_putinserver")
    if(
pev_valid(g_ent[id]) != 2g_ent[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    
g_mins[id][0] = -5.0
    g_mins
[id][1] = -5.0
    g_mins
[id][2] = -5.0
    g_maxs
[id][0] = 5.0
    g_maxs
[id][1] = 5.0
    g_maxs
[id][2] = 5.0
    engfunc
(EngFunc_SetSizeg_ent[id], g_mins[id], g_maxs[id])
    
g_step[id] = floatabs(g_mins[id][2])
    
g_nums[id] = 2
}
public 
client_disconnect(id)
{
    if(
pev_valid(g_ent[id]) == 2engfunc(EngFunc_RemoveEntityg_ent[id])
    
g_ent[id] = 0
}
public 
player_spawn(id)
{
    if(!
is_user_alive(id)) return
    
show_main_menus(idMENU_HOME)
}
public 
show_main_menus(ididmenu)
{
    
g_idmenu[id] = idmenu
    
    
static text[512], lenkey
    
    
switch(idmenu)
    {
        case 
MENU_HOME:
        {
            
len formatex(textcharsmax(text), "\yNull menu \w[\dorigin height \r%0.1f\y\w]^n^n"g_step[id])
            
len += formatex(text[len], charsmax(text) - len"\y[\r1\y] \rEdit size box^n^n")
            
len += formatex(text[len], charsmax(text) - len"\y[\r2\y] \wOrigin up to step^n")
            
len += formatex(text[len], charsmax(text) - len"\y[\r3\y] \wOrigin down to step^n^n")
            
len += formatex(text[len], charsmax(text) - len"\y[\r4\y] \wNext step \y%0.1f^n\y[\r5\y] \wReset origin"step[g_nums[id]])
            
            
key MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5
        
}
        case 
MENU_EDIT:
        {
            
len formatex(textcharsmax(text), "\yEdit size box^n^n")
            
len += formatex(text[len], charsmax(text) - len"\y[\r1\y] \wEdit min \rX \y[\w%0.1f\y]^n"g_mins[id][0])
            
len += formatex(text[len], charsmax(text) - len"\y[\r2\y] \wEdit min \rY \y[\w%0.1f\y]^n"g_mins[id][1])
            
len += formatex(text[len], charsmax(text) - len"\y[\r3\y] \wEdit min \rZ \y[\w%0.1f\y]^n"g_mins[id][2])
            
len += formatex(text[len], charsmax(text) - len"\y[\r4\y] \wEdit max \rX \y[\w%0.1f\y]^n"g_maxs[id][0])
            
len += formatex(text[len], charsmax(text) - len"\y[\r5\y] \wEdit max \rY \y[\w%0.1f\y]^n"g_maxs[id][1])
            
len += formatex(text[len], charsmax(text) - len"\y[\r6\y] \wEdit max \rZ \y[\w%0.1f\y]^n^n\y[\r7\y] \dBack"g_maxs[id][2])
            
            
key MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7
        
}
        case 
MENU_BBOX:
        {
            switch(
g_bbox[id])
            {
                case 
0len formatex(textcharsmax(text), "Edit size \ymin \rX \y[\w%0.1f\y]^n^n"g_mins[id][0])
                case 
1len formatex(textcharsmax(text), "Edit size \ymin \rY \y[\w%0.1f\y]^n^n"g_mins[id][1])
                case 
2len formatex(textcharsmax(text), "Edit size \ymin \rZ \y[\w%0.1f\y]^n^n"g_mins[id][2])
                case 
3len formatex(textcharsmax(text), "Edit size \ymax \rX \y[\w%0.1f\y]^n^n"g_maxs[id][0])
                case 
4len formatex(textcharsmax(text), "Edit size \ymax \rY \y[\w%0.1f\y]^n^n"g_maxs[id][1])
                case 
5len formatex(textcharsmax(text), "Edit size \ymax \rZ \y[\w%0.1f\y]^n^n"g_maxs[id][2])
            }
            
len += formatex(text[len], charsmax(text) - len"\y[\r1\y] \dbbox\y++^n[\r2\y] \dbbox\y--^n^n")
            
len += formatex(text[len], charsmax(text) - len"\y[\r3\y] \wNext step \y%0.1f^n^n"step[g_nums[id]])
            
len += formatex(text[len], charsmax(text) - len"\y[\r4\y] \dBack^n\y[\r5\y] \dHome")
            
            
key MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5
        
}
    }
    
show_menu(idkeytext, -1"main_menus")
    return 
PLUGIN_HANDLED
}
public 
main_menus_handler(idkey)
{
    switch(
g_idmenu[id])
    {
        case 
MENU_HOME:
        {
            switch(
key)
            {
                case 
0g_idmenu[id] = MENU_EDIT
                
case 1g_step[id] += step[g_nums[id]]
                case 
2g_step[id] -= step[g_nums[id]]
                case 
3:
                {
                    if(++
g_nums[id] > charsmax(step)) g_nums[id] = 0
                
}
                case 
4g_step[id] = floatabs(g_mins[id][2])
            }
        }
        case 
MENU_EDIT:
        {
            switch(
key)
            {
                case 
0:
                {
                    
g_bbox[id] = 0
                    g_idmenu
[id] = MENU_BBOX
                
}
                case 
1:
                {
                    
g_bbox[id] = 1
                    g_idmenu
[id] = MENU_BBOX
                
}
                case 
2:
                {
                    
g_bbox[id] = 2
                    g_idmenu
[id] = MENU_BBOX
                
}
                case 
3:
                {
                    
g_bbox[id] = 3
                    g_idmenu
[id] = MENU_BBOX
                
}
                case 
4:
                {
                    
g_bbox[id] = 4
                    g_idmenu
[id] = MENU_BBOX
                
}
                case 
5:
                {
                    
g_bbox[id] = 5
                    g_idmenu
[id] = MENU_BBOX
                
}
                case 
6g_idmenu[id] = MENU_HOME
            
}
        }
        case 
MENU_BBOX:
        {
            switch(
key)
            {
                case 
2:
                {
                    if(++
g_nums[id] > charsmax(step)) g_nums[id] = 0
                
}
                case 
3g_idmenu[id] = MENU_EDIT
                
case 4g_idmenu[id] = MENU_HOME
                
default:
                {
                    switch(
g_bbox[id])
                    {
                        case 
0g_mins[id][0] += (!key step[g_nums[id]] : -step[g_nums[id]])
                        case 
1g_mins[id][1] += (!key step[g_nums[id]] : -step[g_nums[id]])
                        case 
2:
                        {
                            
g_mins[id][2] += (!key step[g_nums[id]] : -step[g_nums[id]])
                            
g_step[id] += (key step[g_nums[id]] : -step[g_nums[id]])
                        }
                        case 
3g_maxs[id][0] += (!key step[g_nums[id]] : -step[g_nums[id]])
                        case 
4g_maxs[id][1] += (!key step[g_nums[id]] : -step[g_nums[id]])
                        case 
5g_maxs[id][2] += (!key step[g_nums[id]] : -step[g_nums[id]])
                    }
                    
engfunc(EngFunc_SetSizeg_ent[id], g_mins[id], g_maxs[id])
                }
            }
        }
    }
    
show_main_menus(idg_idmenu[id])
    return 
PLUGIN_HANDLED
}
public 
player_think(id)
{
    if(!
is_user_alive(id)) return
    
    static 
Float:origin[3]; pev(idpev_originorigin)
    static 
Float:view_ofs[3]; pev(idpev_view_ofsview_ofs)
    static 
Float:angles[3]; pev(idpev_v_angleangles)
    static 
Float:vector[3]; angle_vector(anglesANGLEVECTOR_FORWARDvector)
    static 
Float:end[3], Float:r[8][3], color[3]
    
end[0] = (view_ofs[0] += origin[0]) + (vector[0] * 8989.0)
    
end[1] = (view_ofs[1] += origin[1]) + (vector[1] * 8989.0)
    
end[2] = (view_ofs[2] += origin[2]) + (vector[2] * 8989.0)

    
engfunc(EngFunc_TraceLineview_ofsendDONT_IGNORE_MONSTERSid0)
    
get_tr2(0TR_vecEndPosend); end[2] += g_step[id]
    
    
engfunc(EngFunc_TraceMonsterHullg_ent[id], endendDONT_IGNORE_MONSTERSid0)
    
    if(
get_tr2(0TR_StartSolid) || get_tr2(0TR_AllSolid) || !get_tr2(0TR_InOpen))
    {
        
color[0] = 255
        color
[1] = 0
        color
[2] = 0
    
}
    else
    {
        
color[0] = 0
        color
[1] = 255
        color
[2] = 0
    
}
    
sprite(end1)

    
r[0][0] = end[0] + g_maxs[id][0]
    
r[0][1] = end[1] + g_maxs[id][1]
    
r[0][2] = end[2] + g_maxs[id][2]
    
r[1][0] = end[0] + g_maxs[id][0]
    
r[1][1] = end[1] + g_mins[id][1]
    
r[1][2] = end[2] + g_maxs[id][2]
    
r[2][0] = end[0] + g_mins[id][0]
    
r[2][1] = end[1] + g_mins[id][1]
    
r[2][2] = end[2] + g_maxs[id][2]
    
r[3][0] = end[0] + g_mins[id][0]
    
r[3][1] = end[1] + g_maxs[id][1]
    
r[3][2] = end[2] + g_maxs[id][2]
    
r[4][0] = end[0] + g_maxs[id][0]
    
r[4][1] = end[1] + g_maxs[id][1]
    
r[4][2] = end[2] + g_mins[id][2]
    
r[5][0] = end[0] + g_maxs[id][0]
    
r[5][1] = end[1] + g_mins[id][1]
    
r[5][2] = end[2] + g_mins[id][2]
    
r[6][0] = end[0] + g_mins[id][0]
    
r[6][1] = end[1] + g_mins[id][1]
    
r[6][2] = end[2] + g_mins[id][2]
    
r[7][0] = end[0] + g_mins[id][0]
    
r[7][1] = end[1] + g_maxs[id][1]
    
r[7][2] = end[2] + g_mins[id][2]

    
    
line(r[0], r[1], color[0], color[1], color[2])
    
line(r[1], r[2], color[0], color[1], color[2])
    
line(r[2], r[3], color[0], color[1], color[2])
    
line(r[3], r[0], color[0], color[1], color[2])
    
line(r[0], r[4], color[0], color[1], color[2])
    
line(r[1], r[5], color[0], color[1], color[2])
    
line(r[2], r[6], color[0], color[1], color[2])
    
line(r[3], r[7], color[0], color[1], color[2])
    
line(r[4], r[5], color[0], color[1], color[2])
    
line(r[5], r[6], color[0], color[1], color[2])
    
line(r[6], r[7], color[0], color[1], color[2])
    
line(r[7], r[4], color[0], color[1], color[2])

    
set_hudmessage(025500.360.800.00.10.00.03)
    
ShowSyncHudMsg(idg_sync"%f %f %f player origin^n%f %f %f vievs origin"origin[0], origin[1],  origin[2], end[0], end[1], end[2])
}
stock line(Float:start[3], Float:end[3], rgbwidth 1)
{
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_BEAMPOINTS)
    
engfunc(EngFunc_WriteCoordstart[0])
    
engfunc(EngFunc_WriteCoordstart[1])
    
engfunc(EngFunc_WriteCoordstart[2])
    
engfunc(EngFunc_WriteCoordend[0])
    
engfunc(EngFunc_WriteCoordend[1])
    
engfunc(EngFunc_WriteCoordend[2])
    
write_short(sprite_index[0])
    
write_byte(0)
    
write_byte(1)
    
write_byte(1)
    
write_byte(width)
    
write_byte(0)
    
write_byte(r)
    
write_byte(g)
    
write_byte(b)
    
write_byte(255)
    
write_byte(0)
    
message_end()
}
stock sprite(Float:origin[3], skale 1)
{
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_SPRITE)
    
engfunc(EngFunc_WriteCoordorigin[0])
    
engfunc(EngFunc_WriteCoordorigin[1])
    
engfunc(EngFunc_WriteCoordorigin[2])
    
write_short(sprite_index[1])
    
write_byte(skale)
    
write_byte(255)
    
message_end()

3 меню, в первом можно поднять/опустить коробку.
Во втором выбирается стенка коробки.
В 3м можно эту стенку передвигать(никаких защит не делал от ошибок, когда минимальная больше максимальной)...

В общем такое дело:
Когда по максимальной X, стенка <= 3 - то размеры вообще игнорируются, проверяется только как точка.
Ну и вычислил размеры по максимуму = {27.0, 27.0, 31.0}.
Т.е. они всегда статичны, хоть меняй их, хоть нет, в отличии от минимальных...
_____________________________________________ _____________________________________________ _____________

Three menus, in the first you can raise / lower the box.
In the second menu box wall is selected.
In third you can move this wall (no defenses were made from errors, when the minimum is greater than the maximum) ...

In general, this is the case:
When the maximum X, the wall is <= 3 - then the dimensions are ignored, it is checked only as a point.
But, I calculated the sizes by the maximums = {27.0, 27.0, 31.0}.
Those. They are always static, regardless of the changes unlike the minimum...

Last edited by artist; 08-19-2017 at 07:00.
artist is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 08-18-2017 , 16:57   Re: Trace hull custom box.
Reply With Quote #9

Re-read my post.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
artist
Member
Join Date: Nov 2013
Old 08-19-2017 , 06:57   Re: Trace hull custom box.
Reply With Quote #10

Да я читал, просто не понимаю, почему по максимальным стенкам всё статично...
_____________________________________________ ________________________

Yes, I read, I just do not understand why all the static walls are static ...
artist 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 07:55.


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