--Psychostizia Investigazione --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) c:EnableCounterPermit(0x2c2) --activate aux.ActivateST(c) --add counter local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e0:SetCode(EVENT_CHAINING) e0:SetRange(LOCATION_SZONE) e0:SetOperation(aux.chainreg) c:RegisterEffect(e0) local e0x=Effect.CreateEffect(c) e0x:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e0x:SetCode(EVENT_CHAIN_SOLVED) e0x:SetRange(LOCATION_SZONE) e0x:SetOperation(s.acop) c:RegisterEffect(e0x) --ss local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetRange(LOCATION_SZONE) e1:SetCountLimit(1,id) e1:SetLabel(2) e1:SetCost(s.cost) e1:SetTarget(s.sptg) e1:SetOperation(s.spop) c:RegisterEffect(e1) --set local e2=e1:Clone() e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(0) e2:SetLabel(4) e2:SetTarget(s.settg) e2:SetOperation(s.setop) c:RegisterEffect(e2) --set local e3=e1:Clone() e3:SetDescription(aux.Stringid(id,2)) e3:SetCategory(0) e3:SetLabel(6) e3:SetTarget(s.pltg) e3:SetOperation(s.plop) c:RegisterEffect(e3) end function s.acop(e,tp,eg,ep,ev,re,r,rp) if re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:IsActiveType(TYPE_TRAP) and e:GetHandler():GetFlagEffect(1)>0 then e:GetHandler():AddCounter(0x2c2,1) end end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) local ct=e:GetLabel() if chk==0 then return Duel.IsCanRemoveCounter(tp,1,0,0x2c2,ct,REASON_COST) end Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) Duel.RemoveCounter(tp,1,0,0x2c2,ct,REASON_COST) end function s.spfilter1(c,e,tp) return c:IsSetCard(0x2c2) and c:IsType(TYPE_MONSTER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and (not c:IsLocation(LOCATION_EXTRA) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 or c:IsLocation(LOCATION_EXTRA) and c:IsFaceup() and Duel.GetLocationCountFromEx(tp,tp,nil,c)>0) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.spfilter1,tp,LOCATION_HAND+LOCATION_EXTRA,0,1,nil,e,tp) end local loc=LOCATION_EXTRA if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then loc=loc+LOCATION_HAND end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,loc) end function s.spop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tc=Duel.SelectMatchingCard(tp,s.spfilter1,tp,LOCATION_HAND+LOCATION_EXTRA,0,1,1,nil,e,tp):GetFirst() if tc then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) end end function s.setfilter(c) if c:IsForbidden() then return false end if not c:IsSetCard(0x2c2) or not c:IsType(TYPE_PANDEMONIUM+TYPE_TRAP) then return false end if c:IsType(TYPE_TRAP) then return c:IsSSetable(false) elseif c:IsType(TYPE_PANDEMONIUM) then return c:IsPandemoniumSSetable() end return false 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.setfilter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil,e,tp,eg,ep,ev,re,r,rp) end end function s.setop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 or not e:GetHandler():IsRelateToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.setfilter),tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil) if #g<=0 then return end local tc=g:GetFirst() if tc then if tc:IsType(TYPE_PANDEMONIUM) then Duel.PandSSet(tc,e,tp,REASON_EFFECT) else Duel.SSet(tp,tc) end end end function s.plfilter(c,e,tp,eg,ep,ev,re,r,rp) if not c:IsSetCard(0x2c2) or not c:IsType(TYPE_PANDEMONIUM) then return false end return (c:IsFaceup() or not c:IsLocation(LOCATION_EXTRA)) and c:IsPandemoniumActivatable(tp,tp,true,false,false,false,eg,ep,ev,re,r,rp) end function s.pltg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingMatchingCard(s.plfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil,e,tp,eg,ep,ev,re,r,rp) end end function s.plop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and e:GetHandler():IsRelateToEffect(e) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.plfilter),tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,1,nil,e,tp,eg,ep,ev,re,r,rp) if #g<=0 then return end aux.PandAct(g:GetFirst())(e,tp,eg,ep,ev,re,r,rp) local te=g:GetFirst():GetActivateEffect() te:UseCountLimit(tp,1,true) local tep=g:GetFirst():GetControler() local cost=te:GetCost() if cost then cost(te,tep,eg,ep,ev,re,r,rp,1) end end end