--Psychostizia Supporto Specializzato --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkRace,RACE_PSYCHO),2,2,s.lcheck) c:EnableReviveLimit() --cannot be targeted local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetValue(aux.tgoval) c:RegisterEffect(e1) --protection local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e2:SetRange(LOCATION_MZONE) e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE) e2:SetCondition(s.indcon) e2:SetTarget(s.indtg) e2:SetValue(1) c:RegisterEffect(e2) --quick act local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN) e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE) e3:SetRange(LOCATION_MZONE) e3:SetCondition(s.actcon) e3:SetTargetRange(LOCATION_SZONE,0) e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x2c2)) c:RegisterEffect(e3) --set pande local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,0)) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e4:SetCode(EVENT_SPSUMMON_SUCCESS) e4:SetCountLimit(1,id) e4:SetCondition(s.setcon) e4:SetTarget(s.settg) e4:SetOperation(s.setop) c:RegisterEffect(e4) --set trap local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(id,1)) e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e5:SetCode(EVENT_SPSUMMON_SUCCESS) e5:SetProperty(EFFECT_FLAG_DELAY) e5:SetCountLimit(1,id+100) e5:SetRange(LOCATION_MZONE) e5:SetCondition(s.setcon2) e5:SetTarget(s.settg2) e5:SetOperation(s.setop2) c:RegisterEffect(e5) end function s.lcheck(g,lc) return g:IsExists(Card.IsLinkSetCard,1,nil,0x2c2) end function s.cfilter(c) return c:IsFaceup() and c:IsSetCard(0x2c2) and c:IsType(TYPE_MONSTER) end function s.indcon(e) return e:GetHandler():GetLinkedGroup():IsExists(s.cfilter,1,nil) end function s.indtg(e,c) return e:GetHandler()==c or (c:IsRace(RACE_PSYCHO) and e:GetHandler():GetLinkedGroup():IsContains(c)) end function s.actcon(e) return Duel.GetTurnPlayer()==1-e:GetHandlerPlayer() end function s.setcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK) end function s.filter(c) return c:IsSetCard(0x2c2) and (c:IsFaceup() or not c:IsLocation(LOCATION_EXTRA)) and c:IsPandemoniumSSetable() end function s.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK+LOCATION_EXTRA,0,1,nil) end end function s.setop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,1601) local tc=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK+LOCATION_EXTRA,0,1,1,nil):GetFirst() if tc then Duel.PandSSet(tc,e,tp,REASON_EFFECT) end end function s.thcfilter(c,ec) if not c:IsRace(RACE_PSYCHO) then return false end if c:IsLocation(LOCATION_MZONE) then return ec:GetLinkedGroup():IsContains(c) and c:IsFaceup() else return c:IsPreviousPosition(POS_FACEUP) and bit.extract(ec:GetLinkedZone(c:GetPreviousControler()),c:GetPreviousSequence())~=0 end end function s.setcon2(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(s.thcfilter,1,nil,e:GetHandler()) end function s.setfilter(c,chk) return c:IsSetCard(0x2c2) and c:IsType(TYPE_TRAP) and c:IsSSetable(chk) and not c:IsForbidden() end function s.settg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.setfilter,tp,LOCATION_DECK,0,1,nil,true) end end function s.setop2(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET) local g=Duel.SelectMatchingCard(tp,s.setfilter,tp,LOCATION_DECK,0,1,1,nil,false) if g:GetCount()>0 then Duel.SSet(tp,g:GetFirst()) Duel.ConfirmCards(1-tp,g) end end