--Cavaliere del Cielo Brakadiano Ametistalancia --Scripted by: XGlitchy30 local s,id = GetID() function s.initial_effect(c) aux.EnablePendulumAttribute(c,false) aux.AddSynchroProcedure(c,aux.FilterBoolFunction(Card.IsRace,RACE_DRAGON),aux.NonTuner(aux.FilterBoolFunction(Card.IsSetCard,0xb48)),1,1) c:EnableReviveLimit() --immune local p1=Effect.CreateEffect(c) p1:SetType(EFFECT_TYPE_FIELD) p1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE) p1:SetRange(LOCATION_PZONE) p1:SetTargetRange(LOCATION_MZONE,0) p1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0xb48)) p1:SetValue(1) c:RegisterEffect(p1) --Special summon from the pendulum zone local p2=Effect.CreateEffect(c) p2:SetDescription(aux.Stringid(id,0)) p2:SetCategory(CATEGORY_SPECIAL_SUMMON) p2:SetType(EFFECT_TYPE_IGNITION) p2:SetRange(LOCATION_PZONE) p2:SetCountLimit(1,id) p2:SetCost(s.spcost) p2:SetTarget(s.sptg) p2:SetOperation(s.spop) c:RegisterEffect(p2) --DEF attack local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_PIERCE) e1:SetValue(1) c:RegisterEffect(e1) --ss local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,1)) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,id+100) e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE) e1:SetTarget(s.destg) e1:SetOperation(s.desop) c:RegisterEffect(e1) --place local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,2)) e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_DESTROYED) e3:SetCountLimit(1,id+200) e3:SetCondition(s.dscon) e3:SetCost(s.dscost) e3:SetTarget(s.dstg) e3:SetOperation(s.dsop) c:RegisterEffect(e3) end function s.cf(c,tp) return c:IsFaceup() and c:IsMonster() and c:IsAttribute(ATTRIBUTE_WATER) and c:IsRace(RACE_DRAGON) and Duel.GetMZoneCount(tp,c)>0 and c:IsAbleToRemoveAsCost() end function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.IsExistingMatchingCard(s.cf,tp,LOCATION_MZONE,0,1,nil,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,s.cf,tp,LOCATION_MZONE,0,1,1,nil,tp) if #g>0 then Duel.Remove(g,POS_FACEUP,REASON_COST) end end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function s.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 Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end end function s.damtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local dam=e:GetHandler():GetBattleTarget():GetBaseAttack() if dam<0 then dam=0 end Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(dam) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,dam) end function s.damop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Damage(p,d,REASON_EFFECT) end function s.desfilter(c) return c:IsFaceup() and c:IsSetCard(0xb48) end function s.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.desfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(s.desfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,s.desfilter,tp,LOCATION_MZONE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,#g,0,0) end function s.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)~=0 then local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_FIELD) e2:SetProperty(EFFECT_FLAG_SET_AVAILABLE) e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e2:SetTargetRange(LOCATION_ALL,0) e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0xb48)) e2:SetValue(1) e2:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e2,tp) end end function s.dscon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_EFFECT) and e:GetHandler():IsPreviousLocation(LOCATION_MZONE) and e:GetHandler():GetPreviousControler()==tp end function s.thf(c) return c:IsFaceup() and c:IsSetCard(0xb48) and c:IsAbleToHandAsCost() end function s.dscost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.thf,tp,LOCATION_PZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g=Duel.SelectMatchingCard(tp,s.thf,tp,LOCATION_PZONE,0,1,1,nil) if #g>0 then Duel.SendtoHand(g,tp,REASON_COST) end end function s.dstg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end if e:GetHandler():IsLocation(LOCATION_GRAVE) then Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,e:GetHandler(),1,0,0) end end function s.dsop(e,tp,eg,ep,ev,re,r,rp) if not Duel.CheckLocation(tp,LOCATION_PZONE,0) and not Duel.CheckLocation(tp,LOCATION_PZONE,1) then return end local c=e:GetHandler() if c:IsRelateToEffect(e) then if c:IsLocation(LOCATION_GRAVE) and c:IsHasEffect(EFFECT_NECRO_VALLEY) and not c:IsHasEffect(EFFECT_NECRO_VALLEY_IM) then return end Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) end end