A_CustomMissile flags
Moderator: GZDoom Developers
A_CustomMissile flags
New flags for A_CustomMissile:
CMF_ABSOLUTEPITCH
Use the pitch parameter as absolute pitch.
Implied by CMF_AIMDIRECTION. (Pitch is absolute)
Does not imply CMF_AIMDIRECTION. (Target is required, xy-direction is set by normal aim)
CMF_OFFSETPITCH
Calculate aim normally.
Adjust the aim (pitch) according to the pitch parameter.
CMF_AIMDIRECTION (not new)
Fire straight ahead (base pitch = 0), offset by the angle parameter. Requires no target. Implies CMF_ABSOLUTEPITCH and handles the pitch parameter accordingly.
CMF_SAVEPITCH
If absolutepitch of offsetpitch was specified/implied, this flag causes the actual pitch (based on velocity) to be saved in the missile's pitch property. If the pitch parameter has not been used to calculate missile velocity, the parameter's value is assigned to the pitch property.
CMF_ABSOLUTEANGLE
Override the angle of the shot (not affecting pitch), using the angle as an absolute value (not relative to the firing actor). Pass the angle of the actor as part of the parameter to create a relative offset.
Example calls:
A_CustomMissile("Something", 32, 0, angle + random(-10,10), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-1,10))
Fire something, requiring a target.
XY-aim: None, use absolute angle. Caller angle + a value ranging from -10 to 10.
Z-aim: Aim + a value ranging from -1 (lower by 1 degree) to 10 (raise by 10 degrees).
Savepitch: Saves the resultant pitch (angle) in the pitch property
A_CustomMissile("Something", 32, 0,0, CMF_SAVEPITCH, random(0,99))
Fire something, requiring a target.
Aim: All normal
Savepitch: Assign a random value from 0 to 99 to the pitch property.
A_CustomMissile("Something", 32, 0,angle, CMF_ABSOLUTEANGLE | CMF_ABSOLUTEPITCH, 45)
Fire something, requiring a target.
Aim: All absolute (using angle parameter to align with caller)
Savepitch: No
A_CustomMissile("Something", 32, 0,0, CMF_AIMDIRECTION | CMF_SAVEPITCH, 45)
Fire something, not requiring a target
Aim: Absolute pitch, otherwise aligned with caller.
Savepitch: 45 is saved
CMF_ABSOLUTEPITCH
Use the pitch parameter as absolute pitch.
Implied by CMF_AIMDIRECTION. (Pitch is absolute)
Does not imply CMF_AIMDIRECTION. (Target is required, xy-direction is set by normal aim)
CMF_OFFSETPITCH
Calculate aim normally.
Adjust the aim (pitch) according to the pitch parameter.
CMF_AIMDIRECTION (not new)
Fire straight ahead (base pitch = 0), offset by the angle parameter. Requires no target. Implies CMF_ABSOLUTEPITCH and handles the pitch parameter accordingly.
CMF_SAVEPITCH
If absolutepitch of offsetpitch was specified/implied, this flag causes the actual pitch (based on velocity) to be saved in the missile's pitch property. If the pitch parameter has not been used to calculate missile velocity, the parameter's value is assigned to the pitch property.
CMF_ABSOLUTEANGLE
Override the angle of the shot (not affecting pitch), using the angle as an absolute value (not relative to the firing actor). Pass the angle of the actor as part of the parameter to create a relative offset.
Example calls:
A_CustomMissile("Something", 32, 0, angle + random(-10,10), CMF_ABSOLUTEANGLE | CMF_OFFSETPITCH | CMF_SAVEPITCH, random(-1,10))
Fire something, requiring a target.
XY-aim: None, use absolute angle. Caller angle + a value ranging from -10 to 10.
Z-aim: Aim + a value ranging from -1 (lower by 1 degree) to 10 (raise by 10 degrees).
Savepitch: Saves the resultant pitch (angle) in the pitch property
A_CustomMissile("Something", 32, 0,0, CMF_SAVEPITCH, random(0,99))
Fire something, requiring a target.
Aim: All normal
Savepitch: Assign a random value from 0 to 99 to the pitch property.
A_CustomMissile("Something", 32, 0,angle, CMF_ABSOLUTEANGLE | CMF_ABSOLUTEPITCH, 45)
Fire something, requiring a target.
Aim: All absolute (using angle parameter to align with caller)
Savepitch: No
A_CustomMissile("Something", 32, 0,0, CMF_AIMDIRECTION | CMF_SAVEPITCH, 45)
Fire something, not requiring a target
Aim: Absolute pitch, otherwise aligned with caller.
Savepitch: 45 is saved
- Attachments
-
- A_CustomMissile.txt
- (3.44 KiB) Downloaded 77 times
- Major Cooke
- Posts: 8209
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: A_CustomMissile flags
Looks interesting enough. I might give this a shot later.
- Major Cooke
- Posts: 8209
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: A_CustomMissile flags
So I've been thinking about this... I really like all the current pitch ideas, so I was wondering...
Would it be possible to include a flag for A_FireCustomMissile to transfer the pitch of the player to the projectile? I've tried everything with that but I've been forced to conclude that if I want to spawn things with pitch involved, I'd have to use this instead:
Simply put, that's a long-ass formula that, while works, I can't help but get a feeling is a little shaky. Unfortunately, even with specifying +NOAUTOAIM the wiki clearly states there is no turning off vertical auto-aim.
Does this allow the missile to save pitch in the means that you can use things such as A_SetPitch properly, and/or allow objects to spawn from the projectile using A_SpawnItemEx with the flag SXF_TRANSFERPITCH?
I ask because the code above allows me to make laser-like projectiles such as this:
The A_Warp and A_SpawnItemEx both rely upon pitch being there, and unfortunately I just can't seem to make it work with A_FireCustomMissile. 
Would it be possible to include a flag for A_FireCustomMissile to transfer the pitch of the player to the projectile? I've tried everything with that but I've been forced to conclude that if I want to spawn things with pitch involved, I'd have to use this instead:
Code: Select all
TNT1 A 0 A_SpawnItemEx("JetsonProjectile",cos(-pitch)*10,12,1+(sin(-pitch)*32),cos(-pitch)*10,0,sin(-pitch)*10,0,32|SXF_TRANSFERPITCH)
Does this allow the missile to save pitch in the means that you can use things such as A_SetPitch properly, and/or allow objects to spawn from the projectile using A_SpawnItemEx with the flag SXF_TRANSFERPITCH?
I ask because the code above allows me to make laser-like projectiles such as this:
Code: Select all
ACTOR JetsonProjectile
{
var int user_limit;
+THRUACTORS
+NOGRAVITY
+SKYEXPLODE
Radius 2
Height 2
Speed 10
Projectile
DeathSound "Jetson/Explosion"
Translation "0:255=%[0,0,0]:[0.5,0.8,1.0]"
States
{
Spawn:
MISL A 1 Bright
Moving:
TNT1 A 0 A_SetUserVar("user_limit",user_limit+1)
TNT1 A 0 A_JumpIf(user_limit>=4000,"End")
TNT1 A 0 A_SpawnItemEx("JetsonParticle",(sin(-pitch)*random(-5,5)),frandom(-2,2),frandom(-2,2),0,0,frandom(0,0.2),0,32)
TNT1 A 0 A_Warp(AAPTR_DEFAULT,cos(-pitch)*2,0,sin(-pitch)*2,0,0,"Moving2")
Goto Death
Moving2: //Meant to reduce density of particles. Works perfectly.
TNT1 A 0 A_SetUserVar("user_limit",user_limit+1)
TNT1 A 0 A_JumpIf(user_limit>=4000,"End")
TNT1 A 0 A_Warp(AAPTR_DEFAULT,cos(-pitch)*2,0,sin(-pitch)*2,0,0,"Moving")
Death:
TNT1 A 1 A_SpawnItemEx("JetsonBomb",0,0,0,0,0,0,0,32|SXF_TRANSFERTRANSLATION|SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
Stop
End:
TNT1 A 0
Stop
}
}

Re: A_CustomMissile flags
Either that, or A_SetPitch(float pitch[, int flags])
Flags
PITCH_MODIFY: Add to existing pitch (same as A_SetPitch(pitch + modification)).
PITCH_CALCULATE: Add to calculated pitch (uses actual velocities to determine pitch).
The advantage of having A_SetPitch do it, is that you don't need pitch updates from every function that is capable of setting missile velocity (such as A_SeekerMissile). The advantage of having it everywhere else is that the call that causes the pitch change can perform the variable update without a dedicated decorate frame. Of course, if it were to be "everywhere", A_ChangeVelocity would require a flag for it as well.
Having it available for the CustomMissile and FireCustomMissile calls seems reasonable.
Flags
PITCH_MODIFY: Add to existing pitch (same as A_SetPitch(pitch + modification)).
PITCH_CALCULATE: Add to calculated pitch (uses actual velocities to determine pitch).
The advantage of having A_SetPitch do it, is that you don't need pitch updates from every function that is capable of setting missile velocity (such as A_SeekerMissile). The advantage of having it everywhere else is that the call that causes the pitch change can perform the variable update without a dedicated decorate frame. Of course, if it were to be "everywhere", A_ChangeVelocity would require a flag for it as well.
Having it available for the CustomMissile and FireCustomMissile calls seems reasonable.
- Major Cooke
- Posts: 8209
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: A_CustomMissile flags
That would be extremely helpful if you could do those. If you do manage to set up the A_SetPitch, I wonder how would the PITCH_CALCULATE be used then...
And also, wouldn't A_ScaleVelocity need modifying to check and see if it's using pitch for velocities?
I'll wait to see if you do it first, otherwise I'm derailing the topic.
And also, wouldn't A_ScaleVelocity need modifying to check and see if it's using pitch for velocities?
I'll wait to see if you do it first, otherwise I'm derailing the topic.
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: A_CustomMissile flags
That would be fantastic, yes. (Unfortunately, someone got it into his head that Pitch isn't useful anywhere.Major Cooke wrote:Would it be possible to include a flag for A_FireCustomMissile to transfer the pitch of the player to the projectile?

- Major Cooke
- Posts: 8209
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: A_CustomMissile flags
Uh... Me? I find pitch to be useful in a lot of things.
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: A_CustomMissile flags
No.Major Cooke wrote:Uh... Me?
As do I.Major Cooke wrote:I find pitch to be useful in a lot of things.
Re: A_CustomMissile flags
A_SetPitch with PITCH_CALCULATE would work as follows:
A_SetPitch(0, PITCH_CALCULATE): Calculate the pitch based on current velocity, and save that as the pitch property.
A_SetPitch(10, PITCH_CALCULATE): Calculate the pitch based on current velocity, and save that + 10 degrees as the pitch property.
Sometimes this might not be enough. This works when you need to recalculate your velocuty-based pitch info based on any of several events that can happen to an actor during its lifetime.
The velocity might not always have the pitch you want to know about, of course. A_SetPitch might not actually cover all needs, especially not after A_FireCustomMissile, with autoaims and the lots. I'll think about flags for a possible added parameter.
A_SetPitch(0, PITCH_CALCULATE): Calculate the pitch based on current velocity, and save that as the pitch property.
A_SetPitch(10, PITCH_CALCULATE): Calculate the pitch based on current velocity, and save that + 10 degrees as the pitch property.
Sometimes this might not be enough. This works when you need to recalculate your velocuty-based pitch info based on any of several events that can happen to an actor during its lifetime.
The velocity might not always have the pitch you want to know about, of course. A_SetPitch might not actually cover all needs, especially not after A_FireCustomMissile, with autoaims and the lots. I'll think about flags for a possible added parameter.
- Major Cooke
- Posts: 8209
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: A_CustomMissile flags
Well, I'm definitely hoping to see it. What I'm mainly concerned about is just changing, say, a missile's trajectory using A_SetPitch and A_SetAngle. I figure it will still have to call A_ChangeVelocity in a method like this:
Spoiler:
- 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_CustomMissile flags
Bumping for great justice... And with hopes that it will added soon even though I know it wont help 

- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: A_CustomMissile flags
At the moment the priority is to get a new version out, not to add new features.
And bumping for bump's sake won't make it go faster.
And bumping for bump's sake won't make it go faster.
- 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_CustomMissile flags
Worth a shot 

- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: A_CustomMissile flags
Ok, this doesn't look too intrusive so I guess it's safe to be added.
- 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_CustomMissile flags
Yep, I just creamed my pantsGraf Zahl wrote:Ok, this doesn't look too intrusive so I guess it's safe to be added.