--Automate ID local s,id=GetID() function s.initial_effect(c) --Negate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY+CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e1:SetCode(EVENT_CHAINING) e1:SetCondition(s.condition) e1:SetCost(s.cost) e1:SetTarget(s.target) e1:SetOperation(s.operation) e1:SetCountLimit(1,id) c:RegisterEffect(e1) --act in hand local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_TRAP_ACT_IN_HAND) e2:SetCondition(s.handcon) c:RegisterEffect(e2) --salvage local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_TOHAND) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_TO_GRAVE) e2:SetCondition(s.descon) e2:SetTarget(s.thtg) e2:SetOperation(s.thop) e2:SetCountLimit(1,id+1000) c:RegisterEffect(e2) end function s.condition(e,tp,eg,ep,ev,re,r,rp) if tp==ep or not Duel.IsChainNegatable(ev) then return false end local ex,g,gc,dp,dv=Duel.GetOperationInfo(ev,CATEGORY_REMOVE) local loc=LOCATION_HAND+LOCATION_DECK+LOCATION_GRAVE return ex and (dv&loc>0 or g and g:IsExists(Card.IsLocation,1,nil,loc)) end function s.cfilter1(c,tp) return c:IsSetCard(0x301) and not c:IsPublic() and Duel.IsExistingMatchingCard(s.cfilter2,tp,LOCATION_HAND,0,1,nil,tp,c:GetCode()) end function s.cfilter2(c,tp,code) return c:IsSetCard(0x301) and not c:IsPublic() and not c:IsCode(code) end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) local g=Duel.GetMatchingGroup(s.cfilter1,tp,LOCATION_HAND,0,e:GetHandler(),tp) if chk==0 then return g:GetClassCount(Card.GetCode,nil)>=2 end local g1=g:Select(tp,1,1,nil,tp) local g2=g:FilterSelect(tp,s.cfilter2,1,1,nil,tp,g1:GetFirst():GetCode()) g1:Merge(g2) Duel.ConfirmCards(tp,g1) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.IsPlayerCanDraw(1-tp,1) end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsAbleToDeck() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_TODECK,re:GetHandler(),1,0,0) end Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,PLAYER_ALL,1) end function s.operation(e,tp,eg,ep,ev,re,r,rp) local ec=re:GetHandler() if Duel.NegateActivation(ev) and ec:IsRelateToEffect(re) then ec:CancelToGrave() if Duel.SendtoDeck(ec,nil,0,REASON_EFFECT)~=0 and ec:IsLocation(LOCATION_DECK+LOCATION_EXTRA) then if ec:IsLocation(LOCATION_DECK) then Duel.ShuffleDeck(ec:GetControler()) end Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) Duel.Draw(1-tp,1,REASON_EFFECT) end end end function s.cfilter(c) return c:IsFacedown() or not c:IsSetCard(0x301) end function s.handcon(e) return not Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_MZONE,0,1,nil) end function s.descon(e,tp,eg,ep,ev,re,r,rp) return re and re:GetHandler():IsSetCard(0x301) and not re:GetHandler():IsCode(id) end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsSSetable() end Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,e:GetHandler(),1,0,0) end function s.thop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and c:IsSSetable() then Duel.SSet(tp,c) Duel.ConfirmCards(1-tp,c) end end