Hello, I use an custom variant of pickup archer to merge two units into one. But it doesnt work with summoned units. How can I convert a summoned unit into a ''normal'' unit so I can merge them?
I tried darkconversion but it makes the target lose its abilities.
I had this exact same problem, the solution I ended up using is fairly complicated.
Since the archer ability didn't work (in my case, I also had the problem that the two units I was trying to merge were of the same type, which also didn't work, although in hindsight my problem might have also been that they were summoned rather than regular units), I went for a trigger-based workaround. When one summoned unit used a dummy ability to merge with another summoned unit, I first checked if the two units were valid (since the dummy ability could be used to target anything) and if they were, I killed then both and then used a dummy caster to summon the merged unit (instead of just creating the new unit, in which case it wouldn't count as a summoned unit and wouldn't have an expiration timer). I ended up coding the whole thing in vJass, so it might be useless to you:
private function SpellEffect takes nothing returns nothing
local integer id = GetUnitTypeId(SpellEvent.CastingUnit)
local real x=0.5*(GetUnitX(SpellEvent.CastingUnit)+GetUnitX(SpellEvent.TargetUnit))
local real y=0.5*(GetUnitY(SpellEvent.CastingUnit)+GetUnitY(SpellEvent.TargetUnit))
if id==ELEMENTAL_LEVEL1 then
set caster.level=1
elseif id==ELEMENTAL_LEVEL2 then
set caster.level=2
elseif id==ELEMENTAL_LEVEL3 then
set caster.level=3
endif
set caster.owningplayer=GetOwningPlayer(SpellEvent.CastingUnit)
call UnitRemoveBuffs(SpellEvent.CastingUnit, true, true)
call UnitRemoveBuffs(SpellEvent.TargetUnit, true, true)
call caster.castInPoint(x,y)
endfunction
private function UnitTypeCheck takes nothing returns boolean
local integer id = GetUnitTypeId(GetOrderedUnit())
return (id==ELEMENTAL_LEVEL1 or id==ELEMENTAL_LEVEL2 or id==ELEMENTAL_LEVEL3)
endfunction
private function Order takes nothing returns nothing
local unit s = GetOrderedUnit()
local integer id = GetUnitTypeId(GetOrderTargetUnit())
if GetIssuedOrderId()==OrderId("smart") then
if (id==ELEMENTAL_LEVEL1 or id==ELEMENTAL_LEVEL2 or id==ELEMENTAL_LEVEL3) then
if not IsUnitPaused(s) then
// call PauseUnit(s, true)
call IssueTargetOrder(s, MERGE_ORDER, GetOrderTargetUnit())
// call PauseUnit(s, false)
endif
call BJDebugMsg("SpellOrder")
endif
elseif GetIssuedOrderId()==OrderId(MERGE_ORDER) then
if not(id==ELEMENTAL_LEVEL1 or id==ELEMENTAL_LEVEL2 or id==ELEMENTAL_LEVEL3) then
if not IsUnitPaused(s) then
call PauseUnit(s, true)
call IssueImmediateOrder(s, "stop")
call PauseUnit(s, false)
endif
call BJDebugMsg("CancelOrder")
endif
endif
set s=null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
call TriggerAddCondition(t, Condition(function UnitTypeCheck))
call TriggerAddAction( t, function Order )