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

Post your example zscripts/ACS scripts/etc here.

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

Postby Snarboo » Wed Dec 31, 2014 2:07 pm

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 allExpand view
/*
** Conical Bullet Spread Example
** 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
Attachments
conicalspread.pk3
Pickup a chaingun, or type "give conicalchaingun" in the console.
(1.1 KiB) Downloaded 117 times
Last edited by Snarboo on Thu Jan 01, 2015 12:52 pm, edited 4 times in total.
User avatar
Snarboo
Bacon doesn't know it's not dogs
 
Joined: 29 Nov 2005

Re: [Resource | Code] Conical bullet spread!

Postby Nash » Wed Dec 31, 2014 2:15 pm

Image

Looks like one of those mysterious alien pattern thingies you find in obscure places... =D
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: [Resource | Code] Conical bullet spread!

Postby Snarboo » Wed Dec 31, 2014 2:20 pm

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?!
User avatar
Snarboo
Bacon doesn't know it's not dogs
 
Joined: 29 Nov 2005

Re: [Resource | Code] Conical bullet spread!

Postby Nash » Wed Dec 31, 2014 2:23 pm

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...
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: [Resource | Code] Conical bullet spread!

Postby Snarboo » Wed Dec 31, 2014 2:26 pm

Yeah I've definitely screwed up the math somewhere! I'll look into it.
User avatar
Snarboo
Bacon doesn't know it's not dogs
 
Joined: 29 Nov 2005

Re: [Resource | Code] Conical bullet spread!

Postby Enjay » Wed Dec 31, 2014 2:30 pm

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.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: [Resource | Code] Conical bullet spread!

Postby Nash » Wed Dec 31, 2014 2:35 pm

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)
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: [Resource | Code] Conical bullet spread!

Postby Snarboo » Wed Dec 31, 2014 2:38 pm

The cone does get very skewed at greater pitches, but I'm not sure how to fix that if it can be fixed.
User avatar
Snarboo
Bacon doesn't know it's not dogs
 
Joined: 29 Nov 2005

Re: [Resource | Code] Conical bullet spread!

Postby Enjay » Wed Dec 31, 2014 2:51 pm

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...

;)
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: [Resource | Code] Conical bullet spread!

Postby Snarboo » Wed Dec 31, 2014 3:02 pm

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.
User avatar
Snarboo
Bacon doesn't know it's not dogs
 
Joined: 29 Nov 2005

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

Postby Snarboo » Thu Jan 01, 2015 11:47 am

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

Edit:
Fixed a math related error.
User avatar
Snarboo
Bacon doesn't know it's not dogs
 
Joined: 29 Nov 2005

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

Postby TiberiumSoul » Wed Sep 16, 2015 5:57 pm

sorry for bumping this but... did anyone ever figure out how to get missiles to work with this?
User avatar
TiberiumSoul
The Lost Soul that stumbled into a patch of tiberium crystals
 
Joined: 20 Jan 2012
Location: My Computer...


Return to Script Library

Who is online

Users browsing this forum: No registered users and 1 guest