Screen Space Aim Assist
Posted: Tue Feb 21, 2023 10:07 pm
This is a useful phrase I keep in my spellbook for targeting entities, which selects the entity from a list closest to my crosshair (based on the average position of the entity's feet and head), within a given viewcone. It makes use of a few other utility phrases, which I've included as their own patterns below.
______________________________________________________________________________________________________
Clean Thoth (list<pattern>, list → list)
Thoth, but only the iotas at the top of the stack are included in the returned list. Useful if thoth is required for a phrase part way through a spell which needs to maintain a stack.
______________________________________________________________________________________________________
Inverse Screen Space Distance (vector → num)
Used instead of view angle relative to the crosshair because there's no native atan2 function, this doesn't require a conditional, is simple to calculate, and because it's monotonic with respect to view angle which is all we really want.
______________________________________________________________________________________________________
Argmax (list<num> → num)
Gets the index of the largest value in a list. Also saves a copy of that value to the ravenmind as a side effect, which can be useful.
______________________________________________________________________________________________________
Aim Assist (list<pattern>, num, list<entity> → )
Takes a list of patterns which are to be executed on an entity, a threshold value (where 0 is anything in front of you, 1 is a 90 degree cone, 2 is a 45 degree cone, etc.), and a list of entities. It then executes the patterns on an entity chosen by aim assist. Does nothing if no entity is within the given threshold. Patterns in red below are convenient examples; including them in the spell changes the type to (list<pattern> → ). Note that your own location in screen space is undefined, so this will throw a divide-by-zero mishap if you include yourself in the entity list!
______________________________________________________________________________________________________
Clean Thoth (list<pattern>, list → list)
Thoth, but only the iotas at the top of the stack are included in the returned list. Useful if thoth is required for a phrase part way through a spell which needs to maintain a stack.
______________________________________________________________________________________________________
Inverse Screen Space Distance (vector → num)
Used instead of view angle relative to the crosshair because there's no native atan2 function, this doesn't require a conditional, is simple to calculate, and because it's monotonic with respect to view angle which is all we really want.
______________________________________________________________________________________________________
Argmax (list<num> → num)
Gets the index of the largest value in a list. Also saves a copy of that value to the ravenmind as a side effect, which can be useful.
______________________________________________________________________________________________________
Aim Assist (list<pattern>, num, list<entity> → )
Takes a list of patterns which are to be executed on an entity, a threshold value (where 0 is anything in front of you, 1 is a 90 degree cone, 2 is a 45 degree cone, etc.), and a list of entities. It then executes the patterns on an entity chosen by aim assist. Does nothing if no entity is within the given threshold. Patterns in red below are convenient examples; including them in the spell changes the type to (list<pattern> → ). Note that your own location in screen space is undefined, so this will throw a divide-by-zero mishap if you include yourself in the entity list!