--Varia-Mage Draw function c249000763.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCost(c249000763.cost) e1:SetTarget(c249000763.target) e1:SetOperation(c249000763.activate) c:RegisterEffect(e1) --to hand local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_CHAIN_NEGATED) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetRange(LOCATION_GRAVE) e2:SetCondition(c249000763.thcon) e2:SetTarget(c249000763.thtg) e2:SetOperation(c249000763.thop) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EVENT_CUSTOM+249000763) e3:SetCondition(c249000763.thcon2) c:RegisterEffect(e3) end function c249000763.filter(c) return c:IsSetCard(0x1C8) and c:IsDiscardable() end function c249000763.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c249000763.filter,tp,LOCATION_HAND,0,1,nil) end Duel.DiscardHand(tp,c249000763.filter,1,1,REASON_COST+REASON_DISCARD) if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then return end local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_CHAIN_NEGATED) e1:SetLabelObject(e) e1:SetOperation(c249000763.negcheck) e1:SetReset(RESET_CHAIN) Duel.RegisterEffect(e1,tp) end function c249000763.negcheck(e,tp,eg,ep,ev,re,r,rp) local te=e:GetLabelObject() local de,dp=Duel.GetChainInfo(ev,CHAININFO_DISABLE_REASON,CHAININFO_DISABLE_PLAYER) if rp==tp and de and dp==1-tp and re==te then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_CHAIN_END) e1:SetOperation(c249000763.negevent) e1:SetLabelObject(te) Duel.RegisterEffect(e1,tp) end end function c249000763.negevent(e,tp,eg,ep,ev,re,r,rp) local te=e:GetLabelObject() Duel.RaiseEvent(te:GetHandler(),EVENT_CUSTOM+249000763,te,0,tp,tp,0) e:Reset() end function c249000763.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 c249000763.activate(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c249000763.thcon(e,tp,eg,ep,ev,re,r,rp) local de,dp=Duel.GetChainInfo(ev,CHAININFO_DISABLE_REASON,CHAININFO_DISABLE_PLAYER) return rp==tp and de and dp==1-tp and re:IsHasType(EFFECT_TYPE_ACTIVATE) and e:GetHandler()==re:GetHandler() and e:GetHandler():GetReasonEffect()==de end function c249000763.filter2(c) return c:IsSetCard(0x1C8) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() end function c249000763.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c249000763.filter2,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c249000763.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c249000763.filter2,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 function c249000763.thcon2(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c==re:GetHandler() and c:GetReasonEffect()==nil end