--EMキャスト・チェンジ function c40933355.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(40933355,0)) e1:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCountLimit(1,40933355) e1:SetCondition(c40933355.condition) e1:SetTarget(c40933355.target) e1:SetOperation(c40933355.operation) c:RegisterEffect(e1) --to hand local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(40933355,1)) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_DESTROYED) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e2:SetCountLimit(1,40933355) e2:SetCondition(c40933355.thcon) e2:SetTarget(c40933355.thtg) e2:SetOperation(c40933355.thop) c:RegisterEffect(e2) --special summon local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(40933355,2)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_PHASE+PHASE_BATTLE) e3:SetRange(LOCATION_MZONE) e3:SetCondition(c40933355.spcon) e3:SetCost(c40933355.spcost) e3:SetTarget(c40933355.sptg) e3:SetOperation(c40933355.spop) c:RegisterEffect(e3) end function c40933355.condition(e,tp,eg,ep,ev,re,r,rp) local st=e:GetHandler():GetSummonType() return st>=(SUMMON_TYPE_SPECIAL+100) and st<(SUMMON_TYPE_SPECIAL+150) end function c40933355.filter(c) return c:IsSetCard(0x19) and c:IsAbleToDeck() end function c40933355.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp) and Duel.IsExistingMatchingCard(c40933355.filter,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetTargetPlayer(tp) Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,tp,LOCATION_GRAVE) end function c40933355.operation(e,tp,eg,ep,ev,re,r,rp) local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER) Duel.Hint(HINT_SELECTMSG,p,HINTMSG_TODECK) local g=Duel.SelectMatchingCard(p,c40933355.filter,p,LOCATION_GRAVE,0,1,2,nil) if g:GetCount()>0 then local ct=Duel.SendtoDeck(g,nil,2,REASON_EFFECT) Duel.ShuffleDeck(p) Duel.BreakEffect() Duel.Draw(p,ct,REASON_EFFECT) end end function c40933355.spcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetBattledGroupCount()>0 end function c40933355.spcost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsAbleToDeckAsCost() end Duel.SendtoDeck(c,nil,2,REASON_COST) end function c40933355.spfilter(c,e,tp) return not c:IsCode(40933355) and c:IsSetCard(0x19) and c:IsCanBeSpecialSummoned(e,102,tp,false,false) end function c40933355.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.IsExistingMatchingCard(c40933355.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function c40933355.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c40933355.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc then Duel.SpecialSummon(tc,102,tp,tp,false,false,POS_FACEUP) tc:RegisterFlagEffect(tc:GetOriginalCode(),RESET_EVENT+0x1ff0000,0,0) end end function c40933355.thcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsReason(REASON_EFFECT) end function c40933355.thfilter(c) return (c:IsSetCard(0x19) or c:IsCode(24285858) or c:IsCode(35224440) or c:IsCode(9780364) or c:IsCode(28877100) or c:IsCode(67223587) or c:IsCode(97234686) or c:IsCode(26834022) or c:IsCode(52228131)) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand() end function c40933355.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c40933355.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c40933355.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c40933355.thfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end