How to use A_JumpIfTargetinLOS?

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!)
Post Reply
HungryGzoong
Posts: 3
Joined: Sun Apr 13, 2025 9:48 am

How to use A_JumpIfTargetinLOS?

Post by HungryGzoong »

Code: Select all

Missile:
		POSS F 0 A_PlaySound("insertsoundeffect");
		POSS E 6 A_FaceTarget;
		POSS E 6 A_FaceTarget;
		POSS E 6 A_FaceTarget;
		goto Missile1;
	Missile1:
		POSS F 0 A_PlaySound("insertsoundeffect"); //looping sound effect
		POSS E 6 A_JumpIfTargetInLOS(1,1,JLOSF_NOAUTOAIM);
		goto Missile2;
		POSS E 1 A_MonsterRefire(0,"Missile1");
		goto Missile1+1;
	Missile2:
		POSS F 8 Bright A_SpawnProjectile("Arachnoplasma");
		POSS E 6 A_FaceTarget;
		goto See;
Hello, I can't get an enemy to "hold" its attack while its target is out of sight.
Attachments
Intended result:
Intended result:
How2.png (5.92 KiB) Viewed 137 times
Heisanevilgenius
Posts: 95
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: How to use A_JumpIfTargetinLOS?

Post by Heisanevilgenius »

It seems like you have it backwards.

Your code looks like if the target is in line of sight, it jumps to the refire code, and if they're not in sight, it jumps to the attack.

Try:

Code: Select all

Missile:
		POSS F 0 A_PlaySound("insertsoundeffect");
		POSS E 6 A_FaceTarget;
		POSS E 6 A_FaceTarget;
		POSS E 6 A_FaceTarget;
		goto Missile1;
	Missile1:
		POSS F 0 A_PlaySound("insertsoundeffect"); //looping sound effect
		POSS E 6 A_JumpIfTargetInLOS("Missile2",1,JLOSF_NOAUTOAIM);
		POSS E 1 A_MonsterRefire(0,"Missile1");
		goto Missile1+1;
	Missile2:
		POSS F 8 Bright A_SpawnProjectile("Arachnoplasma");
		POSS E 6 A_FaceTarget;
		goto See;
Post Reply

Return to “Scripting”