--Broken Planter --Script by: XGlitchy30 local cid,id=GetID() function cid.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:GLString(0) e1:SetCategory(CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH) e1:SetCost(cid.cost) e1:SetTarget(cid.target) e1:SetOperation(cid.activate) c:RegisterEffect(e1) end function cid.filter(c) return bit.band(c:GetOriginalType(),TYPE_MONSTER)~=0 and c:IsAbleToGraveAsCost() and ((c:IsFaceup() and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsType(TYPE_CONTINUOUS)) or c:IsFacedown()) and c:GetSequence()<5 end function cid.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.filter,tp,LOCATION_SZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,cid.filter,tp,LOCATION_SZONE,0,1,1,nil) Duel.SendtoGrave(g,REASON_COST) end function cid.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,2) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(2) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2) end function cid.pfilter(c) return c:IsLocation(LOCATION_HAND) and not c:IsPublic() and c:IsType(TYPE_CONTINUOUS) and c:IsType(TYPE_SPELL+TYPE_TRAP) and not c:IsForbidden() end function cid.activate(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) if Duel.Draw(p,d,REASON_EFFECT)>0 then local dr=Duel.GetOperatedGroup() if dr:IsExists(cid.pfilter,1,nil) and (Duel.GetLocationCount(tp,LOCATION_SZONE)>0 or Duel.GetLocationCount(1-tp,LOCATION_SZONE)>0) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOZONE) local tc=dr:FilterSelect(tp,cid.pfilter,1,1,nil):GetFirst() if not tc then return end Duel.ConfirmCards(1-tp,tc) local opt if Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.GetLocationCount(1-tp,LOCATION_SZONE)>0 then opt=Duel.SelectOption(tp,aux.Stringid(id,1),aux.Stringid(id,2)) elseif Duel.GetLocationCount(tp,LOCATION_SZONE)>0 then opt=0 elseif Duel.GetLocationCount(1-tp,LOCATION_SZONE)>0 then opt=1 end if opt==nil then return end local plist={tp,1-tp} local p=plist[opt] if Duel.MoveToField(tc,tp,p,LOCATION_SZONE,POS_FACEUP,true) then local fid=e:GetHandler():GetFieldID() tc:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END,0,1,fid) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_PHASE+PHASE_END) e1:SetCountLimit(1) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e1:SetLabel(fid) e1:SetLabelObject(tc) e1:SetCondition(cid.drycon) e1:SetOperation(cid.dryop) Duel.RegisterEffect(e1,tp) end end end end function cid.drycon(e,tp,eg,ep,ev,re,r,rp) local tc=e:GetLabelObject() if tc:GetFlagEffectLabel(id)~=e:GetLabel() then e:Reset() return false else return true end end function cid.dryop(e,tp,eg,ep,ev,re,r,rp) Duel.Remove(e:GetLabelObject(),POS_FACEUP,REASON_EFFECT) end