#pandt status micro-update:

working on line-effect abilities. I am easily annoyed & distracted when working on the parts of P&T that involve algebra. anyway, it's at least working in an amusingly incorrect way :) this screenshot is Elron ("Elro") using their Piercing Shot ability toward the other creatures in the scene. https://mastodon.weaponvsac.space/media/4bWoCfnlKrwKmiqi6vY

#tabletop #rpg

@radix Huh. It's not clear to me how you'd manage to get that failure mode :)

I wonder - since you're always going to have a relatively small set of pixels to try, maybe you could just treat the scene as a grid over a finite field, find the line between the two points, and then exhaustively test each square to see if it lies on the line?

Non-exhaustive testing for line drawing is hard, but maybe you can cheat ☺

@RAOF since I have your ear, though 😅, does this sound right?

given "clicked_pt", "caster_pos", and "ability_range":

let mut vec = clicked_pt - caster_pos;
vec.normalize_mut()
let line = vec * ability_range;

this is to get a line from the caster *through* the clicked point, as long as the ability_range.

That's basically what I'm doing. If that sounds right then I guess I just have some incidental bugs, like maybe in all the type conversions I'm doing...

@radix That sounds right.

Always worth checking the inverse:

vec + caster_pos = (clicked_pt - caster_pos) + caster_pos = clicked_pt. Cool.-

This assumes (0,0) is the origin and all the usual vector shenanigans.

@RAOF yeah, time for some unit tests :)

@RAOF fixed!

three bugs: drawing the line from the wrong origin; wasn't converting centimeters back to meters; and had a vector difference backwards.

This line drawing algorithm needs to go, though. some angles can't be drawn through a target I'm directly clicking https://mastodon.weaponvsac.space/media/TeT3UVTDBVY4AuVD3fA

#tabletop #rpg

@radix Since this is Rust, are you aware of the uom crate: https://crates.io/crates/uom

Tag your values with their dimensions, and do dimensional analysis at build time!

@radix That's obviously for the cm vs m bug.