--Psychostizia Comandante --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) --pandemonium aux.AddOrigPandemoniumType(c) --activate local p1=Effect.CreateEffect(c) p1:GLString(0) p1:SetCategory(CATEGORY_SPECIAL_SUMMON) p1:SetType(EFFECT_TYPE_QUICK_O) p1:SetCode(EVENT_FREE_CHAIN) p1:SetRange(LOCATION_SZONE) p1:SetCondition(s.actcon) p1:SetTarget(s.acttg) p1:SetOperation(s.actop) c:RegisterEffect(p1) aux.EnablePandemoniumAttribute(c,p1,true,TYPE_PANDEMONIUM+TYPE_EFFECT,false,false,1,false,true) --big bang local p2=Effect.CreateEffect(c) p2:GLString(1) p2:SetCategory(CATEGORY_SPECIAL_SUMMON) p2:SetType(EFFECT_TYPE_QUICK_O) p2:SetCode(EVENT_FREE_CHAIN) p2:SetRange(LOCATION_SZONE) p2:SetCountLimit(1,id) p2:SetCondition(s.sccon) p2:SetTarget(s.sctg) p2:SetOperation(s.scop) c:RegisterEffect(p2) --to hand local e2=Effect.CreateEffect(c) e2:GLString(2) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_CAL) e2:SetCode(EVENT_SUMMON_SUCCESS) e2:SetCountLimit(1,id+100) e2:SetCondition(s.spcon) e2:SetCost(s.spcost) e2:SetTarget(s.sptg) e2:SetOperation(s.spop) c:RegisterEffect(e2) local e2x=e2:Clone() e2x:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e2x) --draw local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,3)) e3:SetCategory(CATEGORY_DRAW) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e3:SetCode(EVENT_DESTROYED) e3:SetCountLimit(1,id+200) e3:SetCondition(s.spcon2) e3:SetCost(s.spcost2) e3:SetTarget(s.sptg2) e3:SetOperation(s.spop2) c:RegisterEffect(e3) end function s.actcon(e,tp,eg,ep,ev,re,r,rp) return e:IsHasType(EFFECT_TYPE_ACTIVATE) and aux.PandActCheck(e) and s.acttg(e,tp,eg,ep,ev,re,r,rp,0) end function s.acttg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsPlayerCanSpecialSummonMonster(tp,id,0x2c2,TYPE_MONSTER+TYPE_EFFECT+TYPE_PANDEMONIUM,1200,1750,3,RACE_PSYCHO,ATTRIBUTE_LIGHT) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function s.actop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) or Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 or not Duel.IsPlayerCanSpecialSummonMonster(tp,id,0x2c2,TYPE_MONSTER+TYPE_EFFECT+TYPE_PANDEMONIUM,1200,1750,3,RACE_PSYCHO,ATTRIBUTE_LIGHT) then return end c:AddMonsterAttribute(TYPE_EFFECT+TYPE_PANDEMONIUM) Duel.SpecialSummon(c,0,tp,tp,true,false,POS_FACEUP) end function s.bbfilter(c,e,tp,mg) if not c:IsType(TYPE_BIGBANG) or not c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_BIGBANG,tp,false,false) or Duel.GetLocationCountFromEx(tp,tp,mg,c)<=0 then return false end local et=global_card_effect_table[c] for _,e in ipairs(et) do if e:GetCode()==EFFECT_SPSUMMON_PROC then local ev=e:GetValue() local ec=e:GetCondition() if ev and (aux.GetValueType(ev)=="function" and ev(ef,c)&340==340 or ev&340==340) and (not ec or ec(e,c,mg)) then return true end end end return false end function s.sccon(e,tp,eg,ep,ev,re,r,rp) return Duel.IsMainPhase() and aux.PandActCheck(e) end function s.sctg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local mg=Duel.GetMatchingGroup(Card.IsRace,tp,LOCATION_MZONE,0,nil,RACE_PSYCHO) return #mg>0 and Duel.IsExistingMatchingCard(s.bbfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.scop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local mg=Duel.GetMatchingGroup(Card.IsRace,tp,LOCATION_MZONE,0,nil,RACE_PSYCHO) if #mg<=0 then return end local g=Duel.GetMatchingGroup(s.bbfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg) if g:GetCount()>0 then local eid=e:GetFieldID() for tc in aux.Next(mg) do tc:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD,EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_SET_AVAILABLE,1,eid) end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_BE_BIGBANG_MATERIAL) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_SET_AVAILABLE) e1:SetTargetRange(0xff,0xff) e1:SetTarget(s.limitmat) e1:SetLabel(eid) e1:SetValue(1) local e1x=e1:Clone() bigbang_limit_mats_condition = e1 bigbang_limit_mats_operation = e1x Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=g:Select(tp,1,1,nil) Duel.SpecialSummonRule(tp,sg:GetFirst()) if Duel.SetSummonCancelable then Duel.SetSummonCancelable(false) end end end function s.limitmat(e,c) return c:GetFlagEffect(id)<=0 or c:GetFlagEffectLabel(id)~=e:GetLabel() end function s.spcon(e) return not e:GetHandler():IsStatus(STATUS_CHAINING) end function s.costfilter(c,e,tp) return c:IsDestructable(e,REASON_COST,tp) and c:IsSetCard(0x2c2) and c:IsFaceupEx() and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,c,e,tp,c) end function s.spfilter(c,e,tp,mc) local mg=Group.FromCards(e:GetHandler(),c) return c:IsFaceup() and c:IsType(TYPE_MONSTER) and c:IsSetCard(0x2c2) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,mc,c)>0 and Duel.IsExistingMatchingCard(s.bbfilter,tp,LOCATION_EXTRA,0,1,mg,e,tp,mg) end function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.costfilter,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,e:GetHandler(),e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectMatchingCard(tp,s.costfilter,tp,LOCATION_HAND+LOCATION_ONFIELD,0,1,1,e:GetHandler(),e,tp) if #g>0 then Duel.Destroy(g,REASON_COST) end end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanSpecialSummonCount(tp,2) and (e:IsCostChecked() or Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,nil)) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_EXTRA,0,1,1,e:GetHandler(),e,tp,nil) if #g>0 and Duel.SpecialSummon(g:GetFirst(),0,tp,tp,false,false,POS_FACEUP)>0 and c:IsRelateToEffect(e) then Duel.RaiseEvent(c,EVENT_ADJUST,nil,0,PLAYER_NONE,PLAYER_NONE,0) local mg=Group.FromCards(c,g:GetFirst()) if mg:FilterCount(Card.IsLocation,nil,LOCATION_MZONE)~=2 then return end local bg=Duel.GetMatchingGroup(s.bbfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg) if #bg>0 then local eid=e:GetFieldID() for tc in aux.Next(mg) do tc:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD,EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_SET_AVAILABLE,1,eid) end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_BE_BIGBANG_MATERIAL) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_SET_AVAILABLE) e1:SetTargetRange(0xff,0xff) e1:SetTarget(s.limitmat) e1:SetLabel(eid) e1:SetValue(1) bigbang_limit_mats_operation = e1 Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=bg:Select(tp,1,1,nil) Duel.SpecialSummonRule(tp,sg:GetFirst()) if Duel.SetSummonCancelable then Duel.SetSummonCancelable(false) end end end end function s.spcon2(e,tp,eg,ep,ev,re,r,rp) return r&REASON_BATTLE==0 end function s.spcost2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDestructable,tp,LOCATION_HAND,0,1,nil,e,REASON_COST,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectMatchingCard(tp,Card.IsDestructable,tp,LOCATION_HAND,0,1,1,nil,e,REASON_COST,tp) if #g>0 then Duel.Destroy(g,REASON_COST) end end function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and e:GetHandler():IsPandemoniumActivatable(tp,tp,true,false,false,false,eg,ep,ev,re,r,rp) end Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function s.spop2(e,tp,eg,ep,ev,re,r,rp) if Duel.Draw(tp,1,REASON_EFFECT)>0 and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and e:GetHandler():IsRelateToEffect(e) and e:GetHandler():IsPandemoniumActivatable(tp,tp,true,false,false,false,eg,ep,ev,re,r,rp) then Duel.BreakEffect() aux.PandAct(e:GetHandler())(e,tp,eg,ep,ev,re,r,rp) local te=e:GetHandler():GetActivateEffect() te:UseCountLimit(tp,1,true) local tep=e:GetHandler():GetControler() local cost=te:GetCost() if cost then cost(te,tep,eg,ep,ev,re,r,rp,1) end end end