The new function scanForNearestShipWithScanClass is not working yet. I tried to use it but it didn't recognise my ships. So I wrote a small testscript for a ship placed near the station and the buoy.
I did get the UPDATE message but never the FOUND message. Even using a "setDesiredRangeTo: 20000.0" in the script didn't help (in case the new function had a range). With the debugging tool I checked the AI was in the IDLE state and the scann_class of the buoy was CLASS_BUOY
My C knowledge is still not enough to really understand all but following the scan code I see no strange things. Only when I come in the new file: OOEntityFilterPredicate I see something strange.
"parameter" is the scanclass we are looking for. Is it changed to an integer and than compared with the string "scanClass"? Could this be that it always returns NO?
Parameter is converted to an int value and it gets compared with scanClass, indeed. But scanClass is not a string. In reality it is an integer value. In OOTypes.h, you will find
Then in Entity.h there is the declaration OOScanClass scanClass (line 104). This is the scanClass that is compared with the parameter value. I had a quick look at the code and it looks pretty OK to me, too. But maybe I will have a better look sometime during the weekend and see if I can discover anything.
Eric is correct; 1.70 is not converting the scan class string to an integer before setting up the search predicate, so the only way it’ll work is if you pass an integer instead of a symbolic name. (But don’t do that; it won’t work in future.)
this.findNearestBuoy = function()
{
let result = null
try
{
result = system.entitiesWithScanClass("CLASS_BUOY", player)[0]
}
catch (error)
{
// If we get here, no buoys were found.
}
return result
}