--Robot Searching Destroyer --scripted by Rawstone local s,id=GetID() function s.initial_effect(c) --Excavate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH+CATEGORY_COIN) e1:SetDescription(aux.Stringid(id,0)) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id) e1:SetRange(LOCATION_MZONE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTarget(s.trg) e1:SetOperation(s.op) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_FIELD) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetCountLimit(1,id+500) e2:SetRange(LOCATION_MZONE) e2:SetCondition(s.cond) e2:SetTarget(s.target) e2:SetOperation(s.opd) c:RegisterEffect(e2) end function s.trg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>0 end if chk==0 then return ct>0 end Duel.SetTargetPlayer(tp) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,0,LOCATION_DECK) Duel.SetOperationInfo(0,CATEGORY_COIN,nil,0,tp,3) end c40001.toss_coin=true function s.filter3(c,tp) return c.toss_coin and c:IsAbleToHand() end function s.op(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(s.filter,tp,LOCATION_DECK,LOCATION_DECK,nil) if g:GetCount()==0 then return end local c1,c2,c3=Duel.TossCoin(tp,3) local ct=c1+c2+c3+3 if ct>g:GetCount() then ct=g:GetCount() end local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER) Duel.ConfirmDecktop(p,ct) local g=Duel.GetDecktopGroup(p,ct) if g:GetCount()>0 and g:IsExists(s.filter3,1,nil) and Duel.SelectYesNo(p,aux.Stringid(40001,0)) then Duel.Hint(HINT_SELECTMSG,p,HINTMSG_ATOHAND) local sg=g:FilterSelect(p,s.filter3,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-p,sg) Duel.ShuffleHand(p) end Duel.ShuffleDeck(p) end function s.filt(c,tp) return c:IsAttribute(ATTRIBUTE_DARK) and c:IsRace(RACE_MACHINE) end function s.cond(e,tp,eg,ep,ev,re,r,rp) return not eg:IsContains(e:GetHandler()) and eg:IsExists(s.filt,1,nil,tp) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function s.opd(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetFieldGroup(tp,LOCATION_ONFIELD,LOCATION_ONFIELD) if g:GetCount()>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local sg=g:Select(tp,1,1,nil) Duel.HintSelection(sg) Duel.Destroy(sg,REASON_EFFECT) end end