Remove shipdef.defaultHyperdrive and replace it by shipdef.hyperdriveClass
This new attribute isn't an equipment type but a simple integer representing the class of hyperdrives. This allows us to loosen the link between equipment and ship types.master
parent
e2d7fe9355
commit
65d393b125
|
@ -178,7 +178,7 @@ local makeAdvert = function (station)
|
|||
|
||||
-- XXX hull mass is a bad way to determine suitability for role
|
||||
--local shipdefs = utils.build_array(utils.filter(function (k,def) return def.tag == 'SHIP' and def.hullMass >= (danger * 17) and def.equipSlotCapacity.ATMOSHIELD > 0 end, pairs(ShipDef)))
|
||||
local shipdefs = utils.build_array(utils.filter(function (k,def) return def.tag == 'SHIP' and def.defaultHyperdrive ~= 'NONE' and def.equipSlotCapacity.ATMOSHIELD > 0 end, pairs(ShipDef)))
|
||||
local shipdefs = utils.build_array(utils.filter(function (k,def) return def.tag == 'SHIP' and def.hyperdriveClass > 0 and def.equipSlotCapacity.ATMOSHIELD > 0 end, pairs(ShipDef)))
|
||||
local shipdef = shipdefs[Engine.rand:Integer(1,#shipdefs)]
|
||||
local shipid = shipdef.id
|
||||
local shipname = shipdef.name
|
||||
|
@ -276,10 +276,10 @@ local onEnterSystem = function (ship)
|
|||
if mission.location:IsSameSystem(syspath) then -- spawn our target ship
|
||||
local station = Space.GetBody(mission.location.bodyIndex)
|
||||
local shiptype = ShipDef[mission.shipid]
|
||||
local default_drive = shiptype.defaultHyperdrive
|
||||
local default_drive = shiptype.hyperdriveClass
|
||||
local laserdefs = utils.build_array(utils.filter(function (k,def) return def.slot == 'LASER' end, pairs(EquipDef)))
|
||||
local laserdef = laserdefs[mission.danger]
|
||||
local count = tonumber(string.sub(default_drive, -1)) ^ 2
|
||||
local count = default_drive ^ 2
|
||||
|
||||
mission.ship = Space.SpawnShipDocked(mission.shipid, station)
|
||||
if mission.ship == nil then
|
||||
|
@ -287,7 +287,7 @@ local onEnterSystem = function (ship)
|
|||
end
|
||||
mission.ship:SetLabel(mission.shipregid)
|
||||
mission.ship:AddEquip('ATMOSPHERIC_SHIELDING')
|
||||
mission.ship:AddEquip(default_drive)
|
||||
mission.ship:AddEquip('DRIVE_CLASS'..tostring(default_drive))
|
||||
mission.ship:AddEquip(laserdef.id)
|
||||
mission.ship:AddEquip('SHIELD_GENERATOR', mission.danger)
|
||||
mission.ship:AddEquip('HYDROGEN', count)
|
||||
|
|
|
@ -373,7 +373,7 @@ local onEnterSystem = function (player)
|
|||
|
||||
if Engine.rand:Number(1) <= risk then
|
||||
local shipdef = shipdefs[Engine.rand:Integer(1,#shipdefs)]
|
||||
local default_drive = shipdef.defaultHyperdrive
|
||||
local default_drive = 'DRIVE_CLASS'..tostring(shipdef.hyperdriveClass)
|
||||
|
||||
local max_laser_size = shipdef.capacity - EquipDef[default_drive].mass
|
||||
local laserdefs = utils.build_array(utils.filter(
|
||||
|
|
|
@ -25,7 +25,7 @@ local onEnterSystem = function (player)
|
|||
max_pirates = max_pirates-1
|
||||
|
||||
local shipdef = shipdefs[Engine.rand:Integer(1,#shipdefs)]
|
||||
local default_drive = shipdef.defaultHyperdrive
|
||||
local default_drive = 'DRIVE_CLASS'..tostring(shipdef.hyperdriveClass)
|
||||
|
||||
-- select a laser. this is naive - it simply chooses at random from
|
||||
-- the set of lasers that will fit, but never more than one above the
|
||||
|
|
|
@ -337,7 +337,7 @@ local onEnterSystem = function (player)
|
|||
|
||||
if Engine.rand:Number(1) <= risk then
|
||||
local shipdef = shipdefs[Engine.rand:Integer(1,#shipdefs)]
|
||||
local default_drive = shipdef.defaultHyperdrive
|
||||
local default_drive = 'DRIVE_CLASS'..tostring(shipdef.hyperdriveClass)
|
||||
|
||||
local max_laser_size = shipdef.capacity - EquipDef[default_drive].mass
|
||||
local laserdefs = utils.build_array(utils.filter(
|
||||
|
|
|
@ -89,7 +89,7 @@ local addShipEquip = function (ship)
|
|||
local ship_type = ShipDef[trader.ship_name]
|
||||
|
||||
-- add standard equipment
|
||||
ship:AddEquip(ship_type.defaultHyperdrive)
|
||||
ship:AddEquip('DRIVE_CLASS'..tostring(ship_type.hyperdriveClass))
|
||||
if ShipDef[ship.shipId].equipSlotCapacity.ATMOSHIELD > 0 then
|
||||
ship:AddEquip('ATMOSPHERIC_SHIELDING')
|
||||
trader.ATMOSHIELD = true -- flag this to save function calls later
|
||||
|
@ -318,13 +318,13 @@ local getAcceptableShips = function ()
|
|||
filter_function = function(k,def)
|
||||
-- XXX should limit to ships large enough to carry significant
|
||||
-- cargo, but we don't have enough ships yet
|
||||
return def.tag == 'SHIP' and def.defaultHyperdrive ~= 'NONE' and def.equipSlotCapacity.ATMOSHIELD > 0
|
||||
return def.tag == 'SHIP' and def.hyperdriveClass > 0 and def.equipSlotCapacity.ATMOSHIELD > 0
|
||||
end
|
||||
else
|
||||
filter_function = function(k,def)
|
||||
-- XXX should limit to ships large enough to carry significant
|
||||
-- cargo, but we don't have enough ships yet
|
||||
return def.tag == 'SHIP' and def.defaultHyperdrive ~= 'NONE'
|
||||
return def.tag == 'SHIP' and def.hyperdriveClass > 0
|
||||
end
|
||||
end
|
||||
return utils.build_array(
|
||||
|
|
|
@ -106,7 +106,9 @@ local function buyShip (sos)
|
|||
player:SetSkin(sos.skin)
|
||||
if sos.pattern then player.model:SetPattern(sos.pattern) end
|
||||
player:SetLabel(sos.label)
|
||||
player:AddEquip(def.defaultHyperdrive)
|
||||
if def.hyperdriveClass > 0 then
|
||||
player:AddEquip('DRIVE_CLASS'..tostring(def.hyperdriveClass))
|
||||
end
|
||||
player:SetFuelPercent(100)
|
||||
|
||||
shipInfo:SetInnerWidget(
|
||||
|
@ -159,7 +161,7 @@ shipTable.onRowClicked:Connect(function (row)
|
|||
ui:Expand("HORIZONTAL", ui:Align("RIGHT", buyButton)),
|
||||
}),
|
||||
ModelSpinner.New(ui, def.modelName, currentShipOnSale.skin, currentShipOnSale.pattern),
|
||||
ui:Label(l.HYPERDRIVE_FITTED.." "..lcore[def.defaultHyperdrive]):SetFont("SMALL"),
|
||||
ui:Label(l.HYPERDRIVE_FITTED.." "..lcore[(def.hyperdriveClass > 0 and 'DRIVE_CLASS'..def.hyperdriveClass or 'NONE')]):SetFont("SMALL"),
|
||||
ui:Margin(10, "TOP",
|
||||
ui:Grid(2,1)
|
||||
:SetFont("SMALL")
|
||||
|
|
|
@ -117,16 +117,15 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Attribute: defaultHyperdrive
|
||||
* Attribute: hyperdriveClass
|
||||
*
|
||||
* The default hyperdrive this ship receives. This is a <Constants.EquipType>
|
||||
* string corresponding to the appropriate drive. Not that this value is only
|
||||
* used when the player purchases a ship. Scripts using <Space.SpawnShip> etc
|
||||
* must manually add a hyperdrive to the ship; it does not get one by default.
|
||||
* An integer representing the power of the hyperdrive usually installed on
|
||||
* those ships. If null, it means the ship usually isn't equipped with one,
|
||||
* although this does not necessarily mean one cannot be installed.
|
||||
*
|
||||
* Availability:
|
||||
*
|
||||
* alpha 10
|
||||
* April 2014
|
||||
*
|
||||
* Status:
|
||||
*
|
||||
|
@ -219,7 +218,7 @@ void LuaShipDef::Register()
|
|||
pi_lua_settable(l, "basePrice", double(st.baseprice)*0.01);
|
||||
pi_lua_settable(l, "minCrew", st.minCrew);
|
||||
pi_lua_settable(l, "maxCrew", st.maxCrew);
|
||||
pi_lua_settable(l, "defaultHyperdrive", EnumStrings::GetString("EquipType", st.hyperdrive));
|
||||
pi_lua_settable(l, "hyperdriveClass", st.hyperdriveClass);
|
||||
pi_lua_settable(l, "effectiveExhaustVelocity", st.effectiveExhaustVelocity);
|
||||
pi_lua_settable(l, "thrusterFuelUse", st.GetFuelUseRate());
|
||||
|
||||
|
|
|
@ -134,15 +134,7 @@ int _define_ship(lua_State *L, ShipType::Tag tag, std::vector<ShipType::Id> *lis
|
|||
|
||||
s.equipSlotCapacity[Equip::SLOT_ENGINE] = Clamp(s.equipSlotCapacity[Equip::SLOT_ENGINE], 0, 1);
|
||||
|
||||
{
|
||||
int hyperclass;
|
||||
hyperclass = t.Get("hyperdrive_class", 1);
|
||||
if (!hyperclass) {
|
||||
s.hyperdrive = Equip::NONE;
|
||||
} else {
|
||||
s.hyperdrive = Equip::Type(Equip::DRIVE_CLASS1+hyperclass-1);
|
||||
}
|
||||
}
|
||||
s.hyperdriveClass = t.Get("hyperdrive_class", 1);
|
||||
|
||||
for (int i = 0; i < ShipType::GUNMOUNT_MAX; i++) {
|
||||
s.gunMount[i].pos = vector3f(0,0,0);
|
||||
|
|
|
@ -60,7 +60,7 @@ struct ShipType {
|
|||
float effectiveExhaustVelocity; // velocity at which the propellant escapes the engines
|
||||
int fuelTankMass; //full fuel tank mass, on top of hullMass
|
||||
int baseprice;
|
||||
Equip::Type hyperdrive;
|
||||
int hyperdriveClass;
|
||||
vector3d cameraOffset;
|
||||
int minCrew, maxCrew; // XXX really only for Lua, but needs to be declared in the ship def
|
||||
///////
|
||||
|
|
Loading…
Reference in New Issue