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

[Solved for now]Player in duct (?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 06-28-2014 , 13:04   [Solved for now]Player in duct (?
Reply With Quote #1

Which is the best way to detect if a player is inside a duct (ventilations)?

Once he is inside there's no need to duck so checking player's buttons in inefficient. I was thinking in force player to stand up and check if he could/couldn't, but I'm not sure how to proceed :/

It's for hns to avoid planting lasermines inside ducts ._.

Any help will be appreciated ^_^

Last edited by NikKOo31; 07-01-2014 at 11:33.
NikKOo31 is offline
Old 06-28-2014, 13:31
HamletEagle
This message has been deleted by HamletEagle.
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-28-2014 , 13:52   Re: Player in duct (?
Reply With Quote #2

By hooking Ham_Duck. (Not sure if this is it's right name. AFAIK this ham is called in the time, while the user is ducking. So you can set protection from these mines in the function of this ham.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 06-28-2014 , 14:04   Re: Player in duct (?
Reply With Quote #3

Quote:
Originally Posted by Flick3rR View Post
By hooking Ham_Duck. (Not sure if this is it's right name. AFAIK this ham is called in the time, while the user is ducking. So you can set protection from these mines in the function of this ham.
Its Ham_Player_Duck but i don't agree with you...
It will detect duck when the player presses duck key and not detect when hes in vent ( duck without pressing the key)

So i would suggest to try getting flags for ducking

Youfunction() if(pev(id, pev_flags) & FL_DUCKIN) // hes ducking

I'm sure it detects player size and not the key so it will work inside vents
__________________
Preparing to release my plugins..
r0ck is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-28-2014 , 14:07   Re: Player in duct (?
Reply With Quote #4

Quote:
Originally Posted by r0ck View Post
Its Ham_Player_Duck but i don't agree with you...
It will detect duck when the player presses duck key and not detect when hes in vent ( duck without pressing the key)

So i would suggest to try getting flags for ducking

Youfunction() if(pev(id, pev_flags) & FL_DUCKIN) // hes ducking

I'm sure it detects player size and not the key so it will work inside vents
Yes,then just check if he is not pressing a key to duck. This should be enough.
HamletEagle is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 06-28-2014 , 14:11   Re: Player in duct (?
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
Yes,then just check if he is not pressing a key to duck. This should be enough.
Players will then hold duck while planting .... well
__________________
Preparing to release my plugins..

Last edited by r0ck; 06-29-2014 at 13:04.
r0ck is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 06-28-2014 , 22:45   Re: Player in duct (?
Reply With Quote #6

You can quite easily check if a player is in a spot where they can not stand up using a EngFunc_TraceHull call. Simply get the origin and add some amount to the z axis (going upwards) and use that as the trace target. If TR_AllSolid is false and TR_flFraction is smaller than 1.0 the player is in a space where they can not stand up. You maybe have to play around a little with how far you need to move up to accurately detect this.
__________________
In Flames we trust!
Nextra is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-28-2014 , 22:50   Re: Player in duct (?
Reply With Quote #7

A simple trace_hull() call should suffice.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 06-28-2014 at 22:50.
hornet is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 06-29-2014 , 12:57   Re: Player in duct (?
Reply With Quote #8

These are my 2 options .-.

PHP Code:
stock bool:player_in_duct(id)
{
    new 
Float:origin[3]
    
pev(idpev_originorigin)
    
origin[2] += 10.0

    engfunc
(EngFunc_TraceHulloriginoriginIGNORE_MONSTERSpev(idpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMANid)

    new 
Float:fFraction
    get_tr2
(0TR_flFractionfFraction)

    if (!
get_tr2(0TR_AllSolid) && fFraction 1.0)
        return 
true

    
return false

PHP Code:
stock bool:player_in_duct2(id)
{
        const 
IN_SOLID_AREA    = (1<<TR_StartSolid)
    new 
Float:origin[3]
    
pev(idpev_originorigin)
    
origin[2] += 10.0

    
if(!(trace_hull(originpev(idpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMANid) & IN_SOLID_AREA)) 
        return 
true

    
return false

I'm not sure of trace_hull, I've never used it. I stole some Connor's code

Will be testing later

Last edited by NikKOo31; 06-29-2014 at 18:28.
NikKOo31 is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 06-30-2014 , 15:44   Re: Player in duct (?
Reply With Quote #9

Bumping ^ Here are the results









TR_AllSolid turns to true inside ventilations & turns false outside.
TR_flFraction always in 1.0 no matter where I am.

In other words, I wasn't able to accurate detect if a player is inside ducts :/

This is my current stock

PHP Code:
stock bool:player_in_duct(id, &solid, &Float:fraction)
{
    static 
tr
    
static Float:origin[3]
    
pev(idpev_originorigin)
    
origin[2] += get_pcvar_float(cvar)
    
engfunc(EngFunc_TraceHulloriginorigin0HULL_HEADidtr)
    
solid get_tr2(trTR_AllSolid)
    
get_tr2(trTR_flFractionfraction)
    if(!
solid && fraction 1.0)
        return 
true
    
    
return false

I tested many distances with the cvar.. With 25-30 I got TR_AllSolid to change
Any help? :c
Attached Images
File Type: jpg 2014-06-30_00005.jpg (73.1 KB, 324 views)
File Type: jpg 2014-06-30_00006.jpg (90.3 KB, 363 views)
File Type: jpg 2014-06-30_00007.jpg (54.8 KB, 271 views)
File Type: jpg 2014-06-30_00008.jpg (86.1 KB, 336 views)
NikKOo31 is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 07-01-2014 , 01:25   Re: Player in duct (?
Reply With Quote #10

It's obvious.

PHP Code:
engfunc(EngFunc_TraceHulloriginorigin0HULL_HEADidtr
You're starting the trace from "origin" to "origin", distance = 0 units, fraction would be always 1.0 lol
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS 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 06:06.


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