## [Resource | Code] Conical bullet spread! *UPDATED*

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

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.

Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

### [Resource | Code] Conical bullet spread! *UPDATED*

Here's a quick and dirty conical bullet spread example! Now it's been updated to correct the fixed point issue, so bullet patterns should no longer form bullseye patterns. Be sure to redownload the file!

Code: Select all

``````/*
** Formula works like this:
**		X = (Radius * Cos(Angle)) + Offset
**		Y = (Radius * Sin(Angle)) + Offset
**
**		Where Radius is the size of the circle you want to draw (can be
**		randomized), Angle is an angle between 0 and 360 (can be fixed or
**		random), and Offset is how offset the circle is from your crosshair.
**
**	NOTE: Two of these values must be identical between X and Y! Radius must be
**		  the same and angle must be the same! However, if you want elliptical
**		  bullet patterns, simply change the X or Y value to be larger or
**		  or smaller than the other.
**
**		  Weapons that make use of this MUST use the EXPLICITANGLE flag! Same
**		  goes for the equivalent monster function A_CustomBulletAttack.
**
**		  Conical spreads are a bit limited with weapons, since weapons do not
**		  have acces to user variables, but they do have access to arguments.
**		  There are problems relating to fixed point numbers and arguments, but
**		  a workaround exists by using the following formula:
**		  X = (((Radius * 10) * Cos(Angle)) * 0.1) + Offset
**		  Y = (((Radius * 10) * Sin(Angle)) * 0.1) + Offset
**
*/``````
Spoiler: Q&A
Spoiler: Known Issues
You do not have the required permissions to view the files attached to this post.
Last edited by Snarboo on Thu Jan 01, 2015 11:52 am, edited 4 times in total.
Nash

Posts: 17452
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

### Re: [Resource | Code] Conical bullet spread!

Looks like one of those mysterious alien pattern thingies you find in obscure places... =D
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

### Re: [Resource | Code] Conical bullet spread!

I MAY have done the math slightly wrong! :p But yeah, I recommend using floats for this so that doesn't happen.

Edit:
Actually wait, can arguments store floats?!
Nash

Posts: 17452
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

### Re: [Resource | Code] Conical bullet spread!

Also, and you may already know this but, this doesn't seem to respect player pitch... in OpenGL with an extreme view pitch, the cone doesn't work...
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

### Re: [Resource | Code] Conical bullet spread!

Yeah I've definitely screwed up the math somewhere! I'll look into it.
Enjay

Posts: 26537
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

### Re: [Resource | Code] Conical bullet spread!

Nash wrote:Also, and you may already know this but, this doesn't seem to respect player pitch... in OpenGL with an extreme view pitch, the cone doesn't work...
You're not running a build with this bug are you?

http://forum.drdteam.org/viewtopic.php?f=25&t=6492

That has now been fixed if you are.
Nash

Posts: 17452
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

### Re: [Resource | Code] Conical bullet spread!

Enjay: no, my screenshot is ZDoom and the software renderer. :D And the behaviour of this conical spread not working correctly with extreme view pitch is also on an old GZDoom build without pixelratio.

(I haven't updated to any of the new pixelratio builds yet)
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

### Re: [Resource | Code] Conical bullet spread!

The cone does get very skewed at greater pitches, but I'm not sure how to fix that if it can be fixed.
Enjay

Posts: 26537
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

### Re: [Resource | Code] Conical bullet spread!

Nash wrote:Enjay: no, my screenshot is ZDoom and the software renderer.
...but I was responding to
Nash wrote:in OpenGL with an extreme view pitch, the cone doesn't work...
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

### Re: [Resource | Code] Conical bullet spread!

I just tried this with a fixed square spread, and the same thing happens: It gets very skewed as you look up and down. Wonder if this is a limitation of the hitscan code, or a limitation of FBF_EXPLICITANGLE?

Edit: Offset doesn't have to be the same with both values, so I updated the first post! I'm also looking into some way of correcting the cone at extreme pitches.

Edit 2:
I did some simple tests in other ZDoom games with different weapons, and it seems that at extreme angles, there is no horizontal spread at all! I'm not sure I can fix this issue, but given other weapons behave the same way, I guess I don't need to.
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

### Re: [Resource | Code] Conical bullet spread! *UPDATED*

I've fixed the "bullseye" issue, so be sure to redownload the example file!

Edit:
Fixed a math related error.
TiberiumSoul
Posts: 1066
Joined: Fri Jan 20, 2012 11:29 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: My Computer...

### Re: [Resource | Code] Conical bullet spread! *UPDATED*

sorry for bumping this but... did anyone ever figure out how to get missiles to work with this?