--Aircaster Horizon --created by Alastar Rainford, originally coded by Lyris local s,id=GetID() function s.initial_effect(c) --activate local e0=Effect.CreateEffect(c) e0:Desc(0) e0:SetType(EFFECT_TYPE_ACTIVATE) e0:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e0) --protection local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT) e1:SetRange(LOCATION_FZONE) e1:SetTargetRange(LOCATION_ONFIELD,LOCATION_ONFIELD) e1:SetTarget(s.indtg) e1:SetValue(s.indval) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:Desc(1) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_FZONE) e2:OPT() e2:SetTarget(s.sptg2) e2:SetOperation(s.spop2) c:RegisterEffect(e2) --equip local e4=Effect.CreateEffect(c) e4:Desc(2) e4:SetCategory(CATEGORY_EQUIP) e4:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_O) e4:SetProperty(EFFECT_FLAG_DELAY|EFFECT_FLAG_CARD_TARGET) e4:SetCode(EVENT_DESTROYED) e4:SetCondition(s.con) e4:SetTarget(s.eqtg) e4:SetOperation(s.eqop) c:RegisterEffect(e4) end function s.indtg(e,c) return c:IsSpell(TYPE_EQUIP) and c:IsSetCard(ARCHE_AIRCASTER) end function s.indval(e,re,r,rp) if r&REASON_EFFECT~=0 then return 1 else return 0 end end function s.spfilter(c,e,tp) return c:IsFaceup() and c:IsSetCard(ARCHE_AIRCASTER) and c:IsOriginalType(TYPE_MONSTER) and c:IsSpell(TYPE_EQUIP) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.sptg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_SZONE) and chkc:IsControler(tp) and s.spfilter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(s.spfilter,tp,LOCATION_SZONE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,s.spfilter,tp,LOCATION_SZONE,0,1,1,nil,e,tp) Duel.SetCardOperationInfo(g,CATEGORY_SPECIAL_SUMMON) end function s.spop2(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToChain() then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) end end function s.con(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousPosition(POS_FACEUP) end function s.filter(c,tp) return c:IsFaceup() and c:IsSetCard(ARCHE_AIRCASTER) and Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_DECK,0,1,nil,tp) end function s.filter2(c,tp) return c:IsSetCard(ARCHE_AIRCASTER) and c:IsType(TYPE_MONSTER) and c:CheckUniqueOnField(tp,LOCATION_SZONE) and not c:IsForbidden() end function s.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingTarget(s.filter,tp,LOCATION_MZONE,0,1,nil,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,s.filter,tp,LOCATION_MZONE,0,1,1,nil,tp) Duel.SetOperationInfo(0,CATEGORY_EQUIP,nil,1,tp,LOCATION_DECK) end function s.eqop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end local tc=Duel.GetFirstTarget() if tc and tc:IsFaceup() and tc:IsRelateToChain() and tc:IsSetCard(ARCHE_AIRCASTER) and tc:IsControler(tp) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) local g=Duel.SelectMatchingCard(tp,s.filter2,tp,LOCATION_DECK,0,1,1,tc,tp) if #g>0 then Duel.EquipToOtherCardAndRegisterLimit(e,tp,g:GetFirst(),tc,true) end end end