--[[ Crystarion Ascendant - Pillar of Emerald Cristarione Ascendente - Pilastro di Smeraldo Card Author: CeruleanZerry Scripted by: XGlitchy30 ]] local s,id=GetID() function s.initial_effect(c) aux.EnableExtraDeckSummonCountLimit() c:EnableReviveLimit() --[[While you have an Engaged "Crystarion" Drive Monster, this card cannot be targeted by your opponent's card effects.]] local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e1:SetCondition(s.imcon) e1:SetValue(aux.tgoval) c:RegisterEffect(e1) --If this card is Ritual Summoned: You can Special Summon 1 "Crystarion" monster from your Deck, but you can only Special Summon once from the Extra Deck for the rest of this turn. local e2=Effect.CreateEffect(c) e2:Desc(0) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:HOPT() e2:SetFunctions(aux.RitualSummonedCond,nil,s.sptg,s.spop) c:RegisterEffect(e2) --[[When a card or effect is activated that would change an Engaged Drive Monster(s)'s Energy (except during the Damage Step) (Quick Effect): You can target 1 card on the field; destroy it, and if you do, draw 1 card]] local e3=Effect.CreateEffect(c) e3:Desc(1) e3:SetCategory(CATEGORY_DESTROY|CATEGORY_DRAW) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetCode(EVENT_CHAINING) e3:SetRange(LOCATION_MZONE) e3:HOPT() e3:SetRelevantTimings() e3:SetFunctions(s.condition,nil,s.target,s.operation) c:RegisterEffect(e3) end --E1 function s.imcon(e) local en=Duel.GetEngagedCard(e:GetHandlerPlayer()) return en and en:IsMonster(TYPE_DRIVE) and en:IsSetCard(ARCHE_CRYSTARION) end --E2 function s.spfilter(c,e,tp) return c:IsSetCard(ARCHE_CRYSTARION) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function s.spop(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,s.spfilter,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 local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetTargetRange(1,0) e1:SetTarget(s.splimit) e1:SetReset(RESET_PHASE|PHASE_END) Duel.RegisterEffect(e1,tp) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_CONTINUOUS|EFFECT_TYPE_FIELD) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetOperation(s.checkop) e2:SetReset(RESET_PHASE|PHASE_END) Duel.RegisterEffect(e2,tp) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e3:SetCode(92345028) e3:SetTargetRange(1,0) e3:SetReset(RESET_PHASE|PHASE_END) Duel.RegisterEffect(e3,tp) Duel.RegisterHint(tp,id,nil,nil,id,2) end function s.splimit(e,c,sump,sumtype,sumpos,targetp,se) return c:IsLocation(LOCATION_EXTRA) and aux.ExtraDeckSummonCountLimit[sump]<=0 end function s.cfilter(c,tp) return c:IsSummonPlayer(tp) and c:IsPreviousLocation(LOCATION_EXTRA) end function s.checkop(e,tp,eg,ep,ev,re,r,rp) if eg:IsExists(s.cfilter,1,nil,tp) then aux.ExtraDeckSummonCountLimit[tp]=aux.ExtraDeckSummonCountLimit[tp]-1 end if eg:IsExists(s.cfilter,1,nil,1-tp) then aux.ExtraDeckSummonCountLimit[1-tp]=aux.ExtraDeckSummonCountLimit[1-tp]-1 end end --E3 function s.condition(e,tp,eg,ep,ev,re,r,rp) local tabs1=Duel.GetCustomOperationInfo(ev,CATEGORY_UPDATE_ENERGY) local tabs2=Duel.GetCustomOperationInfo(ev,CATEGORY_CHANGE_ENERGY) local tabs3=Duel.GetCustomOperationInfo(ev,CATEGORY_RESET_ENERGY) local ct1=tabs1 and #tabs1 or 0 local ct2=tabs2 and #tabs2 or 0 local ct3=tabs3 and #tabs3 or 0 return ct1+ct2+ct3>0 end function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() end if chk==0 then return Duel.IsExistingTarget(nil,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) and Duel.IsPlayerCanDraw(tp,1) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,nil,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,tp,LOCATION_ONFIELD) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function s.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToChain() and Duel.Destroy(tc,REASON_EFFECT)>0 then Duel.Draw(tp,1,REASON_EFFECT) end end