local m=11110107 local cm=_G["c"..m] cm.name="Garleth, Crown Prince of Ichyaltas" function cm.initial_effect(c) aux.AddSynchroProcedure(c,nil,aux.NonTuner(Card.IsSetCard,0x2a7),1) c:EnableReviveLimit() local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,m) e1:SetTarget(cm.sptg) e1:SetOperation(cm.spop) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetRange(LOCATION_MZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetTarget(cm.tg) e2:SetValue(cm.val) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_GRAVE) e3:SetCost(cm.spselfcost) e3:SetTarget(cm.spselftg) e3:SetOperation(cm.spselfop) c:RegisterEffect(e3) end function cm.spfilter(c,e,tp) return c:IsSetCard(0x2a7) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and cm.spfilter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(cm.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,cm.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function cm.spop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) end end function cm.filter(c) return c:IsFaceup() and c:IsSetCard(0x2a7) end function cm.tg(e,c) return c~=e:GetHandler() end function cm.val(e,c) return Duel.GetMatchingGroupCount(cm.filter,c:GetControler(),LOCATION_MZONE,0,nil)*200 end function cm.rfilter(c,tp) return c:IsSetCard(0x2a7) and (c:IsControler(tp) or c:IsFaceup()) end function cm.spselfcost(e,tp,eg,ep,ev,re,r,rp,chk) local rg=Duel.GetReleaseGroup(tp):Filter(cm.rfilter,nil,tp) if chk==0 then return rg:CheckSubGroup(aux.mzctcheckrel,2,2,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) local g=rg:SelectSubGroup(tp,aux.mzctcheckrel,false,2,2,tp) Duel.Release(g,REASON_COST) end function cm.spselftg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function cm.spselfop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)~=0 then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_REDIRECT) e1:SetValue(LOCATION_REMOVED) c:RegisterEffect(e1,true) end end