Smivs wrote:I think Commander Mclane's suggestion
Commander McLane wrote:
More control would be achievable with new AI methods switchCloakOn and switchCloakOff...
is entirely sensible, and would be really useful.
Thanks for the flowers!
It isn't implemented yet in this form, however, which makes NPC cloak control slightly more difficult, but not impossible.
The clue is in JS. You can't do it in the AI, but you can do it in an attached script. For examples have a look into personalities.oxp, which is the reason I requested the methods in the first place.
You can use the
ship.isCloaked property to switch the cloak on or off. However, this brings only a certain degree of flexibility, because the use of the cloak is still mainly controlled by the engine itself through the attackShip-command. (The problem with this was that a NPC with a cloaking device would activate it as soon as it went into attack mode, but there is no command in the code to de-activate it again. So the NPC always stays cloaked from that point, until its energy has been drained.) Since Oolite 1.74 you can use a trick to allow you more control. Because all NPC equipment has become open for scripting, you can award or remove the cloaking device "on the fly", thereby exerting more control over cases in which you
don't want the cloaking device to be used. Only this way it is possible to script a behaviour for NPCs that mimicks a typical player's use of the device, e.g. to cloak only for a second in order to get rid of incoming missiles.