AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Search for wall between 2 origins (https://forums.alliedmods.net/showthread.php?t=63494)

hlstriker 11-22-2007 18:09

Search for wall between 2 origins
 
I made a grenade which deals splash damage. The problem is the grenade will do damage to you even if you are on the opposite side of a wall but still in distance.

Is there a way to check to see if a wall is in between a player and the grenade? I have the origins and the distance, but not sure how to scan for a wall.

Emp` 11-22-2007 19:04

Re: Search for wall between 2 origins
 
do a traceline.

hlstriker 11-24-2007 15:42

Re: Search for wall between 2 origins
 
Alright thanks. This doesn't seem to be working properly for me yet.

I'm trying to return the entity index the traceline is hitting but it seems to be incorrect.

PHP Code:

engfunc(EngFunc_TraceLineplayerOrggrenadeOrg020);
client_print(0print_chat"%i"get_tr2(0TR_pHit)); 

The above code will always either return the players index, or the grenades index. Is it supposed to be random like that? Shouldn't it only be displaying the grenade index since I'm tracing from the players origin to the grenades?

Also, it seems tracelines go through walls? When I run out of view of the grenade it will still display the player index or the grenade index.

ConnorMcLeod 11-24-2007 16:09

Re: Search for wall between 2 origins
 
Try :

Code:
engfunc(EngFunc_TraceLine, playerOrg, grenadeOrg, IGNORE_MONSTERS, id, 0)

where id is the index of player that have for origin playerOrg


Just thought you should have a look at avalanche's "no he through walls" plugin.

hlstriker 11-24-2007 16:37

Re: Search for wall between 2 origins
 
I'm now thinking that the 5th argument is the entity that the traceline is bypassing. Is this correct?

I tried setting it to the players id. Now it will return -1.

I also looked at Avalanche's plugin and it looked pretty much like I have my code now.

Here is what I now have that is returning -1
PHP Code:

engfunc(EngFunc_TraceLinegrenadeOrgplayerOrgDONT_IGNORE_MONSTERSid0); 


ConnorMcLeod 11-24-2007 16:46

Re: Search for wall between 2 origins
 
Quote:

Originally Posted by hlstriker (Post 556349)
I'm now thinking that the 5th argument is the entity that the traceline is bypassing. Is this correct?

I think that if the 5th argument is the entity index that can't be returned (ent to skip).


I also think that if you set 4th arg to DONT_IGNORE_MONSTERS, it can return another player that could be between the nade and the first player.


But a wall is not often an entity, so you have to make other checks.

May be compare nade origin and origin of what is returned
PHP Code:

get_tr2(0TR_vecEndPosdest



Wait for good advises of skilled coders :mrgreen:

hlstriker 11-24-2007 16:51

Re: Search for wall between 2 origins
 
Quote:

Originally Posted by connorr (Post 556357)
May be compare nade origin and origin of what is returned

Well, I can't do that yet because it's either returning -1, the grenade index, or the player that threw the grenades index. lol

Emp` 11-24-2007 19:58

Re: Search for wall between 2 origins
 
Code:

stock fm_trace_line(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
        engfunc(EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent);

        new ent = global_get(glb_trace_ent);
        global_get(glb_trace_endpos, ret);

        return pev_valid(ent) ? ent : 0;
}

it returns the ent if there is one in the way.

hlstriker 11-24-2007 21:41

Re: Search for wall between 2 origins
 
Thanks, working perfect now :)


All times are GMT -4. The time now is 01:16.

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