--Hysteric Ennigmat --Script by XGlitchy30 local cid,id=GetID() function cid.initial_effect(c) --salvage local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetRange(LOCATION_GRAVE) e1:SetCountLimit(1,id) e1:SetCondition(cid.thcon) e1:SetTarget(cid.thtg) e1:SetOperation(cid.thop) c:RegisterEffect(e1) --search local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_HAND) e2:SetCountLimit(1,id+100) e2:SetCost(cid.sharedcost) e2:SetTarget(cid.sctg) e2:SetOperation(cid.scop) c:RegisterEffect(e2) --draw local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,2)) e3:SetCategory(CATEGORY_DRAW+CATEGORY_HANDES) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e3:SetRange(LOCATION_HAND) e3:SetCountLimit(1,id+100) e3:SetCondition(cid.drawcon) e3:SetCost(cid.sharedcost) e3:SetTarget(cid.drawtg) e3:SetOperation(cid.drawop) c:RegisterEffect(e3) end --filters function cid.filter(c,tp) return c:IsType(TYPE_XYZ) and c:IsSetCard(0x2ead) and c:IsControler(tp) and c:IsSummonType(SUMMON_TYPE_XYZ) and c:GetOverlayCount()>=5 end function cid.scfilter(c) return c:IsSetCard(0xead) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) and c:IsAbleToHand() end function cid.cfilter(c) return c:IsFaceup() and c:IsSetCard(0x2ead) and c:IsType(TYPE_MONSTER) and c:IsType(TYPE_XYZ) end --salvage function cid.thcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(cid.filter,1,nil,tp) end function cid.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToHand() end Duel.SetOperationInfo(0,CATEGORY_TOHAND,e:GetHandler(),1,0,0) end function cid.thop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SendtoHand(c,nil,REASON_EFFECT) end end --search function cid.sharedcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsDiscardable() end Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) Duel.SendtoGrave(e:GetHandler(),REASON_COST+REASON_DISCARD) end function cid.sctg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.scfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function cid.scop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cid.scfilter,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 --draw function cid.drawcon(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(cid.cfilter,tp,LOCATION_MZONE,0,1,nil) end function cid.drawtg(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 cid.drawop(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) Duel.ShuffleHand(p) Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) local g=Duel.SelectMatchingCard(p,aux.TRUE,p,LOCATION_HAND,0,1,1,nil):GetFirst() local tg=Duel.GetMatchingGroup(cid.cfilter,p,LOCATION_MZONE,0,nil) if #tg>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local tc=tg:Select(p,1,1,nil) if #tc>0 then Duel.HintSelection(tc) Duel.ConfirmCards(1-p,g) Duel.Overlay(tc:GetFirst(),Group.FromCards(g)) Duel.ShuffleHand(p) end else Duel.DiscardHand(p,nil,1,1,REASON_EFFECT+REASON_DISCARD) end end