Permalink
Browse files

Merge pull request #112 from sprunk/patch-8

ezmorph won't choose locked morphs
  • Loading branch information...
ForbodingAngel committed Jan 24, 2019
2 parents 3a5844f + c537def commit d01c5c113a06c74e84815f763850aa62bc2d3b1f
Showing with 11 additions and 4 deletions.
  1. +11 −4 LuaRules/Gadgets/unit_morph.lua
@@ -1069,12 +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 then
StartMorph(unitID, unitDefID, teamID, morphDef)
break
if (not targetDefID or morphDef.into == targetDefID)
and MorphRequirementsFulfilled(unitID, morphDef, teamTechLevel[teamID] or 0, TechReqList(teamID, morphDef.require)) then
validMorphs[#validMorphs+1] = morphDef
end
end

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

return true, true
end

@@ -1445,4 +1452,4 @@ end
end
--------------------------------------------------------------------------------
-- COMMON
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

0 comments on commit d01c5c1

Please sign in to comment.