LineTrace flag: TRF_ACTIVATELINES

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: LineTrace flag: TRF_ACTIVATELINES

Re: LineTrace flag: TRF_ACTIVATELINES

by phantombeta » Wed Jun 12, 2019 11:47 pm

Matt wrote:TIL LineTracers can't activate lines. The flag for it is commented out and the TraceCallback function is data scope.

We still don't have a solution for this that doesn't involve calling a separate attack.
You put the lines in a dynamic array, then call the Activate function on them from outside TraceCallback. TraceCallback should only handle getting the info, not doing anything with said info.

Re: LineTrace flag: TRF_ACTIVATELINES

by Matt » Wed Jun 12, 2019 11:03 pm

TIL LineTracers can't activate lines. The flag for it is commented out and the TraceCallback function is data scope.

We still don't have a solution for this that doesn't involve calling a separate attack.

Re: LineTrace flag: TRF_ACTIVATELINES

by Matt » Sat Jun 01, 2019 12:58 pm

Thanks for the example! Will take a look in the coming weeks...

Re: LineTrace flag: TRF_ACTIVATELINES

by kodi » Sat Jun 01, 2019 8:15 am

Matt: This is where you'll want to use the Linetracer class with it's more powerful Trace function rather than LineTrace. It can trace through the entire level and return everything if you set it up right. Here is an example of uses, a "railgun" function:

Code: Select all


Class SabotTracer : LineTracer
{
	Actor owner;
	array<actor> skips;
	double maxdist;
	override ETraceStatus TraceCallback()
	{
		if ( Results.HitType == TRACE_HitActor )
		{
			if ( (Results.HitActor == owner || skips.find(Results.Hitactor)!=skips.size())) return TRACE_Skip;
			if ( Results.HitActor.bSHOOTABLE) return TRACE_Stop;
		}
		else if ( (Results.HitType == TRACE_HitWall) && (Results.Tier == TIER_Middle) )
		{
			if ( !Results.HitLine.sidedef[1] || (Results.HitLine.Flags&(Line.ML_BlockHitscan|Line.ML_BlockEverything)) )
				return TRACE_Stop;
			return TRACE_Skip;
		}
		return TRACE_Stop;
	}
}

//[inside custom weapon attack function]

let t = sabotTracer(new("sabotTracer"));
t.owner = self;
t.maxdist = 9000.0;
vector3 dir = DSH_kMath.Vec3FromAngle(10,act.aimvector.x,act.aimvector.y).unit();
while(t.trace((self.pos.xy,player.viewz),cursector,dir,t.maxdist,0))
{
	if( t.Results.HitType == TRACE_HitActor )
	{
		t.skips.push(t.Results.Hitactor);
		t.Results.HitActor.DamageMobj(act,act,120,'bullet',0,0);
	}
	else
	{	
		break;
	}
}
double sparsity = 5;
for ( int i=0; i<t.Results.Distance; i+=sparsity )
{
	Spawn("SabotSmoke",Vec3Offset(dir.x*i,dir.y*i,(player.viewz-self.pos.z-5)+(dir.z*i)));
}
				

Re: LineTrace flag: TRF_ACTIVATELINES

by Matt » Fri May 31, 2019 3:27 pm

Got it, thanks.

Speaking of results after collecting data... is there any way to get from a LineTrace the linedefs that the trace has passed through?

Re: LineTrace flag: TRF_ACTIVATELINES

by Graf Zahl » Fri May 31, 2019 1:33 pm

In many nasty ways - the big problem is that any action can cause an actor to change state and thus to call an action function which in turn can trigger other actions that end up calling P_CheckPosition again, resulting in nasty recursions with unpredictable side effects.

One particular thing is that there are situations where triggering a teleporter simply does not work because after the teleport is complete, the recursion unwinds and only then finishes the move of the teleported actor, essentially resetting it to its old position.

Rest assured: You do not want side effects in checking functions - the actions should be taken after the result from the check has been evaluated, not while it collects its data.

Re: LineTrace flag: TRF_ACTIVATELINES

by Matt » Fri May 31, 2019 1:23 pm

Just out of curiosity how does this intermingling break things?

Re: LineTrace flag: TRF_ACTIVATELINES

by Graf Zahl » Fri May 31, 2019 12:39 pm

I mean safe from a gameplay mechanics point of view. Checking functions and evaluation functions should be separate and not be mixed together.
PIT_CheckThing and PIT_CheckLine made this mistake and it's something that's haunting us for all eternity. The code is fundamentally broken but cannot be fixed.

Re: LineTrace flag: TRF_ACTIVATELINES

by phantombeta » Fri May 31, 2019 12:22 pm

Graf Zahl wrote:No. This simply isn't safe.
In the original code the collision detection for actors works exactly like you suggest and that's the single biggest problem in the entire engine.
What isn't safe about this? Linetrace is play scope.
I'm not sure what you mean wrt. collision detection, either - collision detection wasn't really mentioned anywhere in the OP.

Re: LineTrace flag: TRF_ACTIVATELINES

by Graf Zahl » Fri May 31, 2019 12:15 pm

No. This simply isn't safe.
In the original code the collision detection for actors works exactly like you suggest and that's the single biggest problem in the entire engine.

LineTrace flag: TRF_ACTIVATELINES

by Matt » Fri May 31, 2019 9:44 am

An option to have a LineTrace call activate the lines that the trace crosses.

I've got a use case where I'm calling LineTrace to get all sorts of information on the attack distance, direction, victim, etc. but I'm calling LineAttack again to deal with certain bullet-pass-through lines.

Top