--created by Dragonecro, coded by Lyris local cid,id=GetID() function cid.initial_effect(c) c:EnableReviveLimit() aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkRace,RACE_MACHINE),2,99,cid.lcheck) local e1=Effect.CreateEffect(c) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_SINGLE_RANGE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetRange(LOCATION_EXTRA) e1:SetCode(EFFECT_SPSUMMON_CONDITION) e1:SetValue(aux.linklimit) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetRange(LOCATION_MZONE) e2:SetValue(cid.val) c:RegisterEffect(e2) local e0=e2:Clone() e0:SetCode(EFFECT_UPDATE_DEFENSE) c:RegisterEffect(e0) local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_SINGLE) e4:SetCode(EFFECT_DIRECT_ATTACK) c:RegisterEffect(e4) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e3:SetRange(LOCATION_MZONE) e3:SetCode(EVENT_PRE_BATTLE_DAMAGE) e3:SetCondition(cid.rdcon) e3:SetOperation(cid.rdop) c:RegisterEffect(e3) local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e5:SetCode(EVENT_SPSUMMON_SUCCESS) e5:SetRange(LOCATION_MZONE) e5:SetCountLimit(1,id) e5:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e5:SetCategory(CATEGORY_SPECIAL_SUMMON) e5:SetCondition(cid.con) e5:SetCost(function(e) e:SetLabel(100) return true end) e5:SetTarget(cid.tg) e5:SetOperation(cid.op) c:RegisterEffect(e5) end function cid.lcheck(g) return g:IsExists(Card.IsLinkSetCard,1,nil,0xff2) end function cid.filter(c) return c:IsRace(RACE_MACHINE) and (c:IsLocation(LOCATION_GRAVE) or c:IsFaceup()) end function cid.val(e,c) return Duel.GetMatchingGroupCount(cid.filter,0,0x14,LOCATION_ONFIELD,nil)*200 end function cid.rdcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return ep~=tp and c==Duel.GetAttacker() and Duel.GetAttackTarget()==nil and c:GetEffectCount(EFFECT_DIRECT_ATTACK)<2 and Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)>0 end function cid.rdop(e,tp,eg,ep,ev,re,r,rp) Duel.ChangeBattleDamage(ep,ev/2) end function cid.cfilter(c,zone) local seq=c:GetSequence() if not c:IsLocation(LOCATION_MZONE) then if c:IsControler(1) then seq=seq+16 end else seq=c:GetPreviousSequence() if c:GetPreviousControler()==1 then seq=seq+16 end end return bit.extract(zone,seq)~=0 end function cid.con(e,tp,eg,ep,ev,re,r,rp) local zone=0 local lg=Duel.GetMatchingGroup(Card.IsType,tp,LOCATION_MZONE,0,nil,TYPE_LINK) for tc in aux.Next(lg) do zone=zone|tc:GetLinkedZone(tp) end return eg:IsExists(cid.cfilter,1,nil,zone) end function cid.tfilter(c,e,tp) local zone=c:GetLinkedZone() local ft=Duel.GetLocationCount(tp,LOCATION_MZONE,tp,LOCATION_REASON_TOFIELD,zone) local g=Duel.GetMatchingGroup(cid.sfilter,tp,LOCATION_GRAVE,0,nil,e,tp,zone) return c:IsType(TYPE_LINK) and ft>0 and g:GetClassCount()>=ft end function cid.sfilter(c,e,tp,zone) return c:IsLevelBelow(4) and c:IsSetCard(0xff2) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP,tp,zone) end function cid.tg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and cid.tfilter(chkc,e,tp) end if chk==0 then if e:GetLabel()~=100 then return false end e:SetLabel(0) return Duel.IsExistingTarget(cid.tfilter,tp,LOCATION_MZONE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) local g=Duel.SelectTarget(tp,cid.tfilter,tp,LOCATION_MZONE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,Duel.GetLocationCount(tp,LOCATION_MZONE,tp,LOCATION_REASON_TOFIELD,g:GetFirst():GetLinkedZone()),tp,LOCATION_GRAVE) end function cid.op(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if not tc:IsRelateToEffect(e) then return end local zone=tc:GetLinkedZone() local ft=Duel.GetLocationCount(tp,LOCATION_MZONE,tp,LOCATION_REASON_TOFIELD,zone) if ft<=0 then return end if Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT) then ft=1 end local g=Duel.GetMatchingGroup(cid.sfilter,tp,LOCATION_GRAVE,0,nil,e,tp,zone) if #g==0 then return end local sg=Group.CreateGroup() for i=1,ft do Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) sg=sg+g:Select(tp,1,1,nil) g:Remove(Card.IsCode,nil,sg:GetFirst():GetCode()) if #g==0 then break end end for tc in aux.Next(sg) do Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP,zone) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e2) end Duel.SpecialSummonComplete() end