[ship file] news, setTargetBox() could greatly benefit big ships with complex shapes

As the dude says, some new ■■■■ has come to light man. I’ve searched the forums and I don’t see this information previously discussed.

I was doing a mass search of the extracted bigs to refresh my memory on some stuff, as I often do while modding, when I noticed something odd in hgn_shipyard

setTargetBox(NewShipType, 0, -0.1,-0.7, -0.9, 0.55, 0.5, 0.82)
setTargetBox(NewShipType, 1, -0.9,-0.001, -0.9, 0.005, 0.6, -0.55)

Now I had assumed that setTargetBox as just syntactic sugar for the old targetRandomPoint values, and that setting them direct still worked. Testing that idea doesn’t seem to have panned out for me. Further I had assumed that the second parameter for this function was an bool, seeing this I started to suspect it was an index. And that has some exciting implications.

I mocked up the boxes described there in wings and it somewhat describes the main body and engine block of the shipyard, which made me pretty confident of my guess.

We can have multiple targetboxes on the same model now. I tested it, it works. Ships even seem to pick the nearest box for their targeting, which is great for huge ships.


All the ions are attacking one ship that bears four boxes, very small ones at the forward corners of the ship’s bounding box. The ion cannons quite merrily attack their nearest one, and many start firing way earlier than a preceding test when I only had two target boxes.

Any mod with ships that don’t fill out their bounding box very well and have complex shapes that aren’t well handled by a single target box should really look into this, I think it has the potential to really smooth out some rough combat cases. Fulcrum definitely has a lot of ships that can benefit from this development.

My experimentation strongly suggests that the parameters are as follows

setTargetBox(ship, iIndex, fXmin, fYmin, fZmin, fXmax, fYmax, fZmax)

with the dimensions ranging from -1 to 1 proportional to the bounding box of the collision mesh, as with the old settings.

The game will only permit eight target boxes and ignore any past that point. Should be sufficient for most ships out there.

Also if you’ve got ship files still using the old settings instead of setTargetBox() I don’t think they work anymore.

Now I’ve got to go fix up some ship files…


This is very exciting news! Well done for spotting that! And it is surprising that no-one has noticed it before… Time to model some target boxes!

EDIT: are these values in km instead of m?

EDIT2: it would appear so…

They should be relative to the size of the mesh’s bounding box. So if your ship is 200 meters wide, a box spanning from 50x to -50x would be 0.5 to 0.5

I’ve not quite cracked how to properly handle meshs whose bounding box isn’t perfectly centered on the mesh origin, but that’s math that’s going to have to wait for another day.

Ah, I see, proportional to collision mesh size… The hiigaran destroyer appears to be asymmetric, so maybe that would be a good one to investigate…

If you want to set up target boxes this math seems to pan out in the limited testing I’ve done so far. Go ahead and make a copy of it for your own uses.


Hey @EatThePath

Give mine a shot :wink:
I import the collision mesh into the ol’ CFHodEd and it gives me the correct starting values relative to the 0,0,0 position and a GUI for seeing which box goes where (at least until I get DAEnerys working again).

Make sure you download to get access to the copy macros!


that’s essentially the same as what I’m doing, but I’m getting the box dimensions via Wings3D rather than CFHodEd. DAENerys currently doesn’t have an interface or visualization for the bounding boxes anyway

1 Like

Essentially yes… I just have some macros because I’m lazy :stuck_out_tongue: