I've been batting around some ideas for auto aiming in my camera mod (yeah, I'm still working on it), and got a relatively simple idea. Since I'm using DT's scantrail code and that itself uses a hitscan command, I could just use the hitsprite return variable, get the picnum, x, y, z, and ang of the sprite, then force the player to face it at the press of a button.
It's a good thing I'm trying to start this idea out simple since it's already kicking my butt.
Here's the code. It's beneath the APLAYER line, and the code itself isn't all there. I've only included what I'm trying to alter.
ifvare AIM 1 // if the player's aiming, calculate the cos, sin and z angles, then do a hitscan
{
setvarvar mysector temp
getplayer[THISACTOR].ang angvar
getplayer[THISACTOR].horiz zdist
subvar zdist 100
mulvar zdist -2048
cos mycos angvar
sin mysin angvar
// horiz at 0 z angle is 100; pos for up, neg for down
hitscan x y z mysector mycos mysin zdist hitsector hitwall hitsprite hitx hity hitz clipmask
ifvarn hitsprite -1 { quote 1 }
I'm assuming that the hitsprite variable serves a purpose similar to findnearactor's return variable. In that case, it should print the quote if the hitscan's over a sprite. It doesn't. If i change the line to where it prints the quote if hitsprite EQUALS -1, it plays all the time, but the scantrail is hitting tons of sprites. Is this a clipping issue, or am I just royally screwing something up?