--Flibbertyjibbit local cid,id=GetID() function cid.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_POSITION) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE) e1:SetTarget(cid.target) e1:SetOperation(cid.activate) c:RegisterEffect(e1) --set local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_LEAVE_FIELD) e2:SetRange(LOCATION_GRAVE) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e2:SetCountLimit(1,id) e2:SetCondition(cid.setcon) e2:SetTarget(cid.settg) 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.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 function cid.posfilter(c) return c:IsFaceup() and c:IsSetCard(ARCHE_FLIBBERTY) and c:IsCanTurnSet() end function cid.posfilter1(c) return c:IsFaceup() and c:IsCanTurnSet() end function cid.filter(c,e) return c:IsRelateToEffect(e) and c:IsLocation(LOCATION_MZONE) end function cid.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end if chk==0 then return Duel.IsExistingTarget(cid.posfilter,tp,LOCATION_MZONE,0,1,nil) and Duel.IsExistingTarget(cid.posfilter1,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_POSCHANGE) local g1=Duel.SelectTarget(tp,cid.posfilter,tp,LOCATION_MZONE,0,1,1,nil) e:SetLabelObject(g1:GetFirst()) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISABLE) local g2=Duel.SelectTarget(tp,cid.posfilter1,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_POSITION,g1,1,0,0) Duel.SetOperationInfo(0,CATEGORY_POSITION,g2,1,0,0) end function cid.activate(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(cid.filter,nil,e) if g:GetCount()>0 and Duel.ChangePosition(g,POS_FACEDOWN_DEFENSE)~=0 and Duel.IsExistingMatchingCard(Card.IsFacedown,tp,LOCATION_MZONE,0,2,nil) and c:IsRelateToEffect(e) and c:IsCanTurnSet() then Duel.BreakEffect() c:CancelToGrave() Duel.ChangePosition(c,POS_FACEDOWN) Duel.RaiseEvent(c,EVENT_SSET,e,REASON_EFFECT,tp,tp,0) end end function cid.setfilter(c,tp) return bit.band(c:GetPreviousTypeOnField(),TYPE_MONSTER)~=0 and c:IsPreviousSetCard(ARCHE_FLIBBERTY) and c:IsPreviousControler(tp) and c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsReason(REASON_EFFECT) and c:GetReasonPlayer()==1-tp end function cid.setcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(cid.setfilter,1,nil,tp) 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) then Duel.SSet(tp,c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN) e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD) c:RegisterEffect(e1) end end