--Liafina, Wisprit Knight local cid,id=GetID() function cid.initial_effect(c) --search local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_HANDES+CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetCost(cid.thcost) e1:SetTarget(cid.thtg) e1:SetOperation(cid.thop) c:RegisterEffect(e1) --tograve local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_TOGRAVE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_REMOVE) e2:SetCountLimit(1,id) e2:SetCondition(cid.tgcon) e2:SetTarget(cid.tgtg) e2:SetOperation(cid.tgop) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EVENT_TO_GRAVE) e3:SetCondition(cid.tgcon1) c:RegisterEffect(e3) --gain local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e4:SetCode(EVENT_BE_MATERIAL) e4:SetCondition(cid.mtcon) e4:SetOperation(cid.mtop) c:RegisterEffect(e4) end --filters function cid.costfilter(c) return bit.band(c:GetType(),0x82)==0x82 and not c:IsPublic() end function cid.thfilter(c) return (c:IsAttack(1850) or c:IsDefense(1850)) and c:IsRace(RACE_FAIRY) and c:IsAbleToHand() end function cid.tgfilter(c) return c:IsSetCard(0x26c) and c:IsAbleToGrave() end function cid.cfilter(c) return c:IsRace(RACE_FAIRY) and c:IsAbleToRemoveAsCost() end --search function cid.thcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.costfilter,tp,LOCATION_HAND,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM) local g=Duel.SelectMatchingCard(tp,cid.costfilter,tp,LOCATION_HAND,0,1,1,nil) Duel.ConfirmCards(1-tp,g) Duel.ShuffleHand(tp) end function cid.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)>0 and Duel.IsExistingMatchingCard(cid.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function cid.thop(e,tp,eg,ep,ev,re,r,rp) if Duel.DiscardHand(tp,nil,1,1,REASON_EFFECT+REASON_DISCARD)>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cid.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 end --tograve function cid.tgcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsPreviousLocation(LOCATION_GRAVE) end function cid.tgcon1(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return (c:IsReason(REASON_EFFECT) and not re:GetHandler():IsCode(id)) end function cid.tgtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.tgfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK) end function cid.tgop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,cid.tgfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoGrave(g,REASON_EFFECT) end end --gain function cid.mtcon(e,tp,eg,ep,ev,re,r,rp) return r==REASON_RITUAL end function cid.mtop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local g=eg:Filter(Card.IsSetCard,nil,0x26c) local rc=g:GetFirst() if not rc then return end local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,2)) e1:SetProperty(EFFECT_FLAG_CLIENT_HINT) e1:SetCategory(CATEGORY_NEGATE+CATEGORY_REMOVE) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_CHAINING) e1:SetRange(LOCATION_MZONE) e1:SetCondition(cid.discon) e1:SetCost(cid.discost) e1:SetTarget(cid.distg) e1:SetOperation(cid.disop) rc:RegisterEffect(e1,true) if not rc:IsType(TYPE_EFFECT) then local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_ADD_TYPE) e3:SetValue(TYPE_EFFECT) e3:SetReset(RESET_EVENT+RESETS_STANDARD) rc:RegisterEffect(e3,true) end rc:RegisterFlagEffect(0,RESET_EVENT+RESETS_STANDARD,EFFECT_FLAG_CLIENT_HINT,1,0,aux.Stringid(id,2)) end function cid.discon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return not c:IsStatus(STATUS_BATTLE_DESTROYED) and ep==1-tp and re:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ev) and re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) and Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) and Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS):IsContains(c) end function cid.discost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.cfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,cid.cfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end function cid.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return aux.nbcon(tp,re) end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_REMOVE,eg,1,0,0) end end function cid.disop(e,tp,eg,ep,ev,re,r,rp) if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then Duel.Remove(eg,POS_FACEUP,REASON_EFFECT) end end