--Spiritual Mistress Miha --Automate ID local s,id=GetID() function s.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,nil,4,2) c:EnableReviveLimit() --replace local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_CHAINING) e1:SetRange(LOCATION_HAND) e1:SetCondition(s.condition) e1:SetCost(s.cost) e1:SetTarget(s.target) e1:SetOperation(s.operation) c:RegisterEffect(e1) end function s.condition(e,tp,eg,ep,ev,re,r,rp) if e==re or not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) if not g or g:GetCount()~=1 then return false end local tc=g:GetFirst() e:SetLabelObject(tc) return tc:IsLocation(LOCATION_GRAVE) 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,re,rp,tf,ceg,cep,cev,cre,cr,crp) return tf(re,rp,ceg,cep,cev,cre,cr,crp,0,c) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local ct=ev local label=Duel.GetFlagEffectLabel(0,id) if label then if ev==bit.rshift(label,16) then ct=bit.band(label,0xffff) end end local ce,cp=Duel.GetChainInfo(ct,CHAININFO_TRIGGERING_EFFECT,CHAININFO_TRIGGERING_PLAYER) local tf=ce:GetTarget() local ceg,cep,cev,cre,cr,crp=Duel.GetChainEvent(ct) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and s.filter(chkc,ce,cp,tf,ceg,cep,cev,cre,cr,crp) end if chk==0 then return Duel.IsExistingTarget(s.filter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,e:GetLabelObject(),ce,cp,tf,ceg,cep,cev,cre,cr,crp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) Duel.SelectTarget(tp,s.filter,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,1,e:GetLabelObject(),ce,cp,tf,ceg,cep,cev,cre,cr,crp) local val=ct+bit.lshift(ev+1,16) if label then Duel.SetFlagEffectLabel(0,id,val) else Duel.RegisterFlagEffect(0,id,RESET_CHAIN,0,1,val) end end function s.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.ChangeTargetCard(ev,Group.FromCards(tc)) end end