Sets a ship's missile limit. Maximum allowable value for the player is 16 and for npc ships 32. When not defined, the value with "missiles" is used as max_missiles. When defining more than a few missiles, it could be wise to also define value for "missile_load_time" to avoid massive missile launches. npc ships are more likely to fire missiles the more they carry.
What it doesn't say is that how many missiles a NPC will get with a given max_missiles value.
missiles defaults to 0, regardless of whether max_missiles is present. The only interaction between them is that if both are defined, missiles is clamped to max_missiles.
missiles defaults to 0, regardless of whether max_missiles is present. The only interaction between them is that if both are defined, missiles is clamped to max_missiles.
Does this mean that if max_missiles is 10 and missiles is not present, the ship will have no missiles (unless you give them by some script)?
For the longest time max_missiles was a player-ship-only key, and even now it is mostly relevant for player ships.
Only since a script can award additional missiles to NPCs after they were spawned does it have any relevance for NPCs, being the upper limit of missiles.
Wasn't there an oddity in the AI many a while ago where the NPCs were overly cautious about firing missiles, often not firing a missile until they were all but dead. I recall some debate about one of the mining related OXPs where the number of NPC missiles had to be set to a very large number for it to fire anything.
Is this no longer the case or have I misremembered?
Wasn't there an oddity in the AI many a while ago where the NPCs were overly cautious about firing missiles, often not firing a missile until they were all but dead. I recall some debate about one of the mining related OXPs where the number of NPC missiles had to be set to a very large number for it to fire anything.
Is this no longer the case or have I misremembered?
It's no longer the case, and it's the reason why missile_load_time was introduced (the latter to prevent the missiles from being fired all at once).
Does this mean that if max_missiles is 10 and missiles is not present, the ship will have no missiles (unless you give them by some script)?
Anyone got such a script at hand...?
Let's say that I want to give a NPC three hardheads when it is created - what should I put in its ship script?
Ah, um, talking about Javascript here ("myfancyNPCscript.js" etc.)
Have a look in the external missiles cobra OXP that Griff and I made. That does something along these lines.
Basically in the this.shipSpawned function, just use this.ship.awardEquipment("EQ_HARDENED_MISSILE"); and repeat however many times you want to give it a missile. If you set the missiles key in shipdata to zero and the max_missiles to something higher than zero, you will basically have that many empty pylons to play with.
You can get a little more complex by checking that a pylon is available and also that the equipment itself is available (loaded in the game, if it's OXP) but for this simple and controlled scenario the above should be enough.
There are loop examples in many of the OXP scripts (mine and other peoples) - look for the "for" command.
But in this case, as you only want to do it a fixed three times, it's probably quicker and simpler just to put the awardEquipment command in the script three times
Oh well, didn't immediately find the Griff & Thargoid Cobra, so I constructed a script myself (found relevant stuff in the web tutorial for Javascript and Oolite wiki).
Even managed to make the script to tell me on screen what it accomplished...
Anyway, now the script seems to work: it gives the ship calling it a random amount (from zero to max_missiles) of missiles of my choosing. Yay!