Trace Ray Assistance (Yeah, from me, lol)
I haven't needed to use a trace ray before now, so anyone who can help me, please do so :)
I basicly want to find all players within x radius of a target player. The list of players found will be used to kill them as part of an "explosion", so it should exclude people behind walls, etc. Thanks :) |
Re: Trace Ray Assistance (Yeah, from me, lol)
I'm not sure if you really need a Trace Ray for that, couldn't you just loop trough all players and calculate their vector distance ?
Edit: Nvm, I didn't read the last part of your post. Well, I first would calculate the vector distances of all players and then do that Traceray thing. That's a function of the Tracespray plugin, maybe it helps ;) Quote:
|
Re: Trace Ray Assistance (Yeah, from me, lol)
Helloes :)
DISCLAIMER: I have never done SourceMod scripting :) What you are trying to accomplish might be something like this: 1) You have the origin of the target player, the center of the explosion 2) Loop through all players (skip the target player to avoid division by zero =P ) 2.1) for each player: calculate the distance: get his origin, subtract the two vectors, compute VectorLength (either through a native or by using good old pythagoras) 2.2) if that distance is <= MAXRADIUS, the player is potentially in your explosion radius. If the distance is greater, skip this player as he is unaffected 2.3) Now the trace ray would be used - basically only in order to find out whether there is a wall between the explosion center point and the currently examined player. The start position of the trace ray would be the explosion center point, the direction vector would be (current loop player origin - explosion center point) (you might need to normalise this vector or you might not, I don't know). It can be an infinite trace because you're going to hit the player in that diretion anyway. With the mask flags you can decide what makes the trace stop and what is ignored. You might also need to set up a filter function and filter out the target player if the trace hits him. Then if TR_GetEntityIndex returns the index of the player's entity which is in the current loop, the trace didn't hit anything else in between, so there was no wall and you can safely let the player explode. You could also make the damage done depend on the distance. The easiest way would be a linear relation: damage = MAX_DAMAGE * (MAX_RADIUS - distance) / MAX_RADIUS edit: pseudo code added: Code:
new g_FilteredEntity = -1; |
Re: Trace Ray Assistance (Yeah, from me, lol)
I love when you get involved PM.
|
Re: Trace Ray Assistance (Yeah, from me, lol)
I'm going to try the following, as I want a gaurenteed kill within "half radius"
Code:
new damage = 100; |
| All times are GMT -4. The time now is 05:25. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.