--created by Hoshi, coded by Lyris local s,id=GetID() function s.initial_effect(c) c:SetUniqueOnField(1,0,id) aux.AddCodeList(c,id-1) local e1=Effect.CreateEffect(c) e1:SetDescription(1109) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_HAND) e1:SetCountLimit(1,id) e1:SetCost(s.cost) e1:SetTarget(s.target) e1:SetOperation(s.operation) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_REMOVE) e2:SetRange(LOCATION_HAND+LOCATION_GRAVE) e2:SetCountLimit(1,id+100) e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_EQUIP) e2:SetCondition(function(e,tp,eg) return eg:IsExists(s.cfilter,1,nil,tp) end) e2:SetTarget(s.sptg) e2:SetOperation(s.spop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_MZONE) e3:SetDescription(1102) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetCategory(CATEGORY_REMOVE) e3:SetLabelObject(c) e3:SetTarget(s.rmtg) e3:SetOperation(s.rmop) local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_GRANT) e4:SetRange(LOCATION_SZONE) e4:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE) e4:SetTarget(s.tg) e4:SetLabelObject(e3) c:RegisterEffect(e4) end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsDiscardable() end Duel.SendtoGrave(c,REASON_COST+REASON_DISCARD) end function s.filter(c) return c:IsCode(id-1) and (c:IsLocation(LOCATION_DECK) and c:IsAbleToHand() or (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsAbleToDeck()) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_REMOVED,LOCATION_REMOVED,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_REMOVED) end function s.operation(e,tp,eg,ep,ev,re,r,rp,chk) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local tg=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.filter),tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_REMOVED,LOCATION_REMOVED,1,1,nil):GetFirst() if tg and tg:IsLocation(LOCATION_DECK) then Duel.SendtoHand(tg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tg) elseif tg then Duel.SendtoDeck(tg,nil,2,REASON_EFFECT) end end function s.cfilter(c,tp) return c:IsFaceup() and c:GetPreviousCodeOnField()==id-1 and c:IsPreviousLocation(LOCATION_ONFIELD) and c:GetPreviousControler()==tp end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_REMOVED) Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0) if e:GetHandler():IsLocation(LOCATION_GRAVE) then Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,e:GetHandler(),1,0,0) end if Duel.IsPlayerAffectedByEffect(tp,id+13) then Duel.SetChainLimit(function(e,rpr,p) return rpr==p end) end end function s.spfilter(c,e,tp) return c:IsFaceup() and c:IsCode(id-1) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) or Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 or Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tc=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_REMOVED,LOCATION_REMOVED,1,1,nil,e,tp):GetFirst() if tc and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)~=0 then if not Duel.Equip(tp,c,tc) then return end local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_EQUIP_LIMIT) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD) e1:SetValue(function(ef,cc) return tc==cc end) c:RegisterEffect(e1) end end function s.tg(e,c) return c==e:GetHandler():GetEquipTarget() and c:IsCode(id-1) end function s.rmtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() and chkc:IsAbleToRemove() end local c=e:GetLabelObject() if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToRemove,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) and c:GetFlagEffect(id)==0 end c:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END,0,1) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) Duel.SetOperationInfo(0,CATEGORY_REMOVE,Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil),1,0,0) end function s.rmop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Remove(tc,POS_FACEUP,REASON_EFFECT) end end