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
8 changes: 7 additions & 1 deletion scripts/scenario_03_waves.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ end
function spawnWave()
waveNumber = waveNumber + 1
getPlayerShip(-1):addToShipLog(string.format(_("shipLog", "Wave %d"), waveNumber), "red")
friendlyList[1]:addReputationPoints(150 + waveNumber * 15)
-- friendlyList[1] may have been destroyed by an earlier wave; reward the first station still alive
for _, friendly in ipairs(friendlyList) do
if friendly:isValid() then
friendly:addReputationPoints(150 + waveNumber * 15)
break
end
end

enemyList = {}

Expand Down
8 changes: 4 additions & 4 deletions scripts/scenario_06_edgeofspace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ Thank you for defending our station. Please dock with us, and we'll analyze the
string.format(_("centralcommand-incCall", "Apollo, come in!\n\nLeave the E.O.S. data with Galileo for now, we've confirmed reports that Kraylor are brazen enough to attack our E.O.S. scope directly! All available ships should converge on E.O.S. territory in sector %s!\n\nThat means you, Apollo!"),EOS_Station:getSectorName())
)

kraylor_e1:orderRoaming()
kraylor_e2:orderRoaming()
kraylor_e3:orderRoaming()
kraylor_e4:orderRoaming()
if kraylor_e1:isValid() then kraylor_e1:orderRoaming() end
if kraylor_e2:isValid() then kraylor_e2:orderRoaming() end
if kraylor_e3:isValid() then kraylor_e3:orderRoaming() end
if kraylor_e4:isValid() then kraylor_e4:orderRoaming() end

Human_m1:orderDefendLocation(60500, 42100)
Human_m2:orderDefendLocation(60500, 42100)
Expand Down
1 change: 1 addition & 0 deletions scripts/scenario_07_gftp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ function update(delta)
-- Stakhanov must survive
if not stakhanov:isValid() then
victory("Ghosts")
return -- the rest of update() calls into stakhanov
end

-- The player must survive
Expand Down
15 changes: 8 additions & 7 deletions scripts/scenario_08_atlantis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ end

function phase1WaitForSupplyPickup(delta)
-- Keep the shields of the dummies charged.
target_dummy_1:setShields(300)
target_dummy_2:setShields(300)
if target_dummy_1:isValid() then target_dummy_1:setShields(300) end
if target_dummy_2:isValid() then target_dummy_2:setShields(300) end

