--Tri-Brigade Preperations --scripted by Emiliv function c99900203.initial_effect(c) --activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,999000203) e1:SetTarget(c99900203.target) e1:SetOperation(c99900203.activate) c:RegisterEffect(e1) --draw 1 local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(999000203,1)) e2:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_GRAVE) e2:SetCountLimit(1,999000204) e2:SetCost(c99900203.drawCost) e2:SetTarget(c99900203.drtg) e2:SetOperation(c99900203.drop) c:RegisterEffect(e2) end --activate func function c99900203.filter(c,tp) return c:IsAbleToHand() and c:IsSetCard(0x14d) end function c99900203.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then if Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)<3 then return false end local g=Duel.GetDecktopGroup(tp,3) local result=g:FilterCount(Card.IsAbleToHand,nil)>0 return result end Duel.SetTargetPlayer(tp) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,0,LOCATION_DECK) end function c99900203.activate(e,tp,eg,ep,ev,re,r,rp) local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER) Duel.ConfirmDecktop(p,3) local g=Duel.GetDecktopGroup(p,3) if g:GetCount()>0 then if g:IsExists(c99900203.filter,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(999000203,2)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:FilterSelect(tp,c99900203.filter,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) Duel.ShuffleHand(tp) end Duel.ShuffleDeck(tp) end end --draw 1 func function c99900203.drawCost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsAbleToDeckAsCost() end Duel.SendtoDeck(c,nil,SEQ_DECKBOTTOM,REASON_COST) end function c99900203.tdfilter(c,e,tp) return c:IsRace(RACE_BEAST+RACE_BEASTWARRIOR+RACE_WINDBEAST) and c:IsLocation(LOCATION_REMOVED) and c:IsAbleToDeck() end function c99900203.drtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and c99900203.tdfilter(chkc) end if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.IsExistingTarget(c99900203.tdfilter,tp,LOCATION_REMOVED,0,1,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectTarget(tp,c99900203.tdfilter,tp,LOCATION_REMOVED,0,1,1,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_TODECK,g,g:GetCount(),0,0) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c99900203.drop(e,tp,eg,ep,ev,re,r,rp) local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) if #tg==0 then return end Duel.SendtoDeck(tg,nil,SEQ_DECKSHUFFLE,REASON_EFFECT) local g=Duel.GetOperatedGroup() if g:IsExists(Card.IsLocation,1,nil,LOCATION_DECK) then Duel.ShuffleDeck(tp) end local ct=g:FilterCount(Card.IsLocation,nil,LOCATION_DECK+LOCATION_EXTRA) if ct>0 then Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) end end