I have the following code that warps the farthest bot to where I am pointing.
It works perfectly when pointing at the floor but
when pointing to a wall or other things it places the bots into them and they get stuck.
Is there a way to do the trace to keep them from being placed into things and being stuck?
tx
PHP Code:
public Action Command_warpFarBot(int client, int args)
{
float clientPos[3];
GetEntPropVector(client, Prop_Data, "m_vecOrigin", clientPos);
int farthestBotIndex = getFarthestBot(client);
new Float:g_Origin[3];
new Float:g_Angle[3];
new Float:normal[3];
You want to use a trace hull to scan a rectangular prism area for intersecting entitys before teleporting the player.
The trace hull size would be the max size of the player entity.
If something is intersecting the end point then you would want to move the endpoint away from the wall/ent you just hit by a fixed value in the inverse direction of the tracerays view angle.
Then you run the tracehull scan again until it is cleared or a max threshold of scans are reached.
If the area is then clear we would teleport the player entity or else deny it.
public void OnMapStart()
{
beammdl = PrecacheModel("materials/sprites/laserbeam.vmt", true);
}
bool IsAreaClear(int client, float position[3])
{
//This is the players collision rectangular prism size defined by two 3D Points farthest away from each other
static float vecMins[3] = {-16.0, -16.0, 0.0};
static float vecMaxs[3] = {16.0, 16.0, 72.0};
if(!TR_DidHit(INVALID_HANDLE))
{
PrintToChat(client, "\x01\x02 \x02Trace ray did not hit anything!");
return Plugin_Handled;
}
TR_GetEndPosition(HitEndPoint);
//We can get the ground underneath the player by shooting another raytrace directly down
//This prevents players from spawning on the wall really high and causing fall damage
float down[3] = {90.0, 0.0, 0.0};
iterationCount++;
if(iterationCount > 10)
{
PrintToChat(client, "\x01\x02 \x02Area is not Clear!");
return Plugin_Handled;
}
//Iterate point 32 units towards the player camera for next trace hull check
for(int i = 0;i < 3; i++)
HitEndPoint[i] = HitEndPoint[i] + (fForwards[i] * 32.0);
}
//debug message for iteration loop count
//PrintToChat(client, "\x01\x02 \x10Exit loop after %i iterations", iterationCount);
You want to use a trace hull to scan a rectangular prism area for intersecting entitys before teleporting the player.
The trace hull size would be the max size of the player entity.
If something is intersecting the end point then you would want to move the endpoint away from the wall/ent you just hit by a fixed value in the inverse direction of the tracerays view angle.
Then you run the tracehull scan again until it is cleared or a max threshold of scans are reached.
If the area is then clear we would teleport the player entity or else deny it.
public void OnMapStart()
{
beammdl = PrecacheModel("materials/sprites/laserbeam.vmt", true);
}
bool IsAreaClear(int client, float position[3])
{
//This is the players collision rectangular prism size defined by two 3D Points farthest away from each other
static float vecMins[3] = {-16.0, -16.0, 0.0};
static float vecMaxs[3] = {16.0, 16.0, 72.0};
if(!TR_DidHit(INVALID_HANDLE))
{
PrintToChat(client, "\x01\x02 \x02Trace ray did not hit anything!");
return Plugin_Handled;
}
TR_GetEndPosition(HitEndPoint);
//We can get the ground underneath the player by shooting another raytrace directly down
//This prevents players from spawning on the wall really high and causing fall damage
float down[3] = {90.0, 0.0, 0.0};
iterationCount++;
if(iterationCount > 10)
{
PrintToChat(client, "\x01\x02 \x02Area is not Clear!");
return Plugin_Handled;
}
//Iterate point 32 units towards the player camera for next trace hull check
for(int i = 0;i < 3; i++)
HitEndPoint[i] = HitEndPoint[i] + (fForwards[i] * 32.0);
}
//debug message for iteration loop count
//PrintToChat(client, "\x01\x02 \x10Exit loop after %i iterations", iterationCount);
You want to use a trace hull to scan a rectangular prism area for intersecting entitys before teleporting the player....
WOW!
THANK YOU Franc1sco!
And also thanks to backwards.
Even though you "relied heavly" on Franc1sco' work
-you did all of the modifications-
to HAND me a WORKING
plugin working exactly how I needed it to work.
As well as describing exactly how it works...
There is major credit in that....
"relying heavly" on others work is how this community thrives...
Only thing is giving credit where deserved...
I have been here 20 years! (almost)
Going for another 20?!
I hope alliedmods.net and this great community never goes away.
Even though you "relied heavly" on Franc1sco' work
"relying heavly" on others work is how this community thrives...
Only thing is giving credit where deserved...
I don't know where you got the idea that I used any of his code or references?
I wrote all the code myself, starting only from the snippet of code you posted above.
This is similar to things I already made in older projects like this:
I don't know where you got the idea that I used any of his code or references?
I wrote all the code myself, starting only from the snippet of code you posted above.
This is similar to things I already made in older projects like this:
I misread Franc1sco post as sarcasm.
Very sorry about that!
VERY.
You obviously know SM coding
forwards and backwards.....
Mine is a foulproof function that will teleport you across the your angle. Even teleport behind you if needed / if you are staring directly below yourself.
It will teleport you to the aim position, then for every time you are stuck, teleport you backwards across the angle of aim ( so you can teleport someone behind you if you're looking at a wall... )
I don't know where you got the idea that I used any of his code or references?
I wrote all the code myself, starting only from the snippet of code you posted above.
This is similar to things I already made in older projects like this: