--Asmitala Roots local m=888031 local cm=_G["c"..m] function cm.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DESTROY+CATEGORY_TOGRAVE+CATEGORY_DRAW) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(cm.target) e1:SetOperation(cm.activate) c:RegisterEffect(e1) local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_TOHAND) e4:SetDescription(aux.Stringid(31423101,0)) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_GRAVE) e4:SetCountLimit(1,m) e4:SetCost(cm.thcost) e4:SetTarget(cm.thtg) e4:SetOperation(cm.thop) c:RegisterEffect(e4) end function cm.desfilter(c) return c:IsFaceup() and c:IsSetCard(0xffa) end function cm.sfilter(c) return c:IsType(TYPE_PENDULUM) and c:IsType(TYPE_RITUAL) and c:IsAbleToGrave() end function cm.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_ONFIELD) and chkc:IsControler(tp) and cm.desfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(cm.desfilter,tp,LOCATION_ONFIELD,0,1,e:GetHandler()) and Duel.IsExistingMatchingCard(cm.sfilter,tp,LOCATION_DECK,0,1,nil) and Duel.IsPlayerCanDraw(tp,2) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g=Duel.SelectTarget(tp,cm.desfilter,tp,LOCATION_ONFIELD,0,1,1,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function cm.activate(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,cm.sfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoGrave(g,REASON_EFFECT) if not g:GetFirst():IsLocation(LOCATION_GRAVE) then return end Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tc) end end end function cm.costfilter(c) return c:IsType(TYPE_PENDULUM) and c:IsSetCard(0xffa) and c:IsAbleToGraveAsCost() and c:IsFaceup() end function cm.thcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cm.costfilter,tp,LOCATION_EXTRA,0,1,nil) end local g=Duel.SelectMatchingCard(tp,cm.costfilter,tp,LOCATION_EXTRA,0,1,1,nil) Duel.SendtoGrave(g,REASON_COST) end function cm.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToHand() end Duel.SetOperationInfo(0,CATEGORY_TOHAND,e:GetHandler(),1,0,0) end function cm.thop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SendtoHand(c,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,c) end end