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!)
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:
Actor DSR1Scope: Weapon
{
Obituary "%o was Picked-Off By %k's DSR-1."
Weapon.Kickback 125
Weapon.Ammotype1 "DSR1Loaded"
Weapon.Ammotype2 "338Lapua"
Weapon.Ammouse 1
Weapon.Ammouse2 0
Weapon.Ammogive1 0
Decal "BulletChip"
+NOAUTOFIRE
+DONTBOB
+NOALERT
+UNDROPPABLE
States
{
Spawn:
XXXX X -1
Loop
Ready:
ASCO A 0
ASCO A 2 A_WeaponReady
ASCO A 0 A_TakeInventory("DSRToken2",1)
Loop
Deselect:
ASCO A 0
ASCO A 0
Goto AltFire+2
Select:
ASCO A 0 A_PlaySound("DSROPTIC", CHAN_5)
ASCO A 0 A_ZoomFactor(8)
ASCO A 0 A_Raise
Loop
Fire:
ASCO B 0 A_JumpIfNoAmmo("Reload")
ASCO B 0 A_AlertMonsters
ASCO B 0 A_PlayWeaponSound("DSR1FIRE")
ASCO B 2 A_FireProjectile("308TracerP", FRandom(-0.0001, 0.0001), true, 0.0001, 0.001, 0.0001, FRandom(-1, 0.0001)) <--- This seems to be broken, don't know how to make it shoot straight.
ASCO B 0 A_Quake (2, 2, 0, 1)
ASCO A 0 A_SetPitch (pitch-0.5)
ASCO A 4
ASCO A 1 Offset(0,35) A_PlaySound("DSR1BOLT", CHAN_5)
ASCO A 1 Offset(0,38)
ASCO A 1 Offset(0,44)
ASCO A 1 Offset(0,52)
ASCO A 1 Offset(-1,54)
ASCO A 1 Offset(-2,56)
ASCO A 1 Offset(-3,58)
ASCO A 1 Offset(-3,59)
ASCO A 1 Offset(-3,63)
ASCO A 0 A_spawnitemex ("45Casing", 20, 10, 10, random(4,6), random(4,8), random(4,9), 0)
ASCO A 1 Offset(-3,63)
ASCO A 1 Offset(-3,65)
ASCO A 1 Offset(-3,64)
ASCO A 1 Offset(-3,62)
ASCO A 1 Offset(-3,60)
ASCO A 1 Offset(-3,58)
ASCO A 1 Offset(-3,55)
ASCO A 1 Offset(-2,53)
ASCO A 1 Offset(-2,49)
ASCO A 1 Offset(-2,46)
ASCO A 1 Offset(-2,45)
ASCO A 1 Offset(-1,44)
ASCO A 1 Offset(0,46)
ASCO A 1 Offset(0,44)
ASCO A 1 Offset(0,38)
ASCO A 1 Offset(0,35)
ASCO A 1 Offset(0,32)
ASCO A 1 Offset(0,31)
ASCO A 1 Offset(0,30)
ASCO A 1 Offset(0,29)
ASCO A 1 Offset(0,28)
ASCO A 1 Offset(0,26)
Goto Ready
AltFire:
ASCO A 0 A_JumpIfNoAmmo("Reload")
ASCO A 0 A_PlaySound("DSROPTIC", CHAN_5)
ASCO A 0 A_JumpIfInventory("DSRToken2",1,"Ready")
Goto AltFireDeselect
AltFire2:
ASCO A 0 A_ZoomFactor(8)
ASCO A 0 A_GiveInventory("DSRToken3")
Goto Ready
AltFireDeselect:
ASCO A 0 A_TakeInventory("DSRToken3")
ASCO A 0 A_TakeInventory("DSRToken3")
ASCO A 0 A_GiveInventory("DSRToken1")
ASCO A 0 A_GiveInventory("DSRToken2")
ASCO A 0 A_PlaySound("DSROPTIC", CHAN_5)
ASCO A 0 A_ZoomFactor(8)
ASCO A 0 A_SelectWeapon("DSR1")
ASCO A 0 A_Lower
ASCO A 0 A_Lower
ASCO A 0 A_Lower
ASCO A 0 A_Lower
ASCO A 0 A_Lower
Goto AltfireDeselect+7
}
}
ACTOR DSRToken1 : Ammo
{
Inventory.MaxAmount 1
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 1
}
ACTOR DSRToken2 : Ammo
{
Inventory.MaxAmount 1
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 1
}
ACTOR DSRToken3 : Ammo
{
Inventory.MaxAmount 2
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 2
}
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:
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.