A_Tracer's turning radius

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

A_Tracer's turning radius

Post by Ghastly »

What's the turning radius (as it would be with A_SeekerMissile's parameters) of A_Tracer? It's not on the wiki page.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: A_Tracer's turning radius

Post by Ghastly »

24 hours later. Checked the source, and it's so far over my head, I can't tell what it is from there. :?
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: A_Tracer's turning radius

Post by Gez »

Well. It could use some constants instead of hardcoded values, for consistency and to limit problems if the constants were ever changed for whatever reason.

However:

Code: Select all

	// change angle 	
	exact = R_PointToAngle2 (self->x, self->y, dest->x,  dest->y);

	if (exact != self->angle)
	{
		if (exact - self->angle > 0x80000000) // 0x80000000 == ANGLE_180
		{
			self->angle -= TRACEANGLE; // TRACEANGLE == 0xc0000000 == ANGLE_270
			if (exact - self->angle < 0x80000000)
				self->angle = exact;
		}
		else
		{
			self->angle += TRACEANGLE;
			if (exact - self->angle > 0x80000000)
				self->angle = exact;
		}
	}
Is it any clearer now?
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: A_Tracer's turning radius

Post by Ghastly »

Gez wrote:Is it any clearer now?
Nope. Saw that exact piece while rummaging around, and realized that was exactly what I was looking for, but couldn't make heads nor tails of it.

Which isn't really surprising, since I haven't really tried to learn C, yet.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: A_Tracer's turning radius

Post by Gez »

If the angle to the target is not the current angle:
* If the difference is greater than 180°, subtract up to 270° from the current angle, in order to match the angle to the target.
* Else, add up to 270° to the current angle, in order to match the angle to the target.

However, this affects only the angle it is now targeting. Then the momentum is affected by multiplying its speed (that's 10 for the revenant tracers) by the new angle's sine and cosine for the Y and X axes of movement respectively. At this point, it's maths, not code.

So, you don't have really an explicit radius, but you have a maximum turning angle (270°) and a formula to compute it.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: A_Tracer's turning radius

Post by Ghastly »

Ah. So it's not possible to completely replicate A_Tracer homing aggression with A_SeekerMissile?
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: A_Tracer's turning radius

Post by Gez »

Well, given you're limited to a 90° angle in [wiki]A_SeekerMissile[/wiki] and tracer's values are 180 and 270... Otherwise it would be just that: A_SeekerMissile(180, 270).
User avatar
bagheadspidey
Posts: 1490
Joined: Sat Oct 20, 2007 10:31 pm
Contact:

Re: A_Tracer's turning radius

Post by bagheadspidey »

Fix A_SeekerMissile gez ;)
Locked

Return to “Editing (Archive)”