--Geargiagal --Script by: XGlitchy30 local cid,id=GetID() function cid.initial_effect(c) --spsummon self local e1=Effect.CreateEffect(c) e1:GLString(0) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_POSITION) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_HAND) e1:SetCountLimit(1,id) e1:SetCondition(cid.spcon) e1:SetTarget(cid.sptg) e1:SetOperation(cid.spop) c:RegisterEffect(e1) --summon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,2)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_POSITION) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,id+100) e2:SetCost(cid.cost) e2:SetTarget(cid.target) e2:SetOperation(cid.operation) c:RegisterEffect(e2) --search local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,4)) e3:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetProperty(EFFECT_FLAG_DELAY) e3:SetCode(EVENT_FLIP) e3:SetCountLimit(1,id+200) e3:SetTarget(cid.shtg) e3:SetOperation(cid.shop) c:RegisterEffect(e3) Duel.AddCustomActivityCounter(id,ACTIVITY_SPSUMMON,cid.counterfilter) end function cid.counterfilter(c) return c:IsSetCard(0x72) end --SPSUMMON SELF function cid.cfilter(c) return c:IsFaceup() and not c:IsRace(RACE_MACHINE) end function cid.spcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0 or not Duel.IsExistingMatchingCard(cid.cfilter,tp,LOCATION_MZONE,0,1,nil) end function cid.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function cid.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsRelateToEffect(e) then if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)>0 and Duel.IsExistingMatchingCard(Card.IsFacedown,tp,LOCATION_MZONE,0,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(id,1)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_POSCHANGE) local g=Duel.SelectMatchingCard(tp,Card.IsFacedown,tp,LOCATION_MZONE,0,1,1,nil) if #g>=0 then Duel.HintSelection(g) Duel.ChangePosition(g,POS_FACEUP_ATTACK,POS_FACEUP_ATTACK,POS_FACEUP_DEFENSE,POS_FACEUP_DEFENSE) end end end local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetTarget(cid.splimit) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function cid.splimit(e,c) return c:IsLocation(LOCATION_EXTRA) and not c:IsType(TYPE_XYZ) end --SPSUMMON function cid.costfilter(c,e,tp) return c:IsRace(RACE_MACHINE) and Duel.IsExistingMatchingCard(cid.spfilter,tp,LOCATION_DECK,0,1,c,e,tp) and Duel.GetMZoneCount(tp,c)>0 and (c:IsLocation(LOCATION_HAND) or c:IsFaceup()) end function cid.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroupEx(tp,cid.costfilter,1,e:GetHandler(),e,tp) and Duel.GetCustomActivityCount(id,tp,ACTIVITY_SPSUMMON)==0 end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetTargetRange(1,0) e1:SetTarget(cid.sumlimit) Duel.RegisterEffect(e1,tp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) local g=Duel.SelectReleaseGroupEx(tp,cid.costfilter,1,1,e:GetHandler(),e,tp) Duel.Release(g,REASON_COST) end function cid.sumlimit(e,c,sump,sumtype,sumpos,targetp,se) return not cid.counterfilter(c) end function cid.spfilter(c,e,tp) return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x72) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cid.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function cid.posfilter(c) return c:IsFaceup() and c:IsType(TYPE_MONSTER) and c:IsCanTurnSet() end function cid.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,cid.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if g:GetCount()>0 and Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)>0 and e:GetHandler():IsLocation(LOCATION_MZONE) and e:GetHandler():IsFaceup() and e:GetHandler():IsCanTurnSet() and Duel.IsExistingMatchingCard(cid.posfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,e:GetHandler()) and Duel.SelectYesNo(tp,aux.Stringid(id,3)) then Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local sg=Duel.SelectMatchingCard(tp,cid.posfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,e:GetHandler()) sg:AddCard(e:GetHandler()) if #sg==2 then Duel.HintSelection(sg) Duel.ChangePosition(sg,POS_FACEDOWN_DEFENSE) end end end --SEARCH function cid.filter(c,tp) return c:IsType(TYPE_MONSTER) and c:IsRace(RACE_MACHINE) and c:IsLevel(3,4) and not c:IsCode(id) and c:IsAbleToHand() and Duel.IsExistingMatchingCard(cid.attrfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,c:GetAttribute()) end function cid.attrfilter(c,attr) return c:IsFaceup() and c:IsType(TYPE_MONSTER) and c:IsAttribute(attr) end function cid.shtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.filter,tp,LOCATION_DECK,0,1,nil,tp) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function cid.shop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cid.filter,tp,LOCATION_DECK,0,1,1,nil,tp) if g:GetCount()>0 and Duel.SendtoHand(g,nil,REASON_EFFECT)>0 and g:GetFirst():IsLocation(LOCATION_HAND) then Duel.ConfirmCards(1-tp,g) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetTarget(cid.aclimit) e1:SetLabel(g:GetFirst():GetCode()) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end end function cid.aclimit(e,re,tp) return re:GetHandler():IsCode(e:GetLabel()) and re:IsActiveType(TYPE_MONSTER) end