--Destruction Driven Barrel Dragon --scripted by Rawstone local s,id=GetID() function s.initial_effect(c) --synchro summon aux.AddSynchroProcedure(c,aux.FilterBoolFunction(Card.IsAttribute,ATTRIBUTE_DARK),aux.NonTuner(Card.IsRace,RACE_MACHINE),1) c:EnableReviveLimit() --Destroy & Coin Flip local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_DESTROY+CATEGORY_COIN+CATEGORY_REMOVE) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id) e1:SetRange(LOCATION_MZONE) e1:SetTarget(s.trg) e1:SetOperation(s.cop) c:RegisterEffect(e1) --recover coin flip local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_TOHAND) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET) e2:SetCode(EVENT_TO_GRAVE) e2:SetCountLimit(1,id+500) e2:SetCondition(s.drcon) e2:SetTarget(s.drtg) e2:SetOperation(s.drop) c:RegisterEffect(e2) end c40006.toss_coin=true function s.trg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetMatchingGroup(nil,tp,LOCATION_ONFIELD,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_COIN,nil,0,tp,3) Duel.SetOperationInfo(0,CATEGORY_DESTROY,nil,0,tp,1) Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,1-tp,LOCATION_GRAVE) end function s.cop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(nil,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,0,1,nil) if g:GetCount()==0 then return end local c1,c2,c3=Duel.TossCoin(tp,3) local ct=c1+c2+c3 if ct==0 then return end if ct>g:GetCount() then ct=g:GetCount() end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local dg=g:Select(tp,1,ct,nil) Duel.HintSelection(dg) Duel.Destroy(dg,REASON_EFFECT) if c1+c2+c3==3 then if Duel.GetMatchingGroupCount(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,0,1-tp,nil)<=0 then return end if Duel.SelectYesNo(tp,aux.Stringid(40006,1)) then Duel.BreakEffect() local cg=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,0,1-tp,nil) if cg:IsExists(Card.IsAbleToRemove,1,1-tp) then Duel.Remove(cg,POS_FACEDOWN,REASON_EFFECT) end end end end function s.drcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsPreviousLocation(LOCATION_MZONE) and c:IsSummonType(SUMMON_TYPE_SYNCHRO) end function s.filter(c) return c.toss_coin and c:IsAbleToHand() and c:IsLevelBelow(7) and not c:IsCode(40006) end function s.drtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(s.filter,tp,LOCATION_GRAVE,0,1,1,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,s.filter,tp,LOCATION_GRAVE,0,1,1,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,g:GetCount(),0,0) end function s.drop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) end end