--Astralost Balancer local ref,id=GetID() Duel.LoadScript("Astralost.lua") function ref.initial_effect(c) --xyz summon c:EnableReviveLimit() aux.AddXyzProcedureLevelFree(c,ref.mfilter,ref.xyzcheck,2,2) --Burn Astralost.EnableHealCounter() local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DAMAGE) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetRange(LOCATION_MZONE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetHintTiming(0,TIMING_END_PHASE) e1:SetCountLimit(1,id) e1:SetCost(ref.damcost) e1:SetTarget(ref.damtg) e1:SetOperation(ref.damop) c:RegisterEffect(e1) --Float local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE) e2:SetCode(EVENT_LEAVE_FIELD) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCountLimit(1,id,1) e2:SetCondition(ref.ss1con) e2:SetTarget(ref.sstg) e2:SetOperation(ref.ssop) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_FIELD) e3:SetRange(LOCATION_MZONE) e3:SetCondition(ref.ss2con) c:RegisterEffect(e3) end --Xyz function ref.mfilter(c,xyzc) return c:IsXyzType(TYPE_MONSTER) and c:IsXyzLevel(xyzc,3) end function ref.xyzcheck(g) return g:GetClassCount(Card.GetRace)==#g end --Burn function ref.damcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function ref.damtg(e,tp,eg,ep,ev,re,r,rp,chk) local val=Astralost.GetHealCount(1-tp)*2 if chk==0 then return val>0 end Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(val) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,val) end function ref.setfilter(c) return Astralost.Is(c) and c:IsType(TYPE_FIELD) and c:IsSSetable() end function ref.damop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) if Duel.Damage(p,d,REASON_EFFECT)>0 and Duel.IsExistingMatchingCard(ref.setfilter,tp,LOCATION_DECK,0,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(id,0)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET) local g=Duel.SelectMatchingCard(tp,ref.setfilter,tp,LOCATION_DECK,0,1,1,nil) if #g>0 then Duel.SSet(tp,g) end end end function ref.ss1con(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsPreviousPosition(POS_FACEUP) and c:IsType(TYPE_MONSTER) and c:IsPreviousLocation(LOCATION_ONFIELD) end function ref.sscfilter(c,tp) return c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousControler()==tp and c:IsType(TYPE_MONSTER) and c:IsPreviousLocation(LOCATION_ONFIELD) end function ref.ss2con(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(ref.sscfilter,1,nil,tp) end function ref.ssfilter(c,e,tp) return Astralost.Is(c) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function ref.sstg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(ref.ssfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function ref.ssop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,ref.ssfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if #g>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end end