Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/api/entity/cpuship.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function CpuShip()
ai_controller = {new_name="default", orders="roaming"},
scan_state = {allow_simple_scan=true},
callsign = {callsign=generateRandomCallSign()},
comms_receiver = {script="comms_ship.lua"},
}
e:setFaction(__default_cpu_ship_faction)
return e
Expand Down
3 changes: 3 additions & 0 deletions scripts/api/entity/playerspaceship.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ function PlayerSpaceship()
transform = {rotation=random(0, 360)},
callsign = {callsign=generateRandomCallSign()},
scan_state = scan_state,
comms_transmitter = {},
radar_link = {},
waypoints = {},
}
e:setFaction(__default_player_ship_faction)
return e
Expand Down
16 changes: 11 additions & 5 deletions scripts/api/entity/shiptemplatebasedobject.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ function Entity:setTemplate(template_name)
end
end
if template.__type == "station" then
-- stations have static physics
comp.physics.type = "static"
elseif template.__type == "playership" then
if comp.shields then comp.shields.active = false end
elseif comp.shields then
-- ships have shield frequencies, player shields are off by default
comp.shields.frequency = irandom(0, 20)
if comp.player_control then
comp.shields.active = false
end
end

if comp.ai_controller then
comp.ai_controller.new_name = template.__default_ai
end

if comp.reactor then
Expand All @@ -53,9 +62,6 @@ function Entity:setTemplate(template_name)
crew.components.internal_repair_crew = {}
end
end
if comp.shields and template.__type ~= "station" then
comp.shields.frequency = irandom(0, 20)
end
if comp.internal_rooms == nil then -- No internal rooms, so auto-repair
if comp.beam_weapons then comp.beam_weapons.auto_repair_per_second = 0.005; end
if comp.missile_tubes then comp.missile_tubes.auto_repair_per_second = 0.005 end
Expand Down
1 change: 1 addition & 0 deletions scripts/api/entity/spacestation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function SpaceStation()
e.components = {
transform = {rotation=random(0, 360)},
callsign = {callsign=generateRandomCallSign("DS")},
comms_receiver = {script="comms_station.lua"},
}
e:setFaction(__default_station_faction)
return e
Expand Down
16 changes: 5 additions & 11 deletions scripts/api/shipTemplate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ function ShipTemplate:__init__()
color_by_faction=true,
arrow_if_not_scanned=true,
}
self.__default_ai = "default"
self.__repair_crew_count = 3
self.long_range_radar = {}
self.share_short_range_radar = {}
self.comms_receiver = {script="comms_ship.lua"}
end

--- Sets this ShipTemplate's unique reference name.
Expand Down Expand Up @@ -111,12 +112,6 @@ function ShipTemplate:setType(template_type)
self.science_scanner = {}
self.scan_probe_launcher = {}
self.hacking_device = {}
self.long_range_radar = {}
self.radar_link = {}
self.waypoints = {}
self.comms_transmitter = {}
self.comms_receiver = nil
self.ai_controller = nil
if self.docking_port then
self.docking_port.auto_reload_missiles = false
end
Expand All @@ -129,7 +124,6 @@ function ShipTemplate:setType(template_type)
if self.radar_trace.icon == "radar/ship.png" then
self.radar_trace.icon = "radar/blip.png"
end
self.comms_receiver = {script="comms_station.lua"}
end
return self
end
Expand All @@ -150,7 +144,7 @@ end
--- - "missilevolley" prefers lining up missile attacks from long range
--- Example: template:setAI("fighter") -- default to the "fighter" combat AI state
function ShipTemplate:setDefaultAI(default_ai)
self.ai_controller = {new_name=default_ai}
self.__default_ai = default_ai
return self
end
--- Sets the 3D appearance, by ModelData name, of ShipTemplateBasedObjects created from this ShipTemplate.
Expand Down Expand Up @@ -534,7 +528,7 @@ end
--- Defaults to 30000.0 (30U).
--- Example: template:setLongRangeRadarRange(20000) -- sets the long-range radar range to 20U
function ShipTemplate:setLongRangeRadarRange(range)
if self.long_range_radar then self.long_range_radar.long_range = range end
self.long_range_radar.long_range = range
return self
end
--- Sets the short-range radar range of SpaceShips created from this ShipTemplate.
Expand All @@ -544,7 +538,7 @@ end
--- Defaults to 5000.0 (5U).
--- Example: template:setShortRangeRadarRange(4000) -- sets the short-range radar range to 4U
function ShipTemplate:setShortRangeRadarRange(range)
if self.long_range_radar then self.long_range_radar.short_range = range end
self.long_range_radar.short_range = range
return self
end
--- Sets the sound file used for the impulse drive sounds on SpaceShips created from this ShipTemplate.
Expand Down
Loading