What exactly does max_missiles key do?

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
Zieman
---- E L I T E ----
---- E L I T E ----
Posts: 680
Joined: Tue Sep 01, 2009 11:55 pm
Location: in maZe

What exactly does max_missiles key do?

Post 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:

Code: Select all

max_missiles = 6;
=> 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?
...and keep it under lightspeed!

Friendliest Meteor Police that side of Riedquat

[EliteWiki] Far Arm ships
[EliteWiki] Z-ships
[EliteWiki] Baakili Far Trader
[EliteWiki] Tin of SPAM
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: What exactly does max_missiles key do?

Post 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.
User avatar
Zieman
---- E L I T E ----
---- E L I T E ----
Posts: 680
Joined: Tue Sep 01, 2009 11:55 pm
Location: in maZe

Re: What exactly does max_missiles key do?

Post 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)?
...and keep it under lightspeed!

Friendliest Meteor Police that side of Riedquat

[EliteWiki] Far Arm ships
[EliteWiki] Z-ships
[EliteWiki] Baakili Far Trader
[EliteWiki] Tin of SPAM
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: What exactly does max_missiles key do?

Post by JensAyton »

Exactly.
User avatar
Zieman
---- E L I T E ----
---- E L I T E ----
Posts: 680
Joined: Tue Sep 01, 2009 11:55 pm
Location: in maZe

Re: What exactly does max_missiles key do?

Post by Zieman »

Thank you.
...and keep it under lightspeed!

Friendliest Meteor Police that side of Riedquat

[EliteWiki] Far Arm ships
[EliteWiki] Z-ships
[EliteWiki] Baakili Far Trader
[EliteWiki] Tin of SPAM
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: What exactly does max_missiles key do?

Post 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.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Re: What exactly does max_missiles key do?

Post 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?
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: What exactly does max_missiles key do?

Post 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).
User avatar
Zieman
---- E L I T E ----
---- E L I T E ----
Posts: 680
Joined: Tue Sep 01, 2009 11:55 pm
Location: in maZe

Re: What exactly does max_missiles key do?

Post 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.) :)
...and keep it under lightspeed!

Friendliest Meteor Police that side of Riedquat

[EliteWiki] Far Arm ships
[EliteWiki] Z-ships
[EliteWiki] Baakili Far Trader
[EliteWiki] Tin of SPAM
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: What exactly does max_missiles key do?

Post 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.
User avatar
Zieman
---- E L I T E ----
---- E L I T E ----
Posts: 680
Joined: Tue Sep 01, 2009 11:55 pm
Location: in maZe

Re: What exactly does max_missiles key do?

Post 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...
...and keep it under lightspeed!

Friendliest Meteor Police that side of Riedquat

[EliteWiki] Far Arm ships
[EliteWiki] Z-ships
[EliteWiki] Baakili Far Trader
[EliteWiki] Tin of SPAM
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: What exactly does max_missiles key do?

Post 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 ;)
User avatar
Zieman
---- E L I T E ----
---- E L I T E ----
Posts: 680
Joined: Tue Sep 01, 2009 11:55 pm
Location: in maZe

Re: What exactly does max_missiles key do?

Post 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! :D
...and keep it under lightspeed!

Friendliest Meteor Police that side of Riedquat

[EliteWiki] Far Arm ships
[EliteWiki] Z-ships
[EliteWiki] Baakili Far Trader
[EliteWiki] Tin of SPAM
Post Reply