-- Possessed Skull function c123364.initial_effect(c) --search local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetTarget(c123364.thtg) e1:SetOperation(c123364.thop) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,123364+EFFECT_COUNT_CODE_SINGLE) e2:SetCost(c123364.spcost) e2:SetTarget(c123364.sptg) e2:SetOperation(c123364.spop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_TO_GRAVE) e3:SetRange(LOCATION_GRAVE) e3:SetCountLimit(1,123364+EFFECT_COUNT_CODE_SINGLE) e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e3:SetCondition(c123364.condition2) e3:SetTarget(c123364.target2) e3:SetOperation(c123364.operation2) c:RegisterEffect(e3) end function c123364.thfilter(c) return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand() and c:IsCode(27827272) or c:IsCode(155240) or c:IsCode(155245) end function c123364.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c123364.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c123364.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c123364.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 function c123364.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsReleasable() end Duel.Release(e:GetHandler(),REASON_COST) end function c123364.spfilter(c,e,tp) return c:IsCode(70781052) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c123364.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.IsExistingMatchingCard(c123364.spfilter,tp,LOCATION_GRAVE+LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE+LOCATION_DECK) end function c123364.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c123364.spfilter,tp,LOCATION_GRAVE+LOCATION_DECK,0,1,1,nil,e,tp) if g:GetCount()>0 and not g:GetFirst():IsHasEffect(EFFECT_NECRO_VALLEY) then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end function c123364.cfilter(c,tp) return c:IsCode(70781052) and c:IsControler(tp) and c:IsPreviousLocation(LOCATION_ONFIELD) end function c123364.condition2(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c123364.cfilter,1,nil,tp) end function c123364.target2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c123364.operation2(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)>0 then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+0x47e0000) e1:SetValue(LOCATION_REMOVED) c:RegisterEffect(e1,true) end end