Projectiles don't inherit pitch?

Discuss all aspects related to modding Zandronum here.
User avatar
Ænima
Addicted to Zandronum
Posts: 3583
Joined: Tue Jun 05, 2012 6:12 pm

Projectiles don't inherit pitch?

#1

Post by Ænima » Thu Jan 30, 2014 7:10 pm

For some reason, when a projectile is spawned it inherits its angle from it's firer, but not its pitch. This usually isn't a problem since you can't see an actors' pitch from their sprites anyways, but when you try to make 3D models for atypical projectiles, they always spawn with a centered pitch.

PITCHFROMMOMENTUM is not what I want. All that does is change the model's pitch based on what direction it's moving in the most. It doesn't reflect the actor's actual pitch. For example, let's say I want to make something like a torpedo that can strafe up/down/left/right in midair but always point in the direction you fired it in. PITCHFROMMOMENTUM would make the torpedo point all over the place, even if the actor was looking straight ahead the whole time. And this is what INHERITACTORPITCH is supposed to be useful for.

Buuuuut apperantly projectiles are always spawned with Pitch 0, regardless of what their firer's pitch is. And what i'm trying to do (3D projectiles and trails) looks like poop because of this.
Last edited by Ænima on Thu Jan 30, 2014 7:12 pm, edited 1 time in total.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

ZzZombo
Forum Regular
Posts: 323
Joined: Mon Jun 11, 2012 12:11 pm
Location: Ravenholm

RE: Projectiles don't inherit pitch?

#2

Post by ZzZombo » Sun Feb 02, 2014 5:42 am

Just set it accordingly, using -pitch in some parameter (IDK what function to spawn them do you use).
QZRcon - Qt-based tool for Zandronum/Skulltag servers!
#grandvoid funny stats

scroton
 
Posts: 63
Joined: Mon Aug 26, 2013 3:33 am

RE: Projectiles don't inherit pitch?

#3

Post by scroton » Mon Mar 03, 2014 2:06 am

Yeah, pitch doesn't inherit for any monster projectiles. I tried various ways to get around that to get true 3d fractals in monster projectiles in Fractal Doom but eventually had to settle for horizontally fractal monster projectiles, and even those were a hacky solution with projectiles that were fired at the same time as the other projectiles with the needed angles to intercept other projectiles but were +NOCLIP and +THRUACTORS and invisible until being "fired" by another projectile.

To get monster projectiles to have correct pitch you would need to have the arcsin function to set it via a_setpitch, which you don't in decorate or acs. I asked randy about it a while ago here: http://forum.zdoom.org/viewtopic.php?f= ... 6&p=690257

Since you're using it just for appearances and not to spawn anything else, I've heard A_SetPitch (sin(momz)/cos(momx)) being bandied about; it isn't at all accurate enough to spawn stuff with but might look better than the A_SetPitch(momz*2) you're using. No idea which will be better though.

If you're using this for player fired projectile , then this is an entirely different matter and you can definitely get the exact correct pitch for the trail actors. Instead of firing the initial projectile with A_FireCustomMissile fire it using

A_SpawnItemEx (<type>,cos(-pitch-[desired pitch offset--probably 0])*<Dist. from spawner>,<yoffset>,<zoffset>+(sin(-pitch-[desired pitch offset--probably 0])*<Dist. from spawner>),cos(-pitch[desired pitch offset--probably 0])*<Projectile speed>,0,sin(-pitch[desired pitch offset--probably 0])*<Projectile speed>,<angle>,SXF_TRANSFERPITCH|<other flags>,<chance>)

and then spawn the trail actors using the same formula albiet with the speed at 0.

ZzZombo
Forum Regular
Posts: 323
Joined: Mon Jun 11, 2012 12:11 pm
Location: Ravenholm

RE: Projectiles don't inherit pitch?

#4

Post by ZzZombo » Mon Mar 03, 2014 8:00 am

A_SpawnItem() shouldn't ever be used for projectile spawning. Besides why can't you just use "-pitch" in the pitch parameter of A_CustomMissile()?
QZRcon - Qt-based tool for Zandronum/Skulltag servers!
#grandvoid funny stats

scroton
 
Posts: 63
Joined: Mon Aug 26, 2013 3:33 am

RE: Projectiles don't inherit pitch?

#5

Post by scroton » Mon Mar 03, 2014 8:21 am

ZzZombo wrote: A_SpawnItem() shouldn't ever be used for projectile spawning.

