## Micromod: Crosshair Accurate Weapon Firing 1.3

Projects that alter game functions but do not include new maps belong here.
Forum rules

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

### Micromod: Crosshair Accurate Weapon Firing 1.3

Inspired by the brilliant work of m8f on his Precise Crosshair mod I decided to write a simple function that dynamically adjusts weapons' projectile firing functions' pitch and angle to make it so that projectiles and hitscans always hit the crosshair.
From my testing everything seem to work as intended so I am releasing an example pk3 for modders

All the firing functions examples are in ZScript.QCD

Code: Select all
`Changelog 1.3:- better procedure;- added an example pk3 to be used with QC:DE.Changelog 1.2:- simplified angle/pitch calculation code (VectorAngle duh!);- fixed an issue where depending on the pitch at which you fired a non hitscan projectile it would warp to a different location after impacting with a solid surface. (I would very much love to record a video of what I mean but I am not going to be on my main computer for a few days)Changelog 1.1:It has been kindly brought to my attention that it is better to make the function calculating Angle and Pitch an Action, so the code has been slightly tweaked to make it work that way.I think it looks nicer and more compact`

STEPS FOR MOD IMPLEMENTATION:
Spoiler:

The way it works is quite simple, a line tracer (a non damaging hit scan attack of sort) is fired at your viewheight and is used to return the distance it traveled.
This distance represents the projection of the crosshair onto the map geometry.
Then basic trigonometry is used to determine which are the angle and pitch necessary to make the fired projectile travel toward the point of impact from the XY and Z offset you make it spawn at.

Here is a basic demonstration of it applied to a few of QC:DE's weapons I edited to use it.
Last edited by Ivory Duke on Thu Feb 13, 2020 9:49 am, edited 4 times in total.

Ivory Duke
Not an actual duke

Joined: 17 Jun 2019

### Re: Micromod: Accurate to Crosshair Weapon Firing 1.1

1.1 update, no functional change. Just been told this way is better

Ivory Duke
Not an actual duke

Joined: 17 Jun 2019

### Re: Micromod: Crosshair Accurate Weapon Firing 1.2

1.2, now non hitscan projectiles are always accurate at all firing pitches

Ivory Duke
Not an actual duke

Joined: 17 Jun 2019

### Re: Micromod: Crosshair Accurate Weapon Firing 1.3

1.3 now with a playable example

Ivory Duke
Not an actual duke

Joined: 17 Jun 2019