Raised This Month: $ Target: $400
 0% 

How to check entity side?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kulers2010
Junior Member
Join Date: Oct 2011
Location: Latvia
Old 07-27-2013 , 05:31   How to check entity side?
Reply With Quote #1

I search and found only this but i dont know how to use thats on entity.

#define TOUCH_NONE 1<<0
#define TOUCH_ALL 1<<1
#define TOUCH_BOTH 1<<2
#define TOUCH_HEAD 1<<3
#define TOUCH_FOOT 1<<4
#define TOUCH_OTHER 1<<5

Edit: I mean when player touch thats entity.

Last edited by kulers2010; 07-27-2013 at 06:11.
kulers2010 is offline
Send a message via Skype™ to kulers2010
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-27-2013 , 09:50   Re: How to check entity side?
Reply With Quote #2

Do you want to determine which side of the entity that was touched?
I believe you have to compare origins and check which dimension is the closest to determine that.
__________________
Black Rose is offline
kulers2010
Junior Member
Join Date: Oct 2011
Location: Latvia
Old 07-27-2013 , 11:55   Re: How to check entity side?
Reply With Quote #3

I need if player stands on the block ,or touch side or hit his head to the block bottom
kulers2010 is offline
Send a message via Skype™ to kulers2010
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-27-2013 , 12:39   Re: How to check entity side?
Reply With Quote #4

Quote:
Originally Posted by kulers2010 View Post
I need if player stands on the block ,or touch side or hit his head to the block bottom
Yes, but do you need to determine which side of the block that is touched or just that is was touched?
__________________
Black Rose is offline
kulers2010
Junior Member
Join Date: Oct 2011
Location: Latvia
Old 07-27-2013 , 12:50   Re: How to check entity side?
Reply With Quote #5

How i said i need know whitch side bottom, top or sides
kulers2010 is offline
Send a message via Skype™ to kulers2010
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-27-2013 , 15:30   Re: How to check entity side?
Reply With Quote #6

Ok, then you just compare the differences from the entity origin and the player origin to the size of the entity and the one that is the lowest contains your answer.

EDIT: I found the subject interesting so I decided to try it out. This is the best I could create:
There may be some math errors but I don't think so. If there is, it would be because it's 4AM here and I need to sleep.
Code:
#include <amxmodx> #include <hamsandwich> #include <fakemeta> new const g_TouchedSide[][] = {     "east",     "north",     "top",     "west",     "south",     "bottom" } public plugin_init() {     register_plugin("Test Plugin 9", "", "");         RegisterHam(Ham_Touch, "player", "HamTouch"); } public HamTouch(id, ent) {         if ( 0 >= id > 32 || ! ent )     return;         new iSide, Float:plOrigin[3], Float:entOrigin[3], Float:entSize[3], Float:entMins[3], Float:entMaxs[3];         pev(id, pev_origin, plOrigin);     pev(ent, pev_origin, entOrigin);     pev(ent, pev_size, entSize);     pev(ent, pev_mins, entMins);     pev(ent, pev_maxs, entMaxs);         new Float:fDifference[4] = {0.0,0.0,0.0,9999.9};         fDifference[0] = floatabs(floatabs(floatabs(plOrigin[0]) - floatabs(entOrigin[0] + entMins[0] + ( ( floatabs(entMins[0]) + floatabs(entMaxs[0]) ) / 2 ) ) ) - entSize[0] / 2 - 16); // Touched East/West     fDifference[1] = floatabs(floatabs(floatabs(plOrigin[1]) - floatabs(entOrigin[1] + entMins[1] + ( ( floatabs(entMins[1]) + floatabs(entMaxs[1]) ) / 2 ) ) ) - entSize[1] / 2 - 16); // Touched North/South     fDifference[2] = floatabs(floatabs(floatabs(plOrigin[2]) - floatabs(entOrigin[2] + entMins[2] + ( ( floatabs(entMins[2]) + floatabs(entMaxs[2]) ) / 2 ) ) ) - entSize[2] / 2 - ( pev(id, pev_flags) & FL_DUCKING ? 18 : 36 ) ); // Touched Top/Bottom         for ( new i = 0; i < 3 ; i++ ) {         if ( fDifference[i] < fDifference[3] ) {             iSide = i;             fDifference[3] = fDifference[i]         }     }         if ( plOrigin[iSide] < entOrigin[iSide] )     iSide += 3;         client_print(id, print_chat, "%d touched %d on the %s side", id, ent, g_TouchedSide[iSide]); } /* Player offsets: * X *   +16 * Y *   +16 * Z *   Standing:  +36 *   Ducking:   +18 */
__________________

Last edited by Black Rose; 04-27-2014 at 08:41.
Black Rose 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 06:28.


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