--Mondoassillo Cappa || Worldsbane Cloak --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) c:EnableReviveLimit() aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsRace,RACE_REPTILE),4,2) --activate Field Spell local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,0)) e3:SetCategory(CATEGORY_LEAVE_GRAVE) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_SPSUMMON_SUCCESS) e3:SetProperty(EFFECT_FLAG_DELAY) e3:SetCondition(s.accon) e3:SetTarget(s.acttg) e3:SetOperation(s.actop) c:RegisterEffect(e3) --set local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,1)) e4:SetCategory(CATEGORY_LEAVE_GRAVE) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET) e4:SetCode(EVENT_TO_GRAVE) e4:SetCondition(s.setcon) e4:SetTarget(s.settg) e4:SetOperation(s.setop) c:RegisterEffect(e4) end --activate Field Spell function s.accon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ) end function s.actfilter(c,tp) return c:IsCode(23151811) and c:GetActivateEffect():IsActivatable(tp,true,true) end function s.acttg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.actfilter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil,tp) end end function s.actop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_OPERATECARD) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.actfilter),tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil,tp) local tc=g:GetFirst() if tc then local te=tc:GetActivateEffect() local fc=Duel.GetFieldCard(tp,LOCATION_FZONE,0) if fc then Duel.SendtoGrave(fc,REASON_RULE) Duel.BreakEffect() end Duel.MoveToField(tc,tp,tp,LOCATION_FZONE,POS_FACEUP,true) te:UseCountLimit(tp,1,true) local tep=tc:GetControler() local cost=te:GetCost() if cost then cost(te,tep,eg,ep,ev,re,r,rp,1) end Duel.RaiseEvent(tc,4179255,te,0,tp,tp,Duel.GetCurrentChain()) end end --set function s.setcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsPreviousLocation(LOCATION_ONFIELD) and c:GetOverlayCount()>0 end function s.ssfilter(c,e,tp,eg,ep,ev,re,r,rp) return c:IsSetCard(0x9fa) and (c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable() or c:IsType(TYPE_PANDEMONIUM) and aux.PandeSSetCon(c,tp)(nil,e,tp,eg,ep,ev,re,r,rp)) end function s.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.ssfilter(chkc) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingTarget(s.ssfilter,tp,LOCATION_GRAVE,0,1,nil) end local ct=math.min(Duel.GetLocationCount(tp,LOCATION_SZONE),e:GetHandler():GetOverlayCount()) local g=Duel.SelectTarget(tp,aux.NecroValleyFilter(s.ssfilter),tp,LOCATION_GRAVE,0,1,ct,nil) Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,g,#g,0,0) end function s.ffilter(c) return c:IsLocation(LOCATION_SZONE) and c:IsFacedown() end function s.setop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) if not g or #g==0 or Duel.GetLocationCount(tp,LOCATION_SZONE)<#g then return end aux.PandSSet(g,REASON_EFFECT)(e,tp,eg,ep,ev,re,r,rp) local fg=g:Filter(s.ffilter,nil) if #fg>0 then Duel.ConfirmCards(1-tp,fg) end end