--祈愿流星雨 local m=40009941 local cm=_G["c"..m] function cm.initial_effect(c) --change name aux.EnableChangeCode(c,40009938,LOCATION_HAND+LOCATION_DECK+LOCATION_FZONE+LOCATION_GRAVE+LOCATION_ONFIELD+LOCATION_OVERLAY+LOCATION_PZONE+LOCATION_REMOVED) --to hand local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(m,0)) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH+CATEGORY_HANDES) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_REMOVE) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetCondition(cm.thcon) e1:SetTarget(cm.thtg) e1:SetOperation(cm.thop) c:RegisterEffect(e1) --search local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(m,1)) e2:SetCategory(CATEGORY_TOGRAVE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_MOVE) e2:SetCondition(cm.tgcon) e2:SetTarget(cm.tgtg) e2:SetOperation(cm.tgop) c:RegisterEffect(e2) end function cm.Foreigner(c) local m=_G["c"..c:GetCode()] return m and m.named_with_Foreigner end function cm.thcon(e,tp,eg,ep,ev,re,r,rp) local tc=re:GetHandler() if e:GetHandler():IsReason(REASON_COST) and re:IsActivated() and re:IsActiveType(TYPE_MONSTER) and cm.Foreigner(tc) then e:SetLabel(1) end return e:GetHandler():IsReason(REASON_COST) and re:IsActivated() and (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) end function cm.spfilter(c,e,tp) return cm.Foreigner(c) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cm.thfilter(c) return cm.Foreigner(c) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() end function cm.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(nil,tp,LOCATION_HAND,0,1,e:GetHandler()) and Duel.IsExistingMatchingCard(cm.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function cm.thop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if Duel.DiscardHand(tp,nil,1,1,REASON_EFFECT+REASON_DISCARD,nil)>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cm.thfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 and Duel.SendtoHand(g,nil,REASON_EFFECT)~=0 and Duel.IsExistingMatchingCard(cm.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) and e:GetLabel()==1 and (Duel.GetFlagEffect(tp,m)==0 or Duel.GetFlagEffect(tp,m-1)==0 or Duel.GetFlagEffect(tp,m-2)==0 or Duel.GetFlagEffect(tp,m-3)==0) then Duel.ConfirmCards(1-tp,g) Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=Duel.SelectMatchingCard(tp,cm.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP) Duel.RegisterFlagEffect(tp,m,RESET_PHASE+PHASE_END,0,1) end end end function cm.tgcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsPreviousLocation(LOCATION_REMOVED) and e:GetHandler():IsLocation(LOCATION_GRAVE) end function cm.tgtg(e,tp,eg,ep,ev,re,r,rp,chk) local g=Duel.GetMatchingGroup(Card.IsAbleToGrave,tp,0,LOCATION_ONFIELD,nil) if chk==0 then return #g>0 end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0) end function cm.tgop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsAbleToGrave,tp,0,LOCATION_ONFIELD,nil) if #g>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local sg=g:Select(tp,1,1,nil) Duel.HintSelection(sg) Duel.SendtoGrave(sg,REASON_EFFECT) end end