I'm trying to create an invisible sphere that causes damage to any ships that pass through it (I can just overlay visual effects later). Ideally, this sphere would also take damage from explosions (haven't decided about shockwaves) which intersect with it. Were you to target this sphere with a flack gun or missiles, they should explode inside the sphere, not on the surface. Primaries should pass through harmlessly; not sure about beams.
I can't quite work out how to do the collision detection. I think I could use the $On Frame hook with getDistance(), model radius, and checkRayCollision() to create collision detection, but aside from how much work that would be I'm concerned that it would be very slow in Lua, especially if I'm calling it for dozens of spheres at a time. I don't think I could use the $On Weapon Collision hook because as far as I can tell weapons are treated as line segments rather than spheres or meshes. $On Ship Collision might work if I created a ship .pof that was an invisible polysphere, but aside from just generally being inefficient and reducing the number of ships you can have in a mission, I haven't seen any examples of that hook in use so I don't really know if what I want to do will work.
Also, to determine how much damage to do and generate visual effects, I need the exact time or a close estimation (between frames) that the ship entered the collision sphere, and the ship's position (or a close estimate) when it did so.
Is there some simpler method that I'm not seeing? Aside from learning how to write C++ well enough to write a patch worth committing, I mean.