From 26a4dc1d8f656b6d193b7bf70f3911668c8c6e01 Mon Sep 17 00:00:00 2001 From: Pithlit Date: Thu, 22 Aug 2024 20:28:13 +0200 Subject: [PATCH] scenarios: bugfixes --- scripts-piglit/plots/wh_reputation.lua | 2 +- scripts-piglit/scenario_00_basic.lua | 13 +++++++------ scripts-piglit/scenario_20_training1.lua | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts-piglit/plots/wh_reputation.lua b/scripts-piglit/plots/wh_reputation.lua index c456bdc19..531c7a976 100644 --- a/scripts-piglit/plots/wh_reputation.lua +++ b/scripts-piglit/plots/wh_reputation.lua @@ -10,7 +10,7 @@ function wh_reputation:requestReputation() local player = getPlayerShip(-1) player:addReputationPoints(amount) --]] - self.done == true + self.done = true end end diff --git a/scripts-piglit/scenario_00_basic.lua b/scripts-piglit/scenario_00_basic.lua index 7f429fe4b..3284bbd15 100644 --- a/scripts-piglit/scenario_00_basic.lua +++ b/scripts-piglit/scenario_00_basic.lua @@ -32,6 +32,7 @@ require("utils.lua") -- Returns the bearing between first object/coordinate and second object/coordinate. require("plots/wh_reputation.lua") +require("plots/wh_artifacts.lua") -- Global variables for this scenario local enemyList @@ -40,8 +41,6 @@ local stationList local playerList local addWavesToGMPosition -- If set to true, add wave will require GM to click on the map to position, where the wave should be spawned. local startEnemyCount = nil -local lastReportedProgress -local lastReportedTime local gametimeleft = nil -- Maximum game time in seconds. local timewarning = nil -- Used for checking when to give a warning, and to update it so the warning happens once. @@ -303,7 +302,7 @@ end --- Initialize scenario. function init() - + wh_artifacts:init() --[[ -- Spawn a player Atlantis. player = PlayerSpaceship():setFaction("Human Navy"):setTemplate(getScenarioSetting("PlayerShip")) @@ -317,8 +316,6 @@ function init() friendlyList = {} stationList = {} playerList = {} - lastReportedProgress = 0 - lastReportedTime = 0 onNewPlayerShip(function(ship) table.insert(playerList, ship) @@ -553,8 +550,12 @@ function update(delta) local player_count = countValid(playerList) if startEnemyCount == nil then startEnemyCount = enemy_count + lastEnemyCount = enemy_count end - sendProgressToCampaignServer(enemy_count, startEnemyCount) + if lastEnemyCount ~= enemy_count then + lastEnemyCount = enemy_count + sendProgressToCampaignServer(startEnemyCount - enemy_count, startEnemyCount) + end -- If not playing the Empty variation, declare victory for the -- Humans (players) once all enemies are destroyed. Note that players can win diff --git a/scripts-piglit/scenario_20_training1.lua b/scripts-piglit/scenario_20_training1.lua index 8c1543a50..758420b42 100644 --- a/scripts-piglit/scenario_20_training1.lua +++ b/scripts-piglit/scenario_20_training1.lua @@ -144,13 +144,13 @@ function finished(delta) name = "Exuari warp drive", description = "Some Exuari ships are equipped with a warp drive. They use it to ambush their targets or to escape from a sector with valuable cargo.", } - sendMessageToCampaignServer("artifact", toJson(artDetails)) + sendMessageToCampaignServer("artifact", toJSON(artDetails)) else bonusString = bonusString .. _("msgMainscreen-bonusTarget"," Artifact was destroyed.") end end globalMessage(string.format(_("msgMainscreen", [[Mission Complete. -Your Time: %d +Your Time: %s Bonus target %s]]), formatTime(timer), bonusString)) end end