--the guild of heroes function c249001185.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetOperation(c249001185.activate) c:RegisterEffect(e1) --cannot be target local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e2:SetRange(LOCATION_MZONE) e2:SetCondition(c249001185.tgcon) e2:SetValue(aux.tgoval) c:RegisterEffect(e2) --act limit local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e3:SetCode(EVENT_CHAINING) e3:SetRange(LOCATION_FZONE) e3:SetOperation(c249001185.chainop) c:RegisterEffect(e3) --material local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(19310321,0)) e4:SetProperty(EFFECT_FLAG_CARD_TARGET) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_FZONE) e4:SetCountLimit(1) e4:SetTarget(c249001185.target) e4:SetOperation(c249001185.operation) c:RegisterEffect(e4) end function c249001185.filter(c) return c:IsSetCard(0x22E) and c:IsAbleToHand() and not c:IsCode(249001185) end function c249001185.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(c249001185.filter,tp,LOCATION_DECK,0,nil) if g:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(57103969,0)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:Select(tp,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end end function c249001185.tgfilter(c) return c:IsFaceup() and c:IsSetCard(0x22E) end function c249001185.tgcon(e) return Duel.IsExistingMatchingCard(c249001185.tgfilter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil) end function c249001185.chainop(e,tp,eg,ep,ev,re,r,rp) local rc=re:GetHandler() if rc:IsSetCard(0x22E) and re:IsActiveType(TYPE_SPELL) and rc~=e:GetHandler() then Duel.SetChainLimit(c249001185.chainlm) end end function c249001185.chainlm(e,rp,tp) return tp==rp end function c249001185.filter2(c) return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:IsSetCard(0x22E) end function c249001185.filter3(c) return c:IsSetCard(0x22E) and c:IsCanOverlay() and (c:IsFaceup() or not c:IsLocation(LOCATION_REMOVED)) end function c249001185.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end if chk==0 then return Duel.IsExistingTarget(c249001185.filter2,tp,LOCATION_MZONE,0,1,nil) and Duel.IsExistingTarget(c249001185.filter3,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(19310321,1)) local g1=Duel.SelectTarget(tp,c249001185.filter2,tp,LOCATION_MZONE,0,1,1,nil) e:SetLabelObject(g1:GetFirst()) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) local g2=Duel.SelectTarget(tp,c249001185.filter3,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,1,nil) if g2:GetFirst():IsLocation(LOCATION_GRAVE) then Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,g2,2,0,0) end end function c249001185.operation(e,tp,eg,ep,ev,re,r,rp) local tc=e:GetLabelObject() if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:IsImmuneToEffect(e) then return end local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,tc,e) if g:GetCount()>0 then Duel.Overlay(tc,g) end end