Raised This Month: $ Target: $400
 0% 

How to check entity side?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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