Skip to content

Commit

Permalink
scenario wormhole: lots of fixes on comms code
Browse files Browse the repository at this point in the history
  • Loading branch information
Piglit committed Sep 2, 2024
1 parent 52f6ddb commit eb19534
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 62 deletions.
4 changes: 3 additions & 1 deletion scripts-piglit/border_defend_station.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ function update(delta)
end
else
if my_station:areEnemiesInRange(10000) then
my_ship:orderDefendTarget(my_station)
if my_ship:getOrder() ~= "Defend Target" then
my_ship:orderDefendTarget(my_station)
end
else
if not ship_healthy then
my_ship:orderDock(my_station)
Expand Down
93 changes: 53 additions & 40 deletions scripts-piglit/comms_station_sandbox.lua

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions scripts-piglit/plots/wh_kraylor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function wh_kraylor:spawn_enemies_kraylor(xOrigin, yOrigin, enemyStrength)
local enemyList = {}

local enemyPosition = 0
local sp = irandom(300,500) --random spacing of spawned group
local sp = irandom(500,700) --random spacing of spawned group

local formationLeader = nil
local formationSecond = nil
Expand All @@ -132,7 +132,7 @@ function wh_kraylor:spawn_enemies_kraylor(xOrigin, yOrigin, enemyStrength)
enemyPosition = enemyPosition + 1
ship:setPosition(xOrigin+sp*enemyPosition, yOrigin+sp*enemyPosition)
formationLeader, formationSecond = script_formation.buildFormationIncremental(ship, enemyPosition, formationLeader, formationSecond)
ship:setCommsScript(""):setCommsFunction(commsShip)
ship:setCommsScript(""):setCommsFunction(commsShip) --TODO commsShip is not defined!
table.insert(enemyList, ship)
end

