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

(CS:GO) Detect narrow corridors/doorways etc.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MAGNET12
Member
Join Date: Dec 2017
Old 05-11-2020 , 11:07   (CS:GO) Detect narrow corridors/doorways etc.
Reply With Quote #1

Hello everyone,

I'm trying to create a function that checks if player is standing in a narrow spot, cause I want him to prevent creating exploding mines in such places. I've received a lot of help from ashkerin, who told me to use TraceHull.
What I do right now is creating a "surface" (it's 1 unit thick), that goes straight up from the ground all the way to the player's head and detects if TR_DidHit() have occured

Code:
bool IsFreeArea(int client) {
  float originBegin[3];
  GetClientAbsOrigin(client, originBegin);
  originBegin[2] += 5.0;

  float originEnd[3];
  GetClientEyePosition(client, originEnd);

  float hullMins[3];
  hullMins[0] -= HULL_SIZE;
  hullMins[1] -= HULL_SIZE;

  float hullMaxs[3];
  hullMaxs[0] += HULL_SIZE;
  hullMaxs[1] += HULL_SIZE;
  hullMaxs[2] += 1.0;

  Handle trace = TR_TraceHullFilterEx(originBegin, originEnd, hullMins, hullMaxs, MASK_ALL, TraceEntityFilterPlayer);

  bool hit = TR_DidHit(trace);
  CloseHandle(trace);
  
  return hit;
}

public bool TraceEntityFilterPlayer(entity, contentsMask) {
  return entity > MaxClients;
}
Unfortunately, this solution doesn't work. It returns true in completely random situations.
Am I doing something wrong? Any help would be appreciated.

Thank you in advance
__________________
MAGNET12 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 16:19.


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