beyond-all-reason / Beyond-All-Reason

Main game repository for Beyond All Reason.
https://www.beyondallreason.info/
Other
1.74k stars 290 forks source link

Subs are constructed under the ground most of the time #274

Open Sipke82 opened 3 years ago

Sipke82 commented 3 years ago

image at the red arrow a sub is under construction. this happens for quite some maps when the water is not deep enough.

icexuick commented 3 years ago

Yes correct. Still need a fix.

KyleAnthonyShepherd commented 1 year ago

Bumping, as I think this is still an issue. image

SethDGamre commented 3 weeks ago

tried fixing through gadget. Sub will momentarily be set to the position I want, then immediately revert back to its prior depth.

`if not gadgetHandler:IsSyncedCode() then return end

function gadget:GetInfo() return { name = "Factory UW Depth", desc = "Fixes submarines being built below ground underwater", author = "Floris", date = "September 2020", license = "GNU GPL, v2 or later", layer = 0, enabled = true } end

--anything with a waterline greater than this is considered a submarine local waterlineThreshold = 30

--tables local isUnderwaterFactory = {} local isSubmarine = {}

for unitDefID, unitDef in pairs(UnitDefs) do

if unitDef.waterline and unitDef.waterline >= waterlineThreshold then
    if unitDef.isFactory and #unitDef.buildOptions > 0 then
        isUnderwaterFactory[unitDefID] = unitDef.minWaterDepth or waterlineThreshold
    elseif unitDef.speed and unitDef.speed > 0 then
        isSubmarine[unitDefID] = true
    end
end

end

local function getUnitPositionHeight(unitID) -- returns nil for invalid units if (Spring.GetUnitIsDead(unitID) ~= false) or (Spring.ValidUnitID(unitID) ~= true) then return nil, nil, nil end local posX, posY, posZ = Spring.GetUnitPosition(unitID) if posX and posY and posZ then return posX, posY, posZ else return nil, nil, nil end end

function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) if isUnderwaterFactory[Spring.GetUnitDefID(builderID)] and isSubmarine[unitDefID] then local fPosX, fPosY, fPosZ = getUnitPositionHeight(builderID) if fPosX then Spring.MoveCtrl.Enable(unitID) Spring.MoveCtrl.SetNoBlocking(unitID, true) --Spring.MoveCtrl.SetProgressState(unit, "active") Spring.MoveCtrl.SetPosition(unitID, fPosX, isUnderwaterFactory[Spring.GetUnitDefID(builderID)], fPosZ) end end end

function gadget:UnitFinished(unitID, unitDefID, unitTeam) if isSubmarine[unitDefID] then Spring.MoveCtrl.Disable(unitID) end end `

issue persists. Must be done in engine or elsewhere, not gadget