Page 1 of 1
What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 11:12 am
by Zieman
Wiki isn't very helpful in this case.
It just says:
Code: Select all
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.
It could be something like this:
=> if the key
missiles isn't present, NPC gets random amount of missiles at creation, however not more than 6.
If the behaviour is different, how does it go?
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 11:27 am
by JensAyton
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
.
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 11:50 am
by Zieman
Ahruman wrote: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)?
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 12:06 pm
by JensAyton
Exactly.
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 12:15 pm
by Zieman
Thank you.
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 2:23 pm
by Commander McLane
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
.
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 2:56 pm
by DaddyHoggy
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?
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 3:44 pm
by Commander McLane
DaddyHoggy wrote: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).
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 7:38 pm
by Zieman
Zieman wrote: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.)
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 8:01 pm
by Thargoid
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.
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 8:15 pm
by Zieman
Allright, will try.
TBH, while waiting for answers, I looked up some Javascript tutorials in the Web and tried to figure out how to script such repeat/loop.
Thanks anyway, I think I'll make this easier for myself by taking a peek at your OXP...
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 8:26 pm
by Thargoid
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
Re: What exactly does max_missiles key do?
Posted: Sat Jun 18, 2011 9:31 pm
by Zieman
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!