Duke4.net Forums: Figuring out the angle of a sector slope for spawning sloped sprites - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Figuring out the angle of a sector slope for spawning sloped sprites

User is offline   Jblade 

#1

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

User is online   Danukem 

  • Duke Plus Developer

#2

I think you want something like this:

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

User is offline   Jblade 

#3

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

0

User is online   Danukem 

  • Duke Plus Developer

#4

View PostJblade, 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.
1

User is offline   Jblade 

#5

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
0

User is online   Aleks 

#6

View PostJblade, 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.
2

User is offline   Jblade 

#7

alright, thanks for the heads up.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#8

View PostAleks, 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...
2

User is offline   oasiz 

  • Dr. Effector

#9

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options