From de86dd4a438ebe2b9c3d9c95997d309e0434a2d8 Mon Sep 17 00:00:00 2001 From: Pithlit Date: Wed, 17 Jul 2024 14:50:13 +0200 Subject: [PATCH] scenario fixes. Locust range: 3u --- scripts-piglit/plots/wh_artifacts.lua | 21 +++++++++++++++++---- scripts-piglit/plots/wh_locusts.lua | 23 +++++++++++++++-------- scripts-piglit/plots/wh_terrain.lua | 10 +++++++--- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/scripts-piglit/plots/wh_artifacts.lua b/scripts-piglit/plots/wh_artifacts.lua index cd6e8197f..6127fcdcc 100644 --- a/scripts-piglit/plots/wh_artifacts.lua +++ b/scripts-piglit/plots/wh_artifacts.lua @@ -6,18 +6,27 @@ wh_artifacts = {} function wh_artifacts:init() self.callsign_counter = 1000 + self.artifacts_total = 0 + self.artifacts_collected = 0 + self.artifacts_destroyed = 0 + self.artifacts_delivered = 0 self.strategic_db = ScienceDatabase():setName("Strategic Information"):setLongDescription("Ships of the fleet can gather strategic information by collecting artifacts or completing missions. When a ship with strategic information docks with the fleet command station, the strategic information gets uploaded to all ship databases.") end function wh_artifacts:placeArtifact(x,y,name,info) - if name ~= nil and name.type == "table" and info == nil then + if name ~= nil and type(name) == "table" and info == nil then name, info = name[1], name[2] end local freq = math.floor(random(20, 40)) * 20 self.callsign_counter = self.callsign_counter + math.floor(random(1,200)) local callsign = self.callsign_counter - debris = Artifact():setPosition(x, y):setDescriptions(_("A piece of space junk. Scan to find out the capturing frequency"), name.._("\nCapturing frequency:").." "..freq.. ".\nCalibrate your shields to this frequency and activate them to capture it.") + local debris = Artifact():setPosition(x, y) + if name ~= nil then + debris:setDescriptions(_(nane..". Scan to find out the capturing frequency"), name.._("\nCapturing frequency:").." "..freq.. ".\nCalibrate your shields to this frequency and activate them to capture it.") + else + debris:setDescriptions(_("A piece of space junk. Scan to find out the capturing frequency"), _("\nCapturing frequency:").." "..freq.. ".\nCalibrate your shields to this frequency and activate them to capture it.") + end debris:setScanningParameters(4, 1) debris.freq=freq if freq < 595 then @@ -26,11 +35,11 @@ function wh_artifacts:placeArtifact(x,y,name,info) debris:setModel("debris-blob") end debris:allowPickup(true) - debris:setCallSign(callsign):setRadarTraceColor(255,235,170) + debris:setCallSign(callsign):setRadarTraceColor(96,128,255) if name ~= nil then debris.resource_name = name debris.info_collected = "Collected "..name.."." - debris.info_destroyed = name .. " was destroyed.\n\nTo collect artifacts you need to have shields active and calibrated to the capturing frequency of the artifact." + debris.info_destroyed = name .. " was destroyed.\nTo collect artifacts you need to have shields active and calibrated to the capturing frequency of the artifact." if info ~= nil then debris.resource_descr = info debris.info_collected = debris.info_collected .. "\n\n"..info.."\n\nDeliver it to the fleet command station to upload strategic information for the fleet.\nEach recovered artifact can be used to upgrade the fleet command station." @@ -53,6 +62,7 @@ function wh_artifacts:placeArtifact(x,y,name,info) player:setResourceCategory(art.resource_name, "Strategic Information") player:setResourceDescription(art.resource_name, art.resource_descr) end + self.artifacts_collected = self.artifacts_collected + 1 player:addCustomMessage("science", "artifact_gathered", art.info_collected) player:addCustomMessage("operations", "artifact_gathered", art.info_collected) player:addCustomMessage("single", "artifact_gathered", art.info_collected) @@ -60,12 +70,14 @@ function wh_artifacts:placeArtifact(x,y,name,info) else ExplosionEffect():setPosition(ax,ay):setSize(200) player:takeDamage(50, "kinetic", ax, ay) + self.artifacts_destroyed = self.artifacts_destroyed + 1 player:addCustomMessage("science", "artifact_destroyed", art.info_destroyed) player:addCustomMessage("operations", "artifact_destroyed", art.info_destroyed) player:addCustomMessage("single", "artifact_destroyed", art.info_destroyed) player:addToShipLog(art.info_destroyed, "magenta") end end) + self.artifacts_total = self.artifacts_total + 1 return debris end @@ -75,6 +87,7 @@ function wh_artifacts:transferArtifacts(ps, fc) -- both must be already verified and should be docked local arts = ps:getResourceAmount("Artifacts") if arts > 0 then + self.artifacts_delivered = self.artifacts_delivered + arts local msg = tostring(arts) .. " Artifact" if arts > 1 then msg = msg.."s" diff --git a/scripts-piglit/plots/wh_locusts.lua b/scripts-piglit/plots/wh_locusts.lua index 65f052217..ef4bb111d 100644 --- a/scripts-piglit/plots/wh_locusts.lua +++ b/scripts-piglit/plots/wh_locusts.lua @@ -16,8 +16,8 @@ function wh_locusts:init() -- Artifacts (dropped by the first kills; from the end to the beginning of the table) self.arts_first = { - {"logbook of derelict light cruiser 'Indiskretion'", "Those Ktlitan locusts look like drones. They're very fast. Individually, they should be easy to handle. As a group, they could be a problem.'"}, - {"logbook of derelict scout 'Nudelsuppe'", "'Our sensors have picked up approximately one hundred and fifty Ktlitan ships. The computer calls them locusts. We will approach one.'"}, + {"Logbook of derelict light cruiser 'Indiskretion'", "Those Ktlitan locusts look like drones. They're very fast. Individually, they should be easy to handle. As a group, they could be a problem.'"}, + {"Logbook of derelict scout 'Nudelsuppe'", "'Our sensors have picked up approximately one hundred and fifty Ktlitan ships. The computer calls them locusts. We will approach one.'"}, } -- Artifacts dropped by leaders self.arts_leader= { @@ -209,13 +209,15 @@ function wh_locusts:init() ship:setRotationMaxSpeed(30) ship:setScanningParameters(1,1) ship:orderStandGround() + ship.fight = false ship:onTakingDamage(function(self, instigator) -- Arc Dir Range Cycle time Damage self:setBeamWeapon(0, 40, 0, 600, 4 + random(-1,1), 6 + random(-1,1)) self:setRotationMaxSpeed(15 + random(-2,2)) + self.fight = true end) ship:onDestruction(function(self, instigator) - if instigator.type == "PlayerSpaceship" then + if instigator ~= nil and instigator:isValid() and instigator.typeName == "PlayerSpaceship" then local artifact = table.remove(wh_locusts.arts_first) if artifact ~= nil then local x,y = self:getPosition() @@ -235,7 +237,7 @@ end -- trigger in turn 2 function wh_locusts.trigger_gather_swarm() wh_locusts.swarm_gather = "ready" - removeGMFunction("trigger swarm") + removeGMFunction("locusts swarm") table.insert(self.arts_first, 0, {"locust movement analysis", "All the Ktlitans on our sensors have started moving. They seem to be converging on a central location."} ) @@ -248,7 +250,7 @@ function wh_locusts.trigger_modify_behaviour() ship:setAI("default") end end - removeGMFunction("modify locusts") + removeGMFunction("locusts modify") end -- TODO currently unused @@ -383,7 +385,7 @@ function wh_locusts:createFormation() if self.lead_ship ~= nil and self.lead_ship:isValid() then self.lead_ship:orderRoaming():setImpulseMaxSpeed(110):setRotationMaxSpeed(20) self.lead_ship:onDestruction(function(self, instigator) - if instigator.typeName == "PlayerSpaceship" then + if instigator ~= nil and instigator:isValid() and instigator.typeName == "PlayerSpaceship" then local artifact = table.remove(wh_locusts.arts_leader) if artifact ~= nil then local x,y = self:getPosition() @@ -410,8 +412,13 @@ function wh_locusts:updateSwarm() if #self.swarm_ships > 0 then for i,ship in ipairs(self.swarm_ships) do if ship ~= nil and ship:isValid() then - if ship:areEnemiesInRange(5000) then - ship:orderRoaming() + if ship:areEnemiesInRange(3000) then + if ship.fight == false then + ship:orderRoaming() -- calling this every tick results in strange behaviour. + -- after taking damage they fall back to fighterAI + end + else + ship.fight = false end else self.swarm_ships[i] = self.swarm_ships[#self.swarm_ships] diff --git a/scripts-piglit/plots/wh_terrain.lua b/scripts-piglit/plots/wh_terrain.lua index 43fa5c29d..94b629ec2 100644 --- a/scripts-piglit/plots/wh_terrain.lua +++ b/scripts-piglit/plots/wh_terrain.lua @@ -43,9 +43,12 @@ function wh_terrain:init() {typ = "Asteroid", siz = 1000}, } repeat - local dist = random(2000,50000) + random(2000,50000) + random(2000,50000) + local dist = random(6000,50000) -- avoid wormhole path if dist < 25000 or dist > 35000 then + if dist > 35000 then + dist = dist + random(0,50000) + random(0,50000) + end local ox, oy = vectorFromAngle(random(0,360), dist) ox = ox + center_x oy = oy + center_y @@ -88,6 +91,7 @@ function wh_terrain:init() end until(common_scattered_objects > 100) + print("Terrain: "..wh_artifacts.artifacts_total.." Artifacts placed") getScriptStorage().wh_terrain = self end @@ -121,7 +125,7 @@ function wh_terrain:placeAsteroidBlob(x,y,field_radius, artifact) local angle = random(0,360) size = random(10,400) + random(10,400) local asteroid_space = (base_asteroid:getSize() + size)*random(1.05,1.25) - nax, nay = vectorFromAngleNorth(angle,asteroid_space) + nax, nay = vectorFromAngle(angle,asteroid_space) nax = nax + bax nay = nay + bay for i,asteroid in ipairs(asteroid_list) do @@ -168,7 +172,7 @@ function wh_terrain:placeMinefieldBlob(x,y,mine_blob_radius,artifact) local base_mine = mine_list[base_mine_index] local bmx, bmy = base_mine:getPosition() local angle = random(0,360) - nmx, nmy = vectorFromAngleNorth(angle,mine_space) + nmx, nmy = vectorFromAngle(angle,mine_space) nmx = nmx + bmx nmy = nmy + bmy for i, mine in ipairs(mine_list) do