Page 1 of 1

A question about NPC equipment

Posted: Mon Jan 07, 2013 12:29 am
by jnorichards
Thanks for all the recent help: here's another question that I don't seem to be able to answer from the [EliteWiki] wiki page for Equipment.plist.

What is it that controls the probability that any given NPC ship owns a piece of equipment? I'm assuming that it's more likely that an NPC ship has, say, an escape pod or fuel scoops than it is that it has, say again, a naval energy unit, or a cloaking device, even if all the equipments are available to NPCs as per the plist.

I can't find any mention of what might control that, though. In the interests of full disclosure, what we're looking to do is to have a piece of equipment which can be awarded to NPC ships via a script, but which has a zero (or similarly small!) probability of being in the manifest when the NPC ship is spawned.

Re: A question about NPC equipment

Posted: Mon Jan 07, 2013 3:47 am
by Tricky
You need to look at [EliteWiki] shipdata.plist, more specifically the has_* ship keys.

f.i., the following snippet awards a ship with various bits of core equipment on a percentage basis.

Code: Select all

...
  has_ecm = "0.1"; // 10% chance.
  has_fuel_injection = "0.01"; // 1% chance.
  has_scoop = "0.75"; // 75% chance.
...

Re: A question about NPC equipment

Posted: Mon Jan 07, 2013 7:13 am
by cim
Importantly, the shipdata.plist settings are only available for standard equipment (and not all of that, for that matter). If you want to do something similar for a piece of custom equipment, you need to have a worldscript with a shipSpawned event handler

Code: Select all

this.shipSpawned = function(ship)
{
    if (Math.random() < 0.03) // 3% chance, doesn't care about ship type
    {
        ship.awardEquipment("EQ_MY_EQUIPMENT_KEY");
    }
}
There are considerable improvements which could be made to the above - you probably don't want to award this equipment to asteroids, or missiles, or stations, so check the ship's scan class. Depending on what it does, you might not want it to be awarded to ships that a mission OXP has added, so checking that the ship has a traditional primaryRole can be a good idea. Using a script_info key can allow ship OXP authors to say that a particular ship should have a particular chance of having the equipment.

Re: A question about NPC equipment

Posted: Mon Jan 07, 2013 7:56 am
by Smivs
Also note that NPCs can't have Extra- or Naval-energy units. These can be simulated by increasing the energy_recharge_rate. For extra-energy multiply by 1.8 and naval-energy by 2.6, so if a ship has a standard energy_recharge_rate of 2, energy_recharge_rate of 3.6 will simulate an extra-energy unit etc.

Re: A question about NPC equipment

Posted: Mon Jan 07, 2013 2:54 pm
by jnorichards
cim wrote:
Importantly, the shipdata.plist settings are only available for standard equipment (and not all of that, for that matter). If you want to do something similar for a piece of custom equipment, you need to have a worldscript with a shipSpawned event handler
That's spot on, thank you very much.