Skip to content
Merged
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
22 changes: 12 additions & 10 deletions LuaRules/Gadgets/unit_model_rescale.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ local INLOS_ACCESS = {inlos = true}

VFS.Include("LuaRules/Utilities/tablefunctions.lua")
local suCopyTable = Spring.Utilities.CopyTable
local spGetUnitDefID = Spring.GetUnitDefID

local rescaleUnitDefIDs = {}
for i = 1, #UnitDefs do
local scale = tonumber(UnitDefs[i].customParams.model_rescale)
if scale and scale ~= 1 and scale > 0 then
rescaleUnitDefIDs[i] = scale
end
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -72,7 +81,8 @@ local function UnitModelRescale(unitID, scale, offset)
if not origPieceTable[unitID] then
origPieceTable[unitID] = {Spring.GetUnitPieceMatrix(unitID, base)}
end

local unitDefID = spGetUnitDefID(unitID)
scale = scale * (rescaleUnitDefIDs[unitDefID] or 1)
SetScale(unitID, base, scale, offset)
end
end
Expand All @@ -89,21 +99,13 @@ end

GG.UnitModelRescale = UnitModelRescale

local rescaleUnitDefIDs = {}
for i = 1, #UnitDefs do
local scale = tonumber(UnitDefs[i].customParams.model_rescale)
if scale and scale ~= 1 and scale > 0 then
rescaleUnitDefIDs[i] = scale
end
end

if next(rescaleUnitDefIDs) then
function gadget:UnitCreated(unitID, unitDefID)
local scale = rescaleUnitDefIDs[unitDefID]
if not scale then
return
end

UnitModelRescale(unitID, scale)
UnitModelRescale(unitID, 1)
end
end
1 change: 0 additions & 1 deletion scripts/obj_artefact.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ end
function script.Create()
Turn(pump2, y_axis, -0.523598776)
Turn(pump3, y_axis, 0.523598776)
GG.UnitModelRescale(unitID, 1.4)
local inactive = Spring.GetUnitIsStunned(unitID)
if not inactive then
StartThread(Initialize)
Expand Down
1 change: 1 addition & 0 deletions units/obj_artefact.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ return { obj_artefact = {
no_xp = 1,
bait_level_target = 1,
very_low_priority_target = 1,
model_rescale = 1.4,
},

explodeAs = [[ESTOR_BUILDINGEX]],
Expand Down