I asked this question in the CON thread but I thought it'd be worth making a new thread for extra visibility - is this possible via CON code? I'd like to use it for spawning blood, footstep sprites .etc on sloped surfaces, but I don't even know where to begin to figure out what angle the sprite would need to be set at or how to calculate it, if it's even possible.
serious replies only; just a 'man i'd like this too!' would just clutter the thread up, thanks.
Page 1 of 1
Figuring out the angle of a sector slope for spawning sloped sprites
#1 Posted 31 March 2021 - 12:16 AM
#2 Posted 31 March 2021 - 12:47 AM
I think you want something like this:
I use that in Duke Forces to calculate the angle of the slope to help set the landspeeder models pitch and roll when driving it on a slope.
Your problem is a little different, but I think you want to make the sloped sprite face angvar, and then manipulate its slope in the right proportion to the floors slope.
ifn sector[mysector].floorslope 0 { getsector[mysector].wallptr A getwall[A].point2 B getwall[A].x x getwall[A].y y getwall[B].x x2 getwall[B].y y2 subvarvar x x2 subvarvar y y2 getangle angvar x y }
I use that in Duke Forces to calculate the angle of the slope to help set the landspeeder models pitch and roll when driving it on a slope.
Your problem is a little different, but I think you want to make the sloped sprite face angvar, and then manipulate its slope in the right proportion to the floors slope.
#3 Posted 31 March 2021 - 01:13 AM
that's fantastic, and a lot simpler than I thought - thanks a lot Dan!
This post has been edited by Jblade: 31 March 2021 - 01:13 AM
#4 Posted 31 March 2021 - 01:22 AM
Jblade, on 31 March 2021 - 01:13 AM, said:
that's fantastic, and a lot simpler than I thought - thanks a lot Dan!
Cool, let me know how it turns out. I played around with sloped sprites briefly last year and couldn't quite get the hang of them. Do sprite slopes have the same amount of precision as floor slopes? That could be a problem if the sprites are less precise.
#5 Posted 31 March 2021 - 01:30 AM
IIRC they're a bit dodgy when it comes to clipping (for building actual stuff in a map) but for cosmetic stuff they're absolutely fine. Only problem now is to find out if the sprite slope value is actually exposed to CON lol
#6 Posted 31 March 2021 - 01:41 AM
Jblade, on 31 March 2021 - 01:30 AM, said:
Only problem now is to find out if the sprite slope value is actually exposed to CON lol
The slope of a sprite takes up the same position as X and Y offset, where Y offset is the multiple of 256 and X offset 0-255 is precision down to single number, i.e. offset 40, 4 would be 40 + 1024 = 1064.
#8 Posted 31 March 2021 - 02:40 AM
Aleks, on 31 March 2021 - 01:41 AM, said:
The slope of a sprite takes up the same position as X and Y offset, where Y offset is the multiple of 256 and X offset 0-255 is precision down to single number, i.e. offset 40, 4 would be 40 + 1024 = 1064.
That should be automated...
#9 Posted 31 March 2021 - 07:50 AM
Sloped sprites have exact same precision as sector sloping.
Only quirk is setting a cstat and then combining two bytes (x and y offset) to get 16bit precision for the sloping itself.
Even sectors have a specific bit for "slope on/off" despite having a sloping value of 0 so even that is similar.
I believe I added some functions for sloped sprites in the AMC .m32 file I did, syntax is similar to CON so feel free to poke there to see an example. I actually let you copy sloping value from a sector to sprite and the other way around iirc.
One important thing to take in to account with sprites is that "firstwall" is fixed, sprites will tilt only in one direction and angles will merely rotate this.
If you want footprints then you will need to create some ART duplicates that rotate this picnum for you a bit. with 4 directions it should be enough but it can still some times face a bit weirdly.
Only quirk is setting a cstat and then combining two bytes (x and y offset) to get 16bit precision for the sloping itself.
Even sectors have a specific bit for "slope on/off" despite having a sloping value of 0 so even that is similar.
I believe I added some functions for sloped sprites in the AMC .m32 file I did, syntax is similar to CON so feel free to poke there to see an example. I actually let you copy sloping value from a sector to sprite and the other way around iirc.
One important thing to take in to account with sprites is that "firstwall" is fixed, sprites will tilt only in one direction and angles will merely rotate this.
If you want footprints then you will need to create some ART duplicates that rotate this picnum for you a bit. with 4 directions it should be enough but it can still some times face a bit weirdly.
Share this topic:
Page 1 of 1