--Tuskikage the Vanishing Nijna function c249000297.initial_effect(c) --remove local e1=Effect.CreateEffect(c) e1:SetDescription(1102) e1:SetCategory(CATEGORY_REMOVE) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetRange(LOCATION_MZONE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,2490002971) e1:SetCost(c249000297.rmcost) e1:SetTarget(c249000297.rmtg) e1:SetOperation(c249000297.rmop) c:RegisterEffect(e1) --random to hand local e3=Effect.CreateEffect(c) e3:SetDescription(1001) e3:SetCategory(CATEGORY_TOHAND) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetRange(LOCATION_MZONE) e3:SetCode(EVENT_FREE_CHAIN) e3:SetCountLimit(2,2490002972) e3:SetTarget(c249000297.target) e3:SetOperation(c249000297.operation) c:RegisterEffect(e3) end function c249000297.cfilter(c) return c:IsFaceup() and c:IsSetCard(0x61) and c:IsAbleToRemoveAsCost() end function c249000297.rmcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c249000297.cfilter,tp,LOCATION_GRAVE,0,2,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c249000297.cfilter,tp,LOCATION_GRAVE,0,2,2,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end function c249000297.rmtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemove() end Duel.SetOperationInfo(0,CATEGORY_REMOVE,e:GetHandler(),1,0,0) end function c249000297.rmop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFaceup() and c:IsRelateToEffect(e) then if Duel.Remove(c,POS_FACEUP,REASON_EFFECT+REASON_TEMPORARY)<1 then return end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_PHASE+PHASE_END) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetLabelObject(c) e1:SetCountLimit(1) e1:SetOperation(c249000297.retop) Duel.RegisterEffect(e1,tp) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_AVOID_BATTLE_DAMAGE) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetTargetRange(1,0) e2:SetReset(RESET_PHASE+PHASE_DAMAGE_CAL+PHASE_END) Duel.RegisterEffect(e2,tp) end end function c249000297.retop(e,tp,eg,ep,ev,re,r,rp) Duel.ReturnToField(e:GetLabelObject()) end function c249000297.filter2(c) return c:IsSetCard(0x61) and c:IsAbleToHand() and (c:IsFaceup() or not c:IsLocation(LOCATION_REMOVED)) end function c249000297.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(aux.NecroValleyFilter(c249000297.filter2),tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_REMOVED,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_REMOVED) end function c249000297.operation(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(aux.NecroValleyFilter(c249000297.filter2),tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_REMOVED,0,nil) local sg=g:RandomSelect(1-tp,1) if sg:GetCount()>0 then Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_TRAP_ACT_IN_HAND) e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x61)) e1:SetTargetRange(LOCATION_HAND,0) e1:SetCountLimit(1,249000297) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) local e2=e1:Clone() e2:SetCode(EFFECT_QP_ACT_IN_NTPHAND) Duel.RegisterEffect(e2,tp) end