--Scarlet Enigma - Paladin function c249000649.initial_effect(c) --spsummon local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_CUSTOM+249000649) e1:SetRange(LOCATION_HAND) e1:SetCondition(c249000649.condition) e1:SetTarget(c249000649.target) e1:SetOperation(c249000649.operation) c:RegisterEffect(e1) --ATK change battle local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_ATTACK_ANNOUNCE) e2:SetRange(LOCATION_MZONE) e2:SetCondition(c249000649.drcon) e2:SetTarget(c249000649.drtg) e2:SetOperation(c249000649.drop) c:RegisterEffect(e2) --destroy local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetCategory(CATEGORY_DESTROY) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetRange(LOCATION_MZONE) e3:SetCountLimit(1) e3:SetTarget(c249000649.destg) e3:SetOperation(c249000649.desop) c:RegisterEffect(e3) --ATK change spsummon local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(30914564,0)) e4:SetCategory(CATEGORY_DRAW) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e4:SetCode(EVENT_SPSUMMON_SUCCESS) e4:SetCondition(c249000649.drcon2) e4:SetTarget(c249000649.drtg) e4:SetOperation(c249000649.drop) c:RegisterEffect(e4) if not c249000649.global_check then c249000649.global_check=true c249000649[0]=0 c249000649[1]=0 local ge1=Effect.CreateEffect(c) ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge1:SetCode(EVENT_ATTACK_ANNOUNCE) ge1:SetOperation(c249000649.check) Duel.RegisterEffect(ge1,0) local ge2=Effect.CreateEffect(c) ge2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge2:SetCode(EVENT_ATTACK_DISABLED) ge2:SetOperation(c249000649.check2) Duel.RegisterEffect(ge2,0) local ge3=Effect.CreateEffect(c) ge3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge3:SetCode(EVENT_PHASE_START+PHASE_DRAW) ge3:SetOperation(c249000649.clear) Duel.RegisterEffect(ge3,0) end end function c249000649.check(e,tp,eg,ep,ev,re,r,rp) local tc=eg:GetFirst() if Duel.GetAttackTarget()==nil then c249000649[1-tc:GetControler()]=c249000649[1-tc:GetControler()]+1 if c249000649[1-tc:GetControler()]==1 then c249000649[2]=tc tc:RegisterFlagEffect(249000649,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1) elseif c249000649[1-tc:GetControler()]==2 then Duel.RaiseEvent(tc,EVENT_CUSTOM+249000649,e,0,0,0,0) end end end function c249000649.check2(e,tp,eg,ep,ev,re,r,rp) local tc=eg:GetFirst() if tc:GetFlagEffect(249000649)~=0 and Duel.GetAttackTarget()~=nil then c249000649[1-tc:GetControler()]=c249000649[1-tc:GetControler()]-1 end end function c249000649.clear(e,tp,eg,ep,ev,re,r,rp) c249000649[0]=0 c249000649[1]=0 end function c249000649.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()~=tp and Duel.GetAttackTarget()==nil and c249000649[tp]==2 end function c249000649.target(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0) end function c249000649.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end if Duel.SpecialSummon(c,1,tp,tp,false,false,POS_FACEUP)==0 and Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) then Duel.SendtoGrave(c,REASON_RULE) end end function c249000649.drcon(e,tp,eg,ep,ev,re,r,rp) return (e:GetHandler()==Duel.GetAttacker() and Duel.GetAttackTarget()~=nil) or e:GetHandler()==Duel.GetAttackTarget() end function c249000649.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c249000649.drop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local ct=Duel.Draw(tp,1,REASON_EFFECT) if ct==0 then return end local dc=Duel.GetOperatedGroup():GetFirst() if dc:GetLevel() > 0 and c:IsFaceup() and c:IsRelateToEffect(e) and Duel.SelectYesNo(tp,526) then Duel.BreakEffect() Duel.ConfirmCards(1-tp,dc) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetValue(dc:GetLevel()*200) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) c:RegisterEffect(e1) Duel.ShuffleHand(tp) end end function c249000649.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) end if chk==0 then return Duel.IsExistingTarget(aux.TRUE,tp,0,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,aux.TRUE,tp,0,LOCATION_ONFIELD,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c249000649.desop(e,tp,eg,ep,ev,re,r,rp) local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS) local g=tg:Filter(Card.IsRelateToEffect,nil,e) if g:GetCount()>0 then Duel.Destroy(g,REASON_EFFECT) end end function c249000649.drcon2(e,tp,eg,ep,ev,re,r,rp) local ph=Duel.GetCurrentPhase() return ph>=PHASE_BATTLE_START and ph<=PHASE_BATTLE end