--[[ Viravolve Pervading Animal Viravolve Animale Pervasivo Original Script by: Lyris Rescripted by: XGlitchy30 ]] local s,id=GetID() function s.initial_effect(c) --xyz summon c:EnableReviveLimit() aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsRace,RACE_CYBERSE),1,3) --negate local e2=Effect.CreateEffect(c) e2:Desc(0) e2:SetCategory(CATEGORY_DESTROY|CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_BE_BATTLE_TARGET) e2:SetRange(LOCATION_MZONE) e2:HOPT() e2:SetCondition(s.descon) e2:SetCost(s.descost) e2:SetTarget(s.destg) e2:SetOperation(s.operation) c:RegisterEffect(e2) local e3=e2:Clone() e3:Desc(1) e3:SetCategory(CATEGORY_DESTROY|CATEGORY_SPECIAL_SUMMON|CATEGORY_DISABLE) e3:SetCode(EVENT_CHAINING) e3:SetCondition(s.descon2) e3:SetTarget(s.destg2) e3:SetOperation(s.operation2) c:RegisterEffect(e3) end function s.descon(e,tp,eg,ep,ev,re,r,rp) local d=Duel.GetAttackTarget() return d and d==e:GetHandler() end function s.descon2(e,tp,eg,ep,ev,re,r,rp) if rp~=1-tp or not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) or not Duel.IsChainDisablable(ev) then return false end local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) return g and g:IsContains(e:GetHandler()) end function s.descost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function s.filter(c,e,tp) return c:IsCode(id) and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0 and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) end function s.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local rc=Duel.GetAttacker() Duel.SetTargetCard(rc) if rc:IsRelateToBattle() then Duel.SetOperationInfo(0,CATEGORY_DESTROY,rc,1,0,0) end Duel.SetPossibleOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.destg2(e,tp,eg,ep,ev,re,r,rp,chk) local rc=re:GetHandler() if chk==0 then return not rc:IsDisabled() end Duel.SetOperationInfo(0,CATEGORY_DISABLE,eg,1,0,0) if rc:IsDestructable() and rc:IsRelateToChain(ev) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0) end Duel.SetPossibleOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToBattle() and Duel.NegateAttack() and Duel.Destroy(tc,REASON_EFFECT)~=0 and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_EXTRA,0,1,nil,e,tp) and aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_XMATERIAL) and Duel.SelectYesNo(tp,STRING_ASK_SPSUMMON) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp) if #g>0 then local sc=g:GetFirst() sc:SetMaterial(nil) if Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)~=0 then sc:CompleteProcedure() end end end end function s.operation2(e,tp,eg,ep,ev,re,r,rp) local tc=re:GetHandler() if Duel.NegateEffect(ev) and tc:IsRelateToChain(ev) and Duel.Destroy(tc,REASON_EFFECT)~=0 and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_EXTRA,0,1,nil,e,tp) and aux.MustMaterialCheck(nil,tp,EFFECT_MUST_BE_XMATERIAL) and Duel.SelectYesNo(tp,STRING_ASK_SPSUMMON) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp) if #g>0 then local sc=g:GetFirst() sc:SetMaterial(nil) if Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)~=0 then sc:CompleteProcedure() end end end end