if not supply_drop:isValid() then
shipyard_gamma:sendCommsMessage(
Expand All @@ -371,10 +371,11 @@ end

function phase1ScanDummyShips(delta)
-- Keep the shields of the dummies charged. (Note, at this point, you could destroy them with nukes, which is why we keep the shields at 300)
target_dummy_1:setShields(300)
target_dummy_2:setShields(300)
if target_dummy_1:isValid() then target_dummy_1:setShields(300) end
if target_dummy_2:isValid() then target_dummy_2:setShields(300) end

if target_dummy_1:isScannedBy(player) and target_dummy_2:isScannedBy(player) then
if (not target_dummy_1:isValid() or target_dummy_1:isScannedBy(player))
and (not target_dummy_2:isValid() or target_dummy_2:isScannedBy(player)) then
shipyard_gamma:sendCommsMessage(
player,
_("station-incCall", [[Perfect, Atlantis-1. They identify as Kraylor ships because we put fake IDs in them.
Expand All @@ -384,8 +385,8 @@ Destroy Dummy-1 with your beam weapons, and use a homing missile to take out Dum
The shields of Dummy-2 are configured so that your beam weapons will not penetrate them.]])
)
mission_state = phase1DestroyDummyShips
target_dummy_1:setShieldsMax(30)
target_dummy_2:setShieldsMax(30)
if target_dummy_1:isValid() then target_dummy_1:setShieldsMax(30) end
if target_dummy_2:isValid() then target_dummy_2:setShieldsMax(30) end
player:addReputationPoints(5)
end
end
Expand Down
25 changes: 21 additions & 4 deletions scripts/scenario_31_payload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,11 @@ end

function SafeAttackRandom(ship, shipList, changeTarget)
local changeTarget = changeTarget or false
-- An empty list made shipList[irandom(1, 0)] nil and SafeOrder raised.
-- Callers read false as "keep formation".
if #shipList == 0 then
return false
end
local randomEnemy = shipList[irandom(1, #shipList)]
return SafeOrder(ship, randomEnemy, "Attack", changeTarget)
end
Expand Down Expand Up @@ -692,10 +697,14 @@ end
--

function CheckWinCondition()
if PayloadShip:isDocked(FactionStation) then
victory("Kraylor")
elseif PayloadShip:isDocked(KraylorStation) then
victory("Human Navy")
-- A destroyed PayloadShip has no methods: isDocked below raised "attempt to
-- call a nil value" and stopped update(). Test validity first.
if PayloadShip:isValid() then
if PayloadShip:isDocked(FactionStation) then
victory("Kraylor")
elseif PayloadShip:isDocked(KraylorStation) then
victory("Human Navy")
end
end
if not (Player:isValid()
and PayloadShip:isValid()
Expand All @@ -713,6 +722,10 @@ end

-- Update the Payload's target based on proximities and scan status
function DeterminePayloadTarget()
-- A destroyed PayloadShip has no getPosition: CheckPayloadControl raised.
if PayloadShip == nil or not PayloadShip:isValid() then
return
end
local oldTarget = PayloadShip.target
local inControl, ourCount, oppositionCount = CheckPayloadControl(PayloadShip, "Human Navy", "Kraylor")

Expand Down Expand Up @@ -831,6 +844,10 @@ end

-- Function to handle Payload movement
function HandlePayloadMovement()
-- A destroyed PayloadShip has no getOrder.
if PayloadShip == nil or not PayloadShip:isValid() then
return
end
local currentOrder = PayloadShip:getOrder()
if PayloadShip.target == nil then
if currentOrder ~= "Idle" then
Expand Down
2 changes: 2 additions & 0 deletions scripts/scenario_44_outpost.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6186,6 +6186,7 @@ function enemyComms(comms_data)
comms_target.original_target = original_target
end
comms_target.taunt_may_expire = true --change to conditional in future refactoring
if enemy_reverts == nil then enemy_reverts = {} end
table.insert(enemy_reverts,comms_target)
end
comms_target:orderAttack(comms_source) --consider alternative options besides attack in future refactoring
Expand Down Expand Up @@ -6230,6 +6231,7 @@ function enemyComms(comms_data)
--print(original_target:getCallSign())
comms_target.original_target = original_target
end
if enemy_reverts == nil then enemy_reverts = {} end
table.insert(enemy_reverts,comms_target)
end
comms_target.amenability_may_expire = true --set up conditional in future refactoring
Expand Down
18 changes: 13 additions & 5 deletions scripts/scenario_50_gaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,11 @@ end
-- Transport ship generation and handling
function nearStations(station, compareStationList)
remainingStations = {}
if compareStationList[1]:isValid() then
if compareStationList[1] ~= nil and compareStationList[1]:isValid() then
if station:getCallSign() ~= compareStationList[1]:getCallSign() then
closest = compareStationList[1]
else
if compareStationList[2]:isValid() then
if compareStationList[2] ~= nil and compareStationList[2]:isValid() then
closest = compareStationList[2]
end
end
Expand Down Expand Up @@ -1586,7 +1586,11 @@ function neutralComms()
setCommsMessage(_("trade-comms", "Yes?"))
-- Offer destination information
addCommsReply(_("trade-comms", "Where are you headed?"), function()
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
addCommsReply(_("Back"), commsShip)
end)
-- Offer to trade goods if goods or equipment freighter
Expand Down Expand Up @@ -1686,7 +1690,11 @@ function neutralComms()
if not comms_source:takeReputationPoints(destRep) then
setCommsMessage(_("needRep-comms", "Insufficient reputation"))
else
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
end
addCommsReply(_("Back"), commsShip)
end)
Expand Down Expand Up @@ -3157,7 +3165,7 @@ function waves(delta)
end
end
end
if homeStation:areEnemiesInRange(2000) then
if homeStation:isValid() and homeStation:areEnemiesInRange(2000) then
wakeEnemyFleet = homeStation:getObjectsInRange(2000)
for _, enemy in ipairs(wakeEnemyFleet) do
if enemy:isEnemy(homeStation) then
Expand Down
14 changes: 11 additions & 3 deletions scripts/scenario_55_defenderHunter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3375,7 +3375,11 @@ function neutralComms()
setCommsMessage(_("trade-comms", "Yes?"))
-- Offer destination information
addCommsReply(_("trade-comms", "Where are you headed?"), function()
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
addCommsReply(_("Back"), commsShip)
end)
-- Offer to trade goods if goods or equipment freighter
Expand Down Expand Up @@ -3452,7 +3456,11 @@ function neutralComms()
if not comms_source:takeReputationPoints(destRep) then
setCommsMessage(_("needRep-comms", "Insufficient reputation"))
else
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
end
addCommsReply(_("Back"), commsShip)
end)
Expand Down Expand Up @@ -6226,7 +6234,7 @@ function endStatistics()
survivedNeutralStations = 0
for idx, station in pairs(originalStationList) do
tp = getPlayerShip(-1)
if tp ~= nil and tp:isValid() then
if tp ~= nil and tp:isValid() and station:isValid() then
if station:isFriendly(tp) then
if station:isValid() then
survivedStations = survivedStations + 1
Expand Down
37 changes: 31 additions & 6 deletions scripts/scenario_57_shoreline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8348,6 +8348,7 @@ function neutralFriendlyFreighterComms()
end
end
function friendlyFreighterComms()
local shipType = comms_target:getTypeName()
if comms_source.interaction == nil then
comms_source.interaction = {}
end
Expand Down Expand Up @@ -8400,7 +8401,11 @@ function friendlyFreighterComms()
end)
-- Offer destination information
addCommsReply(_("trade-comms", "Where are you headed?"), function()
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
addCommsReply(_("Back"), altShipComms)
end)
-- Offer to trade goods if goods or equipment freighter
Expand Down Expand Up @@ -8480,7 +8485,11 @@ function friendlyFreighterComms()
if not comms_source:takeReputationPoints(destRep) then
setCommsMessage(_("needRep-comms", "Insufficient reputation"))
else
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
end
addCommsReply(_("Back"), altShipComms)
end)
Expand Down Expand Up @@ -8717,7 +8726,11 @@ function friendlyComms(comms_data)
end)
-- Offer destination information
addCommsReply(_("trade-comms", "Where are you headed?"), function()
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
addCommsReply(_("Back"), altShipComms)
end)
-- Offer to trade goods if goods or equipment freighter
Expand Down Expand Up @@ -8797,7 +8810,11 @@ function friendlyComms(comms_data)
if not comms_source:takeReputationPoints(destRep) then
setCommsMessage(_("needRep-comms", "Insufficient reputation"))
else
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
end
addCommsReply(_("Back"), altShipComms)
end)
Expand Down Expand Up @@ -9214,7 +9231,11 @@ function neutralComms(comms_data)
end)
-- Offer destination information
addCommsReply(_("trade-comms", "Where are you headed?"), function()
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
addCommsReply(_("Back"), altShipComms)
end)
-- Offer to trade goods if goods or equipment freighter
Expand Down Expand Up @@ -9294,7 +9315,11 @@ function neutralComms(comms_data)
if not comms_source:takeReputationPoints(destRep) then
setCommsMessage(_("needRep-comms", "Insufficient reputation"))
else
setCommsMessage(comms_target.target:getCallSign())
if comms_target.target ~= nil and comms_target.target:isValid() then
setCommsMessage(comms_target.target:getCallSign())
else
setCommsMessage(_("shipAssist-comms", "I no longer have a destination."))
end
end
addCommsReply(_("Back"), altShipComms)
end)
Expand Down
Loading