Sniper Rifle projectiles shooting high. A_FireProjectile

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
User avatar
Graaicko
Posts: 531
Joined: Tue Jun 17, 2014 11:22 pm
Graphics Processor: nVidia (Legacy GZDoom)

Sniper Rifle projectiles shooting high. A_FireProjectile

Post by Graaicko »

So I made a kickass DSR-1 Sniper rifle, its bolt-action and was kind of a bitch to get working. But it works. except when using the scope, the projectiles are hitting high or the vertical accuracy is bugged and I can't seem to figure it out.
I am Using A_FireProjectile and it seems to be quite buggy at times. I have no Idea of the numbers it uses. I just made them all 0.001 for maximum precision.

Actor of the weapon in its 'scoped' mode.
Spoiler:
Jarewill
 
 
Posts: 1759
Joined: Sun Jul 21, 2019 8:54 am

Re: Sniper Rifle projectiles shooting high. A_FireProjectile

Post by Jarewill »

How exactly is it shooting too high? I would have expected it to shoot too low if anything, considering how Doom's weapons work.

Doom weapons don't shoot at the same level as the player camera is, they instead shoot lower.
If you want a projectile to fire exactly where the camera is looking, you would have to do something like this:

Code: Select all

A_FireProjectile("PlasmaBall", FRandom(-0.0001, 0.0001), 1, 0, 5, 0, FRandom(-0.0001, 0.0001))
Normal DoomPlayer fires at 36 units from it's feet, while the camera is at 41 units.
So setting the spawnheight to 5, should make the projectile fire where the camera is.

Edit: After looking through the code again, it turns out the pitch parameter is set to fire high:
It picks a random number between -1 and 0.0001, so that means that it will more often aim high than low.
FRandom(-1, 0.0001)) should be replaced with FRandom(-0.0001, 0.0001)) for it to work.
Post Reply

Return to “Scripting”