A question about NPC equipment

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

Moderators: winston, another_commander

Post Reply
User avatar
jnorichards
Average
Average
Posts: 15
Joined: Mon May 24, 2010 7:30 pm

A question about NPC equipment

Post 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.
Last edited by jnorichards on Mon Jan 07, 2013 6:13 pm, edited 1 time in total.
Kubuntu 12.04 on Asus A7N8X with Creative GeForce FX 5600
Cdr Trubshaw is currently flying test sorties in a Python within G3
User avatar
Tricky
---- E L I T E ----
---- E L I T E ----
Posts: 821
Joined: Sun May 13, 2012 11:12 pm
Location: Bradford, UK. (Anarchic)

Re: A question about NPC equipment

Post 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.
...
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: A question about NPC equipment

Post 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.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: A question about NPC equipment

Post 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.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
jnorichards
Average
Average
Posts: 15
Joined: Mon May 24, 2010 7:30 pm

Re: A question about NPC equipment

Post 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.
Kubuntu 12.04 on Asus A7N8X with Creative GeForce FX 5600
Cdr Trubshaw is currently flying test sorties in a Python within G3
Post Reply