--Sorrow from the Dark local s,id=GetID() function s.initial_effect(c) aux.EnableChangeCode(c,CARD_DESPAIR_FROM_THE_DARK,LOCATION_MZONE) --spsum from gy/hand when Despair from the Dark is summoned local GYChk=aux.AddThisCardInGraveAlreadyCheck(c) local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_TRIGGER_O) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetRange(LOCATION_GRAVE|LOCATION_HAND) e1:HOPT() e1:SetLabelObject(GYChk) e1:SetCondition(s.condition) e1:SetTarget(s.target) e1:SetOperation(s.operation) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EVENT_SUMMON_SUCCESS) c:RegisterEffect(e2) local e3=e1:Clone() e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS) c:RegisterEffect(e3) --spsummon local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,1)) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_O) e4:SetCode(EVENT_SPSUMMON_SUCCESS) e4:HOPT() e4:SetTarget(s.sptg) e4:SetOperation(s.spop) c:RegisterEffect(e4) --tohand local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(id,2)) e5:SetCategory(CATEGORY_TOHAND|CATEGORY_SEARCH) e5:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_O) e5:SetProperty(EFFECT_FLAG_DELAY) e5:SetCode(EVENT_TO_GRAVE) e5:HOPT() e5:SetCost(s.thcost) e5:SetTarget(s.thtg) e5:SetOperation(s.thop) c:RegisterEffect(e5) Duel.AddCustomActivityCounter(id,ACTIVITY_SPSUMMON,s.counterfilter) end function s.counterfilter(c) return not c:IsSummonLocation(LOCATION_DECK|LOCATION_GRAVE|LOCATION_HAND) or c:IsRace(RACE_ZOMBIE) end function s.cfilter(c,zone,se) return c:IsFaceup() and c:IsCode(CARD_DESPAIR_FROM_THE_DARK) and (se==nil or c:GetReasonEffect()~=se) end function s.condition(e,tp,eg,ep,ev,re,r,rp) local se=e:GetLabelObject():GetLabelObject() return eg:IsExists(s.cfilter,1,nil,se) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetCardOperationInfo(c,CATEGORY_SPECIAL_SUMMON) end function s.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToChain() then Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end end function s.spfilter(c,e,tp) return c:IsSetCard(ARCHE_FROM_THE_DARK) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP,1-tp) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(1-tp,LOCATION_MZONE,tp)>0 and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local ft=Duel.GetLocationCount(1-tp,LOCATION_MZONE,tp) if ft<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if #g>0 then Duel.SpecialSummon(g,0,tp,1-tp,false,false,POS_FACEUP) end end function s.thfilter(c) return c:IsCode(CARD_DESPAIR_FROM_THE_DARK) and c:IsAbleToHand() end function s.thcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetCustomActivityCount(id,tp,ACTIVITY_SPSUMMON)==0 end Duel.RegisterFlagEffect(tp,id,RESET_CHAIN,0,1) end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK|LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK|LOCATION_GRAVE) end function s.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.thfilter),tp,LOCATION_DECK|LOCATION_GRAVE,0,1,1,nil) if #g>0 then Duel.Search(g,tp) end if e:IsActivated() and Duel.PlayerHasFlagEffect(tp,id) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetTargetRange(1,0) e1:SetReset(RESET_PHASE|PHASE_END) e1:SetTarget(s.splimit) Duel.RegisterEffect(e1,tp) Duel.RegisterHint(tp,id+100,PHASE_END,1,id,3) end end function s.splimit(e,c,sump,sumtype,sumpos,targetp,se) return not c:IsRace(RACE_ZOMBIE) and c:IsLocation(LOCATION_DECK|LOCATION_HAND|LOCATION_GRAVE) end