Skip to content

Commit

Permalink
reclaim shards: simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruwetuin committed Mar 19, 2024
1 parent 934c599 commit 67997fb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions luarules/gadgets/fx_reclaim_shards.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ end
local GetFeaturePosition = Spring.GetFeaturePosition
local SpawnCEG = Spring.SpawnCEG
local random = math.random
local abs = math.abs

local cegs = { "reclaimshards1", "reclaimshards2", "reclaimshards3" }
local featureList = {}
Expand All @@ -33,7 +32,7 @@ for featureDefID, featureDef in pairs(FeatureDefs) do
y = math.floor(featureDef.model.maxy * 0.66)
}
if featureList[featureDefID].minX == featureList[featureDefID].maxX or featureList[featureDefID].minZ == featureList[featureDefID].maxZ then
featureList[featureDefID] = nil -- to prevent error: "Empty interval in math.random()" .... DID DIDNT HELP :-(
featureList[featureDefID] = nil
end
end
end
Expand All @@ -52,8 +51,8 @@ function gadget:AllowFeatureBuildStep(builderID, builderTeam, featureID, feature
local params = featureList[featureDefID] or nil
if params then
local x, y, z = GetFeaturePosition(featureID)
x = x - abs(params.minX) + ((abs(params.minX) + abs(params.maxX)) * random())
z = z - abs(params.minZ) + ((abs(params.minZ) + abs(params.maxZ)) * random())
x = x + params.minX + ((-params.minX + params.maxX) * random())
z = z + params.minZ + ((-params.minZ + params.maxZ) * random())
y = y + params.y
cegList[featureID] = { ceg = cegs[random(1, #cegs)], x = x, y = y, z = z }
end
Expand Down

0 comments on commit 67997fb

Please sign in to comment.