Tracking Projectiles?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Exosphere
Posts: 144
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Tracking Projectiles?

Post by Exosphere »

How do I successfully make a tracking projectile? The one I have used in the past doesn't seem to work anymore.

Code: Select all

class trackRocket : FastProjectile
{
	Default
	{
		Radius 5;
		Height 8;
		Speed 70;
		Damage 6;
		Projectile;
		+RANDOMIZE
		+ROCKETTRAIL
		+ALLOWPARTICLES
		+SEEKERMISSILE
		+SCREENSEEKER
		Decal "Scorch";
		DamageType "ExplsnImmunity";
		DeathSound "sounds/explsn";
		
		Scale 1.0;
	}
	
	States
	{
		Spawn:
			HRKT A 1 Bright A_SeekerMissile(70, 70);
			Loop;
		Death:
			MISL B 1 Bright
			{
				A_EXPLODE(90, 65);
				for(int i = 0; i < random(10,25); i++)
				{
					A_SpawnParticle
					(
					"Orange",//color1
					SPF_RELATIVE|SPF_FULLBRIGHT,//flags
					random(10,40),//lifetime
					frandom(2.0,4.0),//size
					0,//angle
					frandom(-1.0,1.0),//xoff
					frandom(-1.0,1.0),//yoff
					frandom(-1.0,1.0),//zoff
					frandom(-1.0,1.0),//xvel
					frandom(-1.0,1.0),//yvel
					frandom(0.0,5.0),//zvel
					0,//accelx 
					0,//accely 
					-0.5,//accelz 
					1.0,//startalphaf
					0.01,//fadestepf
					0.0//sizestep
					);
				}
			}
			MISL CDEF 1 Bright;
			Stop;
	}
}
User avatar
Blue Shadow
Posts: 4903
Joined: Sun Nov 14, 2010 12:59 am
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Tracking Projectiles?

Post by Blue Shadow »

In my tests, I think it's working. I say "I think", because it's kind of hard to tell due to how fast the projectile travels.
User avatar
Exosphere
Posts: 144
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

Re: Tracking Projectiles?

Post by Exosphere »

Blue Shadow wrote:In my tests, I think it's working. I say "I think", because it's kind of hard to tell due to how fast the projectile travels.
Thats odd, since I can’t tell if its tracking. This is my firing state for the tracking rockets:

Code: Select all

TrackerFire:
			MMLR A 1 BRIGHT 
			{
				A_FireProjectile(
					"trackRocket", 
					angle: 0, 
					spawnofs_xy: 8, 
					spawnheight: 3.25
				);
				A_StartSound("weapons/rlf", CHAN_WEAPON);
			}
			MMLR BCDCBA 4;
			TNT1 A 0 A_JumpIfNoAmmo("Reload");
			Goto Ready;
Could the speed be causing the problem? If so, what speed would be better suited for the projectile to track?
User avatar
Blue Shadow
Posts: 4903
Joined: Sun Nov 14, 2010 12:59 am
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Tracking Projectiles?

Post by Blue Shadow »

I don't know what's the optimal speed, but it'd recommend something lower than what you have set there. With how fast the projectile is, you might as well not bother making it a seeker.

Return to “Scripting”