Expand Down Expand Up @@ -314,13 +314,13 @@ function wh_kraylor:update(delta)
end
end
if threatened and not defended then
if station:getHull() < station.surrender_hull_threshold then
if 100*station:getHull()/station:getHullMax() < station.surrender_hull_threshold then
-- reduce threshold
station.surrender_hull_threshold = station.surrender_hull_threshold / 2
if comms_target.comms_data == nil then
comms_target.comms_data = {}
if station.comms_data == nil then
station.comms_data = {}
end
mergeTables(comms_target.comms_data, {
mergeTables(station.comms_data, {
surrender_hull_threshold = station.surrender_hull_threshold
})
-- change faction
Expand Down
18 changes: 7 additions & 11 deletions scripts-piglit/plots/wh_stations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ function wh_stations:init()
end

function wh_stations:initTest()
PlayerSpaceship():setTemplate("Adder MK7"):setCallSign("Station Visitor"):setPosition(-20000,0):setRotation(90):commandTargetRotation(90)
placeStation(-20000, -500):setCommsScript("comms_station_sandbox.lua")
local x,y = self.stations[1]:getPosition()
local ship = PlayerSpaceship():setTemplate("Adder MK7"):setCallSign("Station Visitor"):setPosition(x,y):setRotation(90):commandTargetRotation(90)
ship:setResourceAmount("Station Command Team", 1)
ship:setResourceAmount("Station Boarding Pod", 1)
ship:setResourceAmount("Diplomatic Crew", 1)
ship:setResourceAmount("Xenolinguistic Team", 1)
end

function wh_stations:setRepairMissions()
Expand Down Expand Up @@ -141,42 +145,34 @@ function wh_stations:setRepairMissions()
for i,station in ipairs(mission_stations) do
station.mission_goods = {}
for j,m_type in ipairs(ordnance_missions) do
if not station.comms_data.weapon_available then
station.mission_goods[m_type] = tableSelectRandom(mission_goods[m_type])
end
station.mission_goods[m_type] = tableSelectRandom(mission_goods[m_type])
end
if not station:getRestocksScanProbes() then
if station.probe_fail_reason == nil then
local reason_list = {
_("situationReport-comms", "Cannot replenish scan probes due to fabrication unit failure."),
_("situationReport-comms", "Parts shortage prevents scan probe replenishment."),
_("situationReport-comms", "Station management has curtailed scan probe replenishment for cost cutting reasons."),
}
station.probe_fail_reason = reason_list[math.random(1,#reason_list)]
station.mission_goods["restock_probes"] = tableSelectRandom(mission_reasons["restock_probes"][station.probe_fail_reason])
end
end
if not station:getRepairDocked() then
if station.repair_fail_reason == nil then
reason_list = {
_("situationReport-comms", "We're out of the necessary materials and supplies for hull repair."),
_("situationReport-comms", "Hull repair automation unavailable while it is undergoing maintenance."),
_("situationReport-comms", "All hull repair technicians quarantined to quarters due to illness."),
}
station.repair_fail_reason = reason_list[math.random(1,#reason_list)]
station.mission_goods["hull"] = tableSelectRandom(mission_reasons["hull"][station.repair_fail_reason])
end
end
if not station:getSharesEnergyWithDocked() then
if station.energy_fail_reason == nil then
reason_list = {
_("situationReport-comms", "A recent reactor failure has put us on auxiliary power, so we cannot recharge ships."),
_("situationReport-comms", "A damaged power coupling makes it too dangerous to recharge ships."),
_("situationReport-comms", "An asteroid strike damaged our solar cells and we are short on power, so we can't recharge ships right now."),
}
station.energy_fail_reason = reason_list[math.random(1,#reason_list)]
station.mission_goods["energy"] = tableSelectRandom(mission_reasons["energy"][station.energy_fail_reason])
end
end

--remove what is sold here
Expand Down
4 changes: 2 additions & 2 deletions scripts-piglit/plots/wh_turns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function wh_turns:startPause()
slowGame()
setScanningComplexity('none')
setHackingDifficulty(3)
local endTime = os.date("%H:%M", os.time() + self.pauseTime) -- TODO test
globalMessage('Flottenbesprechung bis '..endTime)
--local endTime = os.date("%H:%M", os.time() + self.pauseTime) -- FIXME: os not avail
--globalMessage('Flottenbesprechung bis '..endTime)
for id, script in pairs(self.onPause) do
script()
end
Expand Down
2 changes: 2 additions & 0 deletions scripts-piglit/scenario_99_wormhole_expedition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require "plots/wh_wormhole.lua"

--require "sandbox_error.lua"
require "xansta_mods.lua"
require "script_hangar.lua"

require("serpent.lua")
function table.dump(...)
Expand Down Expand Up @@ -66,6 +67,7 @@ function update(delta)
plot:updateTest()
end
end
script_hangar.update(delta)
end


4 changes: 2 additions & 2 deletions scripts-piglit/script_formation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function factionalOffsets(faction, pos)

local x,y -- x - to the front, y - to starport
if faction == "Kraylor" then
x = 300
y = 300
x = 400
y = 400
elseif faction == "Exuari" then
x = -300
y = 300
Expand Down
5 changes: 5 additions & 0 deletions scripts-piglit/xansta_mods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ function init_constants_xansta()
{"software",0},
{"circuit",0},
{"battery",0} }
good_desc = {}
for i,good in ipairs(goodsList) do
local g = good[1]
good_desc[g] = g
end
commonGoods = {"food","medicine","nickel","platinum","gold","dilithium","tritanium","luxury","cobalt","impulse","warp","shield","tractor","repulsor","beam","optic","robotic","filament","transporter","sensor","communication","autodoc","lifter","android","nanites","software","circuit","battery"}
componentGoods = {"impulse","warp","shield","tractor","repulsor","beam","optic","robotic","filament","transporter","sensor","communication","autodoc","lifter","android","nanites","software","circuit","battery"}
mineralGoods = {"nickel","platinum","gold","dilithium","tritanium","cobalt"}
Expand Down

0 comments on commit eb19534

Please sign in to comment.