--Flibbertybungus local cid,id=GetID() function cid.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHAINING) e1:SetCondition(cid.discon) e1:SetTarget(cid.distg) e1:SetOperation(cid.disop) c:RegisterEffect(e1) --set local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_GRAVE) e2:SetCountLimit(1,id) e2:SetCondition(cid.setcon) e2:SetOperation(cid.setop) c:RegisterEffect(e2) --act in set turn local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN) e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE) e3:SetCondition(cid.actcon) c:RegisterEffect(e3) if not cid.global_check then cid.global_check=true local ge1=Effect.CreateEffect(c) ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge1:SetCode(EVENT_SSET) ge1:SetOperation(cid.checkop) Duel.RegisterEffect(ge1,0) end end function cid.negfilter(c) return c:IsFacedown() end function cid.discon(e,tp,eg,ep,ev,re,r,rp) return rp==1-tp and Duel.IsChainNegatable(ev) end function cid.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingTarget(cid.negfilter,tp,LOCATION_MZONE,0,3,nil) end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0) end end function cid.disop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.SelectMatchingCard(tp,cid.negfilter,tp,LOCATION_MZONE,0,1,1,nil) local tc=g:GetFirst() local pos=Duel.SelectPosition(tp,tc,POS_FACEUP) if tc then Duel.ChangePosition(tc,pos) if tc:IsSetCard(ARCHE_FLIBBERTY) and Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then Duel.Destroy(eg,REASON_EFFECT) end end end function cid.filter(c) return c:IsSetCard(ARCHE_FLIBBERTY) and c:IsFaceup() end function cid.filter2(c) return c:IsSetCard(ARCHE_FLIBBERTY) and c:IsFaceup() and c:IsCanTurnSet() end function cid.setcon(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(cid.filter,tp,LOCATION_MZONE,0,2,nil) end function cid.settg(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 cid.setop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.IsExistingMatchingCard(cid.filter2,tp,LOCATION_MZONE,0,1,nil) then local g=Duel.SelectMatchingCard(tp,cid.filter,tp,LOCATION_MZONE,0,1,1,nil) local pos=Duel.SelectPosition(tp,g:GetFirst(),POS_FACEDOWN_DEFENSE) if g:GetCount()>0 and Duel.ChangePosition(g:GetFirst(),pos)~=0 then Duel.SSet(tp,c) end end end function cid.actcon(e) return e:GetHandler():GetFlagEffect(id)>0 end function cid.checkop(e,tp,eg,ep,ev,re,r,rp) if not re or not re:GetHandler():IsSetCard(ARCHE_FLIBBERTY) or re:GetHandler():IsCode(id) then return end local tc=eg:GetFirst() while tc do tc:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END,0,1) tc=eg:GetNext() end end