I don't understand; assuming you mean a_spawnitemex, it's great for player projectiles and does lots of stuff that can't be done otherwise.
ZzZombo wrote: Besides why can't you just use "-pitch" in the pitch parameter of A_CustomMissile()?
None of the flags for A_CustomMissile will transfer an aimed pitch or the firing actor's pitch.

ZzZombo
Forum Regular
Posts: 323
Joined: Mon Jun 11, 2012 12:11 pm
Location: Ravenholm

RE: Projectiles don't inherit pitch?

#6

Post by ZzZombo » Mon Mar 03, 2014 8:24 am

[quote=http://zdoom.org/wiki/A_CustomMissile]CMF_AIMDIRECTION
The missile is not aimed at a target. Instead, it is shot in the specified direction with the specified pitch. This is the same as putting 2 into the aimflags parameter.[/quote]What?
Last edited by ZzZombo on Mon Mar 03, 2014 8:24 am, edited 1 time in total.
QZRcon - Qt-based tool for Zandronum/Skulltag servers!
#grandvoid funny stats

Klofkac
Forum Regular
Posts: 481
Joined: Sat Jun 09, 2012 1:31 pm
Location: Ask Grandvoid servers

RE: Projectiles don't inherit pitch?

#7

Post by Klofkac » Mon Mar 03, 2014 8:26 am

Are you sure this flag exists for ZDoom 2.5.0, or even better 2.3.1 so it can be used in Zandronum? You know that Zandronum is several years late.
𝕂𝕝𝕠𝕗𝕜𝕒𝕔

ZzZombo
Forum Regular
Posts: 323
Joined: Mon Jun 11, 2012 12:11 pm
Location: Ravenholm

RE: Projectiles don't inherit pitch?

#8

Post by ZzZombo » Mon Mar 03, 2014 8:29 am

Damn, why the fuck you think I would came here if I didn't know for sure it works?

Regarding the A_SpawnItemEx() used to spawn projectiles there even was a response from Torr Samaho clearly saying it wasn't designed with spawning of projectiles in mind.
QZRcon - Qt-based tool for Zandronum/Skulltag servers!
#grandvoid funny stats

scroton
 
Posts: 63
Joined: Mon Aug 26, 2013 3:33 am

RE: Projectiles don't inherit pitch?

#9

Post by scroton » Mon Mar 03, 2014 8:31 am

ZzZombo wrote:
http://zdoom.org/wiki/A_CustomMissile wrote:CMF_AIMDIRECTION
The missile is not aimed at a target. Instead, it is shot in the specified direction with the specified pitch. This is the same as putting 2 into the aimflags parameter.
What?
Even if you put "pitch" in A_CustomMissile and use that flag to use the firing actor's pitch it will not work because a monster's pitch is always 0, and so the pitch transferred to the projectile is 0.

Likewise if you use A_CustomMissile to fire a projectile from a projectile fired from a monster, it's still going to have a pitch of 0. So it will transfer that pitch of 0.

ZzZombo
Forum Regular
Posts: 323
Joined: Mon Jun 11, 2012 12:11 pm
Location: Ravenholm

RE: Projectiles don't inherit pitch?

#10

Post by ZzZombo » Mon Mar 03, 2014 8:35 am

Okay, to clarify, I was thinking only about players when posting this.
QZRcon - Qt-based tool for Zandronum/Skulltag servers!
#grandvoid funny stats

scroton
 
Posts: 63
Joined: Mon Aug 26, 2013 3:33 am

RE: Projectiles don't inherit pitch?

#11

Post by scroton » Mon Mar 03, 2014 8:41 am

ZzZombo wrote: Okay, to clarify, I was thinking only about players when posting this.
But A_CustomMissile is a monster attack though.

ZzZombo
Forum Regular
Posts: 323
Joined: Mon Jun 11, 2012 12:11 pm
Location: Ravenholm

RE: Projectiles don't inherit pitch?

#12

Post by ZzZombo » Mon Mar 03, 2014 9:12 am

No. It works for players just as good. Since you yourself pointed out monsters have their pitch zeroed otherwise the pitch parameter and related flags would be useless.
QZRcon - Qt-based tool for Zandronum/Skulltag servers!
#grandvoid funny stats

scroton
 
Posts: 63
Joined: Mon Aug 26, 2013 3:33 am

RE: Projectiles don't inherit pitch?

#13

Post by scroton » Mon Mar 03, 2014 9:40 am

ZzZombo wrote: No. It works for players just as good.
It doesn't work for players correctly. Try the replacement shotgun in this test wad which has the following decorate:
Spoiler: Decorate (Open)
ACTOR TestShotgun : DoomWeapon 2001
{
Weapon.SelectionOrder 1
Weapon.SlotNumber 3
Weapon.AmmoUse 0
Weapon.AmmoGive 8
Weapon.AmmoType "Shell"
Inventory.PickupMessage "$GOTSHOTGUN"
Obituary "$OB_MPSHOTGUN"
Tag "$TAG_SHOTGUN"
States
{
Ready:
SHTG A 1 A_WeaponReady
Loop
Deselect:
SHTG A 1 A_Lower
Loop
Select:
SHTG A 1 A_Raise
Loop
Fire:
SHTG A 3
SHTG A 7 A_CustomMissile("DoomImpBall")
SHTG BC 5
SHTG D 4
SHTG CB 5
SHTG A 3
SHTG A 7 A_ReFire
Goto Ready
Flash:
SHTF A 4 Bright A_Light1
SHTF B 3 Bright A_Light2
Goto LightDone
Spawn:
SHOT A -1
Stop
}
}

Or this other test wad which has the following decorate:
Spoiler: Decorate (Open)
ACTOR TestShotgun : DoomWeapon 2001
{
Weapon.SelectionOrder 1
Weapon.SlotNumber 3
Weapon.AmmoUse 0
Weapon.AmmoGive 8
Weapon.AmmoType "Shell"
Inventory.PickupMessage "$GOTSHOTGUN"
Obituary "$OB_MPSHOTGUN"
Tag "$TAG_SHOTGUN"
States
{
Ready:
SHTG A 1 A_WeaponReady
Loop
Deselect:
SHTG A 1 A_Lower
Loop
Select:
SHTG A 1 A_Raise
Loop
Fire:
SHTG A 3
SHTG A 7 A_CustomMissile("DoomImpBall",32,0,0,CMF_AIMDIRECTION,pitch)
SHTG BC 5
SHTG D 4
SHTG CB 5
SHTG A 3
SHTG A 7 A_ReFire
Goto Ready
Flash:
SHTF A 4 Bright A_Light1
SHTF B 3 Bright A_Light2
Goto LightDone
Spawn:
SHOT A -1
Stop
}
}
ZzZombo wrote: Since you yourself pointed out monsters have their pitch zeroed otherwise the pitch parameter and related flags would be useless.
That flag is used to specify an absolute pitch, which replaces the aimed pitch.
ZzZombo wrote:
http://zdoom.org/wiki/A_CustomMissile wrote:CMF_AIMDIRECTION
The missile is not aimed at a target. Instead, it is shot in the specified direction with the specified pitch. This is the same as putting 2 into the aimflags parameter.
What?

XutaWoo
Forum Regular
Posts: 113
Joined: Mon Jun 04, 2012 7:04 am

RE: Projectiles don't inherit pitch?

#14

Post by XutaWoo » Tue Apr 01, 2014 4:59 am

A_SpawnItemEx may not have been designed for projectiles in mind, but unless Zandronum's developers have been intentionally avoiding adding changes from ZDoom, that's been changed. Projectiles correctly assign their target field to their firer, and that's basically all that's needed for a projectile to function.

Granted, you have to pull off some tricks so that it works with crouching and stuff, but it still works perfectly fine otherwise.
[spoiler]Image[/spoiler]
Image

Lollipop
Zandrone
Posts: 1124
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

RE: Projectiles don't inherit pitch?

#15

Post by Lollipop » Tue Apr 01, 2014 5:57 am

of course the monters attack function for firing missiles will not work when used in a weapons DECORATE, when it is not properly supported for weapon actors ;_;

for weapons, use this for projectiles (obvious)
http://zdoom.org/wiki/A_FireCustomMissile

for monsters it does not matter, you do not have to keep track of kill, frags or the like, only thing you have to make sure of is that you can proberly imitate the behaviour of the monsters projectile attack functionality.
Combinebobnt wrote:i can see the forum league is taking off much better than the ctf ones
GalactusToday at 1:07 PM
are you getting uncomfortable jap
feeling something happen down there

User avatar
Dark-Assassin
Maintenence Crew
Posts: 968
Joined: Fri May 25, 2012 4:25 am

RE: Projectiles don't inherit pitch?

#16

Post by Dark-Assassin » Tue Apr 01, 2014 6:13 am

Code: Select all

A_CustomMissile("YourChildProjectile",0,0,0,CMF_TRACKOWNER|CMF_AIMDIRECTION,(momz*6))
This will spawn a child projectile inheriting the pitch of the parent projectile.
Took me ages to find this out for one of my test projects.

To have it fire in different directions, you need to edit the 4th argument and append to the 6th one after the first bracket. It will take some getting used to.
For Reference: http://zdoom.org/wiki/A_CustomMissile
❗ Don't message me for technical or moderation support.
❔ Use the relevant support channels instead.

scroton
 
Posts: 63
Joined: Mon Aug 26, 2013 3:33 am

RE: Projectiles don't inherit pitch?

#17

Post by scroton » Tue Apr 01, 2014 9:28 pm

Lollipop wrote: of course the monters attack function for firing missiles will not work when used in a weapons DECORATE, when it is not properly supported for weapon actors ;_;

for weapons, use this for projectiles (obvious)
http://zdoom.org/wiki/A_FireCustomMissile

for monsters it does not matter, you do not have to keep track of kill, frags or the like, only thing you have to make sure of is that you can proberly imitate the behaviour of the monsters projectile attack functionality.
For player weapons a_spawnitemex is a lot better if you're looking to do anything with pitch or having it spawn other projectiles. To do what Ænima wants to do with projectiles you'll have to use it for a player weapon in this case.
-=Dark-Assassin=- wrote:

Code: Select all

A_CustomMissile("YourChildProjectile",0,0,0,CMF_TRACKOWNER|CMF_AIMDIRECTION,(momz*6))
This will spawn a child projectile inheriting the pitch of the parent projectile.
Took me ages to find this out for one of my test projects.

To have it fire in different directions, you need to edit the 4th argument and append to the 6th one after the first bracket. It will take some getting used to.
For Reference: http://zdoom.org/wiki/A_CustomMissile
That's basically the same thing Ænima's already doing with his A_setpitch(momz*2), or what I suggested with A_SetPitch (sin(momz)/cos(momx)), except with a different formula.

I have no idea which ends up being more accurate in the end, momz*6, momz*2, or sin(momz)/cos(momx), since none of them is actually the formula for getting a pitch, just an approximation.

I can graph them all later and see which most closely follows the actual pitch, but I have a sneaking suspicion that all will have a range in which they are more accurate than the others but none will be most accurate for the entire range. There is also probably a closer approximation that hasn't been listed yet, dunno what it is.

I suppose you could have jumps in decorate to have it use different pitch formulas depending upon what it's momz is, and that might be most accurate of all. I really wish arc functions were in decorate like other trig functions are. Of course since he's just using it for appearances it doesn't have to be 100% accurate.

Also, Ænima still hasn't said whether this is for monster or player projectiles, though I guess it's probably for monster projectiles.

scroton
 
Posts: 63
Joined: Mon Aug 26, 2013 3:33 am

RE: Projectiles don't inherit pitch?

#18

Post by scroton » Tue Apr 01, 2014 10:44 pm

So I went ahead and checked it pretty quickly (so I could be wrong, and testing is required) and here's what I found:

Don't use sin(momz)/cos(momx) to determine pitch. It's absolutely wrong. I should have checked it myself before passing on the info from another source.

While it isn't actually linear, the function of pitch where Pitch = arcsin(momz/projectile_speed) behaves pretty close to a linear function for any given speed. So close in fact that you could actually probably spawn other projectiles from monster projectiles that have their pitch set through the method I'm about to list and nobody would be able to tell the difference.

The function to determine what number to use to approximate the pitch is as follows: Q = (arcsin((x/2)/x)/(x/2)), or Q = 60/x, where x is the projectile speed.

That gets it really close, and it can be used easily with either A_SetPitch or A_CustomMissile as Dark Assassin listed.

For reference here is the result for projectile speeds 1-20:

Code: Select all

1       60
2       30
3       20
4       15
5       12
6       10
7       (60/70)
8       7.5
9       (20/3)
10       6
11       (60/11)
12       5
13       (60/13)
14       (30/7)
15       4
16       3.75
17       (60/17)
18       (10/3)
19       (60/19)
20       3

User avatar
Ænima
Addicted to Zandronum
Posts: 3583
Joined: Tue Jun 05, 2012 6:12 pm

RE: Projectiles don't inherit pitch?

#19

Post by Ænima » Tue Apr 01, 2014 11:44 pm

Ha. We need more nerds like Scroton to do our trig calculations for us. :p

Thanks! I never actually considered that speed affects it.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

User avatar
Dark-Assassin
Maintenence Crew
Posts: 968
Joined: Fri May 25, 2012 4:25 am

RE: Projectiles don't inherit pitch?

#20

Post by Dark-Assassin » Wed Apr 02, 2014 12:18 am

Neither did I.
Though, I did make it for a projectile with 10 speed.
This table would be handy. *saving*
❗ Don't message me for technical or moderation support.
❔ Use the relevant support channels instead.

Post Reply