--Shadowflame Commander --Design and code by Kindrindra local ref=_G['c'..28915256] function ref.initial_effect(c) --Destroy local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,28915256) e1:SetTarget(ref.thtg) e1:SetOperation(ref.thop) c:RegisterEffect(e1) --Special Summon local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_DESTROY) e2:SetCode(EVENT_LEAVE_FIELD) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_CARD_TARGET) e2:SetCountLimit(1,28915256) e2:SetCondition(ref.descon) e2:SetTarget(ref.destg) e2:SetOperation(ref.desop) c:RegisterEffect(e2) end function ref.thfilter(c) return c:IsSetCard(0x729) and c:IsAbleToHand() end function ref.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(ref.thfilter,tp,LOCATION_DECK,0,2,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,0,LOCATION_DECK) end function ref.thop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsSetCard,tp,LOCATION_DECK,0,nil,0x729) if g:GetClassCount(Card.GetCode)>=2 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM) local sg=g:Select(tp,1,1,nil) g:Remove(Card.IsCode,nil,sg:GetFirst():GetCode()) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM) local sg2=g:Select(tp,1,1,nil) sg:Merge(sg2) Duel.ConfirmCards(1-tp,sg) local tg=sg:Select(1-tp,1,1,nil) local tc=tg:GetFirst() if tc:IsAbleToHand() then Duel.SendtoHand(tc,nil,REASON_EFFECT) sg:RemoveCard(tc) end Duel.SendtoGrave(sg,REASON_EFFECT) end end function ref.descon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsPreviousLocation(LOCATION_MZONE) end function ref.filter(c) return c:IsFaceup() end function ref.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() and ref.filter(chkc) and chkc~=e:GetHandler() end if chk==0 then return Duel.IsExistingTarget(ref.filter,tp,0,LOCATION_ONFIELD,1,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,ref.filter,tp,0,LOCATION_ONFIELD,1,1,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function ref.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end end