Raised This Month: $32 Target: $400
 8% 

Solved Traceline, more ents to ignore


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Vieni
Member
Join Date: Apr 2018
Old 04-19-2020 , 20:25   Traceline, more ents to ignore
Reply With Quote #1

Hey everyone,
So i need help with creating a traceline which ignores more than 1 entity.

It would be useful, when trying to create a traceline, which checks the player ents from wall to wall.

I tried creating a new traceline at the end position of the official one(and so on unless a new traceline hits the scoped end of the official), but it gets into an infinite loop when 2ents intersect, are solid and are in the traceline. It is because it starts to jump from one to another. [Appears if players are intersecting 'cause of the no block plugin, or just create 2 confronting ents in the traceline (e.g tripmine)]


So there are 2 ideas i got in my mind:
- Make the traceline to be created a little farther if it jumps back to an already hit ent
- Somehow come up with a traceline which ignores more ents
-> If that ain't possible, modify the fakemeta module(but i've never done this, so i don't know how hard it would be)

With the first idea the problem is that, i don't know how to add exact value to a vector, i only know how to scale it and if i'd try to scale it, the longer the traceline is, the bigger hole it would create in it(and possibly leave some ents out of the check) and the smaller it is, the more possibility for another infinite loop(e.g. the whole traceline is in 2ents) or just bunch of not neccessary checking.

With the second one, as i mentioned, i don't know if it's possible.

Last edited by Vieni; 04-30-2020 at 12:52.
Vieni is offline
Vieni
Member
Join Date: Apr 2018
Old 04-30-2020 , 12:51   Re: Traceline, more ents to ignore
Reply With Quote #2

Solved
Done by creating arrays and and saving the solidity in them, then make the hit entity non-solid and if once the traceline reached it's end putting back the solidity to the normal. Who would have thought lmao

This is a snippet from my lasermine plugin:
Code:
			static Float:lEnd[3], Float:lOrigin[3]
			entity_get_vector(laserMine, EV_VEC_origin, lOrigin)
			entity_get_vector(laserMine, EV_VEC_beamendpoint, lEnd)
			
			static Float: fFraction
			static lHit
			static lTraceHandle
			lTraceHandle = create_tr2();
			
			static entityName[32]
			static Array:entitiesHit
			static Array:entitiesSolidity
			
			entitiesHit = ArrayCreate(1)
			entitiesSolidity = ArrayCreate(1)
			
			while(engfunc(EngFunc_TraceLine, lOrigin, lEnd, DONT_IGNORE_MONSTERS, laserMine, lTraceHandle)) // will always return 1, see engfunc.cpp
			{
				lHit = get_tr2(lTraceHandle, TR_pHit) // getting hitted entity
				
				get_tr2(lTraceHandle, TR_flFraction, fFraction)
				
				if(lHit == -1 || fFraction >= 1.0) // the traceline finished at the original end position, so we will stop here
				{
					new Float:lEndP[3], Float:lNormal[3]
					new Float:EntVector[3]
					entity_get_vector(laserMine, EV_VEC_origin, lOrigin)

					trace_line(-1, lOrigin, lEnd, lNormal)
					
					lNormal[0] -= lOrigin[0]
					lNormal[1] -= lOrigin[1]
					lNormal[2] -= lOrigin[2]
					EntVector[0] = lNormal[0]*8
					EntVector[1] = lNormal[1]*8
					EntVector[2] = lNormal[2]*8
					EntVector[0] += lOrigin[0]
					EntVector[1] += lOrigin[1]
					EntVector[2] += lOrigin[2]
					
					engfunc(EngFunc_TraceLine, lOrigin, EntVector, IGNORE_MONSTERS, -1, lTraceHandle)
					
					get_tr2(lTraceHandle, TR_vecEndPos, lEndP)
					
					entity_set_vector(laserMine, EV_VEC_beamendpoint, lEndP)
					break
				}
				
				entity_get_string(lHit, EV_SZ_classname, entityName, charsmax(entityName))
				
				if(!equal(entityName, "player") || !is_user_alive(lHit))
				{
					ArrayPushCell(entitiesSolidity, entity_get_int(lHit, EV_INT_solid))
					ArrayPushCell(entitiesHit, lHit)
					entity_set_int(lHit, EV_INT_solid, SOLID_NOT)
					continue
				}
				
				createLaserDamage(laserMine, lHit)
				
				ArrayPushCell(entitiesSolidity, pev(lHit, pev_solid))
				ArrayPushCell(entitiesHit, lHit)
				entity_set_int(lHit, EV_INT_solid, SOLID_NOT)
			}
			

			free_tr2(lTraceHandle) // freeing the tracehandle 
			
			static entHit, entSolidity
			
			for(new i; i < ArraySize(entitiesHit); i++)
			{
				entHit = ArrayGetCell(entitiesHit, i)
				entSolidity = ArrayGetCell(entitiesSolidity, i)
				
				if(pev_valid(entHit))
					entity_set_int(entHit, EV_INT_solid, entSolidity)
			}
			
			ArrayDestroy(entitiesHit)
			ArrayDestroy(entitiesSolidity)

Last edited by Vieni; 04-30-2020 at 12:51.
Vieni is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 05-02-2020 , 11:42   Re: Traceline, more ents to ignore
Reply With Quote #3

Nice, but I have a better idea: save the original start position instead, set entity non-solid, trace further from position of undesired hit, immediately set it back to original solidity. This way you don't need to store the ent IDs.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Vieni
Member
Join Date: Apr 2018
Old 05-02-2020 , 13:40   Re: Traceline, more ents to ignore
Reply With Quote #4

Quote:
Originally Posted by georgik57 View Post
Nice, but I have a better idea: save the original start position instead, set entity non-solid, trace further from position of undesired hit, immediately set it back to original solidity. This way you don't need to store the ent IDs.
I think the same would happen, only now it could be caused by 3 entities:
Quote:
It is because it starts to jump from one to another.

Last edited by Vieni; 05-02-2020 at 13:41.
Vieni is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 05-02-2020 , 13:46   Re: Traceline, more ents to ignore
Reply With Quote #5

Oh ok fair point. Yours sounds like a better solution then.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Reply


Thread Tools
Display Modes

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 01:44.


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