Permalink
Browse files

ezmorph picks at random

requested by damgam
  • Loading branch information...
sprunk committed Jan 24, 2019
1 parent c41c8ec commit c537defc3bb32cb9309c3f97f5b30c6bd8baf889
Showing with 8 additions and 2 deletions.
  1. +8 −2 LuaRules/Gadgets/unit_morph.lua
@@ -1069,13 +1069,19 @@ local function handleEzMorph(unitID, unitDefID, teamID, targetDefID)
if not morphSet then
return true, true
end

local validMorphs = {}
for morphCmd, morphDef in pairs(morphSet) do
if (not targetDefID or morphDef.into == targetDefID)
and MorphRequirementsFulfilled(unitID, morphDef, teamTechLevel[teamID] or 0, TechReqList(teamID, morphDef.require)) then
StartMorph(unitID, unitDefID, teamID, morphDef)
break
validMorphs[#validMorphs+1] = morphDef
end
end

if #validMorphs > 0 then
StartMorph(unitID, unitDefID, teamID, validMorphs[math.random(1, #validMorphs)])
end

return true, true
end

0 comments on commit c537def

Please sign in to comment.