--Solar Markshall --Scripted by: XGlitchy30 local cid,id=GetID() function cid.initial_effect(c) --pandemonium aux.AddOrigPandemoniumType(c) --activate local p1=Effect.CreateEffect(c) p1:GLString(0) p1:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) p1:SetType(EFFECT_TYPE_QUICK_O) p1:SetCode(EVENT_FREE_CHAIN) p1:SetRange(LOCATION_SZONE) p1:SetCondition(cid.actcon) p1:SetTarget(cid.acttg) p1:SetOperation(cid.actop) c:RegisterEffect(p1) --change effect local p2=Effect.CreateEffect(c) p2:GLString(1) p2:SetType(EFFECT_TYPE_QUICK_O) p2:SetCode(EVENT_CHAINING) p2:SetRange(LOCATION_SZONE) p2:SetCountLimit(1,id) p2:SetCondition(cid.discon) p2:SetCost(cid.discost) p2:SetOperation(cid.disop) c:RegisterEffect(p2) aux.EnablePandemoniumAttribute(c,p1) --MONSTER EFFECTS --search local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,2)) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetCountLimit(1,id+100) e1:SetTarget(cid.thtg) e1:SetOperation(cid.thop) c:RegisterEffect(e1) local e1x=e1:Clone() e1x:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e1x) --set local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,3)) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_DESTROYED) e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e2:SetCountLimit(1,id+200) e2:SetCondition(cid.setcon) e2:SetTarget(cid.settg) e2:SetOperation(cid.setop) c:RegisterEffect(e2) end --ACTIVATE function cid.actcon(e,tp,eg,ep,ev,re,r,rp) return e:IsHasType(EFFECT_TYPE_ACTIVATE) and aux.PandActCheck(e) end function cid.tdfilter(c) return c:IsFaceup() and c:IsSetCard(0x7a4) and c:IsAbleToDeck() end function cid.acttg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.IsExistingMatchingCard(cid.tdfilter,tp,LOCATION_REMOVED,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,tp,LOCATION_REMOVED) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function cid.actop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectMatchingCard(tp,cid.tdfilter,tp,LOCATION_REMOVED,0,1,1,nil) if g:GetCount()>0 and Duel.SendtoDeck(g,nil,1,REASON_EFFECT)~=0 and g:IsExists(Card.IsLocation,1,nil,LOCATION_DECK+LOCATION_EXTRA) then if g:IsExists(Card.IsLocation,1,nil,LOCATION_DECK) then Duel.ShuffleDeck(tp) end Duel.Draw(tp,1,REASON_EFFECT) end end --CHANGE EFFECT function cid.filter0(c,e) return c:IsCanBeFusionMaterial() and not c:IsImmuneToEffect(e) and (c:IsLocation(LOCATION_PZONE) or (c:IsFaceup() and c:GetFlagEffect(EFFECT_PANDEMONIUM)>0)) end function cid.filter1(c,e) return not c:IsImmuneToEffect(e) end function cid.filter2(c,e,tp,m,f,chkf) return c:IsType(TYPE_FUSION) and c:IsType(TYPE_PANDEMONIUM) and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf) end function cid.repop(e,tp,eg,ep,ev,re,r,rp) local chkf=tp local mg1=Duel.GetFusionMaterial(tp):Filter(cid.filter1,nil,e) mg1:Merge(Duel.GetMatchingGroup(cid.filter0,tp,LOCATION_PZONE+LOCATION_SZONE,LOCATION_PZONE+LOCATION_SZONE,nil,e)) local sg1=Duel.GetMatchingGroup(cid.filter2,tp,LOCATION_EXTRA,LOCATION_EXTRA,nil,e,tp,mg1,nil,chkf) local mg2=nil local sg2=nil local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() mg2=fgroup(ce,e,tp) local mf=ce:GetValue() sg2=Duel.GetMatchingGroup(cid.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf) end local check=false if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then local sg=sg1:Clone() if sg2 then sg:Merge(sg2) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=sg:Select(tp,1,1,nil) local tc=tg:GetFirst() if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf) tc:SetMaterial(mat1) Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.BreakEffect() if Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)~=0 then check=true end else local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf) local fop=ce:GetOperation() fop(ce,e,tp,tc,mat2) end tc:CompleteProcedure() end if not check then Duel.Damage(tp,1000,REASON_EFFECT) end end function cid.discon(e,tp,eg,ep,ev,re,r,rp) local rc=re:GetHandler() return rc~=e:GetHandler() and re:IsActiveType(TYPE_TRAP) and aux.PandActCheck(e) end function cid.rvfilter(c) return c:IsType(TYPE_MONSTER) and c:IsType(TYPE_FUSION) and c:IsType(TYPE_PANDEMONIUM) and c:IsFacedown() end function cid.discost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.rvfilter,tp,LOCATION_EXTRA,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM) local g=Duel.SelectMatchingCard(tp,cid.rvfilter,tp,LOCATION_EXTRA,0,1,1,nil) Duel.ConfirmCards(1-tp,g) end function cid.disop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Group.CreateGroup() Duel.ChangeTargetCard(ev,g) Duel.ChangeChainOperation(ev,cid.repop) end --SEARCH function cid.thfilter(c) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x7a4) and c:IsRace(RACE_MACHINE) and c:IsAbleToHand() and (not c:IsLocation(LOCATION_EXTRA) or c:IsFaceup()) end function cid.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.thfilter,tp,LOCATION_DECK+LOCATION_EXTRA,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_EXTRA) end function cid.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cid.thfilter,tp,LOCATION_DECK+LOCATION_EXTRA,0,1,1,nil) if #g>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end --SET function cid.setcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_EFFECT) and re and (re:GetHandler():IsSetCard(0x7a4) or re:IsActiveType(TYPE_SPELL+TYPE_TRAP)) end function cid.setfilter(c) return c:IsSetCard(0x7a4) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable() end function cid.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.setfilter,tp,LOCATION_DECK,0,1,nil) end end function cid.setop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET) local g=Duel.SelectMatchingCard(tp,cid.setfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SSet(tp,g:GetFirst()) end end