A_FaceTarget Angel and pitch offsets

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
Xtyfe
Posts: 1490
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

A_FaceTarget Angel and pitch offsets

Post by Xtyfe »

This is my shotgun guy, I'm using the new A_FaceTarget offsets to make all my zombie peoples less accurate but it seems I'm using this wrong. They still hit me dead accurate 99% of the time.
Am I using this correctly? Should I be using larger values?

Also, the default values are not listed on the wiki page for the function, I had to do some guessing for the first 2 arguments for A_FaceTarget.

Code: Select all

Actor XtCorporal : XtMonster replaces ShotgunGuy
{
Radius 20
Height 56
Mass 100
Health 30
PainChance 224
PainChance "Shadow", 256
Speed 4
MinMissileChance 192
MaxTargetRange 1024
Species "Zombie"
SeeSound "zombie/sight"
ActiveSound "zombie/active"
PainSound "zombie/pain"
DeathSound "zombie/death"
DropItem "XtShotgun" 256
DropItem "Xt12Shell" 32, 4
DropItem "XtSMedikit" 8
Obituary "$OB_CORPORAL"

var int user_xraise;

States
	{
	Spawn:
		PLA3 A 1 NoDelay A_LookEx (0, 0, 0, 0, 0, "Chase")
		Loop
	Chase:
		TNT1 A 0 A_SpawnItemEx ("XtZombieStep", 10, 10, 15)
		PLA3 AA 2 A_Chase ("", "")
		PLA3 AA 2 A_Chase ("", "Missile")
		PLA3 BB 2 A_Chase ("", "")
		PLA3 BB 2 A_Chase ("", "Missile")
		TNT1 A 0 A_SpawnItemEx ("XtZombieStep", 0, 0, 15)
		PLA3 CC 2 A_Chase ("", "")
		PLA3 CC 2 A_Chase ("", "Missile")
		PLA3 DD 2 A_Chase ("", "")
		PLA3 DD 2 A_Chase ("", "Missile")
		Loop
	Missile:
		PLA3 E 10 A_FaceTarget (90, 180, FRandom(-24, 24), FRandom(-24, 24), FAF_MIDDLE)
		PLA3 E 3 Bright A_FaceTarget (90, 180, FRandom(-24, 24), FRandom(-24, 24), FAF_MIDDLE)
		TNT1 A 0 A_PlaySound ("weapons/shotgf", CHAN_WEAPON, 1, 0)
		TNT1 A 0 A_ChangeVelocity (Cos(Pitch)*-1, 0, Sin(Pitch)*1, 1)
		TNT1 AAAAAAAAA 0 A_CustomMissile ("XtShotgunShooter", 33, 9, FRandom(-4.5, 4.5), CMF_TRACKOWNER|CMF_OFFSETPITCH, FRandom(-4.5, 4.5))
		PLA3 F 7 Bright A_FaceTarget (90, 180, FRandom(-24, 24), FRandom(-24, 24), FAF_MIDDLE)
		TNT1 A 0 A_ChangeFlag ("NOPAIN", 1)
		TNT1 A 0 A_PlaySound ("weapons/shotgr", CHAN_6, 1, 0)
		PLA3 AAA 10 A_FaceTarget (90, 180, FRandom(-24, 24), FRandom(-24, 24), FAF_MIDDLE)
		PLA3 A 4 A_FaceTarget (90, 180, FRandom(-24, 24), FRandom(-24, 24), FAF_MIDDLE)
		TNT1 A 0 A_ChangeFlag ("NOPAIN", 0)
		Goto Chase
	Pain:
		PLA3 G 3
		PLA3 G 3 A_Pain
		Goto Chase
	Death:
		PLA3 H 5
		PLA3 I 5 A_Scream
		PLA3 J 5 A_NoBlocking
		PLA3 K 5
		TNT1 A 0 A_SpawnItemEx ("XtLightBodyFall", 0, 0, 15)
		PLA3 LM 5
		PLA3 N -1
		Stop
	XDeath:
		TNT1 A 0 A_SetUserVar ("user_xraise", 1)
		PLA3 O 5
		PLA3 P 5 A_XScream
		PLA3 Q 5 A_NoBlocking
		PLA3 RSTUV 5
		PLA3 W -1
		Stop
	Raise:
		TNT1 A 0 A_JumpIf (user_xraise == 1, "XRaise")
		PLA3 MLKJIH 5
		Goto Spawn
	XRaise:
		TNT1 A 0 A_SetUserVar ("user_xraise", 0)
		PLA3 VUTSRQPO 5
		Goto Spawn
	}
}
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: A_FaceTarget Angel and pitch offsets

Post by wildweasel »

A_FaceTarget doesn't affect attack aiming, last I recall. You'll need to find some way to restrict aiming angle from the attack function itself.
User avatar
Caligari87
Admin
Posts: 6241
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: A_FaceTarget Angel and pitch offsets

Post by Caligari87 »

That's correct. I did the same in a mod of mine, and you have to set the proper flags for A_CustomMissile to use the absolute actor angle. Here's an example of what worked for my Shotgun Guy.

Code: Select all

Missile:
	SPOS E 10 A_FaceTarget(0,0)
	TNT1 A 0 A_SetAngle(angle+frandom(-7,7))
	TNT1 A 0 A_SetPitch(pitch+frandom(-7,7))
	TNT1 AAAAAAAAA 0 A_CustomMissile("00Buck_Pellet",32,0,angle+frandom(-1.0,1.0),CMF_ABSOLUTEPITCH|CMF_ABSOLUTEANGLE,pitch+frandom(-1.0,1.0))
	SPOS F 10 Bright A_PlaySound("ShotgunFire")
	SPOS E 10
	Goto See
It uses A_FaceTarget to look at the player (note the arguments for both pitch and angle), then A_SetAngle and A_SetPitch to offset that look, then A_CustomMissile repeated the desired number of times to shoot at the exact angle the actor is looking, offset by the desired shotgun spread (in this case, +/- 1 degree).

8-)
User avatar
Xtyfe
Posts: 1490
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: A_FaceTarget Angel and pitch offsets

Post by Xtyfe »

Ahh I see, so it takes some trickery. Thank you for the example it will be useful
Locked

Return to “Editing (Archive)”